@volcengine/veplayer-plugin 2.12.0-rc.1 → 2.12.0-rc.2

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.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).__VEPLAYER_PLUGIN_HLSJS__={})}(this,(function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n={exports:{}},a=function(e){return e&&e.Math==Math&&e},s=a("object"==typeof globalThis&&globalThis)||a("object"==typeof window&&window)||a("object"==typeof self&&self)||a("object"==typeof r&&r)||function(){return this}()||r||Function("return this")(),o=function(e){try{return!!e()}catch(t){return!0}},l=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),u=l,c=Function.prototype,h=c.apply,d=c.call,f="object"==typeof Reflect&&Reflect.apply||(u?d.bind(h):function(){return d.apply(h,arguments)}),v=l,g=Function.prototype,p=g.call,m=v&&g.bind.bind(p,p),y=v?m:function(e){return function(){return p.apply(e,arguments)}},E=y,k=E({}.toString),T=E("".slice),S=function(e){return T(k(e),8,-1)},A=S,L=y,b=function(e){if("Function"===A(e))return L(e)},R="object"==typeof document&&document.all,I={all:R,IS_HTMLDDA:void 0===R&&void 0!==R},D=I.all,_=I.IS_HTMLDDA?function(e){return"function"==typeof e||e===D}:function(e){return"function"==typeof e},w={},C=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),P=l,x=Function.prototype.call,M=P?x.bind(x):function(){return x.apply(x,arguments)},O={},F={}.propertyIsEnumerable,N=Object.getOwnPropertyDescriptor,U=N&&!F.call({1:2},1);O.f=U?function(e){var t=N(this,e);return!!t&&t.enumerable}:F;var B,G,K=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},H=o,V=S,j=Object,Y=y("".split),q=H((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==V(e)?Y(e,""):j(e)}:j,W=function(e){return null==e},z=W,X=TypeError,Q=function(e){if(z(e))throw X("Can't call method on "+e);return e},$=q,J=Q,Z=function(e){return $(J(e))},ee=_,te=I.all,re=I.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:ee(e)||e===te}:function(e){return"object"==typeof e?null!==e:ee(e)},ie={},ne=ie,ae=s,se=_,oe=function(e){return se(e)?e:void 0},le=function(e,t){return arguments.length<2?oe(ne[e])||oe(ae[e]):ne[e]&&ne[e][t]||ae[e]&&ae[e][t]},ue=y({}.isPrototypeOf),ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",he=s,de=ce,fe=he.process,ve=he.Deno,ge=fe&&fe.versions||ve&&ve.version,pe=ge&&ge.v8;pe&&(G=(B=pe.split("."))[0]>0&&B[0]<4?1:+(B[0]+B[1])),!G&&de&&(!(B=de.match(/Edge\/(\d+)/))||B[1]>=74)&&(B=de.match(/Chrome\/(\d+)/))&&(G=+B[1]);var me=G,ye=me,Ee=o,ke=s.String,Te=!!Object.getOwnPropertySymbols&&!Ee((function(){var e=Symbol();return!ke(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ye&&ye<41})),Se=Te&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ae=le,Le=_,be=ue,Re=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=Ae("Symbol");return Le(t)&&be(t.prototype,Re(e))},De=String,_e=function(e){try{return De(e)}catch(t){return"Object"}},we=_,Ce=_e,Pe=TypeError,xe=function(e){if(we(e))return e;throw Pe(Ce(e)+" is not a function")},Me=xe,Oe=W,Fe=function(e,t){var r=e[t];return Oe(r)?void 0:Me(r)},Ne=M,Ue=_,Be=re,Ge=TypeError,Ke={exports:{}},He=s,Ve=Object.defineProperty,je=function(e,t){try{Ve(He,e,{value:t,configurable:!0,writable:!0})}catch(r){He[e]=t}return t},Ye="__core-js_shared__",qe=s[Ye]||je(Ye,{}),We=qe;(Ke.exports=function(e,t){return We[e]||(We[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=Ke.exports,Xe=Q,Qe=Object,$e=function(e){return Qe(Xe(e))},Je=$e,Ze=y({}.hasOwnProperty),et=Object.hasOwn||function(e,t){return Ze(Je(e),t)},tt=y,rt=0,it=Math.random(),nt=tt(1..toString),at=function(e){return"Symbol("+(void 0===e?"":e)+")_"+nt(++rt+it,36)},st=ze,ot=et,lt=at,ut=Te,ct=Se,ht=s.Symbol,dt=st("wks"),ft=ct?ht.for||ht:ht&&ht.withoutSetter||lt,vt=function(e){return ot(dt,e)||(dt[e]=ut&&ot(ht,e)?ht[e]:ft("Symbol."+e)),dt[e]},gt=M,pt=re,mt=Ie,yt=Fe,Et=function(e,t){var r,i;if("string"===t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;if(Ue(r=e.valueOf)&&!Be(i=Ne(r,e)))return i;if("string"!==t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;throw Ge("Can't convert object to primitive value")},kt=TypeError,Tt=vt("toPrimitive"),St=function(e,t){if(!pt(e)||mt(e))return e;var r,i=yt(e,Tt);if(i){if(void 0===t&&(t="default"),r=gt(i,e,t),!pt(r)||mt(r))return r;throw kt("Can't convert object to primitive value")}return void 0===t&&(t="number"),Et(e,t)},At=Ie,Lt=function(e){var t=St(e,"string");return At(t)?t:t+""},bt=re,Rt=s.document,It=bt(Rt)&&bt(Rt.createElement),Dt=function(e){return It?Rt.createElement(e):{}},_t=Dt,wt=!C&&!o((function(){return 7!=Object.defineProperty(_t("div"),"a",{get:function(){return 7}}).a})),Ct=C,Pt=M,xt=O,Mt=K,Ot=Z,Ft=Lt,Nt=et,Ut=wt,Bt=Object.getOwnPropertyDescriptor;w.f=Ct?Bt:function(e,t){if(e=Ot(e),t=Ft(t),Ut)try{return Bt(e,t)}catch(r){}if(Nt(e,t))return Mt(!Pt(xt.f,e,t),e[t])};var Gt=o,Kt=_,Ht=/#|\.prototype\./,Vt=function(e,t){var r=Yt[jt(e)];return r==Wt||r!=qt&&(Kt(t)?Gt(t):!!t)},jt=Vt.normalize=function(e){return String(e).replace(Ht,".").toLowerCase()},Yt=Vt.data={},qt=Vt.NATIVE="N",Wt=Vt.POLYFILL="P",zt=Vt,Xt=xe,Qt=l,$t=b(b.bind),Jt=function(e,t){return Xt(e),void 0===t?e:Qt?$t(e,t):function(){return e.apply(t,arguments)}},Zt={},er=C&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),tr=re,rr=String,ir=TypeError,nr=function(e){if(tr(e))return e;throw ir(rr(e)+" is not an object")},ar=C,sr=wt,or=er,lr=nr,ur=Lt,cr=TypeError,hr=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,fr="enumerable",vr="configurable",gr="writable";Zt.f=ar?or?function(e,t,r){if(lr(e),t=ur(t),lr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&gr in r&&!r[gr]){var i=dr(e,t);i&&i[gr]&&(e[t]=r.value,r={configurable:vr in r?r[vr]:i[vr],enumerable:fr in r?r[fr]:i[fr],writable:!1})}return hr(e,t,r)}:hr:function(e,t,r){if(lr(e),t=ur(t),lr(r),sr)try{return hr(e,t,r)}catch(i){}if("get"in r||"set"in r)throw cr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Zt,mr=K,yr=C?function(e,t,r){return pr.f(e,t,mr(1,r))}:function(e,t,r){return e[t]=r,e},Er=s,kr=f,Tr=b,Sr=_,Ar=w.f,Lr=zt,br=ie,Rr=Jt,Ir=yr,Dr=et,_r=function(e){var t=function(r,i,n){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,i)}return new e(r,i,n)}return kr(e,this,arguments)};return t.prototype=e.prototype,t},wr=function(e,t){var r,i,n,a,s,o,l,u,c,h=e.target,d=e.global,f=e.stat,v=e.proto,g=d?Er:f?Er[h]:(Er[h]||{}).prototype,p=d?br:br[h]||Ir(br,h,{})[h],m=p.prototype;for(a in t)i=!(r=Lr(d?a:h+(f?".":"#")+a,e.forced))&&g&&Dr(g,a),o=p[a],i&&(l=e.dontCallGetSet?(c=Ar(g,a))&&c.value:g[a]),s=i&&l?l:t[a],i&&typeof o==typeof s||(u=e.bind&&i?Rr(s,Er):e.wrap&&i?_r(s):v&&Sr(s)?Tr(s):s,(e.sham||s&&s.sham||o&&o.sham)&&Ir(u,"sham",!0),Ir(p,a,u),v&&(Dr(br,n=h+"Prototype")||Ir(br,n,{}),Ir(br[n],a,s),e.real&&m&&(r||!m[a])&&Ir(m,a,s)))},Cr=wr,Pr=C,xr=Zt.f;Cr({target:"Object",stat:!0,forced:Object.defineProperty!==xr,sham:!Pr},{defineProperty:xr});var Mr=ie.Object,Or=n.exports=function(e,t,r){return Mr.defineProperty(e,t,r)};Mr.defineProperty.sham&&(Or.sham=!0);var Fr=n.exports,Nr=i(Fr),Ur=S,Br=Array.isArray||function(e){return"Array"==Ur(e)},Gr=Math.ceil,Kr=Math.floor,Hr=Math.trunc||function(e){var t=+e;return(t>0?Kr:Gr)(t)},Vr=function(e){var t=+e;return t!=t||0===t?0:Hr(t)},jr=Vr,Yr=Math.min,qr=function(e){return e>0?Yr(jr(e),9007199254740991):0},Wr=qr,zr=function(e){return Wr(e.length)},Xr=TypeError,Qr=function(e){if(e>9007199254740991)throw Xr("Maximum allowed index exceeded");return e},$r=Lt,Jr=Zt,Zr=K,ei=function(e,t,r){var i=$r(t);i in e?Jr.f(e,i,Zr(0,r)):e[i]=r},ti={};ti[vt("toStringTag")]="z";var ri="[object z]"===String(ti),ii=ri,ni=_,ai=S,si=vt("toStringTag"),oi=Object,li="Arguments"==ai(function(){return arguments}()),ui=ii?ai:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=oi(e),si))?r:li?ai(t):"Object"==(i=ai(t))&&ni(t.callee)?"Arguments":i},ci=_,hi=qe,di=y(Function.toString);ci(hi.inspectSource)||(hi.inspectSource=function(e){return di(e)});var fi=hi.inspectSource,vi=y,gi=o,pi=_,mi=ui,yi=fi,Ei=function(){},ki=[],Ti=le("Reflect","construct"),Si=/^\s*(?:class|function)\b/,Ai=vi(Si.exec),Li=!Si.exec(Ei),bi=function(e){if(!pi(e))return!1;try{return Ti(Ei,ki,e),!0}catch(t){return!1}},Ri=function(e){if(!pi(e))return!1;switch(mi(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Li||!!Ai(Si,yi(e))}catch(t){return!0}};Ri.sham=!0;var Ii=!Ti||gi((function(){var e;return bi(bi.call)||!bi(Object)||!bi((function(){e=!0}))||e}))?Ri:bi,Di=Br,_i=Ii,wi=re,Ci=vt("species"),Pi=Array,xi=function(e){var t;return Di(e)&&(t=e.constructor,(_i(t)&&(t===Pi||Di(t.prototype))||wi(t)&&null===(t=t[Ci]))&&(t=void 0)),void 0===t?Pi:t},Mi=function(e,t){return new(xi(e))(0===t?0:t)},Oi=o,Fi=me,Ni=vt("species"),Ui=function(e){return Fi>=51||!Oi((function(){var t=[];return(t.constructor={})[Ni]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Bi=wr,Gi=o,Ki=Br,Hi=re,Vi=$e,ji=zr,Yi=Qr,qi=ei,Wi=Mi,zi=Ui,Xi=me,Qi=vt("isConcatSpreadable"),$i=Xi>=51||!Gi((function(){var e=[];return e[Qi]=!1,e.concat()[0]!==e})),Ji=function(e){if(!Hi(e))return!1;var t=e[Qi];return void 0!==t?!!t:Ki(e)};Bi({target:"Array",proto:!0,arity:1,forced:!$i||!zi("concat")},{concat:function(e){var t,r,i,n,a,s=Vi(this),o=Wi(s,0),l=0;for(t=-1,i=arguments.length;t<i;t++)if(Ji(a=-1===t?s:arguments[t]))for(n=ji(a),Yi(l+n),r=0;r<n;r++,l++)r in a&&qi(o,l,a[r]);else Yi(l+1),qi(o,l++,a);return o.length=l,o}});var Zi=ui,en=String,tn=function(e){if("Symbol"===Zi(e))throw TypeError("Cannot convert a Symbol value to a string");return en(e)},rn={},nn=Vr,an=Math.max,sn=Math.min,on=function(e,t){var r=nn(e);return r<0?an(r+t,0):sn(r,t)},ln=Z,un=on,cn=zr,hn=function(e){return function(t,r,i){var n,a=ln(t),s=cn(a),o=un(i,s);if(e&&r!=r){for(;s>o;)if((n=a[o++])!=n)return!0}else for(;s>o;o++)if((e||o in a)&&a[o]===r)return e||o||0;return!e&&-1}},dn={includes:hn(!0),indexOf:hn(!1)},fn={},vn=et,gn=Z,pn=dn.indexOf,mn=fn,yn=y([].push),En=function(e,t){var r,i=gn(e),n=0,a=[];for(r in i)!vn(mn,r)&&vn(i,r)&&yn(a,r);for(;t.length>n;)vn(i,r=t[n++])&&(~pn(a,r)||yn(a,r));return a},kn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Tn=En,Sn=kn,An=Object.keys||function(e){return Tn(e,Sn)},Ln=C,bn=er,Rn=Zt,In=nr,Dn=Z,_n=An;rn.f=Ln&&!bn?Object.defineProperties:function(e,t){In(e);for(var r,i=Dn(t),n=_n(t),a=n.length,s=0;a>s;)Rn.f(e,r=n[s++],i[r]);return e};var wn,Cn=le("document","documentElement"),Pn=at,xn=ze("keys"),Mn=function(e){return xn[e]||(xn[e]=Pn(e))},On=nr,Fn=rn,Nn=kn,Un=fn,Bn=Cn,Gn=Dt,Kn="prototype",Hn="script",Vn=Mn("IE_PROTO"),jn=function(){},Yn=function(e){return"<"+Hn+">"+e+"</"+Hn+">"},qn=function(e){e.write(Yn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Wn=function(){try{wn=new ActiveXObject("htmlfile")}catch(n){}var e,t,r;Wn="undefined"!=typeof document?document.domain&&wn?qn(wn):(t=Gn("iframe"),r="java"+Hn+":",t.style.display="none",Bn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Yn("document.F=Object")),e.close(),e.F):qn(wn);for(var i=Nn.length;i--;)delete Wn[Kn][Nn[i]];return Wn()};Un[Vn]=!0;var zn=Object.create||function(e,t){var r;return null!==e?(jn[Kn]=On(e),r=new jn,jn[Kn]=null,r[Vn]=e):r=Wn(),void 0===t?r:Fn.f(r,t)},Xn={},Qn=En,$n=kn.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Qn(e,$n)};var Jn={},Zn=on,ea=zr,ta=ei,ra=Array,ia=Math.max,na=function(e,t,r){for(var i=ea(e),n=Zn(t,i),a=Zn(void 0===r?i:r,i),s=ra(ia(a-n,0)),o=0;n<a;n++,o++)ta(s,o,e[n]);return s.length=o,s},aa=S,sa=Z,oa=Xn.f,la=na,ua="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Jn.f=function(e){return ua&&"Window"==aa(e)?function(e){try{return oa(e)}catch(t){return la(ua)}}(e):oa(sa(e))};var ca={};ca.f=Object.getOwnPropertySymbols;var ha=yr,da=function(e,t,r,i){return i&&i.enumerable?e[t]=r:ha(e,t,r),e},fa=Zt,va=function(e,t,r){return fa.f(e,t,r)},ga={},pa=vt;ga.f=pa;var ma,ya,Ea,ka=ie,Ta=et,Sa=ga,Aa=Zt.f,La=function(e){var t=ka.Symbol||(ka.Symbol={});Ta(t,e)||Aa(t,e,{value:Sa.f(e)})},ba=M,Ra=le,Ia=vt,Da=da,_a=function(){var e=Ra("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,i=Ia("toPrimitive");t&&!t[i]&&Da(t,i,(function(e){return ba(r,this)}),{arity:1})},wa=ui,Ca=ri?{}.toString:function(){return"[object "+wa(this)+"]"},Pa=ri,xa=Zt.f,Ma=yr,Oa=et,Fa=Ca,Na=vt("toStringTag"),Ua=function(e,t,r,i){if(e){var n=r?e:e.prototype;Oa(n,Na)||xa(n,Na,{configurable:!0,value:t}),i&&!Pa&&Ma(n,"toString",Fa)}},Ba=_,Ga=s.WeakMap,Ka=Ba(Ga)&&/native code/.test(String(Ga)),Ha=s,Va=re,ja=yr,Ya=et,qa=qe,Wa=Mn,za=fn,Xa="Object already initialized",Qa=Ha.TypeError,$a=Ha.WeakMap;if(Ka||qa.state){var Ja=qa.state||(qa.state=new $a);Ja.get=Ja.get,Ja.has=Ja.has,Ja.set=Ja.set,ma=function(e,t){if(Ja.has(e))throw Qa(Xa);return t.facade=e,Ja.set(e,t),t},ya=function(e){return Ja.get(e)||{}},Ea=function(e){return Ja.has(e)}}else{var Za=Wa("state");za[Za]=!0,ma=function(e,t){if(Ya(e,Za))throw Qa(Xa);return t.facade=e,ja(e,Za,t),t},ya=function(e){return Ya(e,Za)?e[Za]:{}},Ea=function(e){return Ya(e,Za)}}var es={set:ma,get:ya,has:Ea,enforce:function(e){return Ea(e)?ya(e):ma(e,{})},getterFor:function(e){return function(t){var r;if(!Va(t)||(r=ya(t)).type!==e)throw Qa("Incompatible receiver, "+e+" required");return r}}},ts=Jt,rs=q,is=$e,ns=zr,as=Mi,ss=y([].push),os=function(e){var t=1==e,r=2==e,i=3==e,n=4==e,a=6==e,s=7==e,o=5==e||a;return function(l,u,c,h){for(var d,f,v=is(l),g=rs(v),p=ts(u,c),m=ns(g),y=0,E=h||as,k=t?E(l,m):r||s?E(l,0):void 0;m>y;y++)if((o||y in g)&&(f=p(d=g[y],y,v),e))if(t)k[y]=f;else if(f)switch(e){case 3:return!0;case 5:return d;case 6:return y;case 2:ss(k,d)}else switch(e){case 4:return!1;case 7:ss(k,d)}return a?-1:i||n?n:k}},ls={forEach:os(0),map:os(1),filter:os(2),some:os(3),every:os(4),find:os(5),findIndex:os(6),filterReject:os(7)},us=wr,cs=s,hs=M,ds=y,fs=C,vs=Te,gs=o,ps=et,ms=ue,ys=nr,Es=Z,ks=Lt,Ts=tn,Ss=K,As=zn,Ls=An,bs=Xn,Rs=Jn,Is=ca,Ds=w,_s=Zt,ws=rn,Cs=O,Ps=da,xs=va,Ms=ze,Os=fn,Fs=at,Ns=vt,Us=ga,Bs=La,Gs=_a,Ks=Ua,Hs=es,Vs=ls.forEach,js=Mn("hidden"),Ys="Symbol",qs="prototype",Ws=Hs.set,zs=Hs.getterFor(Ys),Xs=Object[qs],Qs=cs.Symbol,$s=Qs&&Qs[qs],Js=cs.TypeError,Zs=cs.QObject,eo=Ds.f,to=_s.f,ro=Rs.f,io=Cs.f,no=ds([].push),ao=Ms("symbols"),so=Ms("op-symbols"),oo=Ms("wks"),lo=!Zs||!Zs[qs]||!Zs[qs].findChild,uo=fs&&gs((function(){return 7!=As(to({},"a",{get:function(){return to(this,"a",{value:7}).a}})).a}))?function(e,t,r){var i=eo(Xs,t);i&&delete Xs[t],to(e,t,r),i&&e!==Xs&&to(Xs,t,i)}:to,co=function(e,t){var r=ao[e]=As($s);return Ws(r,{type:Ys,tag:e,description:t}),fs||(r.description=t),r},ho=function(e,t,r){e===Xs&&ho(so,t,r),ys(e);var i=ks(t);return ys(r),ps(ao,i)?(r.enumerable?(ps(e,js)&&e[js][i]&&(e[js][i]=!1),r=As(r,{enumerable:Ss(0,!1)})):(ps(e,js)||to(e,js,Ss(1,{})),e[js][i]=!0),uo(e,i,r)):to(e,i,r)},fo=function(e,t){ys(e);var r=Es(t),i=Ls(r).concat(mo(r));return Vs(i,(function(t){fs&&!hs(vo,r,t)||ho(e,t,r[t])})),e},vo=function(e){var t=ks(e),r=hs(io,this,t);return!(this===Xs&&ps(ao,t)&&!ps(so,t))&&(!(r||!ps(this,t)||!ps(ao,t)||ps(this,js)&&this[js][t])||r)},go=function(e,t){var r=Es(e),i=ks(t);if(r!==Xs||!ps(ao,i)||ps(so,i)){var n=eo(r,i);return!n||!ps(ao,i)||ps(r,js)&&r[js][i]||(n.enumerable=!0),n}},po=function(e){var t=ro(Es(e)),r=[];return Vs(t,(function(e){ps(ao,e)||ps(Os,e)||no(r,e)})),r},mo=function(e){var t=e===Xs,r=ro(t?so:Es(e)),i=[];return Vs(r,(function(e){!ps(ao,e)||t&&!ps(Xs,e)||no(i,ao[e])})),i};vs||(Qs=function(){if(ms($s,this))throw Js("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Ts(arguments[0]):void 0,t=Fs(e),r=function(e){this===Xs&&hs(r,so,e),ps(this,js)&&ps(this[js],t)&&(this[js][t]=!1),uo(this,t,Ss(1,e))};return fs&&lo&&uo(Xs,t,{configurable:!0,set:r}),co(t,e)},Ps($s=Qs[qs],"toString",(function(){return zs(this).tag})),Ps(Qs,"withoutSetter",(function(e){return co(Fs(e),e)})),Cs.f=vo,_s.f=ho,ws.f=fo,Ds.f=go,bs.f=Rs.f=po,Is.f=mo,Us.f=function(e){return co(Ns(e),e)},fs&&xs($s,"description",{configurable:!0,get:function(){return zs(this).description}})),us({global:!0,constructor:!0,wrap:!0,forced:!vs,sham:!vs},{Symbol:Qs}),Vs(Ls(oo),(function(e){Bs(e)})),us({target:Ys,stat:!0,forced:!vs},{useSetter:function(){lo=!0},useSimple:function(){lo=!1}}),us({target:"Object",stat:!0,forced:!vs,sham:!fs},{create:function(e,t){return void 0===t?As(e):fo(As(e),t)},defineProperty:ho,defineProperties:fo,getOwnPropertyDescriptor:go}),us({target:"Object",stat:!0,forced:!vs},{getOwnPropertyNames:po}),Gs(),Ks(Qs,Ys),Os[js]=!0;var yo=Te&&!!Symbol.for&&!!Symbol.keyFor,Eo=wr,ko=le,To=et,So=tn,Ao=ze,Lo=yo,bo=Ao("string-to-symbol-registry"),Ro=Ao("symbol-to-string-registry");Eo({target:"Symbol",stat:!0,forced:!Lo},{for:function(e){var t=So(e);if(To(bo,t))return bo[t];var r=ko("Symbol")(t);return bo[t]=r,Ro[r]=t,r}});var Io=wr,Do=et,_o=Ie,wo=_e,Co=yo,Po=ze("symbol-to-string-registry");Io({target:"Symbol",stat:!0,forced:!Co},{keyFor:function(e){if(!_o(e))throw TypeError(wo(e)+" is not a symbol");if(Do(Po,e))return Po[e]}});var xo=y([].slice),Mo=Br,Oo=_,Fo=S,No=tn,Uo=y([].push),Bo=wr,Go=le,Ko=f,Ho=M,Vo=y,jo=o,Yo=_,qo=Ie,Wo=xo,zo=function(e){if(Oo(e))return e;if(Mo(e)){for(var t=e.length,r=[],i=0;i<t;i++){var n=e[i];"string"==typeof n?Uo(r,n):"number"!=typeof n&&"Number"!=Fo(n)&&"String"!=Fo(n)||Uo(r,No(n))}var a=r.length,s=!0;return function(e,t){if(s)return s=!1,t;if(Mo(this))return t;for(var i=0;i<a;i++)if(r[i]===e)return t}}},Xo=Te,Qo=String,$o=Go("JSON","stringify"),Jo=Vo(/./.exec),Zo=Vo("".charAt),el=Vo("".charCodeAt),tl=Vo("".replace),rl=Vo(1..toString),il=/[\uD800-\uDFFF]/g,nl=/^[\uD800-\uDBFF]$/,al=/^[\uDC00-\uDFFF]$/,sl=!Xo||jo((function(){var e=Go("Symbol")();return"[null]"!=$o([e])||"{}"!=$o({a:e})||"{}"!=$o(Object(e))})),ol=jo((function(){return'"\\udf06\\ud834"'!==$o("\udf06\ud834")||'"\\udead"'!==$o("\udead")})),ll=function(e,t){var r=Wo(arguments),i=zo(t);if(Yo(i)||void 0!==e&&!qo(e))return r[1]=function(e,t){if(Yo(i)&&(t=Ho(i,this,Qo(e),t)),!qo(t))return t},Ko($o,null,r)},ul=function(e,t,r){var i=Zo(r,t-1),n=Zo(r,t+1);return Jo(nl,e)&&!Jo(al,n)||Jo(al,e)&&!Jo(nl,i)?"\\u"+rl(el(e,0),16):e};$o&&Bo({target:"JSON",stat:!0,arity:3,forced:sl||ol},{stringify:function(e,t,r){var i=Wo(arguments),n=Ko(sl?ll:$o,null,i);return ol&&"string"==typeof n?tl(n,il,ul):n}});var cl=ca,hl=$e;wr({target:"Object",stat:!0,forced:!Te||o((function(){cl.f(1)}))},{getOwnPropertySymbols:function(e){var t=cl.f;return t?t(hl(e)):[]}}),La("asyncIterator"),La("hasInstance"),La("isConcatSpreadable"),La("iterator"),La("match"),La("matchAll"),La("replace"),La("search"),La("species"),La("split");var dl=_a;La("toPrimitive"),dl();var fl=le,vl=Ua;La("toStringTag"),vl(fl("Symbol"),"Symbol"),La("unscopables"),Ua(s.JSON,"JSON",!0);var gl,pl,ml,yl=ie.Symbol,El={},kl=C,Tl=et,Sl=Function.prototype,Al=kl&&Object.getOwnPropertyDescriptor,Ll=Tl(Sl,"name"),bl={EXISTS:Ll,PROPER:Ll&&"something"===function(){}.name,CONFIGURABLE:Ll&&(!kl||kl&&Al(Sl,"name").configurable)},Rl=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Il=et,Dl=_,_l=$e,wl=Rl,Cl=Mn("IE_PROTO"),Pl=Object,xl=Pl.prototype,Ml=wl?Pl.getPrototypeOf:function(e){var t=_l(e);if(Il(t,Cl))return t[Cl];var r=t.constructor;return Dl(r)&&t instanceof r?r.prototype:t instanceof Pl?xl:null},Ol=o,Fl=_,Nl=re,Ul=zn,Bl=Ml,Gl=da,Kl=vt("iterator"),Hl=!1;[].keys&&("next"in(ml=[].keys())?(pl=Bl(Bl(ml)))!==Object.prototype&&(gl=pl):Hl=!0);var Vl=!Nl(gl)||Ol((function(){var e={};return gl[Kl].call(e)!==e}));Fl((gl=Vl?{}:Ul(gl))[Kl])||Gl(gl,Kl,(function(){return this}));var jl={IteratorPrototype:gl,BUGGY_SAFARI_ITERATORS:Hl},Yl=jl.IteratorPrototype,ql=zn,Wl=K,zl=Ua,Xl=El,Ql=function(){return this},$l=function(e,t,r,i){var n=t+" Iterator";return e.prototype=ql(Yl,{next:Wl(+!i,r)}),zl(e,n,!1,!0),Xl[n]=Ql,e},Jl=y,Zl=xe,eu=_,tu=String,ru=TypeError,iu=function(e,t,r){try{return Jl(Zl(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},nu=nr,au=function(e){if("object"==typeof e||eu(e))return e;throw ru("Can't set "+tu(e)+" as a prototype")},su=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=iu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return nu(r),au(i),t?e(r,i):r.__proto__=i,r}}():void 0),ou=wr,lu=M,uu=bl,cu=$l,hu=Ml,du=Ua,fu=da,vu=El,gu=jl,pu=uu.PROPER,mu=gu.BUGGY_SAFARI_ITERATORS,yu=vt("iterator"),Eu="keys",ku="values",Tu="entries",Su=function(){return this},Au=function(e,t,r,i,n,a,s){cu(r,t,i);var o,l,u,c=function(e){if(e===n&&g)return g;if(!mu&&e in f)return f[e];switch(e){case Eu:case ku:case Tu:return function(){return new r(this,e)}}return function(){return new r(this)}},h=t+" Iterator",d=!1,f=e.prototype,v=f[yu]||f["@@iterator"]||n&&f[n],g=!mu&&v||c(n),p="Array"==t&&f.entries||v;if(p&&(o=hu(p.call(new e)))!==Object.prototype&&o.next&&(du(o,h,!0,!0),vu[h]=Su),pu&&n==ku&&v&&v.name!==ku&&(d=!0,g=function(){return lu(v,this)}),n)if(l={values:c(ku),keys:a?g:c(Eu),entries:c(Tu)},s)for(u in l)(mu||d||!(u in f))&&fu(f,u,l[u]);else ou({target:t,proto:!0,forced:mu||d},l);return s&&f[yu]!==g&&fu(f,yu,g,{name:n}),vu[t]=g,l},Lu=function(e,t){return{value:e,done:t}},bu=Z,Ru=El,Iu=es;Zt.f;var Du=Au,_u=Lu,wu="Array Iterator",Cu=Iu.set,Pu=Iu.getterFor(wu);Du(Array,"Array",(function(e,t){Cu(this,{type:wu,target:bu(e),index:0,kind:t})}),(function(){var e=Pu(this),t=e.target,r=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,_u(void 0,!0)):_u("keys"==r?i:"values"==r?t[i]:[i,t[i]],!1)}),"values"),Ru.Arguments=Ru.Array;var xu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Mu=s,Ou=ui,Fu=yr,Nu=El,Uu=vt("toStringTag");for(var Bu in xu){var Gu=Mu[Bu],Ku=Gu&&Gu.prototype;Ku&&Ou(Ku)!==Uu&&Fu(Ku,Uu,Bu),Nu[Bu]=Nu.Array}var Hu=yl;La("dispose");var Vu=Hu;La("asyncDispose");var ju=wr,Yu=y,qu=le("Symbol"),Wu=qu.keyFor,zu=Yu(qu.prototype.valueOf);ju({target:"Symbol",stat:!0},{isRegistered:function(e){try{return void 0!==Wu(zu(e))}catch(t){return!1}}});for(var Xu=wr,Qu=ze,$u=le,Ju=y,Zu=Ie,ec=vt,tc=$u("Symbol"),rc=tc.isWellKnown,ic=$u("Object","getOwnPropertyNames"),nc=Ju(tc.prototype.valueOf),ac=Qu("wks"),sc=0,oc=ic(tc),lc=oc.length;sc<lc;sc++)try{var uc=oc[sc];Zu(tc[uc])&&ec(uc)}catch(JV){}Xu({target:"Symbol",stat:!0,forced:!0},{isWellKnown:function(e){if(rc&&rc(e))return!0;try{for(var t=nc(e),r=0,i=ic(ac),n=i.length;r<n;r++)if(ac[i[r]]==t)return!0}catch(JV){}return!1}}),La("matcher"),La("metadataKey"),La("observable"),La("metadata"),La("patternMatch"),La("replaceAll");var cc=Vu,hc=i(cc),dc=y,fc=Vr,vc=tn,gc=Q,pc=dc("".charAt),mc=dc("".charCodeAt),yc=dc("".slice),Ec=function(e){return function(t,r){var i,n,a=vc(gc(t)),s=fc(r),o=a.length;return s<0||s>=o?e?"":void 0:(i=mc(a,s))<55296||i>56319||s+1===o||(n=mc(a,s+1))<56320||n>57343?e?pc(a,s):i:e?yc(a,s,s+2):n-56320+(i-55296<<10)+65536}},kc={codeAt:Ec(!1),charAt:Ec(!0)},Tc=kc.charAt,Sc=tn,Ac=es,Lc=Au,bc=Lu,Rc="String Iterator",Ic=Ac.set,Dc=Ac.getterFor(Rc);Lc(String,"String",(function(e){Ic(this,{type:Rc,string:Sc(e),index:0})}),(function(){var e,t=Dc(this),r=t.string,i=t.index;return i>=r.length?bc(void 0,!0):(e=Tc(r,i),t.index+=e.length,bc(e,!1))}));var _c=ga.f("iterator"),wc=i(_c);function Cc(e){return(Cc="function"==typeof hc&&"symbol"==typeof wc?function(e){return typeof e}:function(e){return e&&"function"==typeof hc&&e.constructor===hc&&e!==hc.prototype?"symbol":typeof e})(e)}var Pc=ga.f("toPrimitive"),xc=i(Pc);function Mc(e){var t=function(e,t){if("object"!==Cc(e)||null===e)return e;var r=e[xc];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Cc(t)?t:String(t)}function Oc(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Nr(e,Mc(i.key),i)}}function Fc(e,t,r){return t&&Oc(e.prototype,t),r&&Oc(e,r),Nr(e,"prototype",{writable:!1}),e}var Nc=et,Uc=M,Bc=re,Gc=nr,Kc=function(e){return void 0!==e&&(Nc(e,"value")||Nc(e,"writable"))},Hc=w,Vc=Ml;wr({target:"Reflect",stat:!0},{get:function e(t,r){var i,n,a=arguments.length<3?t:arguments[2];return Gc(t)===a?t[r]:(i=Hc.f(t,r))?Kc(i)?i.value:void 0===i.get?void 0:Uc(i.get,a):Bc(n=Vc(t))?e(n,r,a):void 0}});var jc=i(ie.Reflect.get),Yc=y,qc=xe,Wc=re,zc=et,Xc=xo,Qc=l,$c=Function,Jc=Yc([].concat),Zc=Yc([].join),eh={},th=Qc?$c.bind:function(e){var t=qc(this),r=t.prototype,i=Xc(arguments,1),n=function(){var r=Jc(i,Xc(arguments));return this instanceof n?function(e,t,r){if(!zc(eh,t)){for(var i=[],n=0;n<t;n++)i[n]="a["+n+"]";eh[t]=$c("C,a","return new C("+Zc(i,",")+")")}return eh[t](e,r)}(t,r.length,r):t.apply(e,r)};return Wc(r)&&(n.prototype=r),n},rh=th;wr({target:"Function",proto:!0,forced:Function.bind!==rh},{bind:rh});var ih=ie,nh=function(e){return ih[e+"Prototype"]},ah=nh("Function").bind,sh=ue,oh=ah,lh=Function.prototype,uh=function(e){var t=e.bind;return e===lh||sh(lh,e)&&t===lh.bind?oh:t},ch=i(uh),hh={exports:{}},dh=wr,fh=o,vh=Z,gh=w.f,ph=C;dh({target:"Object",stat:!0,forced:!ph||fh((function(){gh(1)})),sham:!ph},{getOwnPropertyDescriptor:function(e,t){return gh(vh(e),t)}});var mh=ie.Object,yh=hh.exports=function(e,t){return mh.getOwnPropertyDescriptor(e,t)};mh.getOwnPropertyDescriptor.sham&&(yh.sham=!0);var Eh=hh.exports,kh=i(Eh);wr({target:"Object",stat:!0},{setPrototypeOf:su});var Th=i(ie.Object.setPrototypeOf),Sh=$e,Ah=Ml,Lh=Rl;wr({target:"Object",stat:!0,forced:o((function(){Ah(1)})),sham:!Lh},{getPrototypeOf:function(e){return Ah(Sh(e))}});var bh=i(ie.Object.getPrototypeOf);function Rh(e){var t;return(Rh=Th?ch(t=bh).call(t):function(e){return e.__proto__||bh(e)})(e)}function Ih(){var e;"undefined"!=typeof Reflect&&jc?Ih=ch(e=jc).call(e):Ih=function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Rh(e)););return e}(e,t);if(i){var n=kh(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}};return Ih.apply(this,arguments)}wr({target:"Object",stat:!0,sham:!C},{create:zn});var Dh=ie.Object,_h=function(e,t){return Dh.create(e,t)},wh=i(_h);function Ch(e,t){var r;return(Ch=Th?ch(r=Th).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function Ph(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=wh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Nr(e,"prototype",{writable:!1}),t&&Ch(e,t)}var xh=Ii,Mh=_e,Oh=TypeError,Fh=function(e){if(xh(e))return e;throw Oh(Mh(e)+" is not a constructor")},Nh=wr,Uh=f,Bh=th,Gh=Fh,Kh=nr,Hh=re,Vh=zn,jh=o,Yh=le("Reflect","construct"),qh=Object.prototype,Wh=[].push,zh=jh((function(){function e(){}return!(Yh((function(){}),[],e)instanceof e)})),Xh=!jh((function(){Yh((function(){}))})),Qh=zh||Xh;Nh({target:"Reflect",stat:!0,forced:Qh,sham:Qh},{construct:function(e,t){Gh(e),Kh(t);var r=arguments.length<3?e:Gh(arguments[2]);if(Xh&&!zh)return Yh(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var i=[null];return Uh(Wh,i,t),new(Uh(Bh,e,i))}var n=r.prototype,a=Vh(Hh(n)?n:qh),s=Uh(e,a,t);return Hh(s)?s:a}});var $h=i(ie.Reflect.construct);function Jh(){if("undefined"==typeof Reflect||!$h)return!1;if($h.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call($h(Boolean,[],(function(){}))),!0}catch(e){return!1}}function Zh(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ed(e){var t=Jh();return function(){var r,i=Rh(e);if(t){var n=Rh(this).constructor;r=$h(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"===Cc(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Zh(e)}(this,r)}}var td=o,rd=function(e,t){var r=[][e];return!!r&&td((function(){r.call(null,t||function(){return 1},1)}))},id=ls.forEach,nd=rd("forEach")?[].forEach:function(e){return id(this,e,arguments.length>1?arguments[1]:void 0)};wr({target:"Array",proto:!0,forced:[].forEach!=nd},{forEach:nd});var ad=nh("Array").forEach,sd=ui,od=et,ld=ue,ud=ad,cd=Array.prototype,hd={DOMTokenList:!0,NodeList:!0},dd=function(e){var t=e.forEach;return e===cd||ld(cd,e)&&t===cd.forEach||od(hd,sd(e))?ud:t},fd=i(dd),vd=i(dd),gd=C,pd=y,md=An,yd=Z,Ed=pd(O.f),kd=pd([].push),Td=function(e){return function(t){for(var r,i=yd(t),n=md(i),a=n.length,s=0,o=[];a>s;)r=n[s++],gd&&!Ed(i,r)||kd(o,e?[r,i[r]]:i[r]);return o}},Sd={entries:Td(!0),values:Td(!1)},Ad=Sd.values;wr({target:"Object",stat:!0},{values:function(e){return Ad(e)}});var Ld=i(ie.Object.values),bd=nh("Array").concat,Rd=ue,Id=bd,Dd=Array.prototype,_d=i((function(e){var t=e.concat;return e===Dd||Rd(Dd,e)&&t===Dd.concat?Id:t})),wd=$e,Cd=An;wr({target:"Object",stat:!0,forced:o((function(){Cd(1)}))},{keys:function(e){return Cd(wd(e))}});var Pd=ie.Object.keys,xd=i(Pd),Md=ie.Object.getOwnPropertySymbols,Od=i(Md),Fd=ls.filter;wr({target:"Array",proto:!0,forced:!Ui("filter")},{filter:function(e){return Fd(this,e,arguments.length>1?arguments[1]:void 0)}});var Nd=nh("Array").filter,Ud=ue,Bd=Nd,Gd=Array.prototype,Kd=function(e){var t=e.filter;return e===Gd||Ud(Gd,e)&&t===Gd.filter?Bd:t},Hd=i(Kd),Vd=C,jd=Br,Yd=TypeError,qd=Object.getOwnPropertyDescriptor,Wd=Vd&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(JV){return JV instanceof TypeError}}()?function(e,t){if(jd(e)&&!qd(e,"length").writable)throw Yd("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},zd=$e,Xd=zr,Qd=Wd,$d=Qr;wr({target:"Array",proto:!0,arity:1,forced:o((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(JV){return JV instanceof TypeError}}()},{push:function(e){var t=zd(this),r=Xd(t),i=arguments.length;$d(r+i);for(var n=0;n<i;n++)t[r]=arguments[n],r++;return Qd(t,r),r}});var Jd=nh("Array").push,Zd=ue,ef=Jd,tf=Array.prototype,rf=i((function(e){var t=e.push;return e===tf||Zd(tf,e)&&t===tf.push?ef:t})),nf=le,af=Xn,sf=ca,of=nr,lf=y([].concat),uf=nf("Reflect","ownKeys")||function(e){var t=af.f(of(e)),r=sf.f;return r?lf(t,r(e)):t},cf=uf,hf=Z,df=w,ff=ei;wr({target:"Object",stat:!0,sham:!C},{getOwnPropertyDescriptors:function(e){for(var t,r,i=hf(e),n=df.f,a=cf(i),s={},o=0;a.length>o;)void 0!==(r=n(i,t=a[o++]))&&ff(s,t,r);return s}});var vf=ie.Object.getOwnPropertyDescriptors,gf=i(vf),pf={exports:{}},mf=wr,yf=C,Ef=rn.f;mf({target:"Object",stat:!0,forced:Object.defineProperties!==Ef,sham:!yf},{defineProperties:Ef});var kf=ie.Object,Tf=pf.exports=function(e,t){return kf.defineProperties(e,t)};kf.defineProperties.sham&&(Tf.sham=!0);var Sf=pf.exports,Af=i(Sf);function Lf(e,t,r){return(t=Mc(t))in e?Nr(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bf(e,t){var r=xd(e);if(Od){var i=Od(e);t&&(i=Hd(i).call(i,(function(t){return kh(e,t).enumerable}))),rf(r).apply(r,i)}return r}function Rf(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?fd(r=bf(Object(n),!0)).call(r,(function(t){Lf(e,t,n[t])})):gf?Af(e,gf(n)):fd(i=bf(Object(n))).call(i,(function(t){Nr(e,t,kh(n,t))}))}return e}var If,Df="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,_f=TypeError,wf=function(e,t){if(e<t)throw _f("Not enough arguments");return e},Cf=s,Pf=f,xf=_,Mf=Df,Of=ce,Ff=xo,Nf=wf,Uf=Cf.Function,Bf=/MSIE .\./.test(Of)||Mf&&((If=Cf.Bun.version.split(".")).length<3||0==If[0]&&(If[1]<3||3==If[1]&&0==If[2])),Gf=function(e,t){var r=t?2:1;return Bf?function(i,n){var a=Nf(arguments.length,1)>r,s=xf(i)?i:Uf(i),o=a?Ff(arguments,r):[],l=a?function(){Pf(s,this,o)}:s;return t?e(l,n):e(l)}:e},Kf=wr,Hf=s,Vf=Gf(Hf.setInterval,!0);Kf({global:!0,bind:!0,forced:Hf.setInterval!==Vf},{setInterval:Vf});var jf=wr,Yf=s,qf=Gf(Yf.setTimeout,!0);jf({global:!0,bind:!0,forced:Yf.setTimeout!==qf},{setTimeout:qf});var Wf=i(ie.setTimeout),zf=wr,Xf=dn.indexOf,Qf=rd,$f=b([].indexOf),Jf=!!$f&&1/$f([1],1,-0)<0;zf({target:"Array",proto:!0,forced:Jf||!Qf("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return Jf?$f(this,e,t)||0:Xf(this,e,t)}});var Zf=nh("Array").indexOf,ev=ue,tv=Zf,rv=Array.prototype,iv=function(e){var t=e.indexOf;return e===rv||ev(rv,e)&&t===rv.indexOf?tv:t},nv=i(iv),av=i(iv),sv=wr,ov=ls.find,lv="find",uv=!0;lv in[]&&Array(1)[lv]((function(){uv=!1})),sv({target:"Array",proto:!0,forced:uv},{find:function(e){return ov(this,e,arguments.length>1?arguments[1]:void 0)}});var cv=nh("Array").find,hv=ue,dv=cv,fv=Array.prototype,vv=i((function(e){var t=e.find;return e===fv||hv(fv,e)&&t===fv.find?dv:t})),gv=i(Pd),pv=wr,mv=Br,yv=Ii,Ev=re,kv=on,Tv=zr,Sv=Z,Av=ei,Lv=vt,bv=xo,Rv=Ui("slice"),Iv=Lv("species"),Dv=Array,_v=Math.max;pv({target:"Array",proto:!0,forced:!Rv},{slice:function(e,t){var r,i,n,a=Sv(this),s=Tv(a),o=kv(e,s),l=kv(void 0===t?s:t,s);if(mv(a)&&(r=a.constructor,(yv(r)&&(r===Dv||mv(r.prototype))||Ev(r)&&null===(r=r[Iv]))&&(r=void 0),r===Dv||void 0===r))return bv(a,o,l);for(i=new(void 0===r?Dv:r)(_v(l-o,0)),n=0;o<l;o++,n++)o in a&&Av(i,n,a[o]);return i.length=n,i}});var wv=nh("Array").slice,Cv=ue,Pv=wv,xv=Array.prototype,Mv=function(e){var t=e.slice;return e===xv||Cv(xv,e)&&t===xv.slice?Pv:t},Ov=i(Mv),Fv=i(Mv),Nv=_e,Uv=TypeError,Bv=function(e,t){if(!delete e[t])throw Uv("Cannot delete property "+Nv(t)+" of "+Nv(e))},Gv=wr,Kv=$e,Hv=on,Vv=Vr,jv=zr,Yv=Wd,qv=Qr,Wv=Mi,zv=ei,Xv=Bv,Qv=Ui("splice"),$v=Math.max,Jv=Math.min;Gv({target:"Array",proto:!0,forced:!Qv},{splice:function(e,t){var r,i,n,a,s,o,l=Kv(this),u=jv(l),c=Hv(e,u),h=arguments.length;for(0===h?r=i=0:1===h?(r=0,i=u-c):(r=h-2,i=Jv($v(Vv(t),0),u-c)),qv(u+r-i),n=Wv(l,i),a=0;a<i;a++)(s=c+a)in l&&zv(n,a,l[s]);if(n.length=i,r<i){for(a=c;a<u-i;a++)o=a+r,(s=a+i)in l?l[o]=l[s]:Xv(l,o);for(a=u;a>u-i+r;a--)Xv(l,a-1)}else if(r>i)for(a=u-i;a>c;a--)o=a+r-1,(s=a+i-1)in l?l[o]=l[s]:Xv(l,o);for(a=0;a<r;a++)l[a+c]=arguments[a+2];return Yv(l,u-i+r),n}});var Zv=nh("Array").splice,eg=ue,tg=Zv,rg=Array.prototype,ig=i((function(e){var t=e.splice;return e===rg||eg(rg,e)&&t===rg.splice?tg:t})),ng=et,ag=uf,sg=w,og=Zt,lg=re,ug=yr,cg=Error,hg=y("".replace),dg=String(cg("zxcasd").stack),fg=/\n\s*at [^:]*:[^\n]*/,vg=fg.test(dg),gg=K,pg=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",gg(1,7)),7!==e.stack)})),mg=yr,yg=function(e,t){if(vg&&"string"==typeof e&&!cg.prepareStackTrace)for(;t--;)e=hg(e,fg,"");return e},Eg=pg,kg=Error.captureStackTrace,Tg=El,Sg=vt("iterator"),Ag=Array.prototype,Lg=function(e){return void 0!==e&&(Tg.Array===e||Ag[Sg]===e)},bg=ui,Rg=Fe,Ig=W,Dg=El,_g=vt("iterator"),wg=function(e){if(!Ig(e))return Rg(e,_g)||Rg(e,"@@iterator")||Dg[bg(e)]},Cg=M,Pg=xe,xg=nr,Mg=_e,Og=wg,Fg=TypeError,Ng=function(e,t){var r=arguments.length<2?Og(e):t;if(Pg(r))return xg(Cg(r,e));throw Fg(Mg(e)+" is not iterable")},Ug=M,Bg=nr,Gg=Fe,Kg=function(e,t,r){var i,n;Bg(e);try{if(!(i=Gg(e,"return"))){if("throw"===t)throw r;return r}i=Ug(i,e)}catch(JV){n=!0,i=JV}if("throw"===t)throw r;if(n)throw i;return Bg(i),r},Hg=Jt,Vg=M,jg=nr,Yg=_e,qg=Lg,Wg=zr,zg=ue,Xg=Ng,Qg=wg,$g=Kg,Jg=TypeError,Zg=function(e,t){this.stopped=e,this.result=t},ep=Zg.prototype,tp=function(e,t,r){var i,n,a,s,o,l,u,c=r&&r.that,h=!(!r||!r.AS_ENTRIES),d=!(!r||!r.IS_RECORD),f=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),g=Hg(t,c),p=function(e){return i&&$g(i,"normal",e),new Zg(!0,e)},m=function(e){return h?(jg(e),v?g(e[0],e[1],p):g(e[0],e[1])):v?g(e,p):g(e)};if(d)i=e.iterator;else if(f)i=e;else{if(!(n=Qg(e)))throw Jg(Yg(e)+" is not iterable");if(qg(n)){for(a=0,s=Wg(e);s>a;a++)if((o=m(e[a]))&&zg(ep,o))return o;return new Zg(!1)}i=Xg(e,n)}for(l=d?e.next:i.next;!(u=Vg(l,i)).done;){try{o=m(u.value)}catch(JV){$g(i,"throw",JV)}if("object"==typeof o&&o&&zg(ep,o))return o}return new Zg(!1)},rp=tn,ip=wr,np=ue,ap=Ml,sp=su,op=function(e,t,r){for(var i=ag(t),n=og.f,a=sg.f,s=0;s<i.length;s++){var o=i[s];ng(e,o)||r&&ng(r,o)||n(e,o,a(t,o))}},lp=zn,up=yr,cp=K,hp=function(e,t){lg(t)&&"cause"in t&&ug(e,"cause",t.cause)},dp=function(e,t,r,i){Eg&&(kg?kg(e,t):mg(e,"stack",yg(r,i)))},fp=tp,vp=function(e,t){return void 0===e?arguments.length<2?"":t:rp(e)},gp=vt("toStringTag"),pp=Error,mp=[].push,yp=function(e,t){var r,i=np(Ep,this);sp?r=sp(pp(),i?ap(this):Ep):(r=i?this:lp(Ep),up(r,gp,"Error")),void 0!==t&&up(r,"message",vp(t)),dp(r,yp,r.stack,1),arguments.length>2&&hp(r,arguments[2]);var n=[];return fp(e,mp,{that:n}),up(r,"errors",n),r};sp?sp(yp,pp):op(yp,pp,{name:!0});var Ep=yp.prototype=lp(pp.prototype,{constructor:cp(1,yp),message:cp(1,""),name:cp(1,"AggregateError")});ip({global:!0,constructor:!0,arity:2},{AggregateError:yp});var kp,Tp,Sp,Ap,Lp="undefined"!=typeof process&&"process"==S(process),bp=le,Rp=va,Ip=C,Dp=vt("species"),_p=function(e){var t=bp(e);Ip&&t&&!t[Dp]&&Rp(t,Dp,{configurable:!0,get:function(){return this}})},wp=ue,Cp=TypeError,Pp=function(e,t){if(wp(t,e))return e;throw Cp("Incorrect invocation")},xp=nr,Mp=Fh,Op=W,Fp=vt("species"),Np=function(e,t){var r,i=xp(e).constructor;return void 0===i||Op(r=xp(i)[Fp])?t:Mp(r)},Up=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),Bp=s,Gp=f,Kp=Jt,Hp=_,Vp=et,jp=o,Yp=Cn,qp=xo,Wp=Dt,zp=wf,Xp=Up,Qp=Lp,$p=Bp.setImmediate,Jp=Bp.clearImmediate,Zp=Bp.process,em=Bp.Dispatch,tm=Bp.Function,rm=Bp.MessageChannel,im=Bp.String,nm=0,am={},sm="onreadystatechange";jp((function(){kp=Bp.location}));var om=function(e){if(Vp(am,e)){var t=am[e];delete am[e],t()}},lm=function(e){return function(){om(e)}},um=function(e){om(e.data)},cm=function(e){Bp.postMessage(im(e),kp.protocol+"//"+kp.host)};$p&&Jp||($p=function(e){zp(arguments.length,1);var t=Hp(e)?e:tm(e),r=qp(arguments,1);return am[++nm]=function(){Gp(t,void 0,r)},Tp(nm),nm},Jp=function(e){delete am[e]},Qp?Tp=function(e){Zp.nextTick(lm(e))}:em&&em.now?Tp=function(e){em.now(lm(e))}:rm&&!Xp?(Ap=(Sp=new rm).port2,Sp.port1.onmessage=um,Tp=Kp(Ap.postMessage,Ap)):Bp.addEventListener&&Hp(Bp.postMessage)&&!Bp.importScripts&&kp&&"file:"!==kp.protocol&&!jp(cm)?(Tp=cm,Bp.addEventListener("message",um,!1)):Tp=sm in Wp("script")?function(e){Yp.appendChild(Wp("script"))[sm]=function(){Yp.removeChild(this),om(e)}}:function(e){setTimeout(lm(e),0)});var hm={set:$p,clear:Jp},dm=function(){this.head=null,this.tail=null};dm.prototype={add:function(e){var t={item:e,next:null},r=this.tail;r?r.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var fm,vm,gm,pm,mm,ym=dm,Em=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,km=/web0s(?!.*chrome)/i.test(ce),Tm=s,Sm=Jt,Am=w.f,Lm=hm.set,bm=ym,Rm=Up,Im=Em,Dm=km,_m=Lp,wm=Tm.MutationObserver||Tm.WebKitMutationObserver,Cm=Tm.document,Pm=Tm.process,xm=Tm.Promise,Mm=Am(Tm,"queueMicrotask"),Om=Mm&&Mm.value;if(!Om){var Fm=new bm,Nm=function(){var e,t;for(_m&&(e=Pm.domain)&&e.exit();t=Fm.get();)try{t()}catch(JV){throw Fm.head&&fm(),JV}e&&e.enter()};Rm||_m||Dm||!wm||!Cm?!Im&&xm&&xm.resolve?((pm=xm.resolve(void 0)).constructor=xm,mm=Sm(pm.then,pm),fm=function(){mm(Nm)}):_m?fm=function(){Pm.nextTick(Nm)}:(Lm=Sm(Lm,Tm),fm=function(){Lm(Nm)}):(vm=!0,gm=Cm.createTextNode(""),new wm(Nm).observe(gm,{characterData:!0}),fm=function(){gm.data=vm=!vm}),Om=function(e){Fm.head||fm(),Fm.add(e)}}var Um=Om,Bm=function(e){try{return{error:!1,value:e()}}catch(JV){return{error:!0,value:JV}}},Gm=s.Promise,Km="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Hm=!Km&&!Lp&&"object"==typeof window&&"object"==typeof document,Vm=s,jm=Gm,Ym=_,qm=zt,Wm=fi,zm=vt,Xm=Hm,Qm=Km,$m=me,Jm=jm&&jm.prototype,Zm=zm("species"),ey=!1,ty=Ym(Vm.PromiseRejectionEvent),ry={CONSTRUCTOR:qm("Promise",(function(){var e=Wm(jm),t=e!==String(jm);if(!t&&66===$m)return!0;if(!Jm.catch||!Jm.finally)return!0;if(!$m||$m<51||!/native code/.test(e)){var r=new jm((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Zm]=i,!(ey=r.then((function(){}))instanceof i))return!0}return!t&&(Xm||Qm)&&!ty})),REJECTION_EVENT:ty,SUBCLASSING:ey},iy={},ny=xe,ay=TypeError,sy=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw ay("Bad Promise constructor");t=e,r=i})),this.resolve=ny(t),this.reject=ny(r)};iy.f=function(e){return new sy(e)};var oy,ly,uy=wr,cy=Lp,hy=s,dy=M,fy=da,vy=Ua,gy=_p,py=xe,my=_,yy=re,Ey=Pp,ky=Np,Ty=hm.set,Sy=Um,Ay=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(JV){}},Ly=Bm,by=ym,Ry=es,Iy=Gm,Dy=ry,_y=iy,wy="Promise",Cy=Dy.CONSTRUCTOR,Py=Dy.REJECTION_EVENT,xy=Ry.getterFor(wy),My=Ry.set,Oy=Iy&&Iy.prototype,Fy=Iy,Ny=Oy,Uy=hy.TypeError,By=hy.document,Gy=hy.process,Ky=_y.f,Hy=Ky,Vy=!!(By&&By.createEvent&&hy.dispatchEvent),jy="unhandledrejection",Yy=function(e){var t;return!(!yy(e)||!my(t=e.then))&&t},qy=function(e,t){var r,i,n,a=t.value,s=1==t.state,o=s?e.ok:e.fail,l=e.resolve,u=e.reject,c=e.domain;try{o?(s||(2===t.rejection&&$y(t),t.rejection=1),!0===o?r=a:(c&&c.enter(),r=o(a),c&&(c.exit(),n=!0)),r===e.promise?u(Uy("Promise-chain cycle")):(i=Yy(r))?dy(i,r,l,u):l(r)):u(a)}catch(JV){c&&!n&&c.exit(),u(JV)}},Wy=function(e,t){e.notified||(e.notified=!0,Sy((function(){for(var r,i=e.reactions;r=i.get();)qy(r,e);e.notified=!1,t&&!e.rejection&&Xy(e)})))},zy=function(e,t,r){var i,n;Vy?((i=By.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),hy.dispatchEvent(i)):i={promise:t,reason:r},!Py&&(n=hy["on"+e])?n(i):e===jy&&Ay("Unhandled promise rejection",r)},Xy=function(e){dy(Ty,hy,(function(){var t,r=e.facade,i=e.value;if(Qy(e)&&(t=Ly((function(){cy?Gy.emit("unhandledRejection",i,r):zy(jy,r,i)})),e.rejection=cy||Qy(e)?2:1,t.error))throw t.value}))},Qy=function(e){return 1!==e.rejection&&!e.parent},$y=function(e){dy(Ty,hy,(function(){var t=e.facade;cy?Gy.emit("rejectionHandled",t):zy("rejectionhandled",t,e.value)}))},Jy=function(e,t,r){return function(i){e(t,i,r)}},Zy=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Wy(e,!0))},eE=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Uy("Promise can't be resolved itself");var i=Yy(t);i?Sy((function(){var r={done:!1};try{dy(i,t,Jy(eE,r,e),Jy(Zy,r,e))}catch(JV){Zy(r,JV,e)}})):(e.value=t,e.state=1,Wy(e,!1))}catch(JV){Zy({done:!1},JV,e)}}};Cy&&(Ny=(Fy=function(e){Ey(this,Ny),py(e),dy(oy,this);var t=xy(this);try{e(Jy(eE,t),Jy(Zy,t))}catch(JV){Zy(t,JV)}}).prototype,(oy=function(e){My(this,{type:wy,done:!1,notified:!1,parent:!1,reactions:new by,rejection:!1,state:0,value:void 0})}).prototype=fy(Ny,"then",(function(e,t){var r=xy(this),i=Ky(ky(this,Fy));return r.parent=!0,i.ok=!my(e)||e,i.fail=my(t)&&t,i.domain=cy?Gy.domain:void 0,0==r.state?r.reactions.add(i):Sy((function(){qy(i,r)})),i.promise})),ly=function(){var e=new oy,t=xy(e);this.promise=e,this.resolve=Jy(eE,t),this.reject=Jy(Zy,t)},_y.f=Ky=function(e){return e===Fy||undefined===e?new ly(e):Hy(e)}),uy({global:!0,constructor:!0,wrap:!0,forced:Cy},{Promise:Fy}),vy(Fy,wy,!1,!0),gy(wy);var tE=vt("iterator"),rE=!1;try{var iE=0,nE={next:function(){return{done:!!iE++}},return:function(){rE=!0}};nE[tE]=function(){return this},Array.from(nE,(function(){throw 2}))}catch(JV){}var aE=function(e,t){if(!t&&!rE)return!1;var r=!1;try{var i={};i[tE]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(JV){}return r},sE=Gm,oE=ry.CONSTRUCTOR||!aE((function(e){sE.all(e).then(void 0,(function(){}))})),lE=M,uE=xe,cE=iy,hE=Bm,dE=tp;wr({target:"Promise",stat:!0,forced:oE},{all:function(e){var t=this,r=cE.f(t),i=r.resolve,n=r.reject,a=hE((function(){var r=uE(t.resolve),a=[],s=0,o=1;dE(e,(function(e){var l=s++,u=!1;o++,lE(r,t,e).then((function(e){u||(u=!0,a[l]=e,--o||i(a))}),n)})),--o||i(a)}));return a.error&&n(a.value),r.promise}});var fE=wr,vE=ry.CONSTRUCTOR;Gm&&Gm.prototype,fE({target:"Promise",proto:!0,forced:vE,real:!0},{catch:function(e){return this.then(void 0,e)}});var gE=M,pE=xe,mE=iy,yE=Bm,EE=tp;wr({target:"Promise",stat:!0,forced:oE},{race:function(e){var t=this,r=mE.f(t),i=r.reject,n=yE((function(){var n=pE(t.resolve);EE(e,(function(e){gE(n,t,e).then(r.resolve,i)}))}));return n.error&&i(n.value),r.promise}});var kE=M,TE=iy;wr({target:"Promise",stat:!0,forced:ry.CONSTRUCTOR},{reject:function(e){var t=TE.f(this);return kE(t.reject,void 0,e),t.promise}});var SE=nr,AE=re,LE=iy,bE=function(e,t){if(SE(e),AE(t)&&t.constructor===e)return t;var r=LE.f(e);return(0,r.resolve)(t),r.promise},RE=wr,IE=Gm,DE=ry.CONSTRUCTOR,_E=bE,wE=le("Promise"),CE=!DE;RE({target:"Promise",stat:!0,forced:true},{resolve:function(e){return _E(CE&&this===wE?IE:this,e)}});var PE=M,xE=xe,ME=iy,OE=Bm,FE=tp;wr({target:"Promise",stat:!0,forced:oE},{allSettled:function(e){var t=this,r=ME.f(t),i=r.resolve,n=r.reject,a=OE((function(){var r=xE(t.resolve),n=[],a=0,s=1;FE(e,(function(e){var o=a++,l=!1;s++,PE(r,t,e).then((function(e){l||(l=!0,n[o]={status:"fulfilled",value:e},--s||i(n))}),(function(e){l||(l=!0,n[o]={status:"rejected",reason:e},--s||i(n))}))})),--s||i(n)}));return a.error&&n(a.value),r.promise}});var NE=M,UE=xe,BE=le,GE=iy,KE=Bm,HE=tp,VE="No one promise resolved";wr({target:"Promise",stat:!0,forced:oE},{any:function(e){var t=this,r=BE("AggregateError"),i=GE.f(t),n=i.resolve,a=i.reject,s=KE((function(){var i=UE(t.resolve),s=[],o=0,l=1,u=!1;HE(e,(function(e){var c=o++,h=!1;l++,NE(i,t,e).then((function(e){h||u||(u=!0,n(e))}),(function(e){h||u||(h=!0,s[c]=e,--l||a(new r(s,VE)))}))})),--l||a(new r(s,VE))}));return s.error&&a(s.value),i.promise}});var jE=wr,YE=Gm,qE=o,WE=le,zE=_,XE=Np,QE=bE,$E=YE&&YE.prototype;jE({target:"Promise",proto:!0,real:!0,forced:!!YE&&qE((function(){$E.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=XE(this,WE("Promise")),r=zE(e);return this.then(r?function(r){return QE(t,e()).then((function(){return r}))}:e,r?function(r){return QE(t,e()).then((function(){throw r}))}:e)}});var JE=ie.Promise,ZE=iy,ek=Bm;wr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=ZE.f(this),r=ek(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var tk=i(JE),rk="\t\n\v\f\r                 \u2028\u2029\ufeff",ik=Q,nk=tn,ak=rk,sk=y("".replace),ok=RegExp("^["+ak+"]+"),lk=RegExp("(^|[^"+ak+"])["+ak+"]+$"),uk=function(e){return function(t){var r=nk(ik(t));return 1&e&&(r=sk(r,ok,"")),2&e&&(r=sk(r,lk,"$1")),r}},ck={start:uk(1),end:uk(2),trim:uk(3)},hk=s,dk=o,fk=y,vk=tn,gk=ck.trim,pk=rk,mk=hk.parseInt,yk=hk.Symbol,Ek=yk&&yk.iterator,kk=/^[+-]?0x/i,Tk=fk(kk.exec),Sk=8!==mk(pk+"08")||22!==mk(pk+"0x16")||Ek&&!dk((function(){mk(Object(Ek))}))?function(e,t){var r=gk(vk(e));return mk(r,t>>>0||(Tk(kk,r)?16:10))}:mk;wr({global:!0,forced:parseInt!=Sk},{parseInt:Sk});var Ak=i(ie.parseInt),Lk=ls.map;wr({target:"Array",proto:!0,forced:!Ui("map")},{map:function(e){return Lk(this,e,arguments.length>1?arguments[1]:void 0)}});var bk=nh("Array").map,Rk=ue,Ik=bk,Dk=Array.prototype,_k=i((function(e){var t=e.map;return e===Dk||Rk(Dk,e)&&t===Dk.map?Ik:t}));wr({target:"Array",stat:!0},{isArray:Br});var wk=ie.Array.isArray,Ck=i(wk),Pk=i(wk),xk=i(Kd),Mk=C,Ok=y,Fk=M,Nk=o,Uk=An,Bk=ca,Gk=O,Kk=$e,Hk=q,Vk=Object.assign,jk=Object.defineProperty,Yk=Ok([].concat),qk=!Vk||Nk((function(){if(Mk&&1!==Vk({b:1},Vk(jk({},"a",{enumerable:!0,get:function(){jk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),i="abcdefghijklmnopqrst";return e[r]=7,i.split("").forEach((function(e){t[e]=e})),7!=Vk({},e)[r]||Uk(Vk({},t)).join("")!=i}))?function(e,t){for(var r=Kk(e),i=arguments.length,n=1,a=Bk.f,s=Gk.f;i>n;)for(var o,l=Hk(arguments[n++]),u=a?Yk(Uk(l),a(l)):Uk(l),c=u.length,h=0;c>h;)o=u[h++],Mk&&!Fk(s,l,o)||(r[o]=l[o]);return r}:Vk,Wk=qk;wr({target:"Object",stat:!0,arity:2,forced:Object.assign!==Wk},{assign:Wk});var zk=i(ie.Object.assign),Xk=i(cc),Qk=wg,$k=i(Qk),Jk=i(Qk),Zk=i(Md),eT=i(Eh),tT=i(vf),rT=i(Sf),iT=i(Fr),nT=i(_c),aT=i(_h),sT=i(uh),oT=nr,lT=Kg,uT=Jt,cT=M,hT=$e,dT=function(e,t,r,i){try{return i?t(oT(r)[0],r[1]):t(r)}catch(JV){lT(e,"throw",JV)}},fT=Lg,vT=Ii,gT=zr,pT=ei,mT=Ng,yT=wg,ET=Array,kT=function(e){var t=hT(e),r=vT(this),i=arguments.length,n=i>1?arguments[1]:void 0,a=void 0!==n;a&&(n=uT(n,i>2?arguments[2]:void 0));var s,o,l,u,c,h,d=yT(t),f=0;if(!d||this===ET&&fT(d))for(s=gT(t),o=r?new this(s):ET(s);s>f;f++)h=a?n(t[f],f):t[f],pT(o,f,h);else for(c=(u=mT(t,d)).next,o=r?new this:[];!(l=cT(c,u)).done;f++)h=a?dT(u,n,[l.value,f],!0):l.value,pT(o,f,h);return o.length=f,o},TT=kT;wr({target:"Array",stat:!0,forced:!aE((function(e){Array.from(e)}))},{from:TT});var ST=ie.Array.from,AT=i(ST),LT=i(ST),bT=i(Pc);function RT(e,t){var r=gv(e);if(Zk){var i=Zk(e);t&&(i=xk(i).call(i,(function(t){return eT(e,t).enumerable}))),r.push.apply(r,i)}return r}function IT(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=RT(Object(n),!0)).call(r,(function(t){PT(e,t,n[t])})):tT?rT(e,tT(n)):vd(i=RT(Object(n))).call(i,(function(t){iT(e,t,eT(n,t))}))}return e}function DT(e){return(DT="function"==typeof Xk&&"symbol"==typeof nT?function(e){return typeof e}:function(e){return e&&"function"==typeof Xk&&e.constructor===Xk&&e!==Xk.prototype?"symbol":typeof e})(e)}function _T(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wT(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),iT(e,OT(i.key),i)}}function CT(e,t,r){return t&&wT(e.prototype,t),r&&wT(e,r),iT(e,"prototype",{writable:!1}),e}function PT(e,t,r){return(t=OT(t))in e?iT(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xT(e){return function(e){if(Pk(e))return MT(e)}(e)||function(e){if(void 0!==Xk&&null!=Jk(e)||null!=e["@@iterator"])return LT(e)}(e)||function(e,t){var r;if(!e)return;if("string"==typeof e)return MT(e,t);var i=Fv(r=Object.prototype.toString.call(e)).call(r,8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return LT(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return MT(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function MT(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function OT(e){var t=function(e,t){if("object"!==Cc(e)||null===e)return e;var r=e[bT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Cc(t)?t:String(t)}var FT=ls.some;wr({target:"Array",proto:!0,forced:!rd("some")},{some:function(e){return FT(this,e,arguments.length>1?arguments[1]:void 0)}});var NT=nh("Array").some,UT=ue,BT=NT,GT=Array.prototype,KT=i((function(e){var t=e.some;return e===GT||UT(GT,e)&&t===GT.some?BT:t})),HT=Vr,VT=tn,jT=Q,YT=RangeError,qT=y,WT=qr,zT=tn,XT=Q,QT=qT((function(e){var t=VT(jT(this)),r="",i=HT(e);if(i<0||i==1/0)throw YT("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r})),$T=qT("".slice),JT=Math.ceil,ZT=function(e){return function(t,r,i){var n,a,s=zT(XT(t)),o=WT(r),l=s.length,u=void 0===i?" ":zT(i);return o<=l||""==u?s:((a=QT(u,JT((n=o-l)/u.length))).length>n&&(a=$T(a,0,n)),e?s+a:a+s)}},eS={start:ZT(!1),end:ZT(!0)},tS=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),rS=eS.start;wr({target:"String",proto:!0,forced:tS},{padStart:function(e){return rS(this,e,arguments.length>1?arguments[1]:void 0)}});var iS=nh("String").padStart,nS=ue,aS=iS,sS=String.prototype,oS=i((function(e){var t=e.padStart;return"string"==typeof e||e===sS||nS(sS,e)&&t===sS.padStart?aS:t})),lS=i(ie.setInterval),uS=ls.every;wr({target:"Array",proto:!0,forced:!rd("every")},{every:function(e){return uS(this,e,arguments.length>1?arguments[1]:void 0)}});var cS=nh("Array").every,hS=ue,dS=cS,fS=Array.prototype,vS=i((function(e){var t=e.every;return e===fS||hS(fS,e)&&t===fS.every?dS:t})),gS=s,pS=o,mS=tn,yS=ck.trim,ES=rk,kS=y("".charAt),TS=gS.parseFloat,SS=gS.Symbol,AS=SS&&SS.iterator,LS=1/TS(ES+"-0")!=-1/0||AS&&!pS((function(){TS(Object(AS))}))?function(e){var t=yS(mS(e)),r=TS(t);return 0===r&&"-"==kS(t,0)?-0:r}:TS;wr({global:!0,forced:parseFloat!=LS},{parseFloat:LS});var bS=i(ie.parseFloat),RS=bl.PROPER,IS=o,DS=rk,_S=ck.trim;wr({target:"String",proto:!0,forced:function(e){return IS((function(){return!!DS[e]()||"​…᠎"!=="​…᠎"[e]()||RS&&DS[e].name!==e}))}("trim")},{trim:function(){return _S(this)}});var wS=nh("String").trim,CS=ue,PS=wS,xS=String.prototype,MS=i((function(e){var t=e.trim;return"string"==typeof e||e===xS||CS(xS,e)&&t===xS.trim?PS:t})),OS=na,FS=Math.floor,NS=function(e,t){var r=e.length,i=FS(r/2);return r<8?US(e,t):BS(e,NS(OS(e,0,i),t),NS(OS(e,i),t),t)},US=function(e,t){for(var r,i,n=e.length,a=1;a<n;){for(i=a,r=e[a];i&&t(e[i-1],r)>0;)e[i]=e[--i];i!==a++&&(e[i]=r)}return e},BS=function(e,t,r,i){for(var n=t.length,a=r.length,s=0,o=0;s<n||o<a;)e[s+o]=s<n&&o<a?i(t[s],r[o])<=0?t[s++]:r[o++]:s<n?t[s++]:r[o++];return e},GS=NS,KS=ce.match(/firefox\/(\d+)/i),HS=!!KS&&+KS[1],VS=/MSIE|Trident/.test(ce),jS=ce.match(/AppleWebKit\/(\d+)\./),YS=!!jS&&+jS[1],qS=wr,WS=y,zS=xe,XS=$e,QS=zr,$S=Bv,JS=tn,ZS=o,eA=GS,tA=rd,rA=HS,iA=VS,nA=me,aA=YS,sA=[],oA=WS(sA.sort),lA=WS(sA.push),uA=ZS((function(){sA.sort(void 0)})),cA=ZS((function(){sA.sort(null)})),hA=tA("sort"),dA=!ZS((function(){if(nA)return nA<70;if(!(rA&&rA>3)){if(iA)return!0;if(aA)return aA<603;var e,t,r,i,n="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(i=0;i<47;i++)sA.push({k:t+i,v:r})}for(sA.sort((function(e,t){return t.v-e.v})),i=0;i<sA.length;i++)t=sA[i].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));qS({target:"Array",proto:!0,forced:uA||!cA||!hA||!dA},{sort:function(e){void 0!==e&&zS(e);var t=XS(this);if(dA)return void 0===e?oA(t):oA(t,e);var r,i,n=[],a=QS(t);for(i=0;i<a;i++)i in t&&lA(n,t[i]);for(eA(n,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:JS(t)>JS(r)?1:-1}}(e)),r=QS(n),i=0;i<r;)t[i]=n[i++];for(;i<a;)$S(t,i++);return t}});var fA=nh("Array").sort,vA=ue,gA=fA,pA=Array.prototype,mA=i((function(e){var t=e.sort;return e===pA||vA(pA,e)&&t===pA.sort?gA:t})),yA=wr,EA=Date,kA=y(EA.prototype.getTime);yA({target:"Date",stat:!0},{now:function(){return kA(new EA)}});var TA,SA=i(ie.Date.now),AA="undefined"!=typeof window&&window.location&&av(TA=window.location.href).call(TA,"xgplayerdebugger=1")>-1,LA="color: #525252; background-color: #90ee90;",bA="color: #525252; background-color: red;",RA="color: #525252; background-color: yellow; ",IA="%c[xgplayer]",DA={config:{debug:AA?3:0},logInfo:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=3&&(r=console).log.apply(r,_d(t=[IA,LA,e]).call(t,n))},logWarn:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=1&&(r=console).warn.apply(r,_d(t=[IA,RA,e]).call(t,n))},logError:function(e){var t,r;if(!(this.config.debug<1)){for(var i=this.config.debug>=2?"trace":"error",n=arguments.length,a=new Array(n>1?n-1:0),s=1;s<n;s++)a[s-1]=arguments[s];(r=console)[i].apply(r,_d(t=[IA,bA,e]).call(t,a))}}},_A=function(){function e(t){_T(this,e),this.bufferedList=t}return CT(e,[{key:"start",value:function(e){return this.bufferedList[e].start}},{key:"end",value:function(e){return this.bufferedList[e].end}},{key:"length",get:function(){return this.bufferedList.length}}]),e}(),wA={};wA.createDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=document.createElement(t);return a.className=n,a.innerHTML=r,vd(e=gv(i)).call(e,(function(e){var r=e,n=i[e];"video"===t||"audio"===t||"live-video"===t?n&&a.setAttribute(r,n):a.setAttribute(r,n)})),a},wA.createDomFromHtml=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{var i=document.createElement("div");i.innerHTML=e;var n=i.children;if(i=null,n.length>0){var a;if(n=n[0],r&&wA.addClass(n,r),t)vd(a=gv(t)).call(a,(function(e){n.setAttribute(e,t[e])}));return n}return null}catch(s){return DA.logError("util.createDomFromHtml",s),null}},wA.hasClass=function(e,t){if(!e||!t)return!1;try{return KT(Array.prototype).call(e.classList,(function(e){return e===t}))}catch(i){var r=e.className&&"object"===DT(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},wA.addClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.add(t)}))}catch(i){wA.hasClass(e,t)||(e.className&&"object"===DT(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},wA.removeClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.remove(t)}))}catch(n){var i;if(wA.hasClass(e,t))vd(i=t.split(/\s+/g)).call(i,(function(t){var r=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===DT(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")}))}},wA.toggleClass=function(e,t){var r;e&&vd(r=t.split(/\s+/g)).call(r,(function(t){wA.hasClass(e,t)?wA.removeClass(e,t):wA.addClass(e,t)}))},wA.classNames=function(){for(var e=arguments,t=[],r=function(r){if("String"===wA.typeOf(e[r]))t.push(e[r]);else if("Object"===wA.typeOf(e[r])){var i;_k(i=gv(e[r])).call(i,(function(i){e[r][i]&&t.push(i)}))}},i=0;i<arguments.length;i++)r(i);return t.join(" ")},wA.findDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,r=arguments.length>1?arguments[1]:void 0;try{e=t.querySelector(r)}catch(i){DA.logError("util.findDom",i),0===av(r).call(r,"#")&&(e=t.getElementById(Fv(r).call(r,1)))}return e},wA.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},wA.padStart=function(e,t,r){for(var i=String(r),n=t>>0,a=Math.ceil(n/i.length),s=[],o=String(e);a--;)s.push(i);return s.join("").substring(0,n-o.length)+o},wA.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=oS(wA).call(wA,Math.floor(e/3600),2,0),r=oS(wA).call(wA,Math.floor((e-3600*t)/60),2,0),i=oS(wA).call(wA,Math.floor(e-3600*t-60*r),2,0);return("00"===t?[r,i]:[t,r,i]).join(":")},wA.event=function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},wA.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},wA.deepCopy=function(e,t){var r;if("Object"===wA.typeOf(t)&&"Object"===wA.typeOf(e))return vd(r=gv(t)).call(r,(function(r){if("Object"!==wA.typeOf(t[r])||t[r]instanceof Node)if("Array"===wA.typeOf(t[r])){var i;e[r]="Array"===wA.typeOf(e[r])?_d(i=e[r]).call(i,t[r]):t[r]}else e[r]=t[r];else void 0===e[r]||void 0===e[r]?e[r]=t[r]:wA.deepCopy(e[r],t[r])})),e},wA.deepMerge=function(e,t){var r;return _k(r=gv(t)).call(r,(function(r){var i;"Array"===wA.typeOf(t[r])&&"Array"===wA.typeOf(e[r])?"Array"===wA.typeOf(e[r])&&(i=e[r]).push.apply(i,xT(t[r])):wA.typeOf(e[r])!==wA.typeOf(t[r])||null===e[r]||"Object"!==wA.typeOf(e[r])||t[r]instanceof window.Node?null!==t[r]&&(e[r]=t[r]):wA.deepMerge(e[r],t[r])})),e},wA.getBgImage=function(e){var t=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;if(!t||"none"===t)return"";var r=document.createElement("a");return r.href=t.replace(/url\("|"\)/g,""),r.href},wA.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return vd(Array.prototype).call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},wA.setInterval=function(e,t,r,i){e._interval[t]||(e._interval[t]=lS(sT(r).call(r,e),i))},wA.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},wA.setTimeout=function(e,t,r){e._timers||(e._timers=[]);var i=Wf((function(){t(),wA.clearTimeout(e,i)}),r);return e._timers.push(i),i},wA.clearTimeout=function(e,t){var r=e._timers;if("Array"===wA.typeOf(r)){for(var i=0;i<r.length;i++)if(r[i]===t){ig(r).call(r,i,1),clearTimeout(t);break}}else clearTimeout(t)},wA.clearAllTimers=function(e){var t=e._timers;"Array"===wA.typeOf(t)&&(_k(t).call(t,(function(e){clearTimeout(e)})),e._timerIds=[])},wA.createImgBtn=function(e,t,r,i){var n,a,s,o,l,u,c,h,d,f,v,g,p=wA.createDom("xg-".concat(e),"",{},"xgplayer-".concat(e,"-img"));(p.style.backgroundImage='url("'.concat(t,'")'),r&&i)&&(vS(n=["px","rem","em","pt","dp","vw","vh","vm","%"]).call(n,(function(e){var t,n;return!(av(r).call(r,e)>-1&&av(i).call(i,e)>-1)||(c=bS(MS(t=Fv(r).call(r,0,av(r).call(r,e))).call(t)),h=bS(MS(n=Fv(i).call(i,0,av(i).call(i,e))).call(n)),d=e,!1)})),p.style.width=_d(a="".concat(c)).call(a,d),p.style.height=_d(s="".concat(h)).call(s,d),p.style.backgroundSize=_d(o=_d(l=_d(u="".concat(c)).call(u,d," ")).call(l,h)).call(o,d),p.style.margin="start"===e?_d(f=_d(v=_d(g="-".concat(h/2)).call(g,d," auto auto -")).call(v,c/2)).call(f,d):"auto 5px auto 5px");return p},wA.Hex2RGBA=function(e,t){var r,i=[];if(/^\#[0-9A-F]{3}$/i.test(e)){var n="#";e.replace(/[0-9A-F]/gi,(function(e){n+=e+e})),e=n}return/^#[0-9A-F]{6}$/i.test(e)?(e.replace(/[0-9A-F]{2}/gi,(function(e){i.push(Ak(e,16))})),_d(r="rgba(".concat(i.join(","),", ")).call(r,t,")")):"rgba(255, 255, 255, 0.1)"},wA.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},wA.checkIsFunction=function(e){return e&&"function"==typeof e},wA.checkIsObject=function(e){return null!==e&&"object"===DT(e)},wA.hide=function(e){e.style.display="none"},wA.show=function(e,t){e.style.display=t||"block"},wA.isUndefined=function(e){if(null==e)return!0},wA.isNotNull=function(e){return!(null==e)},wA.setStyleFromCsstext=function(e,t){if(t)if("String"===wA.typeOf(t)){var r=t.replace(/\s+/g,"").split(";");_k(r).call(r,(function(t){if(t){var r=t.split(":");r.length>1&&(e.style[r[0]]=r[1])}}))}else{var i;_k(i=gv(t)).call(i,(function(r){e.style[r]=t[r]}))}},wA.filterStyleFromText=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height","top","left","bottom","right","position","z-index","padding","margin","transform"],i=e.style.cssText;if(!i)return{};var n=i.replace(/\s+/g,"").split(";"),a={},s={};return _k(n).call(n,(function(e){if(e){var t=e.split(":");t.length>1&&(!function(e,t){for(var r=0,i=t.length;r<i;r++)if(av(e).call(e,t[r])>-1)return!0;return!1}(t[0],r)?s[t[0]]=t[1]:a[t[0]]=t[1])}})),e.setAttribute("style",""),_k(t=gv(s)).call(t,(function(t){e.style[t]=s[t]})),a},wA.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var r=t.replace(/\s+/g,"").split(";"),i={};return _k(r).call(r,(function(e){if(e){var t=e.split(":");t.length>1&&(i[t[0]]=t[1])}})),i},wA.preloadImg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(e){var i=new window.Image;i.onload=function(e){i=null,t&&t(e)},i.onerror=function(e){i=null,r&&r(e)},i.src=e}},wA.stopPropagation=function(e){e&&e.stopPropagation()},wA.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},wA.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},wA.checkTouchSupport=function(){return"ontouchstart"in window},wA.getBuffered2=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=[],i=0;i<e.length;i++)r.push({start:e.start(i)<.5?0:e.start(i),end:e.end(i)});mA(r).call(r,(function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var n=[];if(t)for(var a=0;a<r.length;a++){var s=n.length;if(s){var o=n[s-1].end;r[a].start-o<t?r[a].end>o&&(n[s-1].end=r[a].end):n.push(r[a])}else n.push(r[a])}else n=r;return new _A(n)},wA.getEventPos=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.touches&&e.touches.length>0&&(e=e.touches[0]),{x:e.x/t,y:e.y/t,clientX:e.clientX/t,clientY:e.clientY/t,offsetX:e.offsetX/t,offsetY:e.offsetY/t,pageX:e.pageX/t,pageY:e.pageY/t}},wA.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},wA.getHostFromUrl=function(e){if("String"!==wA.typeOf(e))return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r},wA.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},wA.isMSE=function(e){return e.media&&(e=e.media),!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},wA.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},wA.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=Ak(e)}catch(r){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=Ak(window.performance.now())),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)}))},wA.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},wA.adjustTimeByDuration=function(e,t,r){return t&&e&&(e>t||r&&e<t)?t:e},wA.createPositionBar=function(e,t){var r=wA.createDom("xg-bar","",{"data-index":-1},e);return t.appendChild(r),r},wA.getTransformStyle=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0,scale:1,rotate:0},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i={scale:"".concat(t.scale||1),translate:_d(e="".concat(t.x||0,"%, ")).call(e,t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")},n=gv(i);return vd(n).call(n,(function(e){var t,n=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),a=_d(t="".concat(e,"(")).call(t,i[e],")");n.test(r)?(n.lastIndex=-1,r=r.replace(n,a)):r+="".concat(a," ")})),r},wA.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},wA.getIndexByTime=function(e,t){var r=t.length,i=-1;if(r<1)return i;if(e<=t[0].end||r<2)i=0;else if(e>t[r-1].end)i=r-1;else for(var n=1;n<r;n++)if(e>t[n-1].end&&e<=t[n].end){i=n;break}return i},wA.getOffsetCurrentTime=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=-1;if((i=r>=0&&r<t.length?r:wA.getIndexByTime(e,t))<0)return-1;var n=t.length,a=t[i],s=a.start,o=a.end,l=a.cTime,u=a.offset;return e<s?l:e>=s&&e<=o?e-u:e>o&&i>=n-1?o:-1},wA.getCurrentTimeByOffset=function(e,t){var r=-1;if(!t||t.length<0)return e;for(var i=0;i<t.length;i++)if(e<=t[i].duration){r=i;break}if(-1!==r){var n=t[r].start;return r-1<0?n+e:n+(e-t[r-1].duration)}return e};var CA="urlchange";function PA(e,t,r){for(var i,n=arguments.length,a=new Array(n>3?n-3:0),s=3;s<n;s++)a[s-3]=arguments[s];var o,l=t.call.apply(t,_d(i=[e]).call(i,a));r&&"function"==typeof r&&(l&&l.then?l.then((function(){for(var t,i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];r.call.apply(r,_d(t=[e]).call(t,n))})):r.call.apply(r,_d(o=[e]).call(o,a)))}function xA(e,t){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{pre:null,next:null};return this.__hooks||(this.__hooks={}),!this.__hooks[e]&&(this.__hooks[e]=null),sT(r=function(){var r,n=arguments,a=this;if(i.pre)try{var s,o;(o=i.pre).call.apply(o,_d(s=[this]).call(s,Fv(Array.prototype).call(arguments)))}catch(p){var l,u;throw p.message=_d(l=_d(u="[pluginName: ".concat(this.pluginName,":")).call(u,e,":pre error] >> ")).call(l,p.message),p}if(this.__hooks&&this.__hooks[e])try{var c,h,d=NA.apply(void 0,_d(c=[this,e,t]).call(c,Fv(Array.prototype).call(arguments)));if(d)if(d.then)d.then((function(e){var r;!1!==e&&PA.apply(void 0,_d(r=[a,t,i.next]).call(r,xT(n)))})).catch((function(e){throw e}));else PA.apply(void 0,_d(h=[this,t,i.next]).call(h,Fv(Array.prototype).call(arguments)));else if(void 0===d){var f;PA.apply(void 0,_d(f=[this,t,i.next]).call(f,Fv(Array.prototype).call(arguments)))}}catch(p){var v,g;throw p.message=_d(v=_d(g="[pluginName: ".concat(this.pluginName,":")).call(g,e,"] >> ")).call(v,p.message),p}else PA.apply(void 0,_d(r=[this,t,i.next]).call(r,Fv(Array.prototype).call(arguments)))}).call(r,this)}function MA(e,t){var r=this.__hooks;if(!r||!Pk(r[e]))return-1;for(var i=r[e],n=0;n<i.length;n++)if(i[n]===t)return n;return-1}function OA(e,t){var r=this.__hooks;if(r)return r.hasOwnProperty(e)?(Pk(r[e])||(r[e]=[]),-1===MA.call(this,e,t)&&r[e].push(t),!0):(console.warn("has no supported hook which name [".concat(e,"]")),!1)}function FA(e,t){var r=this.__hooks;if(r)if(Pk(r[e])){var i=r[e],n=MA.call(this,e,t);-1!==n&&ig(i).call(i,n,1)}else r[e]&&(r[e]=null)}function NA(e,t,r){for(var i=arguments.length,n=new Array(i>3?i-3:0),a=3;a<i;a++)n[a-3]=arguments[a];if(e.__hooks&&Pk(e.__hooks[t])){var s,o=e.__hooks[t],l=-1;return function e(t,r,i){for(var n,a,s=arguments.length,u=new Array(s>3?s-3:0),c=3;c<s;c++)u[c-3]=arguments[c];if(l++,0===o.length||l===o.length)return i.call.apply(i,_d(a=[t,t]).call(a,u));var h,d=o[l],f=d.call.apply(d,_d(n=[t,t]).call(n,u));return f&&f.then?f.then((function(n){var a;return!1===n?null:e.apply(void 0,_d(a=[t,r,i]).call(a,u))})).catch((function(e){console.warn("[runHooks]".concat(r," reject"),e.message)})):!1!==f?e.apply(void 0,_d(h=[t,r,i]).call(h,u)):!1!==f&&void 0}.apply(void 0,_d(s=[e,t,r]).call(s,n))}var u;return r.call.apply(r,_d(u=[e,e]).call(u,n))}function UA(e,t){var r;DA.logError(_d(r="[".concat(e,"] event or callback cant be undefined or null when call ")).call(r,t))}var BA=function(){function e(t){_T(this,e),wA.checkIsFunction(this.beforeCreate)&&this.beforeCreate(t),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&_k(t).call(t,(function(t){e.__hooks[t]=null})),iT(e,"hooks",{get:function(){var t;return e.__hooks&&_k(t=gv(e.__hooks)).call(t,(function(t){if(e.__hooks[t])return t}))}})}(this),this.__args=t,this.__events={},this.__onceEvents={},this.config=t.config||{},this.player=null,this.playerConfig={},this.pluginName="",this.__init(t)}return CT(e,[{key:"beforeCreate",value:function(e){}},{key:"afterCreate",value:function(){}},{key:"beforePlayerInit",value:function(){}},{key:"onPluginsReady",value:function(){}},{key:"afterPlayerInit",value:function(){}},{key:"destroy",value:function(){}},{key:"__init",value:function(e){this.player=e.player,this.playerConfig=e.player&&e.player.config,this.pluginName=e.pluginName?e.pluginName.toLowerCase():this.constructor.pluginName.toLowerCase(),this.logger=e.player&&e.player.logger}},{key:"updateLang",value:function(e){e||(e=this.lang)}},{key:"lang",get:function(){return this.player.lang}},{key:"i18n",get:function(){return this.player.i18n}},{key:"i18nKeys",get:function(){return this.player.i18nKeys}},{key:"domEventType",get:function(){var e=wA.checkTouchSupport()?"touch":"mouse";return!this.playerConfig||"touch"!==this.playerConfig.domEventType&&"mouse"!==this.playerConfig.domEventType||(e=this.playerConfig.domEventType),e}},{key:"on",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(this.__events[e]=t,this.player.on(e,t)):Pk(e)&&vd(e).call(e,(function(e){r.__events[e]=t,r.player.on(e,t)})):UA(this.pluginName,"plugin.on(event, callback)")}},{key:"once",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(this.__onceEvents[e]=t,this.player.once(e,t)):Pk(e)&&vd(e).call(e,(function(i){r.__onceEvents[i]=t,r.player.once(e,t)})):UA(this.pluginName,"plugin.once(event, callback)")}},{key:"off",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(delete this.__events[e],this.player.off(e,t)):Pk(e)&&vd(e).call(e,(function(i){delete r.__events[e],r.player.off(i,t)})):UA(this.pluginName,"plugin.off(event, callback)")}},{key:"offAll",value:function(){var e,t=this;vd(e=["__events","__onceEvents"]).call(e,(function(e){var r;vd(r=gv(t[e])).call(r,(function(r){t[e][r]&&t.off(r,t[e][r]),r&&delete t[e][r]}))})),this.__events={},this.__onceEvents={}}},{key:"emit",value:function(e){var t,r;if(this.player){for(var i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];(r=this.player).emit.apply(r,_d(t=[e]).call(t,n))}}},{key:"emitUserAction",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var i=IT(IT({},r),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,i)}}},{key:"hook",value:function(e,t){var r;return xA.call.apply(xA,_d(r=[this]).call(r,Fv(Array.prototype).call(arguments)))}},{key:"useHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return OA.call.apply(OA,_d(r=[this]).call(r,Fv(Array.prototype).call(arguments)))}},{key:"removeHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return FA.call.apply(FA,_d(r=[this]).call(r,Fv(Array.prototype).call(arguments)))}},{key:"registerPlugin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(this.player)return r&&(t.pluginName=r),this.player.registerPlugin({plugin:e,options:t})}},{key:"getPlugin",value:function(e){return this.player?this.player.getPlugin(e):null}},{key:"__destroy",value:function(){var e,t=this,r=this.player,i=this.pluginName;this.offAll(),wA.clearAllTimers(this),wA.checkIsFunction(this.destroy)&&this.destroy(),_k(e=["player","playerConfig","pluginName","logger","__args","__hooks"]).call(e,(function(e){t[e]=null})),r.unRegisterPlugin(i),this.__hooks=null}}],[{key:"defineGetterOrSetter",value:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&iT(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]&&iT(e,r,{configurable:!0,value:t[r]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}(),GA=o,KA=vt("iterator"),HA=!GA((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[KA]||"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})),VA=y,jA=2147483647,YA=/[^\0-\u007E]/,qA=/[.\u3002\uFF0E\uFF61]/g,WA="Overflow: input needs wider integers to process",zA=RangeError,XA=VA(qA.exec),QA=Math.floor,$A=String.fromCharCode,JA=VA("".charCodeAt),ZA=VA([].join),eL=VA([].push),tL=VA("".replace),rL=VA("".split),iL=VA("".toLowerCase),nL=function(e){return e+22+75*(e<26)},aL=function(e,t,r){var i=0;for(e=r?QA(e/700):e>>1,e+=QA(e/t);e>455;)e=QA(e/35),i+=36;return QA(i+36*e/(e+38))},sL=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var n=JA(e,r++);if(n>=55296&&n<=56319&&r<i){var a=JA(e,r++);56320==(64512&a)?eL(t,((1023&n)<<10)+(1023&a)+65536):(eL(t,n),r--)}else eL(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&&eL(t,$A(i));var l=t.length,u=l;for(l&&eL(t,"-");u<n;){var c=jA;for(r=0;r<e.length;r++)(i=e[r])>=a&&i<c&&(c=i);var h=u+1;if(c-a>QA((jA-s)/h))throw zA(WA);for(s+=(c-a)*h,a=c,r=0;r<e.length;r++){if((i=e[r])<a&&++s>jA)throw zA(WA);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;eL(t,$A(nL(v+g%p))),d=QA(g/p),f+=36}eL(t,$A(nL(d))),o=aL(s,h,u==l),s=0,u++}}s++,a++}return ZA(t,"")},oL=da,lL=function(e,t,r){for(var i in t)r&&r.unsafe&&e[i]?e[i]=t[i]:oL(e,i,t[i],r);return e},uL=wr,cL=s,hL=M,dL=y,fL=C,vL=HA,gL=da,pL=va,mL=lL,yL=Ua,EL=$l,kL=es,TL=Pp,SL=_,AL=et,LL=Jt,bL=ui,RL=nr,IL=re,DL=tn,_L=zn,wL=K,CL=Ng,PL=wg,xL=wf,ML=GS,OL=vt("iterator"),FL="URLSearchParams",NL=FL+"Iterator",UL=kL.set,BL=kL.getterFor(FL),GL=kL.getterFor(NL),KL=Object.getOwnPropertyDescriptor,HL=function(e){if(!fL)return cL[e];var t=KL(cL,e);return t&&t.value},VL=HL("fetch"),jL=HL("Request"),YL=HL("Headers"),qL=jL&&jL.prototype,WL=YL&&YL.prototype,zL=cL.RegExp,XL=cL.TypeError,QL=cL.decodeURIComponent,$L=cL.encodeURIComponent,JL=dL("".charAt),ZL=dL([].join),eb=dL([].push),tb=dL("".replace),rb=dL([].shift),ib=dL([].splice),nb=dL("".split),ab=dL("".slice),sb=/\+/g,ob=Array(4),lb=function(e){return ob[e-1]||(ob[e-1]=zL("((?:%[\\da-f]{2}){"+e+"})","gi"))},ub=function(e){try{return QL(e)}catch(JV){return e}},cb=function(e){var t=tb(e,sb," "),r=4;try{return QL(t)}catch(JV){for(;r;)t=tb(t,lb(r--),ub);return t}},hb=/[!'()~]|%20/g,db={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},fb=function(e){return db[e]},vb=function(e){return tb($L(e),hb,fb)},gb=EL((function(e,t){UL(this,{type:NL,iterator:CL(BL(e).entries),kind:t})}),"Iterator",(function(){var e=GL(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),pb=function(e){this.entries=[],this.url=null,void 0!==e&&(IL(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===JL(e,0)?ab(e,1):e:DL(e)))};pb.prototype={type:FL,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,a,s,o,l=PL(e);if(l)for(r=(t=CL(e,l)).next;!(i=hL(r,t)).done;){if(a=(n=CL(RL(i.value))).next,(s=hL(a,n)).done||(o=hL(a,n)).done||!hL(a,n).done)throw XL("Expected sequence with length 2");eb(this.entries,{key:DL(s.value),value:DL(o.value)})}else for(var u in e)AL(e,u)&&eb(this.entries,{key:u,value:DL(e[u])})},parseQuery:function(e){if(e)for(var t,r,i=nb(e,"&"),n=0;n<i.length;)(t=i[n++]).length&&(r=nb(t,"="),eb(this.entries,{key:cb(rb(r)),value:cb(ZL(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],eb(r,vb(e.key)+"="+vb(e.value));return ZL(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var mb=function(){TL(this,yb);var e=UL(this,new pb(arguments.length>0?arguments[0]:void 0));fL||(this.length=e.entries.length)},yb=mb.prototype;if(mL(yb,{append:function(e,t){xL(arguments.length,2);var r=BL(this);eb(r.entries,{key:DL(e),value:DL(t)}),fL||this.length++,r.updateURL()},delete:function(e){xL(arguments.length,1);for(var t=BL(this),r=t.entries,i=DL(e),n=0;n<r.length;)r[n].key===i?ib(r,n,1):n++;fL||(this.length=r.length),t.updateURL()},get:function(e){xL(arguments.length,1);for(var t=BL(this).entries,r=DL(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){xL(arguments.length,1);for(var t=BL(this).entries,r=DL(e),i=[],n=0;n<t.length;n++)t[n].key===r&&eb(i,t[n].value);return i},has:function(e){xL(arguments.length,1);for(var t=BL(this).entries,r=DL(e),i=0;i<t.length;)if(t[i++].key===r)return!0;return!1},set:function(e,t){xL(arguments.length,1);for(var r,i=BL(this),n=i.entries,a=!1,s=DL(e),o=DL(t),l=0;l<n.length;l++)(r=n[l]).key===s&&(a?ib(n,l--,1):(a=!0,r.value=o));a||eb(n,{key:s,value:o}),fL||(this.length=n.length),i.updateURL()},sort:function(){var e=BL(this);ML(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=BL(this).entries,i=LL(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 gb(this,"keys")},values:function(){return new gb(this,"values")},entries:function(){return new gb(this,"entries")}},{enumerable:!0}),gL(yb,OL,yb.entries,{name:"entries"}),gL(yb,"toString",(function(){return BL(this).serialize()}),{enumerable:!0}),fL&&pL(yb,"size",{get:function(){return BL(this).entries.length},configurable:!0,enumerable:!0}),yL(mb,FL),uL({global:!0,constructor:!0,forced:!vL},{URLSearchParams:mb}),!vL&&SL(YL)){var Eb=dL(WL.has),kb=dL(WL.set),Tb=function(e){if(IL(e)){var t,r=e.body;if(bL(r)===FL)return t=e.headers?new YL(e.headers):new YL,Eb(t,"content-type")||kb(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),_L(e,{body:wL(0,DL(r)),headers:wL(0,t)})}return e};if(SL(VL)&&uL({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return VL(e,arguments.length>1?Tb(arguments[1]):{})}}),SL(jL)){var Sb=function(e){return TL(this,qL),new jL(e,arguments.length>1?Tb(arguments[1]):{})};qL.constructor=Sb,Sb.prototype=qL,uL({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Sb})}}var Ab,Lb=wr,bb=C,Rb=HA,Ib=s,Db=Jt,_b=y,wb=da,Cb=va,Pb=Pp,xb=et,Mb=qk,Ob=kT,Fb=na,Nb=kc.codeAt,Ub=function(e){var t,r,i=[],n=rL(tL(iL(e),qA,"."),".");for(t=0;t<n.length;t++)r=n[t],eL(i,XA(YA,r)?"xn--"+sL(r):r);return ZA(i,".")},Bb=tn,Gb=Ua,Kb=wf,Hb={URLSearchParams:mb,getState:BL},Vb=es,jb=Vb.set,Yb=Vb.getterFor("URL"),qb=Hb.URLSearchParams,Wb=Hb.getState,zb=Ib.URL,Xb=Ib.TypeError,Qb=Ib.parseInt,$b=Math.floor,Jb=Math.pow,Zb=_b("".charAt),eR=_b(/./.exec),tR=_b([].join),rR=_b(1..toString),iR=_b([].pop),nR=_b([].push),aR=_b("".replace),sR=_b([].shift),oR=_b("".split),lR=_b("".slice),uR=_b("".toLowerCase),cR=_b([].unshift),hR="Invalid scheme",dR="Invalid host",fR="Invalid port",vR=/[a-z]/i,gR=/[\d+-.a-z]/i,pR=/\d/,mR=/^0x/i,yR=/^[0-7]+$/,ER=/^\d+$/,kR=/^[\da-f]+$/i,TR=/[\0\t\n\r #%/:<>?@[\\\]^|]/,SR=/[\0\t\n\r #/:<>?@[\\\]^|]/,AR=/^[\u0000-\u0020]+/,LR=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,bR=/[\t\n\r]/g,RR=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)cR(t,e%256),e=$b(e/256);return tR(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+=rR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},IR={},DR=Mb({},IR,{" ":1,'"':1,"<":1,">":1,"`":1}),_R=Mb({},DR,{"#":1,"?":1,"{":1,"}":1}),wR=Mb({},_R,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),CR=function(e,t){var r=Nb(e,0);return r>32&&r<127&&!xb(t,e)?e:encodeURIComponent(e)},PR={ftp:21,file:null,http:80,https:443,ws:80,wss:443},xR=function(e,t){var r;return 2==e.length&&eR(vR,Zb(e,0))&&(":"==(r=Zb(e,1))||!t&&"|"==r)},MR=function(e){var t;return e.length>1&&xR(lR(e,0,2))&&(2==e.length||"/"===(t=Zb(e,2))||"\\"===t||"?"===t||"#"===t)},OR=function(e){return"."===e||"%2e"===uR(e)},FR={},NR={},UR={},BR={},GR={},KR={},HR={},VR={},jR={},YR={},qR={},WR={},zR={},XR={},QR={},$R={},JR={},ZR={},eI={},tI={},rI={},iI=function(e,t,r){var i,n,a,s=Bb(e);if(t){if(n=this.parse(s))throw Xb(n);this.searchParams=null}else{if(void 0!==r&&(i=new iI(r,!0)),n=this.parse(s,null,i))throw Xb(n);(a=Wb(new qb)).bindURL(this),this.searchParams=a}};iI.prototype={type:"URL",parse:function(e,t,r){var i,n,a,s,o,l=this,u=t||FR,c=0,h="",d=!1,f=!1,v=!1;for(e=Bb(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=aR(e,AR,""),e=aR(e,LR,"$1")),e=aR(e,bR,""),i=Ob(e);c<=i.length;){switch(n=i[c],u){case FR:if(!n||!eR(vR,n)){if(t)return hR;u=UR;continue}h+=uR(n),u=NR;break;case NR:if(n&&(eR(gR,n)||"+"==n||"-"==n||"."==n))h+=uR(n);else{if(":"!=n){if(t)return hR;h="",u=UR,c=0;continue}if(t&&(l.isSpecial()!=xb(PR,h)||"file"==h&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=h,t)return void(l.isSpecial()&&PR[l.scheme]==l.port&&(l.port=null));h="","file"==l.scheme?u=XR:l.isSpecial()&&r&&r.scheme==l.scheme?u=BR:l.isSpecial()?u=VR:"/"==i[c+1]?(u=GR,c++):(l.cannotBeABaseURL=!0,nR(l.path,""),u=eI)}break;case UR:if(!r||r.cannotBeABaseURL&&"#"!=n)return hR;if(r.cannotBeABaseURL&&"#"==n){l.scheme=r.scheme,l.path=Fb(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,u=rI;break}u="file"==r.scheme?XR:KR;continue;case BR:if("/"!=n||"/"!=i[c+1]){u=KR;continue}u=jR,c++;break;case GR:if("/"==n){u=YR;break}u=ZR;continue;case KR:if(l.scheme=r.scheme,n==Ab)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.query=r.query;else if("/"==n||"\\"==n&&l.isSpecial())u=HR;else if("?"==n)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.query="",u=tI;else{if("#"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.path.length--,u=ZR;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.query=r.query,l.fragment="",u=rI}break;case HR:if(!l.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,u=ZR;continue}u=YR}else u=jR;break;case VR:if(u=jR,"/"!=n||"/"!=Zb(h,c+1))continue;c++;break;case jR:if("/"!=n&&"\\"!=n){u=YR;continue}break;case YR:if("@"==n){d&&(h="%40"+h),d=!0,a=Ob(h);for(var g=0;g<a.length;g++){var p=a[g];if(":"!=p||v){var m=CR(p,wR);v?l.password+=m:l.username+=m}else v=!0}h=""}else if(n==Ab||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(d&&""==h)return"Invalid authority";c-=Ob(h).length+1,h="",u=qR}else h+=n;break;case qR:case WR:if(t&&"file"==l.scheme){u=$R;continue}if(":"!=n||f){if(n==Ab||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(l.isSpecial()&&""==h)return dR;if(t&&""==h&&(l.includesCredentials()||null!==l.port))return;if(s=l.parseHost(h))return s;if(h="",u=JR,t)return;continue}"["==n?f=!0:"]"==n&&(f=!1),h+=n}else{if(""==h)return dR;if(s=l.parseHost(h))return s;if(h="",u=zR,t==WR)return}break;case zR:if(!eR(pR,n)){if(n==Ab||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()||t){if(""!=h){var y=Qb(h,10);if(y>65535)return fR;l.port=l.isSpecial()&&y===PR[l.scheme]?null:y,h=""}if(t)return;u=JR;continue}return fR}h+=n;break;case XR:if(l.scheme="file","/"==n||"\\"==n)u=QR;else{if(!r||"file"!=r.scheme){u=ZR;continue}if(n==Ab)l.host=r.host,l.path=Fb(r.path),l.query=r.query;else if("?"==n)l.host=r.host,l.path=Fb(r.path),l.query="",u=tI;else{if("#"!=n){MR(tR(Fb(i,c),""))||(l.host=r.host,l.path=Fb(r.path),l.shortenPath()),u=ZR;continue}l.host=r.host,l.path=Fb(r.path),l.query=r.query,l.fragment="",u=rI}}break;case QR:if("/"==n||"\\"==n){u=$R;break}r&&"file"==r.scheme&&!MR(tR(Fb(i,c),""))&&(xR(r.path[0],!0)?nR(l.path,r.path[0]):l.host=r.host),u=ZR;continue;case $R:if(n==Ab||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&xR(h))u=ZR;else if(""==h){if(l.host="",t)return;u=JR}else{if(s=l.parseHost(h))return s;if("localhost"==l.host&&(l.host=""),t)return;h="",u=JR}continue}h+=n;break;case JR:if(l.isSpecial()){if(u=ZR,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=Ab&&(u=ZR,"/"!=n))continue}else l.fragment="",u=rI;else l.query="",u=tI;break;case ZR:if(n==Ab||"/"==n||"\\"==n&&l.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(o=uR(o=h))||"%2e."===o||".%2e"===o||"%2e%2e"===o?(l.shortenPath(),"/"==n||"\\"==n&&l.isSpecial()||nR(l.path,"")):OR(h)?"/"==n||"\\"==n&&l.isSpecial()||nR(l.path,""):("file"==l.scheme&&!l.path.length&&xR(h)&&(l.host&&(l.host=""),h=Zb(h,0)+":"),nR(l.path,h)),h="","file"==l.scheme&&(n==Ab||"?"==n||"#"==n))for(;l.path.length>1&&""===l.path[0];)sR(l.path);"?"==n?(l.query="",u=tI):"#"==n&&(l.fragment="",u=rI)}else h+=CR(n,_R);break;case eI:"?"==n?(l.query="",u=tI):"#"==n?(l.fragment="",u=rI):n!=Ab&&(l.path[0]+=CR(n,IR));break;case tI:t||"#"!=n?n!=Ab&&("'"==n&&l.isSpecial()?l.query+="%27":l.query+="#"==n?"%23":CR(n,IR)):(l.fragment="",u=rI);break;case rI:n!=Ab&&(l.fragment+=CR(n,DR))}c++}},parseHost:function(e){var t,r,i;if("["==Zb(e,0)){if("]"!=Zb(e,e.length-1))return dR;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 Zb(e,h)};if(":"==d()){if(":"!=Zb(e,1))return;h+=2,c=++u}for(;d();){if(8==u)return;if(":"!=d()){for(t=r=0;r<4&&eR(kR,d());)t=16*t+Qb(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(!eR(pR,d()))return;for(;eR(pR,d());){if(a=Qb(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}(lR(e,1,-1)),!t)return dR;this.host=t}else if(this.isSpecial()){if(e=Ub(e),eR(TR,e))return dR;if(t=function(e){var t,r,i,n,a,s,o,l=oR(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"==Zb(n,0)&&(a=eR(mR,n)?16:8,n=lR(n,8==a?1:2)),""===n)s=0;else{if(!eR(10==a?ER:8==a?yR:kR,n))return e;s=Qb(n,a)}nR(r,s)}for(i=0;i<t;i++)if(s=r[i],i==t-1){if(s>=Jb(256,5-t))return null}else if(s>255)return null;for(o=iR(r),i=0;i<r.length;i++)o+=r[i]*Jb(256,3-i);return o}(e),null===t)return dR;this.host=t}else{if(eR(SR,e))return dR;for(t="",r=Ob(e),i=0;i<r.length;i++)t+=CR(r[i],IR);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return xb(PR,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&xR(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+=RR(n),null!==a&&(u+=":"+a)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?s[0]:s.length?"/"+tR(s,"/"):"",null!==o&&(u+="?"+o),null!==l&&(u+="#"+l),u},setHref:function(e){var t=this.parse(e);if(t)throw Xb(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new nI(e.path[0]).origin}catch(JV){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+RR(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Bb(e)+":",FR)},getUsername:function(){return this.username},setUsername:function(e){var t=Ob(Bb(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=CR(t[r],wR)}},getPassword:function(){return this.password},setPassword:function(e){var t=Ob(Bb(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=CR(t[r],wR)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?RR(e):RR(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,qR)},getHostname:function(){var e=this.host;return null===e?"":RR(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,WR)},getPort:function(){var e=this.port;return null===e?"":Bb(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=Bb(e))?this.port=null:this.parse(e,zR))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+tR(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,JR))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=Bb(e))?this.query=null:("?"==Zb(e,0)&&(e=lR(e,1)),this.query="",this.parse(e,tI)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=Bb(e))?("#"==Zb(e,0)&&(e=lR(e,1)),this.fragment="",this.parse(e,rI)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var nI=function(e){var t=Pb(this,aI),r=Kb(arguments.length,1)>1?arguments[1]:void 0,i=jb(t,new iI(e,!1,r));bb||(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())},aI=nI.prototype,sI=function(e,t){return{get:function(){return Yb(this)[e]()},set:t&&function(e){return Yb(this)[t](e)},configurable:!0,enumerable:!0}};if(bb&&(Cb(aI,"href",sI("serialize","setHref")),Cb(aI,"origin",sI("getOrigin")),Cb(aI,"protocol",sI("getProtocol","setProtocol")),Cb(aI,"username",sI("getUsername","setUsername")),Cb(aI,"password",sI("getPassword","setPassword")),Cb(aI,"host",sI("getHost","setHost")),Cb(aI,"hostname",sI("getHostname","setHostname")),Cb(aI,"port",sI("getPort","setPort")),Cb(aI,"pathname",sI("getPathname","setPathname")),Cb(aI,"search",sI("getSearch","setSearch")),Cb(aI,"searchParams",sI("getSearchParams")),Cb(aI,"hash",sI("getHash","setHash"))),wb(aI,"toJSON",(function(){return Yb(this).serialize()}),{enumerable:!0}),wb(aI,"toString",(function(){return Yb(this).serialize()}),{enumerable:!0}),zb){var oI=zb.createObjectURL,lI=zb.revokeObjectURL;oI&&wb(nI,"createObjectURL",Db(oI,zb)),lI&&wb(nI,"revokeObjectURL",Db(lI,zb))}Gb(nI,"URL"),Lb({global:!0,constructor:!0,forced:!Rb,sham:!bb},{URL:nI});var uI=wr,cI=o,hI=wf,dI=tn,fI=HA,vI=le("URL");uI({target:"URL",stat:!0,forced:!(fI&&cI((function(){vI.canParse()})))},{canParse:function(e){var t=hI(arguments.length,1),r=dI(e),i=t<2||void 0===arguments[1]?void 0:dI(arguments[1]);try{return!!new vI(r,i)}catch(JV){return!1}}});var gI=i(ie.URL),pI=re,mI=S,yI=vt("match"),EI=function(e){var t;return pI(e)&&(void 0!==(t=e[yI])?!!t:"RegExp"==mI(e))},kI=TypeError,TI=function(e){if(EI(e))throw kI("The method doesn't accept regular expressions");return e},SI=vt("match"),AI=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[SI]=!1,"/./"[e](t)}catch(i){}}return!1},LI=wr,bI=b;w.f;var RI=qr,II=tn,DI=TI,_I=Q,wI=AI,CI=bI("".startsWith),PI=bI("".slice),xI=Math.min;LI({target:"String",proto:!0,forced:!wI("startsWith")},{startsWith:function(e){var t=II(_I(this));DI(e);var r=RI(xI(arguments.length>1?arguments[1]:void 0,t.length)),i=II(e);return CI?CI(t,i,r):PI(t,r,r+i.length)===i}});var MI=nh("String").startsWith,OI=ue,FI=MI,NI=String.prototype,UI=i((function(e){var t=e.startsWith;return"string"==typeof e||e===NI||OI(NI,e)&&t===NI.startsWith?FI:t})),BI=Sd.entries;wr({target:"Object",stat:!0},{entries:function(e){return BI(e)}});var GI=i(ie.Object.entries),KI=ie,HI=f;KI.JSON||(KI.JSON={stringify:JSON.stringify});var VI=function(e,t,r){return HI(KI.JSON.stringify,null,arguments)},jI=i(VI),YI=re,qI=Math.floor,WI=Number.isInteger||function(e){return!YI(e)&&isFinite(e)&&qI(e)===e};wr({target:"Number",stat:!0},{isInteger:WI});var zI=i(ie.Number.isInteger),XI=dn.includes;wr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return XI(this,e,arguments.length>1?arguments[1]:void 0)}});var QI=nh("Array").includes,$I=wr,JI=TI,ZI=Q,eD=tn,tD=AI,rD=y("".indexOf);$I({target:"String",proto:!0,forced:!tD("includes")},{includes:function(e){return!!~rD(eD(ZI(this)),eD(JI(e)),arguments.length>1?arguments[1]:void 0)}});var iD=nh("String").includes,nD=ue,aD=QI,sD=iD,oD=Array.prototype,lD=String.prototype,uD=i((function(e){var t=e.includes;return e===oD||nD(oD,e)&&t===oD.includes?aD:"string"==typeof e||e===lD||nD(lD,e)&&t===lD.includes?sD:t}));function cD(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 hD(e,t){var r;if(e){if("string"==typeof e)return cD(e,t);var i=Ov(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?AT(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?cD(e,t):void 0}}function dD(e){return function(e){if(Ck(e))return cD(e)}(e)||function(e){if(void 0!==hc&&null!=$k(e)||null!=e["@@iterator"])return AT(e)}(e)||hD(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 fD(e,t){return function(e){if(Ck(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==hc&&$k(e)||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(rf(o).call(o,i.value),o.length!==t);l=!0);}catch(c){u=!0,n=c}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return o}}(e,t)||hD(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 vD={exports:{}},gD=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),pD=o,mD=re,yD=S,ED=gD,kD=Object.isExtensible,TD=pD((function(){kD(1)}))||ED?function(e){return!!mD(e)&&((!ED||"ArrayBuffer"!=yD(e))&&(!kD||kD(e)))}:kD,SD=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),AD=wr,LD=y,bD=fn,RD=re,ID=et,DD=Zt.f,_D=Xn,wD=Jn,CD=TD,PD=SD,xD=!1,MD=at("meta"),OD=0,FD=function(e){DD(e,MD,{value:{objectID:"O"+OD++,weakData:{}}})},ND=vD.exports={enable:function(){ND.enable=function(){},xD=!0;var e=_D.f,t=LD([].splice),r={};r[MD]=1,e(r).length&&(_D.f=function(r){for(var i=e(r),n=0,a=i.length;n<a;n++)if(i[n]===MD){t(i,n,1);break}return i},AD({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:wD.f}))},fastKey:function(e,t){if(!RD(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!ID(e,MD)){if(!CD(e))return"F";if(!t)return"E";FD(e)}return e[MD].objectID},getWeakData:function(e,t){if(!ID(e,MD)){if(!CD(e))return!0;if(!t)return!1;FD(e)}return e[MD].weakData},onFreeze:function(e){return PD&&xD&&CD(e)&&!ID(e,MD)&&FD(e),e}};bD[MD]=!0;var UD=vD.exports,BD=wr,GD=s,KD=UD,HD=o,VD=yr,jD=tp,YD=Pp,qD=_,WD=re,zD=Ua,XD=Zt.f,QD=ls.forEach,$D=C,JD=es.set,ZD=es.getterFor,e_=function(e,t,r){var i,n=-1!==e.indexOf("Map"),a=-1!==e.indexOf("Weak"),s=n?"set":"add",o=GD[e],l=o&&o.prototype,u={};if($D&&qD(o)&&(a||l.forEach&&!HD((function(){(new o).entries().next()})))){var c=(i=t((function(t,r){JD(YD(t,c),{type:e,collection:new o}),null!=r&&jD(r,t[s],{that:t,AS_ENTRIES:n})}))).prototype,h=ZD(e);QD(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in l)||a&&"clear"==e||VD(c,e,(function(r,i){var n=h(this).collection;if(!t&&a&&!WD(r))return"get"==e&&void 0;var s=n[e](0===r?0:r,i);return t?this:s}))})),a||XD(c,"size",{configurable:!0,get:function(){return h(this).collection.size}})}else i=r.getConstructor(t,e,n,s),KD.enable();return zD(i,e,!1,!0),u[e]=i,BD({global:!0,forced:!0},u),a||r.setStrong(i,e,n),i},t_=zn,r_=va,i_=lL,n_=Jt,a_=Pp,s_=W,o_=tp,l_=Au,u_=Lu,c_=_p,h_=C,d_=UD.fastKey,f_=es.set,v_=es.getterFor,g_={getConstructor:function(e,t,r,i){var n=e((function(e,n){a_(e,a),f_(e,{type:t,index:t_(null),first:void 0,last:void 0,size:0}),h_||(e.size=0),s_(n)||o_(n,e[i],{that:e,AS_ENTRIES:r})})),a=n.prototype,s=v_(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=d_(t,!0),key:t,value:r,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=o),i&&(i.next=o),h_?a.size++:e.size++,"F"!==n&&(a.index[n]=o)),e},l=function(e,t){var r,i=s(e),n=d_(t);if("F"!==n)return i.index[n];for(r=i.first;r;r=r.next)if(r.key==t)return r};return i_(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,h_?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),h_?r.size--:t.size--}return!!i},forEach:function(e){for(var t,r=s(this),i=n_(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)}}),i_(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)}}),h_&&r_(a,"size",{configurable:!0,get:function(){return s(this).size}}),n},setStrong:function(e,t,r){var i=t+" Iterator",n=v_(t),a=v_(i);l_(e,t,(function(e,t){f_(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)?u_("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,u_(void 0,!0))}),r?"entries":"values",!r,!0),c_(t)}};e_("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),g_);var p_=ie.Map,m_=Jt,y_=M,E_=xe,k_=Fh,T_=W,S_=tp,A_=[].push,L_=function(e){var t,r,i,n,a=arguments.length,s=a>1?arguments[1]:void 0;return k_(this),(t=void 0!==s)&&E_(s),T_(e)?new this:(r=[],t?(i=0,n=m_(s,a>2?arguments[2]:void 0),S_(e,(function(e){y_(A_,r,n(e,i++))}))):S_(e,A_,{that:r}),new this(r))};wr({target:"Map",stat:!0,forced:!0},{from:L_});var b_=xo,R_=function(){return new this(b_(arguments))};wr({target:"Map",stat:!0,forced:!0},{of:R_});var I_=_e,D_=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(I_(e)+" is not a map")},__=function(e,t){return 1==t?function(t,r){return t[e](r)}:function(t,r,i){return t[e](r,i)}},w_=__,C_=le("Map"),P_={Map:C_,set:w_("set",2),get:w_("get",1),has:w_("has",1),remove:w_("delete",1),proto:C_.prototype},x_=D_,M_=P_.remove;wr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=x_(this),r=!0,i=0,n=arguments.length;i<n;i++)e=M_(t,arguments[i]),r=r&&e;return!!r}});var O_=D_,F_=P_.get,N_=P_.has,U_=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,i,n=O_(this);return N_(n,e)?(r=F_(n,e),"update"in t&&(r=t.update(r,e,n),U_(n,e,r)),r):(i=t.insert(e,n),U_(n,e,i),i)}});var B_=M,G_=function(e,t,r){for(var i,n,a=r||e.next;!(i=B_(a,e)).done;)if(void 0!==(n=t(i.value)))return n},K_=G_,H_=function(e,t,r){return r?K_(e.entries(),(function(e){return t(e[1],e[0])})):e.forEach(t)},V_=Jt,j_=D_,Y_=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=j_(this),r=V_(e,arguments.length>1?arguments[1]:void 0);return!1!==Y_(t,(function(e,i){if(!r(e,i,t))return!1}),!0)}});var q_=Jt,W_=D_,z_=H_,X_=P_.Map,Q_=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=W_(this),r=q_(e,arguments.length>1?arguments[1]:void 0),i=new X_;return z_(t,(function(e,n){r(e,n,t)&&Q_(i,n,e)})),i}});var $_=Jt,J_=D_,Z_=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=J_(this),r=$_(e,arguments.length>1?arguments[1]:void 0),i=Z_(t,(function(e,i){if(r(e,i,t))return{value:e}}),!0);return i&&i.value}});var ew=Jt,tw=D_,rw=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=tw(this),r=ew(e,arguments.length>1?arguments[1]:void 0),i=rw(t,(function(e,i){if(r(e,i,t))return{key:i}}),!0);return i&&i.key}});var iw=wr,nw=M,aw=_,sw=xe,ow=tp,lw=P_.Map,uw=y([].push);iw({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){var r=new(aw(this)?this:lw);sw(t);var i=sw(r.has),n=sw(r.get),a=sw(r.set);return ow(e,(function(e){var s=t(e);nw(i,r,s)?uw(nw(n,r,s),e):nw(a,r,s,[e])})),r}});var cw=function(e,t){return e===t||e!=e&&t!=t},hw=D_,dw=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===dw(hw(this),(function(t){if(cw(t,e))return!0}),!0)}});var fw=M,vw=tp,gw=_,pw=xe,mw=P_.Map;wr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(gw(this)?this:mw);pw(t);var i=pw(r.set);return vw(e,(function(e){fw(i,r,t(e),e)})),r}});var yw=D_,Ew=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=Ew(yw(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var kw=Jt,Tw=D_,Sw=H_,Aw=P_.Map,Lw=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=Tw(this),r=kw(e,arguments.length>1?arguments[1]:void 0),i=new Aw;return Sw(t,(function(e,n){Lw(i,r(e,n,t),e)})),i}});var bw=Jt,Rw=D_,Iw=H_,Dw=P_.Map,_w=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=Rw(this),r=bw(e,arguments.length>1?arguments[1]:void 0),i=new Dw;return Iw(t,(function(e,n){_w(i,n,r(e,n,t))})),i}});var ww=D_,Cw=tp,Pw=P_.set;wr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=ww(this),r=arguments.length,i=0;i<r;)Cw(arguments[i++],(function(e,r){Pw(t,e,r)}),{AS_ENTRIES:!0});return t}});var xw=xe,Mw=D_,Ow=H_,Fw=TypeError;wr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Mw(this),r=arguments.length<2,i=r?void 0:arguments[1];if(xw(e),Ow(t,(function(n,a){r?(r=!1,i=n):i=e(i,n,a,t)})),r)throw Fw("Reduce of empty map with no initial value");return i}});var Nw=Jt,Uw=D_,Bw=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=Uw(this),r=Nw(e,arguments.length>1?arguments[1]:void 0);return!0===Bw(t,(function(e,i){if(r(e,i,t))return!0}),!0)}});var Gw=xe,Kw=D_,Hw=TypeError,Vw=P_.get,jw=P_.has,Yw=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=Kw(this),i=arguments.length;Gw(t);var n=jw(r,e);if(!n&&i<3)throw Hw("Updating absent value");var a=n?Vw(r,e):Gw(i>2?arguments[2]:void 0)(e,r);return Yw(r,e,t(a,e,r)),r}});var qw=M,Ww=xe,zw=_,Xw=nr,Qw=TypeError,$w=function(e,t){var r,i=Xw(this),n=Ww(i.get),a=Ww(i.has),s=Ww(i.set),o=arguments.length>2?arguments[2]:void 0;if(!zw(t)&&!zw(o))throw Qw("At least one callback required");return qw(a,i,e)?(r=qw(n,i,e),zw(t)&&(r=t(r),qw(s,i,e,r))):zw(o)&&(r=o(),qw(s,i,e,r)),r};wr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:$w}),wr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:$w});var Jw=p_,Zw=i(Jw);function eC(e,t,r){var i;Jh()?eC=ch(i=$h).call(i):eC=function(e,t,r){var i=[null];rf(i).apply(i,t);var n=new(ch(Function).apply(e,i));return r&&Ch(n,r.prototype),n};return eC.apply(null,arguments)}function tC(e){var t="function"==typeof Zw?new Zw:void 0;return tC=function(e){if(null===e||(r=e,-1===nv(i=Function.toString.call(r)).call(i,"[native code]")))return e;var r,i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eC(e,arguments,Rh(this).constructor)}return n.prototype=wh(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ch(n,e)},tC(e)}var rC=s.isFinite;wr({target:"Number",stat:!0},{isFinite:Number.isFinite||function(e){return"number"==typeof e&&rC(e)}});var iC=i(ie.Number.isFinite),nC=wr,aC=WI,sC=Math.abs;nC({target:"Number",stat:!0},{isSafeInteger:function(e){return aC(e)&&sC(e)<=9007199254740991}});var oC=i(ie.Number.isSafeInteger);wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var lC=i(9007199254740991),uC=xe,cC=$e,hC=q,dC=zr,fC=TypeError,vC=function(e){return function(t,r,i,n){uC(r);var a=cC(t),s=hC(a),o=dC(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 fC("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}},gC={left:vC(!1),right:vC(!0)}.left;wr({target:"Array",proto:!0,forced:!Lp&&me>79&&me<83||!rd("reduce")},{reduce:function(e){var t=arguments.length;return gC(this,e,t,t>1?arguments[1]:void 0)}});var pC=nh("Array").reduce,mC=ue,yC=pC,EC=Array.prototype,kC=i((function(e){var t=e.reduce;return e===EC||mC(EC,e)&&t===EC.reduce?yC:t})),TC=nr,SC=M,AC=et,LC=ue,bC=function(){var e=TC(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},RC=RegExp.prototype,IC=ue,DC=function(e){var t=e.flags;return void 0!==t||"flags"in RC||AC(e,"flags")||!LC(RC,e)?t:SC(bC,e)},_C=RegExp.prototype,wC=i((function(e){return e===_C||IC(_C,e)?DC(e):e.flags})),CC=f,PC=Z,xC=Vr,MC=zr,OC=rd,FC=Math.min,NC=[].lastIndexOf,UC=!!NC&&1/[1].lastIndexOf(1,-0)<0,BC=OC("lastIndexOf"),GC=UC||!BC?function(e){if(UC)return CC(NC,this,arguments)||0;var t=PC(this),r=MC(t),i=r-1;for(arguments.length>1&&(i=FC(i,xC(arguments[1]))),i<0&&(i=r+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:NC;wr({target:"Array",proto:!0,forced:GC!==[].lastIndexOf},{lastIndexOf:GC});var KC=nh("Array").lastIndexOf,HC=ue,VC=KC,jC=Array.prototype,YC=i((function(e){var t=e.lastIndexOf;return e===jC||HC(jC,e)&&t===jC.lastIndexOf?VC:t})),qC=wr,WC=Br,zC=y([].reverse),XC=[1,2];qC({target:"Array",proto:!0,forced:String(XC)===String(XC.reverse())},{reverse:function(){return WC(this)&&(this.length=this.length),zC(this)}});var QC=nh("Array").reverse,$C=ue,JC=QC,ZC=Array.prototype,eP=i((function(e){var t=e.reverse;return e===ZC||$C(ZC,e)&&t===ZC.reverse?JC:t}));wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var tP=i(Math.pow(2,-52)),rP=i(Jw);e_("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),g_);var iP=ie.Set,nP=_e,aP=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(nP(e)+" is not a set")},sP=__,oP=le("Set"),lP=oP.prototype,uP={Set:oP,add:sP("add",1),has:sP("has",1),remove:sP("delete",1),proto:lP},cP=G_,hP=function(e,t,r){return r?cP(e.keys(),t):e.forEach(t)},dP=hP,fP=uP.Set,vP=uP.add,gP=function(e){var t=new fP;return dP(e,(function(e){vP(t,e)})),t},pP=function(e){return e.size},mP=xe,yP=nr,EP=M,kP=Vr,TP=TypeError,SP=Math.max,AP=function(e,t,r,i){this.set=e,this.size=t,this.has=r,this.keys=i};AP.prototype={getIterator:function(){return yP(EP(this.keys,this.set))},includes:function(e){return EP(this.has,this.set,e)}};var LP=function(e){yP(e);var t=+e.size;if(t!=t)throw TP("Invalid size");return new AP(e,SP(kP(t),0),mP(e.has),mP(e.keys))},bP=aP,RP=gP,IP=pP,DP=LP,_P=hP,wP=G_,CP=uP.has,PP=uP.remove,xP=function(e){var t=bP(this),r=DP(e),i=RP(t);return IP(t)<=r.size?_P(t,(function(e){r.includes(e)&&PP(i,e)})):wP(r.getIterator(),(function(e){CP(t,e)&&PP(i,e)})),i},MP=function(){return!1},OP=xP;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{difference:OP});var FP=aP,NP=pP,UP=LP,BP=hP,GP=G_,KP=uP.Set,HP=uP.add,VP=uP.has,jP=function(e){var t=FP(this),r=UP(e),i=new KP;return NP(t)>r.size?GP(r.getIterator(),(function(e){VP(t,e)&&HP(i,e)})):BP(t,(function(e){r.includes(e)&&HP(i,e)})),i},YP=jP;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{intersection:YP});var qP=aP,WP=uP.has,zP=pP,XP=LP,QP=hP,$P=G_,JP=Kg,ZP=function(e){var t=qP(this),r=XP(e);if(zP(t)<=r.size)return!1!==QP(t,(function(e){if(r.includes(e))return!1}),!0);var i=r.getIterator();return!1!==$P(i,(function(e){if(WP(t,e))return JP(i,"normal",!1)}))},ex=ZP;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{isDisjointFrom:ex});var tx=aP,rx=pP,ix=hP,nx=LP,ax=function(e){var t=tx(this),r=nx(e);return!(rx(t)>r.size)&&!1!==ix(t,(function(e){if(!r.includes(e))return!1}),!0)},sx=ax;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{isSubsetOf:sx});var ox=aP,lx=uP.has,ux=pP,cx=LP,hx=G_,dx=Kg,fx=function(e){var t=ox(this),r=cx(e);if(ux(t)<r.size)return!1;var i=r.getIterator();return!1!==hx(i,(function(e){if(!lx(t,e))return dx(i,"normal",!1)}))},vx=fx;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{isSupersetOf:vx});var gx=aP,px=gP,mx=LP,yx=G_,Ex=uP.add,kx=uP.has,Tx=uP.remove,Sx=function(e){var t=gx(this),r=mx(e).getIterator(),i=px(t);return yx(r,(function(e){kx(t,e)?Tx(i,e):Ex(i,e)})),i},Ax=Sx;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{symmetricDifference:Ax});var Lx=aP,bx=uP.add,Rx=gP,Ix=LP,Dx=G_,_x=function(e){var t=Lx(this),r=Ix(e).getIterator(),i=Rx(t);return Dx(r,(function(e){bx(i,e)})),i},wx=_x;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{union:wx});var Cx=iP;wr({target:"Set",stat:!0,forced:!0},{from:L_}),wr({target:"Set",stat:!0,forced:!0},{of:R_});var Px=aP,xx=uP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=Px(this),t=0,r=arguments.length;t<r;t++)xx(e,arguments[t]);return e}});var Mx=aP,Ox=uP.remove;wr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=Mx(this),r=!0,i=0,n=arguments.length;i<n;i++)e=Ox(t,arguments[i]),r=r&&e;return!!r}});var Fx=Jt,Nx=aP,Ux=hP;wr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=Nx(this),r=Fx(e,arguments.length>1?arguments[1]:void 0);return!1!==Ux(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var Bx=ui,Gx=et,Kx=W,Hx=El,Vx=vt("iterator"),jx=Object,Yx=_,qx=function(e){if(Kx(e))return!1;var t=jx(e);return void 0!==t[Vx]||"@@iterator"in t||Gx(Hx,Bx(t))},Wx=re,zx=le("Set"),Xx=function(e){return function(e){return Wx(e)&&"number"==typeof e.size&&Yx(e.has)&&Yx(e.keys)}(e)?e:qx(e)?new zx(e):e},Qx=M,$x=Xx,Jx=xP;wr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return Qx(Jx,this,$x(e))}});var Zx=Jt,eM=aP,tM=hP,rM=uP.Set,iM=uP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=eM(this),r=Zx(e,arguments.length>1?arguments[1]:void 0),i=new rM;return tM(t,(function(e){r(e,e,t)&&iM(i,e)})),i}});var nM=Jt,aM=aP,sM=hP;wr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=aM(this),r=nM(e,arguments.length>1?arguments[1]:void 0),i=sM(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return i&&i.value}});var oM=M,lM=Xx,uM=jP;wr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return oM(uM,this,lM(e))}});var cM=M,hM=Xx,dM=ZP;wr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return cM(dM,this,hM(e))}});var fM=M,vM=Xx,gM=ax;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return fM(gM,this,vM(e))}});var pM=M,mM=Xx,yM=fx;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return pM(yM,this,mM(e))}});var EM=wr,kM=y,TM=aP,SM=hP,AM=tn,LM=kM([].join),bM=kM([].push);EM({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=TM(this),r=void 0===e?",":AM(e),i=[];return SM(t,(function(e){bM(i,e)})),LM(i,r)}});var RM=Jt,IM=aP,DM=hP,_M=uP.Set,wM=uP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=IM(this),r=RM(e,arguments.length>1?arguments[1]:void 0),i=new _M;return DM(t,(function(e){wM(i,r(e,e,t))})),i}});var CM=xe,PM=aP,xM=hP,MM=TypeError;wr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=PM(this),r=arguments.length<2,i=r?void 0:arguments[1];if(CM(e),xM(t,(function(n){r?(r=!1,i=n):i=e(i,n,n,t)})),r)throw MM("Reduce of empty set with no initial value");return i}});var OM=Jt,FM=aP,NM=hP;wr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=FM(this),r=OM(e,arguments.length>1?arguments[1]:void 0);return!0===NM(t,(function(e){if(r(e,e,t))return!0}),!0)}});var UM=M,BM=Xx,GM=Sx;wr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return UM(GM,this,BM(e))}});var KM=M,HM=Xx,VM=_x;wr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return KM(VM,this,HM(e))}});var jM,YM=i(Cx),qM=nh("Array").entries,WM=ui,zM=et,XM=ue,QM=qM,$M=Array.prototype,JM={DOMTokenList:!0,NodeList:!0},ZM=i((function(e){var t=e.entries;return e===$M||XM($M,e)&&t===$M.entries||zM(JM,WM(e))?QM:t})),eO=nh("Array").values,tO=ui,rO=et,iO=ue,nO=eO,aO=Array.prototype,sO={DOMTokenList:!0,NodeList:!0},oO=i((function(e){var t=e.values;return e===aO||iO(aO,e)&&t===aO.values||rO(sO,tO(e))?nO:t})),lO=iC||function(e){return"number"==typeof e&&isFinite(e)},uO=oC||function(e){return"number"==typeof e&&Math.abs(e)<=cO},cO=lC||9007199254740991,hO=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),dO=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}({}),fO=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}({}),vO="manifest",gO="level",pO="audioTrack",mO="subtitleTrack",yO="main",EO="audio",kO="subtitle",TO=function(){function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=r,this.alpha_=r?Math.exp(Math.log(.5)/r):0,this.estimate_=i,this.totalWeight_=n}return Fc(e,[{key:"sample",value:function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}]),e}(),SO=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;t(this,e),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new TO(r),this.fast_=new TO(i),this.defaultTTFB_=a,this.ttfb_=new TO(r)}return Fc(e,[{key:"update",value:function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new TO(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new TO(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new TO(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 AO(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Cc(e)||!e)return e;var r=e[bT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Cc(t)?t:t+""}(t))in e?iT(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function LO(){var e;return LO=zk?sT(e=zk).call(e):function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},LO.apply(null,arguments)}function bO(e,t){var r=gv(e);if(Zk){var i=Zk(e);t&&(i=xk(i).call(i,(function(t){return eT(e,t).enumerable}))),r.push.apply(r,i)}return r}function RO(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=bO(Object(n),!0)).call(r,(function(t){AO(e,t,n[t])})):tT?rT(e,tT(n)):vd(i=bO(Object(n))).call(i,(function(t){iT(e,t,eT(n,t))}))}return e}var IO=Fc((function e(r,i){var n,a,s,o,l;t(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var u="[".concat(r,"]:");this.trace=DO,this.debug=sT(n=i.debug).call(n,null,u),this.log=sT(a=i.log).call(a,null,u),this.warn=sT(s=i.warn).call(s,null,u),this.info=sT(o=i.info).call(o,null,u),this.error=sT(l=i.error).call(l,null,u)})),DO=function(){},_O={trace:DO,debug:DO,log:DO,warn:DO,info:DO,error:DO};function wO(){return LO({},_O)}function CO(e,t,r){var i;return t[e]?sT(i=t[e]).call(i,t):function(e,t){var r,i=self.console[e];return i?sT(i).call(i,self.console,_d(r="".concat(t?"["+t+"] ":"","[")).call(r,e,"] >")):DO}(e,r)}var PO=wO();var xO=PO;function MO(){if("undefined"!=typeof self)return(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function OO(e,t){var r=gv(e),i=gv(t),n=r.length,a=i.length;return!n||!a||n===a&&!KT(r).call(r,(function(e){return-1===av(i).call(i,e)}))}var FO={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 NO(e,t){var r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!KT(r=e.split(",")).call(r,(function(e){return!UO(e,t,i)}))}function UO(e,t){var r,i=MO(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);return null!=(r=null==i?void 0:i.isTypeSupported(BO(e,t)))&&r}function BO(e,t){var r;return _d(r="".concat(t,"/mp4;codecs=")).call(r,e)}function GO(e){if(e){var t=e.substring(0,4);return FO.video[t]}return 2}function KO(e){var t;return kC(t=e.split(",")).call(t,(function(e,t){var r=FO.video[t];return r?(2*r+e)/(e?3:2):(FO.audio[t]+e)/(e?2:1)}),0)}var HO={};var VO=/flac|opus|mp4a\.40\.34/i;function jO(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(VO,(function(e){return function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(HO[e])return HO[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(UO(r[i],"audio",t))return HO[e]=r[i],r[i];if("mp3"===r[i]&&null!=(n=MO(t))&&n.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)}))}function YO(e,t){var r;if(e&&(e.length>4||-1!==av(r=["ac-3","ec-3","alac","fLaC","Opus"]).call(r,e)))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function qO(e){if(UI(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 WO(e){var t=MO(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 zO={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},XO={};function QO(e,t,r){var i=e.videoCodec,n=e.audioCodec;if(!i&&!n||!r)return tk.resolve(zO);var a,s=[];if(i){var o,l={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},u=e.videoRange;"SDR"!==u&&(l.transferFunction=u.toLowerCase()),s.push.apply(s,_k(o=i.split(",")).call(o,(function(e){return{type:"media-source",video:RO(RO({},l),{},{contentType:BO(qO(e),"video")})}})))}n&&e.audioGroups&&vd(a=e.audioGroups).call(a,(function(e){var r,i;e&&(null==(i=t.groups[e])||vd(r=i.tracks).call(r,(function(t){if(t.groupId===e){var r,i=t.channels||"",a=bS(i);if(lO(a)&&a>2)s.push.apply(s,_k(r=n.split(",")).call(r,(function(e){return{type:"media-source",audio:{contentType:BO(e,"audio"),channels:""+a}}})))}})))}));return tk.all(_k(s).call(s,(function(e){var t=function(e){var t=e.audio,r=e.video,i=r||t;if(i){var n,a,s,o,l,u,c,h=i.contentType.split('"')[1];if(r)return _d(n=_d(a=_d(s=_d(o=_d(l="r".concat(r.height,"x")).call(l,r.width,"f")).call(o,Math.ceil(r.framerate))).call(s,r.transferFunction||"sd","_")).call(a,h,"_")).call(n,Math.ceil(r.bitrate/1e5));if(t)return _d(u=_d(c="c".concat(t.channels)).call(c,t.spatialRendering?"s":"n","_")).call(u,h)}return""}(e);return XO[t]||(XO[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!KT(e).call(e,(function(e){return!e.supported})),configurations:s,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}}))}var $O=["NONE","TYPE-0","TYPE-1",null];var JO=["SDR","PQ","HLG"];var ZO="",eF="YES",tF="v2";function rF(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?tF:eF:ZO}var iF=function(){function e(r,i,n){t(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=r,this.part=i,this.skip=n}return Fc(e,[{key:"addDirectives",value:function(e){var t=new gI(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}(),nF=function(){function e(r){var i,n;t(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[r.url],this._attrs=[r.attrs],this.bitrate=r.bitrate,r.details&&(this.details=r.details),this.id=r.id||0,this.name=r.name,this.width=r.width||0,this.height=r.height||0,this.frameRate=r.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=r.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=r.audioCodec,this.videoCodec=r.videoCodec,this.codecSet=_k(i=xk(n=[r.videoCodec,r.audioCodec]).call(n,(function(e){return!!e}))).call(i,(function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",r.attrs.AUDIO),this.addGroupId("text",r.attrs.SUBTITLES)}return Fc(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return aF(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return aF(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===av(r).call(r,t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===av(i).call(i,t)&&i.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}]),e}();function aF(e,t){return!(!t||!e)&&-1!==av(e).call(e,t)}function sF(e,t){var r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){var n="SDR"!==(i=t.allowedVideoRanges||Fv(JO).call(JO,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 oF(e,t){var r;xO.log(_d(r='[abr] start candidates with "'.concat(e,'" ignored because ')).call(r,t))}function lF(e){return kC(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 uF(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function cF(e,t,r){if("attrs"in e){var i=av(t).call(t,e);if(-1!==i)return i}for(var n=0;n<t.length;n++){if(hF(e,t[n],r))return n}return-1}function hF(e,t,r){var i=e.groupId,n=e.name,a=e.lang,s=e.assocLang,o=e.characteristics,l=e.default,u=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===a||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--";if(e.length===t.length)return e===t;return UI(e).call(e,t)||UI(t).call(t,e)}(a,t.lang))&&(void 0===a||t.assocLang===s)&&(void 0===l||t.default===l)&&(void 0===u||t.forced===u)&&(void 0===o||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),i=t.split(",");return r.length===i.length&&!KT(r).call(r,(function(e){return-1===av(i).call(i,e)}))}(o,t.characteristics))&&(void 0===r||r(e,t))}function dF(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 fF(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 vF(e,t){var r;return!!e&&e!==(null==(r=t.levels[t.loadLevel])?void 0:r.uri)}var gF=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"abr",e.logger)).hls=void 0,n.lastLevelLoadSec=0,n.lastLoadedFragLevel=-1,n.firstSelection=-1,n._nextAutoLevel=-1,n.nextAutoLevelKey="",n.audioTracksByGroup=null,n.codecTiers=null,n.timer=-1,n.fragCurrent=null,n.partCurrent=null,n.bitrateTestDelay=0,n.bwEstimator=void 0,n._abandonRulesCheck=function(){var e,t,r,i,a,s,o,l,u,c,h,d,f=Zh(n),v=f.fragCurrent,g=f.partCurrent,p=f.hls,m=p.autoLevelEnabled,y=p.media;if(v&&y){var E=performance.now(),k=g?g.stats:v.stats,T=g?g.duration:v.duration,S=E-k.loading.start,A=p.minAutoLevel;if(k.aborted||k.loaded&&k.loaded===k.total||v.level<=A)return n.clearTimer(),void(n._nextAutoLevel=-1);if(m&&!y.paused&&y.playbackRate&&y.readyState){var L=p.mainForwardBufferInfo;if(null!==L){var b=n.bwEstimator.getEstimateTTFB(),R=Math.abs(y.playbackRate);if(!(S<=Math.max(b,T/(2*R)*1e3))){var I=L.len/R,D=k.loading.first?k.loading.first-k.loading.start:-1,_=k.loaded&&D>-1,w=n.getBwEstimate(),C=p.levels,P=C[v.level],x=Math.max(k.loaded,Math.round(T*(v.bitrate||P.averageBitrate)/8)),M=_?S-D:S;M<1&&_&&(M=Math.min(S,8*k.loaded/w));var O=_?1e3*k.loaded/M:0,F=b/1e3,N=O?(x-k.loaded)/O:8*x/w+F;if(!(N<=I)){var U,B=O?8*O:w,G=!0===(null==(d=n.hls.latestLevelDetails)?void 0:d.live),K=n.hls.config.abrBandWidthUpFactor,H=Number.POSITIVE_INFINITY;for(U=v.level-1;U>A;U--){var V=C[U].maxBitrate,j=!C[U].details||G;if((H=n.getTimeToLoadFrag(F,B,T*V,j))<Math.min(I,T+F))break}if(!(H>=N||H>10*T)){_?n.bwEstimator.sample(S-Math.min(b,D),k.loaded):n.bwEstimator.sampleTTFB(S);var Y=C[U].maxBitrate;n.getBwEstimate()*K>Y&&n.resetEstimator(Y);var q=n.findBestLevel(Y,A,U,0,I,1,1);q>-1&&(U=q),n.warn(_d(e=_d(t=_d(r=_d(i=_d(a=_d(s=_d(o=_d(l=_d(u=_d(c=_d(h="Fragment ".concat(v.sn)).call(h,g?" part "+g.index:""," of level ")).call(c,v.level," is loading too slowly;\n Fragment duration: ")).call(u,v.duration.toFixed(3),"\n Time to underbuffer: ")).call(l,I.toFixed(3)," s\n Estimated load time for current fragment: ")).call(o,N.toFixed(3)," s\n Estimated load time for down switch fragment: ")).call(s,H.toFixed(3)," s\n TTFB estimate: ")).call(a,0|D," ms\n Current BW estimate: ")).call(i,lO(w)?0|w:"Unknown"," bps\n New BW estimate: ")).call(r,0|n.getBwEstimate()," bps\n Switching to level ")).call(t,U," @ ")).call(e,0|Y," bps")),p.nextLoadLevel=p.nextAutoLevel=U,n.clearTimer(),n.timer=lS((function(){if(n.clearTimer(),n.fragCurrent===v&&n.hls.loadLevel===U&&U>0){var e,t,r=n.getStarvationDelay();if(n.warn(_d(e=_d(t="Aborting inflight request ".concat(U>0?"and switching down":"","\n Fragment duration: ")).call(t,v.duration.toFixed(3)," s\n Time to underbuffer: ")).call(e,r.toFixed(3)," s")),v.abortRequests(),n.fragCurrent=n.partCurrent=null,U>A){var i=n.findBestLevel(n.hls.levels[A].bitrate,A,U,0,r,1,1);-1===i&&(i=A),n.hls.nextLoadLevel=n.hls.nextAutoLevel=i,n.resetEstimator(n.hls.levels[i].bitrate)}}}),1e3*H),p.trigger(fO.FRAG_LOAD_EMERGENCY_ABORTED,{frag:v,part:g,stats:k})}}}}}}},n.hls=e,n.bwEstimator=n.initEstimator(),n.registerListeners(),n}return Fc(i,[{key:"resetEstimator",value:function(e){e&&(this.log("setting initial bwe to ".concat(e)),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new SO(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.FRAG_LOADING,this.onFragLoading,this),e.on(fO.FRAG_LOADED,this.onFragLoaded,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.FRAG_LOADING,this.onFragLoading,this),e.off(fO.FRAG_LOADED,this.onFragLoaded,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(fO.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=lS(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case dO.BUFFER_ADD_CODEC_ERROR:case dO.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case dO.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;lO(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===yO&&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(fO.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!==yO||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e,t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,s=this.findBestLevel(n,i,r,0,a,1,1);if(s>-1)return s;var o=this.hls.firstLevel,l=Math.min(Math.max(o,i),r);return this.warn(_d(e="Could not find best starting auto level. Defaulting to first in playlist ".concat(o," clamped to ")).call(e,l)),l}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=Math.min(Math.max(e,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}},{key:"getAutoLevelKey",value:function(){var e;return _d(e="".concat(this.getBwEstimate(),"_")).call(e,this.getStarvationDelay().toFixed(2))}},{key:"getNextABRAutoLevel",value:function(){var e,t=this.fragCurrent,r=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,s=i.minAutoLevel,o=r?r.duration:t?t.duration:0,l=this.getBwEstimate(),u=this.getStarvationDelay(),c=a.abrBandWidthFactor,h=a.abrBandWidthUpFactor;if(u){var d=this.findBestLevel(l,s,n,u,0,c,h);if(d>=0)return d}var f=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var v,g=this.bitrateTestDelay;if(g)f=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-g,this.info(_d(v="bitrate test took ".concat(Math.round(1e3*g),"ms, set first fragment max fetchDuration to ")).call(v,Math.round(1e3*f)," ms")),c=h=1}var p=this.findBestLevel(l,s,n,u,f,c,h);if(this.info(_d(e="".concat(u?"rebuffering expected":"buffer is empty",", optimal quality level ")).call(e,p)),p>-1)return p;var m=i.levels[s],y=i.levels[i.loadLevel];return(null==m?void 0:m.bitrate)<(null==y?void 0:y.bitrate)?s:i.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,r,i,n,a,s){var o,l=this,u=i+n,c=this.lastLoadedFragLevel,h=-1===c?this.hls.firstLevel:c,d=this.fragCurrent,f=this.partCurrent,v=this.hls,g=v.levels,p=v.allAudioTracks,m=v.loadLevel,y=v.config;if(1===g.length)return 0;var E,k=g[h],T=!(null==(o=this.hls.latestLevelDetails)||!o.live),S=-1===m||-1===c,A="SDR",L=(null==k?void 0:k.frameRate)||0,b=y.audioPreference,R=y.videoPreference,I=this.audioTracksByGroup||(this.audioTracksByGroup=lF(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var _=this.codecTiers||(this.codecTiers=function(e,t,r,i){var n;return kC(n=Fv(e).call(e,r,i+1)).call(n,(function(e,r,i){if(!r.codecSet)return e;var n=r.audioGroups,a=e[r.codecSet];a||(e[r.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,r.bitrate);var s=Math.min(r.height,r.width);return a.minHeight=Math.min(a.minHeight,s),a.minFramerate=Math.min(a.minFramerate,r.frameRate),a.minIndex=Math.min(a.minIndex,i),a.maxScore=Math.max(a.maxScore,r.score),a.fragmentError+=r.fragmentError,a.videoRanges[r.videoRange]=(a.videoRanges[r.videoRange]||0)+1,n&&vd(n).call(n,(function(e){var r;if(e){var i=t.groups[e];i&&(a.hasDefaultAudio=a.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,vd(r=gv(i.channels)).call(r,(function(e){a.channels[e]=(a.channels[e]||0)+i.channels[e]})))}})),e}),{})}(g,I,t,r)),w=function(e,t,r,i,n){for(var a=gv(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==n?void 0:n.videoCodec,u=s&&2===Ak(s),c=!1,h=!1,d=1/0,f=1/0,v=1/0,g=1/0,p=0,m=[],y=sF(t,n),E=y.preferHDR,k=y.allowedVideoRanges,T=function(){var t=e[a[S]];c||(c=t.channels[2]>0),d=Math.min(d,t.minHeight),f=Math.min(f,t.minFramerate),v=Math.min(v,t.minBitrate),xk(k).call(k,(function(e){return t.videoRanges[e]>0})).length>0&&(h=!0)},S=a.length;S--;)T();d=lO(d)?d:0,f=lO(f)?f:0;var A=Math.max(1080,d),L=Math.max(30,f);v=lO(v)?v:r,r=Math.max(v,r),h||(t=void 0);var b=a.length>1;return{codecSet:kC(a).call(a,(function(t,i){var n=e[i];if(i===t)return t;if(m=h?xk(k).call(k,(function(e){return n.videoRanges[e]>0})):[],b){var a,d,f,v,y;if(n.minBitrate>r)return oF(i,_d(a="min bitrate of ".concat(n.minBitrate," > current estimate of ")).call(a,r)),t;if(!n.hasDefaultAudio)return oF(i,"no renditions with default or auto-select sound found"),t;if(o&&av(i).call(i,o.substring(0,4))%5!=0)return oF(i,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!u){if(!n.channels[s])return oF(i,_d(d="no renditions with ".concat(s," channel sound found (channels options: ")).call(d,gv(n.channels),")")),t}else if((!o||u)&&c&&0===n.channels[2])return oF(i,"no renditions with stereo sound found"),t;if(n.minHeight>A)return oF(i,_d(f="min resolution of ".concat(n.minHeight," > maximum of ")).call(f,A)),t;if(n.minFramerate>L)return oF(i,_d(v="min framerate of ".concat(n.minFramerate," > maximum of ")).call(v,L)),t;if(!KT(m).call(m,(function(e){return n.videoRanges[e]>0})))return oF(i,"no variants with VIDEO-RANGE of ".concat(jI(m)," found")),t;if(l&&av(i).call(i,l.substring(0,4))%5!=0)return oF(i,'video codec preference "'.concat(l,'" not found')),t;if(n.maxScore<p)return oF(i,_d(y="max score of ".concat(n.maxScore," < selected max of ")).call(y,p)),t}return t&&(KO(i)>=KO(t)||n.fragmentError>e[t].fragmentError)?t:(g=n.minIndex,p=n.maxScore,i)}),void 0),videoRanges:m,preferHDR:E,minFramerate:f,minBitrate:v,minIndex:g}}(_,A,e,b,R),C=w.codecSet,P=w.videoRanges,x=w.minFramerate,M=w.minBitrate,O=w.minIndex,F=w.preferHDR;D=O,E=C,A=F?P[P.length-1]:P[0],L=x,e=Math.max(e,M),this.log("picked start tier ".concat(jI(w)))}else E=null==k?void 0:k.codecSet,A=null==k?void 0:k.videoRange;for(var N=f?f.duration:d?d.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,B=[],G=function(){var t=g[K],o=K>h;if(!t)return"continue";if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var d=navigator.mediaCapabilities;"function"!=typeof(null==d?void 0:d.decodingInfo)||!function(e,t,r,i,n,a){var s,o=e.audioCodec?e.audioGroups:null,l=null==a?void 0:a.audioCodec,u=null==a?void 0:a.channels,c=u?Ak(u):l?1/0:2,h=null;if(null!=o&&o.length)try{h=1===o.length&&o[0]?t.groups[o[0]].channels:kC(o).call(o,(function(e,r){if(r){var i,n=t.groups[r];if(!n)throw new Error("Audio track group ".concat(r," not found"));vd(i=gv(n.channels)).call(i,(function(t){e[t]=(e[t]||0)+n.channels[t]}))}return e}),{2:0})}catch(JV){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&&lO(c)&&KT(s=gv(h)).call(s,(function(e){return Ak(e)>c}))}(t,I,A,L,e,b)&&"hvc1"!==(null==(V=t.videoCodec)?void 0:V.substring(0,4))?t.supportedResult=zO:(t.supportedPromise=QO(t,I,d),t.supportedPromise.then((function(e){if(l.hls){t.supportedResult=e;var r,i,n=l.hls.levels,a=av(n).call(n,t);if(e.error)l.warn(_d(r=_d(i='MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ')).call(i,a," ")).call(r,jI(e)));else if(!e.supported){var s;l.warn(_d(s="Unsupported MediaCapabilities decodingInfo result for level ".concat(a," ")).call(s,jI(e))),a>-1&&n.length>1&&(l.log("Removing unsupported level ".concat(a)),l.hls.removeLevel(a),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0))}}})))}if((E&&t.codecSet!==E||A&&t.videoRange!==A||o&&L>t.frameRate||!o&&L>0&&L<t.frameRate||t.supportedResult&&(null==(H=t.supportedResult.decodingInfoResults)||!H[0].smooth))&&(!S||K!==D))return B.push(K),"continue";var v,p=t.details,k=(f?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;v=o?s*e:a*e;var R=N&&i>=2*N&&0===n?t.averageBitrate:t.maxBitrate,_=l.getTimeToLoadFrag(U,v,R*k,void 0===p);if(v>=R&&(K===c||0===t.loadError&&0===t.fragmentError)&&(_<=U||!lO(_)||T&&!l.bitrateTestDelay||_<u)){var w=l.forcedAutoLevel;if(K!==m&&(-1===w||w!==m)){var C,P,x,M,O,F,G,j,Y,q,W,z,X,Q,$,J;if(B.length)l.trace(_d(z=_d(X=_d(Q=_d($=_d(J="Skipped level(s) ".concat(B.join(",")," of ")).call(J,r,' max with CODECS and VIDEO-RANGE:"')).call($,g[B[0]].codecs,'" ')).call(Q,g[B[0]].videoRange,'; not compatible with "')).call(X,E,'" ')).call(z,A));l.info(_d(C=_d(P=_d(x=_d(M=_d(O=_d(F=_d(G=_d(j=_d(Y=_d(q=_d(W="switch candidate:".concat(h,"->")).call(W,K," adjustedbw(")).call(q,Math.round(v),")-bitrate=")).call(Y,Math.round(v-R)," ttfb:")).call(j,U.toFixed(1)," avgDuration:")).call(G,k.toFixed(1)," maxFetchDuration:")).call(F,u.toFixed(1)," fetchDuration:")).call(O,_.toFixed(1)," firstSelection:")).call(M,S," codecSet:")).call(x,t.codecSet," videoRange:")).call(P,t.videoRange," hls.loadLevel:")).call(C,m))}return S&&(l.firstSelection=K),{v:K}}},K=r;K>=t;K--){var H,V,j=G();if("continue"!==j&&"object"===Cc(j))return j.v}return-1}}]),i}(IO),pF=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 mF(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===yF(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i,n=kC(i=t.tagList).call(i,(function(e,t){return"INF"===t[0]&&(e+=bS(t[1])),e}),r);return e.start<=n}return!1}(a,e,Math.min(n,i))))return a;var o=pF(t,sT(yF).call(yF,null,r,i));return!o||o===e&&a?a:o}function yF(){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 EF(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function kF(e,t){return pF(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function TF(e){switch(e.details){case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_TIMEOUT:case dO.LEVEL_LOAD_TIMEOUT:case dO.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function SF(e,t){var r=TF(t);return e.default["".concat(r?"timeout":"error","Retry")]}function AF(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function LF(e){return RO(RO({},e),{errorRetry:null,timeoutRetry:null})}function bF(e,t,r,i){if(!e)return!1;var n=null==i?void 0:i.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,a):a}var RF=0,IF=2,DF=3,_F=5,wF=0,CF=1,PF=2,xF=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"error-controller",e.logger)).hls=void 0,n.playlistError=0,n.penalizedRenditions={},n.hls=e,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.ERROR,this.onError,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.ERROR,this.onError,this),e.off(fO.ERROR,this.onErrorOut,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.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)===yO?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 dO.FRAG_LOAD_ERROR:case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_ERROR:case dO.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case dO.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=MF());case dO.FRAG_GAP:case dO.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=IF);case dO.LEVEL_EMPTY_ERROR:case dO.LEVEL_PARSING_ERROR:var a,s,o=t.parent===yO?t.level:i.loadLevel;return void(t.details===dO.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 dO.LEVEL_LOAD_ERROR:case dO.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case dO.AUDIO_TRACK_LOAD_ERROR:case dO.AUDIO_TRACK_LOAD_TIMEOUT:case dO.SUBTITLE_LOAD_ERROR:case dO.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var l=i.levels[i.loadLevel];if(l&&(n.type===pO&&l.hasAudioGroup(n.groupId)||n.type===mO&&l.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=IF,void(t.errorAction.flags=CF)}return;case dO.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:IF,flags:PF,hdcpLevel:c}:this.keySystemError(t));case dO.BUFFER_ADD_CODEC_ERROR:case dO.REMUX_ALLOC_ERROR:case dO.BUFFER_APPEND_ERROR:var h;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(h=t.level)?h:i.loadLevel);return;case dO.INTERNAL_EXCEPTION:case dO.BUFFER_APPENDING_ERROR:case dO.BUFFER_FULL_ERROR:case dO.LEVEL_SWITCH_ERROR:case dO.BUFFER_STALLED_ERROR:case dO.BUFFER_SEEK_OVER_HOLE:case dO.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=MF())}t.type===hO.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=SF(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(bF(r,i,TF(e),e.response))return{action:_F,flags:wF,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=SF(UI(t=e.details).call(t,"key")?l:o,e),c=kC(r=i.levels).call(r,(function(e,t){return e+t.fragmentError}),0);if(a&&(e.details!==dO.FRAG_GAP&&a.fragmentError++,bF(u,c,TF(e),e.response)))return{action:_F,flags:wF,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===dO.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===EO&&s===dO.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===dO.BUFFER_ADD_CODEC_ERROR||s===dO.BUFFER_APPEND_ERROR))&&KT(l).call(l,(function(e){var t=e.audioCodec;return i.audioCodec!==t})),v="video"===e.sourceBufferName&&(s===dO.BUFFER_ADD_CODEC_ERROR||s===dO.BUFFER_APPEND_ERROR)&&KT(l).call(l,(function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(a=e.context)?a:{},p=g.type,m=g.groupId,y=function(){var t=(E+u)%l.length;if(t!==u&&t>=c&&t<=h&&0===l[t].loadError){var r=l[t];if(s===dO.FRAG_GAP&&d===yO&&e.frag){var n=l[t].details;if(n){var a=mF(e.frag,n.fragments,e.frag.start);if(null!=a&&a.gap)return"continue"}}else{if(p===pO&&r.hasAudioGroup(m)||p===mO&&r.hasSubtitleGroup(m))return"continue";if(d===EO&&null!=(k=i.audioGroups)&&KT(k).call(k,(function(e){return r.hasAudioGroup(e)}))||d===kO&&null!=(T=i.subtitleGroups)&&KT(T).call(T,(function(e){return r.hasSubtitleGroup(e)}))||f&&i.audioCodec===r.audioCodec||!f&&i.audioCodec!==r.audioCodec||v&&i.codecSet===r.codecSet)return"continue"}return o=t,"break"}},E=l.length;E--;){var k,T,S=y();if("continue"!==S&&"break"===S)break}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:IF,flags:wF,nextAutoLevel:o}}return{action:IF,flags:CF}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case RF:break;case IF:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===dO.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=wC(r),n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case wF:this.switchLevel(e,a);break;case PF:n&&(t.maxHdcpLevel=$O[av($O).call($O,n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'))}r.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){var r;void 0!==t&&e.errorAction&&(this.warn(_d(r="switching to level ".concat(t," after ")).call(r,e.details)),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}]),i}(IO);function MF(e){var t={action:RF,flags:wF};return e&&(t.resolved=!0),t}var OF="NOT_LOADED",FF="APPENDING",NF="PARTIAL",UF="OK",BF=function(){function e(r){t(this,e),this.activePartLists=aT(null),this.endListFragments=aT(null),this.fragments=aT(null),this.timeRanges=aT(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=r,this._registerListeners()}return Fc(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fO.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fO.FRAG_LOADED,this.onFragLoaded,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=e&&null!==a&&e<=a)return n}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,r){for(var i=this.fragments,n=gv(i),a=n.length;a--;){var s=i[n[a]];if((null==s?void 0:s.body.type)===t&&(!r||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null}},{key:"detectEvictedFragments",value:function(e,t,r,i,n){var a,s=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(null==i?void 0:i.fragment.sn)||-1;vd(a=gv(this.fragments)).call(a,(function(i){var a,l=s.fragments[i];if(l&&!(o>=l.body.sn))if(l.buffered||l.loaded&&!n){var u=l.range[e];u&&(0!==u.time.length?KT(a=u.time).call(a,(function(e){var r=!s.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&s.removeFragment(l.body),r})):s.removeFragment(l.body))}else l.body.type===r&&s.removeFragment(l.body)}))}},{key:"detectPartialFragments",value:function(e){var t,r=this,i=this.timeRanges;if(i&&"initSegment"!==e.frag.sn){var n=e.frag,a=KF(n),s=this.fragments[a];if(!(!s||s.buffered&&n.gap)){var o=!n.relurl;if(vd(t=gv(i)).call(t,(function(t){var a=n.elementaryStreams[t];if(a){var l=i[t],u=o||!0===a.partial;s.range[t]=r.getBufferedTimes(n,e.part,u,l)}})),s.loaded=null,gv(s.range).length)s.buffered=!0,(s.body.endList=n.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),GF(s)||this.removeParts(n.sn-1,n.type);else this.removeFragment(s.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=xk(r).call(r,(function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=KF(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:aT(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}},{key:"getBufferedTimes",value:function(e,t,r,i){for(var n={time:[],partial:r},a=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<i.length;u++){var c=i.start(u)-this.bufferPadding,h=i.end(u)+this.bufferPadding;if(l>=c&&o<=h){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(a<h&&s>c){var d=Math.max(a,i.start(u)),f=Math.min(s,i.end(u));f>d&&(n.partial=!0,n.time.push({startPTS:d,endPTS:f}))}else if(s<=c)break}return n}},{key:"getPartialFragment",value:function(e){var t,r,i,n,a=null,s=0,o=this.bufferPadding,l=this.fragments;return vd(t=gv(l)).call(t,(function(t){var u=l[t];u&&GF(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||GF(t))}},{key:"getState",value:function(e){var t=KF(e),r=this.fragments[t];return r?r.buffered?GF(r)?NF:UF:FF:OF}},{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=KF(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:aT(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=KF(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=gv(t);if(!e)return r.length>0;for(var i=r.length;i--;){var n=t[r[i]];if((null==n?void 0:n.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,r,i,n){var a,s=this;i&&!this.hasGaps||vd(a=gv(this.fragments)).call(a,(function(a){var o=s.fragments[a];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&s.removeFragment(l)}}))}},{key:"removeFragment",value:function(e){var t=KF(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=xk(r).call(r,(function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e,t;this.fragments=aT(null),this.endListFragments=aT(null),this.activePartLists=aT(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&vd(r).call(r,(function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function GF(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 KF(e){var t,r;return _d(t=_d(r="".concat(e.type,"_")).call(r,e.level,"_")).call(t,e.sn)}var HF=0,VF=1,jF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=r,this.aesIV=i,this.aesMode=n}return Fc(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case HF:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case VF: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 YF(e,t,r){return Fv(Uint8Array.prototype)?Fv(e).call(e,t,r):new Uint8Array(Fv(Array.prototype).call(e,t,r))}var qF=function(){function e(){t(this,e),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}return Fc(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],h=o[3],d=new Uint32Array(256),f=0,v=0,g=0;for(g=0;g<256;g++)d[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=v^v<<1^v<<2^v<<3^v<<4;p=p>>>8^255&p^99,e[f]=p,t[p]=f;var m=d[f],y=d[m],E=d[y],k=257*d[p]^16843008*p;i[f]=k<<24|k>>>8,n[f]=k<<16|k>>>16,a[f]=k<<8|k>>>24,s[f]=k,k=16843009*E^65537*y^257*m^16843008*f,l[p]=k<<24|k>>>8,u[p]=k<<16|k>>>16,c[p]=k<<8|k>>>24,h[p]=k,f?(f=m^d[d[d[E^m]]],v^=d[d[v]]):f=v=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,l,u=this.ksRows=4*(n+6+1),c=this.keySchedule=new Uint32Array(u),h=this.invKeySchedule=new Uint32Array(u),d=this.sBox,f=this.rcon,v=this.invSubMix,g=v[0],p=v[1],m=v[2],y=v[3];for(a=0;a<u;a++)a<n?o=c[a]=t[a]:(l=o,a%n==0?(l=d[(l=l<<8|l>>>24)>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l],l^=f[a/n|0]<<24):n>6&&a%n==4&&(l=d[l>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l]),c[a]=o=(c[a-n]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],h[s]=s<4||a<=4?l:g[d[l>>>24]]^p[d[l>>>16&255]]^m[d[l>>>8&255]]^y[d[255&l]],h[s]=h[s]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var i,n,a,s,o,l,u,c,h,d,f,v,g,p,m=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,k=this.invSubMix,T=k[0],S=k[1],A=k[2],L=k[3],b=this.uint8ArrayToUint32Array_(r),R=b[0],I=b[1],D=b[2],_=b[3],w=new Int32Array(e),C=new Int32Array(w.length),P=this.networkToHostOrderSwap;t<w.length;){for(h=P(w[t]),d=P(w[t+1]),f=P(w[t+2]),v=P(w[t+3]),o=h^y[0],l=v^y[1],u=f^y[2],c=d^y[3],g=4,p=1;p<m;p++)i=T[o>>>24]^S[l>>16&255]^A[u>>8&255]^L[255&c]^y[g],n=T[l>>>24]^S[u>>16&255]^A[c>>8&255]^L[255&o]^y[g+1],a=T[u>>>24]^S[c>>16&255]^A[o>>8&255]^L[255&l]^y[g+2],s=T[c>>>24]^S[o>>16&255]^A[l>>8&255]^L[255&u]^y[g+3],o=i,l=n,u=a,c=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&c]^y[g],n=E[l>>>24]<<24^E[u>>16&255]<<16^E[c>>8&255]<<8^E[255&o]^y[g+1],a=E[u>>>24]<<24^E[c>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[c>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],C[t]=P(i^R),C[t+1]=P(s^I),C[t+2]=P(a^D),C[t+3]=P(n^_),R=h,I=d,D=f,_=v,t+=4}return C.buffer}}]),e}(),WF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=r,this.key=i,this.aesMode=n}return Fc(e,[{key:"expandKey",value:function(){var e=function(e){switch(e){case HF:return"AES-CBC";case VF: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 zF(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("undefined"!=typeof TextDecoder){var r=new TextDecoder("utf-8").decode(e);if(t){var i=av(r).call(r,"\0");return-1!==i?r.substring(0,i):r}return r.replace(/\0/g,"")}for(var n,a,s,o=e.length,l="",u=0;u<o;){if(0===(n=e[u++])&&t)return l;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:a=e[u++],l+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[u++],s=e[u++],l+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&s)<<0)}}return l}var XF={hexDump:function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}};function QF(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $F,JF,ZF,eN,tN,rN={exports:{}};$F=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,JF=/^(?=([^\/?#]*))\1([^]*)$/,ZF=/(?:\/|^)\.(?=\/)/g,eN=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,rN.exports=tN={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=MS(e).call(e),!(t=MS(t).call(t))){if(!r.alwaysNormalize)return e;var i=tN.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=tN.normalizePath(i.path),tN.buildURLFromParts(i)}var n=tN.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=tN.normalizePath(n.path),tN.buildURLFromParts(n)):t;var a=tN.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var s=JF.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,YC(l).call(l,"/")+1)+n.path;o.path=tN.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?tN.normalizePath(n.path):n.path),tN.buildURLFromParts(o)},parseURL:function(e){var t=$F.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){var t,r;for(e=eP(t=e.split("")).call(t).join("").replace(ZF,"");e.length!==(e=e.replace(eN,"")).length;);return eP(r=e.split("")).call(r).join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var iN=rN.exports,nN=Fc((function e(){t(this,e),this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}})),aN="audio",sN="video",oN="audiovideo",lN=function(){function e(r){t(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof r&&(r={url:r}),this.base=r}return Fc(e,[{key:"setByteRange",value:function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:Ak(i[1]),this._byteRange=[r,Ak(i[0])+r]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){var e;null===this._streams&&(this._streams=(Lf(e={},aN,null),Lf(e,sN,null),Lf(e,oN,null),e));return this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new nN),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=iN.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[aN]=null,e[sN]=null,e[oN]=null}}]),e}();function uN(e){return"initSegment"!==e.sn}var cN=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n))._decryptdata=null,a._programDateTime=null,a._ref=null,a._bitrate=void 0,a.rawProgramDateTime=null,a.tagList=[],a.duration=0,a.sn=0,a.levelkeys=void 0,a.type=void 0,a.loader=null,a.keyLoader=null,a.level=-1,a.cc=0,a.startPTS=void 0,a.endPTS=void 0,a.startDTS=void 0,a.endDTS=void 0,a.start=0,a.playlistOffset=0,a.deltaPTS=void 0,a.maxStartPTS=void 0,a.minEndPTS=void 0,a.data=void 0,a.bitrateTest=!1,a.title=null,a.initSegment=null,a.endList=void 0,a.gap=void 0,a.urlId=0,a.type=e,a}return Fc(i,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var t=this.byteRange[0],r=this.byteRange[1];if(lO(t)&&lO(r))return r-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=gv(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=lO(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=gv(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){lO(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return uN(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,r,i,n){var a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}}}]),i}(lN),hN=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s,o){var l;t(this,i),(l=r.call(this,a)).fragOffset=0,l.duration=0,l.gap=!1,l.independent=!1,l.relurl=void 0,l.fragment=void 0,l.index=void 0,l.duration=e.decimalFloatingPoint("DURATION"),l.gap=e.bool("GAP"),l.independent=e.bool("INDEPENDENT"),l.relurl=e.enumeratedString("URI"),l.fragment=n,l.index=s;var u=e.enumeratedString("BYTERANGE");return u&&l.setByteRange(u,o),o&&(l.fragOffset=o.fragOffset+o.duration),l}return Fc(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),i}(lN),dN=Math.pow(2,32)-1,fN=[].push,vN={video:1,audio:2,id3:3,text:4};function gN(e){return String.fromCharCode.apply(null,e)}function pN(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function mN(e,t){var r=EN(e,t);return r<0?4294967296+r:r}function yN(e,t){var r=mN(e,t);return r*=Math.pow(2,32),r+=mN(e,t+4)}function EN(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function kN(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 TN(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=mN(e,n),s=a>1?n+a:i;if(gN(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=TN(e.subarray(n+8,s),Fv(t).call(t,1));o.length&&fN.apply(r,o)}n=s}return r}function SN(e){var t=[],r=e[0],i=8,n=mN(e,i);i+=4;var a=0,s=0;0===r?(a=mN(e,i),s=mN(e,i+4),i+=8):(a=yN(e,i),s=yN(e,i+8),i+=16),i+=2;var o=e.length+s,l=pN(e,i);i+=2;for(var u=0;u<l;u++){var c=i,h=mN(e,c);c+=4;var d=2147483647&h;if(1===(2147483648&h)>>>31)return xO.warn("SIDX has hierarchical references (not supported)"),null;var f=mN(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 AN(e){for(var t=[],r=TN(e,["moov","trak"]),i=0;i<r.length;i++){var n=r[i],a=TN(n,["tkhd"])[0];if(a){var s=a[0],o=mN(a,0===s?12:20),l=TN(n,["mdia","mdhd"])[0];if(l){var u=mN(l,0===(s=l[0])?12:20),c=TN(n,["mdia","hdlr"])[0];if(c){var h=gN(c.subarray(8,12)),d={soun:aN,vide:sN}[h];if(d){var f=LN(TN(n,["mdia","minf","stbl","stsd"])[0]);t[o]={timescale:u,type:d},t[d]=RO({timescale:u,id:o},f)}}}}}var v=TN(e,["moov","mvex","trex"]);return vd(v).call(v,(function(e){var r=mN(e,4),i=t[r];i&&(i.default={duration:mN(e,12),flags:mN(e,20)})})),t}function LN(e){var t=e.subarray(8),r=t.subarray(86),i=gN(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=TN(t,[i])[0],o=TN(s.subarray("enca"===i?28:78),["sinf"]);vd(o).call(o,(function(e){var t=TN(e,["schm"])[0];if(t){var r=gN(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=TN(e,["frma"])[0];i&&(n=gN(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var l=TN(r,["avcC"])[0];n+="."+RN(l[1])+RN(l[2])+RN(l[3]);break;case"mp4a":var u=TN(t,[i])[0],c=TN(u.subarray(28),["esds"])[0];if(c&&c.length>7){var h=4;if(3!==c[h++])break;h=bN(c,h),h+=2;var d=c[h++];if(128&d&&(h+=2),64&d&&(h+=c[h++]),4!==c[h++])break;h=bN(c,h);var f=c[h++];if(64!==f)break;if(n+="."+RN(f),h+=12,5!==c[h++])break;h=bN(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=TN(r,["hvcC"])[0],m=p[1],y=["","A","B","C"][m>>6],E=31&m,k=mN(p,2),T=(32&m)>>5?"H":"L",S=p[12],A=p.subarray(6,12);n+="."+y+E,n+="."+k.toString(16).toUpperCase(),n+="."+T+S;for(var L="",b=A.length;b--;){var R=A[b];if(R||L)L="."+R.toString(16).toUpperCase()+L}n+=L;break;case"dvh1":case"dvhe":var I=TN(r,["dvcC"])[0],D=I[2]>>1&127,_=I[2]<<5&32|I[3]>>3&31;n+="."+IN(D)+"."+IN(_);break;case"vp09":var w=TN(r,["vpcC"])[0],C=w[4],P=w[5],x=w[6]>>4&15;n+="."+IN(C)+"."+IN(P)+"."+IN(x);break;case"av01":var M=TN(r,["av1C"])[0],O=M[1]>>>5,F=31&M[1],N=M[2]>>>7?"H":"M",U=(64&M[2])>>6,B=(32&M[2])>>5,G=2===O&&U?B?12:10:U?10:8,K=(16&M[2])>>4,H=(8&M[2])>>3,V=(4&M[2])>>2,j=3&M[2];n+="."+O+"."+IN(F)+N+"."+IN(G)+"."+K+"."+H+V+j+"."+IN(1)+"."+IN(1)+"."+IN(1)+".0"}return{codec:n,encrypted:a}}function bN(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function RN(e){var t;return Fv(t="0"+e.toString(16).toUpperCase()).call(t,-2)}function IN(e){return(e<10?"0":"")+e}function DN(e){var t=TN(e,["schm"])[0];if(t){var r=gN(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return TN(e,["schi","tenc"])[0]}return null}function _N(e){var t=mN(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=mN(e,4),a=0;a<n;a++){if(256&t)i+=mN(e,r),r+=4;512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return i}function wN(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function CN(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1,o=TN(i,["moof"]);return _k(o).call(o,(function(o){var l=o.byteOffset-8,u=TN(o,["traf"]);_k(u).call(u,(function(o){var u,c,h=_k(u=TN(o,["tfdt"])).call(u,(function(e){var t=e[0],r=mN(e,4);return 1===t&&(r*=Math.pow(2,32),r+=mN(e,8)),r/n}))[0];return void 0!==h&&(e=h),_k(c=TN(o,["tfhd"])).call(c,(function(u){var c,h=mN(u,4),d=16777215&mN(u,0),f=0,v=0!=(16&d),g=0,p=0!=(32&d),m=8;h===a&&(0!=(1&d)&&(m+=8),0!=(2&d)&&(m+=4),0!=(8&d)&&(f=mN(u,m),m+=4),v&&(g=mN(u,m),m+=4),p&&(m+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=av(e).call(e,"."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),_k(c=TN(o,["trun"])).call(c,(function(a){var o=a[0],u=16777215&mN(a,0),c=0!=(1&u),h=0,d=0!=(4&u),v=0!=(256&u),p=0,m=0!=(512&u),y=0,E=0!=(1024&u),k=0!=(2048&u),T=0,S=mN(a,4),A=8;c&&(h=mN(a,A),A+=4),d&&(A+=4);for(var L=h+l,b=0;b<S;b++){if(v?(p=mN(a,A),A+=4):p=f,m?(y=mN(a,A),A+=4):y=g,E&&(A+=4),k&&(T=0===o?mN(a,A):EN(a,A),A+=4),t.type===sN)for(var R=0;R<y;){var I=mN(i,L);if(PN(s,i[L+=4]))xN(i.subarray(L,L+I),s?2:1,e+T/n,r);L+=I,R+=I+4}e+=p/n}})))}))}))})),r}function PN(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function xN(e,t,r,i){var n=MN(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;xO.error(_d(h="Malformed SEI payload. ".concat(o," is too small, only ")).call(h,u," bytes left to parse."));break}if(4===s){if(181===n[c++]){var d=pN(n,c);if(c+=2,49===d){var f=mN(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:zF(L),userDataBytes:L})}}}function MN(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 ON(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 FN(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=XF.hexDump(new Uint8Array(a,r+12,16)),o=e.getUint32(28),l=null,u=null;if(0===n){if(t-32<o||o<22)return{offset:r,size:t};u=new Uint8Array(a,r+32,o)}else if(1===n){if(!o||i<r+32+16*o+16)return{offset:r,size:t};l=[];for(var c=0;c<o;c++)l.push(new Uint8Array(a,r+32+16*c,16))}return{version:n,systemId:s,kids:l,data:u,offset:r,size:t}}var NN=function(){function e(r){var i=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).removePKCS7Padding,n=void 0===i||i;if(t(this,e),this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=r.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(s){}this.useSoftware=!this.subtle}return Fc(e,[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,n,a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=a).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?YF(r,0,i-n):r):a}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,r,i){var n=this;return this.useSoftware?new tk((function(a,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);n.softwareDecrypt(o,t,r,i);var l=n.flush();l?a(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}},{key:"softwareDecrypt",value:function(e,t,r,i){var n=this.currentIV,a=this.currentResult,s=this.remainderData;if(i!==HF||16!==t.byteLength)return xO.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=wN(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 qF),l.expandKey(t);var u=a;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=YF(o,-16).buffer,u||null}},{key:"webCryptoDecrypt",value:function(e,t,r,i){var n=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return tk.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new WF(this.subtle,t,i)}return this.fastAesKey.expandKey().then((function(t){return n.subtle?(n.logOnce("WebCrypto AES decrypt"),new jF(n.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):tk.reject(new Error("web crypto not initialized"))})).catch((function(a){var s;return xO.warn(_d(s="[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(a.name,": ")).call(s,a.message)),n.onWebCryptoError(e,t,r,i)}))}},{key:"onWebCryptoError",value:function(e,t,r,i){var n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=YF(e,0,r),this.remainderData=YF(e,r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(xO.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),UN=Math.pow(2,17),BN=function(){function e(r){t(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=r}return Fc(e,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var r=this,i=e.url;if(!i)return tk.reject(new HN({type:hO.NETWORK_ERROR,details:dO.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new tk((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){var u;if(KT(u=e.tagList).call(u,(function(e){return"GAP"===e[0]})))return void l(KN(e));e.gap=!1}var c=r.loader=a?new a(n):new s(n),h=GN(e);e.loader=c;var d=LF(n.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:UN};e.stats=c.stats;var v={onSuccess:function(t,i,n,a){r.resetLoader(e,c);var s=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(Fv(s).call(s,0,16)),s=Fv(s).call(s,16)),o({frag:e,part:null,payload:s,networkDetails:a})},onError:function(t,n,a,s){var o;r.resetLoader(e,c),l(new HN({type:hO.NETWORK_ERROR,details:dO.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:RO({url:i,data:void 0},t),error:new Error(_d(o="HTTP Error ".concat(t.code," ")).call(o,t.text)),networkDetails:a,stats:s}))},onAbort:function(t,i,n){r.resetLoader(e,c),l(new HN({type:hO.NETWORK_ERROR,details:dO.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 HN({type:hO.NETWORK_ERROR,details:dO.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after ".concat(f.timeout,"ms")),networkDetails:n,stats:t}))}};t&&(v.onProgress=function(r,i,n,a){return t({frag:e,part:null,payload:n,networkDetails:a})}),c.load(h,f,v)}))}},{key:"loadPart",value:function(e,t,r){var i=this;this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new tk((function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(KN(e,t));else{var u=i.loader=a?new a(n):new s(n),c=GN(e,t);e.loader=u;var h=LF(n.fragLoadPolicy.default),d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:UN};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 HN({type:hO.NETWORK_ERROR,details:dO.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:RO({url:c.url,data:void 0},r),error:new Error(_d(o="HTTP Error ".concat(r.code," ")).call(o,r.text)),networkDetails:a,stats:s}))},onAbort:function(r,n,a){e.stats.aborted=t.stats.aborted,i.resetLoader(e,u),l(new HN({type:hO.NETWORK_ERROR,details:dO.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 HN({type:hO.NETWORK_ERROR,details:dO.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 GN(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(lO(a)&&lO(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 KN(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),i={type:hO.MEDIA_ERROR,details:dO.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new HN(i)}var HN=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e.error.message)).data=void 0,n.data=e,n}return Fc(i)}(tC(Error)),VN=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(s=r.call(this,e,n))._boundTick=void 0,s._tickTimer=null,s._tickInterval=null,s._tickCallCount=0,s._boundTick=sT(a=s.tick).call(a,Zh(s)),s}return Fc(i,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=lS(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=Wf(this._boundTick,0)}},{key:"doTick",value:function(){}}]),i}(IO),jN=Fc((function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];t(this,e),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=r,this.sn=i,this.id=n,this.size=a,this.part=s,this.partial=o}));var YN={length:0,start:function(){return 0},end:function(){return 0}},qN=function(){function e(){t(this,e)}return Fc(e,null,[{key:"isBuffered",value:function(t,r){if(t)for(var i=e.getBuffered(t),n=i.length;n--;)if(r>=i.start(n)&&r<=i.end(n))return!0;return!1}},{key:"bufferInfo",value:function(t,r,i){if(t){var n=e.getBuffered(t);if(n.length){for(var a=[],s=0;s<n.length;s++)a.push({start:n.start(s),end:n.end(s)});return e.bufferedInfo(a,r,i)}}return{len:0,start:r,end:r,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){t=Math.max(0,t),mA(e).call(e,(function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,c=t,h=0;h<i.length;h++){var d=i[h].start,f=i[h].end;if(t+r>=d&&t<f)u=d,l=(c=f)-t;else if(t+r<d){o=d;break}}return{len:l,start:u||0,end:c||0,nextStart:o}}},{key:"getBuffered",value:function(e){try{return e.buffered||YN}catch(t){return xO.log("failed to get media.buffered",t),YN}}}]),e}(),WN=/\{\$([a-zA-Z0-9-_]+)\}/g;function zN(e){return WN.test(e)}function XN(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(WN,(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 QN(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 gI(r).searchParams;if(!o.has(i))throw new Error(_d(s='"'.concat(i,'" does not match any query parameter in URI: "')).call(s,r,'"'));n=o.get(i)}catch(JV){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(JV.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 $N(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 JN=/^(\d+)x(\d+)$/,ZN=/(.+?)=(".*?"|.*?)(?:,|$)/g,eU=function(){function e(r,i){t(this,e),"string"==typeof r&&(r=e.parseAttrList(r,i)),LO(this,r)}return Fc(e,[{key:"clientAttrs",get:function(){var e;return xk(e=gv(this)).call(e,(function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=Ak(this[e],10);return t>lC?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t,r=Fv(t=this[e]||"0x").call(t,2);r=(1&r.length?"0":"")+r;for(var i=new Uint8Array(r.length/2),n=0;n<r.length/2;n++)i[n]=Ak(Fv(r).call(r,2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=Ak(this[e],16);return t>lC?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return bS(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?bS(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r,i=this[e];return kC(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=JN.exec(this[e]);if(null!==t)return{width:Ak(t[1],10),height:Ak(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,i,n={};for(ZN.lastIndex=0;null!==(i=ZN.exec(e));){var a,s=MS(a=i[1]).call(a),o=i[2],l=0===av(o).call(o,'"')&&YC(o).call(o,'"')===o.length-1,u=!1;if(l)o=Fv(o).call(o,1,-1);else switch(s){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":u=!0}if(t&&(l||u))o=XN(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":xO.warn(_d(r="".concat(e,": attribute ")).call(r,s," is missing quotes"))}n[s]=o}return n}}]),e}();function tU(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var rU=function(){function e(r,i){var n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(n=null==i?void 0:i.tagOrder)?n:a,i){var s=i.attr;for(var o in s)if(Object.prototype.hasOwnProperty.call(r,o)&&r[o]!==s[o]){var l;xO.warn(_d(l='DATERANGE tag attribute: "'.concat(o,'" does not match for tags with ID: "')).call(l,r.ID,'"')),this._badValueForSameId=o;break}r=LO(new eU({}),s,r)}if(this.attr=r,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(r["START-DATE"]),"END-DATE"in this.attr){var u=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);lO(u.getTime())&&(this._endDate=u)}}return Fc(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e,t=this.tagAnchor;return null===t||null===t.programDateTime?(xO.warn(_d(e='Expected tagAnchor Fragment with PDT set for DateRange "'.concat(this.id,'": ')).call(e,t)),NaN):t.start+(this.startDate.getTime()-t.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(lO(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&&lO(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}(),iU=function(){function e(r){t(this,e),this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=r}return Fc(e,[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&lO(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(SA()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}]),e}();function nU(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function aU(e){switch(e){case"AES-128":case"AES-256":return HF;case"AES-256-CTR":return VF;default:throw new Error("invalid full segment method ".concat(e))}}function sU(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function oU(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function lU(e){var t,r,i=e.split(":"),n=null;if("data"===i[0]&&2===i.length){var a=i[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(ig(a).call(a,-1,1),n=sU(l)):(t=oU(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),n=r)}}return n}var uU="undefined"!=typeof self?self:void 0,cU="org.w3.clearkey",hU="com.apple.fps",dU="com.microsoft.playready",fU="com.widevine.alpha",vU="org.w3.clearkey",gU="com.apple.streamingkeydelivery",pU="com.microsoft.playready",mU="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function yU(e){switch(e){case gU:return hU;case pU:return dU;case mU:return fU;case vU:return cU}}var EU="1077efecc0b24d02ace33c1e52e2fb4b",kU="e2719d58a985b3c9781ab030af78d30e",TU="9a04f07998404286ab92e65be0885f95",SU="edef8ba979d64acea3c827dcd51d21ed";function AU(e){return e===SU?fU:e===TU?dU:e===EU||e===kU?cU:void 0}function LU(e){switch(e){case hU:return gU;case dU:return pU;case fU:return mU;case cU:return vU}}function bU(e){var t,r=e.drmSystems,i=e.widevineLicenseUrl,n=r?xk(t=[hU,fU,dU,cU]).call(t,(function(e){return!!r[e]})):[];return!n[fU]&&i&&n.push(fU),n}var RU,IU,DU=null!=uU&&null!=(RU=uU.navigator)&&RU.requestMediaKeySystemAccess?sT(IU=self.navigator.requestMediaKeySystemAccess).call(IU,self.navigator):null;function _U(e,t,r,i){var n;switch(e){case hU:n=["cenc","sinf"];break;case fU:case dU:n=["cenc"];break;case cU:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return function(e,t,r,i){var n={initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:_k(t).call(t,(function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:_k(r).call(r,(function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))};return[n]}(n,t,r,i)}function wU(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,LT(t)),i=r.substring(av(r).call(r,"<"),r.length),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){var a=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(a){var s=sU(a).subarray(0,16);return function(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(s),s}}return null}var CU={},PU=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;t(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=r,this.uri=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=s,this.encrypted=!!r&&"NONE"!==r,this.isCommonEncryption=this.encrypted&&!nU(r)}return Fc(e,[{key:"isSupported",value:function(){var e;if(this.method){if(nU(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case gU:case mU:case pU:case vU:return-1!==av(e=["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"]).call(e,this.method)}}return!1}},{key:"getDecryptData",value:function(t){if(!this.encrypted||!this.uri)return null;if(nU(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(xO.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=lU(this.uri);if(i)switch(this.keyFormat){case mU:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case pU:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ON(n,0,i),this.keyId=wU(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=CU[this.uri];if(!o){var l=gv(CU).length%lC;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),CU[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){CU={}}}]),e}();var xU=/#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,MU=/#EXT-X-MEDIA:(.*)/g,OU=/^#EXT(?:INF|-X-TARGETDURATION):/m,FU=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),NU=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("|")),UU=function(){function e(){t(this,e)}return Fc(e,null,[{key:"findGroup",value:function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}}},{key:"resolve",value:function(e,t){return iN.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return OU.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:zN(t)},a=[];for(xU.lastIndex=0;null!=(i=xU.exec(t));)if(i[1]){var s,o=new eU(i[1],n),l=XN(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),VU(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 eU(d,n),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var g=KU(d,r,n);g.encrypted&&g.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(g)):xO.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(d,'"'));break;case"DEFINE":QN(n,new eU(d,n),r);break;case"CONTENT-STEERING":var p=new eU(d,n);n.contentSteering={uri:e.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=HU(d)}}var m=a.length>0&&a.length<n.levels.length;return n.levels=m?a:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n}},{key:"parseMasterPlaylistMedia",value:function(t,r,i){var n,a={},s=i.levels,o={AUDIO:_k(s).call(s,(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:_k(s).call(s,(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(MU.lastIndex=0;null!==(n=MU.exec(t));){var u=new eU(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];jU(y,E,"audioCodec"),jU(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 iU(t),h=c.fragments,d=[],f=null,v=0,g=0,p=0,m=0,y=0,E=null,k=new cN(i,u),T=-1,S=!1,A=null;for(FU.lastIndex=0,c.m3u8=e,c.hasVariableRefs=zN(e);null!==(s=FU.exec(e));){S&&(S=!1,(k=new cN(i,u)).playlistOffset=p,k.start=p,k.sn=v,k.cc=m,y&&(k.bitrate=y),k.level=r,f&&(k.initSegment=f,f.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null),A&&(k.setByteRange(A),A=null)));var L=s[1];if(L){var b;k.duration=bS(L);var R=Fv(b=" "+s[2]).call(b,1);k.title=R||null,k.tagList.push(R?["INF",L,R]:["INF",L])}else if(s[3]){if(lO(k.duration)){var I;k.playlistOffset=p,k.start=p,l&&WU(k,l,c),k.sn=v,k.level=r,k.cc=m,h.push(k);var D=Fv(I=" "+s[3]).call(I,1);k.relurl=XN(c,D),YU(k,E,d),E=k,p+=k.duration,v++,g=0,S=!0}}else{var _,w,C;if(!(s=s[0].match(NU))){xO.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<s.length&&void 0===s[o];o++);var P=Fv(_=" "+s[o]).call(_,1),x=Fv(w=" "+s[o+1]).call(w,1),M=s[o+2]?Fv(C=" "+s[o+2]).call(C,1):null;switch(P){case"BYTERANGE":E?k.setByteRange(x,E):k.setByteRange(x);break;case"PROGRAM-DATE-TIME":k.rawProgramDateTime=x,k.tagList.push(["PROGRAM-DATE-TIME",x]),-1===T&&(T=h.length);break;case"PLAYLIST-TYPE":c.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":v=c.startSN=Ak(x);break;case"SKIP":c.skippedSegments&&(c.playlistParsingError=new Error("#EXT-X-SKIP MUST NOT appear more than once in a Playlist"));var O=new eU(x,c),F=O.decimalInteger("SKIPPED-SEGMENTS");if(lO(F)){c.skippedSegments+=F;for(var N=F;N--;)h.push(null);v+=F}var U,B=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(B)c.recentlyRemovedDateranges=_d(U=c.recentlyRemovedDateranges||[]).call(U,B.split("\t"));break;case"TARGETDURATION":c.targetduration=Math.max(Ak(x),1);break;case"VERSION":c.version=Ak(x);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"#":(x||M)&&k.tagList.push(M?[x,M]:[x]);break;case"DISCONTINUITY":m++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([P]);break;case"BITRATE":k.tagList.push([P,x]),y=1e3*Ak(x),lO(y)?k.bitrate=y:y=0;break;case"DATERANGE":var G=new eU(x,c),K=new rU(G,c.dateRanges[G.ID],c.dateRangeTagCount);c.dateRangeTagCount++,K.isValid||c.skippedSegments?c.dateRanges[K.id]=K:xO.warn('Ignoring invalid DATERANGE tag: "'.concat(x,'"')),k.tagList.push(["EXT-X-DATERANGE",x]);break;case"DEFINE":var H=new eU(x,c);"IMPORT"in H?$N(c,H,a):QN(c,H,t);break;case"DISCONTINUITY-SEQUENCE":c.startCC=m=Ak(x);break;case"KEY":var V=KU(x,t,c);if(V.isSupported()){if("NONE"===V.method){l=void 0;break}l||(l={}),l[V.keyFormat]&&(l=LO({},l)),l[V.keyFormat]=V}else xO.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(x,'"'));break;case"START":c.startTimeOffset=HU(x);break;case"MAP":var j=new eU(x,c);if(k.duration){var Y=new cN(i,u);qU(Y,j,r,l),f=Y,k.initSegment=f,f.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime)}else{var q=k.byteRangeEndOffset;if(q){var W,z=k.byteRangeStartOffset;A=_d(W="".concat(q-z,"@")).call(W,z)}else A=null;qU(k,j,r,l),f=k,S=!0}f.cc=m;break;case"SERVER-CONTROL":var X=new eU(x);c.canBlockReload=X.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=X.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&X.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),c.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Q=new eU(x);c.partTarget=Q.decimalFloatingPoint("PART-TARGET");break;case"PART":var $=c.partList;$||($=c.partList=[]);var J=g>0?$[$.length-1]:void 0,Z=g++,ee=new eU(x,c),te=new hN(ee,k,u,Z,J);$.push(te),k.duration+=te.duration;break;case"PRELOAD-HINT":var re=new eU(x,c);c.preloadHint=re;break;case"RENDITION-REPORT":var ie=new eU(x,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(ie);break;default:xO.warn("line parsed but not handled: ".concat(s))}}}E&&!E.relurl?(h.pop(),p-=E.duration,c.partList&&(c.fragmentHint=E)):c.partList&&(YU(k,E,d),k.cc=m,c.fragmentHint=k,l&&WU(k,l,c));var ne=h.length,ae=h[0],se=h[ne-1];if((p+=c.skippedSegments*c.targetduration)>0&&ne&&se){c.averagetargetduration=p/ne;var oe=se.sn;c.endSN="initSegment"!==oe?oe:0,c.live||(se.endList=!0),ae&&!c.startCC&&(c.startCC=ae.cc),T>0&&(!function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,T),ae&&d.unshift(ae))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(p+=c.fragmentHint.duration),c.totalduration=p,d.length&&c.dateRangeTagCount&&ae&&BU(d,c),c.endCC=m,c}}]),e}();function BU(e,t){for(var r=e.length,i=e[r-1],n=t.live?1/0:t.totalduration,a=gv(t.dateRanges),s=a.length;s--;){var o=t.dateRanges[a[s]],l=o.startDate.getTime();o.tagAnchor=i.ref;for(var u=r;u--;){var c=GU(t,l,e,u,n);if(-1!==c){o.tagAnchor=t.fragments[c].ref;break}}}}function GU(e,t,r,i,n){var a=r[i];if(a){var s,o=a.programDateTime;if(t>=o||0===i)if(t<=o+1e3*(((null==(s=r[i+1])?void 0:s.start)||n)-a.start)){var l=r[i].sn-e.startSN,u=e.fragments;if(u.length>r.length)for(var c=(r[i+1]||u[u.length-1]).sn-e.startSN;c>l;c--){var h=u[c].programDateTime;if(t>=h&&t<h+1e3*u[c].duration)return c}return l}}return-1}function KU(e,t,r){var i,n,a,s,o=new eU(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&&xO.error("Invalid IV: ".concat(o.IV));var f=u?UU.resolve(u,t):"",v=xk(i=_k(n=(h||"1").split("/")).call(n,Number)).call(i,iC);return new PU(l,f,d,v,c)}function HU(e){var t=new eU(e).decimalFloatingPoint("TIME-OFFSET");return lO(t)?t:null}function VU(e,t){var r,i,n=xk(r=(e||"").split(/[ ,]+/)).call(r,(function(e){return e}));vd(i=["video","audio","text"]).call(i,(function(e){var r=xk(n).call(n,(function(t){return function(e,t){var r=FO[t];return!!r&&!!r[Fv(e).call(e,0,4)]}(t,e)}));r.length&&(t["".concat(e,"Codec")]=r.join(","),n=xk(n).call(n,(function(e){return-1===av(r).call(r,e)})))})),t.unknownCodecs=n}function jU(e,t,r){var i=t[r];i&&(e[r]=i)}function YU(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function qU(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 WU(e,t,r){var i;e.levelkeys=t;var n=r.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!KT(i=gv(t)).call(i,(function(e){return t[e].isCommonEncryption}))||n.push(e)}function zU(e,t){var r=t.startPTS;if(lO(r)){var i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function XU(e,t,r,i,n,a){i-r<=0&&(xO.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(lO(l)){var c=Math.abs(l-r);lO(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--)zU(g[d],g[d-1]);for(d=v;d<g.length-1;d++)zU(g[d],g[d+1]);return e.fragmentHint&&zU(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function QU(e,t){for(var r,i=null,n=e.fragments,a=n.length-1;a>=0;a--){var s=n[a].initSegment;if(s){i=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var o,l=0;!function(e,t,r){for(var i,n,a=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,o=(e.fragmentHint?1:0)+(a?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,l=t.startSN-e.startSN,u=t.fragmentHint?_d(i=t.fragments).call(i,t.fragmentHint):t.fragments,c=e.fragmentHint?_d(n=e.fragments).call(n,e.fragmentHint):e.fragments,h=s;h<=o;h++){var d=c[l+h],f=u[h];a&&!f&&d&&(f=t.fragments[h]=d),d&&f&&r(d,f)}}(e,t,(function(e,r){e.relurl&&(l=e.cc-r.cc),lO(e.startPTS)&&lO(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(o=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,i=e.initSegment)}));var u,c=t.fragmentHint?_d(r=t.fragments).call(r,t.fragmentHint):t.fragments;if(i&&vd(c).call(c,(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)})),t.skippedSegments)if(t.deltaUpdateFailed=KT(u=t.fragments).call(u,(function(e){return!e})),t.deltaUpdateFailed){xO.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=t.skippedSegments;h--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC||(t.startCC=t.fragments[0].cc)}else{var d;t.canSkipDateRanges&&(t.dateRanges=function(e,t){var r=t.dateRanges,i=t.recentlyRemovedDateranges,n=LO({},e);i&&vd(i).call(i,(function(e){delete n[e]}));var a,s=gv(n).length;s&&vd(a=gv(r)).call(a,(function(e){var t=n[e],i=new rU(r[e].attr,t);i.isValid?(n[e]=i,t||(i.tagOrder+=s)):xO.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(jI(r[e].attr),'"'))}));return n}(e.dateRanges,t));var f=xk(d=e.fragments).call(d,(function(e){return e.rawProgramDateTime}));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var v=1;v<c.length;v++)null===c[v].programDateTime&&YU(c[v],c[v-1],f);BU(f,t)}var g=t.fragments;if(l){xO.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<g.length;p++)g[p].cc+=l}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),o?XU(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):$U(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 $U(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}JU(t,s)}function JU(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 ZU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function eB(e,t,r){return e?tB(e.partList,t,r):null}function tB(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 rB(e){vd(e).call(e,(function(e,t){var r,i=null==(r=e.details)?void 0:r.fragments;i&&vd(i).call(i,(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function iB(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 nB(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function aB(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)nB(r[i],e);t.fragmentHint&&nB(t.fragmentHint,e),t.alignedSliding=!0}function sB(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var r=Math.min(t.endCC,e.endCC),i=iB(t.fragments,r),n=iB(e.fragments,r);if(i&&n)xO.log("Aligning playlist at start of dicontinuity sequence ".concat(r)),aB(i.start-n.start,e)}}function oB(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=iB(i,s),a=iB(r,s)),n&&a||(a=iB(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,l=a.programDateTime;if(o&&l)aB((l-o)/1e3-(a.start-n.start),e)}}}var lB=function(e){for(var t="",r=e.length,i=0;i<r;i++){var n;t+=_d(n="[".concat(e.start(i).toFixed(3),"-")).call(n,e.end(i).toFixed(3),"]")}return t},uB="STOPPED",cB="IDLE",hB="KEY_LOADING",dB="FRAG_LOADING",fB="FRAG_LOADING_WAITING_RETRY",vB="WAITING_TRACK",gB="PARSING",pB="PARSED",mB="ENDED",yB="ERROR",EB="WAITING_INIT_PTS",kB="WAITING_LEVEL",TB=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s,o){var l;return t(this,i),(l=r.call(this,s,e.logger)).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=uB,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var e,t=Zh(l),r=t.config,i=t.fragCurrent,n=t.media,a=t.mediaBuffer,s=t.state,o=n?n.currentTime:0,u=qN.bufferInfo(a||n,o,r.maxBufferHole);if(l.log(_d(e="media seeking to ".concat(lO(o)?o.toFixed(3):o,", state: ")).call(e,s)),l.state===mB)l.resetLoadingState();else if(i){var c=r.maxFragLookUpTolerance,h=i.start-c,d=i.start+i.duration+c;if(!u.len||d<u.start||h>u.end){var f=o>d;(o<h||f)&&(f&&i.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(n&&(l.fragmentTracker.removeFragmentsInRange(o,1/0,l.playlistType,!0),o>l.lastCurrentTime&&(l.lastCurrentTime=o),!l.loadingParts)){var v,g=Math.max(u.end,o),p=l.shouldLoadParts(l.getLevelDetails(),g);if(p)l.log(_d(v="LL-Part loading ON after seeking to ".concat(o.toFixed(2)," with buffer @")).call(v,g.toFixed(2))),l.loadingParts=p}l.hls.hasEnoughToStart||u.len||(l.log("setting startPosition to ".concat(o," because of seek before start")),l.nextLoadPosition=l.startPosition=o),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0,l.triggerEnded()},l.playlistType=o,l.hls=e,l.fragmentLoader=new BN(e.config),l.keyLoader=a,l.fragmentTracker=n,l.config=e.config,l.decrypter=new NN(e.config),l}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.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!==uB){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=uB}}},{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 qN.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===uB&&this.startLoad(i.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;null!==i&&(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),i.removeEventListener("seeking",this.onMediaSeeking),i.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r?this.resetTransmuxer():(this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()))}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"triggerEnded",value:function(){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=uB,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,Ih(Rh(i.prototype),"onHandlerDestroyed",this).call(this)}},{key:"loadFragment",value:function(e,t,r){var i=this.hls.config;if(i.interstitialsController&&!1!==i.enableInterstitialPlayback&&e.type!==kO){var n=this.hls.interstitialsManager,a=null==n?void 0:n.bufferingItem;if(a){var s=a.event;if(s){if(s.appendInPlace||Math.abs(e.start-a.start)>1||0===a.start)return}else{var o;if(e.end<=a.start&&!1===(null==(o=t.details)?void 0:o.live))return;if(e.start>a.end&&a.nextEvent)return}}}this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}},{key:"_loadFragForPlayback",value:function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(e){var t,r,n,a=e.frag;if(i.fragContextChanged(a))return i.warn(_d(t=_d(r=_d(n="".concat(a.type," sn: ")).call(n,a.sn)).call(r,e.part?" part: "+e.part.index:""," of ")).call(t,i.fragInfo(a,!1,e.part),") was dropped during download.")),void i.fragmentTracker.removeFragment(a);a.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){var t=i.state,r=e.frag;if(i.fragContextChanged(r))(t===dB||!i.fragCurrent&&t===gB)&&(i.fragmentTracker.removeFragment(r),i.state=cB);else{var n,a,s;if("payload"in e)i.log(_d(n=_d(a=_d(s="Loaded ".concat(r.type," sn: ")).call(s,r.sn," of ")).call(a,i.playlistLabel()," ")).call(n,r.level)),i.hls.trigger(fO.FRAG_LOADED,e);i._handleFragmentLoadComplete(e)}}})).catch((function(t){i.state!==uB&&i.state!==yB&&(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)===FF){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)===NF&&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(fO.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&&nU(a.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,aU(a.method)).catch((function(e){throw t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(n){var a=self.performance.now();return t.trigger(fO.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!==uB&&r.state!==yB&&(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!==uB&&(this.state=cB),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(_d(r=_d(i=_d(n=_d(a="Buffered ".concat(e.type," sn: ")).call(a,e.sn)).call(n,t?" part: "+t.index:""," of ")).call(i,this.fragInfo(e,!1,t)," > buffer:")).call(r,s?lB(qN.getBuffered(s)):"(detached)",")")),uN(e)){var o;if(e.type!==kO){var l,u=e.elementaryStreams;if(!KT(l=gv(u)).call(l,(function(e){return!!u[e]})))return void(this.state=cB)}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=cB}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||KT(n).call(n,(function(e){return!e})),s=new jN(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t){var r,i,n,a,s,o,l=this,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,c=arguments.length>3?arguments[3]:void 0;this.fragCurrent=e;var h=null==t?void 0:t.details;if(!this.levels||!h)throw new Error("frag load aborted, missing level".concat(h?"":" detail","s"));var d,f,v,g,p=null;!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&h.encryptedFragments.length&&this.keyLoader.loadClear(e,h.encryptedFragments):(this.log(_d(d=_d(f=_d(v=_d(g="Loading key for ".concat(e.sn," of [")).call(g,h.startSN,"-")).call(v,h.endSN,"], ")).call(f,this.playlistLabel()," ")).call(d,e.level)),this.state=hB,this.fragCurrent=e,p=this.keyLoader.load(e).then((function(e){if(!l.fragContextChanged(e.frag))return l.hls.trigger(fO.KEY_LOADED,e),l.state===hB&&(l.state=cB),e})),this.hls.trigger(fO.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(p=tk.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var m=this.fragPrevious;if(uN(e)&&(!m||e.sn!==m.sn)){var y,E,k=this.shouldLoadParts(t.details,e.end);if(k!==this.loadingParts)this.log(_d(y=_d(E="LL-Part loading ".concat(k?"ON":"OFF"," loading sn ")).call(E,null==m?void 0:m.sn,"->")).call(y,e.sn)),this.loadingParts=k}if(u=Math.max(e.start,u||0),this.loadingParts&&uN(e)){var T=h.partList;if(T&&c){u>e.end&&h.fragmentHint&&(e=h.fragmentHint);var S=this.getNextPart(T,e,u);if(S>-1){var A,L,b,R,I,D,_,w,C,P,x=T[S];return e=this.fragCurrent=x.fragment,this.log(_d(A=_d(L=_d(b=_d(R=_d(I=_d(D=_d(_=_d(w=_d(C="Loading ".concat(e.type," sn: ")).call(C,e.sn," part: ")).call(w,x.index," (")).call(_,S,"/")).call(D,T.length-1,") of ")).call(I,this.fragInfo(e,!1,x),") cc: ")).call(R,e.cc," [")).call(b,h.startSN,"-")).call(L,h.endSN,"], target: ")).call(A,bS(u.toFixed(3)))),this.nextLoadPosition=x.start+x.duration,this.state=dB,P=p?p.then((function(r){return!r||l.fragContextChanged(r.frag)?null:l.doFragPartsLoad(e,x,t,c)})).catch((function(e){return l.handleFragLoadError(e)})):this.doFragPartsLoad(e,x,t,c).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(fO.FRAG_LOADING,{frag:e,part:x,targetBufferTime:u}),null===this.fragCurrent?tk.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):P}if(!e.url||this.loadedEndOfParts(T,u))return tk.resolve(null)}}if(uN(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(u.toFixed(2))),this.loadingParts=!1;else if(!e.url)return tk.resolve(null);this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Loading ".concat(e.type," sn: ")).call(s,e.sn," of ")).call(a,this.fragInfo(e,!1),") cc: ")).call(n,e.cc," ")).call(i,h?"["+h.startSN+"-"+h.endSN+"]":"",", target: ")).call(r,bS(u.toFixed(3)))),lO(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=dB;var M,O=this.config.progressive;return M=O&&p?p.then((function(t){return!t||l.fragContextChanged(null==t?void 0:t.frag)?null:l.fragmentLoader.load(e,c)})).catch((function(e){return l.handleFragLoadError(e)})):tk.all([this.fragmentLoader.load(e,O?c:void 0),p]).then((function(e){var t=fD(e,1)[0];return!O&&t&&c&&c(t),t})).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(fO.FRAG_LOADING,{frag:e,targetBufferTime:u}),null===this.fragCurrent?tk.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):M}},{key:"doFragPartsLoad",value:function(e,t,r,i){var n=this;return new tk((function(a,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function t(o){n.fragmentLoader.loadPart(e,o,i).then((function(i){l[o.index]=i;var s=i.part;n.hls.trigger(fO.FRAG_LOADED,i);var c=eB(r.details,e.sn,o.index+1)||tB(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===dO.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(fO.ERROR,t)}else this.hls.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===gB){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a);var s,o=this.getLevelDetails(),l=o&&r.sn>o.endSN||this.shouldLoadParts(o,r.end);if(l!==this.loadingParts)this.log(_d(s="LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @")).call(s,r.end.toFixed(2))),this.loadingParts=l;this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===uB||this.state===yB||(this.state=cB)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var r,i,n=e.partList[0];if(t>=n.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0))if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t,r,i=this.levels,n=this.fragCurrent,a=e.level,s=e.sn,o=e.part;if(null==i||!i[a])return this.warn(_d(t=_d(r="Levels object was unset while buffering fragment ".concat(s," of ")).call(r,this.playlistLabel()," ")).call(t,a,". The current chunk will not be buffered.")),null;var l=i[a],u=l.details,c=o>-1?eB(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===gB){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=wN(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(fO.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(qN.isBuffered(t,t.currentTime)){var r=t.currentTime,i=qN.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(!lO(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=qN.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 qN.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]:yO,i=null==(t=this.fragmentTracker)?void 0:t.getAppendedFrag(e,r);return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n=this.config,a=r[0].start,s=n.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l,u=n.initialLiveManifestSize;if(i<u)return this.warn(_d(l="Not enough fragments to start playback (have: ".concat(i,", need: ")).call(l,u,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a){var c,h,d,f;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,r);var v=this.hls.startPosition,g=this.hls.liveSyncPosition,p=o?(-1!==v?v:g)||o.start:e;this.log(_d(c=_d(h=_d(d="Setting startPosition to ".concat(p," to match initial live edge. mainStart: ")).call(d,v," liveSyncPosition: ")).call(h,g," frag.start: ")).call(c,null==(f=o)?void 0:f.start)),this.startPosition=this.nextLoadPosition=p}}else e<=a&&(o=r[0]);if(!o){var m=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,m,t)}return this.mapToInitFragWhenRequired(o)}},{key:"isLoopLoading",value:function(e,t){var r=this.fragmentTracker.getState(e);return(r===UF||r===NF&&!!e.gap)&&this.nextLoadPosition>t}},{key:"getNextFragmentLoopLoading",value:function(e,t,r,i,n){var a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t))&&!a.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==s&&r.len+s.len>=n){var o,l=a.sn;if(this.loopSn!==l)this.log(_d(o='buffer full after gaps in "'.concat(i,'" playlist starting at sn: ')).call(o,l)),this.loopSn=l;return null}}return this.loopSn=void 0,a}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(n||l.independent||a)&&l.fragment===t&&(i=s),n=u}return i}},{key:"loadedEndOfParts",value:function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded}},{key:"getInitialLiveFragment",value:function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime)),i=function(e,t,r){if(null===t||!Pk(e)||!e.length||!lO(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(EF(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=kF(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}},{key:"getFragmentAtPosition",value:function(e,t,r){var i,n,a=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=a.maxFragLookUpTolerance,h=r.partList,d=!!(this.loadingParts&&null!=h&&h.length&&u);(d&&u&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=_d(o).call(o,u),l=u.sn),e<t)?i=mF(s,o,e,e<this.lastCurrentTime||e>t-c||null!=(n=this.media)&&n.paused||!this.startFragRequested?0:c):i=o[o.length-1];if(i){var f=i.sn-r.startSN,v=this.fragmentTracker.getState(i);if((v===UF||v===NF&&i.gap)&&(s=i),s&&i.sn===s.sn&&(!d||h[0].fragment.sn>i.sn||!r.live&&!d))if(s&&i.level===s.level){var g=o[f+1];i=i.sn<l&&this.fragmentTracker.getState(g)!==UF?g:null}}return i}},{key:"alignPlaylists",value:function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var n=e.fragmentStart,a=!t,s=e.alignedSliding&&lO(n);if(a||!s&&!n){var o,l,u;!function(e,t){e&&(sB(t,e),!t.alignedSliding&&e&&oB(t,e),t.alignedSliding||!e||t.skippedSegments||$U(e,t,!1))}(r,e);var c=e.fragmentStart;return this.log(_d(o=_d(l=_d(u="Live playlist sliding: ".concat(c.toFixed(2)," start-sn: ")).call(u,t?t.startSN:"na","->")).call(l,e.startSN," fragments: ")).call(o,i)),c}return n}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r){var i,n,a=null!==this.startTimeOffset,s=a?this.startTimeOffset:e.startTimeOffset;if(null!==s&&lO(s))r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(_d(i=_d(n="Setting startPosition to ".concat(r," for start time offset ")).call(n,s," found in ")).call(i,a?"multivariant":"media"," playlist")),this.startPosition=r;else e.live?(r=this.hls.liveSyncPosition||t,this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0);this.lastCurrentTime=r}this.nextLoadPosition=r}},{key:"getLoadPosition",value:function(){var e,t=this.media,r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}},{key:"handleFragLoadAborted",value:function(e,t){var r,i,n;this.transmuxer&&e.type===this.playlistType&&uN(e)&&e.stats.aborted&&(this.warn(_d(r=_d(i=_d(n="Fragment ".concat(e.sn)).call(n,t?" part "+t.index:""," of ")).call(i,this.playlistLabel()," ")).call(r,e.level," was aborted")),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===fB)||(this.state=cB)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var n,a;this.warn(_d(n="Frag load error must match current frag to retry ".concat(i.url," > ")).call(n,null==(a=this.fragCurrent)?void 0:a.url))}else{var s=t.details===dO.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);var o=t.errorAction,l=o||{},u=l.action,c=wC(l),h=l.retryCount,d=void 0===h?0:h,f=l.retryConfig,v=!!o&&!!f,g=v&&u===_F,p=v&&!o.resolved&&c===CF;if(!g&&p&&uN(i)&&!i.endList)this.resetFragmentErrors(e),this.treatAsGap(i),o.resolved=!0;else if((g||p)&&d<f.maxNumRetry){var m,y,E,k,T,S;this.resetStartWhenNotLoaded(this.levelLastLoaded);var A=AF(f,d);this.warn(_d(m=_d(y=_d(E=_d(k=_d(T=_d(S="Fragment ".concat(i.sn," of ")).call(S,e," ")).call(T,i.level," errored with ")).call(k,t.details,", retrying loading ")).call(E,d+1,"/")).call(y,f.maxNumRetry," in ")).call(m,A,"ms")),o.resolved=!0,this.retryDate=self.performance.now()+A,this.state=fB}else if(f&&o){var L;if(this.resetFragmentErrors(e),!(d<f.maxNumRetry))return void this.warn(_d(L="".concat(t.details," reached or exceeded max retry (")).call(L,d,")"));s||u===DF||(o.resolved=!0)}else this.state=u===IF?kB:yB;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===gB||this.state===pB){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===EO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==uB&&(this.state=cB)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var i=qN.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===mB&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==uB&&(this.state=cB)}},{key:"resetStartWhenNotLoaded",value:function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){var t,r;this.warn(_d(t=_d(r="The loading context changed while buffering fragment ".concat(e.sn," of ")).call(r,this.playlistLabel()," ")).call(t,e.level,". This chunk will not be buffered.")),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,r,i){var n,a,s,o,l,u=this,c=r.details;if(c){if(!kC(n=gv(e.elementaryStreams)).call(n,(function(t,n){var a=e.elementaryStreams[n];if(a){var s,o,l=a.endPTS-a.startPTS;if(l<=0)return u.warn(_d(s=_d(o="Could not parse fragment ".concat(e.sn," ")).call(o,n," duration reliably (")).call(s,l,")")),t||!1;var h=i?0:XU(c,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return u.hls.trigger(fO.LEVEL_PTS_UPDATED,{details:c,level:r,drift:h,type:n,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t}),!1)&&null===(null==(l=this.transmuxer)?void 0:l.error)){var h,d,f,v,g=new Error(_d(h=_d(d="Found no media in fragment ".concat(e.sn," of ")).call(d,this.playlistLabel()," ")).call(h,e.level," resetting transmuxer to fallback to playlist timing"));if(0===r.fragmentError&&this.treatAsGap(e,r),this.warn(g.message),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!1,error:g,frag:e,reason:_d(f=_d(v="Found no media in msn ".concat(e.sn," of ")).call(v,this.playlistLabel(),' "')).call(f,r.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=pB,this.log(_d(a=_d(s=_d(o="Parsed ".concat(e.type," sn: ")).call(o,e.sn)).call(s,t?" part: "+t.index:""," of ")).call(a,this.fragInfo(e,!1,t),")")),this.hls.trigger(fO.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===yO?"level":"track"}},{key:"fragInfo",value:function(e){var t,r,i,n,a,s,o,l=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],u=arguments.length>2?arguments[2]:void 0;return _d(t=_d(r=_d(i=_d(n=_d(a="".concat(this.playlistLabel()," ")).call(a,e.level," (")).call(n,u?"part":"frag",":[")).call(i,(null!=(s=l&&!u?e.startPTS:(u||e).start)?s:NaN).toFixed(3),"-")).call(r,(null!=(o=l&&!u?e.endPTS:(u||e).end)?o:NaN).toFixed(3),"]")).call(t,u&&"main"===e.type?"INDEPENDENT="+(u.independent?"YES":"NO"):"")}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t,r=this._state;r!==e&&(this._state=e,this.log(_d(t="".concat(r,"->")).call(t,e)))}}]),i}(VN),SB=function(){function e(){t(this,e),this.chunks=[],this.dataLength=0}return Fc(e,[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}]),e}();var AB={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}aT&&(i.prototype=aT(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?Fv(i).call(i,1):i);return Zk?_d(n).call(n,Zk(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}(AB);var LB=QF(AB.exports),bB="1.6.0-beta.2",RB={};function IB(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 DB(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 _B(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 wB(e,t){for(var r=t,i=0;DB(e,t);){i+=10,i+=_B(e,t+6),IB(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function CB(e,t){return 255===e[t]&&240==(246&e[t+1])}function PB(e,t){return 1&e[t+1]?7:9}function xB(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function MB(e,t){return t+1<e.length&&CB(e,t)}function OB(e,t){if(MB(e,t)){var r=PB(e,t);if(t+r>=e.length)return!1;var i=xB(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||MB(e,n)}return!1}function FB(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i){var n,a,s,o,l,u=t[r+2],c=u>>2&15;if(!(c>12)){var h=1+(u>>6&3),d=t[r+3]>>6&3|(1&u)<<2,f="mp4a.40."+h,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][c],g=c;5!==h&&29!==h||(g-=3);var p=[h<<3|(14&g)>>1,(1&g)<<7|d<<3];return xO.log(_d(n=_d(a=_d(s=_d(o=_d(l="manifest codec:".concat(i,", parsed codec:")).call(l,f,", channels:")).call(o,d,", rate:")).call(s,v," (ADTS object type:")).call(a,h," sampling index:")).call(n,c,")")),{config:p,samplerate:v,channelCount:d,codec:f,parsedCodec:f,manifestCodec:i}}var m=new Error("invalid ADTS sampling index:".concat(c));e.emit(fO.ERROR,fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!0,error:m,reason:m.message})}(t,r,i,n);if(!a)return;LO(e,a)}}function NB(e){return 9216e4/e}function UB(e,t,r,i,n){var a,s=i+n*NB(e.samplerate),o=function(e,t){var r=PB(e,t);if(t+r<=e.length){var i=xB(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 BB(e,t){return DB(e,t)&&_B(e,t+6)+10<=e.length-t}function GB(e){return function(e,t,r,i){var n=(s=e,s instanceof ArrayBuffer?s:s.buffer),a=1;var s;"BYTES_PER_ELEMENT"in i&&(a=i.BYTES_PER_ELEMENT);var o=(d=e,d&&d.buffer instanceof ArrayBuffer&&void 0!==d.byteLength&&void 0!==d.byteOffset?e.byteOffset:0),l=(o+e.byteLength)/a,u=(o+t)/a,c=Math.floor(Math.max(0,Math.min(u,l))),h=Math.floor(Math.min(c+Math.max(r,0),l));var d;return new i(n,c,h-c)}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,Uint8Array)}function KB(e,t){if(e<0)return-KB(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<tP){var i=Math.floor(e*r);return(i%2==0?i:i+1)/r}return Math.round(e*r)/r}function HB(e){var t,r,i={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var n=av(t=e.data.subarray(1)).call(t,0);if(-1!==n){var a=zF(GB(e.data,1,n)),s=e.data[2+n],o=av(r=e.data.subarray(3+n)).call(r,0);if(-1!==o){var l,u,c=zF(GB(e.data,3+n,o));return l="--\x3e"===a?zF(GB(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 VB(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=zF(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=zF(e.data.subarray(t),!0);t+=r.length+1;var i=zF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=zF(e.data);return{key:e.type,info:"",data:n}}(e):"APIC"===e.type?HB(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=zF(e.data.subarray(t),!0);t+=r.length+1;var i=zF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=zF(e.data.subarray(1));return{key:e.type,info:"",data:n}}}(e)}function jB(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=_B(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var YB=10,qB=10;function WB(e){for(var t=0,r=[];DB(e,t);){var i=_B(e,t+6);e[t+5]>>6&1&&(t+=YB);for(var n=(t+=YB)+i;t+qB<n;){var a=jB(e.subarray(t)),s=VB(a);s&&r.push(s),t+=a.size+YB}IB(e,t)&&(t+=YB)}return r}function zB(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function XB(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 QB(e){for(var t=WB(e),r=0;r<t.length;r++){var i=t[r];if(zB(i))return XB(i)}}var $B=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 JB(){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 ZB=function(){function e(){t(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}return Fc(e,[{key:"resetInitSegment",value:function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,r){}},{key:"demux",value:function(e,t){this.cachedData&&(e=wN(this.cachedData,e),this.cachedData=null);var r,i=wB(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?QB(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&lO(o))&&(this.basePTS=eG(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:$B.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 BB(e,n)?(i=wB(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:$B.audioId3,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===l&&r!==l){var c=YF(e,r);this.cachedData?this.cachedData=wN(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:JB(),id3Track:s,textTrack:JB()}}},{key:"demuxSampleAes",value:function(e,t,r){return tk.reject(new Error("[".concat(this,"] This demuxer does not support Sample-AES decryption")))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:JB(),id3Track:this._id3Track,textTrack:JB()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),eG=function(e,t,r){return lO(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},tG=null,rG=[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],iG=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],nG=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],aG=[0,1,1,4];function sG(e,t,r,i,n){if(!(r+24>t.length)){var a=oG(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 oG(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*rG[14*(3===r?3-i:3===i?3:4)+n-1],u=iG[3*(3===r?0:2===r?1:2)+a],c=3===o?1:2,h=nG[r][i],d=aG[i],f=8*h*d,v=Math.floor(h*l/u+s)*d;if(null===tG){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);tG=g?Ak(g[1]):0}return!!tG&&tG<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:c,frameLength:v,samplesPerFrame:f}}}function lG(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function uG(e,t){return t+1<e.length&&lG(e,t)}function cG(e,t){if(t+1<e.length&&lG(e,t)){var r=oG(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||uG(e,n)}return!1}var hG=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this)).observer=void 0,a.config=void 0,a.observer=e,a.config=n,a}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&CB(e,t)&&xB(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){FB(e,this.observer,t,r,e.manifestCodec);var i=UB(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=wB(e,0),i=(null==r?void 0:r.length)||0;if(cG(e,i))return!1;for(var n=e.length;i<n;i++)if(OB(e,i))return t.log("ADTS sync word found !"),!0;return!1}}]),i}(ZB),dG=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},fG=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this)).observer=void 0,n.observer=e,n}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,r){var i=vG(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=wB(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==QB(t)&&dG(e,r)<16}}]),i}(ZB);function vG(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 gG=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return lG(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return sG(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=wB(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==QB(t)&&dG(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(cG(e,r))return xO.log("MPEG Audio sync word found !"),!0;return!1}}]),i}(ZB),pG=/\/emsg[-/]ID3/i,mG=function(){function e(r,i){t(this,e),this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=i}return Fc(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,i){var n=this.videoTrack=JB("video",1),a=this.audioTrack=JB("audio",1),s=this.txtTrack=JB("text",1);if(this.id3Track=JB("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=AN(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=vN.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=wN(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=TN(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=YF(e,0,i.byteOffset-8),t.remainder=YF(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=CN(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=CN(e,t),{videoTrack:t,audioTrack:JB(),id3Track:i,textTrack:JB()}}},{key:"extractID3Track",value:function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var n=TN(e.samples,["emsg"]);n&&vd(n).call(n,(function(e){var n,a=function(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==gN(e.subarray(u,u+1));)r+=gN(e.subarray(u,u+1)),u+=1;for(r+=gN(e.subarray(u,u+1)),u+=1;"\0"!==gN(e.subarray(u,u+1));)i+=gN(e.subarray(u,u+1)),u+=1;i+=gN(e.subarray(u,u+1)),u+=1,n=mN(e,12),a=mN(e,16),o=mN(e,20),l=mN(e,24),u=28}else if(1===t){n=mN(e,u+=4);var c=mN(e,u+=4),h=mN(e,u+=4);for(u+=4,s=Math.pow(2,32)*c+h,uO(s)||(s=lC,xO.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=mN(e,u),l=mN(e,u+=4),u+=4;"\0"!==gN(e.subarray(u,u+1));)r+=gN(e.subarray(u,u+1)),u+=1;for(r+=gN(e.subarray(u,u+1)),u+=1;"\0"!==gN(e.subarray(u,u+1));)i+=gN(e.subarray(u,u+1)),u+=1;i+=gN(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(pG.test(a.schemeIdUri)){var s=yG(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:$B.emsg,duration:o})}else if(r.config.enableEmsgKLVMetadata&&UI(n=a.schemeIdUri).call(n,"urn:misb:KLV:bin:1910.1")){var u=yG(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:u,pts:u,type:$B.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return i}},{key:"demuxSampleAes",value:function(e,t,r){return tk.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var i=mN(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}}]),e}();function yG(e,t){return lO(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var EG=function(){function e(r,i,n){t(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new NN(i,{removePKCS7Padding:!1})}return Fc(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,HF)}},{key:"decryptAacSample",value:function(e,t,r){var i,n=this,a=e[t].unit;if(!(a.length<=16)){var s=a.subarray(16,a.length-a.length%16),o=Fv(i=s.buffer).call(i,s.byteOffset,s.byteOffset+s.length);this.decryptBuffer(o).then((function(i){var s=new Uint8Array(i);a.set(s,16),n.decrypter.isSync()||n.decryptAacSamples(e,t+1,r)}))}}},{key:"decryptAacSamples",value:function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e}},{key:"decryptAvcSample",value:function(e,t,r,i,n){var a=this,s=MN(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}(),kG=function(){function e(){t(this,e),this.VideoSample=null}return Fc(e,[{key:"createVideoSample",value:function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var n=i.units;r=n[n.length-1]}return r}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,r){var i,n,a=t.byteLength,s=e.naluState||0,o=s,l=[],u=0,c=-1,h=0;for(-1===s&&(c=0,h=this.getNALuType(t,0),s=0,u=1);u<a;)if(i=t[u++],s)if(1!==s)if(i)if(1===i){if(n=u-s-1,c>=0){var d={data:t.subarray(c,n),type:h};l.push(d)}else{var f=this.getLastNalUnit(e.samples);f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),n>0&&(f.data=wN(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=wN(g.data,t))}return e.naluState=s,l}}]),e}(),TG=function(){function e(r){t(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=r,this.bytesAvailable=r.byteLength,this.word=0,this.bitsAvailable=0}return Fc(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&xO.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}(),SG=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 1:var c=!1;n=!0;var h,d=i.data;if(l&&d.length>4){var f=a.readSliceType(d);2!==f&&4!==f&&7!==f&&9!==f||(c=!0)}if(c)null!=(h=o)&&h.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=c;break;case 5:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:n=!0,xN(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 TG(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 TG(e),f=0,v=0,g=0,p=0,m=sT(t=d.readUByte).call(t,d),y=sT(r=d.readBits).call(r,d),E=sT(i=d.readUEG).call(i,d),k=sT(n=d.readBoolean).call(n,d),T=sT(a=d.skipBits).call(a,d),S=sT(s=d.skipEG).call(s,d),A=sT(o=d.skipUEG).call(o,d),L=sT(l=this.skipScalingList).call(l,this);m();var b=m();if(y(5),T(3),m(),A(),100===b||110===b||122===b||244===b||44===b||83===b||86===b||118===b||128===b){var R=E();if(3===R&&T(1),A(),A(),T(1),k())for(c=3!==R?8:12,h=0;h<c;h++)k()&&L(h<6?16:64,d)}A();var I=E();if(0===I)E();else if(1===I)for(T(1),S(),S(),u=E(),h=0;h<u;h++)S();A(),T(1);var D=E(),_=E(),w=y(1);0===w&&T(1),T(1),k()&&(f=E(),v=E(),g=E(),p=E());var C=[1,1];if(k()&&k())switch(m()){case 1:C=[1,1];break;case 2:C=[12,11];break;case 3:C=[10,11];break;case 4:C=[16,11];break;case 5:C=[40,33];break;case 6:C=[24,11];break;case 7:C=[20,11];break;case 8:C=[32,11];break;case 9:C=[80,33];break;case 10:C=[18,11];break;case 11:C=[15,11];break;case 12:C=[64,33];break;case 13:C=[160,99];break;case 14:C=[4,3];break;case 15:C=[3,2];break;case 16:C=[2,1];break;case 255:C=[m()<<8|m(),m()<<8|m()]}return{width:Math.ceil(16*(D+1)-2*f-2*v),height:(2-w)*(_+1)*16-(w?2:4)*(g+p),pixelRatio:C}}}]),i}(kG),AG=function(e){Ph(i,e);var r=ed(i);function i(){var e,n;t(this,i);for(var a=arguments.length,s=new Array(a),o=0;o<a;o++)s[o]=arguments[o];return(n=r.call.apply(r,_d(e=[this]).call(e,s))).initVPS=null,n}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts)),o.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var c;if(n=!0,l)null!=(c=o)&&c.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 39:n=!0,xN(i.data,2,r.pts,t.samples);break;case 32:if(n=!0,!e.vps){var h=a.readVPS(i.data);e.params=RO({},h),a.initVPS=i.data}e.vps=[i.data];break;case 33:if(n=!0,l=!0,"object"===Cc(e.params)){if(void 0===e.vps||e.vps[0]===a.initVPS||void 0===e.sps||a.matchSPS(e.sps[0],i.data)||(a.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=a.readSPS(i.data);for(var f in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],d.params)e.params[f]=d.params[f]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.sps.push(i.data)}o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0;break;case 34:if(n=!0,"object"===Cc(e.params)){if(!e.pps){e.pps=[];var v=a.readPPS(i.data);for(var g in v)e.params[g]=v[g]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.pps.push(i.data)}break;case 35:n=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(a.pushAccessUnit(o,e),o=null),o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts));break;default:n=!1}o&&n&&o.units.push(i)})),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),r=0,i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}},{key:"pushAccessUnit",value:function(e,t){Ih(Rh(i.prototype),"pushAccessUnit",this).call(this,e,t),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new TG(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 TG(this.ebsp2rbsp(e));a.readUByte(),a.readUByte(),a.readBits(4);var s=a.readBits(3);a.readBoolean();for(var o=a.readBits(2),l=a.readBoolean(),u=a.readBits(5),c=a.readUByte(),h=a.readUByte(),d=a.readUByte(),f=a.readUByte(),v=a.readUByte(),g=a.readUByte(),p=a.readUByte(),m=a.readUByte(),y=a.readUByte(),E=a.readUByte(),k=a.readUByte(),T=[],S=[],A=0;A<s;A++)T.push(a.readBoolean()),S.push(a.readBoolean());if(s>0)for(var L=s;L<8;L++)a.readBits(2);for(var b=0;b<s;b++)T[b]&&(a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte()),S[b]&&a.readUByte();a.readUEG();var R=a.readUEG();3==R&&a.skipBits(1);var I=a.readUEG(),D=a.readUEG(),_=a.readBoolean(),w=0,C=0,P=0,x=0;_&&(w+=a.readUEG(),C+=a.readUEG(),P+=a.readUEG(),x+=a.readUEG());for(var M=a.readUEG(),O=a.readUEG(),F=a.readUEG(),N=a.readBoolean()?0:s;N<=s;N++)a.skipUEG(),a.skipUEG(),a.skipUEG();if((a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.readBoolean())&&a.readBoolean())for(var U=0;U<4;U++)for(var B=0;B<(3===U?2:6);B++){if(a.readBoolean()){var G=Math.min(64,1<<4+(U<<1));U>1&&a.readEG();for(var K=0;K<G;K++)a.readEG()}else a.readUEG()}a.readBoolean(),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.skipUEG(),a.skipUEG(),a.readBoolean());for(var H=a.readUEG(),V=0,j=0;j<H;j++){var Y=!1;if(0!==j&&(Y=a.readBoolean()),Y){j===H&&a.readUEG(),a.readBoolean(),a.readUEG();for(var q=0,W=0;W<=V;W++){var z=a.readBoolean(),X=!1;z||(X=a.readBoolean()),(z||X)&&q++}V=q}else{var Q=a.readUEG(),$=a.readUEG();V=Q+$;for(var J=0;J<Q;J++)a.readUEG(),a.readBoolean();for(var Z=0;Z<$;Z++)a.readUEG(),a.readBoolean()}}if(a.readBoolean())for(var ee=a.readUEG(),te=0;te<ee;te++){for(var re=0;re<F+4;re++)a.readBits(1);a.readBits(1)}var ie=0,ne=1,ae=1,se=!0,oe=1,le=0;a.readBoolean(),a.readBoolean();var ue=!1;if(a.readBoolean()){if(a.readBoolean()){var ce=a.readUByte();ce>0&&ce<16?(ne=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ce-1],ae=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ce-1]):255===ce&&(ne=a.readBits(16),ae=a.readBits(16))}if(a.readBoolean()&&a.readBoolean(),a.readBoolean())a.readBits(3),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.readUByte(),a.readUByte());if(a.readBoolean()&&(a.readUEG(),a.readUEG()),a.readBoolean(),a.readBoolean(),a.readBoolean(),(ue=a.readBoolean())&&(w+=a.readUEG(),C+=a.readUEG(),P+=a.readUEG(),x+=a.readUEG()),a.readBoolean())if(oe=a.readBits(32),le=a.readBits(32),a.readBoolean()&&a.readUEG(),a.readBoolean()){var he=a.readBoolean(),de=a.readBoolean(),fe=!1;(he||de)&&((fe=a.readBoolean())&&(a.readUByte(),a.readBits(5),a.readBoolean(),a.readBits(5)),a.readBits(4),a.readBits(4),fe&&a.readBits(4),a.readBits(5),a.readBits(5),a.readBits(5));for(var ve=0;ve<=s;ve++){var ge=!1;(se=a.readBoolean())||a.readBoolean()?a.readEG():ge=a.readBoolean();var pe=ge?1:a.readUEG()+1;if(he)for(var me=0;me<pe;me++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1);if(de)for(var ye=0;ye<pe;ye++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1)}}a.readBoolean()&&(a.readBoolean(),a.readBoolean(),a.readBoolean(),ie=a.readUEG())}var Ee=I,ke=D;if(_||ue){var Te=1,Se=1;1===R?Te=Se=2:2==R&&(Te=2),Ee=I-Te*C-Te*w,ke=D-Se*x-Se*P}for(var Ae=o?["A","B","C"][o]:"",Le=c<<24|h<<16|d<<8|f,be=0,Re=0;Re<32;Re++)be=(be|(Le>>Re&1)<<31-Re)>>>0;var Ie=be.toString(16);1===u&&"2"===Ie&&(Ie="6");var De=l?"H":"L";return{codecString:_d(t=_d(r=_d(i=_d(n="hvc1.".concat(Ae)).call(n,u,".")).call(i,Ie,".")).call(r,De)).call(t,k,".B0"),params:{general_tier_flag:l,general_profile_idc:u,general_profile_space:o,general_profile_compatibility_flags:[c,h,d,f],general_constraint_indicator_flags:[v,g,p,m,y,E],general_level_idc:k,bit_depth:M+8,bit_depth_luma_minus8:M,bit_depth_chroma_minus8:O,min_spatial_segmentation_idc:ie,chroma_format_idc:R,frame_rate:{fixed:se,fps:le/oe}},width:Ee,height:ke,pixelRatio:[ne,ae]}}},{key:"readPPS",value:function(e){var t=new TG(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var r=t.readBoolean(),i=t.readBoolean(),n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}]),i}(kG),LG=188,bG=function(){function e(r,i,n,a){t(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=r,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return Fc(e,[{key:"resetInitSegment",value:function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,r){var i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];n||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,c=s.pid,h=s.pesData,d=o.pid,f=l.pid,v=o.pesData,g=l.pesData,p=null,m=this.pmtParsed,y=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=wN(this.remainderData,t)).length,this.remainderData=null),E<LG&&!a)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var k=Math.max(0,e.syncOffset(t));(E-=(E-k)%LG)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var T=0,S=k;S<E;S+=LG)if(71===t[S]){var A=!!(64&t[S+1]),L=RG(t,S),b=void 0;if((48&t[S+3])>>4>1){if((b=S+5+t[S+4])===S+LG)continue}else b=S+4;switch(L){case c:if(A){if(h&&(i=CG(h,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new SG;break;case"hevc":this.videoParser=new AG}null!==this.videoParser&&this.videoParser.parsePES(s,u,i,!1)}h={data:[],size:0}}h&&(h.data.push(t.subarray(b,S+LG)),h.size+=S+LG-b);break;case d:if(A){if(v&&(i=CG(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+LG)),v.size+=S+LG-b);break;case f:A&&(g&&(i=CG(g,this.logger))&&this.parseID3PES(l,i),g={data:[],size:0}),g&&(g.data.push(t.subarray(b,S+LG)),g.size+=S+LG-b);break;case 0:A&&(b+=t[b]+1),y=this._pmtId=IG(t,b);break;case y:A&&(b+=t[b]+1);var R,I,D=DG(t,b,this.typeSupported,n,this.observer,this.logger);if((c=D.videoPid)>0&&(s.pid=c,s.segmentCodec=D.segmentVideoCodec),(d=D.audioPid)>0&&(o.pid=d,o.segmentCodec=D.segmentAudioCodec),(f=D.id3Pid)>0&&(l.pid=f),null!==p&&!m)this.logger.warn(_d(R=_d(I="MPEG-TS PMT found at ".concat(S," after unknown PID '")).call(I,p,"'. Backtracking to sync byte @")).call(R,k," to parse all TS packets.")),p=null,S=k-188;m=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=L}}else T++;T>0&&_G(this.observer,new Error("Found ".concat(T," TS packet/s that do not start with 0x47")),void 0,this.logger),s.pesData=h,o.pesData=v,l.pesData=g;var _={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(_),_}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(t=CG(s,this.logger))){if(null===this.videoParser)switch(i.segmentCodec){case"avc":this.videoParser=new SG;break;case"hevc":this.videoParser=new AG}null!==this.videoParser&&(this.videoParser.parsePES(i,a,t,!0),i.pesData=null)}else i.pesData=s;if(o&&(t=CG(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=CG(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 EG(this.observer,this.config,t);return this.decrypt(i,n)}},{key:"decrypt",value:function(e,t){return new tk((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){r(e)}))}))}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var r,i,n,a=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=wN(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&&!MB(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",_G(this.observer,new Error(h),d,this.logger),!d)return}if(FB(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=NB(e.samplerate);n=s.sample.pts+f}for(var v,g=0;r<i;){if(r+=(v=UB(e,o,r,n,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!MB(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(uG(r,a)){var o=sG(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=vG(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=LO({},t,{type:this._videoTrack?$B.emsg:$B.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-LG)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=LG){if(71!==e[o]||t-o!==LG&&71!==e[o+LG]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-LG)+1),n||(n=0===RG(e,o)),n&&s>1&&(0===a&&s>2||o+LG>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:vN[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function RG(e,t){return((31&e[t+1])<<8)+e[t+2]}function IG(e,t){return(31&e[t+10])<<8|e[t+11]}function DG(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=RG(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){wG("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){wG("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){wG("AC-3",a);break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="ac3"):a.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&u>0)for(var c=t+5,h=u;h>2;){if(106===e[c])!0!==r.ac3?a.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");var d=e[c+1]+2;c+=d,h-=d}break;case 194:case 135:return _G(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 _G(e,t,r,i){i.warn("parsing error: ".concat(t.message)),e.emit(fO.ERROR,fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function wG(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function CG(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]=wN(l[0],l[1]),ig(l).call(l,1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;var u=r[7];192&u&&(a=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?a-(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>54e5&&(t.warn("".concat(Math.round((a-s)/9e4),"s delta between PTS and DTS, align them")),a=s):s=a);var c=(n=r[8])+9;if(e.size<=c)return null;e.size-=c;for(var h=new Uint8Array(e.size),d=0,f=l.length;d<f;d++){var v=(r=l[d]).byteLength;if(c){if(c>v){c-=v;continue}r=r.subarray(c),v-=c,c=0}h.set(r,o),o+=v}return i&&(i-=n+3),{data:h,pts:a,dts:s,len:i}}return null}var PG=function(){function e(){t(this,e)}return Fc(e,null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}(),xG=Math.pow(2,32)-1,MG=function(){function e(){t(this,e)}return Fc(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))}},{key:"box",value:function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){r*=t;var i=Math.floor(r/(xG+1)),n=Math.floor(r%(xG+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))}},{key:"moov",value:function(t){for(var r,i,n=t.length,a=[];n--;)a[n]=e.trak(t[n]);return e.box.apply(null,_d(r=_d(i=[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)]).call(i,a)).call(r,e.mvex(t)))}},{key:"mvex",value:function(t){for(var r,i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,_d(r=[e.types.mvex]).call(r,n))}},{key:"mvhd",value:function(t,r){r*=t;var i=Math.floor(r/(xG+1)),n=Math.floor(r%(xG+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=wC(n[r]),a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,i,n,a,s,o,l=[],u=[];for(a=0;a<t.sps.length;a++)o=(s=t.sps[a]).byteLength,l.push(o>>>8&255),l.push(255&o),l=_d(l).call(l,Fv(Array.prototype).call(s));for(a=0;a<t.pps.length;a++)o=(s=t.pps[a]).byteLength,u.push(o>>>8&255),u.push(255&o),u=_d(u).call(u,Fv(Array.prototype).call(s));var c=e.box(e.types.avcC,new Uint8Array(_d(r=_d(i=_d(n=[1,l[3],l[4],l[5],255,224|t.sps.length]).call(n,l)).call(i,[t.pps.length])).call(r,u))),h=t.width,d=t.height,f=t.pixelRatio[0],v=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,h>>8&255,255&h,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),c,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,255&f,v>>24,v>>16&255,v>>8&255,255&v])))}},{key:"esds",value:function(e){var t,r=e.config;return new Uint8Array(_d(t=[0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2]).call(t,dD(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/(xG+1)),o=Math.floor(i%(xG+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/(xG+1)),s=Math.floor(r%(xG+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=wC(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 wN(e.FTYP,r)}},{key:"hvc1",value:function(t){for(var r=t.params,i=[t.vps,t.sps,t.pps],n=new Uint8Array([1,r.general_profile_space<<6|(r.general_tier_flag?32:0)|r.general_profile_idc,r.general_profile_compatibility_flags[0],r.general_profile_compatibility_flags[1],r.general_profile_compatibility_flags[2],r.general_profile_compatibility_flags[3],r.general_constraint_indicator_flags[0],r.general_constraint_indicator_flags[1],r.general_constraint_indicator_flags[2],r.general_constraint_indicator_flags[3],r.general_constraint_indicator_flags[4],r.general_constraint_indicator_flags[5],r.general_level_idc,240|r.min_spatial_segmentation_idc>>8,255&r.min_spatial_segmentation_idc,252|r.parallelismType,252|r.chroma_format_idc,248|r.bit_depth_luma_minus8,248|r.bit_depth_chroma_minus8,0,Ak(r.frame_rate.fps),3|r.temporal_id_nested<<2|r.num_temporal_layers<<3|(r.frame_rate.fixed?64:0),i.length]),a=n.length,s=0;s<i.length;s+=1){a+=3;for(var o=0;o<i[s].length;o+=1)a+=2+i[s][o].length}var l=new Uint8Array(a);l.set(n,0),a=n.length;for(var u=i.length-1,c=0;c<i.length;c+=1){l.set(new Uint8Array([32+c|(c===u?128:0),0,i[c].length]),a),a+=3;for(var h=0;h<i[c].length;h+=1)l.set(new Uint8Array([i[c][h].length>>8,255&i[c][h].length]),a),a+=2,l.set(i[c][h],a),a+=i[c][h].length}var d=e.box(e.types.hvcC,l),f=t.width,v=t.height,g=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,f>>8&255,255&f,v>>8&255,255&v,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,255&g,p>>24,p>>16&255,p>>8&255,255&p])))}}]),e}();MG.types=void 0,MG.HDLR_TYPES=void 0,MG.STTS=void 0,MG.STSC=void 0,MG.STCO=void 0,MG.STSZ=void 0,MG.VMHD=void 0,MG.SMHD=void 0,MG.STSD=void 0,MG.FTYP=void 0,MG.DINF=void 0;var OG=9e4;function FG(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 NG(e){return FG(e,1e3,1/OG,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}var UG=null,BG=null,GG=function(){function e(r,i,n,a){if(t(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=r,this.config=i,this.typeSupported=n,this.logger=a,this.ISGenerated=!1,null===UG){var s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);UG=s?Ak(s[1]):0}if(null===BG){var o=navigator.userAgent.match(/Safari\/(\d+)/i);BG=o?Ak(o[1]):0}}return Fc(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,r=e[0].pts,i=kC(e).call(e,(function(e,i){var n=i.pts,a=n-e;return a<-4294967296&&(t=!0,a=(n=KG(n,r))-e),a>0?e:n}),r);return t&&this.logger.debug("PTS rollover detected"),i}},{key:"remux",value:function(e,t,r,i,n,a,s,o){var l,u,c,h,d,f,v=n,g=n,p=e.pid>-1,m=t.pid>-1,y=t.samples.length,E=e.samples.length>0,k=s&&y>0||y>1;if((!p||E)&&(!m||k)||this.ISGenerated||s){if(this.ISGenerated){var T,S,A,L,b=this.videoTrackConfig;(b&&(t.width!==b.width||t.height!==b.height||(null==(T=t.pixelRatio)?void 0:T[0])!==(null==(S=b.pixelRatio)?void 0:S[0])||(null==(A=t.pixelRatio)?void 0:A[1])!==(null==(L=b.pixelRatio)?void 0:L[1]))||!b&&k||null===this.nextAudioPts&&E)&&this.resetInitSegment()}this.ISGenerated||(c=this.generateIS(e,t,n,a));var R,I=this.isVideoContiguous,D=-1;if(k&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!I&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,D>0){var _,w;this.logger.warn(_d(_="[mp4-remuxer]: Dropped ".concat(D," out of ")).call(_,y," video samples due to a missing keyframe"));var C=this.getVideoStartPts(t.samples);t.samples=Fv(w=t.samples).call(w,D),t.dropped+=D,R=g+=(t.samples[0].pts-C)/t.inputTimeScale}else-1===D&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(y," video samples")),f=!1);if(this.ISGenerated){if(E&&k){var P=this.getVideoStartPts(t.samples),x=(KG(e.samples[0].pts,P)-P)/t.inputTimeScale;v+=Math.max(0,x),g+=Math.max(0,-x)}if(E){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,v,this.isAudioContiguous,a,m||k||o===EO?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=HG(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=VG(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):MG.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:MG.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,KG(l[0].dts,v)-g),n=Math.min(n,v-g)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(gv(c).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:c,initPTS:n,timescale:s}}},{key:"remuxVideo",value:function(e,t,r,i){var n,a,s=e.inputTimeScale,o=e.samples,l=[],u=o.length,c=this._initPTS,h=this.nextAvcDts,d=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,p=!1;if(!r||null===h){var m=t*s,y=o[0].pts-KG(o[0].dts,o[0].pts);UG&&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=KG(T.pts-E,h),T.dts=KG(T.dts-E,h),T.dts<o[k>0?k-1:k].dts&&(p=!0)}p&&mA(o).call(o,(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=o[0].dts;var S=(a=o[o.length-1].dts)-n,A=S?Math.round(S/(u-1)):f||e.inputTimeScale/30;if(r){var L=n-h,b=L>A,R=L<-1;if(b||R){var I,D,_,w,C,P;if(b)this.logger.warn(_d(I=_d(D=_d(_="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(_,NG(L,!0)," ms (")).call(D,L,"dts) hole between fragments detected at ")).call(I,t.toFixed(3)));else this.logger.warn(_d(w=_d(C=_d(P="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(P,NG(-L,!0)," ms (")).call(C,L,"dts) overlapping between fragments detected at ")).call(w,t.toFixed(3)));if(!R||h>=o[0].pts||UG){var x,M;n=h;var O=o[0].pts-L;if(b)o[0].dts=n,o[0].pts=O;else for(var F=!0,N=0;N<o.length&&!(o[N].dts>O&&F);N++){var U=o[N].pts;if(o[N].dts-=L,o[N].pts-=L,N<o.length-1){var B=o[N+1].pts;F=B<=o[N].pts==B<=U}}this.logger.log(_d(x=_d(M="Video: Initial PTS/DTS adjusted: ".concat(NG(O,!0),"/")).call(M,NG(n,!0),", delta: ")).call(x,NG(L,!0)," ms"))}}}for(var G=0,K=0,H=n=Math.max(0,n),V=0;V<u;V++){for(var j=o[V],Y=j.units,q=Y.length,W=0,z=0;z<q;z++)W+=Y[z].data.length;K+=W,G+=q,j.length=W,j.dts<H?(j.dts=H,H+=A/4|0||1):H=j.dts,v=Math.min(j.pts,v),g=Math.max(j.pts,g)}a=o[u-1].dts;var X,Q=K+4*G+8;try{X=new Uint8Array(Q)}catch(Ie){return void this.observer.emit(fO.ERROR,fO.ERROR,{type:hO.MUX_ERROR,details:dO.REMUX_ALLOC_ERROR,fatal:!1,error:Ie,bytes:Q,reason:"fail allocating video mdat ".concat(Q)})}var $=new DataView(X.buffer);$.setUint32(0,Q),X.set(MG.types.mdat,4);for(var J=!1,Z=Number.POSITIVE_INFINITY,ee=Number.POSITIVE_INFINITY,te=Number.NEGATIVE_INFINITY,re=Number.NEGATIVE_INFINITY,ie=0;ie<u;ie++){for(var ne=o[ie],ae=ne.units,se=0,oe=0,le=ae.length;oe<le;oe++){var ue=ae[oe],ce=ue.data,he=ue.data.byteLength;$.setUint32(d,he),d+=4,X.set(ce,d),d+=he,se+=4+he}var de=void 0;if(ie<u-1)f=o[ie+1].dts-ne.dts,de=o[ie+1].pts-ne.pts;else{var fe=this.config,ve=ie>0?ne.dts-o[ie-1].dts:A;if(de=ie>0?ne.pts-o[ie-1].pts:A,fe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ge,pe=Math.floor(fe.maxBufferHole*s),me=(i?v+i*s:this.nextAudioPts)-ne.pts;if(me>pe)(f=me-ve)<0?f=ve:J=!0,this.logger.log(_d(ge="[mp4-remuxer]: It is approximately ".concat(me/90," ms to the next segment; using duration ")).call(ge,f/90," ms for the last video frame."));else f=ve}else f=ve}var ye=Math.round(ne.pts-ne.dts);Z=Math.min(Z,f),te=Math.max(te,f),ee=Math.min(ee,de),re=Math.max(re,de),l.push(new YG(ne.key,f,se,ye))}if(l.length)if(UG){if(UG<70){var Ee=wC(l[0]);Ee.dependsOn=2,Ee.isNonSync=0}}else if(BG&&re-ee<te-Z&&A/te<.025&&0===l[0].cts){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ke=n,Te=0,Se=l.length;Te<Se;Te++){var Ae=ke+l[Te].duration,Le=ke+l[Te].cts;if(Te<Se-1){var be=Ae+l[Te+1].cts;l[Te].duration=be-Le}else l[Te].duration=Te?l[Te-1].duration:A;l[Te].cts=0,ke=Ae}}f=J||!f?A:f,this.nextAvcDts=h=a+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;var Re={data1:MG.moof(e.sequenceNumber++,n,LO({},e,{samples:l})),data2:X,startPTS:v/s,endPTS:(g+f)/s,startDTS:n/s,endDTS:h/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Re}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,r,i,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.getSamplesPerFrame(e),l=o*s,u=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],d=void 0!==n,f=e.samples,v=c?0:8,g=this.nextAudioPts||-1,p=t*a,m=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||f.length&&g>0&&(i&&Math.abs(p-g)<9e3||Math.abs(KG(f[0].pts-m,p)-g)<20*l),vd(f).call(f,(function(e){e.pts=KG(e.pts-m,p)})),!r||g<0){if(!(f=xk(f).call(f,(function(e){return e.pts>=0}))).length)return;g=0===n?0:i&&!d?Math.max(0,p):f[0].pts}if("aac"===e.segmentCodec)for(var y=this.config.maxAudioFramesDrift,E=0,k=g;E<f.length;E++){var T,S=f[E],A=S.pts,L=A-k,b=Math.abs(1e3*L/a);if(L<=-y*l&&d){if(0===E)this.logger.warn(_d(T="Audio frame @ ".concat((A/a).toFixed(3),"s overlaps nextAudioPts by ")).call(T,Math.round(1e3*L/a)," ms.")),this.nextAudioPts=g=k=A}else if(L>=y*l&&b<1e4&&d){var R,I,D=Math.round(L/l);(k=A-D*l)<0&&(D--,k+=l),0===E&&(this.nextAudioPts=g=k),this.logger.warn(_d(R=_d(I="[mp4-remuxer]: Injecting ".concat(D," audio frame @ ")).call(I,(k/a).toFixed(3),"s due to ")).call(R,Math.round(1e3*L/a)," ms gap."));for(var _=0;_<D;_++){var w=Math.max(k,0),C=PG.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);C||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),C=S.unit.subarray()),ig(f).call(f,E,0,{unit:C,pts:w}),k+=l,E++}}S.pts=k,k+=l}for(var P,x=null,M=null,O=0,F=f.length;F--;)O+=f[F].unit.byteLength;for(var N=0,U=f.length;N<U;N++){var B=f[N],G=B.unit,K=B.pts;if(null!==M){h[N-1].duration=Math.round((K-M)/s)}else{if(r&&"aac"===e.segmentCodec&&(K=g),x=K,!(O>0))return;O+=v;try{P=new Uint8Array(O)}catch(X){return void this.observer.emit(fO.ERROR,fO.ERROR,{type:hO.MUX_ERROR,details:dO.REMUX_ALLOC_ERROR,fatal:!1,error:X,bytes:O,reason:"fail allocating audio mdat ".concat(O)})}c||(new DataView(P.buffer).setUint32(0,O),P.set(MG.types.mdat,4))}P.set(G,v);var H=G.byteLength;v+=H,h.push(new YG(!0,o,H,0)),M=K}var V=h.length;if(V){var j=h[h.length-1];this.nextAudioPts=g=M+s*j.duration;var Y=c?new Uint8Array(0):MG.moof(e.sequenceNumber++,x/s,LO({},e,{samples:h}));e.samples=[];var q=x/a,W=g/a,z={data1:Y,data2:P,startPTS:q,endPTS:W,startDTS:q,endDTS:W,type:"audio",hasAudio:!0,hasVideo:!1,nb:V};return this.isAudioContiguous=!0,z}}}]),e}();function KG(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 HG(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=KG(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=KG(o.dts-i.baseTime*a/i.timescale,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function VG(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=KG(o.pts-r.baseTime*a/r.timescale,t*a)/a}mA(i=e.samples).call(i,(function(e,t){return e.pts-t.pts}));var l=e.samples;return e.samples=[],{samples:l}}}var jG,YG=Fc((function e(r,i,n,a){t(this,e),this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=n,this.cts=a,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:r?2:1,isNonSync:r?0:1}})),qG=function(){function e(r,i,n,a){t(this,e),this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=a}return Fc(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.lastEndTime=null}},{key:"resetNextTimestamp",value:function(){this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(!e||!t)return e;var r=t.keyId;if(r&&t.isCommonEncryption){var i=TN(e,["moov","trak"]);vd(i).call(i,(function(e){var t=TN(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=TN(t,["enca"]),n=i.length>0;n||(i=TN(t,["encv"])),vd(i).call(i,(function(e){var t=TN(n?e.subarray(28):e.subarray(78),["sinf"]);vd(t).call(t,(function(e){var t=DN(e);if(t){var i,a,s=t.subarray(8,24);KT(s).call(s,(function(e){return 0!==e}))||(xO.log(_d(i=_d(a="[eme] Patching keyId in 'enc".concat(n?"a":"v",">sinf>>tenc' box: ")).call(a,XF.hexDump(s)," -> ")).call(i,XF.hexDump(r))),t.set(r,8))}}))}))}))}return e}(e,i)),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=AN(e);i.audio&&(t=WG(i.audio,aN)),i.video&&(r=WG(i.video,sN));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}},{key:"remux",value:function(e,t,r,i,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};lO(u)||(u=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return c;var d={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,n=0,a=TN(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],l=TN(o,["tfhd"])[0],u=t[mN(l,4)];if(u){var c=u.default,h=mN(l,0)|(null==c?void 0:wC(c)),d=null==c?void 0:c.duration;8&h&&(d=mN(l,2&h?12:8));for(var f=u.timescale||9e4,v=TN(o,["trun"]),g=0;g<v.length;g++)!(r=_N(v[g]))&&d&&(r=d*mN(v[g],4)),u.type===sN?i+=r/f:u.type===aN&&(n+=r/f)}}if(0===i&&0===n){for(var p=1/0,m=0,y=0,E=TN(e,["sidx"]),k=0;k<E.length;k++){var T=SN(E[k]);if(null!=T&&T.references){var S;p=Math.min(p,T.earliestPresentationTime/T.timescale);var A=kC(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&&lO(y))return y}return i||n}(h,f),g=function(e,t){var r;return kC(r=TN(t,["moof","traf"])).call(r,(function(t,r){var i,n=TN(r,["tfdt"])[0],a=n[0],s=kC(i=TN(r,["tfhd"])).call(i,(function(t,r){var i=mN(r,4),s=e[i];if(s){var o=mN(n,4);if(1===a){if(o===dN)return xO.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=dN+1,o+=mN(n,8)}var l=o/(s.timescale||9e4);if(lO(l)&&(null===t||l<t))return l}return t}),null);return null!==s&&lO(s)&&(null===t||s<t)?s:t}),null)}(f,h),p=null===g?n:g;if(function(e,t,r,i){if(null===e)return!0;var n=Math.max(i,1),a=t-e.baseTime/e.timescale;return Math.abs(a-r)>n}(l,p,n,v)||d.timescale!==l.timescale&&a){var m,y;if(d.initPTS=p-n,l&&1===l.timescale)this.logger.warn(_d(m=_d(y="Adjusting initPTS @".concat(n," from ")).call(y,l.baseTime/l.timescale," to ")).call(m,d.initPTS));this.initPTS=l={baseTime:d.initPTS,timescale:1}}var E=e?p-l.baseTime/l.timescale:u,k=E+v;!function(e,t,r){var i;vd(i=TN(t,["moof","traf"])).call(i,(function(t){var i;vd(i=TN(t,["tfhd"])).call(i,(function(i){var n,a=mN(i,4),s=e[a];if(s){var o=s.timescale||9e4;vd(n=TN(t,["tfdt"])).call(n,(function(e){var t=e[0],i=r*o;if(i){var n=mN(e,4);if(0===t)n-=i,kN(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=mN(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(dN+1)),s=Math.floor(n%(dN+1));kN(e,4,a),kN(e,8,s)}}}))}}))}))}(f,h,l.baseTime/l.timescale),v>0?this.lastEndTime=k:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!f.audio,S=!!f.video,A="";T&&(A+="audio"),S&&(A+="video");var L={data1:h,startPTS:E,startDTS:E,endPTS:k,endDTS:k,type:A,hasAudio:T,hasVideo:S,nb:1,dropped:0};return c.audio="audio"===L.type?L:void 0,c.video="audio"!==L.type?L:void 0,c.initSegment=d,c.id3=HG(r,n,l,l),i.samples.length&&(c.text=VG(i,n,l)),c}}]),e}();function WG(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===aN){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return jO(r,!1)}return xO.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"}return xO.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1"}try{var zG;jG=sT(zG=self.performance.now).call(zG,self.performance)}catch(ZV){jG=SA}var XG=[{demux:mG,remux:qG},{demux:bG,remux:GG},{demux:hG,remux:GG},{demux:gG,remux:GG}];ig(XG).call(XG,2,0,{demux:fG,remux:GG});var QG=function(){function e(r,i,n,a,s,o){t(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=r,this.typeSupported=i,this.config=n,this.id=s,this.logger=o}return Fc(e,[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,r,i){var n=this,a=r.transmuxing;a.executeStart=jG();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,c=u.contiguous,h=u.discontinuity,d=u.trackSwitch,f=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,p=l.audioCodec,m=l.videoCodec,y=l.defaultInitPts,E=l.duration,k=l.initSegmentData,T=function(e,t){var r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(s,t);if(T&&nU(T.method)){var S=this.getDecrypter(),A=aU(T.method);if(!S.isSync())return this.asyncResult=!0,this.decryptionPromise=S.webCryptoDecrypt(s,T.key.buffer,T.iv.buffer,A).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var L=S.softwareDecrypt(s,T.key.buffer,T.iv.buffer,A);if(r.part>-1){var b=S.flush();L=b?b.buffer:b}if(!L)return a.executeEnd=jG(),$G(r);s=new Uint8Array(L)}var R=this.needsProbing(h,d);if(R){var I=this.configureTransmuxer(s);if(I)return this.logger.warn("[transmuxer] ".concat(I.message)),this.observer.emit(fO.ERROR,fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),a.executeEnd=jG(),$G(r)}(h||d||g||R)&&this.resetInitSegment(k,p,m,E,t),(h||g||R)&&this.resetInitialTimestamp(y),c||this.resetContiguity();var D=this.transmux(s,T,v,f,r);this.asyncResult=JG(D);var _=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,a.executeEnd=jG(),D}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=jG();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=jG();var h=[$G(e)];return this.asyncResult?tk.resolve(h):h}var d=u.flush(o);return JG(d)?(this.asyncResult=!0,d.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,d,e),this.asyncResult?tk.resolve(s):s)}},{key:"flushRemux",value:function(e,t,r){var i,n,a,s,o=t.audioTrack,l=t.videoTrack,u=t.id3Track,c=t.textTrack,h=this.currentTransmuxState,d=h.accurateTimeOffset,f=h.timeOffset;this.logger.log(_d(i=_d(n=_d(a=_d(s="[transmuxer.ts]: Flushed ".concat(this.id," sn: ")).call(s,r.sn)).call(a,r.part>-1?" part: "+r.part:""," of ")).call(n,this.id===yO?"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=jG()}},{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=XG.length;a<s;a++){var o;if(null!=(o=XG[a].demux)&&o.probe(e,this.logger)){t=XG[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 NN(this.config)),e}}]),e}();var $G=function(e){return{remuxResult:{},chunkMeta:e}};function JG(e){return"then"in e&&e.then instanceof Function}var ZG=Fc((function e(r,i,n,a,s){t(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=s||null})),eK=Fc((function e(r,i,n,a,s,o){t(this,e),this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=r,this.contiguous=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=s,this.initSegmentChange=o})),tK=0,rK=function(){function e(r,i,n,a){var s=this;t(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=tK++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(e){var t=e.data,r=s.hls;if(r&&null!=t&&t.event&&t.instanceNo===s.instanceNo)switch(t.event){case"init":var i,n=null==(i=s.workerContext)?void 0:i.objectURL;n&&gI.revokeObjectURL(n);break;case"transmuxComplete":s.handleTransmuxComplete(t.data);break;case"flush":s.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=s.frag,t.data.part=s.part,t.data.id=s.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){var t,r;if(s.hls){var i=new Error(_d(t=_d(r="".concat(e.message," (")).call(r,e.filename,":")).call(t,e.lineno,")"));s.hls.config.enableWorker=!1,s.hls.logger.warn('Error in "'.concat(s.id,'" Web Worker, fallback to inline')),s.hls.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})}};var o=r.config;this.hls=r,this.id=i,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var l=function(e,t){(t=t||{}).frag=s.frag||void 0,e===fO.ERROR&&(t.parent=s.id,t.part=s.part,s.error=t.error),s.hls.trigger(e,t)};this.observer=new LB,this.observer.on(fO.FRAG_DECRYPTED,l),this.observer.on(fO.ERROR,l);var u=WO(o.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var c=this.hls.logger;if(o.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{var h;if(o.workerPath)c.log(_d(h="loading Web Worker ".concat(o.workerPath,' for "')).call(h,i,'"')),this.workerContext=function(e){var t=RB[e];if(t)return t.clientCount++,t;var r=new gI(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return RB[e]=i,i}(o.workerPath);else c.log('injecting Web Worker for "'.concat(i,'"')),this.workerContext=function(){var e=RB[bB];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=gI.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return RB[bB]=i,i}();var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:i,config:jI(o)})}catch(ZV){c.warn('Error setting up "'.concat(i,'" Web Worker, fallback to inline'),ZV),this.terminateWorker(),this.error=null,this.transmuxer=new QG(this.observer,u,o,"",i,r.logger)}return}}this.transmuxer=new QG(this.observer,u,o,"",i,r.logger)}return Fc(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=tK++;var t=this.hls.config,r=WO(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:jI(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=RB[e||bB];if(t&&1==t.clientCount--){var r=t.worker,i=t.objectURL;delete RB[e||bB],i&&gI.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 eK(y,A,o,E,g,b);if(!A||y||b){var I,D,_,w,C,P,x,M,O,F,N;this.hls.logger.log(_d(I=_d(D=_d(_=_d(w=_d(C=_d(P=_d(x=_d(M=_d(O=_d(F=_d(N="[transmuxer-interface]: Starting new transmux session for ".concat(n.type," sn: ")).call(N,l.sn)).call(F,l.part>-1?" part: "+l.part:""," ")).call(O,this.id===yO?"level":"track",": ")).call(M,l.level," id: ")).call(x,l.id,"\n discontinuity: ")).call(P,y,"\n trackSwitch: ")).call(C,E,"\n contiguous: ")).call(w,A,"\n accurateTimeOffset: ")).call(_,o,"\n timeOffset: ")).call(D,g,"\n initSegmentChange: ")).call(I,b));var U=new ZG(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);JG(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);JG(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(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}},{key:"handleFlushResult",value:function(e,t){var r=this;vd(e).call(e,(function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}]),e}();function iK(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!nK(e[r].attrs,t[r].attrs))return!1;return!0}function nK(e,t,r){var i,n=e["STABLE-RENDITION-ID"];return n&&!r?n===t["STABLE-RENDITION-ID"]:!KT(i=r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).call(i,(function(r){return e[r]!==t[r]}))}function aK(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var sK=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"audio-stream-controller",EO)).mainAnchor=null,s.mainFragLoading=null,s.audioOnly=!1,s.bufferedTrack=null,s.switchingTrack=null,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.flushing=!1,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(fO.BUFFER_RESET,this.onBufferReset,this),e.on(fO.BUFFER_CREATED,this.onBufferCreated,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(fO.FRAG_LOADING,this.onFragLoading,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(Ih(Rh(i.prototype),"unregisterListeners",this).call(this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(fO.BUFFER_RESET,this.onBufferReset,this),e.off(fO.BUFFER_CREATED,this.onBufferCreated,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(fO.FRAG_LOADING,this.onFragLoading,this),e.off(fO.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===yO){var s,o,l=r.cc,u=this.fragCurrent;if(this.initPTS[l]={baseTime:n,timescale:a},this.log(_d(s=_d(o="InitPTS for cc: ".concat(l," found from main: ")).call(o,n,"/")).call(s,a)),this.mainAnchor=r,this.state===EB){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===cB&&this.tick()}}},{key:"findSyncFrag",value:function(e){var t=this.getLevelDetails(),r=e.cc;return function(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var i=r.start,n=r.end,a=e.fragments;if(!r.relurl){var s=e.fragmentHint;s&&(a=_d(a).call(a,s))}return pF(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&&kF(t.fragments,r)||e}},{key:"startLoad",value:function(e){if(!this.levels)return this.startPosition=e,void(this.state=uB);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=cB):this.state=vB,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case cB:this.doTickIdle();break;case vB:var e=this.levels,t=this.trackId,r=null==e?void 0:e[t],n=null==r?void 0:r.details;if(n&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(n))break;this.state=EB}break;case fB: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=cB}break;case EB:var c=this.waitingData;if(c){var h=c.frag,d=c.part,f=c.cache,v=c.complete,g=this.mainAnchor;if(void 0!==this.initPTS[h.cc]){this.waitingData=null,this.state=dB;var p={frag:h,part:d,payload:f.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(p),v&&Ih(Rh(i.prototype),"_handleFragmentLoadComplete",this).call(this,p)}else if(g&&g.cc!==c.frag.cc){var m;this.log(_d(m="Waiting fragment cc (".concat(h.cc,") cancelled because video is at cc ")).call(m,g.cc)),this.nextLoadPosition=this.findSyncFrag(g).start,this.clearWaitingFragment()}}else this.state=cB}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!==uB&&(this.state=cB))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),Ih(Rh(i.prototype),"resetLoadingState",this).call(this)}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,r=this.levels,i=this.media,n=this.trackId,a=t.config;if(this.buffering&&(i||!this.startFragRequested&&a.startFragPrefetch)&&null!=r&&r[n]){var s=r[n],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=vB,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,aN,EO));var u=this.getFwdBufferInfo(l,EO);if(null!==u){var c=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(u,o))return t.trigger(fO.BUFFER_EOS,{type:"audio"}),void(this.state=mB);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&&!nK(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,yO,f)),E){var k=null==(e=this.mainFragLoading)?void 0:e.frag;if(!this.audioOnly&&this.startFragRequested&&k&&uN(k)&&uN(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,yO);S&&S.end>k.end&&(T=S,this.mainFragLoading={frag:S,targetBufferTime:null})}if(E.start>T.end)return}this.loadFragment(E,s,m)}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,t){this.bufferFlushed=this.flushing=!1,Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=_k(r).call(r,(function(e){return new nF(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!==uB&&(this.setInterval(100),this.state=cB,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.hls.trigger(fO.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!==uB&&(this.state=vB));if(l){this.log(_d(r=_d(i=_d(n=_d(a="Audio track ".concat(c," loaded [")).call(a,u.startSN,",")).call(n,u.endSN,"]")).call(i,u.lastPartSn?_d(s="[part-".concat(u.lastPartSn,"-")).call(s,u.lastPartIndex,"]"):"",",duration:")).call(r,u.totalduration));var d=l[c],f=0;if(u.live||null!=(o=d.details)&&o.live){if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;var v;if(d.details)f=this.alignPlaylists(u,d.details,null==(v=this.levelLastLoaded)?void 0:v.details);u.alignedSliding||(sB(u,h),u.alignedSliding||oB(u,h),f=u.fragmentStart)}d.details=u,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(h,f),this.hls.trigger(fO.AUDIO_TRACK_UPDATED,{details:u,id:c,groupId:t.groupId}),this.state!==vB||this.waitForCdnTuneIn(u)||(this.state=cB),this.tick()}else this.warn("Audio tracks were reset while loading level ".concat(c))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var u=l.details;if(!u)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);var c,h,d=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",f=this.transmuxer;if(!f)f=this.transmuxer=new rK(this.hls,EO,sT(c=this._handleTransmuxComplete).call(c,this),sT(h=this._handleTransmuxerFlush).call(h,this));var v=this.initPTS[r.cc],g=null==(t=r.initSegment)?void 0:t.data;if(void 0!==v){var p=i?i.index:-1,m=-1!==p,y=new jN(r.level,r.sn,r.stats.chunkCount,n.byteLength,p,m);f.push(n,g,d,"",r,i,u.totalduration,!1,y,v)}else{var E,k,T,S;this.log(_d(E=_d(k=_d(T=_d(S="Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ")).call(S,r.sn," of [")).call(T,u.startSN," ,")).call(k,u.endSN,"],track ")).call(E,s)),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new SB,complete:!1}).cache.push(new Uint8Array(n)),this.state!==uB&&(this.state=EB)}}else this.warn("Audio track is undefined on fragment load progress")}else{var A;this.warn(_d(A="Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ")).call(A,r.level," will not be buffered"))}}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:Ih(Rh(i.prototype),"_handleFragmentLoadComplete",this).call(this,e)}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===yO&&uN(t.frag)&&(this.mainFragLoading=t,this.state===cB&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part;if(r.type===EO)if(this.fragContextChanged(r)){var n,a,s,o;this.warn(_d(n=_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state,", audioSwitch: ")).call(n,this.switchingTrack?this.switchingTrack.name:"false"))}else{if(uN(r)){this.fragPrevious=r;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(fO.AUDIO_TRACK_SWITCHED,RO({},l)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==yO||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=yB;else switch(t.details){case dO.FRAG_GAP:case dO.FRAG_PARSING_ERROR:case dO.FRAG_DECRYPT_ERROR:case dO.FRAG_LOAD_ERROR:case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_ERROR:case dO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(EO,t);break;case dO.AUDIO_TRACK_LOAD_ERROR:case dO.AUDIO_TRACK_LOAD_TIMEOUT:case dO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==vB||(null==(r=t.context)?void 0:r.type)!==pO||(this.state=cB);break;case dO.BUFFER_APPEND_ERROR:case dO.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===dO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case dO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==sN&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==sN){this.flushing=!1,this.bufferFlushed=!0,this.state===mB&&(this.state=cB);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,r,EO),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=gB,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(fO.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[aN]={startPTS:p,endPTS:m,startDTS:y,endDTS:E}),o.setElementaryStreamInfo(aN,p,m,y,E),this.bufferFragmentData(h,o,l,a)}if(null!=f&&null!=(t=f.samples)&&t.length){var k=LO({id:r,frag:o,details:c},f);i.trigger(fO.FRAG_PARSING_METADATA,k)}if(d){var T=LO({id:r,frag:o,details:c},d);i.trigger(fO.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===gB&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var s=t.audio;s.id="audio";var o=e.audioCodec;this.log(_d(n=_d(a="Init audio buffer, container:".concat(s.container,", codecs[level/parsed]=[")).call(a,o,"/")).call(n,s.codec,"]")),o&&1===o.split(",").length&&(s.levelCodec=o),this.hls.trigger(fO.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(fO.BUFFER_APPENDING,u)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,t,r){var n,a=this.fragmentTracker.getState(e);if(this.switchingTrack||a===OF||a===NF)if(uN(e))if(null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]){var s,o;this.log(_d(s=_d(o="Waiting for video PTS in continuity counter ".concat(e.cc," of live stream before loading audio fragment ")).call(o,e.sn," of level ")).call(s,this.trackId)),this.state=EB;var l=this.mainDetails;l&&l.fragmentStart!==t.details.fragmentStart&&oB(t.details,l)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){var t=this.media,r=this.bufferedTrack,n=null==r?void 0:r.attrs,a=e.attrs;t&&n&&(n.CHANNELS!==a.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(fO.AUDIO_TRACK_SWITCHED,RO({},e))}}]),i}(TB),oK=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n,e.logger)).hls=void 0,a.canLoad=!1,a.timer=-1,a.hls=e,a}return Fc(i,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var n=-1,a=0;a<i.length;a++){var s=i[a],o=void 0;try{o=new gI(s.URI,t.url).href}catch(JV){this.warn("Could not construct new URL for Rendition Report: ".concat(JV)),o=s.URI||""}if(o===e){n=a;break}o===e.substring(0,o.length)&&(n=a)}if(-1!==n){var l=i[n],u=Ak(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),c=Ak(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&h>t.partTarget&&(c+=1)}var d=r&&rF(r);return new iF(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(JV){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(JV))}return e}},{key:"playlistLoaded",value:function(e,t,r){var i=t.details,n=t.stats,a=self.performance.now(),s=n.loading.first?Math.max(0,a-n.loading.first):0;i.advancedDateTime=SA()-s;var o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){var l,u=Math.max(o||0,0);i.appliedTimelineOffset=u,vd(l=i.fragments).call(l,(function(e){e.start=e.playlistOffset+u}))}if(i.live||null!=r&&r.live){var c,h="levelInfo"in t?t.levelInfo:t.track;i.reloaded(r),r&&i.fragments.length>0&&QU(r,i),-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);var d,f=this.hls.mainForwardBufferInfo,v=f?f.end-f.len:0,g=ZU(i,1e3*(i.edge-v));if(i.requestScheduled+g<a?i.requestScheduled=a:i.requestScheduled+=g,this.log(_d(c="live playlist ".concat(e," ")).call(c,i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;var p=void 0,m=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var y=this.hls.config.lowLatencyMode,E=i.lastPartSn,k=i.endSN,T=i.lastPartIndex,S=E===k;-1!==T?S?(p=k+1,m=y?0:T):(p=E,m=y?T+1:i.maxPartIndex):p=k+1;var A=i.age,L=A+i.ageHeader,b=Math.min(L-i.partTarget,1.5*i.targetduration);if(b>0){if(L>3*i.targetduration)this.log("Playlist last advanced ".concat(A.toFixed(2),"s ago. Omitting segment and part directives.")),p=void 0,m=void 0;else if(null!=r&&r.tuneInGoal&&L-i.partTarget>r.tuneInGoal){var R,I;this.warn(_d(R=_d(I="CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ")).call(I,b," with playlist age: ")).call(R,i.age)),b=0}else{var D,_,w,C,P=Math.floor(b/i.targetduration);if(p+=P,void 0!==m)m+=Math.round(b%i.targetduration/i.partTarget);this.log(_d(D=_d(_=_d(w=_d(C="CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ")).call(C,A.toFixed(2),"s goal: ")).call(w,b," skip sn ")).call(_,P," to part ")).call(D,m))}i.tuneInGoal=b}if(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m),y||!S)return i.requestScheduled=a,void this.loadingPlaylist(h,d)}else(i.canBlockReload||i.canSkipUntil)&&(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m));d&&void 0!==p&&i.canBlockReload&&(i.requestScheduled=n.loading.first+Math.max(g-2*s,g/2)),this.scheduleLoading(h,d,i)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,r){var i,n=this,a=r||e.details;if(a){var s=self.performance.now(),o=a.requestScheduled;if(s>=o)this.loadingPlaylist(e,t);else{var l=o-s;this.log(_d(i="reload live playlist ".concat(e.name||e.bitrate+"bps"," in ")).call(i,Math.round(l)," ms")),this.clearTimer(),this.timer=Wf((function(){return n.loadingPlaylist(e,t)}),l)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,i){var n=rF(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=ZO),new iF(r,i,n)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,i=TF(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===_F||!n.resolved&&s===IF);if(c){var h;if(l>=u.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives){var d,f;this.warn(_d(d=_d(f="Retrying playlist loading ".concat(l+1,"/")).call(f,u.maxNumRetry,' after "')).call(d,r,'" without delivery-directives')),this.loadPlaylist()}else{var v,g,p,m=AF(u,l);this.clearTimer(),this.timer=Wf((function(){return t.loadPlaylist()}),m),this.warn(_d(v=_d(g=_d(p="Retrying playlist loading ".concat(l+1,"/")).call(p,u.maxNumRetry,' after "')).call(g,r,'" in ')).call(v,m,"ms"))}e.levelRetry=!0,n.resolved=!0}return c}}]),i}(IO),lK=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e,"audio-track-controller")).tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVEL_LOADING,this.onLevelLoading,this),e.off(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(fO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var r,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Audio track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Audio track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.audioGroups||null,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&KT(r).call(r,(function(e){return-1===(null==i?void 0:av(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=xk(a=this.tracks).call(a,(function(e){return!r||-1!==av(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!KT(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.audioPreference;if(!n&&l){var u=cF(l,o,dF);if(u>-1)n=o[u];else{var c=cF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={audioTracks:o};this.log(_d(s="Updating audio tracks, ".concat(o.length," track(s) found in group(s): ")).call(s,null==r?void 0:r.join(","))),this.hls.trigger(fO.AUDIO_TRACKS_UPDATED,d);var f=this.trackId;if(-1!==h&&-1===f)this.setAudioTrack(h);else if(o.length&&-1===f){var v,g,p=new Error(_d(v="No audio track selected for current audio group-ID(s): ".concat(null==(g=this.groupIds)?void 0:g.join(",")," track count: ")).call(v,o.length));this.warn(p.message),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:p})}}}}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==pO||t.context.id!==this.trackId||this.groupIds&&-1===av(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"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&&hF(e,i,dF))return i;var n=cF(e,this.tracksInGroup,dF);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=kC(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=fF(t,i,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var i=t.audioGroups,a=xk(r).call(r,(function(e){return!i||-1!==av(i).call(i,e.groupId)}));return cF(e,a,n)>-1}));return c>-1?c:fF(t,i,(function(t){var i=t.audioGroups,a=xk(r).call(r,(function(e){return!i||-1!==av(i).call(i,e.groupId)}));return cF(e,a,n)>-1}))}(e,t.levels,r,s,dF);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=cF(e,r);if(l>-1)return r[l]}}}return null}},{key:"setAudioTrack",value:function(e){var t,r,i,n,a=this.tracksInGroup;if(e<0||e>=a.length)this.warn("Invalid audio track id: ".concat(e));else{this.selectDefaultTrack=!1;var s=this.currentTrack,o=a[e],l=o.details&&!o.details.live;if(!(e===this.trackId&&o===s&&l||(this.log(_d(t=_d(r=_d(i=_d(n="Switching to audio-track ".concat(e,' "')).call(n,o.name,'" lang:')).call(i,o.lang," group:")).call(r,o.groupId," channels:")).call(t,o.channels)),this.trackId=e,this.currentTrack=o,this.hls.trigger(fO.AUDIO_TRACK_SWITCHING,RO({},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||hF(e,i,dF)))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(hF({name:n,lang:a,assocLang:s,characteristics:o,audioCodec:l,channels:u},t[c],dF))return c}for(var h=0;h<t.length;h++){var d=t[h];if(nK(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var f=0;f<t.length;f++){var v=t[f];if(nK(e.attrs,v.attrs,["LANGUAGE"]))return f}}return-1}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this);var t=this.currentTrack;this.shouldLoadPlaylist(t)&&vF(t.url,this.hls)&&this.scheduleLoading(t,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading audio-track ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(fO.AUDIO_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}}]),i}(oK),uK=function(){function e(r){t(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=r}return Fc(e,[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,r){if(null!==this.queues&&null!==this.tracks){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){var t=this;return new tk((function(r){var i={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(i,e)}))}},{key:"prependBlocker",value:function(e){var t=this;return new tk((function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}}))}},{key:"removeBlockers",value:function(){var e;null!==this.queues&&vd(e=[this.queues.video,this.queues.audio,this.queues.audiovideo]).call(e,(function(e){var t,r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),ig(e).call(e,0,1))}))}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(JV){var i;if(r.onError(JV),null===this.queues||null===this.tracks)return;var n=null==(i=this.tracks[e])?void 0:i.buffer;null!=n&&n.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e,t,r=this.queues,i=this.tracks;return null===r||null===i?"<destroyed>":_d(e=_d(t="\n".concat(this.list("video"),"\n")).call(t,this.list("audio"),"\n")).call(e,this.list("audiovideo"),"}")}},{key:"list",value:function(e){var t,r,i,n;return null!=(i=this.queues)&&i[e]||null!=(n=this.tracks)&&n[e]?_d(t=_d(r="".concat(e,": (")).call(r,this.listSbInfo(e),") ")).call(t,this.listOps(e)):""}},{key:"listSbInfo",value:function(e){var t,r,i,n=null==(i=this.tracks)?void 0:i[e],a=null==n?void 0:n.buffer;return a?_d(t=_d(r="SourceBuffer".concat(a.updating?" updating":"")).call(r,n.ended?" ended":"")).call(t,n.ending?" ending":""):"none"}},{key:"listOps",value:function(e){var t,r;return(null==(r=this.queues)?void 0:_k(t=r[e]).call(t,(function(e){return e.label})).join(", "))||""}}]),e}(),cK=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,hK="HlsJsTrackRemovedError",dK=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e)).name=hK,n}return Fc(i)}(tC(Error)),fK=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(a=r.call(this,"buffer-controller",e.logger)).hls=void 0,a.fragmentTracker=void 0,a.details=null,a._objectUrl=null,a.operationQueue=null,a.bufferCodecEventsTotal=0,a.media=null,a.mediaSource=null,a.lastMpegAudioChunk=null,a.blockedAudioAppend=null,a.lastVideoAppendEnd=0,a.appendSource=void 0,a.transferData=void 0,a.overrides=void 0,a.appendErrors={audio:0,video:0,audiovideo:0},a.tracks={},a.sourceBuffers=[[null,null],[null,null]],a._onEndStreaming=function(e){var t;a.hls&&"open"===(null==(t=a.mediaSource)?void 0:t.readyState)&&a.hls.pauseBuffering()},a._onStartStreaming=function(e){a.hls&&a.hls.resumeBuffering()},a._onMediaSourceOpen=function(e){var t=Zh(a),r=t.media,i=t.mediaSource;e&&a.log("Media source opened"),r&&i&&(r.removeEventListener("emptied",a._onMediaEmptied),a.updateDuration(),a.hls.trigger(fO.MEDIA_ATTACHED,{media:r,mediaSource:i}),i.removeEventListener("sourceopen",a._onMediaSourceOpen),null!==a.mediaSource&&a.checkPendingTracks())},a._onMediaSourceClose=function(){a.log("Media source closed")},a._onMediaSourceEnded=function(){a.log("Media source ended")},a._onMediaEmptied=function(){var e,t=Zh(a),r=t.mediaSrc,i=t._objectUrl;r!==i&&a.error(_d(e="Media element src was set while attaching MediaSource (".concat(i," > ")).call(e,r,")"))},a.hls=e,a.fragmentTracker=n,a.appendSource=(s=MO(e.config.preferManagedMediaSource),"undefined"!=typeof self&&s===self.ManagedMediaSource),a.initTracks(),a.registerListeners(),a}return Fc(i,[{key:"hasSourceTypes",value:function(){return gv(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.BUFFER_RESET,this.onBufferReset,this),e.on(fO.BUFFER_APPENDING,this.onBufferAppending,this),e.on(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(fO.BUFFER_EOS,this.onBufferEos,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fO.FRAG_PARSED,this.onFragParsed,this),e.on(fO.FRAG_CHANGED,this.onFragChanged,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.BUFFER_RESET,this.onBufferReset,this),e.off(fO.BUFFER_APPENDING,this.onBufferAppending,this),e.off(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fO.BUFFER_EOS,this.onBufferEos,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fO.FRAG_PARSED,this.onFragParsed,this),e.off(fO.FRAG_CHANGED,this.onFragChanged,this),e.off(fO.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a,s,o=this.isQueued();if(n||o)this.warn(_d(a=_d(s="Transfering MediaSource with".concat(o?" operations in queue":"")).call(s,n?" updating SourceBuffer(s)":""," ")).call(a,this.operationQueue));this.operationQueue.destroy()}var l,u=this.transferData;!this.sourceBufferCount&&u&&u.mediaSource===r?LO(i,u.tracks):vd(l=this.sourceBuffers).call(l,(function(t){var r=fD(t,1)[0];r&&(i[r]=LO({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null}));return{media:t,mediaSource:r,tracks:i}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var r,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log("".concat(i," bufferCodec event(s) expected.")),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media,i=MO(this.appendSource);if(this.transferData=this.overrides=void 0,r&&i){var n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var a=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(a),n)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=gI.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,vK(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(JV){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r,i;this.log(_d(t="".concat((null==(r=this.transferData)?void 0:r.mediaSource)===e?"transferred":"created"," media source: ")).call(t,null==(i=e.constructor)?void 0:i.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this,t=this.media,r=this.transferData;if(r&&t){var i=this.tracks,n=r.tracks,a=n?gv(n):null,s=a?a.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(n&&a&&s){var l,u;if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(_d(l=_d(u="attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ")).call(u,jI(i,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ")).call(l,jI(n,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!OO(n,i)){var c,h,d;r.mediaSource=null,r.tracks=void 0;var f,v=t.currentTime,g=this.details,p=Math.max(v,(null==g?void 0:g.fragments[0].start)||0);return p-v>1?void this.log(_d(f="attachTransferred: waiting for playback to reach new tracks start time ".concat(v," -> ")).call(f,p)):(this.warn(_d(c=_d(h=_d(d='attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(gv(n),'"->"')).call(d,gv(i),'") start time: ')).call(h,p," currentTime: ")).call(c,v)),this.onMediaDetaching(fO.MEDIA_DETACHING,{}),this.onMediaAttaching(fO.MEDIA_ATTACHING,r),void(t.currentTime=p))}this.transferData=void 0,vd(a).call(a,(function(t){var r=t,i=n[r];if(i){var a=i.buffer;if(a){var s=e.fragmentTracker,o=i.id;if(s.hasFragments(o)||s.hasParts(o)){var l=qN.getBuffered(a);s.detectEvictedFragments(r,l,o,null,!0)}var u=gK(r),c=[r,a];e.sourceBuffers[u]=c,a.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,i)}}})),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var r=this,i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,s=this._objectUrl;if(a){if(this.log("media source ".concat(i?"transferring":"detaching")),i){var o;vd(o=this.sourceBuffers).call(o,(function(e){var t=fD(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(ZV){this.warn("onMediaDetaching: ".concat(ZV.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&&gI.revokeObjectURL(s),this.mediaSrc===s?(n.removeAttribute("src"),this.appendSource&&vK(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(fO.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){var e,t=this;vd(e=this.sourceBuffers).call(e,(function(e){var r=fD(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(ZV){this.warn("onBufferReset ".concat(e),ZV)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[gK(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 uK(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r,i=this,n=this.tracks,a=gv(t);this.log(_d(r='BUFFER_CODECS: "'.concat(a,'" (current SB count ')).call(r,this.sourceBufferCount,")"));var s,o="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),l=!o&&this.sourceBufferCount&&this.media&&KT(a).call(a,(function(e){return!n[e]}));o||l?this.warn(_d(s='Unsupported transition between "'.concat(gv(n),'" and "')).call(s,a,'" SourceBuffers')):(vd(a).call(a,(function(e){var r,a,s,o=t[e],l=o.id,u=o.codec,c=o.levelCodec,h=o.container,d=o.metadata,f=n[e],v=null==(r=i.transferData)||null==(a=r.tracks)?void 0:a[e],g=null!=v&&v.buffer?v:f,p=(null==g?void 0:g.pendingCodec)||(null==g?void 0:g.codec),m=null==g?void 0:g.levelCodec,y=!g||!!i.hls.config.assetPlayerId;f||(f=n[e]={buffer:void 0,listeners:[],codec:u,container:h,levelCodec:c,metadata:d,id:l});var E,k=YO(p,m),T=null==k?void 0:k.replace(cK,"$1"),S=YO(u,c),A=null==(s=S)?void 0:s.replace(cK,"$1");S&&(T!==A||y)&&("audio"===Fv(e).call(e,0,5)&&(S=jO(S,i.appendSource)),i.log(_d(E="switching codec ".concat(p," to ")).call(E,S)),S!==(f.pendingCodec||f.codec)&&(f.pendingCodec=S),f.container=h,i.appendChangeType(e,h,S))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e,t=this;return kC(e=gv(this.tracks)).call(e,(function(e,r){var i=t.tracks[r];return e[r]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e}),{})}},{key:"appendChangeType",value:function(e,t,r){var i,n=this,a=_d(i="".concat(t,";codecs=")).call(i,r),s={label:"change-type=".concat(a),execute:function(){var i=n.tracks[e];if(i){var s,o=i.buffer;if(null!=o&&o.changeType)n.log(_d(s="changing ".concat(e," sourceBuffer type to ")).call(s,a)),o.changeType(a),i.codec=r,i.container=t}n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){n.warn("Failed to change ".concat(e," SourceBuffer type"),t)}};this.append(s,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,r=this,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,yO))?void 0:t.gap))){var a={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>n||null!=t&&t.buffer&&qN.isBuffered(t.buffer,n)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(n,yO))?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||qN.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&&!qN.isBuffered(y,A)&&this.lastVideoAppendEnd<A&&this.blockAudio(E):this.blockAudio(E)}}var R=(l||o).start,I={label:"append-".concat(a),execute:function(){if(c.executeStart=self.performance.now(),p){var e=r.tracks[a];if(e){var t=e.buffer;if(t){var i,s,o=R-t.timestampOffset;if(Math.abs(o)>=.1)r.log(_d(i=_d(s="Updating audio SourceBuffer timestampOffset to ".concat(R," (delta: ")).call(s,o,") sn: ")).call(i,h,")")),t.timestampOffset=R}}}r.appendExecutor(n,a)},onStart:function(){},onComplete:function(){var e,t=self.performance.now();c.executeEnd=c.end=t,0===f.first&&(f.first=t),v&&0===v.first&&(v.first=t);var i={};vd(e=r.sourceBuffers).call(e,(function(e){var t=fD(e,2),r=t[0],n=t[1];r&&(i[r]=qN.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(fO.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:i})},onError:function(e){var t,i={type:hO.MEDIA_ERROR,parent:o.type,details:dO.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=dO.BUFFER_FULL_ERROR;else if(e.code!==DOMException.INVALID_STATE_ERR||!r.mediaSourceOpenOrEnded||null!=(t=r.media)&&t.error)if(e.name===hK)0===r.sourceBufferCount?i.errorAction=MF(!0):++r.appendErrors[a];else{var n,s,c=++r.appendErrors[a];r.warn(_d(n=_d(s="Failed ".concat(c,"/")).call(s,r.hls.config.appendErrorMaxRetry,' times to append segment in "')).call(n,a,'" sourceBuffer')),c>=r.hls.config.appendErrorMaxRetry&&(i.fatal=!0)}else i.errorAction=MF(!0);r.hls.trigger(fO.ERROR,i)}};this.append(I,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,r){var i,n,a=this;return this.log(_d(i=_d(n='queuing "'.concat(e,'" remove ')).call(n,t,"-")).call(i,r)),{label:"remove",execute:function(){a.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){a.hls.trigger(fO.BUFFER_FLUSHED,{type:e})},onError:function(i){var n,s;a.warn(_d(n=_d(s="Failed to remove ".concat(t,"-")).call(s,r,' from "')).call(n,e,'" SourceBuffer'),i)}}}},{key:"onBufferFlushing",value:function(e,t){var r,i=this,n=t.type,a=t.startOffset,s=t.endOffset;n?this.append(this.getFlushOp(n,a,s),n):vd(r=this.sourceBuffers).call(r,(function(e){var t=fD(e,1)[0];t&&i.append(i.getFlushOp(t,a,s),t)}))}},{key:"onFragParsed",value:function(e,t){var r=this,i=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[oN]?a.push("audiovideo"):(s[aN]&&a.push("audio"),s[sN]&&a.push("video"));var o,l;0===a.length&&this.warn(_d(o=_d(l="Fragments must have at least one ElementaryStreamType set. type: ".concat(i.type," level: ")).call(l,i.level," sn: ")).call(o,i.sn));this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;r.hls.trigger(fO.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})}),a)}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var e,t=this;return this.sourceBufferCount>0&&!KT(e=this.sourceBuffers).call(e,(function(e){var r,i,n=fD(e,1)[0];return n&&(!(null!=(r=t.tracks[n])&&r.ended)||(null==(i=t.tracks[n])?void 0:i.ending))}))}},{key:"onBufferEos",value:function(e,t){var r,i,n,a=this;vd(r=this.sourceBuffers).call(r,(function(e){var r=fD(e,1)[0];if(r){var i=a.tracks[r];t.type&&t.type!==r||(i.ending=!0,i.ended||(i.ended=!0,a.log("".concat(r," buffer reached EOS"))))}}));var s=!1!==(null==(n=this.overrides)?void 0:n.endOfStream);this.sourceBufferCount>0&&!KT(i=this.sourceBuffers).call(i,(function(e){var t,r=fD(e,1)[0];return r&&!(null!=(t=a.tracks[r])&&t.ended)}))&&(this.log("Queueing EOS"),this.blockUntilOpen((function(){var e;if(vd(e=a.sourceBuffers).call(e,(function(e){var t=fD(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(fO.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===dO.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;lO(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(lO(s)&&s>=0){var o=Math.max(s,a),l=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,l)}if(lO(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var u=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),c=Math.max(u,a),h=Math.floor(n/a)*a+c;this.flushFrontBuffer(n,a,h)}}}},{key:"flushBackBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=fD(i,2),s=a[0],o=a[1];if(o){var l=qN.getBuffered(o);if(l.length>0&&r>l.start(0)){var u;n.hls.trigger(fO.BACK_BUFFER_REACHED,{bufferEnd:r});var c=n.tracks[s];if(null!=(u=n.details)&&u.live)n.hls.trigger(fO.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(fO.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}},{key:"flushFrontBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=fD(i,2),s=a[0],o=a[1];if(o){var l=qN.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(fO.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>(lO(r.duration)?r.duration:0)&&i>s||!lO(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&&(lO(i)&&this.log("Updating MediaSource duration to ".concat(i.toFixed(3))),s.duration=i),void 0!==n&&void 0!==a&&(this.log(_d(t=_d(r="MediaSource duration is set to ".concat(s.duration,". Setting seekable range to ")).call(r,n,"-")).call(t,a,".")),s.setLiveSeekableRange(n,a)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e,t,r=this.bufferCodecEventsTotal,i=this.pendingTrackCount,n=this.tracks;if(this.log(_d(e=_d(t="checkPendingTracks (pending: ".concat(i," codec events expected: ")).call(t,r,") ")).call(e,jI(n))),this.tracksReady){var a,s=null==(a=this.transferData)?void 0:a.tracks;s&&gv(s).length?this.attachTransferred():(this.createSourceBuffers(),this.bufferCreated())}}},{key:"bufferCreated",value:function(){var e=this;if(this.sourceBufferCount){var t,r,i={};vd(t=this.sourceBuffers).call(t,(function(t){var r=fD(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(fO.BUFFER_CREATED,{tracks:i}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),vd(r=this.sourceBuffers).call(r,(function(t){var r=fD(t,1)[0];e.executeNext(r)}))}else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,r=this.mediaSource;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(var i in e){var n=i,a=e[n];if(this.isPending(a)){var s,o,l,u=this.getTrackCodec(a,n),c=_d(s="".concat(a.container,";codecs=")).call(s,u);a.codec=u,this.log(_d(o=_d(l="creating sourceBuffer(".concat(c,")")).call(l,this.currentOp(n)?" Queued":""," ")).call(o,jI(a)));try{var h=r.addSourceBuffer(c),d=gK(n),f=[n,h];t[d]=f,a.buffer=h}catch(JV){this.error("error while trying to add sourceBuffer: ".concat(JV.message)),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:JV,sourceBufferName:n,mimeType:c});break}this.trackSourceBuffer(n,a)}}}},{key:"getTrackCodec",value:function(e,t){var r=YO(e.codec,e.levelCodec);return r?"audio"===Fv(t).call(t,0,5)?jO(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(fO.BUFFER_FLUSHED,{type:e})}))}}},{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var r,i,n=new Error(_d(r="".concat(e," SourceBuffer error. MediaSource readyState: ")).call(r,null==(i=this.mediaSource)?void 0:i.readyState));this.error("".concat(n),t),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"removeExecutor",value:function(e,t,r){var i=this.media,n=this.mediaSource,a=this.tracks[e],s=null==a?void 0:a.buffer;if(!i||!n||!s)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var o,l,u=lO(i.duration)?i.duration:1/0,c=lO(n.duration)?n.duration:1/0,h=Math.max(0,t),d=Math.min(r,u,c);d>h&&(!a.ending||a.ended)?(a.ended=!1,this.log(_d(o=_d(l="Removing [".concat(h,",")).call(l,d,"] from the ")).call(o,e," SourceBuffer")),s.remove(h,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new dK("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));r.ending=!1,r.ended=!1,i.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()}},{key:"isUpdating",value:function(){var e;return KT(e=this.sourceBuffers).call(e,(function(e){var t=fD(e,2),r=t[0],i=t[1];return r&&i.updating}))}},{key:"isQueued",value:function(){var e,t=this;return KT(e=this.sourceBuffers).call(e,(function(e){var r=fD(e,1)[0];return r&&!!t.currentOp(r)}))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.sourceBufferTypes;if(!r.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void tk.resolve().then(e);var i=this.operationQueue,n=_k(r).call(r,(function(e){return t.appendBlocker(e)}));r.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),tk.all(n).then((function(n){i===t.operationQueue&&(e(),t.stepOperationQueue(r))}))}},{key:"stepOperationQueue",value:function(e){var t=this;vd(e).call(e,(function(e){var r,i=null==(r=t.tracks[e])?void 0:r.buffer;i&&!i.updating&&t.shiftAndExecuteNext(e)}))}},{key:"append",value:function(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){var e,t=this;return kC(e=gv(this.tracks)).call(e,(function(e,r){return e+(t.isPending(t.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){var e;return kC(e=this.sourceBuffers).call(e,(function(e,t){return e+(fD(t,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){var e,t;return xk(e=_k(t=this.sourceBuffers).call(t,(function(e){return fD(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=sT(r).call(r,this,e);i.listeners.push({event:t,listener:a}),n.addEventListener(t,a)}}}},{key:"removeBufferListeners",value:function(e){var t,r=this.tracks[e];if(r){var i=r.buffer;i&&(vd(t=r.listeners).call(t,(function(e){i.removeEventListener(e.event,e.listener)})),r.listeners.length=0)}}}]),i}(IO);function vK(e){var t,r=e.querySelectorAll("source");vd(t=Fv([]).call(r)).call(t,(function(t){e.removeChild(t)}))}function gK(e){return"audio"===e?1:0}var pK=function(){function e(r){t(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=r,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return Fc(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(fO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fO.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&&lO(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t,r,i,n,a=this.hls,s=this.getMaxLevel(e.length-1);if(s!==this.autoLevelCapping)a.logger.log(_d(t=_d(r=_d(i=_d(n="Setting autoLevelCapping to ".concat(s,": ")).call(n,e[s].height,"p@")).call(i,e[s].bitrate," for media ")).call(r,this.mediaWidth,"x")).call(t,this.mediaHeight));a.autoLevelCapping=s,a.autoLevelEnabled&&a.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=a.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=xk(i).call(i,(function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){var e;this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=lS(sT(e=this.detectPlayerSize).call(e,this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(t){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){var t=this.restrictedLevels;return!KT(t).call(t,(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(null==e||!e.length)return-1;for(var i,n,a=e.length-1,s=Math.max(t,r),o=0;o<e.length;o+=1){var l=e[o];if((l.width>=s||l.height>=s)&&(i=l,!(n=e[o+1])||i.width!==n.width||i.height!==n.height)){a=o;break}}return a}}]),e}(),mK={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},yK={DASH:"d",HLS:"h",SMOOTH:"s",OTHER:"o"},EK={OBJECT:"CMCD-Object",REQUEST:"CMCD-Request",SESSION:"CMCD-Session",STATUS:"CMCD-Status"},kK=(Lf(jM={},EK.OBJECT,["br","d","ot","tb"]),Lf(jM,EK.REQUEST,["bl","dl","mtp","nor","nrr","su"]),Lf(jM,EK.SESSION,["cid","pr","sf","sid","st","v"]),Lf(jM,EK.STATUS,["bs","rtp"]),jM),TK=Fc((function e(r,i){t(this,e),Pk(r)&&(r=_k(r).call(r,(function(t){return t instanceof e?t:new e(t)}))),this.value=r,this.params=i})),SK="Dict";function AK(e,t,r,i){var n,a,s;return new Error(_d(n=_d(a="failed to ".concat(e,' "')).call(a,(s=t,Pk(s)?jI(s):s instanceof rP?"Map{}":s instanceof YM?"Set{}":"object"===Cc(s)?jI(s):String(s)),'" as ')).call(n,r),{cause:i})}function LK(e,t,r){return AK("serialize",e,t,r)}var bK=Fc((function e(r){t(this,e),this.description=r})),RK="Bare Item",IK="Boolean";var DK="Byte Sequence";function _K(e){if(!1===ArrayBuffer.isView(e))throw LK(e,DK);return":".concat((t=e,btoa(String.fromCharCode.apply(String,dD(t)))),":");var t}var wK="Integer";function CK(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw LK(e,wK);return e.toString()}var PK="Decimal";function xK(e){var t=KB(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw LK(e,PK);var r=t.toString();return uD(r).call(r,".")?r:"".concat(r,".0")}var MK="String",OK=/[\x00-\x1f\x7f]+/;var FK="Token";function NK(e){var t,r,i=(t=e).description||Fv(r=t.toString()).call(r,7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw LK(i,FK);return i}function UK(e){switch(Cc(e)){case"number":if(!lO(e))throw LK(e,RK);return zI(e)?CK(e):xK(e);case"string":return function(e){if(OK.test(e))throw LK(e,MK);return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(e);case"symbol":return NK(e);case"boolean":return function(e){if("boolean"!=typeof e)throw LK(e,IK);return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return"@".concat(CK(e.getTime()/1e3))}(e);if(e instanceof Uint8Array)return _K(e);if(e instanceof bK)return NK(e);default:throw LK(e,RK)}}var BK="Key";function GK(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw LK(e,BK);return e}function KK(e){var t;return null==e?"":_k(t=GI(e)).call(t,(function(e){var t,r=fD(e,2),i=r[0],n=r[1];return!0===n?";".concat(GK(i)):_d(t=";".concat(GK(i),"=")).call(t,UK(n))})).join("")}function HK(e){var t;return e instanceof TK?_d(t="".concat(UK(e.value))).call(t,KK(e.params)):UK(e)}function VK(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!==Cc(e))throw LK(e,SK);var i=e instanceof rP?ZM(e).call(e):GI(e),n=(null==r?void 0:r.whitespace)?" ":"";return _k(t=LT(i)).call(t,(function(e){var t=fD(e,2),r=t[0],i=t[1];i instanceof TK==!1&&(i=new TK(i));var n,a,s,o=GK(r);return!0===i.value?o+=KK(i.params):(o+="=",Pk(i.value)?o+=_d(a="(".concat(_k(s=(n=i).value).call(s,HK).join(" "),")")).call(a,KK(n.params)):o+=HK(i)),o})).join(",".concat(n))}var jK=function(e){return Math.round(e)},YK=function(e){return 100*jK(e/100)},qK={br:jK,d:jK,bl:YK,dl:YK,mtp:YK,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=function(e,t){var r,i,n=new gI(e),a=new gI(t);if(n.origin!==a.origin)return e;for(var s=Fv(r=n.pathname.split("/")).call(r,1),o=Fv(i=a.pathname.split("/")).call(i,1,-1);s[0]===o[0];)s.shift(),o.shift();for(;o.length;)o.shift(),s.unshift("..");return s.join("/")}(e,t.baseUrl)),encodeURIComponent(e)},rtp:YK,tb:jK};function WK(e,t){var r,i={};if(null==e||"object"!==Cc(e))return i;var n=mA(r=gv(e)).call(r),a=LO({},qK,null==t?void 0:t.formatters),s=null==t?void 0:xk(t);return vd(n).call(n,(function(r){if(!(null==s?void 0:s(r))){var n=e[r],o=a[r];o&&(n=o(n,t)),"v"===r&&1===n||"pr"==r&&1===n||function(e){return"number"==typeof e?lO(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return"ot"===e||"sf"===e||"st"===e}(r)&&"string"==typeof n&&(n=new bK(n)),i[r]=n)}})),i}function zK(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?function(e,t){return VK(e,t)}(WK(e,t),LO({whitespace:!1},t)):""}function XK(e,t,r){return LO(e,function(e){var t,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={};if(!e)return n;var a=GI(e),s=_d(t=GI(kK)).call(t,GI((null==i?void 0:i.customHeaderMap)||{})),o=kC(a).call(a,(function(e,t){var r,i,n=fD(t,2),a=n[0],o=n[1],l=(null===(r=vv(s).call(s,(function(e){var t;return uD(t=e[1]).call(t,a)})))||void 0===r?void 0:r[0])||EK.REQUEST;return null!==(i=e[l])&&void 0!==i||(e[l]={}),e[l][a]=o,e}),{});return kC(r=GI(o)).call(r,(function(e,t){var r=fD(t,2),n=r[0],a=r[1];return e[n]=zK(a,i),e}),n)}(t,r))}var QK="CMCD";var $K=/CMCD=[^&#]+/;function JK(e,t,r){var i,n,a=function(e){if(!e)return"";var t=zK(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return"".concat(QK,"=").concat(encodeURIComponent(t))}(t,r);if(!a)return e;if($K.test(e))return e.replace($K,a);var s=uD(e).call(e,"?")?"&":"?";return _d(i=_d(n="".concat(e)).call(n,s)).call(i,a)}var ZK=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(e){try{i.apply(e,{ot:mK.MANIFEST,su:!i.initialized})}catch(JV){i.hls.logger.warn("Could not generate manifest CMCD data.",JV)}},this.applyFragmentData=function(e){try{var t=e.frag,r=e.part,n=i.hls.levels[t.level],a=i.getObjectType(t),s={d:1e3*(r||t).duration,ot:a};a!==mK.VIDEO&&a!==mK.AUDIO&&a!=mK.MUXED||(s.br=n.bitrate/1e3,s.tb=i.getTopBandwidth(a)/1e3,s.bl=i.getBufferLength(a));var o=r?i.getNextPart(r):i.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),i.apply(e,s)}catch(JV){i.hls.logger.warn("Could not generate segment CMCD data.",JV)}},this.hls=r;var n=this.config=r.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||r.sessionId,this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.includeKeys=a.includeKeys,this.registerListeners())}return Fc(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHED,this.onMediaDetached,this),e.on(fO.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHED,this.onMediaDetached,this),e.off(fO.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:yK.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};LO(t,this.createData());var r=t.ot===mK.INIT||t.ot===mK.VIDEO||t.ot===mK.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var i,n=this.includeKeys;n&&(t=kC(i=gv(t)).call(i,(function(e,r){return uD(n).call(n,r)&&(e[r]=t[r]),e}),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),XK(e.headers,t,a)):e.url=JK(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){var i=e.sn-r.startSN;return r.fragments[i+1]}}},{key:"getNextPart",value:function(e){var t,r,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(r=t.details)?void 0:r.partList;if(a)for(var s=n.sn,o=a.length-1;o>=0;o--){var l=a[o];if(l.index===i&&l.fragment.sn===s)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?mK.TIMED_TEXT:"initSegment"===e.sn?mK.INIT:"audio"===t?mK.AUDIO:"main"===t?this.hls.audioTracks.length?mK.VIDEO:mK.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,i=this.hls;if(e===mK.AUDIO)t=i.audioTracks;else{var n,a=i.maxAutoLevel,s=a>-1?a+1:i.levels.length;t=Fv(n=i.levels).call(n,0,s)}var o,l=function(e,t){var r=void 0!==hc&&$k(e)||e["@@iterator"];if(!r){if(Ck(e)||(r=hD(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(ZV){l.e(ZV)}finally{l.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===mK.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*qN.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,r=this.applyPlaylistData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,r=this.applyFragmentData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}}]),e}(),eH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"content-steering",e.logger)).hls=void 0,n.loader=null,n.uri=null,n.pathwayId=".",n._pathwayPriority=null,n.timeToLoad=300,n.reloadTimer=-1,n.updated=0,n.started=!1,n.enabled=!0,n.levels=null,n.audioTracks=null,n.subtitleTracks=null,n.penalizedPathways={},n.hls=e,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.ERROR,this.onError,this))}},{key:"pathways",value:function(){var e;return kC(e=this.levels||[]).call(e,(function(e,t){return-1===av(e).call(e,t.pathwayId)&&e.push(t.pathwayId),e}),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=xk(t).call(t,(function(t){return t!==e})))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===IF&&wC(r)===CF){var i,n,a,s,o,l=this.levels,u=this._pathwayPriority,c=this.pathwayId;if(t.context){var h=t.context,d=h.groupId,f=h.pathwayId,v=h.type;d&&l?c=this.getPathwayForGroupId(d,v,c):f&&(c=f)}if(c in this.penalizedPathways||(this.penalizedPathways[c]=performance.now()),!u&&l&&(u=this.pathways()),u&&u.length>1&&(this.updatePathwayPriority(u),r.resolved=this.pathwayId!==c),!r.resolved)this.warn(_d(i=_d(n=_d(a=_d(s=_d(o="Could not resolve ".concat(t.details,' ("')).call(o,t.error.message,'") with content-steering for Pathway: ')).call(s,c," levels: ")).call(a,l?l.length:l," priorities: ")).call(n,jI(u)," penalized: ")).call(i,jI(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t,r,i=this.getLevelsForPathway(this.pathwayId);if(0===i.length){var n,a=e[0].pathwayId;this.log(_d(n="No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "')).call(n,a,'"')),i=this.getLevelsForPathway(a),this.pathwayId=a}i.length!==e.length&&this.log(_d(t=_d(r="Found ".concat(i.length,"/")).call(r,e.length,' levels in Pathway "')).call(t,this.pathwayId,'"'));return i}},{key:"getLevelsForPathway",value:function(e){var t;return null===this.levels?[]:xk(t=this.levels).call(t,(function(t){return e===t.pathwayId}))}},{key:"updatePathwayPriority",value:function(e){var t,r;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();vd(t=gv(i)).call(t,(function(e){n-i[e]>3e5&&delete i[e]}));for(var a=0;a<e.length;a++){var s=e[a];if(!(s in i)){if(s===this.pathwayId)return;var o=this.hls.nextLoadLevel,l=this.hls.levels[o];if((r=this.getLevelsForPathway(s)).length>0){this.log('Setting Pathway to "'.concat(s,'"')),this.pathwayId=s,rB(r),this.hls.trigger(fO.LEVELS_UPDATED,{levels:r});var u=this.hls.levels[o];if(l&&u&&this.levels){var c;if(u.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==l.bitrate)this.log(_d(c="Unstable Pathways change from bitrate ".concat(l.bitrate," to ")).call(c,u.bitrate));this.hls.nextLoadLevel=o}break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var i,n=_d(i=this.getLevelsForPathway(r)).call(i,this.levels||[]),a=0;a<n.length;a++)if(t===pO&&n[a].hasAudioGroup(e)||t===mO&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return r}},{key:"clonePathways",value:function(e){var t=this,r=this.levels;if(r){var i={},n={};vd(e).call(e,(function(e){var a,s=e.ID,o=e["BASE-ID"],l=e["URI-REPLACEMENT"];if(!KT(r).call(r,(function(e){return e.pathwayId===s}))){var u=_k(a=t.getLevelsForPathway(o)).call(a,(function(e){var t,r,a=new eU(e.attrs);a["PATHWAY-ID"]=s;var o=a.AUDIO&&_d(t="".concat(a.AUDIO,"_clone_")).call(t,s),u=a.SUBTITLES&&_d(r="".concat(a.SUBTITLES,"_clone_")).call(r,s);o&&(i[a.AUDIO]=o,a.AUDIO=o),u&&(n[a.SUBTITLES]=u,a.SUBTITLES=u);var c=rH(e.uri,a["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),h=new nF({attrs:a,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:c,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++){var f;h.addGroupId("audio",_d(f="".concat(e.audioGroups[d],"_clone_")).call(f,s))}if(e.subtitleGroups)for(var v=1;v<e.subtitleGroups.length;v++){var g;h.addGroupId("text",_d(g="".concat(e.subtitleGroups[v],"_clone_")).call(g,s))}return h}));r.push.apply(r,dD(u)),tH(t.audioTracks,i,l,s),tH(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 gI(e)}catch(JV){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 gI(o,t).href}catch(JV){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(fO.STEERING_MANIFEST_LOADED,c),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION ".concat(s.VERSION," not supported!"))},onError:function(e,t,i,n){var a,s;if(r.log(_d(a=_d(s="Error loading steering manifest: ".concat(e.code," ")).call(s,e.text," (")).call(a,t.url,")")),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest ".concat(t.url," no longer available"));var o=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,o);else{var l=r.loader;if("function"==typeof(null==l?void 0:l.getResponseHeader)){var u=l.getResponseHeader("Retry-After");u&&(o=1e3*bS(u))}r.log("Steering manifest ".concat(t.url," rate limited"))}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest (".concat(t.url,")")),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: ".concat(t)),this.loader.load(s,u,c)}},{key:"scheduleRefresh",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3*this.timeToLoad;this.clearTimeout(),this.reloadTimer=Wf((function(){var r,i=null==(r=t.hls)?void 0:r.media;!i||i.ended?t.scheduleRefresh(e,1e3*t.timeToLoad):t.loadSteeringManifest(e)}),r)}}]),i}(IO);function tH(e,t,r,i){var n;e&&vd(n=gv(t)).call(n,(function(n){var a,s=_k(a=xk(e).call(e,(function(e){return e.groupId===n}))).call(a,(function(e){var a=LO({},e);return a.details=void 0,a.attrs=new eU(a.attrs),a.url=a.attrs.URI=rH(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,dD(s))}))}function rH(e,t,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];t&&(n=null==o?void 0:o[t])&&(e=n);var l,u,c=new gI(e);(a&&!n&&(c.host=a),s)&&vd(l=mA(u=gv(s)).call(u)).call(l,(function(e){e&&c.searchParams.set(e,s[e])}));return c.href}var iH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"eme",e.logger)).hls=void 0,n.config=void 0,n.media=null,n.keyFormatPromise=null,n.keySystemAccessPromises={},n._requestLicenseFailureCount=0,n.mediaKeySessions=[],n.keyIdToKeySessionPromise={},n.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],n.onMediaEncrypted=function(e){var t,r=e.initDataType,i=e.initData,a=_d(t='"'.concat(e.type,'" event: init data type: "')).call(t,r,'"');if(n.debug(a),null!==i){var s,o;if("sinf"===r&&n.getLicenseServerUrl(hU)){var l=gN(new Uint8Array(i));try{var u=DN(sU(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=hU}catch(JV){var c;return void n.warn(_d(c="".concat(a," Failed to parse sinf: ")).call(c,JV))}}else if(n.getLicenseServerUrl(fU)){var h=function(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,i=0;i+32<r;){var n=FN(new DataView(e,i));t.push(n),i+=n.size}return t}(i),d=gv(n.keySystemAccessPromises);d.length||(d=bU(n.config));var f=xk(h).call(h,(function(e){var t=e.systemId?AU(e.systemId):null;return!!t&&av(d).call(d,t)>-1}))[0];if(!f){var v;if(0===h.length||KT(h).call(h,(function(e){return!e.systemId})))n.warn("".concat(a," contains incomplete or invalid pssh data"));else n.log(_d(v="ignoring ".concat(a," for ")).call(v,_k(h).call(h,(function(e){return AU(e.systemId)})).join(",")," pssh data in favor of playlist keys"));return}if(o=AU(f.systemId),0===f.version&&f.data)if(o===fU){var g=f.data.length-22;s=f.data.subarray(g,g+16)}else o===dU&&(s=wU(f.data))}if(o&&s){for(var p=XF.hexDump(s),m=Zh(n),y=m.keyIdToKeySessionPromise,E=m.mediaKeySessions,k=y[p],T=function(){var e,t=E[S],a=t.decryptdata;if(!a.keyId)return"continue";var o=XF.hexDump(a.keyId);return p===o||-1!==av(e=a.uri.replace(/-/g,"")).call(e,p)?(k=y[o],a.pssh||(delete y[o],a.pssh=new Uint8Array(i),a.keyId=s,(k=y[p]=k.then((function(){return n.generateRequestWithPreferredKeySession(t,r,i,"encrypted-event-key-match")}))).catch((function(e){return n.handleError(e)}))),"break"):void 0},S=0;S<E.length;S++){var A=T();if("continue"!==A&&"break"===A)break}k||(k=y[p]=n.getKeySystemSelectionPromise([o]).then((function(e){var t,a=e.keySystem,o=e.mediaKeys;n.throwIfDestroyed();var l=new PU("ISO-23001-7",p,null!=(t=LU(a))?t:"");return l.pssh=new Uint8Array(i),l.keyId=s,n.attemptSetMediaKeys(a,o).then((function(){n.throwIfDestroyed();var e=n.createMediaKeySessionContext({decryptdata:l,keySystem:a,mediaKeys:o});return n.generateRequestWithPreferredKeySession(e,r,i,"encrypted-event-no-match")}))}))).catch((function(e){return n.handleError(e)}))}}},n.onWaitingForKey=function(e){n.log('"'.concat(e.type,'" event'))},n.hls=e,n.config=e.config,n.registerListeners(),n}return Fc(i,[{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(fO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(fO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(fO.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===fU&&i?i:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error('no license server URL configured for key-system "'.concat(e,'"'));return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'.concat(e,'"]'))}},{key:"attemptKeySystemAccess",value:function(e){var t,r,i=this,n=this.hls.levels,a=function(e,t,r){return!!e&&av(r).call(r,e)===t},s=xk(t=_k(n).call(n,(function(e){return e.audioCodec}))).call(t,a),o=xk(r=_k(n).call(n,(function(e){return e.videoCodec}))).call(r,a);return s.length+o.length===0&&o.push("avc1.42e01e"),new tk((function(t,r){!function e(n){var a=n.shift();i.getMediaKeysPromise(a,s,o).then((function(e){return t({keySystem:a,mediaKeys:e})})).catch((function(t){n.length?e(n):r(t instanceof nH?t:new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.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===DU&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),tk.reject(new Error(i))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var i=this,n=_U(e,t,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e],s=null==a?void 0:a.keySystemAccess;if(!s){var o;this.log(_d(o='Requesting encrypted media "'.concat(e,'" key-system access with config: ')).call(o,jI(n))),s=this.requestMediaKeySystemAccess(e,n);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){var r;i.log(_d(r='Failed to obtain access to key-system "'.concat(e,'": ')).call(r,t))})),s.then((function(t){i.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=i.fetchServerCertificate(e);return i.log('Create media-keys for "'.concat(e,'"')),l.mediaKeys=t.createMediaKeys().then((function(t){return i.log('Media-keys created for "'.concat(e,'"')),r.then((function(r){return r?i.setMediaKeysServerCertificate(t,e,r):t}))})),l.mediaKeys.catch((function(t){var r;i.error(_d(r='Failed to create media-keys for "'.concat(e,'"}: ')).call(r,t))})),l.mediaKeys}))}return s.then((function(){return a.mediaKeys}))}},{key:"createMediaKeySessionContext",value:function(e){var t,r=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log(_d(t='Creating key-system session "'.concat(i,'" keyId: ')).call(t,XF.hexDump(r.keyId||[])));var a=n.createSession(),s={decryptdata:r,keySystem:i,mediaKeys:n,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"getKeyIdString",value:function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return XF.hexDump(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,i,n,a=e.mediaKeysSession;return this.log(_d(r=_d(i='Updating key-session "'.concat(a.sessionId,'" for keyID ')).call(i,XF.hexDump((null==(n=e.decryptdata)?void 0:n.keyId)||[]),"\n } (data length: ")).call(r,t?t.byteLength:t,")")),a.update(t)}},{key:"selectKeySystemFormat",value:function(e){var t,r,i,n=gv(e.levelkeys||{});this.keyFormatPromise||(this.log(_d(t=_d(r=_d(i="Selecting key-system from fragment (sn: ".concat(e.sn," ")).call(i,e.type,": ")).call(r,e.level,") key formats ")).call(t,n.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(n));return this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new tk((function(r,i){var n,a=bU(t.config),s=xk(n=_k(e).call(e,yU)).call(n,(function(e){return!!e&&-1!==av(a).call(a,e)}));return t.getKeySystemSelectionPromise(s).then((function(e){var t=e.keySystem,n=LU(t);n?r(n):i(new Error('Unable to find format for key-system "'.concat(t,'"')))})).catch(i)}))}},{key:"loadKey",value:function(e){var t,r,i,n=this,a=e.keyInfo.decryptdata,s=this.getKeyIdString(a),o=_d(t=_d(r=_d(i="(keyId: ".concat(s,' format: "')).call(i,a.keyFormat,'" method: ')).call(r,a.method," uri: ")).call(t,a.uri,")");this.log("Starting session for key ".concat(o));var l=this.keyIdToKeySessionPromise[s];l||(l=this.getKeySystemForKeyPromise(a).then((function(t){var r,i,s,l=t.keySystem,u=t.mediaKeys;return n.throwIfDestroyed(),n.log(_d(r=_d(i=_d(s="Handle encrypted media sn: ".concat(e.frag.sn," ")).call(s,e.frag.type,": ")).call(i,e.frag.level," using key ")).call(r,o)),n.attemptSetMediaKeys(l,u).then((function(){return n.throwIfDestroyed(),n.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:a})}))})),(this.keyIdToKeySessionPromise[s]=l.then((function(e){var t=a.pssh?a.pssh.buffer:null;return n.generateRequestWithPreferredKeySession(e,"cenc",t,"playlist-key")}))).catch((function(e){return n.handleError(e)})));return l}},{key:"throwIfDestroyed",value:function(){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e){this.hls&&(this.error(e.message),e instanceof nH?this.hls.trigger(fO.ERROR,e.data):this.hls.trigger(fO.ERROR,{type:hO.KEY_SYSTEM_ERROR,details:dO.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=yU(e.keyFormat),n=i?[i]:bU(this.config);return this.attemptKeySystemAccess(n)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=bU(this.config)),0===e.length)throw new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(jI({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r,i=this,n=Fv(r=this.setMediaKeysQueue).call(r);this.log('Setting media-keys for "'.concat(e,'"'));var a=tk.all(n).then((function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(a),a.then((function(){var t;i.log('Media-keys set for "'.concat(e,'"')),n.push(a),i.setMediaKeysQueue=xk(t=i.setMediaKeysQueue).call(t,(function(e){return-1===av(n).call(n,e)}))}))}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,r,i){var n,a,s,o,l,u=this,c=null==(o=this.config.drmSystems)||null==(l=o[e.keySystem])?void 0:l.generateRequest;if(c)try{var h=c.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=h.initData?h.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(JV){var d;if(this.warn(JV.message),null!=(d=this.hls)&&d.config.debug)throw JV}if(null===r)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),tk.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log(_d(n=_d(a=_d(s='Generating key-session request for "'.concat(i,'": ')).call(s,f," (init data type: ")).call(a,t," length: ")).call(n,r?r.byteLength:null,")"));var v=new LB,g=e._onmessage=function(t){var r,i,n=e.mediaKeysSession;if(n){var a=t.messageType,s=t.message;u.log(_d(r=_d(i='"'.concat(a,'" message event for session "')).call(i,n.sessionId,'" message size: ')).call(r,s.byteLength)),"license-request"===a||"license-renewal"===a?u.renewLicense(e,s).catch((function(e){v.eventNames().length?v.emit("error",e):u.handleError(e)})):"license-release"===a?e.keySystem===hU&&(u.updateKeySession(e,oU("acknowledged")),u.removeSession(e)):u.warn('unhandled media key message type "'.concat(a,'"'))}else v.emit("error",new Error("invalid state"))},p=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){u.onKeyStatusChange(e);var r,i=e.keyStatus;if(v.emit("keyStatus",i),"expired"===i)u.warn(_d(r="".concat(e.keySystem," expired for key ")).call(r,f)),u.renewKeySession(e)}else v.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",g),e.mediaKeysSession.addEventListener("keystatuseschange",p);var m=new tk((function(e,t){v.on("error",t),v.on("keyStatus",(function(r){UI(r).call(r,"usable")?e():"output-restricted"===r?t(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(r,'"'))):"expired"===r?t(new Error("key expired while generating request")):u.warn('unhandled key status change "'.concat(r,'"'))}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t,r;u.log(_d(t='Request generated for key-session "'.concat(null==(r=e.mediaKeysSession)?void 0:r.sessionId,'" keyId: ')).call(t,f))})).catch((function(e){throw new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: ".concat(e))})).then((function(){return m})).catch((function(t){throw v.removeAllListeners(),u.removeSession(e),t})).then((function(){return v.removeAllListeners(),e}))}},{key:"onKeyStatusChange",value:function(e){var t,r=this;vd(t=e.mediaKeysSession.keyStatuses).call(t,(function(t,i){var n,a,s;r.log(_d(n=_d(a=_d(s='key status change "'.concat(t,'" for keyStatuses keyId: ')).call(s,XF.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))," session keyId: ")).call(a,XF.hexDump(new Uint8Array(e.decryptdata.keyId||[]))," uri: ")).call(n,e.decryptdata.uri)),e.keyStatus=t}))}},{key:"fetchServerCertificate",value:function(e){var t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching server certificate for "'.concat(e,'"')),new tk((function(n,a){var s={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:function(e,t,r,i){n(e.data)},onError:function(t,r,n,o){var l,u,c;a(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:RO({url:s.url,data:void 0},t)},_d(l=_d(u=_d(c='"'.concat(e,'" certificate request failed (')).call(c,i,"). Status: ")).call(u,t.code," (")).call(l,t.text,")")))},onTimeout:function(t,r,n){var o;a(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:s.url,data:void 0}},_d(o='"'.concat(e,'" certificate request timed out (')).call(o,i,")")))},onAbort:function(e,t,r){a(new Error("aborted"))}};r.load(s,l,u)}))):tk.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var i=this;return new tk((function(n,a){e.setServerCertificate(r).then((function(a){var s,o;i.log(_d(s=_d(o="setServerCertificate ".concat(a?"success":"not supported by CDM"," (")).call(o,null==r?void 0:r.byteLength,') on "')).call(s,t,'"')),n(e)})).catch((function(e){a(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.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 nH({type:hO.KEY_SYSTEM_ERROR,details:dO.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(!uD(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 oU(atob(f))}},{key:"setupLicenseXHR",value:function(e,t,r,i){var n=this,a=this.config.licenseXhrSetup;return a?tk.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return a.call(n.hls,e,t,r,i)})).catch((function(s){if(!r.decryptdata)throw s;return e.open("POST",t,!0),a.call(n.hls,e,t,r,i)})).then((function(r){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||i}})):(e.open("POST",t,!0),tk.resolve({xhr:e,licenseChallenge:i}))}},{key:"requestLicense",value:function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new tk((function(n,a){var s=r.getLicenseServerUrlOrThrow(e.keySystem);r.log("Sending license request to URL: ".concat(s));var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received ".concat(l instanceof ArrayBuffer?l.byteLength:l));var u=r.config.licenseResponseCallback;if(u)try{l=u.call(r.hls,o,s,e)}catch(JV){r.error(JV)}n(l)}else{var c=i.errorRetry,h=c?c.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>h||o.status>=400&&o.status<500){var d,f;a(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},_d(d=_d(f="License Request XHR failed (".concat(s,"). Status: ")).call(f,o.status," (")).call(d,o.statusText,")")))}else{var v=h-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(v," attempts left")),r.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,t).then((function(t){var i=t.xhr,n=t.licenseChallenge;e.keySystem==dU&&(n=r.unpackPlayReadyKeyMessage(i,n)),i.send(n)}))}))}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}}},{key:"onMediaDetached",value:function(){var e,t,r=this,n=this.media,a=this.mediaKeySessions;n&&(n.removeEventListener("encrypted",this.onMediaEncrypted),n.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},PU.clearKeyUriToKeyIdMap();var s=a.length;i.CDMCleanupPromise=tk.all(_d(e=_k(a).call(a,(function(e){return r.removeSession(e)}))).call(e,null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch((function(e){var t;r.log("Could not clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){s&&(r.log("finished closing key sessions and clearing media keys"),a.length=0)})).catch((function(e){var t;r.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.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=kC(r).call(r,(function(e,t){return-1===av(e).call(e,t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys ".concat(i.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){var n;this.log("Remove licenses and keys and close session ".concat(r.sessionId)),e._onmessage&&(r.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a,s=av(n=this.mediaKeySessions).call(n,e);if(s>-1)ig(a=this.mediaKeySessions).call(a,s,1);return r.remove().catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.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(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),i}(IO);iH.CDMCleanupPromise=void 0;var nH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n)).data=void 0,e.error||(e.error=new Error(n)),a.data=e,e.err=e.error,a}return Fc(i)}(tC(Error)),aH=function(){function e(r){t(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=r,this.registerListeners()}return Fc(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i,n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=lS(sT(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(fO.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(fO.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}]),e}();function sH(e,t){var r;try{r=new Event("addtrack")}catch(ZV){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function oH(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(ZV){xO.debug("[texttrack-utils]: ".concat(ZV));try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(n){xO.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(n))}}"disabled"===r&&(e.mode=r)}function lH(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 uH(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;var i=0,n=r;for(;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}function cH(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}var hH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e,"subtitle-track-controller")).media=null,n.tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.queuedDefaultTrack=-1,n.useTextTrackPolling=!1,n.subtitlePollingInterval=-1,n._subtitleDisplay=!0,n.asyncPollTrackChange=function(){return n.pollTrackChange(0)},n.onTextTracksChanged=function(){if(n.useTextTrackPolling||self.clearInterval(n.subtitlePollingInterval),n.media&&n.hls.config.renderTextTracksNatively){for(var e=null,t=cH(n.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}var i=n.findTrackForTextTrack(e);n.subtitleTrack!==i&&n.setSubtitleTrack(i)}},n.registerListeners(),n}return Fc(i,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVEL_LOADING,this.onLevelLoading,this),e.off(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(fO.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=lS(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;if(r){var i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!i){var n=cH(r.textTracks);vd(n).call(n,(function(e){lH(e)}))}}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Subtitle track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Subtitle track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.subtitleGroups||null,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&KT(r).call(r,(function(e){return-1===(null==i?void 0:av(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=xk(a=this.tracks).call(a,(function(e){return!r||-1!==av(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!KT(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.subtitlePreference;if(!n&&l){this.selectDefaultTrack=!1;var u=cF(l,o);if(u>-1)n=o[u];else{var c=cF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={subtitleTracks:o};this.log(_d(s="Updating subtitle tracks, ".concat(o.length,' track(s) found in "')).call(s,null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(fO.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||hF(n,e)))return i}if(e){for(var a=0;a<t.length;a++){var s=t[a];if(nK(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return a}for(var o=0;o<t.length;o++){var l=t[o];if(nK(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(aK(t[r],e))return r}return-1}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==mO||t.context.id!==this.trackId||this.groupIds&&-1===av(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var r=this.currentTrack;if(r&&hF(e,r))return r;var i=cF(e,this.tracksInGroup);if(i>-1){var n=this.tracksInGroup[i];return this.setSubtitleTrack(i),n}if(r)return null;var a=cF(e,t);if(a>-1)return t[a]}}return null}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading subtitle ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(fO.SUBTITLE_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}},{key:"toggleTrackModes",value:function(){var e,t=this.media;if(t){var r,i,n=cH(t.textTracks),a=this.currentTrack;if(a)if(!(r=xk(n).call(n,(function(e){return aK(a,e)}))[0]))this.warn(_d(i='Unable to find subtitle TextTrack with name "'.concat(a.name,'" and language "')).call(i,a.lang,'"'));if(vd(e=Fv([]).call(n)).call(e,(function(e){"disabled"!==e.mode&&e!==r&&(e.mode="disabled")})),r){var s=this.subtitleDisplay?"showing":"hidden";r.mode!==s&&(r.mode=s)}}}},{key:"setSubtitleTrack",value:function(e){var t,r,i=this.tracksInGroup;if(this.media)if(e<-1||e>=i.length||!lO(e))this.warn("Invalid subtitle track id: ".concat(e));else{this.selectDefaultTrack=!1;var n=this.currentTrack,a=i[e]||null;if(this.trackId=e,this.currentTrack=a,this.toggleTrackModes(),a){var s=!!a.details&&!a.details.live;if(e!==this.trackId||a!==n||!s){this.log("Switching to subtitle-track ".concat(e)+(a?_d(t=_d(r=' "'.concat(a.name,'" lang:')).call(r,a.lang," group:")).call(t,a.groupId):""));var o=a.id,l=a.groupId,u=void 0===l?"":l,c=a.name,h=a.type,d=a.url;this.hls.trigger(fO.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(fO.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),i}(oK);function dH(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var fH=.02,vH=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function gH(e,t,r){var i,n;return _d(i=_d(n="".concat(e.identifier,"-")).call(n,r+1,"-")).call(i,dH(t))}var pH=function(){function e(r,i){t(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.base=i,this.dateRange=r,this.setDateRange(r)}return Fc(e,[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=this.error=void 0}},{key:"isAssetPastPlayoutLimit",value:function(e){if(e>=this.assetList.length)return!0;var t=this.playoutLimit;return!(e<=0||isNaN(t))&&this.assetList[e].startOffset>t}},{key:"findAssetIndex",value:function(e){var t;return av(t=this.assetList).call(t,e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return mH(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=lO(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 mH(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)<fH))},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"]?vH.Range:vH.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"toString",value:function(){return _d(t=_d(r=_d(i='["'.concat((e=this).identifier,'" ')).call(i,e.cue.pre?"<pre>":e.cue.post?"<post>":"")).call(r,e.timelineStart.toFixed(2),"-")).call(t,e.resumeTime.toFixed(2),"]");var e,t,r,i}}]),e}();function mH(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<fH)?t.start:t.start+t.duration}function yH(e,t,r){var i=new gI(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function EH(e){var t,r,i=e.timelineStart,n=e.duration||0;return _d(t=_d(r='["'.concat(e.identifier,'" ')).call(r,i.toFixed(2),"-")).call(t,(i+n).toFixed(2),"]")}var kH=function(){function e(r,i,n,a){var s=this;t(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this.playoutOffset=0,this.checkPlayout=function(){var e=s.interstitial.playoutLimit;s.playoutOffset+s.currentTime>=e&&s.hls.trigger(fO.PLAYOUT_LIMIT_REACHED,{})};var o=this.hls=new r(i);this.interstitial=n,this.assetItem=a;var l=a.uri;try{l=yH(l,o.sessionId).href}catch(JV){}o.loadSource(l);var u=function(){s.hasDetails=!0};o.once(fO.LEVEL_LOADED,u),o.once(fO.AUDIO_TRACK_LOADED,u),o.once(fO.SUBTITLE_TRACK_LOADED,u),o.on(fO.MEDIA_ATTACHING,(function(e,t){var r=t.media;s.removeMediaListeners(),s.mediaAttached=r;var i,n,o=s.interstitial;o.playoutLimit&&(s.playoutOffset=(null==(n=o.assetList[av(i=o.assetList).call(i,a)])?void 0:n.startOffset)||0,r.addEventListener("timeupdate",s.checkPlayout))}))}return Fc(e,[{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){return this.hls.media}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return 0;var t=qN.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):0}},{key:"duration",get:function(){var e,t=null==(e=this.assetItem)?void 0:e.duration;return t||0}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"timelineOffset",get:function(){return this.hls.config.timelineOffset||0},set:function(e){var t=this.timelineOffset;if(e!==t){var r=e-t;if(Math.abs(r)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&e.removeEventListener("timeupdate",this.checkPlayout)}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){this.hls.attachMedia(e)}},{key:"detachMedia",value:function(){this.removeMediaListeners(),this.hls.detachMedia()}},{key:"resumeBuffering",value:function(){this.hls.resumeBuffering()}},{key:"pauseBuffering",value:function(){this.hls.pauseBuffering()}},{key:"transferMedia",value:function(){return this.hls.transferMedia()}},{key:"on",value:function(e,t,r){this.hls.on(e,t)}},{key:"once",value:function(e,t,r){this.hls.once(e,t)}},{key:"off",value:function(e,t,r){this.hls.off(e,t)}},{key:"toString",value:function(){var e,t;return _d(e=_d(t="HlsAssetPlayer: ".concat(EH(this.assetItem)," ")).call(t,this.hls.sessionId," ")).call(e,this.interstitial.appendInPlace?"append-in-place":"")}}]),e}(),TH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,"interstitials-sched",n)).onScheduleUpdate=void 0,a.eventMap={},a.events=null,a.items=null,a.durations={primary:0,playout:0,integrated:0},a.onScheduleUpdate=e,a}return Fc(i,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){var e;(this.eventMap={},this.setDurations(0,0,0),this.events)&&vd(e=this.events).call(e,(function(e){return e.reset()}));this.events=this.items=null}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);var i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(n=i[r])&&n.event;){var n;r--}return r}},{key:"findItemIndexAtTime",value:function(e,t){var r=this.items;if(r)for(var i=0;i<r.length;i++){var n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return i}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var r=this.items;if(r)for(var i=e;i<=t&&r[i];i++){var n=r[i].event;if(null!=n&&n.restrictions.jump&&!n.appendInPlace)return i}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var r=t.length;r--;){var i;if((null==(i=t[r].event)?void 0:i.identifier)===e)return r}return-1}},{key:"findAssetIndex",value:function(e,t){var r=e.assetList,i=r.length;if(i>1)for(var n=0;n<i;n++){var a=r[n];if(!a.error){var s=a.timelineStart;if(t===s||t>s&&t<s+(a.duration||0))return n}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t,r=null==(e=this.items)||null==(t=e[this.length-1])?void 0:t.event;if(r){var i=r.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e){var t=this,r=e.main.details,i=r.dateRanges,n=this.events,a=this.parseDateRanges(i,{url:r.url}),s=gv(i),o=n?xk(n).call(n,(function(e){return!uD(s).call(s,e.identifier)})):[];a.length&&mA(a).call(a,(function(e,t){var r=e.cue.pre,i=e.cue.post,n=t.cue.pre,a=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!a)return 1;if(a&&!i)return-1;if(!(r||n||i||a)){var s=e.startTime,o=t.startTime;if(s!==o)return s-o}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=a,vd(o).call(o,(function(e){t.removeEvent(e)})),this.updateSchedule(e,o)}},{key:"updateSchedule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.events||[];if(r.length||t.length||this.length<2){var i=this.items,n=this.parseSchedule(r,e);(t.length||(null==i?void 0:i.length)!==n.length||KT(n).call(n,(function(e,t){return Math.abs(e.playout.start-i[t].playout.start)>.005||Math.abs(e.playout.end-i[t].playout.end)>.005})))&&(this.items=n,this.onScheduleUpdate(t,i))}}},{key:"parseDateRanges",value:function(e,t){for(var r=[],i=gv(e),n=0;n<i.length;n++){var a=i[n],s=e[a];if(s.isInterstitial){var o=this.eventMap[a];o?o.setDateRange(s):(o=new pH(s,t),this.eventMap[a]=o),r.push(o)}}return r}},{key:"parseSchedule",value:function(e,t){var r=[],i=t.main.details,n=i.live?1/0:i.edge,a=0;if((e=xk(e).call(e,(function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(vd(e).call(e,(function(t,i){var l=t.cue.pre,u=t.cue.post,c=e[i-1]||null,h=t.appendInPlace,d=u?n:t.startOffset,f=t.duration,v=t.timelineOccupancy===vH.Range?f:0,g=t.resumptionOffset,p=(null==c?void 0:c.startTime)===d,m=d+t.cumulativeDuration,y=h?m+f:d+g;if(l||!u&&d<=0){var E=o;o+=v,t.timelineStart=m;var k=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:k,end:a},integrated:{start:E,end:o}})}else{if(!(d<=n))return;if(!p){var T=d-s;if(T>.033){var S=s,A=o;o+=T;var L=a;a+=T;var b={previousEvent:e[i-1]||null,nextEvent:t,start:S,end:S+T,playout:{start:L,end:a},integrated:{start:A,end:o}};r.push(b)}else T>0&&c&&(c.cumulativeDuration+=T,r[r.length-1].end=d)}u&&(y=m),t.timelineStart=m;var R=o;o+=v;var I=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:I,end:a},integrated:{start:R,end:o}})}var D=t.resumeTime;s=u||D>n?n:D})),s<n){var l,u=s,c=o,h=n-s;o+=h;var d=a;a+=h,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:s,end:u+h,playout:{start:d,end:a},integrated:{start:c,end:o}})}this.setDurations(n,a,o)}else{r.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n)}return r}},{key:"setDurations",value:function(e,t,r){this.durations={primary:e,playout:t,integrated:r}}},{key:"resolveOffsets",value:function(e,t){var r=this,i=t.main.details,n=i.live?1/0:i.edge,a=0,s=-1;vd(e).call(e,(function(o,l){var u=o.cue.pre,c=o.cue.post,h=u?0:c?n:o.startTime;(r.updateAssetDurations(o),s===h?o.cumulativeDuration=a:(a=0,s=h),!c&&o.snapOptions.in&&(o.resumeAnchor=mF(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(r.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));if(!o.appendInPlace)for(var d=l-1;l--;){e[d+1].startTime-e[d].resumeTime<.033&&(e[d].appendInPlace=!1)}var f=lO(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)>fH?(this.log(_d(i=_d(n='"'.concat(e.identifier,'" resumption ')).call(n,o," not aligned with estimated timeline end ")).call(i,l)),!1):t?!KT(r=gv(t)).call(r,(function(r){var i,n,a,l=t[r].details,u=l.edge;if(o>u)return s.log(_d(i=_d(n=_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," past ")).call(n,r," playlist end ")).call(i,u)),!0;var c,h,d=mF(null,l.fragments,o);if(!d)return s.log(_d(c=_d(h='"'.concat(e.identifier,'" resumption ')).call(h,o," does not align with any fragments in ")).call(c,r," playlist")),!0;var f,v,g,p,m,y,E="audio"===r?.175:0;return!(Math.abs(d.start-o)<fH||Math.abs(d.end-o)<fH+E)&&(s.log(_d(f=_d(v=_d(g=_d(p=_d(m=_d(y='"'.concat(e.identifier,'" resumption ')).call(y,o," not aligned with ")).call(m,r," fragment bounds (")).call(p,d.start,"-")).call(g,d.end," sn: ")).call(v,d.sn," cc: ")).call(f,d.cc,")")),!0)})):(this.log(_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," can not be aligned with media (none selected)")),!1)}},{key:"updateAssetDurations",value:function(e){var t,r=e.timelineStart,i=0,n=!1,a=!1;vd(t=e.assetList).call(t,(function(e,t){var s=r+i;e.startOffset=i,e.timelineStart=s,n||(n=null===e.duration),a||(a=!!e.error);var o=e.error?0:e.duration||0;i+=o})),e.duration=n&&!a?Math.max(i,e.duration):i}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}]),i}(IO);function SH(e){var t,r;return _d(t=_d(r="[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ")).call(r,e.start.toFixed(2),"-")).call(t,e.end.toFixed(2),"]")}var AH=function(){function e(r){t(this,e),this.hls=void 0,this.hls=r}return Fc(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,i=this,n=e.assetListUrl;try{r=yH(n,this.hls.sessionId,e.baseUrl)}catch(JV){var a=this.assignAssetListError(e,dO.ASSET_LIST_LOAD_ERROR,JV,n);return void this.hls.trigger(fO.ERROR,a)}if(t&&!e.cue.pre&&!e.cue.post&&"data:"!==r.protocol){var s=t-e.startTime;s>0&&r.searchParams.set("_HLS_start_offset",""+Math.round(1e3*s)/1e3)}var o=this.hls.config,l=new(0,o.loader)(o),u={responseType:"json",url:r.href},c=o.interstitialAssetListLoadPolicy.default,h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:function(t,r,n,a){var s=t.data,o=null==s?void 0:s.ASSETS;if(Pk(o))e.assetListResponse=s,i.hls.trigger(fO.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:a});else{var l=i.assignAssetListError(e,dO.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,r,a);i.hls.trigger(fO.ERROR,l)}},onError:function(t,r,n,a){var s,o,l=i.assignAssetListError(e,dO.ASSET_LIST_LOAD_ERROR,new Error(_d(s=_d(o="Error loading X-ASSET-LIST: HTTP status ".concat(t.code," ")).call(o,t.text," (")).call(s,r.url,")")),r.url,a,n);i.hls.trigger(fO.ERROR,l)},onTimeout:function(t,r,n){var a=i.assignAssetListError(e,dO.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,n);i.hls.trigger(fO.ERROR,a)}};return l.load(u,h,d),this.hls.trigger(fO.ASSET_LIST_LOADING,{event:e}),l}},{key:"assignAssetListError",value:function(e,t,r,i,n,a){return e.error=r,{type:hO.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:a,stats:n}}}]),e}();function LH(e){null==e||e.play().catch()}var bH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,"interstitials",e.logger)).HlsPlayerClass=void 0,a.hls=void 0,a.assetListLoader=void 0,a.mediaSelection=null,a.altSelection=null,a.media=null,a.detachedData=null,a.requiredTracks=null,a.manager=null,a.playerQueue=[],a.bufferedPos=-1,a.timelinePos=-1,a.schedule=void 0,a.playingItem=null,a.bufferingItem=null,a.waitingItem=null,a.playingAsset=null,a.bufferingAsset=null,a.shouldPlay=!1,a.onPlay=function(){a.shouldPlay=!0},a.onPause=function(){a.shouldPlay=!1},a.onSeeking=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled){var t=e-a.timelinePos;if(!(Math.abs(t)<1/7056e5)){var r=t<=-.01;a.timelinePos=e,a.bufferedPos=e,a.checkBuffer();var i=a.playingItem;if(i)if(r&&e<i.start||e>=i.end){var n,s=a.schedule.findItemIndexAtTime(a.timelinePos);if(!a.isInterstitial(i)&&null!=(n=a.media)&&n.paused&&(a.shouldPlay=!1),!r){var o=a.findItemIndex(i);if(s>o){var l=a.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void a.setSchedulePosition(l)}}a.setSchedulePosition(s)}else{var u=a.playingAsset;if(u){var c=u.timelineStart,h=u.duration||0;(r&&e<c||e>=c+h)&&a.setScheduleToAssetAtTime(e,u)}else if(a.playingLastItem&&a.isInterstitial(i)){var d=i.event.assetList[0];d&&(a.playingItem=null,a.setScheduleToAssetAtTime(e,d))}}}}},a.onTimeupdate=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled&&e>a.timelinePos){e>a.bufferedPos&&a.checkBuffer(),a.timelinePos=e;var t=a.playingItem;if(t&&!a.playingLastItem){if(e>=t.end){a.timelinePos=t.end;var r=a.findItemIndex(t);a.setSchedulePosition(r+1)}var i=a.playingAsset;if(i)e>=i.timelineStart+(i.duration||0)&&a.setScheduleToAssetAtTime(e,i)}}},a.onScheduleUpdate=function(e,t){var r,i,n,s=a.schedule,o=a.playingItem,l=s.events||[],u=s.items||[],c=s.durations,h=_k(e).call(e,(function(e){return e.identifier})),d=!(!l.length&&!h.length);d&&(!1===a.hls.config.interstitialAppendInPlace&&vd(l).call(l,(function(e){return e.appendInPlace=!1})),a.log(_d(i=_d(n="INTERSTITIALS_UPDATED (".concat(l.length,"): ")).call(n,l,"\nSchedule: ")).call(i,_k(u).call(u,(function(e){return SH(e)})))));h.length&&a.log("Removed events ".concat(h)),vd(r=a.playerQueue).call(r,(function(e){if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(o){var i,n,s;if(Math.abs(r)>fH)a.warn(_d(i=_d(n=_d(s="".concat(o,' ("')).call(s,e.assetId,'" ')).call(n,e.timelineOffset,"->")).call(i,t,")"))}}})),o&&!o.event&&(a.playingItem=a.updateItem(o,a.timelinePos));var f=a.bufferingItem;if(f&&(f.event?a.updateItem(f)||(a.bufferingItem=null,a.clearInterstitial(f.event,null)):a.bufferingItem=a.updateItem(f,a.bufferedPos)),a.waitingItem=a.updateItem(a.waitingItem),vd(e).call(e,(function(e){var t;vd(t=e.assetList).call(t,(function(e){a.clearAssetPlayer(e.identifier,null)}))})),d||t){if(a.hls.trigger(fO.INTERSTITIALS_UPDATED,{events:Fv(l).call(l,0),schedule:Fv(u).call(u,0),durations:c,removedIds:h}),a.isInterstitial(o)&&uD(h).call(h,o.event.identifier))return a.warn('Interstitial "'.concat(o.event.identifier,'" removed while playing')),void a.primaryFallback(o.event);a.checkBuffer()}},a.hls=e,a.HlsPlayerClass=n,a.assetListLoader=new AH(e),a.schedule=new TH(a.onScheduleUpdate,e.logger),a.registerListeners(),a}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(fO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(fO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(fO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(fO.MEDIA_ENDED,this.onMediaEnded,this),e.on(fO.ERROR,this.onError,this),e.on(fO.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(fO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(fO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(fO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(fO.MEDIA_ENDED,this.onMediaEnded,this),e.off(fO.ERROR,this.onError,this),e.off(fO.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;vd(e=this.playerQueue).call(e,(function(e){return e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){var e;vd(e=this.playerQueue).call(e,(function(e){return e.pauseBuffering()}))}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){e.removeEventListener("play",this.onPlay),e.removeEventListener("pause",this.onPause),e.removeEventListener("seeking",this.onSeeking),e.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media;this.removeMediaListeners(r),r.addEventListener("seeking",this.onSeeking),r.addEventListener("timeupdate",this.onTimeupdate),r.addEventListener("play",this.onPlay),r.addEventListener("pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var r=this.playingItem,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();var n=this.findItemIndex(r);this.setSchedulePosition(n)}}},{key:"clearScheduleState",value:function(){this.playingItem=this.bufferingItem=this.waitingItem=this.playingAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){var n=this.getBufferingPlayer();n&&(this.playingAsset=null,this.bufferingAsset=null,this.bufferingItem=null,this.waitingItem=null,this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.manager){if(!this.hls||!this.schedule.events)return null;var e=this,t=function(){return e.bufferingItem||e.waitingItem},r=function(){return e.playingItem||e.waitingItem},i=function(t){return t?e.getAssetPlayer(t.identifier):t},n=function(t,r,n,a,o){if(t){var l=t[r].start,u=t.event;if(u){if("playout"===r||u.timelineOccupancy!==vH.Point){var c=i(n);(null==c?void 0:c.interstitial)===u&&(l+=c.assetItem.startOffset+c[o])}}else l+=("bufferedPos"===a?s():e[a])-t.start;return l}return 0},a=function(t,r){if(0!==t&&"primary"!==r&&e.schedule.length){var i,n=e.schedule.findItemIndexAtTime(t),a=null==(i=e.schedule.items)?void 0:i[n];if(a)return t+(a[r].start-a.start)}return t},s=function(){var t=e.bufferedPos;return t===Number.MAX_VALUE?o("primary"):t},o=function(t){var r;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:e.schedule.durations[t]},l=function(t,a){var s,o,l,u=r();if(null==u||null==(o=u.event)||!o.restrictions.skip){e.log(_d(s="seek to ".concat(t,' "')).call(s,a,'"'));var c=r(),h=e.schedule.findItemIndexAtTime(t,a),d=null==(l=e.schedule.items)?void 0:l[h],f=null==c?void 0:c.event,v=null==f?void 0:f.appendInPlace,g=c&&e.itemsMatch(c,d);if(c&&(v||g)){var p=i(e.playingAsset),m=(null==p?void 0:p.media)||e.hls.media;if(m){var y=t-("primary"===a?m.currentTime:n(c,a,e.playingAsset,"timelinePos","currentTime")),E=m.currentTime+y;if(E>=0&&(!p||v||E<=p.duration))return void(m.currentTime=E)}}if(d){var k=t;if("primary"!==a){var T=t-d[a].start;k=d.start+T}var S=!e.isInterstitial(d);if(e.isInterstitial(c)||!S&&!d.event.appendInPlace){if(c){var A=e.findItemIndex(c);if(h>A){var L=e.schedule.findJumpRestrictedIndex(A+1,h);if(L>A)return void e.setSchedulePosition(L)}var b=0;if(S)e.timelinePos=k;else{var R,I=null==d||null==(R=d.event)?void 0:R.assetList;if(I)for(var D=t-(d[a]||d).start,_=I.length;_--;){var w=I[_];if(w.duration&&D>=w.startOffset&&D<w.startOffset+w.duration){b=_;break}}}e.setSchedulePosition(h,b)}}else{var C=e.hls.media;C&&(C.currentTime=k)}}}};this.manager={get events(){var t,r;return(null==(t=e.schedule)||null==(r=t.events)?void 0:Fv(r).call(r,0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:Fv(r).call(r,0))||[]},get playerQueue(){var t;return Fv(t=e.playerQueue).call(t,0)},get bufferingPlayer(){return e.getBufferingPlayer()},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return e.bufferingItem},get playingAsset(){return e.playingAsset},get playingItem(){return e.playingItem},get bufferingIndex(){var r=t();return e.findItemIndex(r)},get playingIndex(){var t=r();return e.findItemIndex(t)},get waitingIndex(){return e.findItemIndex(e.waitingItem)},primary:{get bufferedEnd(){return s()},get currentTime(){var t=e.timelinePos;return t>0?t:0},get duration(){return o("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0},seekTo:function(e){return l(e,"primary")}},playout:{get bufferedEnd(){return n(t(),"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"playout",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("playout")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"playout")},seekTo:function(e){return l(e,"playout")}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"integrated",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("integrated")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")},seekTo:function(e){return l(e,"integrated")}},skip:function(){var t=r(),i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;l(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,1/0)}}}}return this.manager}},{key:"playingLastItem",get:function(){var e,t=this.playingItem;if(!this.playbackStarted||!t)return!1;var r=null==(e=this.schedule)?void 0:e.items;return this.itemsMatch(t,r?r[r.length-1]:null)}},{key:"playbackStarted",get:function(){return null!==this.playingItem}},{key:"currentTime",get:function(){var e,t,r;if(null!==this.mediaSelection){var i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(n=this.primaryMedia);var a=null==(r=n)?void 0:r.currentTime;if(void 0!==a&&lO(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var r=e.interstitial.appendInPlace,i=e.media;if(r&&i===this.primaryMedia){var n;if(!t||this.isInterstitial(t)&&!t.event.appendInPlace)return void(t&&i&&(this.detachedData={media:i}));var a=e.transferMedia();this.log(_d(n="transfer MediaSource from ".concat(e," ")).call(n,jI(a))),this.bufferingAsset=null,this.detachedData=a}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}},{key:"transferMediaTo",value:function(e,t){var r,i,n,a,s,o,l=null,u=this.hls,c=e!==u,h=c&&e.interstitial.appendInPlace,d=null==(a=this.detachedData)?void 0:a.mediaSource;if(u.media&&h)l=u.transferMedia(),this.detachedData=l,o="Primary";else if(d){var f=this.getBufferingPlayer();f&&(l=f.transferMedia()),o="".concat(f)}else o="<unknown>";this.log(_d(r=_d(i="transferring to ".concat(c?e:"Primary","\nMediaSource ")).call(i,jI(l)," from ")).call(r,o)),l||(d?(l=this.detachedData,this.log("using detachedData: MediaSource ".concat(jI(l)))):this.detachedData&&this.hls.media!==t||(this.hls.detachMedia(),this.detachedData={media:t}));var v=l&&"mediaSource"in l&&"closed"!==(null==(s=l.mediaSource)?void 0:s.readyState),g=v&&l?l:t;if(this.log(_d(n="".concat(v?"transfering MediaSource":"attaching media"," to ")).call(n,c?e:"Primary")),g===l){var p=c&&e.assetId===this.schedule.assetIdAtEnd;g.overrides={duration:this.schedule.duration,endOfStream:!c||p,cueRemoval:!1}}e.attachMedia(g)}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=e.events;if(t&&!this.playbackDisabled){-1===this.bufferedPos&&(this.bufferedPos=0);var r=this.timelinePos,i=this.waitingItem;if(-1===r){var n=this.hls.startPosition;if(this.timelinePos=n,t.length&&t[0].cue.pre){var a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(n>=0||!this.primaryLive){var s=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(i&&!this.playingItem){var l=e.findItemIndex(i);this.setSchedulePosition(l)}}}},{key:"advanceAfterAssetEnded",value:function(e,t,r){var i=r+1;if(e.isAssetPastPlayoutLimit(i)||e.assetList[i].error){var n=this.schedule.items;if(n){var a=t+1;if(a>=n.length)return void this.setSchedulePosition(-1);this.setSchedulePosition(a)}}else this.setSchedulePosition(t,i)}},{key:"setScheduleToAssetAtTime",value:function(e,t){var r=this.schedule,i=t.parentIdentifier,n=r.getEvent(i);if(n){var a=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.setSchedulePosition(a,s)}}},{key:"setSchedulePosition",value:function(e,t){var r,i=this,n=this.schedule.items;if(n&&!this.playbackDisabled){this.log(_d(r="setSchedulePosition ".concat(e,", ")).call(r,t));var a=e>=0?n[e]:null,s=this.primaryMedia,o=this.playingItem,l=this.playingLastItem;if(this.isInterstitial(o)){var u,c,h=o.event,d=this.playingAsset,f=null==d?void 0:d.identifier,v=f?this.getAssetPlayer(f):null;if(v&&f&&(!this.eventItemsMatch(o,a)||void 0!==t&&f!==(null==(u=h.assetList)?void 0:u[t].identifier))){var g,p;this.playingAsset=null;var m=h.findAssetIndex(d);this.log(_d(g=_d(p="INTERSTITIAL_ASSET_ENDED ".concat(m+1,"/")).call(p,h.assetList.length," ")).call(g,EH(d))),this.hls.trigger(fO.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:m,event:h,schedule:Fv(n).call(n,0),scheduleIndex:e,player:v}),this.retreiveMediaSource(f,a),v.media&&!this.detachedData&&v.detachMedia(),this.clearAssetPlayer(f,a)}if(!this.eventItemsMatch(o,a))if(this.playingItem=null,this.log(_d(c="INTERSTITIAL_ENDED ".concat(h," ")).call(c,SH(o))),h.hasPlayed=!0,this.hls.trigger(fO.INTERSTITIAL_ENDED,{event:h,schedule:Fv(n).call(n,0),scheduleIndex:e}),this.clearInterstitial(h,a),h.cue.once){if(this.updateSchedule(),a){var y=this.schedule.findItemIndex(a);this.setSchedulePosition(y,t)}return}}var E=this.playerQueue;if(E.length&&vd(E).call(E,(function(t){var r=t.interstitial,n=i.schedule.findEventIndex(r.identifier);(n<e||n>e+1)&&i.clearInterstitial(r,a)})),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);var k=a.event;void 0===t&&(t=this.schedule.findAssetIndex(k,this.timelinePos));var T,S=this.waitingItem,A=this.preloadAssets(k,t);if(A||this.setBufferingItem(a),!this.eventItemsMatch(a,o||S))this.waitingItem=a,this.log(_d(T="INTERSTITIAL_STARTED ".concat(SH(a)," ")).call(T,k.appendInPlace?"append in place":"")),this.hls.trigger(fO.INTERSTITIAL_STARTED,{event:k,schedule:Fv(n).call(n,0),scheduleIndex:e});var L=k.assetList.length;if(0===L&&!k.assetListResponse)return void this.log("Waiting for ASSET-LIST to complete loading ".concat(k));if(k.assetListLoader&&(k.assetListLoader.destroy(),k.assetListLoader=void 0),!s)return void this.log("Waiting for attachMedia to start Interstitial ".concat(k));this.waitingItem=null,this.playingItem=a;var b,R,I=k.assetList[t];if(!I){var D=n[e+1],_=this.media;return D&&_&&!this.isInterstitial(D)&&_.currentTime<D.start&&(_.currentTime=this.timelinePos=D.start),void this.advanceAfterAssetEnded(k,e,t||0)}if(A||(A=this.getAssetPlayer(I.identifier)),null===A||A.destroyed)this.warn(_d(b=_d(R="asset ".concat(t+1,"/")).call(R,L," player destroyed ")).call(b,k)),A=this.createAssetPlayer(k,I,t);if(!this.eventItemsMatch(a,this.bufferingItem)&&k.appendInPlace&&this.isAssetBuffered(I))return;this.startAssetPlayer(A,t,n,e,s),this.shouldPlay&&LH(A.media)}else null!==a?(this.resumePrimary(a,e,o),this.shouldPlay&&LH(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(SH(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(SH(e))),this.hls.trigger(fO.INTERSTITIALS_PRIMARY_RESUMED,{schedule:Fv(a).call(a,0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var r=e.start;if(this.primaryLive){var i=this.primaryDetails;if(0===t)return this.hls.startPosition;if(i&&(r<i.fragmentStart||r>i.edge))return this.hls.liveSyncPosition||-1}return r}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:qN.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(fO.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(fO.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],i=RO(RO({},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=RO(RO({},i),{},{audio:r});this.mediaSelection=n}else this.altSelection=RO(RO({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(i){var n=RO(RO({},i),{},{subtitles:r});this.mediaSelection=n}else this.altSelection=RO(RO({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r,i=uF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(i)}))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r,i=uF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(i)}))}},{key:"onBufferCodecs",value:function(e,t){var r=t.tracks;r&&(this.requiredTracks=r)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var r=this.playingItem;if(r&&r!==this.bufferingItem&&!this.isInterstitial(r)){var i=this.timelinePos;this.bufferedPos=i,this.setBufferingItem(r)}}},{key:"onBufferedToEnd",value:function(e){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var r=0;r<t.length;r++){var i=t[r];if(i.cue.post){var n,a=this.schedule.findEventIndex(i.identifier),s=null==(n=this.schedule.items)?void 0:n[a];this.isInterstitial(s)&&this.eventItemsMatch(s,this.bufferingItem)&&this.bufferedToItem(s,0);break}}this.bufferedPos=Number.MAX_VALUE}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var r=this.findItemIndex(t);this.setSchedulePosition(r+1)}}},{key:"updateItem",value:function(e,t){var r=this.schedule.items;return e&&r&&r[this.findItemIndex(e,t)]||null}},{key:"itemsMatch",value:function(e,t){var r,i;return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&(null==(r=e.nextEvent)?void 0:r.identifier)===(null==(i=t.nextEvent)?void 0:i.identifier))}},{key:"eventItemsMatch",value:function(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}},{key:"findItemIndex",value:function(e,t){return e?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(){var e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[])}},{key:"checkBuffer",value:function(){var e=this.schedule.items;if(e){var t=qN.bufferInfo(this.primaryMedia,this.timelinePos,0);this.updateBufferedPos(t.end,e,0===t.len)}}},{key:"updateBufferedPos",value:function(e,t,r){var i=this.schedule,n=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],n))this.bufferedPos=e;else{var a=this.playingItem,s=this.findItemIndex(a),o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,u=this.findItemIndex(n),c=Math.min(u+1,t.length-1),h=t[c];if(-1===o&&n&&e>=n.end&&(o=c),c-s>1&&!1===(null==n||null==(l=n.event)?void 0:l.appendInPlace))return;if(this.bufferedPos=e,o>u&&o>s)this.bufferedToItem(h);else{var d=this.primaryDetails;this.primaryLive&&d&&e>d.edge-d.targetduration&&h.start<d.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else r&&a&&n!==a&&o===s&&this.bufferedToItem(a)}}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,r=this.schedule,i=r.items,n=r.events;if(i&&n&&(!t||r.findItemIndex(t)!==r.findItemIndex(e))){var a,s,o=this.isInterstitial(e),l=this.getBufferingPlayer(),u=l?l.remaining:t?t.end-this.timelinePos:0;if(this.log("buffered to boundary ".concat(SH(e))+(t?" (".concat(u.toFixed(2)," remaining)"):"")),this.bufferingItem=e,this.bufferedPos=e.start,!this.playbackDisabled)if(o)vd(a=this.playerQueue).call(a,(function(e){return e.resumeBuffering()}));else this.hls.resumeBuffering(),vd(s=this.playerQueue).call(s,(function(e){return e.pauseBuffering()}));this.hls.trigger(fO.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:Fv(n).call(n,0),schedule:Fv(i).call(i,0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}return t}},{key:"bufferedToItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;var i=this.detachedData;if(i)if(i.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}},{key:"bufferedToEvent",value:function(e,t){var r=e.event,i=0===r.assetList.length&&!r.assetListLoader,n=r.cue.once;if(i||!n){var a=this.preloadAssets(r,t);if(null!=a&&a.interstitial.appendInPlace){var s=r.assetList[t],o=this.primaryMedia;s&&o&&this.bufferAssetPlayer(a,o)}}}},{key:"preloadAssets",value:function(e,t){var r=e.assetList.length,i=0===r&&!e.assetListLoader,n=e.cue.once;if(i){var a,s;this.log(_d(a=_d(s="Load interstitial asset ".concat(t+1,"/")).call(s,r," ")).call(a,e));var o=e.timelineStart;e.appendInPlace&&this.flushFrontBuffer(o);var l=e.assetUrl;if(l)return this.createAsset(e,0,0,o,e.duration,l);var u=0;!this.playingItem&&this.primaryLive&&-1===(u=this.hls.startPosition)&&(u=this.hls.liveSyncPosition||0);var c=this.assetListLoader.loadAssetList(e,u);c&&(e.assetListLoader=c)}else if(!n&&r){for(var h=t;h<r;h++){var d=e.assetList[h],f=this.getAssetPlayerQueueIndex(d.identifier);-1!==f&&!this.playerQueue[f].destroyed||d.error||this.createAssetPlayer(e,d,h)}return this.getAssetPlayer(e.assetList[t].identifier)}return null}},{key:"flushFrontBuffer",value:function(e){var t=this,r=this.requiredTracks;if(r){var i=gv(r);vd(i).call(i,(function(r){t.hls.trigger(fO.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r})}))}}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}},{key:"createAsset",value:function(e,t,r,i,n,a){var s={parentIdentifier:e.identifier,identifier:gH(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(EH(t)));var n=this.hls,a=n.userConfig,s=a.videoPreference,o=n.levels[n.loadLevel]||n.levels[n.currentLevel];(s||o)&&(s=LO({},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=RO(RO({},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=LO({},v,{contentId:dH(t.uri)}));var g=new kH(this.HlsPlayerClass,f,e,t);this.playerQueue.push(g),e.assetList[r]=t;var p=t.identifier,m=function(n){if(n.live){var a=new Error("Interstitials MUST be VOD assets ".concat(e)),s={fatal:!0,type:hO.OTHER_ERROR,details:dO.INTERSTITIAL_ASSET_ITEM_ERROR,error:a};i.handleAssetItemError(s,e,i.schedule.findEventIndex(e.identifier),r,a.message)}else{var o,l,u=n.edge-n.fragmentStart,c=t.duration;if(null===c||u>c)i.log(_d(o=_d(l='Interstitial asset "'.concat(p,'" duration change ')).call(l,c," > ")).call(o,u)),t.duration=u,i.updateSchedule()}};g.on(fO.LEVEL_UPDATED,(function(e,t){var r=t.details;return m(r)})),g.on(fO.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return m(r)}));g.on(fO.BUFFER_CODECS,(function e(t,r){var n=i.getAssetPlayer(p);if(n&&r.tracks){n.off(fO.BUFFER_CODECS,e),n.tracks=r.tracks;var a=i.primaryMedia;i.bufferingAsset===n.assetItem&&a&&!n.media&&i.bufferAssetPlayer(n,a)}}));g.on(fO.BUFFERED_TO_END,(function r(n){var a,s=i.getAssetPlayer(p);if(i.log("buffered to end of asset ".concat(s)),s){s.off(fO.BUFFERED_TO_END,r);var o=i.schedule.findEventIndex(e.identifier),l=e.findAssetIndex(t),u=l+1,c=null==(a=i.schedule.items)?void 0:a[o];if(i.isInterstitial(c))if(-1===l||e.isAssetPastPlayoutLimit(u)||e.assetList[u].error){var h,d=null==(h=i.schedule.items)?void 0:h[o+1];d&&i.bufferedToItem(d)}else i.bufferedToItem(c,l+1)}}));var y=function(t){return function(){if(i.getAssetPlayer(p)){i.shouldPlay=!0;var r=i.schedule.findEventIndex(e.identifier);i.advanceAfterAssetEnded(e,r,t)}}};return g.once(fO.MEDIA_ENDED,y(r)),g.once(fO.PLAYOUT_LIMIT_REACHED,y(1/0)),g.on(fO.ERROR,(function(t,n){var a;i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,_d(a="Asset player error ".concat(n.error," ")).call(a,e))})),g.on(fO.DESTROYING,(function(){if(i.getAssetPlayer(p)){var t=new Error("Asset player destroyed unexpectedly ".concat(p)),n={fatal:!0,type:hO.OTHER_ERROR,details:dO.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(fO.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:g}),g}},{key:"clearInterstitial",value:function(e,t){var r,i=this;vd(r=e.assetList).call(r,(function(e){i.clearAssetPlayer(e.identifier,t)})),e.appendInPlaceStarted=!1}},{key:"clearAssetPlayer",value:function(e,t){if(null!==t){var r=this.getAssetPlayerQueueIndex(e);if(-1!==r){var i,n;this.log(_d(i='clearAssetPlayer "'.concat(e,'" toSegment: ')).call(i,t?SH(t):t));var a=this.playerQueue[r];this.transferMediaFromPlayer(a,t),ig(n=this.playerQueue).call(n,r,1),a.destroy()}}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,r,i,n){var a,s,o=e.interstitial,l=e.assetItem,u=e.assetId,c=o.assetList.length,h=this.playingAsset;(this.playingAsset=l,h&&h.identifier===u)||(h&&(this.clearAssetPlayer(h.identifier,r[i]),delete h.error),this.log(_d(a=_d(s="INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/")).call(s,c," ")).call(a,e)),this.hls.trigger(fO.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:o,schedule:Fv(r).call(r,0),scheduleIndex:i,player:e}));e.media||this.bufferAssetPlayer(e,n)}},{key:"bufferAssetPlayer",value:function(e,t){var r,i,n=e.interstitial,a=e.assetItem,s=e.assetId,o=this.schedule.findEventIndex(n.identifier),l=null==(r=this.schedule.items)?void 0:r[o];if(l){this.setBufferingItem(l),this.bufferingAsset=a;var u=this.getBufferingPlayer();if(u!==e){var c=(null==u?void 0:u.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(n.appendInPlace&&a!==this.playingAsset){if(!e.tracks)return;if(c&&!OO(c,e.tracks)){var h,d,f=new Error(_d(h=_d(d='Asset "'.concat(s,"\" SourceBuffer tracks ('")).call(d,gv(e.tracks),"') are not compatible with primary content tracks ('")).call(h,gv(c),"')")),v={fatal:!0,type:hO.OTHER_ERROR,details:dO.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!==dO.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=LO({},e,{fatal:!1,errorAction:MF(!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(fO.INTERSTITIAL_ASSET_ERROR,c),e.fatal){var h=new Error(n);s&&(this.playingAsset!==s&&this.clearAssetPlayer(s.identifier,null),s.error=h),KT(a=t.assetList).call(a,(function(e){return!e.error}))?t.appendInPlace&&(t.error=h):t.error=h,this.primaryFallback(t)}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,r=this.playingItem||this.waitingItem;if(this.updateSchedule(),r){var i,n,a,s;this.log(_d(i=_d(n=_d(a=_d(s='Fallback to primary from event "'.concat(e.identifier,'" start: ')).call(s,t," pos: ")).call(a,this.timelinePos," playing: ")).call(n,r?SH(r):"<none>"," error: ")).call(i,e.error)),e.appendInPlace&&(e.appendInPlace=!1,this.attachPrimary(t,null),this.flushFrontBuffer(t));var o=this.timelinePos;-1===o&&(o=this.hls.startPosition);var l=this.updateItem(r,o);if(!this.itemsMatch(r,l)){var u=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(u)}}else this.checkStart()}},{key:"onAssetListLoaded",value:function(e,t){var r,i=this,n=t.event,a=n.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(a)){var o=n.timelineStart,l=0;vd(s).call(s,(function(e,t){var r=bS(e.DURATION);i.createAsset(n,t,l,o+l,r,e.URI),l+=r})),n.duration=l;var u=this.waitingItem,c=(null==u?void 0:u.event.identifier)===a;this.updateSchedule();var h=null==(r=this.bufferingItem)?void 0:r.event;if(c){var d,f=this.schedule.findEventIndex(a),v=null==(d=this.schedule.items)?void 0:d[f];v&&this.setBufferingItem(v),this.setSchedulePosition(f)}else if((null==h?void 0:h.identifier)===a&&h.appendInPlace){var g=n.assetList[0],p=this.getAssetPlayer(g.identifier),m=this.primaryMedia;g&&p&&m&&this.bufferAssetPlayer(p,m)}}}},{key:"onError",value:function(e,t){switch(t.details){case dO.ASSET_LIST_PARSING_ERROR:case dO.ASSET_LIST_LOAD_ERROR:case dO.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r)}}}]),i}(IO),RH=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"subtitle-stream-controller",kO)).currentTrackId=-1,s.tracksBuffered=[],s.mainDetails=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(fO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(fO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e){this.stopLoad(),this.state=cB,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,t){this.tracksBuffered=[],Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var r=t.frag,i=t.success;if(uN(r)&&(this.fragPrevious=r),this.state=cB,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var a,s=r.start,o=0;o<n.length;o++)if(s>=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n,a=i-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),vd(n=this.tracksBuffered).call(n,(function(e){for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}})),this.fragmentTracker.removeFragmentsInRange(r,a,kO)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===kO&&(t.details===dO.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==uB&&(this.state=cB))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks;this.levels&&iK(this.levels,i)?this.levels=_k(i).call(i,(function(e){return new nF(e)})):(this.tracksBuffered=[],this.levels=_k(i).call(i,(function(e){var t=new nF(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,kO),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!==uB&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,i,n,a,s,o,l=this.currentTrackId,u=this.levels,c=t.details,h=t.id;if(u){var d=u[h];if(!(h>=u.length)&&d){this.log(_d(r=_d(i=_d(n=_d(a="Subtitle track ".concat(h," loaded [")).call(a,c.startSN,",")).call(n,c.endSN,"]")).call(i,c.lastPartSn?_d(s="[part-".concat(c.lastPartSn,"-")).call(s,c.lastPartIndex,"]"):"",",duration:")).call(r,c.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;if(c.live||null!=(o=d.details)&&o.live){var f=this.mainDetails;if(c.deltaUpdateFailed||!f)return;var v,g=f.fragments[0];if(d.details)0===this.alignPlaylists(c,d.details,null==(v=this.levelLastLoaded)?void 0:v.details)&&g&&JU(c,g.start);else c.hasProgramDateTime&&f.hasProgramDateTime?(oB(c,f),c.fragmentStart):g&&JU(c,g.start)}if(d.details=c,this.levelLastLoaded=d,h===l)if(this.hls.trigger(fO.SUBTITLE_TRACK_UPDATED,{details:c,id:h,groupId:t.groupId}),this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===cB)mF(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&&nU(n.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,aU(n.method)).catch((function(e){throw a.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();a.trigger(fO.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){var r;t.warn(_d(r="".concat(e.name,": ")).call(r,e.message)),t.state=cB}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===cB){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=qN.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=mF(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(uN(d=this.mapToInitFragWhenRequired(d))){var p=u[d.sn-l.startSN-1];p&&p.cc===d.cc&&this.fragmentTracker.getState(p)===OF&&(d=p)}this.fragmentTracker.getState(d)===OF&&this.loadFragment(d,r,s)}}else this.state=cB}},{key:"loadFragment",value:function(e,t,r){uN(e)?Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r):this._loadInitSegment(e,t)}},{key:"mediaBufferTimeRanges",get:function(){return new IH(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(TB),IH=Fc((function e(r){t(this,e),this.buffered=void 0;var i=function(e,t,i){var n,a;if((t>>>=0)>i-1)throw new DOMException(_d(n=_d(a="Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (")).call(a,t,") is greater than the maximum bound (")).call(n,i,")"));return r[t][e]};this.buffered={get length(){return r.length},end:function(e){return i("end",e,r.length)},start:function(e){return i("start",e,r.length)}}})),DH={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},_H=function(e){return String.fromCharCode(DH[e]||e)},wH=15,CH=100,PH={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},xH={17:2,18:4,21:6,22:8,23:10,19:13,20:15},MH={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},OH={25:2,26:4,29:6,30:8,31:10,27:13,28:15},FH=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],NH=function(){function e(){t(this,e),this.time=null,this.verboseLevel=0}return Fc(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r,i,n="function"==typeof t?t():t;xO.log(_d(r=_d(i="".concat(this.time," [")).call(i,e,"] ")).call(r,n))}}}]),e}(),UH=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},BH=function(){function e(){t(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return Fc(e,[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}]),e}(),GH=function(){function e(){t(this,e),this.uchar=" ",this.penState=new BH}return Fc(e,[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}]),e}(),KH=function(){function e(r){t(this,e),this.chars=[],this.pos=0,this.currPenState=new BH,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<CH;i++)this.chars.push(new GH);this.logger=r}return Fc(e,[{key:"equals",value:function(e){for(var t=0;t<CH;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<CH;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<CH;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>CH&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=CH)}},{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=_H(e);this.pos>=CH?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<CH;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<CH;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}(),HH=function(){function e(r){t(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<wH;i++)this.rows.push(new KH(r));this.logger=r}return Fc(e,[{key:"reset",value:function(){for(var e=0;e<wH;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,r=0;r<wH;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<wH;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<wH;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 = "+jI(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<wH;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 = "+jI(e)})),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){var e,t,r=this;if(null!==this.nrRollUpRows){this.logger.log(1,(function(){return r.getDisplayText()}));var i=this.currRow+1-this.nrRollUpRows,n=ig(e=this.rows).call(e,i,1)[0];n.clear(),ig(t=this.rows).call(t,this.currRow,0,n),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],r="",i=-1,n=0;n<wH;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(MS(a).call(a)))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),VH=function(){function e(r,i,n){t(this,e),this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=r,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new HH(n),this.nonDisplayedMemory=new HH(n),this.lastOutputScreen=new HH(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}return Fc(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return i+": "+t.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(function(){return"DISP: "+e.displayedMemory.getDisplayText()}))}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+jI(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}(),jH=function(){function e(r,i,n){t(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new NH;this.channels=[null,new VH(r,i,a),new VH(r+1,n,a)]}return Fc(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r=this;this.logger.time=e;for(var i=function(e){var i=127&t[e],n=127&t[e+1],a=!1,s=null;if(0===i&&0===n)return"continue";r.logger.log(3,(function(){return"["+UH([t[e],t[e+1]])+"] -> ("+UH([i,n])+")"}));var o=r.cmdHistory;if(i>=16&&i<=31){if(function(e,t,r){return r.a===e&&r.b===t}(i,n,o))return YH(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+UH([i,n])+") is dropped"})),"continue";YH(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 YH(null,null,o);if(!a&&(s=r.parseChars(i,n))){var l=r.currentChannel;if(l&&l>0)r.channels[l].insertChars(s);else r.logger.log(2,"No channel found yet. TEXT-MODE?")}a||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+UH([i,n])+" orig: "+UH([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 ("+UH([e,t])+")"})),!0)}return!1}},{key:"parsePAC",value:function(e,t){var r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var i=e<=23?1:2;r=t>=64&&t<=95?1===i?PH[e]:MH[e]:1===i?xH[e]:OH[e];var n=this.channels[i];return!!n&&(n.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}},{key:"interpretPAC",value:function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}},{key:"parseChars",value:function(e,t){var r,i,n=null,a=null;(e>=25?(r=2,a=e-8):(r=1,a=e),a>=17&&a<=19)?(i=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+_H(i)+"' in channel "+r})),n=[i]):e>=32&&e<=127&&(n=0===t?[e]:[e,t]);return n&&this.logger.log(3,(function(){return"Char codes = "+UH(n).join(",")})),n}},{key:"parseBackgroundAttributes",value:function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=FH[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(i),!0}},{key:"reset",value:function(){for(var e=0;e<gv(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}YH(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 YH(e,t,r){r.a=e,r.b=t}var qH=function(){if(null!=uU&&uU.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Pk(e))return!1;var r=t.toLowerCase();return!!~av(e).call(e,r)&&r}function i(e){return r(t,e)}function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,h=t,d=a,f=s,v=null,g="",p=!0,m="auto",y="start",E=50,k="middle",T=50,S="middle";iT(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),iT(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),iT(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}})),iT(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}})),iT(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),iT(o,"region",n({},l,{get:function(){return v},set:function(e){v=e,this.hasBeenReset=!0}})),iT(o,"vertical",n({},l,{get:function(){return g},set:function(t){var i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),iT(o,"snapToLines",n({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),iT(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}})),iT(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}})),iT(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}})),iT(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}})),iT(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}})),iT(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}(),WH=function(){function e(){t(this,e)}return Fc(e,[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}]),e}();function zH(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+bS(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?bS(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var XH=function(){function e(){t(this,e),this.values=aT(null)}return Fc(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(oO(this)[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?oO(this)[e]:t[r]:this.has(e)?oO(this)[e]:t}},{key:"has",value:function(e){return e in oO(this)}},{key:"alt",value:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,Ak(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=bS(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function QH(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);if(2===s.length)t(s[0],s[1])}}var $H=new qH(0,0,""),JH="middle"===$H.align?"middle":"center";function ZH(e,t,r){var i=e;function n(){var t=zH(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=n(),a(),"--\x3e"!==Fv(e).call(e,0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=Fv(e).call(e,3),a(),t.endTime=n(),a(),function(e,t){var i=new XH;QH(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",JH,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",JH,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",JH,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===$H.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",JH);var a=i.get("position","auto");"auto"===a&&50===$H.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function eV(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var tV=function(){function e(){t(this,e),this.state="INITIAL",this.buffer="",this.decoder=new WH,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return Fc(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=eV(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=Fv(e).call(e,0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=Fv(e).call(e,r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var n=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(null==n||!n[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var a=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:i=r(),t.state){case"HEADER":/:/.test(i)?QH(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 qH(0,0,""),t.state="CUE",-1===av(i).call(i,"--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{ZH(i,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==av(i).call(i,"--\x3e");if(!i||s&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch(o){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}]),e}(),rV=/\r\n|\n\r|\n|\r/g,iV=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Fv(e).call(e,r,r+t.length)===t};function nV(e,t,r){return dH(e.toString())+dH(t.toString())+dH(r)}function aV(e,t,r,i,n,a,s){var o,l,u=new tV,c=MS(o=zF(new Uint8Array(e))).call(o).replace(rV,"\n").split("\n"),h=[],d=t?function(e){return FG(e,OG,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=KG(9e4*(e.startTime+o-g),9e4*n)/9e4;e.startTime=Math.max(f,0),e.endTime=Math.max(f+c,0);var p=MS(a=e.text).call(a);e.text=decodeURIComponent(encodeURIComponent(p)),e.id||(e.id=nV(e.startTime,e.endTime,p)),e.endTime>0&&h.push(e)},u.onparsingerror=function(e){l=e},u.onflush=function(){l?s(l):a(h)},vd(c).call(c,(function(e){if(p){if(iV(e,"X-TIMESTAMP-MAP=")){var t;p=!1,vd(t=Fv(e).call(e,16).split(",")).call(t,(function(e){iV(e,"LOCAL:")?f=Fv(e).call(e,6):iV(e,"MPEGTS:")&&(v=Ak(Fv(e).call(e,7)))}));try{g=function(e){var t=Ak(Fv(e).call(e,-3)),r=Ak(Fv(e).call(e,-6,-4)),i=Ak(Fv(e).call(e,-9,-7)),n=e.length>9?Ak(e.substring(0,av(e).call(e,":"))):0;if(!(lO(t)&&lO(r)&&lO(i)&&lO(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*i,t+36e5*n}(f)/1e3}catch(JV){l=JV}return}""===e&&(p=!1)}u.parse(e+"\n")})),u.flush()}var sV="stpp.ttml.im1t",oV=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,lV=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,uV={left:"start",center:"center",right:"end",start:"start",end:"end"};function cV(e,t,r,i){var n=TN(new Uint8Array(e),["mdat"]);if(0!==n.length){var a=_k(n).call(n,(function(e){return zF(e)})),s=function(e,t){return FG(e,t,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}(t.baseTime,1,t.timescale);try{vd(a).call(a,(function(e){return r(function(e,t){var r,i,n=(new DOMParser).parseFromString(e,"text/xml"),a=n.getElementsByTagName("tt")[0];if(!a)throw new Error("Invalid ttml");var s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},o=kC(r=gv(s)).call(r,(function(e,t){return e[t]=a.getAttribute("ttp:".concat(t))||s[t],e}),{}),l="preserve"!==a.getAttribute("xml:space"),u=dV(hV(a,"styling","style")),c=dV(hV(a,"layout","region")),h=hV(a,"body","[begin]");return xk(i=_k([]).call(h,(function(e){var r=fV(e,l);if(!r||!e.hasAttribute("begin"))return null;var i=pV(e.getAttribute("begin"),o),n=pV(e.getAttribute("dur"),o),a=pV(e.getAttribute("end"),o);if(null===i)throw gV(e);if(null===a){if(null===n)throw gV(e);a=i+n}var s=new qH(i-t,a-t,r);s.id=nV(s.startTime,s.endTime,s.text);var h=function(e,t,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;s&&r.hasOwnProperty(s)&&(n=r[s]);return kC(a).call(a,(function(r,a){var s=vV(t,i,a)||vV(e,i,a)||vV(n,i,a);return s&&(r[a]=s),r}),{})}(c[e.getAttribute("region")],u[e.getAttribute("style")],u),d=h.textAlign;if(d){var f=uV[d];f&&(s.lineAlign=f),s.align=d}return LO(s,h),s}))).call(i,(function(e){return null!==e}))}(e,s))}))}catch(JV){i(JV)}}else i(new Error("Could not parse IMSC1 mdat"))}function hV(e,t,r){var i=e.getElementsByTagName(t)[0];return i?Fv([]).call(i.querySelectorAll(r)):[]}function dV(e){return kC(e).call(e,(function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function fV(e,t){var r;return kC(r=Fv([]).call(e.childNodes)).call(r,(function(e,r,i){var n,a;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?fV(r,t):t?e+MS(a=r.textContent).call(a).replace(/\s+/g," "):e+r.textContent}),"")}function vV(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function gV(e){return new Error("Could not parse ttml timestamp ".concat(e))}function pV(e,t){if(!e)return null;var r=zH(e);return null===r&&(oV.test(e)?r=function(e,t){var r=oV.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):lV.test(e)&&(r=function(e,t){var r=lV.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}var mV=function(){function e(r,i){t(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=r,this.trackName=i}return Fc(e,[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}]),e}(),yV=function(){function e(r){t(this,e),this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=r,this.config=r.config,this.Cues=r.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},r.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),r.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(fO.FRAG_LOADING,this.onFragLoading,this),r.on(fO.FRAG_LOADED,this.onFragLoaded,this),r.on(fO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),r.on(fO.FRAG_DECRYPTED,this.onFragDecrypted,this),r.on(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(fO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),r.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this)}return Fc(e,[{key:"destroy",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(fO.FRAG_LOADING,this.onFragLoading,this),e.off(fO.FRAG_LOADED,this.onFragLoaded,this),e.off(fO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(fO.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(fO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(fO.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 mV(this,"textTrack1"),t=new mV(this,"textTrack2"),r=new mV(this,"textTrack3"),i=new mV(this,"textTrack4");this.cea608Parser1=new jH(1,e,t),this.cea608Parser2=new jH(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(fO.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===yO&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],vd(o).call(o,(function(e){r.onFragLoaded(fO.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(kV(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,lH(r[e]),sH(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(fO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}}},{key:"createTextTrack",value:function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var r,i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;vd(r=gv(n)).call(r,(function(e){lH(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++)lH(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks||[],n=KT(i).call(i,(function(e){return e.textCodec===sV}));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(iK(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a,s=this.media,o=s?cH(s.textTracks):null;if(vd(a=this.tracks).call(a,(function(e,t){var i;if(o){for(var n=null,a=0;a<o.length;a++)if(o[a]&&kV(o[a],e)){n=o[a],o[a]=null;break}n&&(i=n)}if(i)lH(i);else{var s=EV(e);(i=r.createTextTrack(s,e.name,e.lang))&&(i.mode="disabled")}i&&r.textTracks.push(i)})),null!=o&&o.length){var l,u=_k(l=xk(o).call(o,(function(e){return null!==e}))).call(l,(function(e){return e.label}));u.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(u.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){var c,h=_k(c=this.tracks).call(c,(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(fO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:h})}}}},{key:"onManifestLoaded",value:function(e,t){var r,i=this;this.config.enableCEA708Captions&&t.captions&&vd(r=t.captions).call(r,(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack".concat(t[1]),n=i.captionsProperties[r];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}}))}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===yO){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===kO)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===sV?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(fO.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;cV(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(fO.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){i.logger.log("Failed to parse IMSC1: ".concat(t)),i.trigger(fO.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;aV(null!=(t=i.initSegment)&&t.data?wN(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(fO.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(fO.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||cV(t,this.initPTS[e.cc],(function(){i.textCodec=sV,r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))}},{key:"_appendCues",value:function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;vd(e).call(e,(function(e){return oH(i,e)}))}else{var n=this.tracks[t];if(!n)return;var a=n.default?"default":"subtitles"+t;r.trigger(fO.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===kO&&this.onFragLoaded(fO.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!==yO||"NONE"!==this.closedCaptionsForLevel(r))for(var n=0;n<i.length;n++){var a=i[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();var s=this.extractCea608Data(a);this.cea608Parser1.addData(i[n].pts,s[0]),this.cea608Parser2.addData(i[n].pts,s[1])}}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.endOffsetSubtitles,a=t.type,s=this.media;if(s&&!(s.currentTime<i)){if(!a||"video"===a){var o,l=this.captionsTracks;vd(o=gv(l)).call(o,(function(e){return uH(l[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u,c=this.textTracks;vd(u=gv(c)).call(u,(function(e){return uH(c[e],r,n)}))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],r=31&e[0],i=2,n=0;n<r;n++){var a=e[i++],s=127&e[i++],o=127&e[i++];if(0!==s||0!==o)if(0!=(4&a)){var l=3&a;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}();function EV(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function kV(e,t){return!!e&&e.kind===EV(t)&&aK(t,e)}var TV=/\s/,SV={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++)TV.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=eV(MS(l).call(l)),g=nV(t,r,v);null!=e&&null!=(d=e.cues)&&d.getCueById(g)||((a=new c(t,r,v)).id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return e&&u.length&&(mA(u).call(u,(function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),vd(u).call(u,(function(t){return oH(e,t)}))),u}};var AV=/(\d+)-(\d+)\/(\d+)/,LV=function(){function e(r){t(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=r.fetchSetup||bV,this.controller=new self.AbortController,this.stats=new nN}return Fc(e,[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(LO({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s=r.onProgress,o="arraybuffer"===e.responseType,l=o?"byteLength":"length",u=t.loadPolicy,c=u.maxTimeToFirstByteMs,h=u.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=c&&lO(c)?c:h,this.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),(JG(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(a){i.response=i.loader=a;var l=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=h,i.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),h-(l-n.loading.start)),!a.ok){var u=a.status,c=a.statusText;throw new RV(c||"fetch, bad network response",u,a)}return n.loading.first=l,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=AV.exec(e);if(t)return Ak(t[2])-Ak(t[1])+1}(t);if(lO(r))return r}var i=e.get("Content-Length");if(i)return Ak(i)}(a.headers)||n.total,s&&lO(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,s):o?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var c={url:o.url,data:a,code:o.status};s&&!lO(t.highWaterMark)&&s(n,e,a,o),r.onSuccess(c,n,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;r.onError({code:a,text:s},e,t?t.details:null,n)}}))}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?bS(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4?arguments[4]:void 0,a=new SB,s=e.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(t,r,a.flush().buffer,e),tk.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return t.loaded+=u,u<i||a.dataLength?(a.push(l),a.dataLength>=i&&n(t,r,a.flush().buffer,e)):n(t,r,l.buffer,e),o()})).catch((function(){return tk.reject()}))}()}}]),e}();function bV(e,t){return new self.Request(e.url,t)}var RV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e)).code=void 0,s.details=void 0,s.code=n,s.details=a,s}return Fc(i)}(tC(Error)),IV=/^age:\s*[\d.]+\s*$/im,DV=function(){function e(r){t(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=r&&r.xhrSetup||null,this.stats=new nN,this.retryDelay=0}return Fc(e,[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?tk.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return a(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){e.callbacks.onError({code:i.status,text:t.message},r,i,n)})):this.openAndSendXhr(i,r,t)}}},{key:"openAndSendXhr",value:function(e,t,r){var i,n,a;e.readyState||e.open("GET",t.url,!0);var s=t.headers,o=r.loadPolicy,l=o.maxTimeToFirstByteMs,u=o.maxLoadTimeMs;if(s)for(var c in s)e.setRequestHeader(c,s[c]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=sT(i=this.readystatechange).call(i,this),e.onprogress=sT(n=this.loadprogress).call(n,this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&lO(l)?l:u,this.requestTimeout=Wf(sT(a=this.loadtimeout).call(a,this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,n=this.config;if(!r.aborted&&i>=2){var a;if(0===r.loading.first)if(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=Wf(sT(a=this.loadtimeout).call(a,this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start));if(4===i){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var s=t.status,o="text"===t.responseType?t.responseText:null;if(s>=200&&s<300){var l=null!=o?o:t.response;if(null!=l){r.loading.end=Math.max(self.performance.now(),r.loading.first);var u="arraybuffer"===t.responseType?l.byteLength:l.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;var h={url:t.responseURL,data:l,code:s};return void this.callbacks.onSuccess(h,r,e,t)}}var d,f=n.loadPolicy.errorRetry;if(bF(f,r.retry,!1,{url:e.url,data:void 0,code:s}))this.retry(f);else xO.error(_d(d="".concat(s," while loading ")).call(d,e.url)),this.callbacks.onError({code:s,text:t.statusText},e,t,r)}}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(bF(e,this.stats.retry,!0))this.retry(e);else{var t;xO.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=AF(e,o.retry),o.retry++,xO.warn(_d(t=_d(r=_d(i=_d(n="".concat(status?"HTTP Status "+status:"Timeout"," while loading ")).call(n,null==s?void 0:s.url,", retrying ")).call(i,o.retry,"/")).call(r,e.maxNumRetry," in ")).call(t,this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=Wf(sT(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&&IV.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?bS(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp("^".concat(e,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}]),e}(),_V=RO(RO({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:DV,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:gF,bufferController:fK,capLevelController:pK,errorController:xF,fpsController:aH,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:DU,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:SV,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:RH,subtitleTrackController:hH,timelineController:yV,audioStreamController:sK,audioTrackController:lK,emeController:iH,cmcdController:ZK,contentSteeringController:eH,interstitialsController:bH});function wV(e){var t;return e&&"object"===Cc(e)?Pk(e)?_k(e).call(e,wV):kC(t=gv(e)).call(t,(function(t,r){return t[r]=wV(e[r]),t}),{}):e}function CV(e,t){var r=e.loader;r!==LV&&r!==DV?(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=LV,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}function PV(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function xV(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,jI(n?RO({type:n},i):i))}return a}var MV=function(){var e=PV();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();var OV=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){i.hls&&i.hls.trigger(fO.EVENT_CUE_ENTER,{})},this.hls=r,this._registerListeners()}return Fc(e,[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fO.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fO.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&&lH(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 sH(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=PV();if(s)for(var o=0;o<a.length;o++){var l=a[o].type;if((l!==$B.emsg||i)&&n){var u=WB(a[o].data);if(u){var c=a[o].pts,h=c+a[o].duration;h>MV&&(h=MV),h-c<=0&&(h=c+.25);for(var d=0;d<u.length;d++){var f=u[d];if(!zB(f)){this.updateId3CueEnds(c,l);var v=xV(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===MV&&(a.endTime=e)}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,a=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(l||u))uH(a,r,i,"audio"===n?function(e){return e.type===$B.audioId3&&u}:"video"===n?function(e){return e.type===$B.emsg&&l}:function(e){return e.type===$B.audioId3&&u||e.type===$B.emsg&&l})}}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;this.updateDateRangeCues(r,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var r=this;if(this.media&&e.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var i,n=this.id3Track,a=e.dateRanges,s=gv(a),o=this.dateRangeCuesAppended;if(n&&t)if(null!=(i=n.cues)&&i.length)for(var l,u=xk(l=gv(o)).call(l,(function(e){return!uD(s).call(s,e)})),c=function(){var e,t=u[h],i=o[t].cues;delete o[t],vd(e=gv(i)).call(e,(function(e){try{var t=i[e];t.removeEventListener("enter",r.onEventCueEnter),n.removeCue(t)}catch(a){}}))},h=u.length;h--;)c();else o=this.dateRangeCuesAppended={};var d=e.fragments[e.fragments.length-1];if(0!==s.length&&lO(null==d?void 0:d.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=PV(),v=function(){var e=s[g],t=a[e],i=t.startTime,n=o[e],l=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,c=MV,h=t.duration;if(t.endDate&&null!==h)c=i+h,u=!0;else if(t.endOnNext&&!u){var d=kC(s).call(s,(function(e,r){if(r!==t.id){var i=a[r];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate<e.startDate))return i}return e}),null);d&&(c=d.startTime,u=!0)}for(var v,p,m=gv(t.attr),y=0;y<m.length;y++){var E=m[y];if("ID"!==(p=E)&&"CLASS"!==p&&"CUE"!==p&&"START-DATE"!==p&&"DURATION"!==p&&"END-DATE"!==p&&"END-ON-NEXT"!==p){var k=l[E];if(k)u&&!n.durationKnown?k.endTime=c:Math.abs(k.startTime-i)>.01&&(k.startTime=i,k.endTime=c);else if(f){var T=t.attr[E];tU(E)&&(v=T,T=Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=xV(f,i,c,{key:E,data:T},$B.dateRange);S&&(S.id=e,r.id3Track.addCue(S),l[E]=S,r.hls.config.interstitialsController&&("X-ASSET-LIST"!==E&&"X-ASSET-URL"!==E||S.addEventListener("enter",r.onEventCueEnter)))}}}o[e]={cues:l,dateRange:t,durationKnown:u}},g=0;g<s.length;g++)v()}}}}]),e}(),FV=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=i.media,t=i.hls.latestLevelDetails;if(e&&t){i.currentTime=e.currentTime;var r=i.computeLatency();if(null!==r){i._latency=r;var n=i.config,a=n.lowLatencyMode,s=n.maxLiveSyncPlaybackRate;if(a&&1!==s&&t.live){var o=i.targetLatency;if(null!==o){var l=r-o;if(l<Math.min(i.maxLatency,o+t.targetduration)&&l>.05&&i.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),c=Math.round(2/(1+Math.exp(-.75*l-i.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=r,this.config=r.config,this.registerListeners()}return Fc(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e,t=this.config;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;var r=null==(e=this.hls)?void 0:e.latestLevelDetails;return r?t.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var c=i;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var r=this.hls.latestLevelDetails;if(null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.hls.latestLevelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.hls.latestLevelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){this.hls.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){this.hls.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(fO.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===dO.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}(),NV=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,e,"level-controller"))._levels=[],a._firstLevel=-1,a._maxAutoLevel=-1,a._startLevel=void 0,a.currentLevel=null,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.steering=void 0,a.onParsedComplete=void 0,a.steering=n,a._registerListeners(),a}return Fc(i,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fO.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){var e=this._levels;vd(e).call(e,(function(e){e.loadError=0,e.fragmentError=0})),Ih(Rh(i.prototype),"stopLoad",this).call(this)}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var r,i=this,n=this.hls.config.preferManagedMediaSource,a=[],s={},o={},l=!1,u=!1,c=!1;vd(r=t.levels).call(r,(function(e){var t,r,h,d,f,v,g,p=e.attrs,m=e.audioCodec,y=e.videoCodec;m&&(e.audioCodec=m=jO(m,n)||void 0),0===(null==(g=y)?void 0:av(g).call(g,"avc1"))&&(y=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var n,a=i.shift()+".";a+=Ak(i.shift()).toString(16),a+=Fv(n="000"+Ak(i.shift()).toString(16)).call(n,-4),t[r]=a}}return t.join(",")}(y));var E=e.width,k=e.height,T=e.unknownCodecs,S=T?T.length:0;if(T)for(var A=S;A--;){var L,b=T[A];if(i.isAudioSupported(b))e.audioCodec=m=m?_d(L="".concat(m,",")).call(L,b):b,S--,FO.audio[m.substring(0,4)]=2;else if(i.isVideoSupported(b)){var R;e.videoCodec=y=y?_d(R="".concat(y,",")).call(R,b):b,S--,FO.video[y.substring(0,4)]=2}}if(l||(l=!(!E||!k)),u||(u=!!y),c||(c=!!m),!(S||m&&!i.isAudioSupported(m)||y&&!i.isVideoSupported(y))){var I=p.CODECS,D=p["FRAME-RATE"],_=p["HDCP-LEVEL"],w=p["PATHWAY-ID"],C=p.RESOLUTION,P=p["VIDEO-RANGE"],x="".concat(w||".","-"),M=_d(t=_d(r=_d(h=_d(d=_d(f=_d(v="".concat(x)).call(v,e.bitrate,"-")).call(f,C,"-")).call(d,D,"-")).call(h,I,"-")).call(r,P,"-")).call(t,_);if(s[M])if(s[M].uri===e.url||e.attrs["PATHWAY-ID"])s[M].addGroupId("audio",p.AUDIO),s[M].addGroupId("text",p.SUBTITLES);else{var O=o[M]+=1;e.attrs["PATHWAY-ID"]=new Array(O+1).join(".");var F=new nF(e);s[M]=F,a.push(F)}else{var N=new nF(e);s[M]=N,o[M]=1,a.push(N)}}})),this.filterAndSortMediaOptions(a,t,l,u,c)}},{key:"isAudioSupported",value:function(e){return NO(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return NO(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,i,n){var a=this,s=[],o=[],l=e;if((r||i)&&n&&(l=xk(l).call(l,(function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&(!!(t=i)&&av(JO).call(JO,t)>-1)}))),0!==l.length){var u;if(t.audioTracks)UV(s=xk(u=t.audioTracks).call(u,(function(e){return!e.audioCodec||a.isAudioSupported(e.audioCodec)})));t.subtitles&&UV(o=t.subtitles);var c=Fv(l).call(l,0);mA(l).call(l,(function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return av(JO).call(JO,e.videoRange)-av(JO).call(JO,t.videoRange);if(e.videoCodec!==t.videoCodec){var i=GO(e.videoCodec),n=GO(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=KO(e.codecSet),s=KO(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==c.length)for(var d=0;d<c.length;d++)if(c[d].pathwayId===l[0].pathwayId){h=c[d];break}this._levels=l;for(var f=0;f<l.length;f++)if(l[f]===h){var v,g;this._firstLevel=f;var p=h.bitrate,m=this.hls.bandwidthEstimate;if(this.log(_d(v="manifest loaded, ".concat(l.length," level(s) found, first bitrate: ")).call(v,p)),void 0===(null==(g=this.hls.userConfig)?void 0:g.abrEwmaDefaultEstimate)){var y=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);y>m&&m===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=y)}break}var E=n&&!i,k={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!E&&KT(s).call(s,(function(e){return!!e.url}))};this.hls.trigger(fO.MANIFEST_PARSED,k)}else tk.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: ".concat(jI(t.levels[0].attrs)));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.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(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,l.length-1)}var h=this.currentLevelIndex,d=this.currentLevel,f=d?d.attrs["PATHWAY-ID"]:void 0,v=l[e],g=v.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=v,h!==e||!d||f!==g){this.log(_d(t=_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Switching to level ".concat(e," (")).call(o,v.height?v.height+"p ":"")).call(s,v.videoRange?v.videoRange+" ":"")).call(a,v.codecSet?v.codecSet+" ":"","@")).call(n,v.bitrate,")")).call(i,g?" with Pathway "+g:""," from level ")).call(r,h)).call(t,f?" with Pathway "+f:""));var p={level:e,attrs:v.attrs,details:v.details,bitrate:v.bitrate,averageBitrate:v.averageBitrate,maxBitrate:v.maxBitrate,realBitrate:v.realBitrate,width:v.width,height:v.height,codecSet:v.codecSet,audioCodec:v.audioCodec,videoCodec:v.videoCodec,audioGroups:v.audioGroups,subtitleGroups:v.subtitleGroups,loaded:v.loaded,loadError:v.loadError,fragmentError:v.fragmentError,name:v.name,id:v.id,uri:v.uri,url:v.url,urlId:0,audioGroupIds:v.audioGroupIds,textGroupIds:v.textGroupIds};this.hls.trigger(fO.LEVEL_SWITCHING,p);var m=v.details;if(!m||m.live){var y=this.switchParams(v.uri,null==d?void 0:d.details,m);this.loadPlaylist(y)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t,r=this.steering.pathways(),i=xk(e).call(e,(function(e){return-1!==av(r).call(r,e)}));if(e.length<1)return void this.warn(_d(t="pathwayPriority ".concat(e," should contain at least one pathway from list: ")).call(t,r));this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===gO&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===yO){var i,n=r.elementaryStreams;if(!KT(i=gv(n)).call(i,(function(e){return!!n[e]})))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of ".concat(a.loadError," on frag buffered")),a.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n=t.level,a=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index ".concat(n)),void(null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(n,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var o=this.getUrlWithDirectives(e.uri,t),l=this.currentLevelIndex,u=e.attrs["PATHWAY-ID"],c=e.details,h=null==c?void 0:c.age;this.log(_d(r=_d(n=_d(a=_d(s="Loading level index ".concat(l)).call(s,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,u?" Pathway "+u:"")).call(n,h&&c.live?" age "+h.toFixed(1)+(c.type&&" "+c.type||""):""," ")).call(r,o)),this.hls.trigger(fO.LEVEL_LOADING,{url:o,level:l,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t,r,i=this;if(1!==this._levels.length){var n=xk(t=this._levels).call(t,(function(t,r){if(r!==e)return!0;var n;(i.steering&&i.steering.removeLevel(t),t===i.currentLevel)&&(i.currentLevel=null,i.currentLevelIndex=-1,t.details&&vd(n=t.details.fragments).call(n,(function(e){return e.level=-1})));return!1}));rB(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(fO.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(fO.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}]),i}(oK);function UV(e){var t={};vd(e).call(e,(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var BV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s){var o;return t(this,i),(o=r.call(this,"gap-controller",s.logger)).config=void 0,o.media=null,o.fragmentTracker=void 0,o.hls=void 0,o.nudgeRetry=0,o.stallReported=!1,o.stalled=null,o.moved=!1,o.seeking=!1,o.ended=0,o.config=e,o.media=n,o.fragmentTracker=a,o.hls=s,o}return Fc(i,[{key:"destroy",value:function(){this.media=null,this.hls=this.fragmentTracker=null}},{key:"poll",value:function(e,t,r,i){var n=this.config,a=this.media,s=this.stalled;if(null!==a){var o=a.currentTime,l=a.seeking,u=this.seeking&&!l,c=!this.seeking&&l;if(this.seeking=l,o===e)if(c||u)this.stalled=null;else{if(a.paused&&!l||a.ended||0===a.playbackRate||!qN.getBuffered(a).length)return!this.ended&&a.ended&&(this.ended=o||1,this.hls.trigger(fO.MEDIA_ENDED,{stalled:!1})),void(this.nudgeRetry=0);var h=qN.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===mB&&(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(fO.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(h),!this.media)return}var k=qN.bufferInfo(a,o,n.maxBufferHole);this._tryFixBufferStall(k,E)}else this.stalled=y}else if(e&&(this.ended=0),this.moved=!0,l||(this.nudgeRetry=0),null!==s){if(this.stallReported){var T,S=self.performance.now()-s;this.warn(_d(T="playback not stuck anymore @".concat(o,", after ")).call(T,Math.round(S),"ms")),this.stallReported=!1}this.stalled=null}}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s)if(this._trySkipBufferHole(s)||!this.media)return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(this.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}}},{key:"_reportStall",value:function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){var i;this.stallReported=!0;var n=new Error(_d(i="Playback stalling at @".concat(r.currentTime," due to low buffer (")).call(i,jI(e),")"));this.warn(n.message),t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.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=qN.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,yO);f&&s<f.end&&(d=!0)}if(!d){var v=e||h.getAppendedFrag(n,yO);if(v){for(var g=!1,p=v.end;p<s;){var m=h.getPartialFragment(p);if(!m){g=!0;break}p+=m.duration}if(g)return 0}}}var y=Math.max(s+.05,n+.1);if(this.warn(_d(c="skipping hole, adjusting currentTime from ".concat(n," to ")).call(c,y)),this.moved=!0,this.stalled=null,i.currentTime=y,e&&!e.gap){var E,k=new Error(_d(E="fragment loaded with buffer holes, seeking from ".concat(n," to ")).call(E,y));r.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:k,reason:k.message,frag:e})}return y}}return 0}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var n=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var a,s=n+(i+1)*e.nudgeOffset,o=new Error(_d(a="Nudging 'currentTime' from ".concat(n," to ")).call(a,s));this.warn(o.message),r.currentTime=s,t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l,u=new Error(_d(l="Playhead still not moving while enough data buffered @".concat(n," after ")).call(l,e.nudgeMaxRetry," nudges"));this.error(u.message),t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_STALLED_ERROR,error:u,fatal:!0})}}}}]),i}(IO);function GV(){return self.SourceBuffer||self.WebKitSourceBuffer}function KV(){if(!MO())return!1;var e=GV();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var HV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"stream-controller",yO)).audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s._hasEnoughToStart=!1,s.altAudio=0,s.audioOnly=!1,s.fragPlaying=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s.onMediaPlaying=function(){var e=s.gapController;e&&(e.ended=0),s.tick()},s.onMediaSeeked=function(){var e=s.media,t=e?e.currentTime:null;lO(t)&&s.log("Media seeked to ".concat(t.toFixed(3)));var r=s.getMainFwdBufferInfo();null!==r&&0!==r.len?s.tick():s.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"))},s.registerListeners(),s}return Fc(i,[{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(fO.BUFFER_CREATED,this.onBufferCreated,this),e.on(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(fO.BUFFER_CREATED,this.onBufferCreated,this),e.off(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this)}},{key:"startLoad",value:function(e,t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var n=i.startLevel;-1===n&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.firstAutoLevel),i.nextLoadLevel=n,this.level=i.loadLevel,this._hasEnoughToStart=!1}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r),this.state=cB,this.nextLoadPosition=this.lastCurrentTime=e,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=uB}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,Ih(Rh(i.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case kB: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=cB;break}if(this.hls.nextLoadLevel!==this.level){this.state=cB;break}break;case fB: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=cB}}this.state===cB&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){Ih(Rh(i.prototype),"onTickEnd",this).call(this),this.checkBuffer(),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[n]){var a=r[n],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return 2===this.altAudio&&(l.type="video"),this.hls.trigger(fO.BUFFER_EOS,l),void(this.state=mB)}if(this.buffering){var u;if(e.loadLevel!==n&&-1===e.manualLevel)this.log(_d(u="Adapting to level ".concat(n," from level ")).call(u,this.level));this.level=e.nextLoadLevel=n;var c=a.details;if(!c||this.state===kB||this.waitForLive(a))return this.level=n,this.state=kB,void(this.startFragRequested=!1);var h=s.len,d=this.getMaxBufferLength(a.maxBitrate);if(!(h>=d)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:s.end,v=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&v&&uN(v)&&this.fragmentTracker.getState(v)!==UF){var g,p=(null!=(g=this.backtrackFragment)?g:v).sn-c.startSN,m=c.fragments[p-1];m&&v.cc===m.cc&&(v=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,f)){if(!v.gap){var y=this.audioOnly&&!this.altAudio?aN:sN,E=(y===sN?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,y,yO)}v=this.getNextFragmentLoopLoading(v,c,s,yO,d)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,a,f))}}}}}}},{key:"loadFragment",value:function(e,t,r){var n=this.fragmentTracker.getState(e);if(n===OF||n===NF)if(uN(e))if(this.bitrateTest){var a;this.log(_d(a="Fragment ".concat(e.sn," of level ")).call(a,e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,yO)}},{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 hB:case dB:case fB:case gB:case pB:this.state=cB}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,t){Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,e,t,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,t){Ih(Rh(i.prototype),"onMediaAttached",this).call(this,e,t);var r=t.media;r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked),r.addEventListener("playing",this.onMediaPlaying),r.addEventListener("seeked",this.onMediaSeeked),this.gapController=new BV(this.config,r,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;r&&(r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t),!!t.transferMedia||(this._hasEnoughToStart=!1)}},{key:"triggerEnded",value:function(){var e=this.gapController;if(e){var t;if(e.ended)return;e.ended=(null==(t=this.media)?void 0:t.currentTime)||1}this.hls.trigger(fO.MEDIA_ENDED,{stalled:!1})}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(fO.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){var r,i,n,a=!1,s=!1;vd(r=t.levels).call(r,(function(e){var t=e.audioCodec;t&&(a=a||-1!==av(t).call(t,"mp4a.40.2"),s=s||-1!==av(t).call(t,"mp4a.40.5"))})),this.audioCodecSwitch=a&&s&&!("function"==typeof(null==(n=GV())||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===cB){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=kB)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n,a,s,o,l,u,c=this.levels,h=this.startFragRequested,d=t.level,f=t.details,v=f.totalduration;if(c){this.log(_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Level ".concat(d," loaded [")).call(o,f.startSN,",")).call(s,f.endSN,"]")).call(a,f.lastPartSn?_d(l="[part-".concat(f.lastPartSn,"-")).call(l,f.lastPartIndex,"]"):"",", cc [")).call(n,f.startCC,", ")).call(i,f.endCC,"] duration:")).call(r,v));var g=t.levelInfo,p=this.fragCurrent;!p||this.state!==dB&&this.state!==fB||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(fO.LEVEL_UPDATED,{details:f,level:d}),this.state===kB){if(this.waitForCdnTuneIn(f))return;this.state=cB}h&&f.live&&this.synchronizeToLiveEdge(f),this.tick()}else this.warn("Levels were reset while loading level ".concat(d))}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragmentStart,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var l,u,c=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if(!o&&r.readyState<4||n<s-c)if(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState)this.warn(_d(l=_d(u="Playback: ".concat(n.toFixed(3)," is located too far from the end of live sliding playlist: ")).call(u,s,", reset currentTime to : ")).call(l,i.toFixed(3))),r.currentTime=i}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r,i,n=e.frag,a=e.part,s=e.payload,o=this.levels;if(o){var l=o[n.level];if(l){var u,c=l.details;if(!c)return this.warn(_d(u="Dropping fragment ".concat(n.sn," of level ")).call(u,n.level," after level details were reset")),void this.fragmentTracker.removeFragment(n);var h=l.videoCodec,d=c.PTSKnown||!c.live,f=null==(i=n.initSegment)?void 0:i.data,v=this._getAudioCodec(l),g=this.transmuxer=this.transmuxer||new rK(this.hls,yO,sT(t=this._handleTransmuxComplete).call(t,this),sT(r=this._handleTransmuxerFlush).call(r,this)),p=a?a.index:-1,m=-1!==p,y=new jN(n.level,n.sn,n.stats.chunkCount,s.byteLength,p,m),E=this.initPTS[n.cc];g.push(s,f,v,h,n,a,c.totalduration,d,y,E)}else this.warn("Level ".concat(n.level," not found on progress"))}else{var k;this.warn(_d(k="Levels were reset while fragment load was in progress. Fragment ".concat(n.sn," of level ")).call(k,n.level," will not be buffered"))}}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this.hls,i=2===this.altAudio;if(vF(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(fO.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(fO.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=vF(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===yO;if(n){var a,s,o;if(this.fragContextChanged(r))return this.warn(_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state)),void(this.state===pB&&(this.state=cB));var l=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),uN(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=yB;else switch(t.details){case dO.FRAG_GAP:case dO.FRAG_PARSING_ERROR:case dO.FRAG_DECRYPT_ERROR:case dO.FRAG_LOAD_ERROR:case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_ERROR:case dO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(yO,t);break;case dO.LEVEL_LOAD_ERROR:case dO.LEVEL_LOAD_TIMEOUT:case dO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==kB||(null==(r=t.context)?void 0:r.type)!==gO||(this.state=cB);break;case dO.BUFFER_APPEND_ERROR:case dO.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===dO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case dO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"checkBuffer",value:function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this._hasEnoughToStart||!qN.getBuffered(e).length){var r=this.state,i=r!==cB?this.fragCurrent:null,n=this.getLevelDetails();t.poll(this.lastCurrentTime,i,n,r)}this.lastCurrentTime=e.currentTime}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=cB,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==aN||this.audioOnly&&!this.altAudio){var i=(r===sN?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,yO),this.tick()}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0){var i;if(e.seeking)return void this.log(_d(i="could not seek to ".concat(r,", already seeking at ")).call(i,t));var n=this.getLevelDetails(),a=this.config.timelineOffset;a&&r&&(r+=(null==n?void 0:n.appliedTimelineOffset)||a);var s,o,l=qN.getBuffered(e),u=l.length?l.start(0):0,c=u-r,h=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(c>0&&(c<h||this.loadingParts&&c<2*((null==n?void 0:n.partTarget)||0))&&(this.log("adjusting start position by ".concat(c," to match buffer start")),r+=c,this.startPosition=r),t<r)this.log(_d(s=_d(o="seek to target start position ".concat(r," from current time ")).call(o,t," buffer start ")).call(s,u)),e.currentTime=r}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==av(t).call(t,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(e){var i=r.hls,n=null==e?void 0:e.frag;if(n&&!r.fragContextChanged(n)){t.fragmentError=0,r.state=cB,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(fO.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=gB,f){if(null!=f&&f.tracks){var p=o.initSegment||o;this._bufferInitSegment(u,f.tracks,p,a),i.trigger(fO.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:f.tracks})}var m=f.initPTS,y=f.timescale;lO(m)&&(this.initPTS[o.cc]={baseTime:m,timescale:y},i.trigger(fO.INIT_PTS_FOUND,{frag:o,id:r,initPTS:m,timescale:y}))}if(c&&v){var E=v.fragments[o.sn-1-v.startSN],k=o.sn===v.startSN,T=!E||o.cc>E.cc;if(!1!==n.independent){var S=c.startPTS,A=c.endPTS,L=c.startDTS,b=c.endDTS;if(l)l.elementaryStreams[c.type]={startPTS:S,endPTS:A,startDTS:L,endDTS:b};else if(c.firstKeyFrame&&c.independent&&1===a.id&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){var R=this.getMainFwdBufferInfo(),I=(R?R.end:this.getLoadPosition())+this.config.maxBufferHole,D=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!k&&I<D-this.config.maxBufferHole&&!T)return void this.backtrack(o);T&&(o.gap=!0),o.setElementaryStreamInfo(c.type,o.start,A,o.start,b,!0)}else k&&S-(v.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(c.type,S,A,L,b),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,l,a,k||T)}else{if(!k&&!T)return void this.backtrack(o);o.gap=!0}}if(g){var _=g.startPTS,w=g.endPTS,C=g.startDTS,P=g.endDTS;l&&(l.elementaryStreams[aN]={startPTS:_,endPTS:w,startDTS:C,endDTS:P}),o.setElementaryStreamInfo(aN,_,w,C,P),this.bufferFragmentData(g,o,l,a)}if(v&&null!=d&&null!=(t=d.samples)&&t.length){var x={id:r,frag:o,details:v,samples:d.samples};i.trigger(fO.FRAG_PARSING_METADATA,x)}if(v&&h){var M={id:r,frag:o,details:v,samples:h.samples};i.trigger(fO.FRAG_PARSING_USERDATA,M)}}}else this.resetWhenMissingContext(a)}},{key:"_bufferInitSegment",value:function(e,t,r,i){var n=this;if(this.state===gB){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a,s,o=t.audio,l=t.video,u=t.audiovideo;if(o){var c,h,d,f=YO(o.codec,e.audioCodec);"mp4a"===f&&(f="mp4a.40.5");var v,g=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){f&&(f=-1!==av(f).call(f,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var p=o.metadata;p&&"channelCount"in p&&1!==(p.channelCount||1)&&-1===av(g).call(g,"firefox")&&(f="mp4a.40.5")}if(f&&-1!==av(f).call(f,"mp4a.40.5")&&-1!==av(g).call(g,"android")&&"audio/mpeg"!==o.container&&(f="mp4a.40.2",this.log("Android: force audio codec to ".concat(f))),e.audioCodec&&e.audioCodec!==f)this.log(_d(v='Swapping manifest audio codec "'.concat(e.audioCodec,'" for "')).call(v,f,'"'));o.levelCodec=f,o.id="main",this.log(_d(c=_d(h=_d(d="Init audio buffer, container:".concat(o.container,", codecs[selected/level/parsed]=[")).call(d,f||"","/")).call(h,e.audioCodec||"","/")).call(c,o.codec,"]")),delete t.audiovideo}if(l){var m,y,E;l.levelCodec=e.videoCodec,l.id="main";var k=l.codec;if(4===(null==k?void 0:k.length))switch(k){case"hvc1":case"hev1":l.codec="hvc1.1.6.L120.90";break;case"av01":l.codec="av01.0.04M.08";break;case"avc1":l.codec="avc1.42e01e"}this.log(_d(m=_d(y=_d(E="Init video buffer, container:".concat(l.container,", codecs[level/parsed]=[")).call(E,e.videoCodec||"","/")).call(y,k)).call(m,l.codec!==k?" parsed-corrected="+l.codec:"","}]")),delete t.audiovideo}if(u)this.log(_d(a=_d(s="Init audiovideo buffer, container:".concat(u.container,", codecs[level/parsed]=[")).call(s,e.codecs,"/")).call(a,u.codec,"]")),delete t.video,delete t.audio;var T=gv(t);if(T.length){if(this.hls.trigger(fO.BUFFER_CODECS,t),!this.hls)return;vd(T).call(T,(function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(fO.BUFFER_APPENDING,{type:e,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,yO)}},{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=cB}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(qN.isBuffered(e,r)?t=this.getAppendedFrag(r):qN.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(fO.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(fO.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 lO(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(lO(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?mF(null,r.fragments,t):null);if(i){var n=i.programDateTime;if(null!==n){var a=n+1e3*(t-i.start);return new Date(a)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),i}(TB),VV=function(){function e(r){t(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=r}return Fc(e,[{key:"abort",value:function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}}},{key:"detach",value:function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}},{key:"createKeyLoadError",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dO.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 HN({type:hO.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}},{key:"loadClear",value:function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(){var e=t[s];if(n<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),"break"},s=0;s<t.length;s++){if("break"===a())break}}},{key:"load",value:function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var r,i;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return tk.reject(this.createKeyLoadError(e,dO.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return tk.reject(this.createKeyLoadError(e,dO.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(s,'"'))));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return n.key=l.decryptdata.key,tk.resolve({frag:e,keyInfo:l});if(null!=(i=l)&&i.keyLoadPromise)switch(null==(o=l.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return l.keyLoadPromise.then((function(t){return n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return tk.reject(this.createKeyLoadError(e,dO.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(n.method,'"'))))}}},{key:"loadKeyEME",value:function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return tk.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new tk((function(a,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(e,t,i,n){var o=i.frag,l=i.keyInfo,u=i.url;if(!o.decryptdata||l!==r.keyUriToKeyInfo[u])return s(r.createKeyLoadError(o,dO.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,dO.KEY_LOAD_ERROR,new Error(_d(l="HTTP Error ".concat(e.code," loading key ")).call(l,e.text)),n,RO({url:o.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,dO.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,dO.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 jV(e){switch(e.type){case pO:return EO;case mO:return kO;default:return yO}}function YV(e,t){var r=e.url;return void 0!==r&&0!==av(r).call(r,"data:")||(r=t.url),r}var qV=function(){function e(r){t(this,e),this.hls=void 0,this.loaders=aT(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=r,this.registerListeners()}return Fc(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(fO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.LEVEL_LOADING,this.onLevelLoading,this),e.off(fO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(fO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(fO.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:vO,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:gO,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:pO,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:mO,url:n,deliveryDirectives:a,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[gO];if(r){var i,n=r.context;n&&!KT(i=t.levels).call(i,(function(e){return e===n.levelOrTrack}))&&(r.abort(),delete this.loaders[gO])}}},{key:"load",value:function(e){var t,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(e);if(s){var o=this.hls.logger,l=s.context;if(l&&l.levelOrTrack===e.levelOrTrack&&(l.url===e.url||l.deliveryDirectives&&!e.deliveryDirectives)){var u;if(l.url===e.url)o.log("[playlist-loader]: ignore ".concat(e.url," ongoing request"));else o.log(_d(u="[playlist-loader]: ignore ".concat(e.url," in favor of ")).call(u,l.url));return}o.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if((r=e.type===vO?a.manifestLoadPolicy.default:LO({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),lO(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===gO&&null!==e.level?i=this.hls.levels[e.level].details:e.type===pO&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===mO&&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=LO({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var f=r.errorRetry||r.timeoutRetry||{},v={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},g={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===av(s).call(s,"#EXTM3U")?(t.parsing.start=performance.now(),UU.isMediaPlaylist(s)||r.type!==vO?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,v,g)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e,t=this.hls,r=t.config,i=r.autoStartLoad,n=r.startPosition,a=t.forceStartLoad;if(i||a)this.hls.logger.log(_d(e="".concat(i?"auto":"force"," startLoad with configured startPosition ")).call(e,n)),this.hls.startLoad(n)}}},{key:"handleMasterPlaylist",value:function(e,t,r,i){var n=this.hls,a=e.data,s=YV(e,r),o=UU.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=UU.parseMasterPlaylistMedia(a,s,o),g=v.AUDIO,p=void 0===g?[]:g,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];if(p.length)KT(p).call(p,(function(e){return!e.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new eU({}),bitrate:0,url:""}));n.trigger(fO.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=YV(e,r),c=lO(o)?o:lO(s)?s:0,h=jV(r),d=UU.parseLevelPlaylist(e.data,u,c,h,0,this.variableList);if(l===vO){var f={attrs:new eU({}),bitrate:0,details:d,name:"",url:u};d.requestScheduled=t.loading.start+ZU(d,0),a.trigger(fO.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(fO.ERROR,{type:hO.NETWORK_ERROR,details:dO.MANIFEST_PARSING_ERROR,fatal:t.type===vO,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}},{key:"handleNetworkError",value:function(e,t){var r,i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=_d(r="A network ".concat(n?"timeout":"error"+(a?" (status "+a.code+")":"")," occurred while loading ")).call(r,e.type);if(e.type===gO)o+=_d(i=": ".concat(e.level," id: ")).call(i,e.id);else if(e.type===pO||e.type===mO){var l;o+=_d(l=" id: ".concat(e.id,' group-id: "')).call(l,e.groupId,'"')}var u=new Error(o);this.hls.logger.warn("[playlist-loader]: ".concat(o));var c=dO.UNKNOWN,h=!1,d=this.getInternalLoader(e);switch(e.type){case vO:c=n?dO.MANIFEST_LOAD_TIMEOUT:dO.MANIFEST_LOAD_ERROR,h=!0;break;case gO:c=n?dO.LEVEL_LOAD_TIMEOUT:dO.LEVEL_LOAD_ERROR,h=!1;break;case pO:c=n?dO.AUDIO_TRACK_LOAD_TIMEOUT:dO.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case mO:c=n?dO.SUBTITLE_TRACK_LOAD_TIMEOUT:dO.SUBTITLE_LOAD_ERROR,h=!1}d&&this.resetInternalLoader(e.type);var f={type:hO.NETWORK_ERROR,details:c,fatal:h,url:e.url,loader:d,context:e,error:u,networkDetails:t,stats:s};if(a){var v=(null==t?void 0:t.url)||e.url;f.response=RO({url:v,data:void 0},a)}this.hls.trigger(fO.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=YV(t,i),f=jV(i),v="number"==typeof i.level&&f===yO?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var g=e.playlistParsingError;if(g)s.trigger(fO.ERROR,{type:hO.NETWORK_ERROR,details:dO.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 vO:case gO:s.trigger(fO.LEVEL_LOADED,{details:e,levelInfo:i.levelOrTrack||s.levels[0],level:v||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===vO});break;case pO:s.trigger(fO.AUDIO_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case mO:s.trigger(fO.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(fO.ERROR,{type:hO.NETWORK_ERROR,details:dO.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}(),WV=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new LB,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var i=this.logger=function(e,t,r){var i=wO();if("object"===("undefined"==typeof console?"undefined":Cc(console))&&!0===e||"object"===Cc(e)){var n=["debug","log","info","warn","error"];vd(n).call(n,(function(t){i[t]=CO(t,e,r)}));try{i.log('Debug logs enabled for "'.concat(t,'" in hls.js version ',"1.6.0-beta.2"))}catch(a){return wO()}vd(n).call(n,(function(t){PO[t]=CO(t,e)}))}else LO(PO,i);return i}(r.debug||!1,"Hls instance",r.assetPlayerId),n=this.config=function(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=wV(e),n=["manifest","level","frag"],a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return vd(n).call(n,(function(e){var n,s,o="".concat("level"===e?"playlist":e,"LoadPolicy"),l=void 0===t[o],u=[];vd(a).call(a,(function(r){var n,a=_d(n="".concat(e,"Loading")).call(n,r),s=t[a];if(void 0!==s&&l){u.push(a);var c=i[o].default;switch(t[o]={default:c},r){case"TimeOut":c.maxLoadTimeMs=s,c.maxTimeToFirstByteMs=s;break;case"MaxRetry":c.errorRetry.maxNumRetry=s,c.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":c.errorRetry.retryDelayMs=s,c.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":c.errorRetry.maxRetryDelayMs=s,c.timeoutRetry.maxRetryDelayMs=s}}})),u.length&&r.warn(_d(n=_d(s='hls.js config: "'.concat(u.join('", "'),'" setting(s) are deprecated, use "')).call(s,o,'": ')).call(n,jI(t[o])))})),RO(RO({},i),t)}(e.DefaultConfig,r,i);this.userConfig=r,n.progressive&&CV(n,i);var a=n.abrController,s=n.bufferController,o=n.capLevelController,l=n.errorController,u=n.fpsController,c=new l(this),h=this.abrController=new a(this),d=new BF(this),f=n.interstitialsController,v=f?this.interstitialsController=new f(this,e):null,g=this.bufferController=new s(this,d),p=this.capLevelController=new o(this),m=new u(this),y=new qV(this),E=n.contentSteeringController,k=E?new E(this):null,T=this.levelController=new NV(this,k),S=new OV(this),A=new VV(this.config),L=this.streamController=new HV(this,d,A);p.setStreamController(L),m.setStreamController(L);var b=[y,T,L];v&&ig(b).call(b,1,0,v),k&&ig(b).call(b,1,0,k),this.networkControllers=b;var R=[h,g,p,m,S,d];this.audioTrackController=this.createController(n.audioTrackController,b);var I=n.audioStreamController;I&&b.push(new I(this,d,A)),this.subtitleTrackController=this.createController(n.subtitleTrackController,b);var D=n.subtitleStreamController;D&&b.push(new D(this,d,A)),this.createController(n.timelineController,R),A.emeController=this.emeController=this.createController(n.emeController,R),this.cmcdController=this.createController(n.cmcdController,R),this.latencyController=this.createController(FV,R),this.coreComponents=R,b.push(c);var _=c.onErrorOut;"function"==typeof _&&this.on(fO.ERROR,_,c),this.on(fO.MANIFEST_LOADED,y.onManifestLoaded,y)}return Fc(e,[{key:"createController",value:function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null}},{key:"on",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.on(e,t,r)}},{key:"once",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.once(e,t,r)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,i=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,i)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,r){return this._emitter.emit(e,t,r)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(JV){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+JV.message+'". Here is a stacktrace:',JV),!this.triggeringException){this.triggeringException=!0;var r=e===fO.ERROR;this.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.INTERNAL_EXCEPTION,fatal:r,event:e,error:JV}),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(fO.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,vd(e=this.networkControllers).call(e,(function(e){return e.destroy()})),this.networkControllers.length=0,vd(t=this.coreComponents).call(t,(function(e){return e.destroy()})),this.coreComponents.length=0;var r=this.config;r.xhrSetup=r.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument (".concat(e,")"));this.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.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(fO.MEDIA_ATTACHING,n)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(fO.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(fO.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=iN.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(fO.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=arguments.length>1?arguments[1]:void 0;this.logger.log("startLoad(".concat(e+(t?", <skip seek to start>":""),")")),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){var e;this.bufferingEnabled||(this.logger.log("resume buffering"),vd(e=this.networkControllers).call(e,(function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){var e;this.bufferingEnabled&&(this.logger.log("pause buffering"),vd(e=this.networkControllers).call(e,(function(e){e.pauseBuffering&&e.pauseBuffering()})))}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(JV){try{var e=gI.createObjectURL(new Blob),t=e.toString();return gI.revokeObjectURL(e),Fv(t).call(t,YC(t).call(t,"/")+1)}catch(i){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)}))}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:".concat(e)),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:".concat(e)),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:".concat(e)),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:".concat(e)),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return av($O).call($O,e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e){return QO(e,lF(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return bB}},{key:"isMSESupported",value:function(){return KV()}},{key:"isSupported",value:function(){return function(){var e,t;if(!KV())return!1;var r=MO();return"function"==typeof(null==r?void 0:r.isTypeSupported)&&(KT(e=["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"]).call(e,(function(e){return r.isTypeSupported(BO(e,"video"))}))||KT(t=["mp4a.40.2","fLaC"]).call(t,(function(e){return r.isTypeSupported(BO(e,"audio"))})))}()}},{key:"getMediaSource",value:function(){return MO()}},{key:"Events",get:function(){return fO}},{key:"MetadataSchema",get:function(){return $B}},{key:"ErrorTypes",get:function(){return hO}},{key:"ErrorDetails",get:function(){return dO}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:_V},set:function(t){e.defaultConfig=t}}]),e}();WV.defaultConfig=void 0;var zV={liveSyncDuration:{key:"targetLatency",val:10},liveMaxLatencyDuration:{key:"maxLatency",val:20},backBufferLength:{key:"bufferBehind",val:10},initialLiveManifestSize:{key:"minSegmentsStartPlay",val:3},preferManagedMediaSource:[{key:"preferMMS",val:!1},{key:"preferMMSStreaming",val:!1}],lowLatencyMode:{key:"useLowLatency",val:!0},startPosition:{key:"startTime",val:0},interstitialLiveLookAhead:{key:"preloadTime",val:30}};var XV=function(){function e(r,i){t(this,e),this.hls=r,this.player=i}return Fc(e,[{key:"getAudioTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.audioTracks||[]}catch(JV){return console.error("Failed to get audio tracks:",JV),[]}}},{key:"getCurrentAudioTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.audioTrack}catch(JV){return console.error("Failed to get current audio track:",JV),-1}}},{key:"switchAudioTrack",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;var t=this.getAudioTracks();if(0===t.length)return console.warn("No audio tracks available"),!1;if(!KT(t).call(t,(function(t,r){return r===e})))return console.warn("Audio track with ID ".concat(e," not found")),!1;try{return this.hls.audioTrack=e,this.player.emit("core_event",{eventName:"core.audiotrackchange",trackId:e,trackInfo:t[e]||null}),!0}catch(JV){return console.error("Failed to switch audio track:",JV),!1}}},{key:"getSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.subtitleTracks||[]}catch(JV){return console.error("Failed to get subtitle tracks:",JV),[]}}},{key:"getAllSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.allSubtitleTracks||[]}catch(JV){return console.error("Failed to get all subtitle tracks:",JV),[]}}},{key:"getCurrentSubtitleTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.subtitleTrack}catch(JV){return console.error("Failed to get current subtitle track:",JV),-1}}},{key:"switchSubtitleTrack",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;var t=this.getSubtitleTracks();if(-1===e)try{return this.hls.subtitleTrack=-1,this.player.emit("core_event",{eventName:"core.subtitletrackchange",trackId:-1,trackInfo:null}),!0}catch(JV){return console.error("Failed to disable subtitle track:",JV),!1}if(0===t.length)return console.warn("No subtitle tracks available"),!1;if(!KT(t).call(t,(function(t,r){return r===e})))return console.warn("Subtitle track with ID ".concat(e," not found")),!1;try{return this.hls.subtitleTrack=e,this.player.emit("core_event",{eventName:"core.subtitletrackchange",trackId:e,trackInfo:t[e]||null}),!0}catch(JV){return console.error("Failed to switch subtitle track:",JV),!1}}},{key:"getSubtitleDisplay",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),!1;try{return this.hls.subtitleDisplay}catch(JV){return console.error("Failed to get subtitle display status:",JV),!1}}},{key:"setSubtitleDisplay",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;try{return this.hls.subtitleDisplay=e,this.player.emit("core_event",{eventName:"core.subtitledisplaychange",enabled:e}),!0}catch(JV){return console.error("Failed to set subtitle display:",JV),!1}}}]),e}(),QV=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"beforePlayerInit",value:function(){Ih(Rh(i.prototype),"beforePlayerInit",this).call(this),this._transEvent()}},{key:"_transEvent",value:function(){var e,t=this;vd(e=Ld(fO)).call(e,(function(e){e!==fO.ERROR&&t._transCoreEvent(e)}))}},{key:"_transCoreEvent",value:function(e){var t,r=this;null===(t=this.hls)||void 0===t||t.on(e,(function(t){if(r.player){for(var i,n,a=arguments.length,s=new Array(a>1?a-1:0),o=1;o<a;o++)s[o-1]=arguments[o];(i=r.player).emit.apply(i,_d(n=[e]).call(n,s))}}))}}]),i}(function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,Rf(Rf({},e),{},{pluginName:i.pluginName})))._tickInterval=500,n._currentIndex=0,n._onPlay=function(){n.hls.startLoad()},n.onUrlChange=function(e){/^blob/.test(e)||(n.playerConfig.url=e,n.register(e))},n._getBufferend=function(e){var t=e.buffered;return t&&t.length?t.end(t.length-1):0},n._tick=function(){clearTimeout(n._tickTimer);var e=n.player.media;if(e){n._tickTimer=Wf(n._tick,n._tickInterval);var t=n._getBufferend(e);t<.1||!e.readyState||n.player.config.isLive&&4===e.readyState&&e.paused&&t-e.currentTime>n.config.disconnectTime&&n.hls.stopLoad()}},n.on=function(e,t){var r;null==(r=n.hls)||r.on(e,t)},n.config=e.config||{},n.player.handleSource=!1,n}return Fc(i,[{key:"beforePlayerInit",value:function(){this.register(this.player.config.url)}},{key:"initEvt",value:function(){var e,t;e=this.hls,t=this.player,e.on(WV.Events.SUBTITLE_FRAG_PROCESSED,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.subtitlesegments",list:i})})),e.on(WV.Events.MANIFEST_PARSED,(function(e,r){var i=r.levels;t.emit("core_event",{eventName:"core.subtitleplaylist",list:i})})),e.on(WV.Events.MANIFEST_LOADING,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadstart",url:i})})),e.on(WV.Events.LEVEL_LOADING,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadstart",url:i})})),e.on(WV.Events.FRAG_LOADING,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.loadstart",url:i.url})})),e.on(WV.Events.MANIFEST_LOADED,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadcomplete",url:i})})),e.on(WV.Events.LEVEL_LOADED,(function(e,r){var i=r.details,n=r.stats;t.emit("core_event",Rf(Rf({eventName:"core.loadcomplete"},n),{},{url:null==i?void 0:i.url}))})),e.on(WV.Events.FRAG_LOADED,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.loadcomplete",url:i.url})})),e.on(WV.Events.FRAG_PARSING_USERDATA,(function(e,r){var i=r.samples;t.emit("core_event",{eventName:"core.sei",sei:i})})),e.on(WV.Events.MANIFEST_LOADED,(function(e,r){var i=r.levels,n=r.networkDetails;t.emit("core_event",{eventName:"core.hlsmanifestloaded",playlist:i}),t.emit("core_event",{eventName:"core.loadresponseheaders",headers:n.headers})})),e.on(WV.Events.LEVEL_LOADED,(function(e,r){var i,n=r.details,a={};vd(i=gv(n.dateRanges)).call(i,(function(e){a[e]=n.dateRanges[e].attr["START-DATE"]})),t.emit("core_event",{eventName:"core.hlslevelloaded",playlist:Rf(Rf({},n),{},{segments:n.fragments,dateRanges:a})})})),e.on(WV.Events.ERROR,(function(r,i){var n=i.details,a=i.fatal,s=i.type,o=i.response,l=i.reason,u=i.error;if(a){var c,h;switch(s){case WV.ErrorTypes.NETWORK_ERROR:c=2100,uD(n).call(n,"TimeOut")?c=2101:403===(null==o?void 0:o.code)?c=2103:404===(null==o?void 0:o.code)&&(c=2104),t.emit("error",{errorType:"network",errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case WV.ErrorTypes.MEDIA_ERROR:h="media",n===WV.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?c=5104:n===WV.ErrorDetails.FRAG_DECRYPT_ERROR?c=5105:n===WV.ErrorDetails.FRAG_PARSING_ERROR?(c=1100,h="manifest"):n===WV.ErrorDetails.FRAG_GAP?c=5104:n===WV.ErrorDetails.BUFFER_ADD_CODEC_ERROR?c=5200:n===WV.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR?c=5104:n===WV.ErrorDetails.BUFFER_APPEND_ERROR||n===WV.ErrorDetails.BUFFER_APPENDING_ERROR?c=5201:n===WV.ErrorDetails.BUFFER_STALLED_ERROR||n===WV.ErrorDetails.BUFFER_FULL_ERROR?c=5203:(n===WV.ErrorDetails.BUFFER_SEEK_OVER_HOLE||n===WV.ErrorDetails.BUFFER_NUDGE_ON_STALL)&&(c=5202),t.emit("error",{errorType:h||s,errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case WV.ErrorTypes.MUX_ERROR:c=4100,t.emit("error",{errorType:"remux",errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case WV.ErrorTypes.KEY_SYSTEM_ERROR:c=7111,n===WV.ErrorDetails.KEY_SYSTEM_NO_KEYS?c=7103:n===WV.ErrorDetails.KEY_SYSTEM_NO_ACCESS?c=7101:n===WV.ErrorDetails.KEY_SYSTEM_NO_SESSION?c=7104:n===WV.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?c=7107:n===WV.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED?c=7108:n===WV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED||n===WV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?c=7110:n===WV.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?c=7104:n===WV.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR&&(c=7111),t.emit("error",{errorType:"drm",errorCode:c,message:(null==u?void 0:u.message)||l||n,originError:i});break;default:n===WV.ErrorDetails.LEVEL_SWITCH_ERROR&&(c=2100,h="network"),t.emit("error",{errorType:h||"other",errorCode:c,message:(null==u?void 0:u.message)||l||n,originError:i})}try{e.stopLoad(),t.pause()}catch(d){}}})),e.on(WV.Events.MEDIA_ATTACHED,(function(){t.emit("sourceopen")})),e.on(WV.Events.BUFFER_APPENDED,(function(){t.emit("bufferappend")})),e.on(WV.Events.AUDIO_TRACKS_UPDATED,(function(e,r){var i=r.audioTracks;t.emit("core_event",{eventName:"core.audiotracksupdate",audioTracks:i})})),e.on(WV.Events.AUDIO_TRACK_SWITCHING,(function(e,r){t.emit("core_event",Rf({eventName:"core.audiotrackswitching"},r))})),e.on(WV.Events.AUDIO_TRACK_SWITCHED,(function(e,r){t.emit("core_event",Rf({eventName:"core.audiotrackswitched"},r))})),e.on(WV.Events.SUBTITLE_TRACKS_UPDATED,(function(e,r){var i=r.subtitleTracks;t.emit("core_event",{eventName:"core.subtitletracksupdate",subtitleTracks:i})})),e.on(WV.Events.SUBTITLE_TRACKS_CLEARED,(function(){t.emit("core_event",{eventName:"core.subtitletracksclear"})})),e.on(WV.Events.SUBTITLE_TRACK_SWITCH,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackswitch"},r))})),e.on(WV.Events.SUBTITLE_TRACK_LOADING,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackloading"},r))})),e.on(WV.Events.SUBTITLE_TRACK_LOADED,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackloaded"},r))}))}},{key:"afterCreate",value:function(){var e=this.player.media;this.player.on(CA,this.onUrlChange);try{BA.defineGetterOrSetter(this.player,{url:{get:function(){try{return e.src}catch(JV){return null}},configurable:!0}})}catch(t){}}},{key:"register",value:function(e){var t=this.player;this.hls&&this.hls.destroy();var r=function(e){var t,r={};vd(t=gv(zV)).call(t,(function(t){var i=zV[t];i instanceof Array?vd(i).call(i,(function(e){r[t]=e.val})):r[t]=e[i.key]||i.val}));var i="number"==typeof e.retryCount?e.retryCount:3,n="number"==typeof e.retryDelay?e.retryDelay:1e3,a=e.loadTimeout||1e4,s="number"==typeof e.manifestLoadTimeout?e.manifestLoadTimeout:1e4,o={maxNumRetry:i,retryDelayMs:n,maxRetryDelayMs:n,shouldRetry:function(e,t){return t<e.maxNumRetry}},l={maxNumRetry:i,retryDelayMs:n,maxRetryDelayMs:n,shouldRetry:function(e,t){return t<e.maxNumRetry}};return r.manifestLoadPolicy={default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:s,timeoutRetry:o,errorRetry:l}},r.playlistLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:a,timeoutRetry:o,errorRetry:l}},r.fragLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:a,timeoutRetry:o,errorRetry:l}},Rf(Rf({},r),e)}(this.config);(this.hls=new WV(r),this._trackManager=new XV(this.hls,this.player),this.initEvt(),t.config.preProcessUrl)&&(e=t.config.preProcessUrl(e).url);this.hls.loadSource(e);var i=this.player.media;this.hls.attachMedia(i),clearTimeout(this._tickTimer),this._tickTimer=Wf(this._tick,this._tickInterval),i.removeEventListener("play",this._onPlay),i.addEventListener("play",this._onPlay)}},{key:"switchUrl",value:function(e,t){var r=t.startTime;(t.bitrate,t.seamless,this.hls.loadSource(e),void 0!==r)&&(this.player.media.currentTime=r)}},{key:"getAudioTracks",value:function(){return this._trackManager.getAudioTracks()}},{key:"getCurrentAudioTrack",value:function(){return this._trackManager.getCurrentAudioTrack()}},{key:"switchAudioTrack",value:function(e){return this._trackManager.switchAudioTrack(e)}},{key:"getSubtitleTracks",value:function(){return this._trackManager.getSubtitleTracks()}},{key:"getAllSubtitleTracks",value:function(){return this._trackManager.getAllSubtitleTracks()}},{key:"getCurrentSubtitleTrack",value:function(){return this._trackManager.getCurrentSubtitleTrack()}},{key:"switchSubtitleTrack",value:function(e){return this._trackManager.switchSubtitleTrack(e)}},{key:"getSubtitleDisplay",value:function(){return this._trackManager.getSubtitleDisplay()}},{key:"setSubtitleDisplay",value:function(e){return this._trackManager.setSubtitleDisplay(e)}},{key:"destroy",value:function(){var e;clearTimeout(this._tickTimer),this.player.off(CA,this.onUrlChange),null==(e=this.hls)||e.destroy()}}],[{key:"pluginName",get:function(){return"hls"}}]),i}(BA)),$V=window.VePlayer.DynamicModule;VePlayer.registerPlugin($V.PluginHlsJs,{HlsPlugin:QV}),e.HlsPlugin=QV}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).__VEPLAYER_PLUGIN_HLSJS__={})}(this,(function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n={exports:{}},a=function(e){return e&&e.Math==Math&&e},s=a("object"==typeof globalThis&&globalThis)||a("object"==typeof window&&window)||a("object"==typeof self&&self)||a("object"==typeof r&&r)||function(){return this}()||r||Function("return this")(),o=function(e){try{return!!e()}catch(t){return!0}},l=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),u=l,c=Function.prototype,h=c.apply,d=c.call,f="object"==typeof Reflect&&Reflect.apply||(u?d.bind(h):function(){return d.apply(h,arguments)}),v=l,g=Function.prototype,p=g.call,m=v&&g.bind.bind(p,p),y=v?m:function(e){return function(){return p.apply(e,arguments)}},E=y,k=E({}.toString),T=E("".slice),S=function(e){return T(k(e),8,-1)},A=S,L=y,b=function(e){if("Function"===A(e))return L(e)},R="object"==typeof document&&document.all,I={all:R,IS_HTMLDDA:void 0===R&&void 0!==R},D=I.all,_=I.IS_HTMLDDA?function(e){return"function"==typeof e||e===D}:function(e){return"function"==typeof e},w={},C=!o((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),P=l,x=Function.prototype.call,M=P?x.bind(x):function(){return x.apply(x,arguments)},O={},F={}.propertyIsEnumerable,N=Object.getOwnPropertyDescriptor,U=N&&!F.call({1:2},1);O.f=U?function(e){var t=N(this,e);return!!t&&t.enumerable}:F;var B,G,K=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},H=o,V=S,j=Object,Y=y("".split),q=H((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==V(e)?Y(e,""):j(e)}:j,W=function(e){return null==e},z=W,X=TypeError,Q=function(e){if(z(e))throw X("Can't call method on "+e);return e},$=q,J=Q,Z=function(e){return $(J(e))},ee=_,te=I.all,re=I.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:ee(e)||e===te}:function(e){return"object"==typeof e?null!==e:ee(e)},ie={},ne=ie,ae=s,se=_,oe=function(e){return se(e)?e:void 0},le=function(e,t){return arguments.length<2?oe(ne[e])||oe(ae[e]):ne[e]&&ne[e][t]||ae[e]&&ae[e][t]},ue=y({}.isPrototypeOf),ce="undefined"!=typeof navigator&&String(navigator.userAgent)||"",he=s,de=ce,fe=he.process,ve=he.Deno,ge=fe&&fe.versions||ve&&ve.version,pe=ge&&ge.v8;pe&&(G=(B=pe.split("."))[0]>0&&B[0]<4?1:+(B[0]+B[1])),!G&&de&&(!(B=de.match(/Edge\/(\d+)/))||B[1]>=74)&&(B=de.match(/Chrome\/(\d+)/))&&(G=+B[1]);var me=G,ye=me,Ee=o,ke=s.String,Te=!!Object.getOwnPropertySymbols&&!Ee((function(){var e=Symbol();return!ke(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ye&&ye<41})),Se=Te&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ae=le,Le=_,be=ue,Re=Object,Ie=Se?function(e){return"symbol"==typeof e}:function(e){var t=Ae("Symbol");return Le(t)&&be(t.prototype,Re(e))},De=String,_e=function(e){try{return De(e)}catch(t){return"Object"}},we=_,Ce=_e,Pe=TypeError,xe=function(e){if(we(e))return e;throw Pe(Ce(e)+" is not a function")},Me=xe,Oe=W,Fe=function(e,t){var r=e[t];return Oe(r)?void 0:Me(r)},Ne=M,Ue=_,Be=re,Ge=TypeError,Ke={exports:{}},He=s,Ve=Object.defineProperty,je=function(e,t){try{Ve(He,e,{value:t,configurable:!0,writable:!0})}catch(r){He[e]=t}return t},Ye="__core-js_shared__",qe=s[Ye]||je(Ye,{}),We=qe;(Ke.exports=function(e,t){return We[e]||(We[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=Ke.exports,Xe=Q,Qe=Object,$e=function(e){return Qe(Xe(e))},Je=$e,Ze=y({}.hasOwnProperty),et=Object.hasOwn||function(e,t){return Ze(Je(e),t)},tt=y,rt=0,it=Math.random(),nt=tt(1..toString),at=function(e){return"Symbol("+(void 0===e?"":e)+")_"+nt(++rt+it,36)},st=ze,ot=et,lt=at,ut=Te,ct=Se,ht=s.Symbol,dt=st("wks"),ft=ct?ht.for||ht:ht&&ht.withoutSetter||lt,vt=function(e){return ot(dt,e)||(dt[e]=ut&&ot(ht,e)?ht[e]:ft("Symbol."+e)),dt[e]},gt=M,pt=re,mt=Ie,yt=Fe,Et=function(e,t){var r,i;if("string"===t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;if(Ue(r=e.valueOf)&&!Be(i=Ne(r,e)))return i;if("string"!==t&&Ue(r=e.toString)&&!Be(i=Ne(r,e)))return i;throw Ge("Can't convert object to primitive value")},kt=TypeError,Tt=vt("toPrimitive"),St=function(e,t){if(!pt(e)||mt(e))return e;var r,i=yt(e,Tt);if(i){if(void 0===t&&(t="default"),r=gt(i,e,t),!pt(r)||mt(r))return r;throw kt("Can't convert object to primitive value")}return void 0===t&&(t="number"),Et(e,t)},At=Ie,Lt=function(e){var t=St(e,"string");return At(t)?t:t+""},bt=re,Rt=s.document,It=bt(Rt)&&bt(Rt.createElement),Dt=function(e){return It?Rt.createElement(e):{}},_t=Dt,wt=!C&&!o((function(){return 7!=Object.defineProperty(_t("div"),"a",{get:function(){return 7}}).a})),Ct=C,Pt=M,xt=O,Mt=K,Ot=Z,Ft=Lt,Nt=et,Ut=wt,Bt=Object.getOwnPropertyDescriptor;w.f=Ct?Bt:function(e,t){if(e=Ot(e),t=Ft(t),Ut)try{return Bt(e,t)}catch(r){}if(Nt(e,t))return Mt(!Pt(xt.f,e,t),e[t])};var Gt=o,Kt=_,Ht=/#|\.prototype\./,Vt=function(e,t){var r=Yt[jt(e)];return r==Wt||r!=qt&&(Kt(t)?Gt(t):!!t)},jt=Vt.normalize=function(e){return String(e).replace(Ht,".").toLowerCase()},Yt=Vt.data={},qt=Vt.NATIVE="N",Wt=Vt.POLYFILL="P",zt=Vt,Xt=xe,Qt=l,$t=b(b.bind),Jt=function(e,t){return Xt(e),void 0===t?e:Qt?$t(e,t):function(){return e.apply(t,arguments)}},Zt={},er=C&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),tr=re,rr=String,ir=TypeError,nr=function(e){if(tr(e))return e;throw ir(rr(e)+" is not an object")},ar=C,sr=wt,or=er,lr=nr,ur=Lt,cr=TypeError,hr=Object.defineProperty,dr=Object.getOwnPropertyDescriptor,fr="enumerable",vr="configurable",gr="writable";Zt.f=ar?or?function(e,t,r){if(lr(e),t=ur(t),lr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&gr in r&&!r[gr]){var i=dr(e,t);i&&i[gr]&&(e[t]=r.value,r={configurable:vr in r?r[vr]:i[vr],enumerable:fr in r?r[fr]:i[fr],writable:!1})}return hr(e,t,r)}:hr:function(e,t,r){if(lr(e),t=ur(t),lr(r),sr)try{return hr(e,t,r)}catch(i){}if("get"in r||"set"in r)throw cr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Zt,mr=K,yr=C?function(e,t,r){return pr.f(e,t,mr(1,r))}:function(e,t,r){return e[t]=r,e},Er=s,kr=f,Tr=b,Sr=_,Ar=w.f,Lr=zt,br=ie,Rr=Jt,Ir=yr,Dr=et,_r=function(e){var t=function(r,i,n){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,i)}return new e(r,i,n)}return kr(e,this,arguments)};return t.prototype=e.prototype,t},wr=function(e,t){var r,i,n,a,s,o,l,u,c,h=e.target,d=e.global,f=e.stat,v=e.proto,g=d?Er:f?Er[h]:(Er[h]||{}).prototype,p=d?br:br[h]||Ir(br,h,{})[h],m=p.prototype;for(a in t)i=!(r=Lr(d?a:h+(f?".":"#")+a,e.forced))&&g&&Dr(g,a),o=p[a],i&&(l=e.dontCallGetSet?(c=Ar(g,a))&&c.value:g[a]),s=i&&l?l:t[a],i&&typeof o==typeof s||(u=e.bind&&i?Rr(s,Er):e.wrap&&i?_r(s):v&&Sr(s)?Tr(s):s,(e.sham||s&&s.sham||o&&o.sham)&&Ir(u,"sham",!0),Ir(p,a,u),v&&(Dr(br,n=h+"Prototype")||Ir(br,n,{}),Ir(br[n],a,s),e.real&&m&&(r||!m[a])&&Ir(m,a,s)))},Cr=wr,Pr=C,xr=Zt.f;Cr({target:"Object",stat:!0,forced:Object.defineProperty!==xr,sham:!Pr},{defineProperty:xr});var Mr=ie.Object,Or=n.exports=function(e,t,r){return Mr.defineProperty(e,t,r)};Mr.defineProperty.sham&&(Or.sham=!0);var Fr=n.exports,Nr=i(Fr),Ur=S,Br=Array.isArray||function(e){return"Array"==Ur(e)},Gr=Math.ceil,Kr=Math.floor,Hr=Math.trunc||function(e){var t=+e;return(t>0?Kr:Gr)(t)},Vr=function(e){var t=+e;return t!=t||0===t?0:Hr(t)},jr=Vr,Yr=Math.min,qr=function(e){return e>0?Yr(jr(e),9007199254740991):0},Wr=qr,zr=function(e){return Wr(e.length)},Xr=TypeError,Qr=function(e){if(e>9007199254740991)throw Xr("Maximum allowed index exceeded");return e},$r=Lt,Jr=Zt,Zr=K,ei=function(e,t,r){var i=$r(t);i in e?Jr.f(e,i,Zr(0,r)):e[i]=r},ti={};ti[vt("toStringTag")]="z";var ri="[object z]"===String(ti),ii=ri,ni=_,ai=S,si=vt("toStringTag"),oi=Object,li="Arguments"==ai(function(){return arguments}()),ui=ii?ai:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=oi(e),si))?r:li?ai(t):"Object"==(i=ai(t))&&ni(t.callee)?"Arguments":i},ci=_,hi=qe,di=y(Function.toString);ci(hi.inspectSource)||(hi.inspectSource=function(e){return di(e)});var fi=hi.inspectSource,vi=y,gi=o,pi=_,mi=ui,yi=fi,Ei=function(){},ki=[],Ti=le("Reflect","construct"),Si=/^\s*(?:class|function)\b/,Ai=vi(Si.exec),Li=!Si.exec(Ei),bi=function(e){if(!pi(e))return!1;try{return Ti(Ei,ki,e),!0}catch(t){return!1}},Ri=function(e){if(!pi(e))return!1;switch(mi(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Li||!!Ai(Si,yi(e))}catch(t){return!0}};Ri.sham=!0;var Ii=!Ti||gi((function(){var e;return bi(bi.call)||!bi(Object)||!bi((function(){e=!0}))||e}))?Ri:bi,Di=Br,_i=Ii,wi=re,Ci=vt("species"),Pi=Array,xi=function(e){var t;return Di(e)&&(t=e.constructor,(_i(t)&&(t===Pi||Di(t.prototype))||wi(t)&&null===(t=t[Ci]))&&(t=void 0)),void 0===t?Pi:t},Mi=function(e,t){return new(xi(e))(0===t?0:t)},Oi=o,Fi=me,Ni=vt("species"),Ui=function(e){return Fi>=51||!Oi((function(){var t=[];return(t.constructor={})[Ni]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Bi=wr,Gi=o,Ki=Br,Hi=re,Vi=$e,ji=zr,Yi=Qr,qi=ei,Wi=Mi,zi=Ui,Xi=me,Qi=vt("isConcatSpreadable"),$i=Xi>=51||!Gi((function(){var e=[];return e[Qi]=!1,e.concat()[0]!==e})),Ji=function(e){if(!Hi(e))return!1;var t=e[Qi];return void 0!==t?!!t:Ki(e)};Bi({target:"Array",proto:!0,arity:1,forced:!$i||!zi("concat")},{concat:function(e){var t,r,i,n,a,s=Vi(this),o=Wi(s,0),l=0;for(t=-1,i=arguments.length;t<i;t++)if(Ji(a=-1===t?s:arguments[t]))for(n=ji(a),Yi(l+n),r=0;r<n;r++,l++)r in a&&qi(o,l,a[r]);else Yi(l+1),qi(o,l++,a);return o.length=l,o}});var Zi=ui,en=String,tn=function(e){if("Symbol"===Zi(e))throw TypeError("Cannot convert a Symbol value to a string");return en(e)},rn={},nn=Vr,an=Math.max,sn=Math.min,on=function(e,t){var r=nn(e);return r<0?an(r+t,0):sn(r,t)},ln=Z,un=on,cn=zr,hn=function(e){return function(t,r,i){var n,a=ln(t),s=cn(a),o=un(i,s);if(e&&r!=r){for(;s>o;)if((n=a[o++])!=n)return!0}else for(;s>o;o++)if((e||o in a)&&a[o]===r)return e||o||0;return!e&&-1}},dn={includes:hn(!0),indexOf:hn(!1)},fn={},vn=et,gn=Z,pn=dn.indexOf,mn=fn,yn=y([].push),En=function(e,t){var r,i=gn(e),n=0,a=[];for(r in i)!vn(mn,r)&&vn(i,r)&&yn(a,r);for(;t.length>n;)vn(i,r=t[n++])&&(~pn(a,r)||yn(a,r));return a},kn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Tn=En,Sn=kn,An=Object.keys||function(e){return Tn(e,Sn)},Ln=C,bn=er,Rn=Zt,In=nr,Dn=Z,_n=An;rn.f=Ln&&!bn?Object.defineProperties:function(e,t){In(e);for(var r,i=Dn(t),n=_n(t),a=n.length,s=0;a>s;)Rn.f(e,r=n[s++],i[r]);return e};var wn,Cn=le("document","documentElement"),Pn=at,xn=ze("keys"),Mn=function(e){return xn[e]||(xn[e]=Pn(e))},On=nr,Fn=rn,Nn=kn,Un=fn,Bn=Cn,Gn=Dt,Kn="prototype",Hn="script",Vn=Mn("IE_PROTO"),jn=function(){},Yn=function(e){return"<"+Hn+">"+e+"</"+Hn+">"},qn=function(e){e.write(Yn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Wn=function(){try{wn=new ActiveXObject("htmlfile")}catch(n){}var e,t,r;Wn="undefined"!=typeof document?document.domain&&wn?qn(wn):(t=Gn("iframe"),r="java"+Hn+":",t.style.display="none",Bn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Yn("document.F=Object")),e.close(),e.F):qn(wn);for(var i=Nn.length;i--;)delete Wn[Kn][Nn[i]];return Wn()};Un[Vn]=!0;var zn=Object.create||function(e,t){var r;return null!==e?(jn[Kn]=On(e),r=new jn,jn[Kn]=null,r[Vn]=e):r=Wn(),void 0===t?r:Fn.f(r,t)},Xn={},Qn=En,$n=kn.concat("length","prototype");Xn.f=Object.getOwnPropertyNames||function(e){return Qn(e,$n)};var Jn={},Zn=on,ea=zr,ta=ei,ra=Array,ia=Math.max,na=function(e,t,r){for(var i=ea(e),n=Zn(t,i),a=Zn(void 0===r?i:r,i),s=ra(ia(a-n,0)),o=0;n<a;n++,o++)ta(s,o,e[n]);return s.length=o,s},aa=S,sa=Z,oa=Xn.f,la=na,ua="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Jn.f=function(e){return ua&&"Window"==aa(e)?function(e){try{return oa(e)}catch(t){return la(ua)}}(e):oa(sa(e))};var ca={};ca.f=Object.getOwnPropertySymbols;var ha=yr,da=function(e,t,r,i){return i&&i.enumerable?e[t]=r:ha(e,t,r),e},fa=Zt,va=function(e,t,r){return fa.f(e,t,r)},ga={},pa=vt;ga.f=pa;var ma,ya,Ea,ka=ie,Ta=et,Sa=ga,Aa=Zt.f,La=function(e){var t=ka.Symbol||(ka.Symbol={});Ta(t,e)||Aa(t,e,{value:Sa.f(e)})},ba=M,Ra=le,Ia=vt,Da=da,_a=function(){var e=Ra("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,i=Ia("toPrimitive");t&&!t[i]&&Da(t,i,(function(e){return ba(r,this)}),{arity:1})},wa=ui,Ca=ri?{}.toString:function(){return"[object "+wa(this)+"]"},Pa=ri,xa=Zt.f,Ma=yr,Oa=et,Fa=Ca,Na=vt("toStringTag"),Ua=function(e,t,r,i){if(e){var n=r?e:e.prototype;Oa(n,Na)||xa(n,Na,{configurable:!0,value:t}),i&&!Pa&&Ma(n,"toString",Fa)}},Ba=_,Ga=s.WeakMap,Ka=Ba(Ga)&&/native code/.test(String(Ga)),Ha=s,Va=re,ja=yr,Ya=et,qa=qe,Wa=Mn,za=fn,Xa="Object already initialized",Qa=Ha.TypeError,$a=Ha.WeakMap;if(Ka||qa.state){var Ja=qa.state||(qa.state=new $a);Ja.get=Ja.get,Ja.has=Ja.has,Ja.set=Ja.set,ma=function(e,t){if(Ja.has(e))throw Qa(Xa);return t.facade=e,Ja.set(e,t),t},ya=function(e){return Ja.get(e)||{}},Ea=function(e){return Ja.has(e)}}else{var Za=Wa("state");za[Za]=!0,ma=function(e,t){if(Ya(e,Za))throw Qa(Xa);return t.facade=e,ja(e,Za,t),t},ya=function(e){return Ya(e,Za)?e[Za]:{}},Ea=function(e){return Ya(e,Za)}}var es={set:ma,get:ya,has:Ea,enforce:function(e){return Ea(e)?ya(e):ma(e,{})},getterFor:function(e){return function(t){var r;if(!Va(t)||(r=ya(t)).type!==e)throw Qa("Incompatible receiver, "+e+" required");return r}}},ts=Jt,rs=q,is=$e,ns=zr,as=Mi,ss=y([].push),os=function(e){var t=1==e,r=2==e,i=3==e,n=4==e,a=6==e,s=7==e,o=5==e||a;return function(l,u,c,h){for(var d,f,v=is(l),g=rs(v),p=ts(u,c),m=ns(g),y=0,E=h||as,k=t?E(l,m):r||s?E(l,0):void 0;m>y;y++)if((o||y in g)&&(f=p(d=g[y],y,v),e))if(t)k[y]=f;else if(f)switch(e){case 3:return!0;case 5:return d;case 6:return y;case 2:ss(k,d)}else switch(e){case 4:return!1;case 7:ss(k,d)}return a?-1:i||n?n:k}},ls={forEach:os(0),map:os(1),filter:os(2),some:os(3),every:os(4),find:os(5),findIndex:os(6),filterReject:os(7)},us=wr,cs=s,hs=M,ds=y,fs=C,vs=Te,gs=o,ps=et,ms=ue,ys=nr,Es=Z,ks=Lt,Ts=tn,Ss=K,As=zn,Ls=An,bs=Xn,Rs=Jn,Is=ca,Ds=w,_s=Zt,ws=rn,Cs=O,Ps=da,xs=va,Ms=ze,Os=fn,Fs=at,Ns=vt,Us=ga,Bs=La,Gs=_a,Ks=Ua,Hs=es,Vs=ls.forEach,js=Mn("hidden"),Ys="Symbol",qs="prototype",Ws=Hs.set,zs=Hs.getterFor(Ys),Xs=Object[qs],Qs=cs.Symbol,$s=Qs&&Qs[qs],Js=cs.TypeError,Zs=cs.QObject,eo=Ds.f,to=_s.f,ro=Rs.f,io=Cs.f,no=ds([].push),ao=Ms("symbols"),so=Ms("op-symbols"),oo=Ms("wks"),lo=!Zs||!Zs[qs]||!Zs[qs].findChild,uo=fs&&gs((function(){return 7!=As(to({},"a",{get:function(){return to(this,"a",{value:7}).a}})).a}))?function(e,t,r){var i=eo(Xs,t);i&&delete Xs[t],to(e,t,r),i&&e!==Xs&&to(Xs,t,i)}:to,co=function(e,t){var r=ao[e]=As($s);return Ws(r,{type:Ys,tag:e,description:t}),fs||(r.description=t),r},ho=function(e,t,r){e===Xs&&ho(so,t,r),ys(e);var i=ks(t);return ys(r),ps(ao,i)?(r.enumerable?(ps(e,js)&&e[js][i]&&(e[js][i]=!1),r=As(r,{enumerable:Ss(0,!1)})):(ps(e,js)||to(e,js,Ss(1,{})),e[js][i]=!0),uo(e,i,r)):to(e,i,r)},fo=function(e,t){ys(e);var r=Es(t),i=Ls(r).concat(mo(r));return Vs(i,(function(t){fs&&!hs(vo,r,t)||ho(e,t,r[t])})),e},vo=function(e){var t=ks(e),r=hs(io,this,t);return!(this===Xs&&ps(ao,t)&&!ps(so,t))&&(!(r||!ps(this,t)||!ps(ao,t)||ps(this,js)&&this[js][t])||r)},go=function(e,t){var r=Es(e),i=ks(t);if(r!==Xs||!ps(ao,i)||ps(so,i)){var n=eo(r,i);return!n||!ps(ao,i)||ps(r,js)&&r[js][i]||(n.enumerable=!0),n}},po=function(e){var t=ro(Es(e)),r=[];return Vs(t,(function(e){ps(ao,e)||ps(Os,e)||no(r,e)})),r},mo=function(e){var t=e===Xs,r=ro(t?so:Es(e)),i=[];return Vs(r,(function(e){!ps(ao,e)||t&&!ps(Xs,e)||no(i,ao[e])})),i};vs||(Qs=function(){if(ms($s,this))throw Js("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Ts(arguments[0]):void 0,t=Fs(e),r=function(e){this===Xs&&hs(r,so,e),ps(this,js)&&ps(this[js],t)&&(this[js][t]=!1),uo(this,t,Ss(1,e))};return fs&&lo&&uo(Xs,t,{configurable:!0,set:r}),co(t,e)},Ps($s=Qs[qs],"toString",(function(){return zs(this).tag})),Ps(Qs,"withoutSetter",(function(e){return co(Fs(e),e)})),Cs.f=vo,_s.f=ho,ws.f=fo,Ds.f=go,bs.f=Rs.f=po,Is.f=mo,Us.f=function(e){return co(Ns(e),e)},fs&&xs($s,"description",{configurable:!0,get:function(){return zs(this).description}})),us({global:!0,constructor:!0,wrap:!0,forced:!vs,sham:!vs},{Symbol:Qs}),Vs(Ls(oo),(function(e){Bs(e)})),us({target:Ys,stat:!0,forced:!vs},{useSetter:function(){lo=!0},useSimple:function(){lo=!1}}),us({target:"Object",stat:!0,forced:!vs,sham:!fs},{create:function(e,t){return void 0===t?As(e):fo(As(e),t)},defineProperty:ho,defineProperties:fo,getOwnPropertyDescriptor:go}),us({target:"Object",stat:!0,forced:!vs},{getOwnPropertyNames:po}),Gs(),Ks(Qs,Ys),Os[js]=!0;var yo=Te&&!!Symbol.for&&!!Symbol.keyFor,Eo=wr,ko=le,To=et,So=tn,Ao=ze,Lo=yo,bo=Ao("string-to-symbol-registry"),Ro=Ao("symbol-to-string-registry");Eo({target:"Symbol",stat:!0,forced:!Lo},{for:function(e){var t=So(e);if(To(bo,t))return bo[t];var r=ko("Symbol")(t);return bo[t]=r,Ro[r]=t,r}});var Io=wr,Do=et,_o=Ie,wo=_e,Co=yo,Po=ze("symbol-to-string-registry");Io({target:"Symbol",stat:!0,forced:!Co},{keyFor:function(e){if(!_o(e))throw TypeError(wo(e)+" is not a symbol");if(Do(Po,e))return Po[e]}});var xo=y([].slice),Mo=Br,Oo=_,Fo=S,No=tn,Uo=y([].push),Bo=wr,Go=le,Ko=f,Ho=M,Vo=y,jo=o,Yo=_,qo=Ie,Wo=xo,zo=function(e){if(Oo(e))return e;if(Mo(e)){for(var t=e.length,r=[],i=0;i<t;i++){var n=e[i];"string"==typeof n?Uo(r,n):"number"!=typeof n&&"Number"!=Fo(n)&&"String"!=Fo(n)||Uo(r,No(n))}var a=r.length,s=!0;return function(e,t){if(s)return s=!1,t;if(Mo(this))return t;for(var i=0;i<a;i++)if(r[i]===e)return t}}},Xo=Te,Qo=String,$o=Go("JSON","stringify"),Jo=Vo(/./.exec),Zo=Vo("".charAt),el=Vo("".charCodeAt),tl=Vo("".replace),rl=Vo(1..toString),il=/[\uD800-\uDFFF]/g,nl=/^[\uD800-\uDBFF]$/,al=/^[\uDC00-\uDFFF]$/,sl=!Xo||jo((function(){var e=Go("Symbol")();return"[null]"!=$o([e])||"{}"!=$o({a:e})||"{}"!=$o(Object(e))})),ol=jo((function(){return'"\\udf06\\ud834"'!==$o("\udf06\ud834")||'"\\udead"'!==$o("\udead")})),ll=function(e,t){var r=Wo(arguments),i=zo(t);if(Yo(i)||void 0!==e&&!qo(e))return r[1]=function(e,t){if(Yo(i)&&(t=Ho(i,this,Qo(e),t)),!qo(t))return t},Ko($o,null,r)},ul=function(e,t,r){var i=Zo(r,t-1),n=Zo(r,t+1);return Jo(nl,e)&&!Jo(al,n)||Jo(al,e)&&!Jo(nl,i)?"\\u"+rl(el(e,0),16):e};$o&&Bo({target:"JSON",stat:!0,arity:3,forced:sl||ol},{stringify:function(e,t,r){var i=Wo(arguments),n=Ko(sl?ll:$o,null,i);return ol&&"string"==typeof n?tl(n,il,ul):n}});var cl=ca,hl=$e;wr({target:"Object",stat:!0,forced:!Te||o((function(){cl.f(1)}))},{getOwnPropertySymbols:function(e){var t=cl.f;return t?t(hl(e)):[]}}),La("asyncIterator"),La("hasInstance"),La("isConcatSpreadable"),La("iterator"),La("match"),La("matchAll"),La("replace"),La("search"),La("species"),La("split");var dl=_a;La("toPrimitive"),dl();var fl=le,vl=Ua;La("toStringTag"),vl(fl("Symbol"),"Symbol"),La("unscopables"),Ua(s.JSON,"JSON",!0);var gl,pl,ml,yl=ie.Symbol,El={},kl=C,Tl=et,Sl=Function.prototype,Al=kl&&Object.getOwnPropertyDescriptor,Ll=Tl(Sl,"name"),bl={EXISTS:Ll,PROPER:Ll&&"something"===function(){}.name,CONFIGURABLE:Ll&&(!kl||kl&&Al(Sl,"name").configurable)},Rl=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Il=et,Dl=_,_l=$e,wl=Rl,Cl=Mn("IE_PROTO"),Pl=Object,xl=Pl.prototype,Ml=wl?Pl.getPrototypeOf:function(e){var t=_l(e);if(Il(t,Cl))return t[Cl];var r=t.constructor;return Dl(r)&&t instanceof r?r.prototype:t instanceof Pl?xl:null},Ol=o,Fl=_,Nl=re,Ul=zn,Bl=Ml,Gl=da,Kl=vt("iterator"),Hl=!1;[].keys&&("next"in(ml=[].keys())?(pl=Bl(Bl(ml)))!==Object.prototype&&(gl=pl):Hl=!0);var Vl=!Nl(gl)||Ol((function(){var e={};return gl[Kl].call(e)!==e}));Fl((gl=Vl?{}:Ul(gl))[Kl])||Gl(gl,Kl,(function(){return this}));var jl={IteratorPrototype:gl,BUGGY_SAFARI_ITERATORS:Hl},Yl=jl.IteratorPrototype,ql=zn,Wl=K,zl=Ua,Xl=El,Ql=function(){return this},$l=function(e,t,r,i){var n=t+" Iterator";return e.prototype=ql(Yl,{next:Wl(+!i,r)}),zl(e,n,!1,!0),Xl[n]=Ql,e},Jl=y,Zl=xe,eu=_,tu=String,ru=TypeError,iu=function(e,t,r){try{return Jl(Zl(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},nu=nr,au=function(e){if("object"==typeof e||eu(e))return e;throw ru("Can't set "+tu(e)+" as a prototype")},su=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=iu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return nu(r),au(i),t?e(r,i):r.__proto__=i,r}}():void 0),ou=wr,lu=M,uu=bl,cu=$l,hu=Ml,du=Ua,fu=da,vu=El,gu=jl,pu=uu.PROPER,mu=gu.BUGGY_SAFARI_ITERATORS,yu=vt("iterator"),Eu="keys",ku="values",Tu="entries",Su=function(){return this},Au=function(e,t,r,i,n,a,s){cu(r,t,i);var o,l,u,c=function(e){if(e===n&&g)return g;if(!mu&&e in f)return f[e];switch(e){case Eu:case ku:case Tu:return function(){return new r(this,e)}}return function(){return new r(this)}},h=t+" Iterator",d=!1,f=e.prototype,v=f[yu]||f["@@iterator"]||n&&f[n],g=!mu&&v||c(n),p="Array"==t&&f.entries||v;if(p&&(o=hu(p.call(new e)))!==Object.prototype&&o.next&&(du(o,h,!0,!0),vu[h]=Su),pu&&n==ku&&v&&v.name!==ku&&(d=!0,g=function(){return lu(v,this)}),n)if(l={values:c(ku),keys:a?g:c(Eu),entries:c(Tu)},s)for(u in l)(mu||d||!(u in f))&&fu(f,u,l[u]);else ou({target:t,proto:!0,forced:mu||d},l);return s&&f[yu]!==g&&fu(f,yu,g,{name:n}),vu[t]=g,l},Lu=function(e,t){return{value:e,done:t}},bu=Z,Ru=El,Iu=es;Zt.f;var Du=Au,_u=Lu,wu="Array Iterator",Cu=Iu.set,Pu=Iu.getterFor(wu);Du(Array,"Array",(function(e,t){Cu(this,{type:wu,target:bu(e),index:0,kind:t})}),(function(){var e=Pu(this),t=e.target,r=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,_u(void 0,!0)):_u("keys"==r?i:"values"==r?t[i]:[i,t[i]],!1)}),"values"),Ru.Arguments=Ru.Array;var xu={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},Mu=s,Ou=ui,Fu=yr,Nu=El,Uu=vt("toStringTag");for(var Bu in xu){var Gu=Mu[Bu],Ku=Gu&&Gu.prototype;Ku&&Ou(Ku)!==Uu&&Fu(Ku,Uu,Bu),Nu[Bu]=Nu.Array}var Hu=yl;La("dispose");var Vu=Hu;La("asyncDispose");var ju=wr,Yu=y,qu=le("Symbol"),Wu=qu.keyFor,zu=Yu(qu.prototype.valueOf);ju({target:"Symbol",stat:!0},{isRegistered:function(e){try{return void 0!==Wu(zu(e))}catch(t){return!1}}});for(var Xu=wr,Qu=ze,$u=le,Ju=y,Zu=Ie,ec=vt,tc=$u("Symbol"),rc=tc.isWellKnown,ic=$u("Object","getOwnPropertyNames"),nc=Ju(tc.prototype.valueOf),ac=Qu("wks"),sc=0,oc=ic(tc),lc=oc.length;sc<lc;sc++)try{var uc=oc[sc];Zu(tc[uc])&&ec(uc)}catch(JV){}Xu({target:"Symbol",stat:!0,forced:!0},{isWellKnown:function(e){if(rc&&rc(e))return!0;try{for(var t=nc(e),r=0,i=ic(ac),n=i.length;r<n;r++)if(ac[i[r]]==t)return!0}catch(JV){}return!1}}),La("matcher"),La("metadataKey"),La("observable"),La("metadata"),La("patternMatch"),La("replaceAll");var cc=Vu,hc=i(cc),dc=y,fc=Vr,vc=tn,gc=Q,pc=dc("".charAt),mc=dc("".charCodeAt),yc=dc("".slice),Ec=function(e){return function(t,r){var i,n,a=vc(gc(t)),s=fc(r),o=a.length;return s<0||s>=o?e?"":void 0:(i=mc(a,s))<55296||i>56319||s+1===o||(n=mc(a,s+1))<56320||n>57343?e?pc(a,s):i:e?yc(a,s,s+2):n-56320+(i-55296<<10)+65536}},kc={codeAt:Ec(!1),charAt:Ec(!0)},Tc=kc.charAt,Sc=tn,Ac=es,Lc=Au,bc=Lu,Rc="String Iterator",Ic=Ac.set,Dc=Ac.getterFor(Rc);Lc(String,"String",(function(e){Ic(this,{type:Rc,string:Sc(e),index:0})}),(function(){var e,t=Dc(this),r=t.string,i=t.index;return i>=r.length?bc(void 0,!0):(e=Tc(r,i),t.index+=e.length,bc(e,!1))}));var _c=ga.f("iterator"),wc=i(_c);function Cc(e){return(Cc="function"==typeof hc&&"symbol"==typeof wc?function(e){return typeof e}:function(e){return e&&"function"==typeof hc&&e.constructor===hc&&e!==hc.prototype?"symbol":typeof e})(e)}var Pc=ga.f("toPrimitive"),xc=i(Pc);function Mc(e){var t=function(e,t){if("object"!==Cc(e)||null===e)return e;var r=e[xc];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Cc(t)?t:String(t)}function Oc(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Nr(e,Mc(i.key),i)}}function Fc(e,t,r){return t&&Oc(e.prototype,t),r&&Oc(e,r),Nr(e,"prototype",{writable:!1}),e}var Nc=et,Uc=M,Bc=re,Gc=nr,Kc=function(e){return void 0!==e&&(Nc(e,"value")||Nc(e,"writable"))},Hc=w,Vc=Ml;wr({target:"Reflect",stat:!0},{get:function e(t,r){var i,n,a=arguments.length<3?t:arguments[2];return Gc(t)===a?t[r]:(i=Hc.f(t,r))?Kc(i)?i.value:void 0===i.get?void 0:Uc(i.get,a):Bc(n=Vc(t))?e(n,r,a):void 0}});var jc=i(ie.Reflect.get),Yc=y,qc=xe,Wc=re,zc=et,Xc=xo,Qc=l,$c=Function,Jc=Yc([].concat),Zc=Yc([].join),eh={},th=Qc?$c.bind:function(e){var t=qc(this),r=t.prototype,i=Xc(arguments,1),n=function(){var r=Jc(i,Xc(arguments));return this instanceof n?function(e,t,r){if(!zc(eh,t)){for(var i=[],n=0;n<t;n++)i[n]="a["+n+"]";eh[t]=$c("C,a","return new C("+Zc(i,",")+")")}return eh[t](e,r)}(t,r.length,r):t.apply(e,r)};return Wc(r)&&(n.prototype=r),n},rh=th;wr({target:"Function",proto:!0,forced:Function.bind!==rh},{bind:rh});var ih=ie,nh=function(e){return ih[e+"Prototype"]},ah=nh("Function").bind,sh=ue,oh=ah,lh=Function.prototype,uh=function(e){var t=e.bind;return e===lh||sh(lh,e)&&t===lh.bind?oh:t},ch=i(uh),hh={exports:{}},dh=wr,fh=o,vh=Z,gh=w.f,ph=C;dh({target:"Object",stat:!0,forced:!ph||fh((function(){gh(1)})),sham:!ph},{getOwnPropertyDescriptor:function(e,t){return gh(vh(e),t)}});var mh=ie.Object,yh=hh.exports=function(e,t){return mh.getOwnPropertyDescriptor(e,t)};mh.getOwnPropertyDescriptor.sham&&(yh.sham=!0);var Eh=hh.exports,kh=i(Eh);wr({target:"Object",stat:!0},{setPrototypeOf:su});var Th=i(ie.Object.setPrototypeOf),Sh=$e,Ah=Ml,Lh=Rl;wr({target:"Object",stat:!0,forced:o((function(){Ah(1)})),sham:!Lh},{getPrototypeOf:function(e){return Ah(Sh(e))}});var bh=i(ie.Object.getPrototypeOf);function Rh(e){var t;return(Rh=Th?ch(t=bh).call(t):function(e){return e.__proto__||bh(e)})(e)}function Ih(){var e;"undefined"!=typeof Reflect&&jc?Ih=ch(e=jc).call(e):Ih=function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Rh(e)););return e}(e,t);if(i){var n=kh(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}};return Ih.apply(this,arguments)}wr({target:"Object",stat:!0,sham:!C},{create:zn});var Dh=ie.Object,_h=function(e,t){return Dh.create(e,t)},wh=i(_h);function Ch(e,t){var r;return(Ch=Th?ch(r=Th).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function Ph(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=wh(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Nr(e,"prototype",{writable:!1}),t&&Ch(e,t)}var xh=Ii,Mh=_e,Oh=TypeError,Fh=function(e){if(xh(e))return e;throw Oh(Mh(e)+" is not a constructor")},Nh=wr,Uh=f,Bh=th,Gh=Fh,Kh=nr,Hh=re,Vh=zn,jh=o,Yh=le("Reflect","construct"),qh=Object.prototype,Wh=[].push,zh=jh((function(){function e(){}return!(Yh((function(){}),[],e)instanceof e)})),Xh=!jh((function(){Yh((function(){}))})),Qh=zh||Xh;Nh({target:"Reflect",stat:!0,forced:Qh,sham:Qh},{construct:function(e,t){Gh(e),Kh(t);var r=arguments.length<3?e:Gh(arguments[2]);if(Xh&&!zh)return Yh(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var i=[null];return Uh(Wh,i,t),new(Uh(Bh,e,i))}var n=r.prototype,a=Vh(Hh(n)?n:qh),s=Uh(e,a,t);return Hh(s)?s:a}});var $h=i(ie.Reflect.construct);function Jh(){if("undefined"==typeof Reflect||!$h)return!1;if($h.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call($h(Boolean,[],(function(){}))),!0}catch(e){return!1}}function Zh(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ed(e){var t=Jh();return function(){var r,i=Rh(e);if(t){var n=Rh(this).constructor;r=$h(i,arguments,n)}else r=i.apply(this,arguments);return function(e,t){if(t&&("object"===Cc(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Zh(e)}(this,r)}}var td=o,rd=function(e,t){var r=[][e];return!!r&&td((function(){r.call(null,t||function(){return 1},1)}))},id=ls.forEach,nd=rd("forEach")?[].forEach:function(e){return id(this,e,arguments.length>1?arguments[1]:void 0)};wr({target:"Array",proto:!0,forced:[].forEach!=nd},{forEach:nd});var ad=nh("Array").forEach,sd=ui,od=et,ld=ue,ud=ad,cd=Array.prototype,hd={DOMTokenList:!0,NodeList:!0},dd=function(e){var t=e.forEach;return e===cd||ld(cd,e)&&t===cd.forEach||od(hd,sd(e))?ud:t},fd=i(dd),vd=i(dd),gd=C,pd=y,md=An,yd=Z,Ed=pd(O.f),kd=pd([].push),Td=function(e){return function(t){for(var r,i=yd(t),n=md(i),a=n.length,s=0,o=[];a>s;)r=n[s++],gd&&!Ed(i,r)||kd(o,e?[r,i[r]]:i[r]);return o}},Sd={entries:Td(!0),values:Td(!1)},Ad=Sd.values;wr({target:"Object",stat:!0},{values:function(e){return Ad(e)}});var Ld=i(ie.Object.values),bd=nh("Array").concat,Rd=ue,Id=bd,Dd=Array.prototype,_d=i((function(e){var t=e.concat;return e===Dd||Rd(Dd,e)&&t===Dd.concat?Id:t})),wd=$e,Cd=An;wr({target:"Object",stat:!0,forced:o((function(){Cd(1)}))},{keys:function(e){return Cd(wd(e))}});var Pd=ie.Object.keys,xd=i(Pd),Md=ie.Object.getOwnPropertySymbols,Od=i(Md),Fd=ls.filter;wr({target:"Array",proto:!0,forced:!Ui("filter")},{filter:function(e){return Fd(this,e,arguments.length>1?arguments[1]:void 0)}});var Nd=nh("Array").filter,Ud=ue,Bd=Nd,Gd=Array.prototype,Kd=function(e){var t=e.filter;return e===Gd||Ud(Gd,e)&&t===Gd.filter?Bd:t},Hd=i(Kd),Vd=C,jd=Br,Yd=TypeError,qd=Object.getOwnPropertyDescriptor,Wd=Vd&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(JV){return JV instanceof TypeError}}()?function(e,t){if(jd(e)&&!qd(e,"length").writable)throw Yd("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},zd=$e,Xd=zr,Qd=Wd,$d=Qr;wr({target:"Array",proto:!0,arity:1,forced:o((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(JV){return JV instanceof TypeError}}()},{push:function(e){var t=zd(this),r=Xd(t),i=arguments.length;$d(r+i);for(var n=0;n<i;n++)t[r]=arguments[n],r++;return Qd(t,r),r}});var Jd=nh("Array").push,Zd=ue,ef=Jd,tf=Array.prototype,rf=i((function(e){var t=e.push;return e===tf||Zd(tf,e)&&t===tf.push?ef:t})),nf=le,af=Xn,sf=ca,of=nr,lf=y([].concat),uf=nf("Reflect","ownKeys")||function(e){var t=af.f(of(e)),r=sf.f;return r?lf(t,r(e)):t},cf=uf,hf=Z,df=w,ff=ei;wr({target:"Object",stat:!0,sham:!C},{getOwnPropertyDescriptors:function(e){for(var t,r,i=hf(e),n=df.f,a=cf(i),s={},o=0;a.length>o;)void 0!==(r=n(i,t=a[o++]))&&ff(s,t,r);return s}});var vf=ie.Object.getOwnPropertyDescriptors,gf=i(vf),pf={exports:{}},mf=wr,yf=C,Ef=rn.f;mf({target:"Object",stat:!0,forced:Object.defineProperties!==Ef,sham:!yf},{defineProperties:Ef});var kf=ie.Object,Tf=pf.exports=function(e,t){return kf.defineProperties(e,t)};kf.defineProperties.sham&&(Tf.sham=!0);var Sf=pf.exports,Af=i(Sf);function Lf(e,t,r){return(t=Mc(t))in e?Nr(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bf(e,t){var r=xd(e);if(Od){var i=Od(e);t&&(i=Hd(i).call(i,(function(t){return kh(e,t).enumerable}))),rf(r).apply(r,i)}return r}function Rf(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?fd(r=bf(Object(n),!0)).call(r,(function(t){Lf(e,t,n[t])})):gf?Af(e,gf(n)):fd(i=bf(Object(n))).call(i,(function(t){Nr(e,t,kh(n,t))}))}return e}var If,Df="function"==typeof Bun&&Bun&&"string"==typeof Bun.version,_f=TypeError,wf=function(e,t){if(e<t)throw _f("Not enough arguments");return e},Cf=s,Pf=f,xf=_,Mf=Df,Of=ce,Ff=xo,Nf=wf,Uf=Cf.Function,Bf=/MSIE .\./.test(Of)||Mf&&((If=Cf.Bun.version.split(".")).length<3||0==If[0]&&(If[1]<3||3==If[1]&&0==If[2])),Gf=function(e,t){var r=t?2:1;return Bf?function(i,n){var a=Nf(arguments.length,1)>r,s=xf(i)?i:Uf(i),o=a?Ff(arguments,r):[],l=a?function(){Pf(s,this,o)}:s;return t?e(l,n):e(l)}:e},Kf=wr,Hf=s,Vf=Gf(Hf.setInterval,!0);Kf({global:!0,bind:!0,forced:Hf.setInterval!==Vf},{setInterval:Vf});var jf=wr,Yf=s,qf=Gf(Yf.setTimeout,!0);jf({global:!0,bind:!0,forced:Yf.setTimeout!==qf},{setTimeout:qf});var Wf=i(ie.setTimeout),zf=wr,Xf=dn.indexOf,Qf=rd,$f=b([].indexOf),Jf=!!$f&&1/$f([1],1,-0)<0;zf({target:"Array",proto:!0,forced:Jf||!Qf("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return Jf?$f(this,e,t)||0:Xf(this,e,t)}});var Zf=nh("Array").indexOf,ev=ue,tv=Zf,rv=Array.prototype,iv=function(e){var t=e.indexOf;return e===rv||ev(rv,e)&&t===rv.indexOf?tv:t},nv=i(iv),av=i(iv);wr({target:"Array",stat:!0},{isArray:Br});var sv=ie.Array.isArray,ov=i(sv),lv=i(sv),uv=wr,cv=ls.find,hv="find",dv=!0;hv in[]&&Array(1)[hv]((function(){dv=!1})),uv({target:"Array",proto:!0,forced:dv},{find:function(e){return cv(this,e,arguments.length>1?arguments[1]:void 0)}});var fv=nh("Array").find,vv=ue,gv=fv,pv=Array.prototype,mv=i((function(e){var t=e.find;return e===pv||vv(pv,e)&&t===pv.find?gv:t})),yv=i(Pd),Ev=wr,kv=Br,Tv=Ii,Sv=re,Av=on,Lv=zr,bv=Z,Rv=ei,Iv=vt,Dv=xo,_v=Ui("slice"),wv=Iv("species"),Cv=Array,Pv=Math.max;Ev({target:"Array",proto:!0,forced:!_v},{slice:function(e,t){var r,i,n,a=bv(this),s=Lv(a),o=Av(e,s),l=Av(void 0===t?s:t,s);if(kv(a)&&(r=a.constructor,(Tv(r)&&(r===Cv||kv(r.prototype))||Sv(r)&&null===(r=r[wv]))&&(r=void 0),r===Cv||void 0===r))return Dv(a,o,l);for(i=new(void 0===r?Cv:r)(Pv(l-o,0)),n=0;o<l;o++,n++)o in a&&Rv(i,n,a[o]);return i.length=n,i}});var xv=nh("Array").slice,Mv=ue,Ov=xv,Fv=Array.prototype,Nv=function(e){var t=e.slice;return e===Fv||Mv(Fv,e)&&t===Fv.slice?Ov:t},Uv=i(Nv),Bv=i(Nv),Gv=_e,Kv=TypeError,Hv=function(e,t){if(!delete e[t])throw Kv("Cannot delete property "+Gv(t)+" of "+Gv(e))},Vv=wr,jv=$e,Yv=on,qv=Vr,Wv=zr,zv=Wd,Xv=Qr,Qv=Mi,$v=ei,Jv=Hv,Zv=Ui("splice"),eg=Math.max,tg=Math.min;Vv({target:"Array",proto:!0,forced:!Zv},{splice:function(e,t){var r,i,n,a,s,o,l=jv(this),u=Wv(l),c=Yv(e,u),h=arguments.length;for(0===h?r=i=0:1===h?(r=0,i=u-c):(r=h-2,i=tg(eg(qv(t),0),u-c)),Xv(u+r-i),n=Qv(l,i),a=0;a<i;a++)(s=c+a)in l&&$v(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]:Jv(l,o);for(a=u;a>u-i+r;a--)Jv(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]:Jv(l,o);for(a=0;a<r;a++)l[a+c]=arguments[a+2];return zv(l,u-i+r),n}});var rg=nh("Array").splice,ig=ue,ng=rg,ag=Array.prototype,sg=i((function(e){var t=e.splice;return e===ag||ig(ag,e)&&t===ag.splice?ng:t})),og=et,lg=uf,ug=w,cg=Zt,hg=re,dg=yr,fg=Error,vg=y("".replace),gg=String(fg("zxcasd").stack),pg=/\n\s*at [^:]*:[^\n]*/,mg=pg.test(gg),yg=K,Eg=!o((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",yg(1,7)),7!==e.stack)})),kg=yr,Tg=function(e,t){if(mg&&"string"==typeof e&&!fg.prepareStackTrace)for(;t--;)e=vg(e,pg,"");return e},Sg=Eg,Ag=Error.captureStackTrace,Lg=El,bg=vt("iterator"),Rg=Array.prototype,Ig=function(e){return void 0!==e&&(Lg.Array===e||Rg[bg]===e)},Dg=ui,_g=Fe,wg=W,Cg=El,Pg=vt("iterator"),xg=function(e){if(!wg(e))return _g(e,Pg)||_g(e,"@@iterator")||Cg[Dg(e)]},Mg=M,Og=xe,Fg=nr,Ng=_e,Ug=xg,Bg=TypeError,Gg=function(e,t){var r=arguments.length<2?Ug(e):t;if(Og(r))return Fg(Mg(r,e));throw Bg(Ng(e)+" is not iterable")},Kg=M,Hg=nr,Vg=Fe,jg=function(e,t,r){var i,n;Hg(e);try{if(!(i=Vg(e,"return"))){if("throw"===t)throw r;return r}i=Kg(i,e)}catch(JV){n=!0,i=JV}if("throw"===t)throw r;if(n)throw i;return Hg(i),r},Yg=Jt,qg=M,Wg=nr,zg=_e,Xg=Ig,Qg=zr,$g=ue,Jg=Gg,Zg=xg,ep=jg,tp=TypeError,rp=function(e,t){this.stopped=e,this.result=t},ip=rp.prototype,np=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=Yg(t,c),p=function(e){return i&&ep(i,"normal",e),new rp(!0,e)},m=function(e){return h?(Wg(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=Zg(e)))throw tp(zg(e)+" is not iterable");if(Xg(n)){for(a=0,s=Qg(e);s>a;a++)if((o=m(e[a]))&&$g(ip,o))return o;return new rp(!1)}i=Jg(e,n)}for(l=d?e.next:i.next;!(u=qg(l,i)).done;){try{o=m(u.value)}catch(JV){ep(i,"throw",JV)}if("object"==typeof o&&o&&$g(ip,o))return o}return new rp(!1)},ap=tn,sp=wr,op=ue,lp=Ml,up=su,cp=function(e,t,r){for(var i=lg(t),n=cg.f,a=ug.f,s=0;s<i.length;s++){var o=i[s];og(e,o)||r&&og(r,o)||n(e,o,a(t,o))}},hp=zn,dp=yr,fp=K,vp=function(e,t){hg(t)&&"cause"in t&&dg(e,"cause",t.cause)},gp=function(e,t,r,i){Sg&&(Ag?Ag(e,t):kg(e,"stack",Tg(r,i)))},pp=np,mp=function(e,t){return void 0===e?arguments.length<2?"":t:ap(e)},yp=vt("toStringTag"),Ep=Error,kp=[].push,Tp=function(e,t){var r,i=op(Sp,this);up?r=up(Ep(),i?lp(this):Sp):(r=i?this:hp(Sp),dp(r,yp,"Error")),void 0!==t&&dp(r,"message",mp(t)),gp(r,Tp,r.stack,1),arguments.length>2&&vp(r,arguments[2]);var n=[];return pp(e,kp,{that:n}),dp(r,"errors",n),r};up?up(Tp,Ep):cp(Tp,Ep,{name:!0});var Sp=Tp.prototype=hp(Ep.prototype,{constructor:fp(1,Tp),message:fp(1,""),name:fp(1,"AggregateError")});sp({global:!0,constructor:!0,arity:2},{AggregateError:Tp});var Ap,Lp,bp,Rp,Ip="undefined"!=typeof process&&"process"==S(process),Dp=le,_p=va,wp=C,Cp=vt("species"),Pp=function(e){var t=Dp(e);wp&&t&&!t[Cp]&&_p(t,Cp,{configurable:!0,get:function(){return this}})},xp=ue,Mp=TypeError,Op=function(e,t){if(xp(t,e))return e;throw Mp("Incorrect invocation")},Fp=nr,Np=Fh,Up=W,Bp=vt("species"),Gp=function(e,t){var r,i=Fp(e).constructor;return void 0===i||Up(r=Fp(i)[Bp])?t:Np(r)},Kp=/(?:ipad|iphone|ipod).*applewebkit/i.test(ce),Hp=s,Vp=f,jp=Jt,Yp=_,qp=et,Wp=o,zp=Cn,Xp=xo,Qp=Dt,$p=wf,Jp=Kp,Zp=Ip,em=Hp.setImmediate,tm=Hp.clearImmediate,rm=Hp.process,im=Hp.Dispatch,nm=Hp.Function,am=Hp.MessageChannel,sm=Hp.String,om=0,lm={},um="onreadystatechange";Wp((function(){Ap=Hp.location}));var cm=function(e){if(qp(lm,e)){var t=lm[e];delete lm[e],t()}},hm=function(e){return function(){cm(e)}},dm=function(e){cm(e.data)},fm=function(e){Hp.postMessage(sm(e),Ap.protocol+"//"+Ap.host)};em&&tm||(em=function(e){$p(arguments.length,1);var t=Yp(e)?e:nm(e),r=Xp(arguments,1);return lm[++om]=function(){Vp(t,void 0,r)},Lp(om),om},tm=function(e){delete lm[e]},Zp?Lp=function(e){rm.nextTick(hm(e))}:im&&im.now?Lp=function(e){im.now(hm(e))}:am&&!Jp?(Rp=(bp=new am).port2,bp.port1.onmessage=dm,Lp=jp(Rp.postMessage,Rp)):Hp.addEventListener&&Yp(Hp.postMessage)&&!Hp.importScripts&&Ap&&"file:"!==Ap.protocol&&!Wp(fm)?(Lp=fm,Hp.addEventListener("message",dm,!1)):Lp=um in Qp("script")?function(e){zp.appendChild(Qp("script"))[um]=function(){zp.removeChild(this),cm(e)}}:function(e){setTimeout(hm(e),0)});var vm={set:em,clear:tm},gm=function(){this.head=null,this.tail=null};gm.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 pm,mm,ym,Em,km,Tm=gm,Sm=/ipad|iphone|ipod/i.test(ce)&&"undefined"!=typeof Pebble,Am=/web0s(?!.*chrome)/i.test(ce),Lm=s,bm=Jt,Rm=w.f,Im=vm.set,Dm=Tm,_m=Kp,wm=Sm,Cm=Am,Pm=Ip,xm=Lm.MutationObserver||Lm.WebKitMutationObserver,Mm=Lm.document,Om=Lm.process,Fm=Lm.Promise,Nm=Rm(Lm,"queueMicrotask"),Um=Nm&&Nm.value;if(!Um){var Bm=new Dm,Gm=function(){var e,t;for(Pm&&(e=Om.domain)&&e.exit();t=Bm.get();)try{t()}catch(JV){throw Bm.head&&pm(),JV}e&&e.enter()};_m||Pm||Cm||!xm||!Mm?!wm&&Fm&&Fm.resolve?((Em=Fm.resolve(void 0)).constructor=Fm,km=bm(Em.then,Em),pm=function(){km(Gm)}):Pm?pm=function(){Om.nextTick(Gm)}:(Im=bm(Im,Lm),pm=function(){Im(Gm)}):(mm=!0,ym=Mm.createTextNode(""),new xm(Gm).observe(ym,{characterData:!0}),pm=function(){ym.data=mm=!mm}),Um=function(e){Bm.head||pm(),Bm.add(e)}}var Km=Um,Hm=function(e){try{return{error:!1,value:e()}}catch(JV){return{error:!0,value:JV}}},Vm=s.Promise,jm="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Ym=!jm&&!Ip&&"object"==typeof window&&"object"==typeof document,qm=s,Wm=Vm,zm=_,Xm=zt,Qm=fi,$m=vt,Jm=Ym,Zm=jm,ey=me,ty=Wm&&Wm.prototype,ry=$m("species"),iy=!1,ny=zm(qm.PromiseRejectionEvent),ay={CONSTRUCTOR:Xm("Promise",(function(){var e=Qm(Wm),t=e!==String(Wm);if(!t&&66===ey)return!0;if(!ty.catch||!ty.finally)return!0;if(!ey||ey<51||!/native code/.test(e)){var r=new Wm((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[ry]=i,!(iy=r.then((function(){}))instanceof i))return!0}return!t&&(Jm||Zm)&&!ny})),REJECTION_EVENT:ny,SUBCLASSING:iy},sy={},oy=xe,ly=TypeError,uy=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw ly("Bad Promise constructor");t=e,r=i})),this.resolve=oy(t),this.reject=oy(r)};sy.f=function(e){return new uy(e)};var cy,hy,dy=wr,fy=Ip,vy=s,gy=M,py=da,my=Ua,yy=Pp,Ey=xe,ky=_,Ty=re,Sy=Op,Ay=Gp,Ly=vm.set,by=Km,Ry=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(JV){}},Iy=Hm,Dy=Tm,_y=es,wy=Vm,Cy=ay,Py=sy,xy="Promise",My=Cy.CONSTRUCTOR,Oy=Cy.REJECTION_EVENT,Fy=_y.getterFor(xy),Ny=_y.set,Uy=wy&&wy.prototype,By=wy,Gy=Uy,Ky=vy.TypeError,Hy=vy.document,Vy=vy.process,jy=Py.f,Yy=jy,qy=!!(Hy&&Hy.createEvent&&vy.dispatchEvent),Wy="unhandledrejection",zy=function(e){var t;return!(!Ty(e)||!ky(t=e.then))&&t},Xy=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&&eE(t),t.rejection=1),!0===o?r=a:(c&&c.enter(),r=o(a),c&&(c.exit(),n=!0)),r===e.promise?u(Ky("Promise-chain cycle")):(i=zy(r))?gy(i,r,l,u):l(r)):u(a)}catch(JV){c&&!n&&c.exit(),u(JV)}},Qy=function(e,t){e.notified||(e.notified=!0,by((function(){for(var r,i=e.reactions;r=i.get();)Xy(r,e);e.notified=!1,t&&!e.rejection&&Jy(e)})))},$y=function(e,t,r){var i,n;qy?((i=Hy.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),vy.dispatchEvent(i)):i={promise:t,reason:r},!Oy&&(n=vy["on"+e])?n(i):e===Wy&&Ry("Unhandled promise rejection",r)},Jy=function(e){gy(Ly,vy,(function(){var t,r=e.facade,i=e.value;if(Zy(e)&&(t=Iy((function(){fy?Vy.emit("unhandledRejection",i,r):$y(Wy,r,i)})),e.rejection=fy||Zy(e)?2:1,t.error))throw t.value}))},Zy=function(e){return 1!==e.rejection&&!e.parent},eE=function(e){gy(Ly,vy,(function(){var t=e.facade;fy?Vy.emit("rejectionHandled",t):$y("rejectionhandled",t,e.value)}))},tE=function(e,t,r){return function(i){e(t,i,r)}},rE=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Qy(e,!0))},iE=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Ky("Promise can't be resolved itself");var i=zy(t);i?by((function(){var r={done:!1};try{gy(i,t,tE(iE,r,e),tE(rE,r,e))}catch(JV){rE(r,JV,e)}})):(e.value=t,e.state=1,Qy(e,!1))}catch(JV){rE({done:!1},JV,e)}}};My&&(Gy=(By=function(e){Sy(this,Gy),Ey(e),gy(cy,this);var t=Fy(this);try{e(tE(iE,t),tE(rE,t))}catch(JV){rE(t,JV)}}).prototype,(cy=function(e){Ny(this,{type:xy,done:!1,notified:!1,parent:!1,reactions:new Dy,rejection:!1,state:0,value:void 0})}).prototype=py(Gy,"then",(function(e,t){var r=Fy(this),i=jy(Ay(this,By));return r.parent=!0,i.ok=!ky(e)||e,i.fail=ky(t)&&t,i.domain=fy?Vy.domain:void 0,0==r.state?r.reactions.add(i):by((function(){Xy(i,r)})),i.promise})),hy=function(){var e=new cy,t=Fy(e);this.promise=e,this.resolve=tE(iE,t),this.reject=tE(rE,t)},Py.f=jy=function(e){return e===By||undefined===e?new hy(e):Yy(e)}),dy({global:!0,constructor:!0,wrap:!0,forced:My},{Promise:By}),my(By,xy,!1,!0),yy(xy);var nE=vt("iterator"),aE=!1;try{var sE=0,oE={next:function(){return{done:!!sE++}},return:function(){aE=!0}};oE[nE]=function(){return this},Array.from(oE,(function(){throw 2}))}catch(JV){}var lE=function(e,t){if(!t&&!aE)return!1;var r=!1;try{var i={};i[nE]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(JV){}return r},uE=Vm,cE=ay.CONSTRUCTOR||!lE((function(e){uE.all(e).then(void 0,(function(){}))})),hE=M,dE=xe,fE=sy,vE=Hm,gE=np;wr({target:"Promise",stat:!0,forced:cE},{all:function(e){var t=this,r=fE.f(t),i=r.resolve,n=r.reject,a=vE((function(){var r=dE(t.resolve),a=[],s=0,o=1;gE(e,(function(e){var l=s++,u=!1;o++,hE(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 pE=wr,mE=ay.CONSTRUCTOR;Vm&&Vm.prototype,pE({target:"Promise",proto:!0,forced:mE,real:!0},{catch:function(e){return this.then(void 0,e)}});var yE=M,EE=xe,kE=sy,TE=Hm,SE=np;wr({target:"Promise",stat:!0,forced:cE},{race:function(e){var t=this,r=kE.f(t),i=r.reject,n=TE((function(){var n=EE(t.resolve);SE(e,(function(e){yE(n,t,e).then(r.resolve,i)}))}));return n.error&&i(n.value),r.promise}});var AE=M,LE=sy;wr({target:"Promise",stat:!0,forced:ay.CONSTRUCTOR},{reject:function(e){var t=LE.f(this);return AE(t.reject,void 0,e),t.promise}});var bE=nr,RE=re,IE=sy,DE=function(e,t){if(bE(e),RE(t)&&t.constructor===e)return t;var r=IE.f(e);return(0,r.resolve)(t),r.promise},_E=wr,wE=Vm,CE=ay.CONSTRUCTOR,PE=DE,xE=le("Promise"),ME=!CE;_E({target:"Promise",stat:!0,forced:true},{resolve:function(e){return PE(ME&&this===xE?wE:this,e)}});var OE=M,FE=xe,NE=sy,UE=Hm,BE=np;wr({target:"Promise",stat:!0,forced:cE},{allSettled:function(e){var t=this,r=NE.f(t),i=r.resolve,n=r.reject,a=UE((function(){var r=FE(t.resolve),n=[],a=0,s=1;BE(e,(function(e){var o=a++,l=!1;s++,OE(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 GE=M,KE=xe,HE=le,VE=sy,jE=Hm,YE=np,qE="No one promise resolved";wr({target:"Promise",stat:!0,forced:cE},{any:function(e){var t=this,r=HE("AggregateError"),i=VE.f(t),n=i.resolve,a=i.reject,s=jE((function(){var i=KE(t.resolve),s=[],o=0,l=1,u=!1;YE(e,(function(e){var c=o++,h=!1;l++,GE(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,qE)))}))})),--l||a(new r(s,qE))}));return s.error&&a(s.value),i.promise}});var WE=wr,zE=Vm,XE=o,QE=le,$E=_,JE=Gp,ZE=DE,ek=zE&&zE.prototype;WE({target:"Promise",proto:!0,real:!0,forced:!!zE&&XE((function(){ek.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=JE(this,QE("Promise")),r=$E(e);return this.then(r?function(r){return ZE(t,e()).then((function(){return r}))}:e,r?function(r){return ZE(t,e()).then((function(){throw r}))}:e)}});var tk=ie.Promise,rk=sy,ik=Hm;wr({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=rk.f(this),r=ik(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var nk=i(tk),ak="\t\n\v\f\r                 \u2028\u2029\ufeff",sk=Q,ok=tn,lk=ak,uk=y("".replace),ck=RegExp("^["+lk+"]+"),hk=RegExp("(^|[^"+lk+"])["+lk+"]+$"),dk=function(e){return function(t){var r=ok(sk(t));return 1&e&&(r=uk(r,ck,"")),2&e&&(r=uk(r,hk,"$1")),r}},fk={start:dk(1),end:dk(2),trim:dk(3)},vk=s,gk=o,pk=y,mk=tn,yk=fk.trim,Ek=ak,kk=vk.parseInt,Tk=vk.Symbol,Sk=Tk&&Tk.iterator,Ak=/^[+-]?0x/i,Lk=pk(Ak.exec),bk=8!==kk(Ek+"08")||22!==kk(Ek+"0x16")||Sk&&!gk((function(){kk(Object(Sk))}))?function(e,t){var r=yk(mk(e));return kk(r,t>>>0||(Lk(Ak,r)?16:10))}:kk;wr({global:!0,forced:parseInt!=bk},{parseInt:bk});var Rk=i(ie.parseInt),Ik=ls.map;wr({target:"Array",proto:!0,forced:!Ui("map")},{map:function(e){return Ik(this,e,arguments.length>1?arguments[1]:void 0)}});var Dk=nh("Array").map,_k=ue,wk=Dk,Ck=Array.prototype,Pk=i((function(e){var t=e.map;return e===Ck||_k(Ck,e)&&t===Ck.map?wk:t})),xk=i(Kd),Mk=C,Ok=y,Fk=M,Nk=o,Uk=An,Bk=ca,Gk=O,Kk=$e,Hk=q,Vk=Object.assign,jk=Object.defineProperty,Yk=Ok([].concat),qk=!Vk||Nk((function(){if(Mk&&1!==Vk({b:1},Vk(jk({},"a",{enumerable:!0,get:function(){jk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),i="abcdefghijklmnopqrst";return e[r]=7,i.split("").forEach((function(e){t[e]=e})),7!=Vk({},e)[r]||Uk(Vk({},t)).join("")!=i}))?function(e,t){for(var r=Kk(e),i=arguments.length,n=1,a=Bk.f,s=Gk.f;i>n;)for(var o,l=Hk(arguments[n++]),u=a?Yk(Uk(l),a(l)):Uk(l),c=u.length,h=0;c>h;)o=u[h++],Mk&&!Fk(s,l,o)||(r[o]=l[o]);return r}:Vk,Wk=qk;wr({target:"Object",stat:!0,arity:2,forced:Object.assign!==Wk},{assign:Wk});var zk=i(ie.Object.assign),Xk=i(cc),Qk=xg,$k=i(Qk),Jk=i(Qk),Zk=i(Md),eT=i(Eh),tT=i(vf),rT=i(Sf),iT=i(Fr),nT=i(_c),aT=i(_h),sT=i(uh),oT=nr,lT=jg,uT=Jt,cT=M,hT=$e,dT=function(e,t,r,i){try{return i?t(oT(r)[0],r[1]):t(r)}catch(JV){lT(e,"throw",JV)}},fT=Ig,vT=Ii,gT=zr,pT=ei,mT=Gg,yT=xg,ET=Array,kT=function(e){var t=hT(e),r=vT(this),i=arguments.length,n=i>1?arguments[1]:void 0,a=void 0!==n;a&&(n=uT(n,i>2?arguments[2]:void 0));var s,o,l,u,c,h,d=yT(t),f=0;if(!d||this===ET&&fT(d))for(s=gT(t),o=r?new this(s):ET(s);s>f;f++)h=a?n(t[f],f):t[f],pT(o,f,h);else for(c=(u=mT(t,d)).next,o=r?new this:[];!(l=cT(c,u)).done;f++)h=a?dT(u,n,[l.value,f],!0):l.value,pT(o,f,h);return o.length=f,o},TT=kT;wr({target:"Array",stat:!0,forced:!lE((function(e){Array.from(e)}))},{from:TT});var ST=ie.Array.from,AT=i(ST),LT=i(ST),bT=i(Pc);function RT(e,t){var r=yv(e);if(Zk){var i=Zk(e);t&&(i=xk(i).call(i,(function(t){return eT(e,t).enumerable}))),r.push.apply(r,i)}return r}function IT(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=RT(Object(n),!0)).call(r,(function(t){PT(e,t,n[t])})):tT?rT(e,tT(n)):vd(i=RT(Object(n))).call(i,(function(t){iT(e,t,eT(n,t))}))}return e}function DT(e){return(DT="function"==typeof Xk&&"symbol"==typeof nT?function(e){return typeof e}:function(e){return e&&"function"==typeof Xk&&e.constructor===Xk&&e!==Xk.prototype?"symbol":typeof e})(e)}function _T(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wT(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),iT(e,OT(i.key),i)}}function CT(e,t,r){return t&&wT(e.prototype,t),r&&wT(e,r),iT(e,"prototype",{writable:!1}),e}function PT(e,t,r){return(t=OT(t))in e?iT(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xT(e){return function(e){if(lv(e))return MT(e)}(e)||function(e){if(void 0!==Xk&&null!=Jk(e)||null!=e["@@iterator"])return LT(e)}(e)||function(e,t){var r;if(!e)return;if("string"==typeof e)return MT(e,t);var i=Bv(r=Object.prototype.toString.call(e)).call(r,8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return LT(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return MT(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function MT(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function OT(e){var t=function(e,t){if("object"!==Cc(e)||null===e)return e;var r=e[bT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Cc(t)?t:String(t)}var FT=ls.some;wr({target:"Array",proto:!0,forced:!rd("some")},{some:function(e){return FT(this,e,arguments.length>1?arguments[1]:void 0)}});var NT=nh("Array").some,UT=ue,BT=NT,GT=Array.prototype,KT=i((function(e){var t=e.some;return e===GT||UT(GT,e)&&t===GT.some?BT:t})),HT=Vr,VT=tn,jT=Q,YT=RangeError,qT=y,WT=qr,zT=tn,XT=Q,QT=qT((function(e){var t=VT(jT(this)),r="",i=HT(e);if(i<0||i==1/0)throw YT("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r})),$T=qT("".slice),JT=Math.ceil,ZT=function(e){return function(t,r,i){var n,a,s=zT(XT(t)),o=WT(r),l=s.length,u=void 0===i?" ":zT(i);return o<=l||""==u?s:((a=QT(u,JT((n=o-l)/u.length))).length>n&&(a=$T(a,0,n)),e?s+a:a+s)}},eS={start:ZT(!1),end:ZT(!0)},tS=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ce),rS=eS.start;wr({target:"String",proto:!0,forced:tS},{padStart:function(e){return rS(this,e,arguments.length>1?arguments[1]:void 0)}});var iS=nh("String").padStart,nS=ue,aS=iS,sS=String.prototype,oS=i((function(e){var t=e.padStart;return"string"==typeof e||e===sS||nS(sS,e)&&t===sS.padStart?aS:t})),lS=i(ie.setInterval),uS=ls.every;wr({target:"Array",proto:!0,forced:!rd("every")},{every:function(e){return uS(this,e,arguments.length>1?arguments[1]:void 0)}});var cS=nh("Array").every,hS=ue,dS=cS,fS=Array.prototype,vS=i((function(e){var t=e.every;return e===fS||hS(fS,e)&&t===fS.every?dS:t})),gS=s,pS=o,mS=tn,yS=fk.trim,ES=ak,kS=y("".charAt),TS=gS.parseFloat,SS=gS.Symbol,AS=SS&&SS.iterator,LS=1/TS(ES+"-0")!=-1/0||AS&&!pS((function(){TS(Object(AS))}))?function(e){var t=yS(mS(e)),r=TS(t);return 0===r&&"-"==kS(t,0)?-0:r}:TS;wr({global:!0,forced:parseFloat!=LS},{parseFloat:LS});var bS=i(ie.parseFloat),RS=bl.PROPER,IS=o,DS=ak,_S=fk.trim;wr({target:"String",proto:!0,forced:function(e){return IS((function(){return!!DS[e]()||"​…᠎"!=="​…᠎"[e]()||RS&&DS[e].name!==e}))}("trim")},{trim:function(){return _S(this)}});var wS=nh("String").trim,CS=ue,PS=wS,xS=String.prototype,MS=i((function(e){var t=e.trim;return"string"==typeof e||e===xS||CS(xS,e)&&t===xS.trim?PS:t})),OS=na,FS=Math.floor,NS=function(e,t){var r=e.length,i=FS(r/2);return r<8?US(e,t):BS(e,NS(OS(e,0,i),t),NS(OS(e,i),t),t)},US=function(e,t){for(var r,i,n=e.length,a=1;a<n;){for(i=a,r=e[a];i&&t(e[i-1],r)>0;)e[i]=e[--i];i!==a++&&(e[i]=r)}return e},BS=function(e,t,r,i){for(var n=t.length,a=r.length,s=0,o=0;s<n||o<a;)e[s+o]=s<n&&o<a?i(t[s],r[o])<=0?t[s++]:r[o++]:s<n?t[s++]:r[o++];return e},GS=NS,KS=ce.match(/firefox\/(\d+)/i),HS=!!KS&&+KS[1],VS=/MSIE|Trident/.test(ce),jS=ce.match(/AppleWebKit\/(\d+)\./),YS=!!jS&&+jS[1],qS=wr,WS=y,zS=xe,XS=$e,QS=zr,$S=Hv,JS=tn,ZS=o,eA=GS,tA=rd,rA=HS,iA=VS,nA=me,aA=YS,sA=[],oA=WS(sA.sort),lA=WS(sA.push),uA=ZS((function(){sA.sort(void 0)})),cA=ZS((function(){sA.sort(null)})),hA=tA("sort"),dA=!ZS((function(){if(nA)return nA<70;if(!(rA&&rA>3)){if(iA)return!0;if(aA)return aA<603;var e,t,r,i,n="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(i=0;i<47;i++)sA.push({k:t+i,v:r})}for(sA.sort((function(e,t){return t.v-e.v})),i=0;i<sA.length;i++)t=sA[i].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));qS({target:"Array",proto:!0,forced:uA||!cA||!hA||!dA},{sort:function(e){void 0!==e&&zS(e);var t=XS(this);if(dA)return void 0===e?oA(t):oA(t,e);var r,i,n=[],a=QS(t);for(i=0;i<a;i++)i in t&&lA(n,t[i]);for(eA(n,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:JS(t)>JS(r)?1:-1}}(e)),r=QS(n),i=0;i<r;)t[i]=n[i++];for(;i<a;)$S(t,i++);return t}});var fA=nh("Array").sort,vA=ue,gA=fA,pA=Array.prototype,mA=i((function(e){var t=e.sort;return e===pA||vA(pA,e)&&t===pA.sort?gA:t})),yA=wr,EA=Date,kA=y(EA.prototype.getTime);yA({target:"Date",stat:!0},{now:function(){return kA(new EA)}});var TA,SA=i(ie.Date.now),AA="undefined"!=typeof window&&window.location&&av(TA=window.location.href).call(TA,"xgplayerdebugger=1")>-1,LA="color: #525252; background-color: #90ee90;",bA="color: #525252; background-color: red;",RA="color: #525252; background-color: yellow; ",IA="%c[xgplayer]",DA={config:{debug:AA?3:0},logInfo:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=3&&(r=console).log.apply(r,_d(t=[IA,LA,e]).call(t,n))},logWarn:function(e){for(var t,r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];this.config.debug>=1&&(r=console).warn.apply(r,_d(t=[IA,RA,e]).call(t,n))},logError:function(e){var t,r;if(!(this.config.debug<1)){for(var i=this.config.debug>=2?"trace":"error",n=arguments.length,a=new Array(n>1?n-1:0),s=1;s<n;s++)a[s-1]=arguments[s];(r=console)[i].apply(r,_d(t=[IA,bA,e]).call(t,a))}}},_A=function(){function e(t){_T(this,e),this.bufferedList=t}return CT(e,[{key:"start",value:function(e){return this.bufferedList[e].start}},{key:"end",value:function(e){return this.bufferedList[e].end}},{key:"length",get:function(){return this.bufferedList.length}}]),e}(),wA={};wA.createDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=document.createElement(t);return a.className=n,a.innerHTML=r,vd(e=yv(i)).call(e,(function(e){var r=e,n=i[e];"video"===t||"audio"===t||"live-video"===t?n&&a.setAttribute(r,n):a.setAttribute(r,n)})),a},wA.createDomFromHtml=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{var i=document.createElement("div");i.innerHTML=e;var n=i.children;if(i=null,n.length>0){var a;if(n=n[0],r&&wA.addClass(n,r),t)vd(a=yv(t)).call(a,(function(e){n.setAttribute(e,t[e])}));return n}return null}catch(s){return DA.logError("util.createDomFromHtml",s),null}},wA.hasClass=function(e,t){if(!e||!t)return!1;try{return KT(Array.prototype).call(e.classList,(function(e){return e===t}))}catch(i){var r=e.className&&"object"===DT(e.className)?e.getAttribute("class"):e.className;return r&&!!r.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},wA.addClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.add(t)}))}catch(i){wA.hasClass(e,t)||(e.className&&"object"===DT(e.className)?e.setAttribute("class",e.getAttribute("class")+" "+t):e.className+=" "+t)}},wA.removeClass=function(e,t){if(e&&t)try{var r;vd(r=t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g)).call(r,(function(t){t&&e.classList.remove(t)}))}catch(n){var i;if(wA.hasClass(e,t))vd(i=t.split(/\s+/g)).call(i,(function(t){var r=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className&&"object"===DT(e.className)?e.setAttribute("class",e.getAttribute("class").replace(r," ")):e.className=e.className.replace(r," ")}))}},wA.toggleClass=function(e,t){var r;e&&vd(r=t.split(/\s+/g)).call(r,(function(t){wA.hasClass(e,t)?wA.removeClass(e,t):wA.addClass(e,t)}))},wA.classNames=function(){for(var e=arguments,t=[],r=function(r){if("String"===wA.typeOf(e[r]))t.push(e[r]);else if("Object"===wA.typeOf(e[r])){var i;Pk(i=yv(e[r])).call(i,(function(i){e[r][i]&&t.push(i)}))}},i=0;i<arguments.length;i++)r(i);return t.join(" ")},wA.findDom=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,r=arguments.length>1?arguments[1]:void 0;try{e=t.querySelector(r)}catch(i){DA.logError("util.findDom",i),0===av(r).call(r,"#")&&(e=t.getElementById(Bv(r).call(r,1)))}return e},wA.getCss=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,!1)[t]},wA.padStart=function(e,t,r){for(var i=String(r),n=t>>0,a=Math.ceil(n/i.length),s=[],o=String(e);a--;)s.push(i);return s.join("").substring(0,n-o.length)+o},wA.format=function(e){if(window.isNaN(e))return"";e=Math.round(e);var t=oS(wA).call(wA,Math.floor(e/3600),2,0),r=oS(wA).call(wA,Math.floor((e-3600*t)/60),2,0),i=oS(wA).call(wA,Math.floor(e-3600*t-60*r),2,0);return("00"===t?[r,i]:[t,r,i]).join(":")},wA.event=function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},wA.typeOf=function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},wA.deepCopy=function(e,t){var r;if("Object"===wA.typeOf(t)&&"Object"===wA.typeOf(e))return vd(r=yv(t)).call(r,(function(r){if("Object"!==wA.typeOf(t[r])||t[r]instanceof Node)if("Array"===wA.typeOf(t[r])){var i;e[r]="Array"===wA.typeOf(e[r])?_d(i=e[r]).call(i,t[r]):t[r]}else e[r]=t[r];else void 0===e[r]||void 0===e[r]?e[r]=t[r]:wA.deepCopy(e[r],t[r])})),e},wA.deepMerge=function(e,t){var r;return Pk(r=yv(t)).call(r,(function(r){var i;"Array"===wA.typeOf(t[r])&&"Array"===wA.typeOf(e[r])?"Array"===wA.typeOf(e[r])&&(i=e[r]).push.apply(i,xT(t[r])):wA.typeOf(e[r])!==wA.typeOf(t[r])||null===e[r]||"Object"!==wA.typeOf(e[r])||t[r]instanceof window.Node?null!==t[r]&&(e[r]=t[r]):wA.deepMerge(e[r],t[r])})),e},wA.getBgImage=function(e){var t=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;if(!t||"none"===t)return"";var r=document.createElement("a");return r.href=t.replace(/url\("|"\)/g,""),r.href},wA.copyDom=function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return vd(Array.prototype).call(e.attributes,(function(e){t.setAttribute(e.name,e.value)})),e.innerHTML&&(t.innerHTML=e.innerHTML),t}return""},wA.setInterval=function(e,t,r,i){e._interval[t]||(e._interval[t]=lS(sT(r).call(r,e),i))},wA.clearInterval=function(e,t){clearInterval(e._interval[t]),e._interval[t]=null},wA.setTimeout=function(e,t,r){e._timers||(e._timers=[]);var i=Wf((function(){t(),wA.clearTimeout(e,i)}),r);return e._timers.push(i),i},wA.clearTimeout=function(e,t){var r=e._timers;if("Array"===wA.typeOf(r)){for(var i=0;i<r.length;i++)if(r[i]===t){sg(r).call(r,i,1),clearTimeout(t);break}}else clearTimeout(t)},wA.clearAllTimers=function(e){var t=e._timers;"Array"===wA.typeOf(t)&&(Pk(t).call(t,(function(e){clearTimeout(e)})),e._timerIds=[])},wA.createImgBtn=function(e,t,r,i){var n,a,s,o,l,u,c,h,d,f,v,g,p=wA.createDom("xg-".concat(e),"",{},"xgplayer-".concat(e,"-img"));(p.style.backgroundImage='url("'.concat(t,'")'),r&&i)&&(vS(n=["px","rem","em","pt","dp","vw","vh","vm","%"]).call(n,(function(e){var t,n;return!(av(r).call(r,e)>-1&&av(i).call(i,e)>-1)||(c=bS(MS(t=Bv(r).call(r,0,av(r).call(r,e))).call(t)),h=bS(MS(n=Bv(i).call(i,0,av(i).call(i,e))).call(n)),d=e,!1)})),p.style.width=_d(a="".concat(c)).call(a,d),p.style.height=_d(s="".concat(h)).call(s,d),p.style.backgroundSize=_d(o=_d(l=_d(u="".concat(c)).call(u,d," ")).call(l,h)).call(o,d),p.style.margin="start"===e?_d(f=_d(v=_d(g="-".concat(h/2)).call(g,d," auto auto -")).call(v,c/2)).call(f,d):"auto 5px auto 5px");return p},wA.Hex2RGBA=function(e,t){var r,i=[];if(/^\#[0-9A-F]{3}$/i.test(e)){var n="#";e.replace(/[0-9A-F]/gi,(function(e){n+=e+e})),e=n}return/^#[0-9A-F]{6}$/i.test(e)?(e.replace(/[0-9A-F]{2}/gi,(function(e){i.push(Rk(e,16))})),_d(r="rgba(".concat(i.join(","),", ")).call(r,t,")")):"rgba(255, 255, 255, 0.1)"},wA.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},wA.checkIsFunction=function(e){return e&&"function"==typeof e},wA.checkIsObject=function(e){return null!==e&&"object"===DT(e)},wA.hide=function(e){e.style.display="none"},wA.show=function(e,t){e.style.display=t||"block"},wA.isUndefined=function(e){if(null==e)return!0},wA.isNotNull=function(e){return!(null==e)},wA.setStyleFromCsstext=function(e,t){if(t)if("String"===wA.typeOf(t)){var r=t.replace(/\s+/g,"").split(";");Pk(r).call(r,(function(t){if(t){var r=t.split(":");r.length>1&&(e.style[r[0]]=r[1])}}))}else{var i;Pk(i=yv(t)).call(i,(function(r){e.style[r]=t[r]}))}},wA.filterStyleFromText=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["width","height","top","left","bottom","right","position","z-index","padding","margin","transform"],i=e.style.cssText;if(!i)return{};var n=i.replace(/\s+/g,"").split(";"),a={},s={};return Pk(n).call(n,(function(e){if(e){var t=e.split(":");t.length>1&&(!function(e,t){for(var r=0,i=t.length;r<i;r++)if(av(e).call(e,t[r])>-1)return!0;return!1}(t[0],r)?s[t[0]]=t[1]:a[t[0]]=t[1])}})),e.setAttribute("style",""),Pk(t=yv(s)).call(t,(function(t){e.style[t]=s[t]})),a},wA.getStyleFromCsstext=function(e){var t=e.style.cssText;if(!t)return{};var r=t.replace(/\s+/g,"").split(";"),i={};return Pk(r).call(r,(function(e){if(e){var t=e.split(":");t.length>1&&(i[t[0]]=t[1])}})),i},wA.preloadImg=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(e){var i=new window.Image;i.onload=function(e){i=null,t&&t(e)},i.onerror=function(e){i=null,r&&r(e)},i.src=e}},wA.stopPropagation=function(e){e&&e.stopPropagation()},wA.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},wA.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0},wA.checkTouchSupport=function(){return"ontouchstart"in window},wA.getBuffered2=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5,r=[],i=0;i<e.length;i++)r.push({start:e.start(i)<.5?0:e.start(i),end:e.end(i)});mA(r).call(r,(function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var n=[];if(t)for(var a=0;a<r.length;a++){var s=n.length;if(s){var o=n[s-1].end;r[a].start-o<t?r[a].end>o&&(n[s-1].end=r[a].end):n.push(r[a])}else n.push(r[a])}else n=r;return new _A(n)},wA.getEventPos=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e.touches&&e.touches.length>0&&(e=e.touches[0]),{x:e.x/t,y:e.y/t,clientX:e.clientX/t,clientY:e.clientY/t,offsetX:e.offsetX/t,offsetY:e.offsetY/t,pageX:e.pageX/t,pageY:e.pageY/t}},wA.requestAnimationFrame=function(e){var t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(t)return t(e)},wA.getHostFromUrl=function(e){if("String"!==wA.typeOf(e))return"";var t=e.split("/"),r="";return t.length>3&&t[2]&&(r=t[2]),r},wA.cancelAnimationFrame=function(e){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;t&&t(e)},wA.isMSE=function(e){return e.media&&(e=e.media),!!(e&&e instanceof HTMLMediaElement)&&(/^blob/.test(e.currentSrc)||/^blob/.test(e.src))},wA.isBlob=function(e){return"string"==typeof e&&/^blob/.test(e)},wA.generateSessionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=(new Date).getTime();try{e=Rk(e)}catch(r){e=0}return t+=e,window.performance&&"function"==typeof window.performance.now&&(t+=Rk(window.performance.now())),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var r=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"===e?r:3&r|8).toString(16)}))},wA.createEvent=function(e){var t;return"function"==typeof window.Event?t=new Event(e):(t=document.createEvent("Event")).initEvent(e,!0,!0),t},wA.adjustTimeByDuration=function(e,t,r){return t&&e&&(e>t||r&&e<t)?t:e},wA.createPositionBar=function(e,t){var r=wA.createDom("xg-bar","",{"data-index":-1},e);return t.appendChild(r),r},wA.getTransformStyle=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{x:0,y:0,scale:1,rotate:0},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i={scale:"".concat(t.scale||1),translate:_d(e="".concat(t.x||0,"%, ")).call(e,t.y||0,"%"),rotate:"".concat(t.rotate||0,"deg")},n=yv(i);return vd(n).call(n,(function(e){var t,n=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),a=_d(t="".concat(e,"(")).call(t,i[e],")");n.test(r)?(n.lastIndex=-1,r=r.replace(n,a)):r+="".concat(a," ")})),r},wA.convertDeg=function(e){return Math.abs(e)<=1?360*e:e%360},wA.getIndexByTime=function(e,t){var r=t.length,i=-1;if(r<1)return i;if(e<=t[0].end||r<2)i=0;else if(e>t[r-1].end)i=r-1;else for(var n=1;n<r;n++)if(e>t[n-1].end&&e<=t[n].end){i=n;break}return i},wA.getOffsetCurrentTime=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=-1;if((i=r>=0&&r<t.length?r:wA.getIndexByTime(e,t))<0)return-1;var n=t.length,a=t[i],s=a.start,o=a.end,l=a.cTime,u=a.offset;return e<s?l:e>=s&&e<=o?e-u:e>o&&i>=n-1?o:-1},wA.getCurrentTimeByOffset=function(e,t){var r=-1;if(!t||t.length<0)return e;for(var i=0;i<t.length;i++)if(e<=t[i].duration){r=i;break}if(-1!==r){var n=t[r].start;return r-1<0?n+e:n+(e-t[r-1].duration)}return e};var CA="urlchange";function PA(e,t,r){for(var i,n=arguments.length,a=new Array(n>3?n-3:0),s=3;s<n;s++)a[s-3]=arguments[s];var o,l=t.call.apply(t,_d(i=[e]).call(i,a));r&&"function"==typeof r&&(l&&l.then?l.then((function(){for(var t,i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];r.call.apply(r,_d(t=[e]).call(t,n))})):r.call.apply(r,_d(o=[e]).call(o,a)))}function xA(e,t){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{pre:null,next:null};return this.__hooks||(this.__hooks={}),!this.__hooks[e]&&(this.__hooks[e]=null),sT(r=function(){var r,n=arguments,a=this;if(i.pre)try{var s,o;(o=i.pre).call.apply(o,_d(s=[this]).call(s,Bv(Array.prototype).call(arguments)))}catch(p){var l,u;throw p.message=_d(l=_d(u="[pluginName: ".concat(this.pluginName,":")).call(u,e,":pre error] >> ")).call(l,p.message),p}if(this.__hooks&&this.__hooks[e])try{var c,h,d=NA.apply(void 0,_d(c=[this,e,t]).call(c,Bv(Array.prototype).call(arguments)));if(d)if(d.then)d.then((function(e){var r;!1!==e&&PA.apply(void 0,_d(r=[a,t,i.next]).call(r,xT(n)))})).catch((function(e){throw e}));else PA.apply(void 0,_d(h=[this,t,i.next]).call(h,Bv(Array.prototype).call(arguments)));else if(void 0===d){var f;PA.apply(void 0,_d(f=[this,t,i.next]).call(f,Bv(Array.prototype).call(arguments)))}}catch(p){var v,g;throw p.message=_d(v=_d(g="[pluginName: ".concat(this.pluginName,":")).call(g,e,"] >> ")).call(v,p.message),p}else PA.apply(void 0,_d(r=[this,t,i.next]).call(r,Bv(Array.prototype).call(arguments)))}).call(r,this)}function MA(e,t){var r=this.__hooks;if(!r||!lv(r[e]))return-1;for(var i=r[e],n=0;n<i.length;n++)if(i[n]===t)return n;return-1}function OA(e,t){var r=this.__hooks;if(r)return r.hasOwnProperty(e)?(lv(r[e])||(r[e]=[]),-1===MA.call(this,e,t)&&r[e].push(t),!0):(console.warn("has no supported hook which name [".concat(e,"]")),!1)}function FA(e,t){var r=this.__hooks;if(r)if(lv(r[e])){var i=r[e],n=MA.call(this,e,t);-1!==n&&sg(i).call(i,n,1)}else r[e]&&(r[e]=null)}function NA(e,t,r){for(var i=arguments.length,n=new Array(i>3?i-3:0),a=3;a<i;a++)n[a-3]=arguments[a];if(e.__hooks&&lv(e.__hooks[t])){var s,o=e.__hooks[t],l=-1;return function e(t,r,i){for(var n,a,s=arguments.length,u=new Array(s>3?s-3:0),c=3;c<s;c++)u[c-3]=arguments[c];if(l++,0===o.length||l===o.length)return i.call.apply(i,_d(a=[t,t]).call(a,u));var h,d=o[l],f=d.call.apply(d,_d(n=[t,t]).call(n,u));return f&&f.then?f.then((function(n){var a;return!1===n?null:e.apply(void 0,_d(a=[t,r,i]).call(a,u))})).catch((function(e){console.warn("[runHooks]".concat(r," reject"),e.message)})):!1!==f?e.apply(void 0,_d(h=[t,r,i]).call(h,u)):!1!==f&&void 0}.apply(void 0,_d(s=[e,t,r]).call(s,n))}var u;return r.call.apply(r,_d(u=[e,e]).call(u,n))}function UA(e,t){var r;DA.logError(_d(r="[".concat(e,"] event or callback cant be undefined or null when call ")).call(r,t))}var BA=function(){function e(t){_T(this,e),wA.checkIsFunction(this.beforeCreate)&&this.beforeCreate(t),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];e.__hooks={},t&&Pk(t).call(t,(function(t){e.__hooks[t]=null})),iT(e,"hooks",{get:function(){var t;return e.__hooks&&Pk(t=yv(e.__hooks)).call(t,(function(t){if(e.__hooks[t])return t}))}})}(this),this.__args=t,this.__events={},this.__onceEvents={},this.config=t.config||{},this.player=null,this.playerConfig={},this.pluginName="",this.__init(t)}return CT(e,[{key:"beforeCreate",value:function(e){}},{key:"afterCreate",value:function(){}},{key:"beforePlayerInit",value:function(){}},{key:"onPluginsReady",value:function(){}},{key:"afterPlayerInit",value:function(){}},{key:"destroy",value:function(){}},{key:"__init",value:function(e){this.player=e.player,this.playerConfig=e.player&&e.player.config,this.pluginName=e.pluginName?e.pluginName.toLowerCase():this.constructor.pluginName.toLowerCase(),this.logger=e.player&&e.player.logger}},{key:"updateLang",value:function(e){e||(e=this.lang)}},{key:"lang",get:function(){return this.player.lang}},{key:"i18n",get:function(){return this.player.i18n}},{key:"i18nKeys",get:function(){return this.player.i18nKeys}},{key:"domEventType",get:function(){var e=wA.checkTouchSupport()?"touch":"mouse";return!this.playerConfig||"touch"!==this.playerConfig.domEventType&&"mouse"!==this.playerConfig.domEventType||(e=this.playerConfig.domEventType),e}},{key:"on",value:function(e,t){var r=this;e&&t&&this.player?"string"==typeof e?(this.__events[e]=t,this.player.on(e,t)):lv(e)&&vd(e).call(e,(function(e){r.__events[e]=t,r.player.on(e,t)})):UA(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)):lv(e)&&vd(e).call(e,(function(i){r.__onceEvents[i]=t,r.player.once(e,t)})):UA(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)):lv(e)&&vd(e).call(e,(function(i){delete r.__events[e],r.player.off(i,t)})):UA(this.pluginName,"plugin.off(event, callback)")}},{key:"offAll",value:function(){var e,t=this;vd(e=["__events","__onceEvents"]).call(e,(function(e){var r;vd(r=yv(t[e])).call(r,(function(r){t[e][r]&&t.off(r,t[e][r]),r&&delete t[e][r]}))})),this.__events={},this.__onceEvents={}}},{key:"emit",value:function(e){var t,r;if(this.player){for(var i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];(r=this.player).emit.apply(r,_d(t=[e]).call(t,n))}}},{key:"emitUserAction",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.player){var i=IT(IT({},r),{},{pluginName:this.pluginName});this.player.emitUserAction(e,t,i)}}},{key:"hook",value:function(e,t){var r;return xA.call.apply(xA,_d(r=[this]).call(r,Bv(Array.prototype).call(arguments)))}},{key:"useHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return OA.call.apply(OA,_d(r=[this]).call(r,Bv(Array.prototype).call(arguments)))}},{key:"removeHooks",value:function(e,t){for(var r,i=arguments.length,n=new Array(i>2?i-2:0),a=2;a<i;a++)n[a-2]=arguments[a];return FA.call.apply(FA,_d(r=[this]).call(r,Bv(Array.prototype).call(arguments)))}},{key:"registerPlugin",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(this.player)return r&&(t.pluginName=r),this.player.registerPlugin({plugin:e,options:t})}},{key:"getPlugin",value:function(e){return this.player?this.player.getPlugin(e):null}},{key:"__destroy",value:function(){var e,t=this,r=this.player,i=this.pluginName;this.offAll(),wA.clearAllTimers(this),wA.checkIsFunction(this.destroy)&&this.destroy(),Pk(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)&&iT(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]&&iT(e,r,{configurable:!0,value:t[r]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),e}(),GA=o,KA=vt("iterator"),HA=!GA((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[KA]||"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})),VA=y,jA=2147483647,YA=/[^\0-\u007E]/,qA=/[.\u3002\uFF0E\uFF61]/g,WA="Overflow: input needs wider integers to process",zA=RangeError,XA=VA(qA.exec),QA=Math.floor,$A=String.fromCharCode,JA=VA("".charCodeAt),ZA=VA([].join),eL=VA([].push),tL=VA("".replace),rL=VA("".split),iL=VA("".toLowerCase),nL=function(e){return e+22+75*(e<26)},aL=function(e,t,r){var i=0;for(e=r?QA(e/700):e>>1,e+=QA(e/t);e>455;)e=QA(e/35),i+=36;return QA(i+36*e/(e+38))},sL=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var n=JA(e,r++);if(n>=55296&&n<=56319&&r<i){var a=JA(e,r++);56320==(64512&a)?eL(t,((1023&n)<<10)+(1023&a)+65536):(eL(t,n),r--)}else eL(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&&eL(t,$A(i));var l=t.length,u=l;for(l&&eL(t,"-");u<n;){var c=jA;for(r=0;r<e.length;r++)(i=e[r])>=a&&i<c&&(c=i);var h=u+1;if(c-a>QA((jA-s)/h))throw zA(WA);for(s+=(c-a)*h,a=c,r=0;r<e.length;r++){if((i=e[r])<a&&++s>jA)throw zA(WA);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;eL(t,$A(nL(v+g%p))),d=QA(g/p),f+=36}eL(t,$A(nL(d))),o=aL(s,h,u==l),s=0,u++}}s++,a++}return ZA(t,"")},oL=da,lL=function(e,t,r){for(var i in t)r&&r.unsafe&&e[i]?e[i]=t[i]:oL(e,i,t[i],r);return e},uL=wr,cL=s,hL=M,dL=y,fL=C,vL=HA,gL=da,pL=va,mL=lL,yL=Ua,EL=$l,kL=es,TL=Op,SL=_,AL=et,LL=Jt,bL=ui,RL=nr,IL=re,DL=tn,_L=zn,wL=K,CL=Gg,PL=xg,xL=wf,ML=GS,OL=vt("iterator"),FL="URLSearchParams",NL=FL+"Iterator",UL=kL.set,BL=kL.getterFor(FL),GL=kL.getterFor(NL),KL=Object.getOwnPropertyDescriptor,HL=function(e){if(!fL)return cL[e];var t=KL(cL,e);return t&&t.value},VL=HL("fetch"),jL=HL("Request"),YL=HL("Headers"),qL=jL&&jL.prototype,WL=YL&&YL.prototype,zL=cL.RegExp,XL=cL.TypeError,QL=cL.decodeURIComponent,$L=cL.encodeURIComponent,JL=dL("".charAt),ZL=dL([].join),eb=dL([].push),tb=dL("".replace),rb=dL([].shift),ib=dL([].splice),nb=dL("".split),ab=dL("".slice),sb=/\+/g,ob=Array(4),lb=function(e){return ob[e-1]||(ob[e-1]=zL("((?:%[\\da-f]{2}){"+e+"})","gi"))},ub=function(e){try{return QL(e)}catch(JV){return e}},cb=function(e){var t=tb(e,sb," "),r=4;try{return QL(t)}catch(JV){for(;r;)t=tb(t,lb(r--),ub);return t}},hb=/[!'()~]|%20/g,db={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},fb=function(e){return db[e]},vb=function(e){return tb($L(e),hb,fb)},gb=EL((function(e,t){UL(this,{type:NL,iterator:CL(BL(e).entries),kind:t})}),"Iterator",(function(){var e=GL(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),pb=function(e){this.entries=[],this.url=null,void 0!==e&&(IL(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===JL(e,0)?ab(e,1):e:DL(e)))};pb.prototype={type:FL,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,a,s,o,l=PL(e);if(l)for(r=(t=CL(e,l)).next;!(i=hL(r,t)).done;){if(a=(n=CL(RL(i.value))).next,(s=hL(a,n)).done||(o=hL(a,n)).done||!hL(a,n).done)throw XL("Expected sequence with length 2");eb(this.entries,{key:DL(s.value),value:DL(o.value)})}else for(var u in e)AL(e,u)&&eb(this.entries,{key:u,value:DL(e[u])})},parseQuery:function(e){if(e)for(var t,r,i=nb(e,"&"),n=0;n<i.length;)(t=i[n++]).length&&(r=nb(t,"="),eb(this.entries,{key:cb(rb(r)),value:cb(ZL(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],eb(r,vb(e.key)+"="+vb(e.value));return ZL(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var mb=function(){TL(this,yb);var e=UL(this,new pb(arguments.length>0?arguments[0]:void 0));fL||(this.length=e.entries.length)},yb=mb.prototype;if(mL(yb,{append:function(e,t){xL(arguments.length,2);var r=BL(this);eb(r.entries,{key:DL(e),value:DL(t)}),fL||this.length++,r.updateURL()},delete:function(e){xL(arguments.length,1);for(var t=BL(this),r=t.entries,i=DL(e),n=0;n<r.length;)r[n].key===i?ib(r,n,1):n++;fL||(this.length=r.length),t.updateURL()},get:function(e){xL(arguments.length,1);for(var t=BL(this).entries,r=DL(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){xL(arguments.length,1);for(var t=BL(this).entries,r=DL(e),i=[],n=0;n<t.length;n++)t[n].key===r&&eb(i,t[n].value);return i},has:function(e){xL(arguments.length,1);for(var t=BL(this).entries,r=DL(e),i=0;i<t.length;)if(t[i++].key===r)return!0;return!1},set:function(e,t){xL(arguments.length,1);for(var r,i=BL(this),n=i.entries,a=!1,s=DL(e),o=DL(t),l=0;l<n.length;l++)(r=n[l]).key===s&&(a?ib(n,l--,1):(a=!0,r.value=o));a||eb(n,{key:s,value:o}),fL||(this.length=n.length),i.updateURL()},sort:function(){var e=BL(this);ML(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=BL(this).entries,i=LL(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 gb(this,"keys")},values:function(){return new gb(this,"values")},entries:function(){return new gb(this,"entries")}},{enumerable:!0}),gL(yb,OL,yb.entries,{name:"entries"}),gL(yb,"toString",(function(){return BL(this).serialize()}),{enumerable:!0}),fL&&pL(yb,"size",{get:function(){return BL(this).entries.length},configurable:!0,enumerable:!0}),yL(mb,FL),uL({global:!0,constructor:!0,forced:!vL},{URLSearchParams:mb}),!vL&&SL(YL)){var Eb=dL(WL.has),kb=dL(WL.set),Tb=function(e){if(IL(e)){var t,r=e.body;if(bL(r)===FL)return t=e.headers?new YL(e.headers):new YL,Eb(t,"content-type")||kb(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),_L(e,{body:wL(0,DL(r)),headers:wL(0,t)})}return e};if(SL(VL)&&uL({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return VL(e,arguments.length>1?Tb(arguments[1]):{})}}),SL(jL)){var Sb=function(e){return TL(this,qL),new jL(e,arguments.length>1?Tb(arguments[1]):{})};qL.constructor=Sb,Sb.prototype=qL,uL({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Sb})}}var Ab,Lb=wr,bb=C,Rb=HA,Ib=s,Db=Jt,_b=y,wb=da,Cb=va,Pb=Op,xb=et,Mb=qk,Ob=kT,Fb=na,Nb=kc.codeAt,Ub=function(e){var t,r,i=[],n=rL(tL(iL(e),qA,"."),".");for(t=0;t<n.length;t++)r=n[t],eL(i,XA(YA,r)?"xn--"+sL(r):r);return ZA(i,".")},Bb=tn,Gb=Ua,Kb=wf,Hb={URLSearchParams:mb,getState:BL},Vb=es,jb=Vb.set,Yb=Vb.getterFor("URL"),qb=Hb.URLSearchParams,Wb=Hb.getState,zb=Ib.URL,Xb=Ib.TypeError,Qb=Ib.parseInt,$b=Math.floor,Jb=Math.pow,Zb=_b("".charAt),eR=_b(/./.exec),tR=_b([].join),rR=_b(1..toString),iR=_b([].pop),nR=_b([].push),aR=_b("".replace),sR=_b([].shift),oR=_b("".split),lR=_b("".slice),uR=_b("".toLowerCase),cR=_b([].unshift),hR="Invalid scheme",dR="Invalid host",fR="Invalid port",vR=/[a-z]/i,gR=/[\d+-.a-z]/i,pR=/\d/,mR=/^0x/i,yR=/^[0-7]+$/,ER=/^\d+$/,kR=/^[\da-f]+$/i,TR=/[\0\t\n\r #%/:<>?@[\\\]^|]/,SR=/[\0\t\n\r #/:<>?@[\\\]^|]/,AR=/^[\u0000-\u0020]+/,LR=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,bR=/[\t\n\r]/g,RR=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)cR(t,e%256),e=$b(e/256);return tR(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+=rR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},IR={},DR=Mb({},IR,{" ":1,'"':1,"<":1,">":1,"`":1}),_R=Mb({},DR,{"#":1,"?":1,"{":1,"}":1}),wR=Mb({},_R,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),CR=function(e,t){var r=Nb(e,0);return r>32&&r<127&&!xb(t,e)?e:encodeURIComponent(e)},PR={ftp:21,file:null,http:80,https:443,ws:80,wss:443},xR=function(e,t){var r;return 2==e.length&&eR(vR,Zb(e,0))&&(":"==(r=Zb(e,1))||!t&&"|"==r)},MR=function(e){var t;return e.length>1&&xR(lR(e,0,2))&&(2==e.length||"/"===(t=Zb(e,2))||"\\"===t||"?"===t||"#"===t)},OR=function(e){return"."===e||"%2e"===uR(e)},FR={},NR={},UR={},BR={},GR={},KR={},HR={},VR={},jR={},YR={},qR={},WR={},zR={},XR={},QR={},$R={},JR={},ZR={},eI={},tI={},rI={},iI=function(e,t,r){var i,n,a,s=Bb(e);if(t){if(n=this.parse(s))throw Xb(n);this.searchParams=null}else{if(void 0!==r&&(i=new iI(r,!0)),n=this.parse(s,null,i))throw Xb(n);(a=Wb(new qb)).bindURL(this),this.searchParams=a}};iI.prototype={type:"URL",parse:function(e,t,r){var i,n,a,s,o,l=this,u=t||FR,c=0,h="",d=!1,f=!1,v=!1;for(e=Bb(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=aR(e,AR,""),e=aR(e,LR,"$1")),e=aR(e,bR,""),i=Ob(e);c<=i.length;){switch(n=i[c],u){case FR:if(!n||!eR(vR,n)){if(t)return hR;u=UR;continue}h+=uR(n),u=NR;break;case NR:if(n&&(eR(gR,n)||"+"==n||"-"==n||"."==n))h+=uR(n);else{if(":"!=n){if(t)return hR;h="",u=UR,c=0;continue}if(t&&(l.isSpecial()!=xb(PR,h)||"file"==h&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=h,t)return void(l.isSpecial()&&PR[l.scheme]==l.port&&(l.port=null));h="","file"==l.scheme?u=XR:l.isSpecial()&&r&&r.scheme==l.scheme?u=BR:l.isSpecial()?u=VR:"/"==i[c+1]?(u=GR,c++):(l.cannotBeABaseURL=!0,nR(l.path,""),u=eI)}break;case UR:if(!r||r.cannotBeABaseURL&&"#"!=n)return hR;if(r.cannotBeABaseURL&&"#"==n){l.scheme=r.scheme,l.path=Fb(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,u=rI;break}u="file"==r.scheme?XR:KR;continue;case BR:if("/"!=n||"/"!=i[c+1]){u=KR;continue}u=jR,c++;break;case GR:if("/"==n){u=YR;break}u=ZR;continue;case KR:if(l.scheme=r.scheme,n==Ab)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.query=r.query;else if("/"==n||"\\"==n&&l.isSpecial())u=HR;else if("?"==n)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.query="",u=tI;else{if("#"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.path.length--,u=ZR;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=Fb(r.path),l.query=r.query,l.fragment="",u=rI}break;case HR:if(!l.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,u=ZR;continue}u=YR}else u=jR;break;case VR:if(u=jR,"/"!=n||"/"!=Zb(h,c+1))continue;c++;break;case jR:if("/"!=n&&"\\"!=n){u=YR;continue}break;case YR:if("@"==n){d&&(h="%40"+h),d=!0,a=Ob(h);for(var g=0;g<a.length;g++){var p=a[g];if(":"!=p||v){var m=CR(p,wR);v?l.password+=m:l.username+=m}else v=!0}h=""}else if(n==Ab||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(d&&""==h)return"Invalid authority";c-=Ob(h).length+1,h="",u=qR}else h+=n;break;case qR:case WR:if(t&&"file"==l.scheme){u=$R;continue}if(":"!=n||f){if(n==Ab||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()){if(l.isSpecial()&&""==h)return dR;if(t&&""==h&&(l.includesCredentials()||null!==l.port))return;if(s=l.parseHost(h))return s;if(h="",u=JR,t)return;continue}"["==n?f=!0:"]"==n&&(f=!1),h+=n}else{if(""==h)return dR;if(s=l.parseHost(h))return s;if(h="",u=zR,t==WR)return}break;case zR:if(!eR(pR,n)){if(n==Ab||"/"==n||"?"==n||"#"==n||"\\"==n&&l.isSpecial()||t){if(""!=h){var y=Qb(h,10);if(y>65535)return fR;l.port=l.isSpecial()&&y===PR[l.scheme]?null:y,h=""}if(t)return;u=JR;continue}return fR}h+=n;break;case XR:if(l.scheme="file","/"==n||"\\"==n)u=QR;else{if(!r||"file"!=r.scheme){u=ZR;continue}if(n==Ab)l.host=r.host,l.path=Fb(r.path),l.query=r.query;else if("?"==n)l.host=r.host,l.path=Fb(r.path),l.query="",u=tI;else{if("#"!=n){MR(tR(Fb(i,c),""))||(l.host=r.host,l.path=Fb(r.path),l.shortenPath()),u=ZR;continue}l.host=r.host,l.path=Fb(r.path),l.query=r.query,l.fragment="",u=rI}}break;case QR:if("/"==n||"\\"==n){u=$R;break}r&&"file"==r.scheme&&!MR(tR(Fb(i,c),""))&&(xR(r.path[0],!0)?nR(l.path,r.path[0]):l.host=r.host),u=ZR;continue;case $R:if(n==Ab||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&xR(h))u=ZR;else if(""==h){if(l.host="",t)return;u=JR}else{if(s=l.parseHost(h))return s;if("localhost"==l.host&&(l.host=""),t)return;h="",u=JR}continue}h+=n;break;case JR:if(l.isSpecial()){if(u=ZR,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=Ab&&(u=ZR,"/"!=n))continue}else l.fragment="",u=rI;else l.query="",u=tI;break;case ZR:if(n==Ab||"/"==n||"\\"==n&&l.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(o=uR(o=h))||"%2e."===o||".%2e"===o||"%2e%2e"===o?(l.shortenPath(),"/"==n||"\\"==n&&l.isSpecial()||nR(l.path,"")):OR(h)?"/"==n||"\\"==n&&l.isSpecial()||nR(l.path,""):("file"==l.scheme&&!l.path.length&&xR(h)&&(l.host&&(l.host=""),h=Zb(h,0)+":"),nR(l.path,h)),h="","file"==l.scheme&&(n==Ab||"?"==n||"#"==n))for(;l.path.length>1&&""===l.path[0];)sR(l.path);"?"==n?(l.query="",u=tI):"#"==n&&(l.fragment="",u=rI)}else h+=CR(n,_R);break;case eI:"?"==n?(l.query="",u=tI):"#"==n?(l.fragment="",u=rI):n!=Ab&&(l.path[0]+=CR(n,IR));break;case tI:t||"#"!=n?n!=Ab&&("'"==n&&l.isSpecial()?l.query+="%27":l.query+="#"==n?"%23":CR(n,IR)):(l.fragment="",u=rI);break;case rI:n!=Ab&&(l.fragment+=CR(n,DR))}c++}},parseHost:function(e){var t,r,i;if("["==Zb(e,0)){if("]"!=Zb(e,e.length-1))return dR;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 Zb(e,h)};if(":"==d()){if(":"!=Zb(e,1))return;h+=2,c=++u}for(;d();){if(8==u)return;if(":"!=d()){for(t=r=0;r<4&&eR(kR,d());)t=16*t+Qb(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(!eR(pR,d()))return;for(;eR(pR,d());){if(a=Qb(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}(lR(e,1,-1)),!t)return dR;this.host=t}else if(this.isSpecial()){if(e=Ub(e),eR(TR,e))return dR;if(t=function(e){var t,r,i,n,a,s,o,l=oR(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"==Zb(n,0)&&(a=eR(mR,n)?16:8,n=lR(n,8==a?1:2)),""===n)s=0;else{if(!eR(10==a?ER:8==a?yR:kR,n))return e;s=Qb(n,a)}nR(r,s)}for(i=0;i<t;i++)if(s=r[i],i==t-1){if(s>=Jb(256,5-t))return null}else if(s>255)return null;for(o=iR(r),i=0;i<r.length;i++)o+=r[i]*Jb(256,3-i);return o}(e),null===t)return dR;this.host=t}else{if(eR(SR,e))return dR;for(t="",r=Ob(e),i=0;i<r.length;i++)t+=CR(r[i],IR);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return xb(PR,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&xR(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+=RR(n),null!==a&&(u+=":"+a)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?s[0]:s.length?"/"+tR(s,"/"):"",null!==o&&(u+="?"+o),null!==l&&(u+="#"+l),u},setHref:function(e){var t=this.parse(e);if(t)throw Xb(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new nI(e.path[0]).origin}catch(JV){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+RR(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Bb(e)+":",FR)},getUsername:function(){return this.username},setUsername:function(e){var t=Ob(Bb(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=CR(t[r],wR)}},getPassword:function(){return this.password},setPassword:function(e){var t=Ob(Bb(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=CR(t[r],wR)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?RR(e):RR(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,qR)},getHostname:function(){var e=this.host;return null===e?"":RR(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,WR)},getPort:function(){var e=this.port;return null===e?"":Bb(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=Bb(e))?this.port=null:this.parse(e,zR))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+tR(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,JR))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=Bb(e))?this.query=null:("?"==Zb(e,0)&&(e=lR(e,1)),this.query="",this.parse(e,tI)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=Bb(e))?("#"==Zb(e,0)&&(e=lR(e,1)),this.fragment="",this.parse(e,rI)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var nI=function(e){var t=Pb(this,aI),r=Kb(arguments.length,1)>1?arguments[1]:void 0,i=jb(t,new iI(e,!1,r));bb||(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())},aI=nI.prototype,sI=function(e,t){return{get:function(){return Yb(this)[e]()},set:t&&function(e){return Yb(this)[t](e)},configurable:!0,enumerable:!0}};if(bb&&(Cb(aI,"href",sI("serialize","setHref")),Cb(aI,"origin",sI("getOrigin")),Cb(aI,"protocol",sI("getProtocol","setProtocol")),Cb(aI,"username",sI("getUsername","setUsername")),Cb(aI,"password",sI("getPassword","setPassword")),Cb(aI,"host",sI("getHost","setHost")),Cb(aI,"hostname",sI("getHostname","setHostname")),Cb(aI,"port",sI("getPort","setPort")),Cb(aI,"pathname",sI("getPathname","setPathname")),Cb(aI,"search",sI("getSearch","setSearch")),Cb(aI,"searchParams",sI("getSearchParams")),Cb(aI,"hash",sI("getHash","setHash"))),wb(aI,"toJSON",(function(){return Yb(this).serialize()}),{enumerable:!0}),wb(aI,"toString",(function(){return Yb(this).serialize()}),{enumerable:!0}),zb){var oI=zb.createObjectURL,lI=zb.revokeObjectURL;oI&&wb(nI,"createObjectURL",Db(oI,zb)),lI&&wb(nI,"revokeObjectURL",Db(lI,zb))}Gb(nI,"URL"),Lb({global:!0,constructor:!0,forced:!Rb,sham:!bb},{URL:nI});var uI=wr,cI=o,hI=wf,dI=tn,fI=HA,vI=le("URL");uI({target:"URL",stat:!0,forced:!(fI&&cI((function(){vI.canParse()})))},{canParse:function(e){var t=hI(arguments.length,1),r=dI(e),i=t<2||void 0===arguments[1]?void 0:dI(arguments[1]);try{return!!new vI(r,i)}catch(JV){return!1}}});var gI=i(ie.URL),pI=re,mI=S,yI=vt("match"),EI=function(e){var t;return pI(e)&&(void 0!==(t=e[yI])?!!t:"RegExp"==mI(e))},kI=TypeError,TI=function(e){if(EI(e))throw kI("The method doesn't accept regular expressions");return e},SI=vt("match"),AI=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[SI]=!1,"/./"[e](t)}catch(i){}}return!1},LI=wr,bI=b;w.f;var RI=qr,II=tn,DI=TI,_I=Q,wI=AI,CI=bI("".startsWith),PI=bI("".slice),xI=Math.min;LI({target:"String",proto:!0,forced:!wI("startsWith")},{startsWith:function(e){var t=II(_I(this));DI(e);var r=RI(xI(arguments.length>1?arguments[1]:void 0,t.length)),i=II(e);return CI?CI(t,i,r):PI(t,r,r+i.length)===i}});var MI=nh("String").startsWith,OI=ue,FI=MI,NI=String.prototype,UI=i((function(e){var t=e.startsWith;return"string"==typeof e||e===NI||OI(NI,e)&&t===NI.startsWith?FI:t})),BI=Sd.entries;wr({target:"Object",stat:!0},{entries:function(e){return BI(e)}});var GI=i(ie.Object.entries),KI=ie,HI=f;KI.JSON||(KI.JSON={stringify:JSON.stringify});var VI=function(e,t,r){return HI(KI.JSON.stringify,null,arguments)},jI=i(VI),YI=re,qI=Math.floor,WI=Number.isInteger||function(e){return!YI(e)&&isFinite(e)&&qI(e)===e};wr({target:"Number",stat:!0},{isInteger:WI});var zI=i(ie.Number.isInteger),XI=dn.includes;wr({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return XI(this,e,arguments.length>1?arguments[1]:void 0)}});var QI=nh("Array").includes,$I=wr,JI=TI,ZI=Q,eD=tn,tD=AI,rD=y("".indexOf);$I({target:"String",proto:!0,forced:!tD("includes")},{includes:function(e){return!!~rD(eD(ZI(this)),eD(JI(e)),arguments.length>1?arguments[1]:void 0)}});var iD=nh("String").includes,nD=ue,aD=QI,sD=iD,oD=Array.prototype,lD=String.prototype,uD=i((function(e){var t=e.includes;return e===oD||nD(oD,e)&&t===oD.includes?aD:"string"==typeof e||e===lD||nD(lD,e)&&t===lD.includes?sD:t}));function cD(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 hD(e,t){var r;if(e){if("string"==typeof e)return cD(e,t);var i=Uv(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?AT(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?cD(e,t):void 0}}function dD(e){return function(e){if(ov(e))return cD(e)}(e)||function(e){if(void 0!==hc&&null!=$k(e)||null!=e["@@iterator"])return AT(e)}(e)||hD(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 fD(e,t){return function(e){if(ov(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==hc&&$k(e)||e["@@iterator"];if(null!=r){var i,n,a,s,o=[],l=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(rf(o).call(o,i.value),o.length!==t);l=!0);}catch(c){u=!0,n=c}finally{try{if(!l&&null!=r.return&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw n}}return o}}(e,t)||hD(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 vD={exports:{}},gD=o((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),pD=o,mD=re,yD=S,ED=gD,kD=Object.isExtensible,TD=pD((function(){kD(1)}))||ED?function(e){return!!mD(e)&&((!ED||"ArrayBuffer"!=yD(e))&&(!kD||kD(e)))}:kD,SD=!o((function(){return Object.isExtensible(Object.preventExtensions({}))})),AD=wr,LD=y,bD=fn,RD=re,ID=et,DD=Zt.f,_D=Xn,wD=Jn,CD=TD,PD=SD,xD=!1,MD=at("meta"),OD=0,FD=function(e){DD(e,MD,{value:{objectID:"O"+OD++,weakData:{}}})},ND=vD.exports={enable:function(){ND.enable=function(){},xD=!0;var e=_D.f,t=LD([].splice),r={};r[MD]=1,e(r).length&&(_D.f=function(r){for(var i=e(r),n=0,a=i.length;n<a;n++)if(i[n]===MD){t(i,n,1);break}return i},AD({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:wD.f}))},fastKey:function(e,t){if(!RD(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!ID(e,MD)){if(!CD(e))return"F";if(!t)return"E";FD(e)}return e[MD].objectID},getWeakData:function(e,t){if(!ID(e,MD)){if(!CD(e))return!0;if(!t)return!1;FD(e)}return e[MD].weakData},onFreeze:function(e){return PD&&xD&&CD(e)&&!ID(e,MD)&&FD(e),e}};bD[MD]=!0;var UD=vD.exports,BD=wr,GD=s,KD=UD,HD=o,VD=yr,jD=np,YD=Op,qD=_,WD=re,zD=Ua,XD=Zt.f,QD=ls.forEach,$D=C,JD=es.set,ZD=es.getterFor,e_=function(e,t,r){var i,n=-1!==e.indexOf("Map"),a=-1!==e.indexOf("Weak"),s=n?"set":"add",o=GD[e],l=o&&o.prototype,u={};if($D&&qD(o)&&(a||l.forEach&&!HD((function(){(new o).entries().next()})))){var c=(i=t((function(t,r){JD(YD(t,c),{type:e,collection:new o}),null!=r&&jD(r,t[s],{that:t,AS_ENTRIES:n})}))).prototype,h=ZD(e);QD(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in l)||a&&"clear"==e||VD(c,e,(function(r,i){var n=h(this).collection;if(!t&&a&&!WD(r))return"get"==e&&void 0;var s=n[e](0===r?0:r,i);return t?this:s}))})),a||XD(c,"size",{configurable:!0,get:function(){return h(this).collection.size}})}else i=r.getConstructor(t,e,n,s),KD.enable();return zD(i,e,!1,!0),u[e]=i,BD({global:!0,forced:!0},u),a||r.setStrong(i,e,n),i},t_=zn,r_=va,i_=lL,n_=Jt,a_=Op,s_=W,o_=np,l_=Au,u_=Lu,c_=Pp,h_=C,d_=UD.fastKey,f_=es.set,v_=es.getterFor,g_={getConstructor:function(e,t,r,i){var n=e((function(e,n){a_(e,a),f_(e,{type:t,index:t_(null),first:void 0,last:void 0,size:0}),h_||(e.size=0),s_(n)||o_(n,e[i],{that:e,AS_ENTRIES:r})})),a=n.prototype,s=v_(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=d_(t,!0),key:t,value:r,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=o),i&&(i.next=o),h_?a.size++:e.size++,"F"!==n&&(a.index[n]=o)),e},l=function(e,t){var r,i=s(e),n=d_(t);if("F"!==n)return i.index[n];for(r=i.first;r;r=r.next)if(r.key==t)return r};return i_(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,h_?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),h_?r.size--:t.size--}return!!i},forEach:function(e){for(var t,r=s(this),i=n_(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)}}),i_(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)}}),h_&&r_(a,"size",{configurable:!0,get:function(){return s(this).size}}),n},setStrong:function(e,t,r){var i=t+" Iterator",n=v_(t),a=v_(i);l_(e,t,(function(e,t){f_(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)?u_("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,u_(void 0,!0))}),r?"entries":"values",!r,!0),c_(t)}};e_("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),g_);var p_=ie.Map,m_=Jt,y_=M,E_=xe,k_=Fh,T_=W,S_=np,A_=[].push,L_=function(e){var t,r,i,n,a=arguments.length,s=a>1?arguments[1]:void 0;return k_(this),(t=void 0!==s)&&E_(s),T_(e)?new this:(r=[],t?(i=0,n=m_(s,a>2?arguments[2]:void 0),S_(e,(function(e){y_(A_,r,n(e,i++))}))):S_(e,A_,{that:r}),new this(r))};wr({target:"Map",stat:!0,forced:!0},{from:L_});var b_=xo,R_=function(){return new this(b_(arguments))};wr({target:"Map",stat:!0,forced:!0},{of:R_});var I_=_e,D_=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(I_(e)+" is not a map")},__=function(e,t){return 1==t?function(t,r){return t[e](r)}:function(t,r,i){return t[e](r,i)}},w_=__,C_=le("Map"),P_={Map:C_,set:w_("set",2),get:w_("get",1),has:w_("has",1),remove:w_("delete",1),proto:C_.prototype},x_=D_,M_=P_.remove;wr({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=x_(this),r=!0,i=0,n=arguments.length;i<n;i++)e=M_(t,arguments[i]),r=r&&e;return!!r}});var O_=D_,F_=P_.get,N_=P_.has,U_=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{emplace:function(e,t){var r,i,n=O_(this);return N_(n,e)?(r=F_(n,e),"update"in t&&(r=t.update(r,e,n),U_(n,e,r)),r):(i=t.insert(e,n),U_(n,e,i),i)}});var B_=M,G_=function(e,t,r){for(var i,n,a=r||e.next;!(i=B_(a,e)).done;)if(void 0!==(n=t(i.value)))return n},K_=G_,H_=function(e,t,r){return r?K_(e.entries(),(function(e){return t(e[1],e[0])})):e.forEach(t)},V_=Jt,j_=D_,Y_=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=j_(this),r=V_(e,arguments.length>1?arguments[1]:void 0);return!1!==Y_(t,(function(e,i){if(!r(e,i,t))return!1}),!0)}});var q_=Jt,W_=D_,z_=H_,X_=P_.Map,Q_=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=W_(this),r=q_(e,arguments.length>1?arguments[1]:void 0),i=new X_;return z_(t,(function(e,n){r(e,n,t)&&Q_(i,n,e)})),i}});var $_=Jt,J_=D_,Z_=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=J_(this),r=$_(e,arguments.length>1?arguments[1]:void 0),i=Z_(t,(function(e,i){if(r(e,i,t))return{value:e}}),!0);return i&&i.value}});var ew=Jt,tw=D_,rw=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=tw(this),r=ew(e,arguments.length>1?arguments[1]:void 0),i=rw(t,(function(e,i){if(r(e,i,t))return{key:i}}),!0);return i&&i.key}});var iw=wr,nw=M,aw=_,sw=xe,ow=np,lw=P_.Map,uw=y([].push);iw({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){var r=new(aw(this)?this:lw);sw(t);var i=sw(r.has),n=sw(r.get),a=sw(r.set);return ow(e,(function(e){var s=t(e);nw(i,r,s)?uw(nw(n,r,s),e):nw(a,r,s,[e])})),r}});var cw=function(e,t){return e===t||e!=e&&t!=t},hw=D_,dw=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return!0===dw(hw(this),(function(t){if(cw(t,e))return!0}),!0)}});var fw=M,vw=np,gw=_,pw=xe,mw=P_.Map;wr({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new(gw(this)?this:mw);pw(t);var i=pw(r.set);return vw(e,(function(e){fw(i,r,t(e),e)})),r}});var yw=D_,Ew=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){var t=Ew(yw(this),(function(t,r){if(t===e)return{key:r}}),!0);return t&&t.key}});var kw=Jt,Tw=D_,Sw=H_,Aw=P_.Map,Lw=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=Tw(this),r=kw(e,arguments.length>1?arguments[1]:void 0),i=new Aw;return Sw(t,(function(e,n){Lw(i,r(e,n,t),e)})),i}});var bw=Jt,Rw=D_,Iw=H_,Dw=P_.Map,_w=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=Rw(this),r=bw(e,arguments.length>1?arguments[1]:void 0),i=new Dw;return Iw(t,(function(e,n){_w(i,n,r(e,n,t))})),i}});var ww=D_,Cw=np,Pw=P_.set;wr({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=ww(this),r=arguments.length,i=0;i<r;)Cw(arguments[i++],(function(e,r){Pw(t,e,r)}),{AS_ENTRIES:!0});return t}});var xw=xe,Mw=D_,Ow=H_,Fw=TypeError;wr({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=Mw(this),r=arguments.length<2,i=r?void 0:arguments[1];if(xw(e),Ow(t,(function(n,a){r?(r=!1,i=n):i=e(i,n,a,t)})),r)throw Fw("Reduce of empty map with no initial value");return i}});var Nw=Jt,Uw=D_,Bw=H_;wr({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=Uw(this),r=Nw(e,arguments.length>1?arguments[1]:void 0);return!0===Bw(t,(function(e,i){if(r(e,i,t))return!0}),!0)}});var Gw=xe,Kw=D_,Hw=TypeError,Vw=P_.get,jw=P_.has,Yw=P_.set;wr({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=Kw(this),i=arguments.length;Gw(t);var n=jw(r,e);if(!n&&i<3)throw Hw("Updating absent value");var a=n?Vw(r,e):Gw(i>2?arguments[2]:void 0)(e,r);return Yw(r,e,t(a,e,r)),r}});var qw=M,Ww=xe,zw=_,Xw=nr,Qw=TypeError,$w=function(e,t){var r,i=Xw(this),n=Ww(i.get),a=Ww(i.has),s=Ww(i.set),o=arguments.length>2?arguments[2]:void 0;if(!zw(t)&&!zw(o))throw Qw("At least one callback required");return qw(a,i,e)?(r=qw(n,i,e),zw(t)&&(r=t(r),qw(s,i,e,r))):zw(o)&&(r=o(),qw(s,i,e,r)),r};wr({target:"Map",proto:!0,real:!0,forced:!0},{upsert:$w}),wr({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:$w});var Jw=p_,Zw=i(Jw);function eC(e,t,r){var i;Jh()?eC=ch(i=$h).call(i):eC=function(e,t,r){var i=[null];rf(i).apply(i,t);var n=new(ch(Function).apply(e,i));return r&&Ch(n,r.prototype),n};return eC.apply(null,arguments)}function tC(e){var t="function"==typeof Zw?new Zw:void 0;return tC=function(e){if(null===e||(r=e,-1===nv(i=Function.toString.call(r)).call(i,"[native code]")))return e;var r,i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return eC(e,arguments,Rh(this).constructor)}return n.prototype=wh(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ch(n,e)},tC(e)}var rC=s.isFinite;wr({target:"Number",stat:!0},{isFinite:Number.isFinite||function(e){return"number"==typeof e&&rC(e)}});var iC=i(ie.Number.isFinite),nC=wr,aC=WI,sC=Math.abs;nC({target:"Number",stat:!0},{isSafeInteger:function(e){return aC(e)&&sC(e)<=9007199254740991}});var oC=i(ie.Number.isSafeInteger);wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991});var lC=i(9007199254740991),uC=xe,cC=$e,hC=q,dC=zr,fC=TypeError,vC=function(e){return function(t,r,i,n){uC(r);var a=cC(t),s=hC(a),o=dC(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 fC("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}},gC={left:vC(!1),right:vC(!0)}.left;wr({target:"Array",proto:!0,forced:!Ip&&me>79&&me<83||!rd("reduce")},{reduce:function(e){var t=arguments.length;return gC(this,e,t,t>1?arguments[1]:void 0)}});var pC=nh("Array").reduce,mC=ue,yC=pC,EC=Array.prototype,kC=i((function(e){var t=e.reduce;return e===EC||mC(EC,e)&&t===EC.reduce?yC:t})),TC=nr,SC=M,AC=et,LC=ue,bC=function(){var e=TC(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},RC=RegExp.prototype,IC=ue,DC=function(e){var t=e.flags;return void 0!==t||"flags"in RC||AC(e,"flags")||!LC(RC,e)?t:SC(bC,e)},_C=RegExp.prototype,wC=i((function(e){return e===_C||IC(_C,e)?DC(e):e.flags})),CC=f,PC=Z,xC=Vr,MC=zr,OC=rd,FC=Math.min,NC=[].lastIndexOf,UC=!!NC&&1/[1].lastIndexOf(1,-0)<0,BC=OC("lastIndexOf"),GC=UC||!BC?function(e){if(UC)return CC(NC,this,arguments)||0;var t=PC(this),r=MC(t),i=r-1;for(arguments.length>1&&(i=FC(i,xC(arguments[1]))),i<0&&(i=r+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:NC;wr({target:"Array",proto:!0,forced:GC!==[].lastIndexOf},{lastIndexOf:GC});var KC=nh("Array").lastIndexOf,HC=ue,VC=KC,jC=Array.prototype,YC=i((function(e){var t=e.lastIndexOf;return e===jC||HC(jC,e)&&t===jC.lastIndexOf?VC:t})),qC=wr,WC=Br,zC=y([].reverse),XC=[1,2];qC({target:"Array",proto:!0,forced:String(XC)===String(XC.reverse())},{reverse:function(){return WC(this)&&(this.length=this.length),zC(this)}});var QC=nh("Array").reverse,$C=ue,JC=QC,ZC=Array.prototype,eP=i((function(e){var t=e.reverse;return e===ZC||$C(ZC,e)&&t===ZC.reverse?JC:t}));wr({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)});var tP=i(Math.pow(2,-52)),rP=i(Jw);e_("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),g_);var iP=ie.Set,nP=_e,aP=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(nP(e)+" is not a set")},sP=__,oP=le("Set"),lP=oP.prototype,uP={Set:oP,add:sP("add",1),has:sP("has",1),remove:sP("delete",1),proto:lP},cP=G_,hP=function(e,t,r){return r?cP(e.keys(),t):e.forEach(t)},dP=hP,fP=uP.Set,vP=uP.add,gP=function(e){var t=new fP;return dP(e,(function(e){vP(t,e)})),t},pP=function(e){return e.size},mP=xe,yP=nr,EP=M,kP=Vr,TP=TypeError,SP=Math.max,AP=function(e,t,r,i){this.set=e,this.size=t,this.has=r,this.keys=i};AP.prototype={getIterator:function(){return yP(EP(this.keys,this.set))},includes:function(e){return EP(this.has,this.set,e)}};var LP=function(e){yP(e);var t=+e.size;if(t!=t)throw TP("Invalid size");return new AP(e,SP(kP(t),0),mP(e.has),mP(e.keys))},bP=aP,RP=gP,IP=pP,DP=LP,_P=hP,wP=G_,CP=uP.has,PP=uP.remove,xP=function(e){var t=bP(this),r=DP(e),i=RP(t);return IP(t)<=r.size?_P(t,(function(e){r.includes(e)&&PP(i,e)})):wP(r.getIterator(),(function(e){CP(t,e)&&PP(i,e)})),i},MP=function(){return!1},OP=xP;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{difference:OP});var FP=aP,NP=pP,UP=LP,BP=hP,GP=G_,KP=uP.Set,HP=uP.add,VP=uP.has,jP=function(e){var t=FP(this),r=UP(e),i=new KP;return NP(t)>r.size?GP(r.getIterator(),(function(e){VP(t,e)&&HP(i,e)})):BP(t,(function(e){r.includes(e)&&HP(i,e)})),i},YP=jP;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{intersection:YP});var qP=aP,WP=uP.has,zP=pP,XP=LP,QP=hP,$P=G_,JP=jg,ZP=function(e){var t=qP(this),r=XP(e);if(zP(t)<=r.size)return!1!==QP(t,(function(e){if(r.includes(e))return!1}),!0);var i=r.getIterator();return!1!==$P(i,(function(e){if(WP(t,e))return JP(i,"normal",!1)}))},ex=ZP;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{isDisjointFrom:ex});var tx=aP,rx=pP,ix=hP,nx=LP,ax=function(e){var t=tx(this),r=nx(e);return!(rx(t)>r.size)&&!1!==ix(t,(function(e){if(!r.includes(e))return!1}),!0)},sx=ax;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{isSubsetOf:sx});var ox=aP,lx=uP.has,ux=pP,cx=LP,hx=G_,dx=jg,fx=function(e){var t=ox(this),r=cx(e);if(ux(t)<r.size)return!1;var i=r.getIterator();return!1!==hx(i,(function(e){if(!lx(t,e))return dx(i,"normal",!1)}))},vx=fx;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{isSupersetOf:vx});var gx=aP,px=gP,mx=LP,yx=G_,Ex=uP.add,kx=uP.has,Tx=uP.remove,Sx=function(e){var t=gx(this),r=mx(e).getIterator(),i=px(t);return yx(r,(function(e){kx(t,e)?Tx(i,e):Ex(i,e)})),i},Ax=Sx;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{symmetricDifference:Ax});var Lx=aP,bx=uP.add,Rx=gP,Ix=LP,Dx=G_,_x=function(e){var t=Lx(this),r=Ix(e).getIterator(),i=Rx(t);return Dx(r,(function(e){bx(i,e)})),i},wx=_x;wr({target:"Set",proto:!0,real:!0,forced:!MP()},{union:wx});var Cx=iP;wr({target:"Set",stat:!0,forced:!0},{from:L_}),wr({target:"Set",stat:!0,forced:!0},{of:R_});var Px=aP,xx=uP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{addAll:function(){for(var e=Px(this),t=0,r=arguments.length;t<r;t++)xx(e,arguments[t]);return e}});var Mx=aP,Ox=uP.remove;wr({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:function(){for(var e,t=Mx(this),r=!0,i=0,n=arguments.length;i<n;i++)e=Ox(t,arguments[i]),r=r&&e;return!!r}});var Fx=Jt,Nx=aP,Ux=hP;wr({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=Nx(this),r=Fx(e,arguments.length>1?arguments[1]:void 0);return!1!==Ux(t,(function(e){if(!r(e,e,t))return!1}),!0)}});var Bx=ui,Gx=et,Kx=W,Hx=El,Vx=vt("iterator"),jx=Object,Yx=_,qx=function(e){if(Kx(e))return!1;var t=jx(e);return void 0!==t[Vx]||"@@iterator"in t||Gx(Hx,Bx(t))},Wx=re,zx=le("Set"),Xx=function(e){return function(e){return Wx(e)&&"number"==typeof e.size&&Yx(e.has)&&Yx(e.keys)}(e)?e:qx(e)?new zx(e):e},Qx=M,$x=Xx,Jx=xP;wr({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){return Qx(Jx,this,$x(e))}});var Zx=Jt,eM=aP,tM=hP,rM=uP.Set,iM=uP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=eM(this),r=Zx(e,arguments.length>1?arguments[1]:void 0),i=new rM;return tM(t,(function(e){r(e,e,t)&&iM(i,e)})),i}});var nM=Jt,aM=aP,sM=hP;wr({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=aM(this),r=nM(e,arguments.length>1?arguments[1]:void 0),i=sM(t,(function(e){if(r(e,e,t))return{value:e}}),!0);return i&&i.value}});var oM=M,lM=Xx,uM=jP;wr({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){return oM(uM,this,lM(e))}});var cM=M,hM=Xx,dM=ZP;wr({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){return cM(dM,this,hM(e))}});var fM=M,vM=Xx,gM=ax;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){return fM(gM,this,vM(e))}});var pM=M,mM=Xx,yM=fx;wr({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){return pM(yM,this,mM(e))}});var EM=wr,kM=y,TM=aP,SM=hP,AM=tn,LM=kM([].join),bM=kM([].push);EM({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=TM(this),r=void 0===e?",":AM(e),i=[];return SM(t,(function(e){bM(i,e)})),LM(i,r)}});var RM=Jt,IM=aP,DM=hP,_M=uP.Set,wM=uP.add;wr({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=IM(this),r=RM(e,arguments.length>1?arguments[1]:void 0),i=new _M;return DM(t,(function(e){wM(i,r(e,e,t))})),i}});var CM=xe,PM=aP,xM=hP,MM=TypeError;wr({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=PM(this),r=arguments.length<2,i=r?void 0:arguments[1];if(CM(e),xM(t,(function(n){r?(r=!1,i=n):i=e(i,n,n,t)})),r)throw MM("Reduce of empty set with no initial value");return i}});var OM=Jt,FM=aP,NM=hP;wr({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=FM(this),r=OM(e,arguments.length>1?arguments[1]:void 0);return!0===NM(t,(function(e){if(r(e,e,t))return!0}),!0)}});var UM=M,BM=Xx,GM=Sx;wr({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){return UM(GM,this,BM(e))}});var KM=M,HM=Xx,VM=_x;wr({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){return KM(VM,this,HM(e))}});var jM,YM=i(Cx),qM=nh("Array").entries,WM=ui,zM=et,XM=ue,QM=qM,$M=Array.prototype,JM={DOMTokenList:!0,NodeList:!0},ZM=i((function(e){var t=e.entries;return e===$M||XM($M,e)&&t===$M.entries||zM(JM,WM(e))?QM:t})),eO=nh("Array").values,tO=ui,rO=et,iO=ue,nO=eO,aO=Array.prototype,sO={DOMTokenList:!0,NodeList:!0},oO=i((function(e){var t=e.values;return e===aO||iO(aO,e)&&t===aO.values||rO(sO,tO(e))?nO:t})),lO=iC||function(e){return"number"==typeof e&&isFinite(e)},uO=oC||function(e){return"number"==typeof e&&Math.abs(e)<=cO},cO=lC||9007199254740991,hO=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),dO=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}({}),fO=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}({}),vO="manifest",gO="level",pO="audioTrack",mO="subtitleTrack",yO="main",EO="audio",kO="subtitle",TO=function(){function e(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=r,this.alpha_=r?Math.exp(Math.log(.5)/r):0,this.estimate_=i,this.totalWeight_=n}return Fc(e,[{key:"sample",value:function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}]),e}(),SO=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;t(this,e),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new TO(r),this.fast_=new TO(i),this.defaultTTFB_=a,this.ttfb_=new TO(r)}return Fc(e,[{key:"update",value:function(e,t){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==e&&(this.slow_=new TO(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new TO(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new TO(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 AO(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=Cc(e)||!e)return e;var r=e[bT];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=Cc(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Cc(t)?t:t+""}(t))in e?iT(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function LO(){var e;return LO=zk?sT(e=zk).call(e):function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},LO.apply(null,arguments)}function bO(e,t){var r=yv(e);if(Zk){var i=Zk(e);t&&(i=xk(i).call(i,(function(t){return eT(e,t).enumerable}))),r.push.apply(r,i)}return r}function RO(e){for(var t=1;t<arguments.length;t++){var r,i,n=null!=arguments[t]?arguments[t]:{};t%2?vd(r=bO(Object(n),!0)).call(r,(function(t){AO(e,t,n[t])})):tT?rT(e,tT(n)):vd(i=bO(Object(n))).call(i,(function(t){iT(e,t,eT(n,t))}))}return e}var IO=Fc((function e(r,i){var n,a,s,o,l;t(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var u="[".concat(r,"]:");this.trace=DO,this.debug=sT(n=i.debug).call(n,null,u),this.log=sT(a=i.log).call(a,null,u),this.warn=sT(s=i.warn).call(s,null,u),this.info=sT(o=i.info).call(o,null,u),this.error=sT(l=i.error).call(l,null,u)})),DO=function(){},_O={trace:DO,debug:DO,log:DO,warn:DO,info:DO,error:DO};function wO(){return LO({},_O)}function CO(e,t,r){var i;return t[e]?sT(i=t[e]).call(i,t):function(e,t){var r,i=self.console[e];return i?sT(i).call(i,self.console,_d(r="".concat(t?"["+t+"] ":"","[")).call(r,e,"] >")):DO}(e,r)}var PO=wO();var xO=PO;function MO(){if("undefined"!=typeof self)return(!(arguments.length>0&&void 0!==arguments[0])||arguments[0]||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function OO(e,t){var r=yv(e),i=yv(t),n=r.length,a=i.length;return!n||!a||n===a&&!KT(r).call(r,(function(e){return-1===av(i).call(i,e)}))}var FO={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 NO(e,t){var r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!KT(r=e.split(",")).call(r,(function(e){return!UO(e,t,i)}))}function UO(e,t){var r,i=MO(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);return null!=(r=null==i?void 0:i.isTypeSupported(BO(e,t)))&&r}function BO(e,t){var r;return _d(r="".concat(t,"/mp4;codecs=")).call(r,e)}function GO(e){if(e){var t=e.substring(0,4);return FO.video[t]}return 2}function KO(e){var t;return kC(t=e.split(",")).call(t,(function(e,t){var r=FO.video[t];return r?(2*r+e)/(e?3:2):(FO.audio[t]+e)/(e?2:1)}),0)}var HO={};var VO=/flac|opus|mp4a\.40\.34/i;function jO(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(VO,(function(e){return function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(HO[e])return HO[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(UO(r[i],"audio",t))return HO[e]=r[i],r[i];if("mp3"===r[i]&&null!=(n=MO(t))&&n.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t)}))}function YO(e,t){var r;if(e&&(e.length>4||-1!==av(r=["ac-3","ec-3","alac","fLaC","Opus"]).call(r,e)))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function qO(e){if(UI(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 WO(e){var t=MO(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 zO={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},XO={};function QO(e,t,r){var i=e.videoCodec,n=e.audioCodec;if(!i&&!n||!r)return nk.resolve(zO);var a,s=[];if(i){var o,l={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},u=e.videoRange;"SDR"!==u&&(l.transferFunction=u.toLowerCase()),s.push.apply(s,Pk(o=i.split(",")).call(o,(function(e){return{type:"media-source",video:RO(RO({},l),{},{contentType:BO(qO(e),"video")})}})))}n&&e.audioGroups&&vd(a=e.audioGroups).call(a,(function(e){var r,i;e&&(null==(i=t.groups[e])||vd(r=i.tracks).call(r,(function(t){if(t.groupId===e){var r,i=t.channels||"",a=bS(i);if(lO(a)&&a>2)s.push.apply(s,Pk(r=n.split(",")).call(r,(function(e){return{type:"media-source",audio:{contentType:BO(e,"audio"),channels:""+a}}})))}})))}));return nk.all(Pk(s).call(s,(function(e){var t=function(e){var t=e.audio,r=e.video,i=r||t;if(i){var n,a,s,o,l,u,c,h=i.contentType.split('"')[1];if(r)return _d(n=_d(a=_d(s=_d(o=_d(l="r".concat(r.height,"x")).call(l,r.width,"f")).call(o,Math.ceil(r.framerate))).call(s,r.transferFunction||"sd","_")).call(a,h,"_")).call(n,Math.ceil(r.bitrate/1e5));if(t)return _d(u=_d(c="c".concat(t.channels)).call(c,t.spatialRendering?"s":"n","_")).call(u,h)}return""}(e);return XO[t]||(XO[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!KT(e).call(e,(function(e){return!e.supported})),configurations:s,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:s,decodingInfoResults:[],error:e}}))}var $O=["NONE","TYPE-0","TYPE-1",null];var JO=["SDR","PQ","HLG"];var ZO="",eF="YES",tF="v2";function rF(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?tF:eF:ZO}var iF=function(){function e(r,i,n){t(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=r,this.part=i,this.skip=n}return Fc(e,[{key:"addDirectives",value:function(e){var t=new gI(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}(),nF=function(){function e(r){var i,n;t(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[r.url],this._attrs=[r.attrs],this.bitrate=r.bitrate,r.details&&(this.details=r.details),this.id=r.id||0,this.name=r.name,this.width=r.width||0,this.height=r.height||0,this.frameRate=r.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=r.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=r.audioCodec,this.videoCodec=r.videoCodec,this.codecSet=Pk(i=xk(n=[r.videoCodec,r.audioCodec]).call(n,(function(e){return!!e}))).call(i,(function(e){return e.substring(0,4)})).join(","),this.addGroupId("audio",r.attrs.AUDIO),this.addGroupId("text",r.attrs.SUBTITLES)}return Fc(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return aF(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return aF(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===av(r).call(r,t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===av(i).call(i,t)&&i.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}]),e}();function aF(e,t){return!(!t||!e)&&-1!==av(e).call(e,t)}function sF(e,t){var r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){var n="SDR"!==(i=t.allowedVideoRanges||Bv(JO).call(JO,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 oF(e,t){var r;xO.log(_d(r='[abr] start candidates with "'.concat(e,'" ignored because ')).call(r,t))}function lF(e){return kC(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 uF(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function cF(e,t,r){if("attrs"in e){var i=av(t).call(t,e);if(-1!==i)return i}for(var n=0;n<t.length;n++){if(hF(e,t[n],r))return n}return-1}function hF(e,t,r){var i=e.groupId,n=e.name,a=e.lang,s=e.assocLang,o=e.characteristics,l=e.default,u=e.forced;return(void 0===i||t.groupId===i)&&(void 0===n||t.name===n)&&(void 0===a||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--";if(e.length===t.length)return e===t;return UI(e).call(e,t)||UI(t).call(t,e)}(a,t.lang))&&(void 0===a||t.assocLang===s)&&(void 0===l||t.default===l)&&(void 0===u||t.forced===u)&&(void 0===o||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),i=t.split(",");return r.length===i.length&&!KT(r).call(r,(function(e){return-1===av(i).call(i,e)}))}(o,t.characteristics))&&(void 0===r||r(e,t))}function dF(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 fF(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 vF(e,t){var r;return!!e&&e!==(null==(r=t.levels[t.loadLevel])?void 0:r.uri)}var gF=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"abr",e.logger)).hls=void 0,n.lastLevelLoadSec=0,n.lastLoadedFragLevel=-1,n.firstSelection=-1,n._nextAutoLevel=-1,n.nextAutoLevelKey="",n.audioTracksByGroup=null,n.codecTiers=null,n.timer=-1,n.fragCurrent=null,n.partCurrent=null,n.bitrateTestDelay=0,n.bwEstimator=void 0,n._abandonRulesCheck=function(){var e,t,r,i,a,s,o,l,u,c,h,d,f=Zh(n),v=f.fragCurrent,g=f.partCurrent,p=f.hls,m=p.autoLevelEnabled,y=p.media;if(v&&y){var E=performance.now(),k=g?g.stats:v.stats,T=g?g.duration:v.duration,S=E-k.loading.start,A=p.minAutoLevel;if(k.aborted||k.loaded&&k.loaded===k.total||v.level<=A)return n.clearTimer(),void(n._nextAutoLevel=-1);if(m&&!y.paused&&y.playbackRate&&y.readyState){var L=p.mainForwardBufferInfo;if(null!==L){var b=n.bwEstimator.getEstimateTTFB(),R=Math.abs(y.playbackRate);if(!(S<=Math.max(b,T/(2*R)*1e3))){var I=L.len/R,D=k.loading.first?k.loading.first-k.loading.start:-1,_=k.loaded&&D>-1,w=n.getBwEstimate(),C=p.levels,P=C[v.level],x=Math.max(k.loaded,Math.round(T*(v.bitrate||P.averageBitrate)/8)),M=_?S-D:S;M<1&&_&&(M=Math.min(S,8*k.loaded/w));var O=_?1e3*k.loaded/M:0,F=b/1e3,N=O?(x-k.loaded)/O:8*x/w+F;if(!(N<=I)){var U,B=O?8*O:w,G=!0===(null==(d=n.hls.latestLevelDetails)?void 0:d.live),K=n.hls.config.abrBandWidthUpFactor,H=Number.POSITIVE_INFINITY;for(U=v.level-1;U>A;U--){var V=C[U].maxBitrate,j=!C[U].details||G;if((H=n.getTimeToLoadFrag(F,B,T*V,j))<Math.min(I,T+F))break}if(!(H>=N||H>10*T)){_?n.bwEstimator.sample(S-Math.min(b,D),k.loaded):n.bwEstimator.sampleTTFB(S);var Y=C[U].maxBitrate;n.getBwEstimate()*K>Y&&n.resetEstimator(Y);var q=n.findBestLevel(Y,A,U,0,I,1,1);q>-1&&(U=q),n.warn(_d(e=_d(t=_d(r=_d(i=_d(a=_d(s=_d(o=_d(l=_d(u=_d(c=_d(h="Fragment ".concat(v.sn)).call(h,g?" part "+g.index:""," of level ")).call(c,v.level," is loading too slowly;\n Fragment duration: ")).call(u,v.duration.toFixed(3),"\n Time to underbuffer: ")).call(l,I.toFixed(3)," s\n Estimated load time for current fragment: ")).call(o,N.toFixed(3)," s\n Estimated load time for down switch fragment: ")).call(s,H.toFixed(3)," s\n TTFB estimate: ")).call(a,0|D," ms\n Current BW estimate: ")).call(i,lO(w)?0|w:"Unknown"," bps\n New BW estimate: ")).call(r,0|n.getBwEstimate()," bps\n Switching to level ")).call(t,U," @ ")).call(e,0|Y," bps")),p.nextLoadLevel=p.nextAutoLevel=U,n.clearTimer(),n.timer=lS((function(){if(n.clearTimer(),n.fragCurrent===v&&n.hls.loadLevel===U&&U>0){var e,t,r=n.getStarvationDelay();if(n.warn(_d(e=_d(t="Aborting inflight request ".concat(U>0?"and switching down":"","\n Fragment duration: ")).call(t,v.duration.toFixed(3)," s\n Time to underbuffer: ")).call(e,r.toFixed(3)," s")),v.abortRequests(),n.fragCurrent=n.partCurrent=null,U>A){var i=n.findBestLevel(n.hls.levels[A].bitrate,A,U,0,r,1,1);-1===i&&(i=A),n.hls.nextLoadLevel=n.hls.nextAutoLevel=i,n.resetEstimator(n.hls.levels[i].bitrate)}}}),1e3*H),p.trigger(fO.FRAG_LOAD_EMERGENCY_ABORTED,{frag:v,part:g,stats:k})}}}}}}},n.hls=e,n.bwEstimator=n.initEstimator(),n.registerListeners(),n}return Fc(i,[{key:"resetEstimator",value:function(e){e&&(this.log("setting initial bwe to ".concat(e)),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new SO(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.FRAG_LOADING,this.onFragLoading,this),e.on(fO.FRAG_LOADED,this.onFragLoaded,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.FRAG_LOADING,this.onFragLoading,this),e.off(fO.FRAG_LOADED,this.onFragLoaded,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(fO.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=lS(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case dO.BUFFER_ADD_CODEC_ERROR:case dO.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case dO.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;lO(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===yO&&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(fO.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!==yO||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e,t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,s=this.findBestLevel(n,i,r,0,a,1,1);if(s>-1)return s;var o=this.hls.firstLevel,l=Math.min(Math.max(o,i),r);return this.warn(_d(e="Could not find best starting auto level. Defaulting to first in playlist ".concat(o," clamped to ")).call(e,l)),l}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel,n=Math.min(Math.max(e,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}},{key:"getAutoLevelKey",value:function(){var e;return _d(e="".concat(this.getBwEstimate(),"_")).call(e,this.getStarvationDelay().toFixed(2))}},{key:"getNextABRAutoLevel",value:function(){var e,t=this.fragCurrent,r=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,s=i.minAutoLevel,o=r?r.duration:t?t.duration:0,l=this.getBwEstimate(),u=this.getStarvationDelay(),c=a.abrBandWidthFactor,h=a.abrBandWidthUpFactor;if(u){var d=this.findBestLevel(l,s,n,u,0,c,h);if(d>=0)return d}var f=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var v,g=this.bitrateTestDelay;if(g)f=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-g,this.info(_d(v="bitrate test took ".concat(Math.round(1e3*g),"ms, set first fragment max fetchDuration to ")).call(v,Math.round(1e3*f)," ms")),c=h=1}var p=this.findBestLevel(l,s,n,u,f,c,h);if(this.info(_d(e="".concat(u?"rebuffering expected":"buffer is empty",", optimal quality level ")).call(e,p)),p>-1)return p;var m=i.levels[s],y=i.levels[i.loadLevel];return(null==m?void 0:m.bitrate)<(null==y?void 0:y.bitrate)?s:i.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,r,i,n,a,s){var o,l=this,u=i+n,c=this.lastLoadedFragLevel,h=-1===c?this.hls.firstLevel:c,d=this.fragCurrent,f=this.partCurrent,v=this.hls,g=v.levels,p=v.allAudioTracks,m=v.loadLevel,y=v.config;if(1===g.length)return 0;var E,k=g[h],T=!(null==(o=this.hls.latestLevelDetails)||!o.live),S=-1===m||-1===c,A="SDR",L=(null==k?void 0:k.frameRate)||0,b=y.audioPreference,R=y.videoPreference,I=this.audioTracksByGroup||(this.audioTracksByGroup=lF(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var _=this.codecTiers||(this.codecTiers=function(e,t,r,i){var n;return kC(n=Bv(e).call(e,r,i+1)).call(n,(function(e,r,i){if(!r.codecSet)return e;var n=r.audioGroups,a=e[r.codecSet];a||(e[r.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,r.bitrate);var s=Math.min(r.height,r.width);return a.minHeight=Math.min(a.minHeight,s),a.minFramerate=Math.min(a.minFramerate,r.frameRate),a.minIndex=Math.min(a.minIndex,i),a.maxScore=Math.max(a.maxScore,r.score),a.fragmentError+=r.fragmentError,a.videoRanges[r.videoRange]=(a.videoRanges[r.videoRange]||0)+1,n&&vd(n).call(n,(function(e){var r;if(e){var i=t.groups[e];i&&(a.hasDefaultAudio=a.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,vd(r=yv(i.channels)).call(r,(function(e){a.channels[e]=(a.channels[e]||0)+i.channels[e]})))}})),e}),{})}(g,I,t,r)),w=function(e,t,r,i,n){for(var a=yv(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===Rk(s),c=!1,h=!1,d=1/0,f=1/0,v=1/0,g=1/0,p=0,m=[],y=sF(t,n),E=y.preferHDR,k=y.allowedVideoRanges,T=function(){var t=e[a[S]];c||(c=t.channels[2]>0),d=Math.min(d,t.minHeight),f=Math.min(f,t.minFramerate),v=Math.min(v,t.minBitrate),xk(k).call(k,(function(e){return t.videoRanges[e]>0})).length>0&&(h=!0)},S=a.length;S--;)T();d=lO(d)?d:0,f=lO(f)?f:0;var A=Math.max(1080,d),L=Math.max(30,f);v=lO(v)?v:r,r=Math.max(v,r),h||(t=void 0);var b=a.length>1;return{codecSet:kC(a).call(a,(function(t,i){var n=e[i];if(i===t)return t;if(m=h?xk(k).call(k,(function(e){return n.videoRanges[e]>0})):[],b){var a,d,f,v,y;if(n.minBitrate>r)return oF(i,_d(a="min bitrate of ".concat(n.minBitrate," > current estimate of ")).call(a,r)),t;if(!n.hasDefaultAudio)return oF(i,"no renditions with default or auto-select sound found"),t;if(o&&av(i).call(i,o.substring(0,4))%5!=0)return oF(i,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!u){if(!n.channels[s])return oF(i,_d(d="no renditions with ".concat(s," channel sound found (channels options: ")).call(d,yv(n.channels),")")),t}else if((!o||u)&&c&&0===n.channels[2])return oF(i,"no renditions with stereo sound found"),t;if(n.minHeight>A)return oF(i,_d(f="min resolution of ".concat(n.minHeight," > maximum of ")).call(f,A)),t;if(n.minFramerate>L)return oF(i,_d(v="min framerate of ".concat(n.minFramerate," > maximum of ")).call(v,L)),t;if(!KT(m).call(m,(function(e){return n.videoRanges[e]>0})))return oF(i,"no variants with VIDEO-RANGE of ".concat(jI(m)," found")),t;if(l&&av(i).call(i,l.substring(0,4))%5!=0)return oF(i,'video codec preference "'.concat(l,'" not found')),t;if(n.maxScore<p)return oF(i,_d(y="max score of ".concat(n.maxScore," < selected max of ")).call(y,p)),t}return t&&(KO(i)>=KO(t)||n.fragmentError>e[t].fragmentError)?t:(g=n.minIndex,p=n.maxScore,i)}),void 0),videoRanges:m,preferHDR:E,minFramerate:f,minBitrate:v,minIndex:g}}(_,A,e,b,R),C=w.codecSet,P=w.videoRanges,x=w.minFramerate,M=w.minBitrate,O=w.minIndex,F=w.preferHDR;D=O,E=C,A=F?P[P.length-1]:P[0],L=x,e=Math.max(e,M),this.log("picked start tier ".concat(jI(w)))}else E=null==k?void 0:k.codecSet,A=null==k?void 0:k.videoRange;for(var N=f?f.duration:d?d.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,B=[],G=function(){var t=g[K],o=K>h;if(!t)return"continue";if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var d=navigator.mediaCapabilities;"function"!=typeof(null==d?void 0:d.decodingInfo)||!function(e,t,r,i,n,a){var s,o=e.audioCodec?e.audioGroups:null,l=null==a?void 0:a.audioCodec,u=null==a?void 0:a.channels,c=u?Rk(u):l?1/0:2,h=null;if(null!=o&&o.length)try{h=1===o.length&&o[0]?t.groups[o[0]].channels:kC(o).call(o,(function(e,r){if(r){var i,n=t.groups[r];if(!n)throw new Error("Audio track group ".concat(r," not found"));vd(i=yv(n.channels)).call(i,(function(t){e[t]=(e[t]||0)+n.channels[t]}))}return e}),{2:0})}catch(JV){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&&lO(c)&&KT(s=yv(h)).call(s,(function(e){return Rk(e)>c}))}(t,I,A,L,e,b)&&"hvc1"!==(null==(V=t.videoCodec)?void 0:V.substring(0,4))?t.supportedResult=zO:(t.supportedPromise=QO(t,I,d),t.supportedPromise.then((function(e){if(l.hls){t.supportedResult=e;var r,i,n=l.hls.levels,a=av(n).call(n,t);if(e.error)l.warn(_d(r=_d(i='MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ')).call(i,a," ")).call(r,jI(e)));else if(!e.supported){var s;l.warn(_d(s="Unsupported MediaCapabilities decodingInfo result for level ".concat(a," ")).call(s,jI(e))),a>-1&&n.length>1&&(l.log("Removing unsupported level ".concat(a)),l.hls.removeLevel(a),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0))}}})))}if((E&&t.codecSet!==E||A&&t.videoRange!==A||o&&L>t.frameRate||!o&&L>0&&L<t.frameRate||t.supportedResult&&(null==(H=t.supportedResult.decodingInfoResults)||!H[0].smooth))&&(!S||K!==D))return B.push(K),"continue";var v,p=t.details,k=(f?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;v=o?s*e:a*e;var R=N&&i>=2*N&&0===n?t.averageBitrate:t.maxBitrate,_=l.getTimeToLoadFrag(U,v,R*k,void 0===p);if(v>=R&&(K===c||0===t.loadError&&0===t.fragmentError)&&(_<=U||!lO(_)||T&&!l.bitrateTestDelay||_<u)){var w=l.forcedAutoLevel;if(K!==m&&(-1===w||w!==m)){var C,P,x,M,O,F,G,j,Y,q,W,z,X,Q,$,J;if(B.length)l.trace(_d(z=_d(X=_d(Q=_d($=_d(J="Skipped level(s) ".concat(B.join(",")," of ")).call(J,r,' max with CODECS and VIDEO-RANGE:"')).call($,g[B[0]].codecs,'" ')).call(Q,g[B[0]].videoRange,'; not compatible with "')).call(X,E,'" ')).call(z,A));l.info(_d(C=_d(P=_d(x=_d(M=_d(O=_d(F=_d(G=_d(j=_d(Y=_d(q=_d(W="switch candidate:".concat(h,"->")).call(W,K," adjustedbw(")).call(q,Math.round(v),")-bitrate=")).call(Y,Math.round(v-R)," ttfb:")).call(j,U.toFixed(1)," avgDuration:")).call(G,k.toFixed(1)," maxFetchDuration:")).call(F,u.toFixed(1)," fetchDuration:")).call(O,_.toFixed(1)," firstSelection:")).call(M,S," codecSet:")).call(x,t.codecSet," videoRange:")).call(P,t.videoRange," hls.loadLevel:")).call(C,m))}return S&&(l.firstSelection=K),{v:K}}},K=r;K>=t;K--){var H,V,j=G();if("continue"!==j&&"object"===Cc(j))return j.v}return-1}}]),i}(IO),pF=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 mF(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===yF(r,i,a)||function(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i,n=kC(i=t.tagList).call(i,(function(e,t){return"INF"===t[0]&&(e+=bS(t[1])),e}),r);return e.start<=n}return!1}(a,e,Math.min(n,i))))return a;var o=pF(t,sT(yF).call(yF,null,r,i));return!o||o===e&&a?a:o}function yF(){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 EF(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function kF(e,t){return pF(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function TF(e){switch(e.details){case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_TIMEOUT:case dO.LEVEL_LOAD_TIMEOUT:case dO.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function SF(e,t){var r=TF(t);return e.default["".concat(r?"timeout":"error","Retry")]}function AF(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function LF(e){return RO(RO({},e),{errorRetry:null,timeoutRetry:null})}function bF(e,t,r,i){if(!e)return!1;var n=null==i?void 0:i.code,a=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(n)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,a):a}var RF=0,IF=2,DF=3,_F=5,wF=0,CF=1,PF=2,xF=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"error-controller",e.logger)).hls=void 0,n.playlistError=0,n.penalizedRenditions={},n.hls=e,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.ERROR,this.onError,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.ERROR,this.onError,this),e.off(fO.ERROR,this.onErrorOut,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.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)===yO?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 dO.FRAG_LOAD_ERROR:case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_ERROR:case dO.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case dO.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=MF());case dO.FRAG_GAP:case dO.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=IF);case dO.LEVEL_EMPTY_ERROR:case dO.LEVEL_PARSING_ERROR:var a,s,o=t.parent===yO?t.level:i.loadLevel;return void(t.details===dO.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 dO.LEVEL_LOAD_ERROR:case dO.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case dO.AUDIO_TRACK_LOAD_ERROR:case dO.AUDIO_TRACK_LOAD_TIMEOUT:case dO.SUBTITLE_LOAD_ERROR:case dO.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var l=i.levels[i.loadLevel];if(l&&(n.type===pO&&l.hasAudioGroup(n.groupId)||n.type===mO&&l.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=IF,void(t.errorAction.flags=CF)}return;case dO.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:IF,flags:PF,hdcpLevel:c}:this.keySystemError(t));case dO.BUFFER_ADD_CODEC_ERROR:case dO.REMUX_ALLOC_ERROR:case dO.BUFFER_APPEND_ERROR:var h;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(h=t.level)?h:i.loadLevel);return;case dO.INTERNAL_EXCEPTION:case dO.BUFFER_APPENDING_ERROR:case dO.BUFFER_FULL_ERROR:case dO.LEVEL_SWITCH_ERROR:case dO.BUFFER_STALLED_ERROR:case dO.BUFFER_SEEK_OVER_HOLE:case dO.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=MF())}t.type===hO.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=SF(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(bF(r,i,TF(e),e.response))return{action:_F,flags:wF,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=SF(UI(t=e.details).call(t,"key")?l:o,e),c=kC(r=i.levels).call(r,(function(e,t){return e+t.fragmentError}),0);if(a&&(e.details!==dO.FRAG_GAP&&a.fragmentError++,bF(u,c,TF(e),e.response)))return{action:_F,flags:wF,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===dO.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===EO&&s===dO.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===dO.BUFFER_ADD_CODEC_ERROR||s===dO.BUFFER_APPEND_ERROR))&&KT(l).call(l,(function(e){var t=e.audioCodec;return i.audioCodec!==t})),v="video"===e.sourceBufferName&&(s===dO.BUFFER_ADD_CODEC_ERROR||s===dO.BUFFER_APPEND_ERROR)&&KT(l).call(l,(function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(a=e.context)?a:{},p=g.type,m=g.groupId,y=function(){var t=(E+u)%l.length;if(t!==u&&t>=c&&t<=h&&0===l[t].loadError){var r=l[t];if(s===dO.FRAG_GAP&&d===yO&&e.frag){var n=l[t].details;if(n){var a=mF(e.frag,n.fragments,e.frag.start);if(null!=a&&a.gap)return"continue"}}else{if(p===pO&&r.hasAudioGroup(m)||p===mO&&r.hasSubtitleGroup(m))return"continue";if(d===EO&&null!=(k=i.audioGroups)&&KT(k).call(k,(function(e){return r.hasAudioGroup(e)}))||d===kO&&null!=(T=i.subtitleGroups)&&KT(T).call(T,(function(e){return r.hasSubtitleGroup(e)}))||f&&i.audioCodec===r.audioCodec||!f&&i.audioCodec!==r.audioCodec||v&&i.codecSet===r.codecSet)return"continue"}return o=t,"break"}},E=l.length;E--;){var k,T,S=y();if("continue"!==S&&"break"===S)break}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:IF,flags:wF,nextAutoLevel:o}}return{action:IF,flags:CF}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case RF:break;case IF:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===dO.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=wC(r),n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case wF:this.switchLevel(e,a);break;case PF:n&&(t.maxHdcpLevel=$O[av($O).call($O,n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'))}r.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){var r;void 0!==t&&e.errorAction&&(this.warn(_d(r="switching to level ".concat(t," after ")).call(r,e.details)),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}]),i}(IO);function MF(e){var t={action:RF,flags:wF};return e&&(t.resolved=!0),t}var OF="NOT_LOADED",FF="APPENDING",NF="PARTIAL",UF="OK",BF=function(){function e(r){t(this,e),this.activePartLists=aT(null),this.endListFragments=aT(null),this.fragments=aT(null),this.timeRanges=aT(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=r,this._registerListeners()}return Fc(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fO.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fO.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=yv(i),a=n.length;a--;){var s=i[n[a]];if((null==s?void 0:s.body.type)===t&&(!r||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null}},{key:"detectEvictedFragments",value:function(e,t,r,i,n){var a,s=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(null==i?void 0:i.fragment.sn)||-1;vd(a=yv(this.fragments)).call(a,(function(i){var a,l=s.fragments[i];if(l&&!(o>=l.body.sn))if(l.buffered||l.loaded&&!n){var u=l.range[e];u&&(0!==u.time.length?KT(a=u.time).call(a,(function(e){var r=!s.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&s.removeFragment(l.body),r})):s.removeFragment(l.body))}else l.body.type===r&&s.removeFragment(l.body)}))}},{key:"detectPartialFragments",value:function(e){var t,r=this,i=this.timeRanges;if(i&&"initSegment"!==e.frag.sn){var n=e.frag,a=KF(n),s=this.fragments[a];if(!(!s||s.buffered&&n.gap)){var o=!n.relurl;if(vd(t=yv(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,yv(s.range).length)s.buffered=!0,(s.body.endList=n.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),GF(s)||this.removeParts(n.sn-1,n.type);else this.removeFragment(s.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=xk(r).call(r,(function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=KF(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:aT(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}},{key:"getBufferedTimes",value:function(e,t,r,i){for(var n={time:[],partial:r},a=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<i.length;u++){var c=i.start(u)-this.bufferPadding,h=i.end(u)+this.bufferPadding;if(l>=c&&o<=h){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(a<h&&s>c){var d=Math.max(a,i.start(u)),f=Math.min(s,i.end(u));f>d&&(n.partial=!0,n.time.push({startPTS:d,endPTS:f}))}else if(s<=c)break}return n}},{key:"getPartialFragment",value:function(e){var t,r,i,n,a=null,s=0,o=this.bufferPadding,l=this.fragments;return vd(t=yv(l)).call(t,(function(t){var u=l[t];u&&GF(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||GF(t))}},{key:"getState",value:function(e){var t=KF(e),r=this.fragments[t];return r?r.buffered?GF(r)?NF:UF:FF:OF}},{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=KF(r);this.fragments[n]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:aT(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=KF(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=yv(t);if(!e)return r.length>0;for(var i=r.length;i--;){var n=t[r[i]];if((null==n?void 0:n.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,r,i,n){var a,s=this;i&&!this.hasGaps||vd(a=yv(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=KF(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=xk(r).call(r,(function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e,t;this.fragments=aT(null),this.endListFragments=aT(null),this.activePartLists=aT(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&vd(r).call(r,(function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function GF(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 KF(e){var t,r;return _d(t=_d(r="".concat(e.type,"_")).call(r,e.level,"_")).call(t,e.sn)}var HF=0,VF=1,jF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=r,this.aesIV=i,this.aesMode=n}return Fc(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case HF:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case VF: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 YF(e,t,r){return Bv(Uint8Array.prototype)?Bv(e).call(e,t,r):new Uint8Array(Bv(Array.prototype).call(e,t,r))}var qF=function(){function e(){t(this,e),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}return Fc(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],h=o[3],d=new Uint32Array(256),f=0,v=0,g=0;for(g=0;g<256;g++)d[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=v^v<<1^v<<2^v<<3^v<<4;p=p>>>8^255&p^99,e[f]=p,t[p]=f;var m=d[f],y=d[m],E=d[y],k=257*d[p]^16843008*p;i[f]=k<<24|k>>>8,n[f]=k<<16|k>>>16,a[f]=k<<8|k>>>24,s[f]=k,k=16843009*E^65537*y^257*m^16843008*f,l[p]=k<<24|k>>>8,u[p]=k<<16|k>>>16,c[p]=k<<8|k>>>24,h[p]=k,f?(f=m^d[d[d[E^m]]],v^=d[d[v]]):f=v=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,l,u=this.ksRows=4*(n+6+1),c=this.keySchedule=new Uint32Array(u),h=this.invKeySchedule=new Uint32Array(u),d=this.sBox,f=this.rcon,v=this.invSubMix,g=v[0],p=v[1],m=v[2],y=v[3];for(a=0;a<u;a++)a<n?o=c[a]=t[a]:(l=o,a%n==0?(l=d[(l=l<<8|l>>>24)>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l],l^=f[a/n|0]<<24):n>6&&a%n==4&&(l=d[l>>>24]<<24|d[l>>>16&255]<<16|d[l>>>8&255]<<8|d[255&l]),c[a]=o=(c[a-n]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],h[s]=s<4||a<=4?l:g[d[l>>>24]]^p[d[l>>>16&255]]^m[d[l>>>8&255]]^y[d[255&l]],h[s]=h[s]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var i,n,a,s,o,l,u,c,h,d,f,v,g,p,m=this.keySize+6,y=this.invKeySchedule,E=this.invSBox,k=this.invSubMix,T=k[0],S=k[1],A=k[2],L=k[3],b=this.uint8ArrayToUint32Array_(r),R=b[0],I=b[1],D=b[2],_=b[3],w=new Int32Array(e),C=new Int32Array(w.length),P=this.networkToHostOrderSwap;t<w.length;){for(h=P(w[t]),d=P(w[t+1]),f=P(w[t+2]),v=P(w[t+3]),o=h^y[0],l=v^y[1],u=f^y[2],c=d^y[3],g=4,p=1;p<m;p++)i=T[o>>>24]^S[l>>16&255]^A[u>>8&255]^L[255&c]^y[g],n=T[l>>>24]^S[u>>16&255]^A[c>>8&255]^L[255&o]^y[g+1],a=T[u>>>24]^S[c>>16&255]^A[o>>8&255]^L[255&l]^y[g+2],s=T[c>>>24]^S[o>>16&255]^A[l>>8&255]^L[255&u]^y[g+3],o=i,l=n,u=a,c=s,g+=4;i=E[o>>>24]<<24^E[l>>16&255]<<16^E[u>>8&255]<<8^E[255&c]^y[g],n=E[l>>>24]<<24^E[u>>16&255]<<16^E[c>>8&255]<<8^E[255&o]^y[g+1],a=E[u>>>24]<<24^E[c>>16&255]<<16^E[o>>8&255]<<8^E[255&l]^y[g+2],s=E[c>>>24]<<24^E[o>>16&255]<<16^E[l>>8&255]<<8^E[255&u]^y[g+3],C[t]=P(i^R),C[t+1]=P(s^I),C[t+2]=P(a^D),C[t+3]=P(n^_),R=h,I=d,D=f,_=v,t+=4}return C.buffer}}]),e}(),WF=function(){function e(r,i,n){t(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=r,this.key=i,this.aesMode=n}return Fc(e,[{key:"expandKey",value:function(){var e=function(e){switch(e){case HF:return"AES-CBC";case VF: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 zF(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("undefined"!=typeof TextDecoder){var r=new TextDecoder("utf-8").decode(e);if(t){var i=av(r).call(r,"\0");return-1!==i?r.substring(0,i):r}return r.replace(/\0/g,"")}for(var n,a,s,o=e.length,l="",u=0;u<o;){if(0===(n=e[u++])&&t)return l;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:a=e[u++],l+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[u++],s=e[u++],l+=String.fromCharCode((15&n)<<12|(63&a)<<6|(63&s)<<0)}}return l}var XF={hexDump:function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t}};function QF(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $F,JF,ZF,eN,tN,rN={exports:{}};$F=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,JF=/^(?=([^\/?#]*))\1([^]*)$/,ZF=/(?:\/|^)\.(?=\/)/g,eN=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,rN.exports=tN={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=MS(e).call(e),!(t=MS(t).call(t))){if(!r.alwaysNormalize)return e;var i=tN.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=tN.normalizePath(i.path),tN.buildURLFromParts(i)}var n=tN.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=tN.normalizePath(n.path),tN.buildURLFromParts(n)):t;var a=tN.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var s=JF.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,YC(l).call(l,"/")+1)+n.path;o.path=tN.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?tN.normalizePath(n.path):n.path),tN.buildURLFromParts(o)},parseURL:function(e){var t=$F.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){var t,r;for(e=eP(t=e.split("")).call(t).join("").replace(ZF,"");e.length!==(e=e.replace(eN,"")).length;);return eP(r=e.split("")).call(r).join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};var iN=rN.exports,nN=Fc((function e(){t(this,e),this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}})),aN="audio",sN="video",oN="audiovideo",lN=function(){function e(r){t(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof r&&(r={url:r}),this.base=r}return Fc(e,[{key:"setByteRange",value:function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:Rk(i[1]),this._byteRange=[r,Rk(i[0])+r]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){var e;null===this._streams&&(this._streams=(Lf(e={},aN,null),Lf(e,sN,null),Lf(e,oN,null),e));return this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new nN),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=iN.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[aN]=null,e[sN]=null,e[oN]=null}}]),e}();function uN(e){return"initSegment"!==e.sn}var cN=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n))._decryptdata=null,a._programDateTime=null,a._ref=null,a._bitrate=void 0,a.rawProgramDateTime=null,a.tagList=[],a.duration=0,a.sn=0,a.levelkeys=void 0,a.type=void 0,a.loader=null,a.keyLoader=null,a.level=-1,a.cc=0,a.startPTS=void 0,a.endPTS=void 0,a.startDTS=void 0,a.endDTS=void 0,a.start=0,a.playlistOffset=0,a.deltaPTS=void 0,a.maxStartPTS=void 0,a.minEndPTS=void 0,a.data=void 0,a.bitrateTest=!1,a.title=null,a.initSegment=null,a.endList=void 0,a.gap=void 0,a.urlId=0,a.type=e,a}return Fc(i,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var t=this.byteRange[0],r=this.byteRange[1];if(lO(t)&&lO(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=yv(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=lO(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=yv(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){lO(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return uN(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,r,i,n){var a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}}}]),i}(lN),hN=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s,o){var l;t(this,i),(l=r.call(this,a)).fragOffset=0,l.duration=0,l.gap=!1,l.independent=!1,l.relurl=void 0,l.fragment=void 0,l.index=void 0,l.duration=e.decimalFloatingPoint("DURATION"),l.gap=e.bool("GAP"),l.independent=e.bool("INDEPENDENT"),l.relurl=e.enumeratedString("URI"),l.fragment=n,l.index=s;var u=e.enumeratedString("BYTERANGE");return u&&l.setByteRange(u,o),o&&(l.fragOffset=o.fragOffset+o.duration),l}return Fc(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),i}(lN),dN=Math.pow(2,32)-1,fN=[].push,vN={video:1,audio:2,id3:3,text:4};function gN(e){return String.fromCharCode.apply(null,e)}function pN(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function mN(e,t){var r=EN(e,t);return r<0?4294967296+r:r}function yN(e,t){var r=mN(e,t);return r*=Math.pow(2,32),r+=mN(e,t+4)}function EN(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function kN(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 TN(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=mN(e,n),s=a>1?n+a:i;if(gN(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var o=TN(e.subarray(n+8,s),Bv(t).call(t,1));o.length&&fN.apply(r,o)}n=s}return r}function SN(e){var t=[],r=e[0],i=8,n=mN(e,i);i+=4;var a=0,s=0;0===r?(a=mN(e,i),s=mN(e,i+4),i+=8):(a=yN(e,i),s=yN(e,i+8),i+=16),i+=2;var o=e.length+s,l=pN(e,i);i+=2;for(var u=0;u<l;u++){var c=i,h=mN(e,c);c+=4;var d=2147483647&h;if(1===(2147483648&h)>>>31)return xO.warn("SIDX has hierarchical references (not supported)"),null;var f=mN(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 AN(e){for(var t=[],r=TN(e,["moov","trak"]),i=0;i<r.length;i++){var n=r[i],a=TN(n,["tkhd"])[0];if(a){var s=a[0],o=mN(a,0===s?12:20),l=TN(n,["mdia","mdhd"])[0];if(l){var u=mN(l,0===(s=l[0])?12:20),c=TN(n,["mdia","hdlr"])[0];if(c){var h=gN(c.subarray(8,12)),d={soun:aN,vide:sN}[h];if(d){var f=LN(TN(n,["mdia","minf","stbl","stsd"])[0]);t[o]={timescale:u,type:d},t[d]=RO({timescale:u,id:o},f)}}}}}var v=TN(e,["moov","mvex","trex"]);return vd(v).call(v,(function(e){var r=mN(e,4),i=t[r];i&&(i.default={duration:mN(e,12),flags:mN(e,20)})})),t}function LN(e){var t=e.subarray(8),r=t.subarray(86),i=gN(t.subarray(4,8)),n=i,a="enca"===i||"encv"===i;if(a){var s=TN(t,[i])[0],o=TN(s.subarray("enca"===i?28:78),["sinf"]);vd(o).call(o,(function(e){var t=TN(e,["schm"])[0];if(t){var r=gN(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=TN(e,["frma"])[0];i&&(n=gN(i))}}}))}switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var l=TN(r,["avcC"])[0];n+="."+RN(l[1])+RN(l[2])+RN(l[3]);break;case"mp4a":var u=TN(t,[i])[0],c=TN(u.subarray(28),["esds"])[0];if(c&&c.length>7){var h=4;if(3!==c[h++])break;h=bN(c,h),h+=2;var d=c[h++];if(128&d&&(h+=2),64&d&&(h+=c[h++]),4!==c[h++])break;h=bN(c,h);var f=c[h++];if(64!==f)break;if(n+="."+RN(f),h+=12,5!==c[h++])break;h=bN(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=TN(r,["hvcC"])[0],m=p[1],y=["","A","B","C"][m>>6],E=31&m,k=mN(p,2),T=(32&m)>>5?"H":"L",S=p[12],A=p.subarray(6,12);n+="."+y+E,n+="."+k.toString(16).toUpperCase(),n+="."+T+S;for(var L="",b=A.length;b--;){var R=A[b];if(R||L)L="."+R.toString(16).toUpperCase()+L}n+=L;break;case"dvh1":case"dvhe":var I=TN(r,["dvcC"])[0],D=I[2]>>1&127,_=I[2]<<5&32|I[3]>>3&31;n+="."+IN(D)+"."+IN(_);break;case"vp09":var w=TN(r,["vpcC"])[0],C=w[4],P=w[5],x=w[6]>>4&15;n+="."+IN(C)+"."+IN(P)+"."+IN(x);break;case"av01":var M=TN(r,["av1C"])[0],O=M[1]>>>5,F=31&M[1],N=M[2]>>>7?"H":"M",U=(64&M[2])>>6,B=(32&M[2])>>5,G=2===O&&U?B?12:10:U?10:8,K=(16&M[2])>>4,H=(8&M[2])>>3,V=(4&M[2])>>2,j=3&M[2];n+="."+O+"."+IN(F)+N+"."+IN(G)+"."+K+"."+H+V+j+"."+IN(1)+"."+IN(1)+"."+IN(1)+".0"}return{codec:n,encrypted:a}}function bN(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function RN(e){var t;return Bv(t="0"+e.toString(16).toUpperCase()).call(t,-2)}function IN(e){return(e<10?"0":"")+e}function DN(e){var t=TN(e,["schm"])[0];if(t){var r=gN(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return TN(e,["schi","tenc"])[0]}return null}function _N(e){var t=mN(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=mN(e,4),a=0;a<n;a++){if(256&t)i+=mN(e,r),r+=4;512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return i}function wN(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function CN(e,t){var r=[],i=t.samples,n=t.timescale,a=t.id,s=!1,o=TN(i,["moof"]);return Pk(o).call(o,(function(o){var l=o.byteOffset-8,u=TN(o,["traf"]);Pk(u).call(u,(function(o){var u,c,h=Pk(u=TN(o,["tfdt"])).call(u,(function(e){var t=e[0],r=mN(e,4);return 1===t&&(r*=Math.pow(2,32),r+=mN(e,8)),r/n}))[0];return void 0!==h&&(e=h),Pk(c=TN(o,["tfhd"])).call(c,(function(u){var c,h=mN(u,4),d=16777215&mN(u,0),f=0,v=0!=(16&d),g=0,p=0!=(32&d),m=8;h===a&&(0!=(1&d)&&(m+=8),0!=(2&d)&&(m+=4),0!=(8&d)&&(f=mN(u,m),m+=4),v&&(g=mN(u,m),m+=4),p&&(m+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=av(e).call(e,"."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),Pk(c=TN(o,["trun"])).call(c,(function(a){var o=a[0],u=16777215&mN(a,0),c=0!=(1&u),h=0,d=0!=(4&u),v=0!=(256&u),p=0,m=0!=(512&u),y=0,E=0!=(1024&u),k=0!=(2048&u),T=0,S=mN(a,4),A=8;c&&(h=mN(a,A),A+=4),d&&(A+=4);for(var L=h+l,b=0;b<S;b++){if(v?(p=mN(a,A),A+=4):p=f,m?(y=mN(a,A),A+=4):y=g,E&&(A+=4),k&&(T=0===o?mN(a,A):EN(a,A),A+=4),t.type===sN)for(var R=0;R<y;){var I=mN(i,L);if(PN(s,i[L+=4]))xN(i.subarray(L,L+I),s?2:1,e+T/n,r);L+=I,R+=I+4}e+=p/n}})))}))}))})),r}function PN(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function xN(e,t,r,i){var n=MN(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;xO.error(_d(h="Malformed SEI payload. ".concat(o," is too small, only ")).call(h,u," bytes left to parse."));break}if(4===s){if(181===n[c++]){var d=pN(n,c);if(c+=2,49===d){var f=mN(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:zF(L),userDataBytes:L})}}}function MN(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 ON(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 FN(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=XF.hexDump(new Uint8Array(a,r+12,16)),o=e.getUint32(28),l=null,u=null;if(0===n){if(t-32<o||o<22)return{offset:r,size:t};u=new Uint8Array(a,r+32,o)}else if(1===n){if(!o||i<r+32+16*o+16)return{offset:r,size:t};l=[];for(var c=0;c<o;c++)l.push(new Uint8Array(a,r+32+16*c,16))}return{version:n,systemId:s,kids:l,data:u,offset:r,size:t}}var NN=function(){function e(r){var i=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).removePKCS7Padding,n=void 0===i||i;if(t(this,e),this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=r.enableSoftwareAES,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(s){}this.useSoftware=!this.subtle}return Fc(e,[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,n,a=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=a).byteLength,(n=i&&new DataView(r.buffer).getUint8(i-1))?YF(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 nk((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!==HF||16!==t.byteLength)return xO.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=wN(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 qF),l.expandKey(t);var u=a;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=YF(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 nk.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new WF(this.subtle,t,i)}return this.fastAesKey.expandKey().then((function(t){return n.subtle?(n.logOnce("WebCrypto AES decrypt"),new jF(n.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):nk.reject(new Error("web crypto not initialized"))})).catch((function(a){var s;return xO.warn(_d(s="[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(a.name,": ")).call(s,a.message)),n.onWebCryptoError(e,t,r,i)}))}},{key:"onWebCryptoError",value:function(e,t,r,i){var n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var a=this.flush();if(a)return a.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=YF(e,0,r),this.remainderData=YF(e,r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(xO.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),UN=Math.pow(2,17),BN=function(){function e(r){t(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=r}return Fc(e,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var r=this,i=e.url;if(!i)return nk.reject(new HN({type:hO.NETWORK_ERROR,details:dO.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,s=n.loader;return new nk((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){var u;if(KT(u=e.tagList).call(u,(function(e){return"GAP"===e[0]})))return void l(KN(e));e.gap=!1}var c=r.loader=a?new a(n):new s(n),h=GN(e);e.loader=c;var d=LF(n.fragLoadPolicy.default),f={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:UN};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(Bv(s).call(s,0,16)),s=Bv(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 HN({type:hO.NETWORK_ERROR,details:dO.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:RO({url:i,data:void 0},t),error:new Error(_d(o="HTTP Error ".concat(t.code," ")).call(o,t.text)),networkDetails:a,stats:s}))},onAbort:function(t,i,n){r.resetLoader(e,c),l(new HN({type:hO.NETWORK_ERROR,details:dO.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 HN({type:hO.NETWORK_ERROR,details:dO.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 nk((function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(KN(e,t));else{var u=i.loader=a?new a(n):new s(n),c=GN(e,t);e.loader=u;var h=LF(n.fragLoadPolicy.default),d={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:UN};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 HN({type:hO.NETWORK_ERROR,details:dO.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:RO({url:c.url,data:void 0},r),error:new Error(_d(o="HTTP Error ".concat(r.code," ")).call(o,r.text)),networkDetails:a,stats:s}))},onAbort:function(r,n,a){e.stats.aborted=t.stats.aborted,i.resetLoader(e,u),l(new HN({type:hO.NETWORK_ERROR,details:dO.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 HN({type:hO.NETWORK_ERROR,details:dO.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 GN(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(lO(a)&&lO(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 KN(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),i={type:hO.MEDIA_ERROR,details:dO.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new HN(i)}var HN=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e.error.message)).data=void 0,n.data=e,n}return Fc(i)}(tC(Error)),VN=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(s=r.call(this,e,n))._boundTick=void 0,s._tickTimer=null,s._tickInterval=null,s._tickCallCount=0,s._boundTick=sT(a=s.tick).call(a,Zh(s)),s}return Fc(i,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=lS(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=Wf(this._boundTick,0)}},{key:"doTick",value:function(){}}]),i}(IO),jN=Fc((function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];t(this,e),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=r,this.sn=i,this.id=n,this.size=a,this.part=s,this.partial=o}));var YN={length:0,start:function(){return 0},end:function(){return 0}},qN=function(){function e(){t(this,e)}return Fc(e,null,[{key:"isBuffered",value:function(t,r){if(t)for(var i=e.getBuffered(t),n=i.length;n--;)if(r>=i.start(n)&&r<=i.end(n))return!0;return!1}},{key:"bufferInfo",value:function(t,r,i){if(t){var n=e.getBuffered(t);if(n.length){for(var a=[],s=0;s<n.length;s++)a.push({start:n.start(s),end:n.end(s)});return e.bufferedInfo(a,r,i)}}return{len:0,start:r,end:r,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){t=Math.max(0,t),mA(e).call(e,(function(e,t){return e.start-t.start||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,c=t,h=0;h<i.length;h++){var d=i[h].start,f=i[h].end;if(t+r>=d&&t<f)u=d,l=(c=f)-t;else if(t+r<d){o=d;break}}return{len:l,start:u||0,end:c||0,nextStart:o}}},{key:"getBuffered",value:function(e){try{return e.buffered||YN}catch(t){return xO.log("failed to get media.buffered",t),YN}}}]),e}(),WN=/\{\$([a-zA-Z0-9-_]+)\}/g;function zN(e){return WN.test(e)}function XN(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(WN,(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 QN(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 gI(r).searchParams;if(!o.has(i))throw new Error(_d(s='"'.concat(i,'" does not match any query parameter in URI: "')).call(s,r,'"'));n=o.get(i)}catch(JV){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(JV.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 $N(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 JN=/^(\d+)x(\d+)$/,ZN=/(.+?)=(".*?"|.*?)(?:,|$)/g,eU=function(){function e(r,i){t(this,e),"string"==typeof r&&(r=e.parseAttrList(r,i)),LO(this,r)}return Fc(e,[{key:"clientAttrs",get:function(){var e;return xk(e=yv(this)).call(e,(function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=Rk(this[e],10);return t>lC?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t,r=Bv(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]=Rk(Bv(r).call(r,2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=Rk(this[e],16);return t>lC?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return bS(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?bS(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r,i=this[e];return kC(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=JN.exec(this[e]);if(null!==t)return{width:Rk(t[1],10),height:Rk(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,i,n={};for(ZN.lastIndex=0;null!==(i=ZN.exec(e));){var a,s=MS(a=i[1]).call(a),o=i[2],l=0===av(o).call(o,'"')&&YC(o).call(o,'"')===o.length-1,u=!1;if(l)o=Bv(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=XN(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":xO.warn(_d(r="".concat(e,": attribute ")).call(r,s," is missing quotes"))}n[s]=o}return n}}]),e}();function tU(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var rU=function(){function e(r,i){var n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(t(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(n=null==i?void 0:i.tagOrder)?n:a,i){var s=i.attr;for(var o in s)if(Object.prototype.hasOwnProperty.call(r,o)&&r[o]!==s[o]){var l;xO.warn(_d(l='DATERANGE tag attribute: "'.concat(o,'" does not match for tags with ID: "')).call(l,r.ID,'"')),this._badValueForSameId=o;break}r=LO(new eU({}),s,r)}if(this.attr=r,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(r["START-DATE"]),"END-DATE"in this.attr){var u=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);lO(u.getTime())&&(this._endDate=u)}}return Fc(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e,t=this.tagAnchor;return null===t||null===t.programDateTime?(xO.warn(_d(e='Expected tagAnchor Fragment with PDT set for DateRange "'.concat(this.id,'": ')).call(e,t)),NaN):t.start+(this.startDate.getTime()-t.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(lO(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&&lO(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}(),iU=function(){function e(r){t(this,e),this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=r}return Fc(e,[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&lO(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(SA()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}]),e}();function nU(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function aU(e){switch(e){case"AES-128":case"AES-256":return HF;case"AES-256-CTR":return VF;default:throw new Error("invalid full segment method ".concat(e))}}function sU(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function oU(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function lU(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?(sg(a).call(a,-1,1),n=sU(l)):(t=oU(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),n=r)}}return n}var uU="undefined"!=typeof self?self:void 0,cU="org.w3.clearkey",hU="com.apple.fps",dU="com.microsoft.playready",fU="com.widevine.alpha",vU="org.w3.clearkey",gU="com.apple.streamingkeydelivery",pU="com.microsoft.playready",mU="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function yU(e){switch(e){case gU:return hU;case pU:return dU;case mU:return fU;case vU:return cU}}var EU="1077efecc0b24d02ace33c1e52e2fb4b",kU="e2719d58a985b3c9781ab030af78d30e",TU="9a04f07998404286ab92e65be0885f95",SU="edef8ba979d64acea3c827dcd51d21ed";function AU(e){return e===SU?fU:e===TU?dU:e===EU||e===kU?cU:void 0}function LU(e){switch(e){case hU:return gU;case dU:return pU;case fU:return mU;case cU:return vU}}function bU(e){var t,r=e.drmSystems,i=e.widevineLicenseUrl,n=r?xk(t=[hU,fU,dU,cU]).call(t,(function(e){return!!r[e]})):[];return!n[fU]&&i&&n.push(fU),n}var RU,IU,DU=null!=uU&&null!=(RU=uU.navigator)&&RU.requestMediaKeySystemAccess?sT(IU=self.navigator.requestMediaKeySystemAccess).call(IU,self.navigator):null;function _U(e,t,r,i){var n;switch(e){case hU:n=["cenc","sinf"];break;case fU:case dU:n=["cenc"];break;case cU:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return function(e,t,r,i){var n={initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:Pk(t).call(t,(function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:Pk(r).call(r,(function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))};return[n]}(n,t,r,i)}function wU(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,LT(t)),i=r.substring(av(r).call(r,"<"),r.length),n=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(n){var a=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(a){var s=sU(a).subarray(0,16);return function(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(s),s}}return null}var CU={},PU=function(){function e(r,i,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;t(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=r,this.uri=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=s,this.encrypted=!!r&&"NONE"!==r,this.isCommonEncryption=this.encrypted&&!nU(r)}return Fc(e,[{key:"isSupported",value:function(){var e;if(this.method){if(nU(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case gU:case mU:case pU:case vU:return-1!==av(e=["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"]).call(e,this.method)}}return!1}},{key:"getDecryptData",value:function(t){if(!this.encrypted||!this.uri)return null;if(nU(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(xO.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=lU(this.uri);if(i)switch(this.keyFormat){case mU:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case pU:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=ON(n,0,i),this.keyId=wU(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=CU[this.uri];if(!o){var l=yv(CU).length%lC;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),CU[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){CU={}}}]),e}();var xU=/#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,MU=/#EXT-X-MEDIA:(.*)/g,OU=/^#EXT(?:INF|-X-TARGETDURATION):/m,FU=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),NU=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("|")),UU=function(){function e(){t(this,e)}return Fc(e,null,[{key:"findGroup",value:function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}}},{key:"resolve",value:function(e,t){return iN.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return OU.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:zN(t)},a=[];for(xU.lastIndex=0;null!=(i=xU.exec(t));)if(i[1]){var s,o=new eU(i[1],n),l=XN(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),VU(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 eU(d,n),v=f["DATA-ID"];v&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[v]=f);break;case"SESSION-KEY":var g=KU(d,r,n);g.encrypted&&g.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(g)):xO.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(d,'"'));break;case"DEFINE":QN(n,new eU(d,n),r);break;case"CONTENT-STEERING":var p=new eU(d,n);n.contentSteering={uri:e.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=HU(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:Pk(s).call(s,(function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:Pk(s).call(s,(function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(MU.lastIndex=0;null!==(n=MU.exec(t));){var u=new eU(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];jU(y,E,"audioCodec"),jU(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 iU(t),h=c.fragments,d=[],f=null,v=0,g=0,p=0,m=0,y=0,E=null,k=new cN(i,u),T=-1,S=!1,A=null;for(FU.lastIndex=0,c.m3u8=e,c.hasVariableRefs=zN(e);null!==(s=FU.exec(e));){S&&(S=!1,(k=new cN(i,u)).playlistOffset=p,k.start=p,k.sn=v,k.cc=m,y&&(k.bitrate=y),k.level=r,f&&(k.initSegment=f,f.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime,f.rawProgramDateTime=null),A&&(k.setByteRange(A),A=null)));var L=s[1];if(L){var b;k.duration=bS(L);var R=Bv(b=" "+s[2]).call(b,1);k.title=R||null,k.tagList.push(R?["INF",L,R]:["INF",L])}else if(s[3]){if(lO(k.duration)){var I;k.playlistOffset=p,k.start=p,l&&WU(k,l,c),k.sn=v,k.level=r,k.cc=m,h.push(k);var D=Bv(I=" "+s[3]).call(I,1);k.relurl=XN(c,D),YU(k,E,d),E=k,p+=k.duration,v++,g=0,S=!0}}else{var _,w,C;if(!(s=s[0].match(NU))){xO.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o<s.length&&void 0===s[o];o++);var P=Bv(_=" "+s[o]).call(_,1),x=Bv(w=" "+s[o+1]).call(w,1),M=s[o+2]?Bv(C=" "+s[o+2]).call(C,1):null;switch(P){case"BYTERANGE":E?k.setByteRange(x,E):k.setByteRange(x);break;case"PROGRAM-DATE-TIME":k.rawProgramDateTime=x,k.tagList.push(["PROGRAM-DATE-TIME",x]),-1===T&&(T=h.length);break;case"PLAYLIST-TYPE":c.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":v=c.startSN=Rk(x);break;case"SKIP":c.skippedSegments&&(c.playlistParsingError=new Error("#EXT-X-SKIP MUST NOT appear more than once in a Playlist"));var O=new eU(x,c),F=O.decimalInteger("SKIPPED-SEGMENTS");if(lO(F)){c.skippedSegments+=F;for(var N=F;N--;)h.push(null);v+=F}var U,B=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(B)c.recentlyRemovedDateranges=_d(U=c.recentlyRemovedDateranges||[]).call(U,B.split("\t"));break;case"TARGETDURATION":c.targetduration=Math.max(Rk(x),1);break;case"VERSION":c.version=Rk(x);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"#":(x||M)&&k.tagList.push(M?[x,M]:[x]);break;case"DISCONTINUITY":m++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([P]);break;case"BITRATE":k.tagList.push([P,x]),y=1e3*Rk(x),lO(y)?k.bitrate=y:y=0;break;case"DATERANGE":var G=new eU(x,c),K=new rU(G,c.dateRanges[G.ID],c.dateRangeTagCount);c.dateRangeTagCount++,K.isValid||c.skippedSegments?c.dateRanges[K.id]=K:xO.warn('Ignoring invalid DATERANGE tag: "'.concat(x,'"')),k.tagList.push(["EXT-X-DATERANGE",x]);break;case"DEFINE":var H=new eU(x,c);"IMPORT"in H?$N(c,H,a):QN(c,H,t);break;case"DISCONTINUITY-SEQUENCE":c.startCC=m=Rk(x);break;case"KEY":var V=KU(x,t,c);if(V.isSupported()){if("NONE"===V.method){l=void 0;break}l||(l={}),l[V.keyFormat]&&(l=LO({},l)),l[V.keyFormat]=V}else xO.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(x,'"'));break;case"START":c.startTimeOffset=HU(x);break;case"MAP":var j=new eU(x,c);if(k.duration){var Y=new cN(i,u);qU(Y,j,r,l),f=Y,k.initSegment=f,f.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=f.rawProgramDateTime)}else{var q=k.byteRangeEndOffset;if(q){var W,z=k.byteRangeStartOffset;A=_d(W="".concat(q-z,"@")).call(W,z)}else A=null;qU(k,j,r,l),f=k,S=!0}f.cc=m;break;case"SERVER-CONTROL":var X=new eU(x);c.canBlockReload=X.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=X.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&X.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),c.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Q=new eU(x);c.partTarget=Q.decimalFloatingPoint("PART-TARGET");break;case"PART":var $=c.partList;$||($=c.partList=[]);var J=g>0?$[$.length-1]:void 0,Z=g++,ee=new eU(x,c),te=new hN(ee,k,u,Z,J);$.push(te),k.duration+=te.duration;break;case"PRELOAD-HINT":var re=new eU(x,c);c.preloadHint=re;break;case"RENDITION-REPORT":var ie=new eU(x,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(ie);break;default:xO.warn("line parsed but not handled: ".concat(s))}}}E&&!E.relurl?(h.pop(),p-=E.duration,c.partList&&(c.fragmentHint=E)):c.partList&&(YU(k,E,d),k.cc=m,c.fragmentHint=k,l&&WU(k,l,c));var ne=h.length,ae=h[0],se=h[ne-1];if((p+=c.skippedSegments*c.targetduration)>0&&ne&&se){c.averagetargetduration=p/ne;var oe=se.sn;c.endSN="initSegment"!==oe?oe:0,c.live||(se.endList=!0),ae&&!c.startCC&&(c.startCC=ae.cc),T>0&&(!function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(h,T),ae&&d.unshift(ae))}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(p+=c.fragmentHint.duration),c.totalduration=p,d.length&&c.dateRangeTagCount&&ae&&BU(d,c),c.endCC=m,c}}]),e}();function BU(e,t){for(var r=e.length,i=e[r-1],n=t.live?1/0:t.totalduration,a=yv(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=GU(t,l,e,u,n);if(-1!==c){o.tagAnchor=t.fragments[c].ref;break}}}}function GU(e,t,r,i,n){var a=r[i];if(a){var s,o=a.programDateTime;if(t>=o||0===i)if(t<=o+1e3*(((null==(s=r[i+1])?void 0:s.start)||n)-a.start)){var l=r[i].sn-e.startSN,u=e.fragments;if(u.length>r.length)for(var c=(r[i+1]||u[u.length-1]).sn-e.startSN;c>l;c--){var h=u[c].programDateTime;if(t>=h&&t<h+1e3*u[c].duration)return c}return l}}return-1}function KU(e,t,r){var i,n,a,s,o=new eU(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&&xO.error("Invalid IV: ".concat(o.IV));var f=u?UU.resolve(u,t):"",v=xk(i=Pk(n=(h||"1").split("/")).call(n,Number)).call(i,iC);return new PU(l,f,d,v,c)}function HU(e){var t=new eU(e).decimalFloatingPoint("TIME-OFFSET");return lO(t)?t:null}function VU(e,t){var r,i,n=xk(r=(e||"").split(/[ ,]+/)).call(r,(function(e){return e}));vd(i=["video","audio","text"]).call(i,(function(e){var r=xk(n).call(n,(function(t){return function(e,t){var r=FO[t];return!!r&&!!r[Bv(e).call(e,0,4)]}(t,e)}));r.length&&(t["".concat(e,"Codec")]=r.join(","),n=xk(n).call(n,(function(e){return-1===av(r).call(r,e)})))})),t.unknownCodecs=n}function jU(e,t,r){var i=t[r];i&&(e[r]=i)}function YU(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function qU(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 WU(e,t,r){var i;e.levelkeys=t;var n=r.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!KT(i=yv(t)).call(i,(function(e){return t[e].isCommonEncryption}))||n.push(e)}function zU(e,t){var r=t.startPTS;if(lO(r)){var i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&i.setDuration(n)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function XU(e,t,r,i,n,a){i-r<=0&&(xO.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(lO(l)){var c=Math.abs(l-r);lO(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--)zU(g[d],g[d-1]);for(d=v;d<g.length-1;d++)zU(g[d],g[d+1]);return e.fragmentHint&&zU(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,h}function QU(e,t){for(var r,i=null,n=e.fragments,a=n.length-1;a>=0;a--){var s=n[a].initSegment;if(s){i=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var o,l=0;!function(e,t,r){for(var i,n,a=t.skippedSegments,s=Math.max(e.startSN,t.startSN)-t.startSN,o=(e.fragmentHint?1:0)+(a?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,l=t.startSN-e.startSN,u=t.fragmentHint?_d(i=t.fragments).call(i,t.fragmentHint):t.fragments,c=e.fragmentHint?_d(n=e.fragments).call(n,e.fragmentHint):e.fragments,h=s;h<=o;h++){var d=c[l+h],f=u[h];a&&!f&&d&&(f=t.fragments[h]=d),d&&f&&r(d,f)}}(e,t,(function(e,r){e.relurl&&(l=e.cc-r.cc),lO(e.startPTS)&&lO(e.endPTS)&&(r.setStart(r.startPTS=e.startPTS),r.startDTS=e.startDTS,r.maxStartPTS=e.maxStartPTS,r.endPTS=e.endPTS,r.endDTS=e.endDTS,r.minEndPTS=e.minEndPTS,r.setDuration(e.endPTS-e.startPTS),r.duration&&(o=r),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(r.elementaryStreams=e.elementaryStreams),r.loader=e.loader,e.hasStats&&(r.stats=e.stats),e.initSegment&&(r.initSegment=e.initSegment,i=e.initSegment)}));var u,c=t.fragmentHint?_d(r=t.fragments).call(r,t.fragmentHint):t.fragments;if(i&&vd(c).call(c,(function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)})),t.skippedSegments)if(t.deltaUpdateFailed=KT(u=t.fragments).call(u,(function(e){return!e})),t.deltaUpdateFailed){xO.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=t.skippedSegments;h--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC||(t.startCC=t.fragments[0].cc)}else{var d;t.canSkipDateRanges&&(t.dateRanges=function(e,t){var r=t.dateRanges,i=t.recentlyRemovedDateranges,n=LO({},e);i&&vd(i).call(i,(function(e){delete n[e]}));var a,s=yv(n).length;s&&vd(a=yv(r)).call(a,(function(e){var t=n[e],i=new rU(r[e].attr,t);i.isValid?(n[e]=i,t||(i.tagOrder+=s)):xO.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(jI(r[e].attr),'"'))}));return n}(e.dateRanges,t));var f=xk(d=e.fragments).call(d,(function(e){return e.rawProgramDateTime}));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var v=1;v<c.length;v++)null===c[v].programDateTime&&YU(c[v],c[v-1],f);BU(f,t)}var g=t.fragments;if(l){xO.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<g.length;p++)g[p].cc+=l}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),o?XU(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):$U(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 $U(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}JU(t,s)}function JU(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 ZU(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){var i=e.fragments;if(i.length&&4*r>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function eB(e,t,r){return e?tB(e.partList,t,r):null}function tB(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 rB(e){vd(e).call(e,(function(e,t){var r,i=null==(r=e.details)?void 0:r.fragments;i&&vd(i).call(i,(function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function iB(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 nB(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function aB(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)nB(r[i],e);t.fragmentHint&&nB(t.fragmentHint,e),t.alignedSliding=!0}function sB(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var r=Math.min(t.endCC,e.endCC),i=iB(t.fragments,r),n=iB(e.fragments,r);if(i&&n)xO.log("Aligning playlist at start of dicontinuity sequence ".concat(r)),aB(i.start-n.start,e)}}function oB(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=iB(i,s),a=iB(r,s)),n&&a||(a=iB(r,(n=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=n.programDateTime,l=a.programDateTime;if(o&&l)aB((l-o)/1e3-(a.start-n.start),e)}}}var lB=function(e){for(var t="",r=e.length,i=0;i<r;i++){var n;t+=_d(n="[".concat(e.start(i).toFixed(3),"-")).call(n,e.end(i).toFixed(3),"]")}return t},uB="STOPPED",cB="IDLE",hB="KEY_LOADING",dB="FRAG_LOADING",fB="FRAG_LOADING_WAITING_RETRY",vB="WAITING_TRACK",gB="PARSING",pB="PARSED",mB="ENDED",yB="ERROR",EB="WAITING_INIT_PTS",kB="WAITING_LEVEL",TB=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s,o){var l;return t(this,i),(l=r.call(this,s,e.logger)).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=uB,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var e,t=Zh(l),r=t.config,i=t.fragCurrent,n=t.media,a=t.mediaBuffer,s=t.state,o=n?n.currentTime:0,u=qN.bufferInfo(a||n,o,r.maxBufferHole);if(l.log(_d(e="media seeking to ".concat(lO(o)?o.toFixed(3):o,", state: ")).call(e,s)),l.state===mB)l.resetLoadingState();else if(i){var c=r.maxFragLookUpTolerance,h=i.start-c,d=i.start+i.duration+c;if(!u.len||d<u.start||h>u.end){var f=o>d;(o<h||f)&&(f&&i.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(n&&(l.fragmentTracker.removeFragmentsInRange(o,1/0,l.playlistType,!0),o>l.lastCurrentTime&&(l.lastCurrentTime=o),!l.loadingParts)){var v,g=Math.max(u.end,o),p=l.shouldLoadParts(l.getLevelDetails(),g);if(p)l.log(_d(v="LL-Part loading ON after seeking to ".concat(o.toFixed(2)," with buffer @")).call(v,g.toFixed(2))),l.loadingParts=p}l.hls.hasEnoughToStart||u.len||(l.log("setting startPosition to ".concat(o," because of seek before start")),l.nextLoadPosition=l.startPosition=o),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0,l.triggerEnded()},l.playlistType=o,l.hls=e,l.fragmentLoader=new BN(e.config),l.keyLoader=a,l.fragmentTracker=n,l.config=e.config,l.decrypter=new NN(e.config),l}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.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!==uB){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=uB}}},{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 qN.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===uB&&this.startLoad(i.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;null!==i&&(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),i.removeEventListener("seeking",this.onMediaSeeking),i.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r?this.resetTransmuxer():(this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()))}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"triggerEnded",value:function(){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=uB,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,Ih(Rh(i.prototype),"onHandlerDestroyed",this).call(this)}},{key:"loadFragment",value:function(e,t,r){var i=this.hls.config;if(i.interstitialsController&&!1!==i.enableInterstitialPlayback&&e.type!==kO){var n=this.hls.interstitialsManager,a=null==n?void 0:n.bufferingItem;if(a){var s=a.event;if(s){if(s.appendInPlace||Math.abs(e.start-a.start)>1||0===a.start)return}else{var o;if(e.end<=a.start&&!1===(null==(o=t.details)?void 0:o.live))return;if(e.start>a.end&&a.nextEvent)return}}}this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}},{key:"_loadFragForPlayback",value:function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(e){var t,r,n,a=e.frag;if(i.fragContextChanged(a))return i.warn(_d(t=_d(r=_d(n="".concat(a.type," sn: ")).call(n,a.sn)).call(r,e.part?" part: "+e.part.index:""," of ")).call(t,i.fragInfo(a,!1,e.part),") was dropped during download.")),void i.fragmentTracker.removeFragment(a);a.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){var t=i.state,r=e.frag;if(i.fragContextChanged(r))(t===dB||!i.fragCurrent&&t===gB)&&(i.fragmentTracker.removeFragment(r),i.state=cB);else{var n,a,s;if("payload"in e)i.log(_d(n=_d(a=_d(s="Loaded ".concat(r.type," sn: ")).call(s,r.sn," of ")).call(a,i.playlistLabel()," ")).call(n,r.level)),i.hls.trigger(fO.FRAG_LOADED,e);i._handleFragmentLoadComplete(e)}}})).catch((function(t){i.state!==uB&&i.state!==yB&&(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)===FF){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)===NF&&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(fO.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&&nU(a.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,aU(a.method)).catch((function(e){throw t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(n){var a=self.performance.now();return t.trigger(fO.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!==uB&&r.state!==yB&&(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!==uB&&(this.state=cB),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(_d(r=_d(i=_d(n=_d(a="Buffered ".concat(e.type," sn: ")).call(a,e.sn)).call(n,t?" part: "+t.index:""," of ")).call(i,this.fragInfo(e,!1,t)," > buffer:")).call(r,s?lB(qN.getBuffered(s)):"(detached)",")")),uN(e)){var o;if(e.type!==kO){var l,u=e.elementaryStreams;if(!KT(l=yv(u)).call(l,(function(e){return!!u[e]})))return void(this.state=cB)}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=cB}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||KT(n).call(n,(function(e){return!e})),s=new jN(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t){var r,i,n,a,s,o,l=this,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,c=arguments.length>3?arguments[3]:void 0;this.fragCurrent=e;var h=null==t?void 0:t.details;if(!this.levels||!h)throw new Error("frag load aborted, missing level".concat(h?"":" detail","s"));var d,f,v,g,p=null;!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&h.encryptedFragments.length&&this.keyLoader.loadClear(e,h.encryptedFragments):(this.log(_d(d=_d(f=_d(v=_d(g="Loading key for ".concat(e.sn," of [")).call(g,h.startSN,"-")).call(v,h.endSN,"], ")).call(f,this.playlistLabel()," ")).call(d,e.level)),this.state=hB,this.fragCurrent=e,p=this.keyLoader.load(e).then((function(e){if(!l.fragContextChanged(e.frag))return l.hls.trigger(fO.KEY_LOADED,e),l.state===hB&&(l.state=cB),e})),this.hls.trigger(fO.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(p=nk.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var m=this.fragPrevious;if(uN(e)&&(!m||e.sn!==m.sn)){var y,E,k=this.shouldLoadParts(t.details,e.end);if(k!==this.loadingParts)this.log(_d(y=_d(E="LL-Part loading ".concat(k?"ON":"OFF"," loading sn ")).call(E,null==m?void 0:m.sn,"->")).call(y,e.sn)),this.loadingParts=k}if(u=Math.max(e.start,u||0),this.loadingParts&&uN(e)){var T=h.partList;if(T&&c){u>e.end&&h.fragmentHint&&(e=h.fragmentHint);var S=this.getNextPart(T,e,u);if(S>-1){var A,L,b,R,I,D,_,w,C,P,x=T[S];return e=this.fragCurrent=x.fragment,this.log(_d(A=_d(L=_d(b=_d(R=_d(I=_d(D=_d(_=_d(w=_d(C="Loading ".concat(e.type," sn: ")).call(C,e.sn," part: ")).call(w,x.index," (")).call(_,S,"/")).call(D,T.length-1,") of ")).call(I,this.fragInfo(e,!1,x),") cc: ")).call(R,e.cc," [")).call(b,h.startSN,"-")).call(L,h.endSN,"], target: ")).call(A,bS(u.toFixed(3)))),this.nextLoadPosition=x.start+x.duration,this.state=dB,P=p?p.then((function(r){return!r||l.fragContextChanged(r.frag)?null:l.doFragPartsLoad(e,x,t,c)})).catch((function(e){return l.handleFragLoadError(e)})):this.doFragPartsLoad(e,x,t,c).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(fO.FRAG_LOADING,{frag:e,part:x,targetBufferTime:u}),null===this.fragCurrent?nk.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):P}if(!e.url||this.loadedEndOfParts(T,u))return nk.resolve(null)}}if(uN(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(u.toFixed(2))),this.loadingParts=!1;else if(!e.url)return nk.resolve(null);this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Loading ".concat(e.type," sn: ")).call(s,e.sn," of ")).call(a,this.fragInfo(e,!1),") cc: ")).call(n,e.cc," ")).call(i,h?"["+h.startSN+"-"+h.endSN+"]":"",", target: ")).call(r,bS(u.toFixed(3)))),lO(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=dB;var M,O=this.config.progressive;return M=O&&p?p.then((function(t){return!t||l.fragContextChanged(null==t?void 0:t.frag)?null:l.fragmentLoader.load(e,c)})).catch((function(e){return l.handleFragLoadError(e)})):nk.all([this.fragmentLoader.load(e,O?c:void 0),p]).then((function(e){var t=fD(e,1)[0];return!O&&t&&c&&c(t),t})).catch((function(e){return l.handleFragLoadError(e)})),this.hls.trigger(fO.FRAG_LOADING,{frag:e,targetBufferTime:u}),null===this.fragCurrent?nk.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):M}},{key:"doFragPartsLoad",value:function(e,t,r,i){var n=this;return new nk((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(fO.FRAG_LOADED,i);var c=eB(r.details,e.sn,o.index+1)||tB(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===dO.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(fO.ERROR,t)}else this.hls.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===gB){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a);var s,o=this.getLevelDetails(),l=o&&r.sn>o.endSN||this.shouldLoadParts(o,r.end);if(l!==this.loadingParts)this.log(_d(s="LL-Part loading ".concat(l?"ON":"OFF"," after parsing segment ending @")).call(s,r.end.toFixed(2))),this.loadingParts=l;this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||this.state===uB||this.state===yB||(this.state=cB)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var r,i,n=e.partList[0];if(t>=n.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0))if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t,r,i=this.levels,n=this.fragCurrent,a=e.level,s=e.sn,o=e.part;if(null==i||!i[a])return this.warn(_d(t=_d(r="Levels object was unset while buffering fragment ".concat(s," of ")).call(r,this.playlistLabel()," ")).call(t,a,". The current chunk will not be buffered.")),null;var l=i[a],u=l.details,c=o>-1?eB(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===gB){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=wN(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(fO.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(qN.isBuffered(t,t.currentTime)){var r=t.currentTime,i=qN.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(!lO(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=qN.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 qN.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]:yO,i=null==(t=this.fragmentTracker)?void 0:t.getAppendedFrag(e,r);return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n=this.config,a=r[0].start,s=n.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l,u=n.initialLiveManifestSize;if(i<u)return this.warn(_d(l="Not enough fragments to start playback (have: ".concat(i,", need: ")).call(l,u,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<a){var c,h,d,f;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,r);var v=this.hls.startPosition,g=this.hls.liveSyncPosition,p=o?(-1!==v?v:g)||o.start:e;this.log(_d(c=_d(h=_d(d="Setting startPosition to ".concat(p," to match initial live edge. mainStart: ")).call(d,v," liveSyncPosition: ")).call(h,g," frag.start: ")).call(c,null==(f=o)?void 0:f.start)),this.startPosition=this.nextLoadPosition=p}}else e<=a&&(o=r[0]);if(!o){var m=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,m,t)}return this.mapToInitFragWhenRequired(o)}},{key:"isLoopLoading",value:function(e,t){var r=this.fragmentTracker.getState(e);return(r===UF||r===NF&&!!e.gap)&&this.nextLoadPosition>t}},{key:"getNextFragmentLoopLoading",value:function(e,t,r,i,n){var a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t))&&!a.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==s&&r.len+s.len>=n){var o,l=a.sn;if(this.loopSn!==l)this.log(_d(o='buffer full after gaps in "'.concat(i,'" playlist starting at sn: ')).call(o,l)),this.loopSn=l;return null}}return this.loopSn=void 0,a}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(n||l.independent||a)&&l.fragment===t&&(i=s),n=u}return i}},{key:"loadedEndOfParts",value:function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded}},{key:"getInitialLiveFragment",value:function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime)),i=function(e,t,r){if(null===t||!lv(e)||!e.length||!lO(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(EF(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=kF(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}},{key:"getFragmentAtPosition",value:function(e,t,r){var i,n,a=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=a.maxFragLookUpTolerance,h=r.partList,d=!!(this.loadingParts&&null!=h&&h.length&&u);(d&&u&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=_d(o).call(o,u),l=u.sn),e<t)?i=mF(s,o,e,e<this.lastCurrentTime||e>t-c||null!=(n=this.media)&&n.paused||!this.startFragRequested?0:c):i=o[o.length-1];if(i){var f=i.sn-r.startSN,v=this.fragmentTracker.getState(i);if((v===UF||v===NF&&i.gap)&&(s=i),s&&i.sn===s.sn&&(!d||h[0].fragment.sn>i.sn||!r.live&&!d))if(s&&i.level===s.level){var g=o[f+1];i=i.sn<l&&this.fragmentTracker.getState(g)!==UF?g:null}}return i}},{key:"alignPlaylists",value:function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var n=e.fragmentStart,a=!t,s=e.alignedSliding&&lO(n);if(a||!s&&!n){var o,l,u;!function(e,t){e&&(sB(t,e),!t.alignedSliding&&e&&oB(t,e),t.alignedSliding||!e||t.skippedSegments||$U(e,t,!1))}(r,e);var c=e.fragmentStart;return this.log(_d(o=_d(l=_d(u="Live playlist sliding: ".concat(c.toFixed(2)," start-sn: ")).call(u,t?t.startSN:"na","->")).call(l,e.startSN," fragments: ")).call(o,i)),c}return n}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r){var i,n,a=null!==this.startTimeOffset,s=a?this.startTimeOffset:e.startTimeOffset;if(null!==s&&lO(s))r=t+s,s<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(_d(i=_d(n="Setting startPosition to ".concat(r," for start time offset ")).call(n,s," found in ")).call(i,a?"multivariant":"media"," playlist")),this.startPosition=r;else e.live?(r=this.hls.liveSyncPosition||t,this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0);this.lastCurrentTime=r}this.nextLoadPosition=r}},{key:"getLoadPosition",value:function(){var e,t=this.media,r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}},{key:"handleFragLoadAborted",value:function(e,t){var r,i,n;this.transmuxer&&e.type===this.playlistType&&uN(e)&&e.stats.aborted&&(this.warn(_d(r=_d(i=_d(n="Fragment ".concat(e.sn)).call(n,t?" part "+t.index:""," of ")).call(i,this.playlistLabel()," ")).call(r,e.level," was aborted")),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===fB)||(this.state=cB)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var n,a;this.warn(_d(n="Frag load error must match current frag to retry ".concat(i.url," > ")).call(n,null==(a=this.fragCurrent)?void 0:a.url))}else{var s=t.details===dO.FRAG_GAP;s&&this.fragmentTracker.fragBuffered(i,!0);var o=t.errorAction,l=o||{},u=l.action,c=wC(l),h=l.retryCount,d=void 0===h?0:h,f=l.retryConfig,v=!!o&&!!f,g=v&&u===_F,p=v&&!o.resolved&&c===CF;if(!g&&p&&uN(i)&&!i.endList)this.resetFragmentErrors(e),this.treatAsGap(i),o.resolved=!0;else if((g||p)&&d<f.maxNumRetry){var m,y,E,k,T,S;this.resetStartWhenNotLoaded(this.levelLastLoaded);var A=AF(f,d);this.warn(_d(m=_d(y=_d(E=_d(k=_d(T=_d(S="Fragment ".concat(i.sn," of ")).call(S,e," ")).call(T,i.level," errored with ")).call(k,t.details,", retrying loading ")).call(E,d+1,"/")).call(y,f.maxNumRetry," in ")).call(m,A,"ms")),o.resolved=!0,this.retryDate=self.performance.now()+A,this.state=fB}else if(f&&o){var L;if(this.resetFragmentErrors(e),!(d<f.maxNumRetry))return void this.warn(_d(L="".concat(t.details," reached or exceeded max retry (")).call(L,d,")"));s||u===DF||(o.resolved=!0)}else this.state=u===IF?kB:yB;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===gB||this.state===pB){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===EO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==uB&&(this.state=cB)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var i=qN.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===mB&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==uB&&(this.state=cB)}},{key:"resetStartWhenNotLoaded",value:function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){var t,r;this.warn(_d(t=_d(r="The loading context changed while buffering fragment ".concat(e.sn," of ")).call(r,this.playlistLabel()," ")).call(t,e.level,". This chunk will not be buffered.")),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,r,i){var n,a,s,o,l,u=this,c=r.details;if(c){if(!kC(n=yv(e.elementaryStreams)).call(n,(function(t,n){var a=e.elementaryStreams[n];if(a){var s,o,l=a.endPTS-a.startPTS;if(l<=0)return u.warn(_d(s=_d(o="Could not parse fragment ".concat(e.sn," ")).call(o,n," duration reliably (")).call(s,l,")")),t||!1;var h=i?0:XU(c,e,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return u.hls.trigger(fO.LEVEL_PTS_UPDATED,{details:c,level:r,drift:h,type:n,frag:e,start:a.startPTS,end:a.endPTS}),!0}return t}),!1)&&null===(null==(l=this.transmuxer)?void 0:l.error)){var h,d,f,v,g=new Error(_d(h=_d(d="Found no media in fragment ".concat(e.sn," of ")).call(d,this.playlistLabel()," ")).call(h,e.level," resetting transmuxer to fallback to playlist timing"));if(0===r.fragmentError&&this.treatAsGap(e,r),this.warn(g.message),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!1,error:g,frag:e,reason:_d(f=_d(v="Found no media in msn ".concat(e.sn," of ")).call(v,this.playlistLabel(),' "')).call(f,r.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=pB,this.log(_d(a=_d(s=_d(o="Parsed ".concat(e.type," sn: ")).call(o,e.sn)).call(s,t?" part: "+t.index:""," of ")).call(a,this.fragInfo(e,!1,t),")")),this.hls.trigger(fO.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===yO?"level":"track"}},{key:"fragInfo",value:function(e){var t,r,i,n,a,s,o,l=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],u=arguments.length>2?arguments[2]:void 0;return _d(t=_d(r=_d(i=_d(n=_d(a="".concat(this.playlistLabel()," ")).call(a,e.level," (")).call(n,u?"part":"frag",":[")).call(i,(null!=(s=l&&!u?e.startPTS:(u||e).start)?s:NaN).toFixed(3),"-")).call(r,(null!=(o=l&&!u?e.endPTS:(u||e).end)?o:NaN).toFixed(3),"]")).call(t,u&&"main"===e.type?"INDEPENDENT="+(u.independent?"YES":"NO"):"")}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t,r=this._state;r!==e&&(this._state=e,this.log(_d(t="".concat(r,"->")).call(t,e)))}}]),i}(VN),SB=function(){function e(){t(this,e),this.chunks=[],this.dataLength=0}return Fc(e,[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}]),e}();var AB={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}aT&&(i.prototype=aT(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?Bv(i).call(i,1):i);return Zk?_d(n).call(n,Zk(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}(AB);var LB=QF(AB.exports),bB="1.6.0-beta.2",RB={};function IB(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 DB(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 _B(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 wB(e,t){for(var r=t,i=0;DB(e,t);){i+=10,i+=_B(e,t+6),IB(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function CB(e,t){return 255===e[t]&&240==(246&e[t+1])}function PB(e,t){return 1&e[t+1]?7:9}function xB(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function MB(e,t){return t+1<e.length&&CB(e,t)}function OB(e,t){if(MB(e,t)){var r=PB(e,t);if(t+r>=e.length)return!1;var i=xB(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||MB(e,n)}return!1}function FB(e,t,r,i,n){if(!e.samplerate){var a=function(e,t,r,i){var n,a,s,o,l,u=t[r+2],c=u>>2&15;if(!(c>12)){var h=1+(u>>6&3),d=t[r+3]>>6&3|(1&u)<<2,f="mp4a.40."+h,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][c],g=c;5!==h&&29!==h||(g-=3);var p=[h<<3|(14&g)>>1,(1&g)<<7|d<<3];return xO.log(_d(n=_d(a=_d(s=_d(o=_d(l="manifest codec:".concat(i,", parsed codec:")).call(l,f,", channels:")).call(o,d,", rate:")).call(s,v," (ADTS object type:")).call(a,h," sampling index:")).call(n,c,")")),{config:p,samplerate:v,channelCount:d,codec:f,parsedCodec:f,manifestCodec:i}}var m=new Error("invalid ADTS sampling index:".concat(c));e.emit(fO.ERROR,fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!0,error:m,reason:m.message})}(t,r,i,n);if(!a)return;LO(e,a)}}function NB(e){return 9216e4/e}function UB(e,t,r,i,n){var a,s=i+n*NB(e.samplerate),o=function(e,t){var r=PB(e,t);if(t+r<=e.length){var i=xB(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 BB(e,t){return DB(e,t)&&_B(e,t+6)+10<=e.length-t}function GB(e){return function(e,t,r,i){var n=(s=e,s instanceof ArrayBuffer?s:s.buffer),a=1;var s;"BYTES_PER_ELEMENT"in i&&(a=i.BYTES_PER_ELEMENT);var o=(d=e,d&&d.buffer instanceof ArrayBuffer&&void 0!==d.byteLength&&void 0!==d.byteOffset?e.byteOffset:0),l=(o+e.byteLength)/a,u=(o+t)/a,c=Math.floor(Math.max(0,Math.min(u,l))),h=Math.floor(Math.min(c+Math.max(r,0),l));var d;return new i(n,c,h-c)}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,Uint8Array)}function KB(e,t){if(e<0)return-KB(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<tP){var i=Math.floor(e*r);return(i%2==0?i:i+1)/r}return Math.round(e*r)/r}function HB(e){var t,r,i={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var n=av(t=e.data.subarray(1)).call(t,0);if(-1!==n){var a=zF(GB(e.data,1,n)),s=e.data[2+n],o=av(r=e.data.subarray(3+n)).call(r,0);if(-1!==o){var l,u,c=zF(GB(e.data,3+n,o));return l="--\x3e"===a?zF(GB(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 VB(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=zF(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=zF(e.data.subarray(t),!0);t+=r.length+1;var i=zF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=zF(e.data);return{key:e.type,info:"",data:n}}(e):"APIC"===e.type?HB(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=zF(e.data.subarray(t),!0);t+=r.length+1;var i=zF(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=zF(e.data.subarray(1));return{key:e.type,info:"",data:n}}}(e)}function jB(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=_B(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var YB=10,qB=10;function WB(e){for(var t=0,r=[];DB(e,t);){var i=_B(e,t+6);e[t+5]>>6&1&&(t+=YB);for(var n=(t+=YB)+i;t+qB<n;){var a=jB(e.subarray(t)),s=VB(a);s&&r.push(s),t+=a.size+YB}IB(e,t)&&(t+=YB)}return r}function zB(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function XB(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 QB(e){for(var t=WB(e),r=0;r<t.length;r++){var i=t[r];if(zB(i))return XB(i)}}var $B=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 JB(){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 ZB=function(){function e(){t(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}return Fc(e,[{key:"resetInitSegment",value:function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,r){}},{key:"demux",value:function(e,t){this.cachedData&&(e=wN(this.cachedData,e),this.cachedData=null);var r,i=wB(e,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?QB(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&lO(o))&&(this.basePTS=eG(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:$B.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 BB(e,n)?(i=wB(e,n),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:$B.audioId3,duration:Number.POSITIVE_INFINITY}),r=n+=i.length):n++;if(n===l&&r!==l){var c=YF(e,r);this.cachedData?this.cachedData=wN(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:JB(),id3Track:s,textTrack:JB()}}},{key:"demuxSampleAes",value:function(e,t,r){return nk.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:JB(),id3Track:this._id3Track,textTrack:JB()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),eG=function(e,t,r){return lO(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},tG=null,rG=[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],iG=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],nG=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],aG=[0,1,1,4];function sG(e,t,r,i,n){if(!(r+24>t.length)){var a=oG(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 oG(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*rG[14*(3===r?3-i:3===i?3:4)+n-1],u=iG[3*(3===r?0:2===r?1:2)+a],c=3===o?1:2,h=nG[r][i],d=aG[i],f=8*h*d,v=Math.floor(h*l/u+s)*d;if(null===tG){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);tG=g?Rk(g[1]):0}return!!tG&&tG<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:c,frameLength:v,samplesPerFrame:f}}}function lG(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function uG(e,t){return t+1<e.length&&lG(e,t)}function cG(e,t){if(t+1<e.length&&lG(e,t)){var r=oG(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||uG(e,n)}return!1}var hG=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this)).observer=void 0,a.config=void 0,a.observer=e,a.config=n,a}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&CB(e,t)&&xB(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){FB(e,this.observer,t,r,e.manifestCodec);var i=UB(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=wB(e,0),i=(null==r?void 0:r.length)||0;if(cG(e,i))return!1;for(var n=e.length;i<n;i++)if(OB(e,i))return t.log("ADTS sync word found !"),!0;return!1}}]),i}(ZB),dG=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},fG=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this)).observer=void 0,n.observer=e,n}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,r){var i=vG(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=wB(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==QB(t)&&dG(e,r)<16}}]),i}(ZB);function vG(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 gG=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"resetInitSegment",value:function(e,t,r,n){Ih(Rh(i.prototype),"resetInitSegment",this).call(this,e,t,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return lG(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return sG(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=wB(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==QB(t)&&dG(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(cG(e,r))return xO.log("MPEG Audio sync word found !"),!0;return!1}}]),i}(ZB),pG=/\/emsg[-/]ID3/i,mG=function(){function e(r,i){t(this,e),this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=i}return Fc(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,i){var n=this.videoTrack=JB("video",1),a=this.audioTrack=JB("audio",1),s=this.txtTrack=JB("text",1);if(this.id3Track=JB("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=AN(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=vN.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=wN(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},r=TN(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=YF(e,0,i.byteOffset-8),t.remainder=YF(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=CN(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=CN(e,t),{videoTrack:t,audioTrack:JB(),id3Track:i,textTrack:JB()}}},{key:"extractID3Track",value:function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var n=TN(e.samples,["emsg"]);n&&vd(n).call(n,(function(e){var n,a=function(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==gN(e.subarray(u,u+1));)r+=gN(e.subarray(u,u+1)),u+=1;for(r+=gN(e.subarray(u,u+1)),u+=1;"\0"!==gN(e.subarray(u,u+1));)i+=gN(e.subarray(u,u+1)),u+=1;i+=gN(e.subarray(u,u+1)),u+=1,n=mN(e,12),a=mN(e,16),o=mN(e,20),l=mN(e,24),u=28}else if(1===t){n=mN(e,u+=4);var c=mN(e,u+=4),h=mN(e,u+=4);for(u+=4,s=Math.pow(2,32)*c+h,uO(s)||(s=lC,xO.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=mN(e,u),l=mN(e,u+=4),u+=4;"\0"!==gN(e.subarray(u,u+1));)r+=gN(e.subarray(u,u+1)),u+=1;for(r+=gN(e.subarray(u,u+1)),u+=1;"\0"!==gN(e.subarray(u,u+1));)i+=gN(e.subarray(u,u+1)),u+=1;i+=gN(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(pG.test(a.schemeIdUri)){var s=yG(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:$B.emsg,duration:o})}else if(r.config.enableEmsgKLVMetadata&&UI(n=a.schemeIdUri).call(n,"urn:misb:KLV:bin:1910.1")){var u=yG(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:u,pts:u,type:$B.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return i}},{key:"demuxSampleAes",value:function(e,t,r){return nk.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=mN(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}}]),e}();function yG(e,t){return lO(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var EG=function(){function e(r,i,n){t(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new NN(i,{removePKCS7Padding:!1})}return Fc(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,HF)}},{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=Bv(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=MN(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}(),kG=function(){function e(){t(this,e),this.VideoSample=null}return Fc(e,[{key:"createVideoSample",value:function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var n=i.units;r=n[n.length-1]}return r}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,r){var i,n,a=t.byteLength,s=e.naluState||0,o=s,l=[],u=0,c=-1,h=0;for(-1===s&&(c=0,h=this.getNALuType(t,0),s=0,u=1);u<a;)if(i=t[u++],s)if(1!==s)if(i)if(1===i){if(n=u-s-1,c>=0){var d={data:t.subarray(c,n),type:h};l.push(d)}else{var f=this.getLastNalUnit(e.samples);f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),n>0&&(f.data=wN(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=wN(g.data,t))}return e.naluState=s,l}}]),e}(),TG=function(){function e(r){t(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=r,this.bytesAvailable=r.byteLength,this.word=0,this.bitsAvailable=0}return Fc(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&xO.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}(),SG=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 1:var c=!1;n=!0;var h,d=i.data;if(l&&d.length>4){var f=a.readSliceType(d);2!==f&&4!==f&&7!==f&&9!==f||(c=!0)}if(c)null!=(h=o)&&h.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=c;break;case 5:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:n=!0,xN(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 TG(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 TG(e),f=0,v=0,g=0,p=0,m=sT(t=d.readUByte).call(t,d),y=sT(r=d.readBits).call(r,d),E=sT(i=d.readUEG).call(i,d),k=sT(n=d.readBoolean).call(n,d),T=sT(a=d.skipBits).call(a,d),S=sT(s=d.skipEG).call(s,d),A=sT(o=d.skipUEG).call(o,d),L=sT(l=this.skipScalingList).call(l,this);m();var b=m();if(y(5),T(3),m(),A(),100===b||110===b||122===b||244===b||44===b||83===b||86===b||118===b||128===b){var R=E();if(3===R&&T(1),A(),A(),T(1),k())for(c=3!==R?8:12,h=0;h<c;h++)k()&&L(h<6?16:64,d)}A();var I=E();if(0===I)E();else if(1===I)for(T(1),S(),S(),u=E(),h=0;h<u;h++)S();A(),T(1);var D=E(),_=E(),w=y(1);0===w&&T(1),T(1),k()&&(f=E(),v=E(),g=E(),p=E());var C=[1,1];if(k()&&k())switch(m()){case 1:C=[1,1];break;case 2:C=[12,11];break;case 3:C=[10,11];break;case 4:C=[16,11];break;case 5:C=[40,33];break;case 6:C=[24,11];break;case 7:C=[20,11];break;case 8:C=[32,11];break;case 9:C=[80,33];break;case 10:C=[18,11];break;case 11:C=[15,11];break;case 12:C=[64,33];break;case 13:C=[160,99];break;case 14:C=[4,3];break;case 15:C=[3,2];break;case 16:C=[2,1];break;case 255:C=[m()<<8|m(),m()<<8|m()]}return{width:Math.ceil(16*(D+1)-2*f-2*v),height:(2-w)*(_+1)*16-(w?2:4)*(g+p),pixelRatio:C}}}]),i}(kG),AG=function(e){Ph(i,e);var r=ed(i);function i(){var e,n;t(this,i);for(var a=arguments.length,s=new Array(a),o=0;o<a;o++)s[o]=arguments[o];return(n=r.call.apply(r,_d(e=[this]).call(e,s))).initVPS=null,n}return Fc(i,[{key:"parsePES",value:function(e,t,r,i){var n,a=this,s=this.parseNALu(e,r.data,i),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),vd(s).call(s,(function(i){var s,u;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts)),o.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var c;if(n=!0,l)null!=(c=o)&&c.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null);o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 39:n=!0,xN(i.data,2,r.pts,t.samples);break;case 32:if(n=!0,!e.vps){var h=a.readVPS(i.data);e.params=RO({},h),a.initVPS=i.data}e.vps=[i.data];break;case 33:if(n=!0,l=!0,"object"===Cc(e.params)){if(void 0===e.vps||e.vps[0]===a.initVPS||void 0===e.sps||a.matchSPS(e.sps[0],i.data)||(a.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=a.readSPS(i.data);for(var f in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],d.params)e.params[f]=d.params[f]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.sps.push(i.data)}o||(o=a.VideoSample=a.createVideoSample(!0,r.pts,r.dts)),o.key=!0;break;case 34:if(n=!0,"object"===Cc(e.params)){if(!e.pps){e.pps=[];var v=a.readPPS(i.data);for(var g in v)e.params[g]=v[g]}void 0!==e.vps&&e.vps[0]===a.initVPS&&e.pps.push(i.data)}break;case 35:n=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(a.pushAccessUnit(o,e),o=null),o||(o=a.VideoSample=a.createVideoSample(!1,r.pts,r.dts));break;default:n=!1}o&&n&&o.units.push(i)})),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),r=0,i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}},{key:"pushAccessUnit",value:function(e,t){Ih(Rh(i.prototype),"pushAccessUnit",this).call(this,e,t),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new TG(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 TG(this.ebsp2rbsp(e));a.readUByte(),a.readUByte(),a.readBits(4);var s=a.readBits(3);a.readBoolean();for(var o=a.readBits(2),l=a.readBoolean(),u=a.readBits(5),c=a.readUByte(),h=a.readUByte(),d=a.readUByte(),f=a.readUByte(),v=a.readUByte(),g=a.readUByte(),p=a.readUByte(),m=a.readUByte(),y=a.readUByte(),E=a.readUByte(),k=a.readUByte(),T=[],S=[],A=0;A<s;A++)T.push(a.readBoolean()),S.push(a.readBoolean());if(s>0)for(var L=s;L<8;L++)a.readBits(2);for(var b=0;b<s;b++)T[b]&&(a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte(),a.readUByte()),S[b]&&a.readUByte();a.readUEG();var R=a.readUEG();3==R&&a.skipBits(1);var I=a.readUEG(),D=a.readUEG(),_=a.readBoolean(),w=0,C=0,P=0,x=0;_&&(w+=a.readUEG(),C+=a.readUEG(),P+=a.readUEG(),x+=a.readUEG());for(var M=a.readUEG(),O=a.readUEG(),F=a.readUEG(),N=a.readBoolean()?0:s;N<=s;N++)a.skipUEG(),a.skipUEG(),a.skipUEG();if((a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.skipUEG(),a.readBoolean())&&a.readBoolean())for(var U=0;U<4;U++)for(var B=0;B<(3===U?2:6);B++){if(a.readBoolean()){var G=Math.min(64,1<<4+(U<<1));U>1&&a.readEG();for(var K=0;K<G;K++)a.readEG()}else a.readUEG()}a.readBoolean(),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.skipUEG(),a.skipUEG(),a.readBoolean());for(var H=a.readUEG(),V=0,j=0;j<H;j++){var Y=!1;if(0!==j&&(Y=a.readBoolean()),Y){j===H&&a.readUEG(),a.readBoolean(),a.readUEG();for(var q=0,W=0;W<=V;W++){var z=a.readBoolean(),X=!1;z||(X=a.readBoolean()),(z||X)&&q++}V=q}else{var Q=a.readUEG(),$=a.readUEG();V=Q+$;for(var J=0;J<Q;J++)a.readUEG(),a.readBoolean();for(var Z=0;Z<$;Z++)a.readUEG(),a.readBoolean()}}if(a.readBoolean())for(var ee=a.readUEG(),te=0;te<ee;te++){for(var re=0;re<F+4;re++)a.readBits(1);a.readBits(1)}var ie=0,ne=1,ae=1,se=!0,oe=1,le=0;a.readBoolean(),a.readBoolean();var ue=!1;if(a.readBoolean()){if(a.readBoolean()){var ce=a.readUByte();ce>0&&ce<16?(ne=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][ce-1],ae=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][ce-1]):255===ce&&(ne=a.readBits(16),ae=a.readBits(16))}if(a.readBoolean()&&a.readBoolean(),a.readBoolean())a.readBits(3),a.readBoolean(),a.readBoolean()&&(a.readUByte(),a.readUByte(),a.readUByte());if(a.readBoolean()&&(a.readUEG(),a.readUEG()),a.readBoolean(),a.readBoolean(),a.readBoolean(),(ue=a.readBoolean())&&(w+=a.readUEG(),C+=a.readUEG(),P+=a.readUEG(),x+=a.readUEG()),a.readBoolean())if(oe=a.readBits(32),le=a.readBits(32),a.readBoolean()&&a.readUEG(),a.readBoolean()){var he=a.readBoolean(),de=a.readBoolean(),fe=!1;(he||de)&&((fe=a.readBoolean())&&(a.readUByte(),a.readBits(5),a.readBoolean(),a.readBits(5)),a.readBits(4),a.readBits(4),fe&&a.readBits(4),a.readBits(5),a.readBits(5),a.readBits(5));for(var ve=0;ve<=s;ve++){var ge=!1;(se=a.readBoolean())||a.readBoolean()?a.readEG():ge=a.readBoolean();var pe=ge?1:a.readUEG()+1;if(he)for(var me=0;me<pe;me++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1);if(de)for(var ye=0;ye<pe;ye++)a.readUEG(),a.readUEG(),fe&&(a.readUEG(),a.readUEG()),a.skipBits(1)}}a.readBoolean()&&(a.readBoolean(),a.readBoolean(),a.readBoolean(),ie=a.readUEG())}var Ee=I,ke=D;if(_||ue){var Te=1,Se=1;1===R?Te=Se=2:2==R&&(Te=2),Ee=I-Te*C-Te*w,ke=D-Se*x-Se*P}for(var Ae=o?["A","B","C"][o]:"",Le=c<<24|h<<16|d<<8|f,be=0,Re=0;Re<32;Re++)be=(be|(Le>>Re&1)<<31-Re)>>>0;var Ie=be.toString(16);1===u&&"2"===Ie&&(Ie="6");var De=l?"H":"L";return{codecString:_d(t=_d(r=_d(i=_d(n="hvc1.".concat(Ae)).call(n,u,".")).call(i,Ie,".")).call(r,De)).call(t,k,".B0"),params:{general_tier_flag:l,general_profile_idc:u,general_profile_space:o,general_profile_compatibility_flags:[c,h,d,f],general_constraint_indicator_flags:[v,g,p,m,y,E],general_level_idc:k,bit_depth:M+8,bit_depth_luma_minus8:M,bit_depth_chroma_minus8:O,min_spatial_segmentation_idc:ie,chroma_format_idc:R,frame_rate:{fixed:se,fps:le/oe}},width:Ee,height:ke,pixelRatio:[ne,ae]}}},{key:"readPPS",value:function(e){var t=new TG(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var r=t.readBoolean(),i=t.readBoolean(),n=1;return i&&r?n=0:i?n=3:r&&(n=2),{parallelismType:n}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}]),i}(kG),LG=188,bG=function(){function e(r,i,n,a){t(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=r,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return Fc(e,[{key:"resetInitSegment",value:function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,r){var i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];n||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,c=s.pid,h=s.pesData,d=o.pid,f=l.pid,v=o.pesData,g=l.pesData,p=null,m=this.pmtParsed,y=this._pmtId,E=t.length;if(this.remainderData&&(E=(t=wN(this.remainderData,t)).length,this.remainderData=null),E<LG&&!a)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var k=Math.max(0,e.syncOffset(t));(E-=(E-k)%LG)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E));for(var T=0,S=k;S<E;S+=LG)if(71===t[S]){var A=!!(64&t[S+1]),L=RG(t,S),b=void 0;if((48&t[S+3])>>4>1){if((b=S+5+t[S+4])===S+LG)continue}else b=S+4;switch(L){case c:if(A){if(h&&(i=CG(h,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new SG;break;case"hevc":this.videoParser=new AG}null!==this.videoParser&&this.videoParser.parsePES(s,u,i,!1)}h={data:[],size:0}}h&&(h.data.push(t.subarray(b,S+LG)),h.size+=S+LG-b);break;case d:if(A){if(v&&(i=CG(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+LG)),v.size+=S+LG-b);break;case f:A&&(g&&(i=CG(g,this.logger))&&this.parseID3PES(l,i),g={data:[],size:0}),g&&(g.data.push(t.subarray(b,S+LG)),g.size+=S+LG-b);break;case 0:A&&(b+=t[b]+1),y=this._pmtId=IG(t,b);break;case y:A&&(b+=t[b]+1);var R,I,D=DG(t,b,this.typeSupported,n,this.observer,this.logger);if((c=D.videoPid)>0&&(s.pid=c,s.segmentCodec=D.segmentVideoCodec),(d=D.audioPid)>0&&(o.pid=d,o.segmentCodec=D.segmentAudioCodec),(f=D.id3Pid)>0&&(l.pid=f),null!==p&&!m)this.logger.warn(_d(R=_d(I="MPEG-TS PMT found at ".concat(S," after unknown PID '")).call(I,p,"'. Backtracking to sync byte @")).call(R,k," to parse all TS packets.")),p=null,S=k-188;m=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=L}}else T++;T>0&&_G(this.observer,new Error("Found ".concat(T," TS packet/s that do not start with 0x47")),void 0,this.logger),s.pesData=h,o.pesData=v,l.pesData=g;var _={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return a&&this.extractRemainingSamples(_),_}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(t=CG(s,this.logger))){if(null===this.videoParser)switch(i.segmentCodec){case"avc":this.videoParser=new SG;break;case"hevc":this.videoParser=new AG}null!==this.videoParser&&(this.videoParser.parsePES(i,a,t,!0),i.pesData=null)}else i.pesData=s;if(o&&(t=CG(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=CG(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 EG(this.observer,this.config,t);return this.decrypt(i,n)}},{key:"decrypt",value:function(e,t){return new nk((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=wN(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&&!MB(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",_G(this.observer,new Error(h),d,this.logger),!d)return}if(FB(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=NB(e.samplerate);n=s.sample.pts+f}for(var v,g=0;r<i;){if(r+=(v=UB(e,o,r,n,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!MB(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(uG(r,a)){var o=sG(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=vG(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=LO({},t,{type:this._videoTrack?$B.emsg:$B.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-LG)+1,i=0;i<r;){for(var n=!1,a=-1,s=0,o=i;o<t;o+=LG){if(71!==e[o]||t-o!==LG&&71!==e[o+LG]){if(s)return-1;break}if(s++,-1===a&&0!==(a=o)&&(r=Math.min(a+18612,e.length-LG)+1),n||(n=0===RG(e,o)),n&&s>1&&(0===a&&s>2||o+LG>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:vN[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function RG(e,t){return((31&e[t+1])<<8)+e[t+2]}function IG(e,t){return(31&e[t+10])<<8|e[t+11]}function DG(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=RG(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){wG("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){wG("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){wG("AC-3",a);break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="ac3"):a.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&u>0)for(var c=t+5,h=u;h>2;){if(106===e[c])!0!==r.ac3?a.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");var d=e[c+1]+2;c+=d,h-=d}break;case 194:case 135:return _G(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 _G(e,t,r,i){i.warn("parsing error: ".concat(t.message)),e.emit(fO.ERROR,fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function wG(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function CG(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]=wN(l[0],l[1]),sg(l).call(l,1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;var u=r[7];192&u&&(a=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?a-(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>54e5&&(t.warn("".concat(Math.round((a-s)/9e4),"s delta between PTS and DTS, align them")),a=s):s=a);var c=(n=r[8])+9;if(e.size<=c)return null;e.size-=c;for(var h=new Uint8Array(e.size),d=0,f=l.length;d<f;d++){var v=(r=l[d]).byteLength;if(c){if(c>v){c-=v;continue}r=r.subarray(c),v-=c,c=0}h.set(r,o),o+=v}return i&&(i-=n+3),{data:h,pts:a,dts:s,len:i}}return null}var PG=function(){function e(){t(this,e)}return Fc(e,null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}(),xG=Math.pow(2,32)-1,MG=function(){function e(){t(this,e)}return Fc(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))}},{key:"box",value:function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){r*=t;var i=Math.floor(r/(xG+1)),n=Math.floor(r%(xG+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))}},{key:"moov",value:function(t){for(var r,i,n=t.length,a=[];n--;)a[n]=e.trak(t[n]);return e.box.apply(null,_d(r=_d(i=[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)]).call(i,a)).call(r,e.mvex(t)))}},{key:"mvex",value:function(t){for(var r,i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,_d(r=[e.types.mvex]).call(r,n))}},{key:"mvhd",value:function(t,r){r*=t;var i=Math.floor(r/(xG+1)),n=Math.floor(r%(xG+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=wC(n[r]),a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,i,n,a,s,o,l=[],u=[];for(a=0;a<t.sps.length;a++)o=(s=t.sps[a]).byteLength,l.push(o>>>8&255),l.push(255&o),l=_d(l).call(l,Bv(Array.prototype).call(s));for(a=0;a<t.pps.length;a++)o=(s=t.pps[a]).byteLength,u.push(o>>>8&255),u.push(255&o),u=_d(u).call(u,Bv(Array.prototype).call(s));var c=e.box(e.types.avcC,new Uint8Array(_d(r=_d(i=_d(n=[1,l[3],l[4],l[5],255,224|t.sps.length]).call(n,l)).call(i,[t.pps.length])).call(r,u))),h=t.width,d=t.height,f=t.pixelRatio[0],v=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,h>>8&255,255&h,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),c,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,255&f,v>>24,v>>16&255,v>>8&255,255&v])))}},{key:"esds",value:function(e){var t,r=e.config;return new Uint8Array(_d(t=[0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2]).call(t,dD(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/(xG+1)),o=Math.floor(i%(xG+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/(xG+1)),s=Math.floor(r%(xG+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=wC(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 wN(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,Rk(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}();MG.types=void 0,MG.HDLR_TYPES=void 0,MG.STTS=void 0,MG.STSC=void 0,MG.STCO=void 0,MG.STSZ=void 0,MG.VMHD=void 0,MG.SMHD=void 0,MG.STSD=void 0,MG.FTYP=void 0,MG.DINF=void 0;var OG=9e4;function FG(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 NG(e){return FG(e,1e3,1/OG,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}var UG=null,BG=null,GG=function(){function e(r,i,n,a){if(t(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=r,this.config=i,this.typeSupported=n,this.logger=a,this.ISGenerated=!1,null===UG){var s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);UG=s?Rk(s[1]):0}if(null===BG){var o=navigator.userAgent.match(/Safari\/(\d+)/i);BG=o?Rk(o[1]):0}}return Fc(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,r=e[0].pts,i=kC(e).call(e,(function(e,i){var n=i.pts,a=n-e;return a<-4294967296&&(t=!0,a=(n=KG(n,r))-e),a>0?e:n}),r);return t&&this.logger.debug("PTS rollover detected"),i}},{key:"remux",value:function(e,t,r,i,n,a,s,o){var l,u,c,h,d,f,v=n,g=n,p=e.pid>-1,m=t.pid>-1,y=t.samples.length,E=e.samples.length>0,k=s&&y>0||y>1;if((!p||E)&&(!m||k)||this.ISGenerated||s){if(this.ISGenerated){var T,S,A,L,b=this.videoTrackConfig;(b&&(t.width!==b.width||t.height!==b.height||(null==(T=t.pixelRatio)?void 0:T[0])!==(null==(S=b.pixelRatio)?void 0:S[0])||(null==(A=t.pixelRatio)?void 0:A[1])!==(null==(L=b.pixelRatio)?void 0:L[1]))||!b&&k||null===this.nextAudioPts&&E)&&this.resetInitSegment()}this.ISGenerated||(c=this.generateIS(e,t,n,a));var R,I=this.isVideoContiguous,D=-1;if(k&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!I&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,D>0){var _,w;this.logger.warn(_d(_="[mp4-remuxer]: Dropped ".concat(D," out of ")).call(_,y," video samples due to a missing keyframe"));var C=this.getVideoStartPts(t.samples);t.samples=Bv(w=t.samples).call(w,D),t.dropped+=D,R=g+=(t.samples[0].pts-C)/t.inputTimeScale}else-1===D&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(y," video samples")),f=!1);if(this.ISGenerated){if(E&&k){var P=this.getVideoStartPts(t.samples),x=(KG(e.samples[0].pts,P)-P)/t.inputTimeScale;v+=Math.max(0,x),g+=Math.max(0,-x)}if(E){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,v,this.isAudioContiguous,a,m||k||o===EO?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=HG(r,n,this._initPTS,this._initDTS)),i.samples.length&&(h=VG(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):MG.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:MG.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,KG(l[0].dts,v)-g),n=Math.min(n,v-g)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(yv(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-KG(o[0].dts,o[0].pts);UG&&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=KG(T.pts-E,h),T.dts=KG(T.dts-E,h),T.dts<o[k>0?k-1:k].dts&&(p=!0)}p&&mA(o).call(o,(function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=o[0].dts;var S=(a=o[o.length-1].dts)-n,A=S?Math.round(S/(u-1)):f||e.inputTimeScale/30;if(r){var L=n-h,b=L>A,R=L<-1;if(b||R){var I,D,_,w,C,P;if(b)this.logger.warn(_d(I=_d(D=_d(_="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(_,NG(L,!0)," ms (")).call(D,L,"dts) hole between fragments detected at ")).call(I,t.toFixed(3)));else this.logger.warn(_d(w=_d(C=_d(P="".concat((e.segmentCodec||"").toUpperCase(),": ")).call(P,NG(-L,!0)," ms (")).call(C,L,"dts) overlapping between fragments detected at ")).call(w,t.toFixed(3)));if(!R||h>=o[0].pts||UG){var x,M;n=h;var O=o[0].pts-L;if(b)o[0].dts=n,o[0].pts=O;else for(var F=!0,N=0;N<o.length&&!(o[N].dts>O&&F);N++){var U=o[N].pts;if(o[N].dts-=L,o[N].pts-=L,N<o.length-1){var B=o[N+1].pts;F=B<=o[N].pts==B<=U}}this.logger.log(_d(x=_d(M="Video: Initial PTS/DTS adjusted: ".concat(NG(O,!0),"/")).call(M,NG(n,!0),", delta: ")).call(x,NG(L,!0)," ms"))}}}for(var G=0,K=0,H=n=Math.max(0,n),V=0;V<u;V++){for(var j=o[V],Y=j.units,q=Y.length,W=0,z=0;z<q;z++)W+=Y[z].data.length;K+=W,G+=q,j.length=W,j.dts<H?(j.dts=H,H+=A/4|0||1):H=j.dts,v=Math.min(j.pts,v),g=Math.max(j.pts,g)}a=o[u-1].dts;var X,Q=K+4*G+8;try{X=new Uint8Array(Q)}catch(Ie){return void this.observer.emit(fO.ERROR,fO.ERROR,{type:hO.MUX_ERROR,details:dO.REMUX_ALLOC_ERROR,fatal:!1,error:Ie,bytes:Q,reason:"fail allocating video mdat ".concat(Q)})}var $=new DataView(X.buffer);$.setUint32(0,Q),X.set(MG.types.mdat,4);for(var J=!1,Z=Number.POSITIVE_INFINITY,ee=Number.POSITIVE_INFINITY,te=Number.NEGATIVE_INFINITY,re=Number.NEGATIVE_INFINITY,ie=0;ie<u;ie++){for(var ne=o[ie],ae=ne.units,se=0,oe=0,le=ae.length;oe<le;oe++){var ue=ae[oe],ce=ue.data,he=ue.data.byteLength;$.setUint32(d,he),d+=4,X.set(ce,d),d+=he,se+=4+he}var de=void 0;if(ie<u-1)f=o[ie+1].dts-ne.dts,de=o[ie+1].pts-ne.pts;else{var fe=this.config,ve=ie>0?ne.dts-o[ie-1].dts:A;if(de=ie>0?ne.pts-o[ie-1].pts:A,fe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ge,pe=Math.floor(fe.maxBufferHole*s),me=(i?v+i*s:this.nextAudioPts)-ne.pts;if(me>pe)(f=me-ve)<0?f=ve:J=!0,this.logger.log(_d(ge="[mp4-remuxer]: It is approximately ".concat(me/90," ms to the next segment; using duration ")).call(ge,f/90," ms for the last video frame."));else f=ve}else f=ve}var ye=Math.round(ne.pts-ne.dts);Z=Math.min(Z,f),te=Math.max(te,f),ee=Math.min(ee,de),re=Math.max(re,de),l.push(new YG(ne.key,f,se,ye))}if(l.length)if(UG){if(UG<70){var Ee=wC(l[0]);Ee.dependsOn=2,Ee.isNonSync=0}}else if(BG&&re-ee<te-Z&&A/te<.025&&0===l[0].cts){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ke=n,Te=0,Se=l.length;Te<Se;Te++){var Ae=ke+l[Te].duration,Le=ke+l[Te].cts;if(Te<Se-1){var be=Ae+l[Te+1].cts;l[Te].duration=be-Le}else l[Te].duration=Te?l[Te-1].duration:A;l[Te].cts=0,ke=Ae}}f=J||!f?A:f,this.nextAvcDts=h=a+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;var Re={data1:MG.moof(e.sequenceNumber++,n,LO({},e,{samples:l})),data2:X,startPTS:v/s,endPTS:(g+f)/s,startDTS:n/s,endDTS:h/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Re}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,r,i,n){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.getSamplesPerFrame(e),l=o*s,u=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],d=void 0!==n,f=e.samples,v=c?0:8,g=this.nextAudioPts||-1,p=t*a,m=u.baseTime*a/u.timescale;if(this.isAudioContiguous=r=r||f.length&&g>0&&(i&&Math.abs(p-g)<9e3||Math.abs(KG(f[0].pts-m,p)-g)<20*l),vd(f).call(f,(function(e){e.pts=KG(e.pts-m,p)})),!r||g<0){if(!(f=xk(f).call(f,(function(e){return e.pts>=0}))).length)return;g=0===n?0:i&&!d?Math.max(0,p):f[0].pts}if("aac"===e.segmentCodec)for(var y=this.config.maxAudioFramesDrift,E=0,k=g;E<f.length;E++){var T,S=f[E],A=S.pts,L=A-k,b=Math.abs(1e3*L/a);if(L<=-y*l&&d){if(0===E)this.logger.warn(_d(T="Audio frame @ ".concat((A/a).toFixed(3),"s overlaps nextAudioPts by ")).call(T,Math.round(1e3*L/a)," ms.")),this.nextAudioPts=g=k=A}else if(L>=y*l&&b<1e4&&d){var R,I,D=Math.round(L/l);(k=A-D*l)<0&&(D--,k+=l),0===E&&(this.nextAudioPts=g=k),this.logger.warn(_d(R=_d(I="[mp4-remuxer]: Injecting ".concat(D," audio frame @ ")).call(I,(k/a).toFixed(3),"s due to ")).call(R,Math.round(1e3*L/a)," ms gap."));for(var _=0;_<D;_++){var w=Math.max(k,0),C=PG.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);C||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),C=S.unit.subarray()),sg(f).call(f,E,0,{unit:C,pts:w}),k+=l,E++}}S.pts=k,k+=l}for(var P,x=null,M=null,O=0,F=f.length;F--;)O+=f[F].unit.byteLength;for(var N=0,U=f.length;N<U;N++){var B=f[N],G=B.unit,K=B.pts;if(null!==M){h[N-1].duration=Math.round((K-M)/s)}else{if(r&&"aac"===e.segmentCodec&&(K=g),x=K,!(O>0))return;O+=v;try{P=new Uint8Array(O)}catch(X){return void this.observer.emit(fO.ERROR,fO.ERROR,{type:hO.MUX_ERROR,details:dO.REMUX_ALLOC_ERROR,fatal:!1,error:X,bytes:O,reason:"fail allocating audio mdat ".concat(O)})}c||(new DataView(P.buffer).setUint32(0,O),P.set(MG.types.mdat,4))}P.set(G,v);var H=G.byteLength;v+=H,h.push(new YG(!0,o,H,0)),M=K}var V=h.length;if(V){var j=h[h.length-1];this.nextAudioPts=g=M+s*j.duration;var Y=c?new Uint8Array(0):MG.moof(e.sequenceNumber++,x/s,LO({},e,{samples:h}));e.samples=[];var q=x/a,W=g/a,z={data1:Y,data2:P,startPTS:q,endPTS:W,startDTS:q,endDTS:W,type:"audio",hasAudio:!0,hasVideo:!1,nb:V};return this.isAudioContiguous=!0,z}}}]),e}();function KG(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 HG(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=KG(o.pts-r.baseTime*a/r.timescale,t*a)/a,o.dts=KG(o.dts-i.baseTime*a/i.timescale,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function VG(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=KG(o.pts-r.baseTime*a/r.timescale,t*a)/a}mA(i=e.samples).call(i,(function(e,t){return e.pts-t.pts}));var l=e.samples;return e.samples=[],{samples:l}}}var jG,YG=Fc((function e(r,i,n,a){t(this,e),this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=n,this.cts=a,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:r?2:1,isNonSync:r?0:1}})),qG=function(){function e(r,i,n,a){t(this,e),this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=a}return Fc(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.lastEndTime=null}},{key:"resetNextTimestamp",value:function(){this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(!e||!t)return e;var r=t.keyId;if(r&&t.isCommonEncryption){var i=TN(e,["moov","trak"]);vd(i).call(i,(function(e){var t=TN(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=TN(t,["enca"]),n=i.length>0;n||(i=TN(t,["encv"])),vd(i).call(i,(function(e){var t=TN(n?e.subarray(28):e.subarray(78),["sinf"]);vd(t).call(t,(function(e){var t=DN(e);if(t){var i,a,s=t.subarray(8,24);KT(s).call(s,(function(e){return 0!==e}))||(xO.log(_d(i=_d(a="[eme] Patching keyId in 'enc".concat(n?"a":"v",">sinf>>tenc' box: ")).call(a,XF.hexDump(s)," -> ")).call(i,XF.hexDump(r))),t.set(r,8))}}))}))}))}return e}(e,i)),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=AN(e);i.audio&&(t=WG(i.audio,aN)),i.video&&(r=WG(i.video,sN));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}},{key:"remux",value:function(e,t,r,i,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};lO(u)||(u=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return c;var d={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,n=0,a=TN(e,["moof","traf"]),s=0;s<a.length;s++){var o=a[s],l=TN(o,["tfhd"])[0],u=t[mN(l,4)];if(u){var c=u.default,h=mN(l,0)|(null==c?void 0:wC(c)),d=null==c?void 0:c.duration;8&h&&(d=mN(l,2&h?12:8));for(var f=u.timescale||9e4,v=TN(o,["trun"]),g=0;g<v.length;g++)!(r=_N(v[g]))&&d&&(r=d*mN(v[g],4)),u.type===sN?i+=r/f:u.type===aN&&(n+=r/f)}}if(0===i&&0===n){for(var p=1/0,m=0,y=0,E=TN(e,["sidx"]),k=0;k<E.length;k++){var T=SN(E[k]);if(null!=T&&T.references){var S;p=Math.min(p,T.earliestPresentationTime/T.timescale);var A=kC(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&&lO(y))return y}return i||n}(h,f),g=function(e,t){var r;return kC(r=TN(t,["moof","traf"])).call(r,(function(t,r){var i,n=TN(r,["tfdt"])[0],a=n[0],s=kC(i=TN(r,["tfhd"])).call(i,(function(t,r){var i=mN(r,4),s=e[i];if(s){var o=mN(n,4);if(1===a){if(o===dN)return xO.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=dN+1,o+=mN(n,8)}var l=o/(s.timescale||9e4);if(lO(l)&&(null===t||l<t))return l}return t}),null);return null!==s&&lO(s)&&(null===t||s<t)?s:t}),null)}(f,h),p=null===g?n:g;if(function(e,t,r,i){if(null===e)return!0;var n=Math.max(i,1),a=t-e.baseTime/e.timescale;return Math.abs(a-r)>n}(l,p,n,v)||d.timescale!==l.timescale&&a){var m,y;if(d.initPTS=p-n,l&&1===l.timescale)this.logger.warn(_d(m=_d(y="Adjusting initPTS @".concat(n," from ")).call(y,l.baseTime/l.timescale," to ")).call(m,d.initPTS));this.initPTS=l={baseTime:d.initPTS,timescale:1}}var E=e?p-l.baseTime/l.timescale:u,k=E+v;!function(e,t,r){var i;vd(i=TN(t,["moof","traf"])).call(i,(function(t){var i;vd(i=TN(t,["tfhd"])).call(i,(function(i){var n,a=mN(i,4),s=e[a];if(s){var o=s.timescale||9e4;vd(n=TN(t,["tfdt"])).call(n,(function(e){var t=e[0],i=r*o;if(i){var n=mN(e,4);if(0===t)n-=i,kN(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=mN(e,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(dN+1)),s=Math.floor(n%(dN+1));kN(e,4,a),kN(e,8,s)}}}))}}))}))}(f,h,l.baseTime/l.timescale),v>0?this.lastEndTime=k:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!f.audio,S=!!f.video,A="";T&&(A+="audio"),S&&(A+="video");var L={data1:h,startPTS:E,startDTS:E,endPTS:k,endDTS:k,type:A,hasAudio:T,hasVideo:S,nb:1,dropped:0};return c.audio="audio"===L.type?L:void 0,c.video="audio"!==L.type?L:void 0,c.initSegment=d,c.id3=HG(r,n,l,l),i.samples.length&&(c.text=VG(i,n,l)),c}}]),e}();function WG(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===aN){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return jO(r,!1)}return xO.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"}return xO.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1"}try{var zG;jG=sT(zG=self.performance.now).call(zG,self.performance)}catch(ZV){jG=SA}var XG=[{demux:mG,remux:qG},{demux:bG,remux:GG},{demux:hG,remux:GG},{demux:gG,remux:GG}];sg(XG).call(XG,2,0,{demux:fG,remux:GG});var QG=function(){function e(r,i,n,a,s,o){t(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=r,this.typeSupported=i,this.config=n,this.id=s,this.logger=o}return Fc(e,[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,r,i){var n=this,a=r.transmuxing;a.executeStart=jG();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,c=u.contiguous,h=u.discontinuity,d=u.trackSwitch,f=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,p=l.audioCodec,m=l.videoCodec,y=l.defaultInitPts,E=l.duration,k=l.initSegmentData,T=function(e,t){var r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(s,t);if(T&&nU(T.method)){var S=this.getDecrypter(),A=aU(T.method);if(!S.isSync())return this.asyncResult=!0,this.decryptionPromise=S.webCryptoDecrypt(s,T.key.buffer,T.iv.buffer,A).then((function(e){var t=n.push(e,null,r);return n.decryptionPromise=null,t})),this.decryptionPromise;var L=S.softwareDecrypt(s,T.key.buffer,T.iv.buffer,A);if(r.part>-1){var b=S.flush();L=b?b.buffer:b}if(!L)return a.executeEnd=jG(),$G(r);s=new Uint8Array(L)}var R=this.needsProbing(h,d);if(R){var I=this.configureTransmuxer(s);if(I)return this.logger.warn("[transmuxer] ".concat(I.message)),this.observer.emit(fO.ERROR,fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),a.executeEnd=jG(),$G(r)}(h||d||g||R)&&this.resetInitSegment(k,p,m,E,t),(h||g||R)&&this.resetInitialTimestamp(y),c||this.resetContiguity();var D=this.transmux(s,T,v,f,r);this.asyncResult=JG(D);var _=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,a.executeEnd=jG(),D}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=jG();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=jG();var h=[$G(e)];return this.asyncResult?nk.resolve(h):h}var d=u.flush(o);return JG(d)?(this.asyncResult=!0,d.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,d,e),this.asyncResult?nk.resolve(s):s)}},{key:"flushRemux",value:function(e,t,r){var i,n,a,s,o=t.audioTrack,l=t.videoTrack,u=t.id3Track,c=t.textTrack,h=this.currentTransmuxState,d=h.accurateTimeOffset,f=h.timeOffset;this.logger.log(_d(i=_d(n=_d(a=_d(s="[transmuxer.ts]: Flushed ".concat(this.id," sn: ")).call(s,r.sn)).call(a,r.part>-1?" part: "+r.part:""," of ")).call(n,this.id===yO?"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=jG()}},{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=XG.length;a<s;a++){var o;if(null!=(o=XG[a].demux)&&o.probe(e,this.logger)){t=XG[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 NN(this.config)),e}}]),e}();var $G=function(e){return{remuxResult:{},chunkMeta:e}};function JG(e){return"then"in e&&e.then instanceof Function}var ZG=Fc((function e(r,i,n,a,s){t(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=r,this.videoCodec=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=s||null})),eK=Fc((function e(r,i,n,a,s,o){t(this,e),this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=r,this.contiguous=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=s,this.initSegmentChange=o})),tK=0,rK=function(){function e(r,i,n,a){var s=this;t(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=tK++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(e){var t=e.data,r=s.hls;if(r&&null!=t&&t.event&&t.instanceNo===s.instanceNo)switch(t.event){case"init":var i,n=null==(i=s.workerContext)?void 0:i.objectURL;n&&gI.revokeObjectURL(n);break;case"transmuxComplete":s.handleTransmuxComplete(t.data);break;case"flush":s.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=s.frag,t.data.part=s.part,t.data.id=s.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){var t,r;if(s.hls){var i=new Error(_d(t=_d(r="".concat(e.message," (")).call(r,e.filename,":")).call(t,e.lineno,")"));s.hls.config.enableWorker=!1,s.hls.logger.warn('Error in "'.concat(s.id,'" Web Worker, fallback to inline')),s.hls.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})}};var o=r.config;this.hls=r,this.id=i,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var l=function(e,t){(t=t||{}).frag=s.frag||void 0,e===fO.ERROR&&(t.parent=s.id,t.part=s.part,s.error=t.error),s.hls.trigger(e,t)};this.observer=new LB,this.observer.on(fO.FRAG_DECRYPTED,l),this.observer.on(fO.ERROR,l);var u=WO(o.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var c=this.hls.logger;if(o.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{var h;if(o.workerPath)c.log(_d(h="loading Web Worker ".concat(o.workerPath,' for "')).call(h,i,'"')),this.workerContext=function(e){var t=RB[e];if(t)return t.clientCount++,t;var r=new gI(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return RB[e]=i,i}(o.workerPath);else c.log('injecting Web Worker for "'.concat(i,'"')),this.workerContext=function(){var e=RB[bB];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=gI.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return RB[bB]=i,i}();var d=this.workerContext.worker;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:u,id:i,config:jI(o)})}catch(ZV){c.warn('Error setting up "'.concat(i,'" Web Worker, fallback to inline'),ZV),this.terminateWorker(),this.error=null,this.transmuxer=new QG(this.observer,u,o,"",i,r.logger)}return}}this.transmuxer=new QG(this.observer,u,o,"",i,r.logger)}return Fc(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=tK++;var t=this.hls.config,r=WO(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:jI(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=RB[e||bB];if(t&&1==t.clientCount--){var r=t.worker,i=t.objectURL;delete RB[e||bB],i&&gI.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 eK(y,A,o,E,g,b);if(!A||y||b){var I,D,_,w,C,P,x,M,O,F,N;this.hls.logger.log(_d(I=_d(D=_d(_=_d(w=_d(C=_d(P=_d(x=_d(M=_d(O=_d(F=_d(N="[transmuxer-interface]: Starting new transmux session for ".concat(n.type," sn: ")).call(N,l.sn)).call(F,l.part>-1?" part: "+l.part:""," ")).call(O,this.id===yO?"level":"track",": ")).call(M,l.level," id: ")).call(x,l.id,"\n discontinuity: ")).call(P,y,"\n trackSwitch: ")).call(C,E,"\n contiguous: ")).call(w,A,"\n accurateTimeOffset: ")).call(_,o,"\n timeOffset: ")).call(D,g,"\n initSegmentChange: ")).call(I,b));var U=new ZG(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);JG(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);JG(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(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}},{key:"handleFlushResult",value:function(e,t){var r=this;vd(e).call(e,(function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}]),e}();function iK(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!nK(e[r].attrs,t[r].attrs))return!1;return!0}function nK(e,t,r){var i,n=e["STABLE-RENDITION-ID"];return n&&!r?n===t["STABLE-RENDITION-ID"]:!KT(i=r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).call(i,(function(r){return e[r]!==t[r]}))}function aK(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var sK=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"audio-stream-controller",EO)).mainAnchor=null,s.mainFragLoading=null,s.audioOnly=!1,s.bufferedTrack=null,s.switchingTrack=null,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.flushing=!1,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(fO.BUFFER_RESET,this.onBufferReset,this),e.on(fO.BUFFER_CREATED,this.onBufferCreated,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(fO.FRAG_LOADING,this.onFragLoading,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(Ih(Rh(i.prototype),"unregisterListeners",this).call(this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(fO.BUFFER_RESET,this.onBufferReset,this),e.off(fO.BUFFER_CREATED,this.onBufferCreated,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(fO.FRAG_LOADING,this.onFragLoading,this),e.off(fO.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===yO){var s,o,l=r.cc,u=this.fragCurrent;if(this.initPTS[l]={baseTime:n,timescale:a},this.log(_d(s=_d(o="InitPTS for cc: ".concat(l," found from main: ")).call(o,n,"/")).call(s,a)),this.mainAnchor=r,this.state===EB){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===cB&&this.tick()}}},{key:"findSyncFrag",value:function(e){var t=this.getLevelDetails(),r=e.cc;return function(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var i=r.start,n=r.end,a=e.fragments;if(!r.relurl){var s=e.fragmentHint;s&&(a=_d(a).call(a,s))}return pF(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&&kF(t.fragments,r)||e}},{key:"startLoad",value:function(e){if(!this.levels)return this.startPosition=e,void(this.state=uB);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=cB):this.state=vB,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case cB:this.doTickIdle();break;case vB:var e=this.levels,t=this.trackId,r=null==e?void 0:e[t],n=null==r?void 0:r.details;if(n&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(n))break;this.state=EB}break;case fB: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=cB}break;case EB:var c=this.waitingData;if(c){var h=c.frag,d=c.part,f=c.cache,v=c.complete,g=this.mainAnchor;if(void 0!==this.initPTS[h.cc]){this.waitingData=null,this.state=dB;var p={frag:h,part:d,payload:f.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(p),v&&Ih(Rh(i.prototype),"_handleFragmentLoadComplete",this).call(this,p)}else if(g&&g.cc!==c.frag.cc){var m;this.log(_d(m="Waiting fragment cc (".concat(h.cc,") cancelled because video is at cc ")).call(m,g.cc)),this.nextLoadPosition=this.findSyncFrag(g).start,this.clearWaitingFragment()}}else this.state=cB}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!==uB&&(this.state=cB))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),Ih(Rh(i.prototype),"resetLoadingState",this).call(this)}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,r=this.levels,i=this.media,n=this.trackId,a=t.config;if(this.buffering&&(i||!this.startFragRequested&&a.startFragPrefetch)&&null!=r&&r[n]){var s=r[n],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=vB,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,aN,EO));var u=this.getFwdBufferInfo(l,EO);if(null!==u){var c=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(u,o))return t.trigger(fO.BUFFER_EOS,{type:"audio"}),void(this.state=mB);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&&!nK(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,yO,f)),E){var k=null==(e=this.mainFragLoading)?void 0:e.frag;if(!this.audioOnly&&this.startFragRequested&&k&&uN(k)&&uN(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,yO);S&&S.end>k.end&&(T=S,this.mainFragLoading={frag:S,targetBufferTime:null})}if(E.start>T.end)return}this.loadFragment(E,s,m)}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,t){this.bufferFlushed=this.flushing=!1,Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=Pk(r).call(r,(function(e){return new nF(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!==uB&&(this.setInterval(100),this.state=cB,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.hls.trigger(fO.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!==uB&&(this.state=vB));if(l){this.log(_d(r=_d(i=_d(n=_d(a="Audio track ".concat(c," loaded [")).call(a,u.startSN,",")).call(n,u.endSN,"]")).call(i,u.lastPartSn?_d(s="[part-".concat(u.lastPartSn,"-")).call(s,u.lastPartIndex,"]"):"",",duration:")).call(r,u.totalduration));var d=l[c],f=0;if(u.live||null!=(o=d.details)&&o.live){if(this.checkLiveUpdate(u),u.deltaUpdateFailed)return;var v;if(d.details)f=this.alignPlaylists(u,d.details,null==(v=this.levelLastLoaded)?void 0:v.details);u.alignedSliding||(sB(u,h),u.alignedSliding||oB(u,h),f=u.fragmentStart)}d.details=u,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(h,f),this.hls.trigger(fO.AUDIO_TRACK_UPDATED,{details:u,id:c,groupId:t.groupId}),this.state!==vB||this.waitForCdnTuneIn(u)||(this.state=cB),this.tick()}else this.warn("Audio tracks were reset while loading level ".concat(c))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var u=l.details;if(!u)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);var c,h,d=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",f=this.transmuxer;if(!f)f=this.transmuxer=new rK(this.hls,EO,sT(c=this._handleTransmuxComplete).call(c,this),sT(h=this._handleTransmuxerFlush).call(h,this));var v=this.initPTS[r.cc],g=null==(t=r.initSegment)?void 0:t.data;if(void 0!==v){var p=i?i.index:-1,m=-1!==p,y=new jN(r.level,r.sn,r.stats.chunkCount,n.byteLength,p,m);f.push(n,g,d,"",r,i,u.totalduration,!1,y,v)}else{var E,k,T,S;this.log(_d(E=_d(k=_d(T=_d(S="Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ")).call(S,r.sn," of [")).call(T,u.startSN," ,")).call(k,u.endSN,"],track ")).call(E,s)),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new SB,complete:!1}).cache.push(new Uint8Array(n)),this.state!==uB&&(this.state=EB)}}else this.warn("Audio track is undefined on fragment load progress")}else{var A;this.warn(_d(A="Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ")).call(A,r.level," will not be buffered"))}}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:Ih(Rh(i.prototype),"_handleFragmentLoadComplete",this).call(this,e)}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===yO&&uN(t.frag)&&(this.mainFragLoading=t,this.state===cB&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part;if(r.type===EO)if(this.fragContextChanged(r)){var n,a,s,o;this.warn(_d(n=_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state,", audioSwitch: ")).call(n,this.switchingTrack?this.switchingTrack.name:"false"))}else{if(uN(r)){this.fragPrevious=r;var l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(fO.AUDIO_TRACK_SWITCHED,RO({},l)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==yO||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=yB;else switch(t.details){case dO.FRAG_GAP:case dO.FRAG_PARSING_ERROR:case dO.FRAG_DECRYPT_ERROR:case dO.FRAG_LOAD_ERROR:case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_ERROR:case dO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(EO,t);break;case dO.AUDIO_TRACK_LOAD_ERROR:case dO.AUDIO_TRACK_LOAD_TIMEOUT:case dO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==vB||(null==(r=t.context)?void 0:r.type)!==pO||(this.state=cB);break;case dO.BUFFER_APPEND_ERROR:case dO.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===dO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case dO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==sN&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==sN){this.flushing=!1,this.bufferFlushed=!0,this.state===mB&&(this.state=cB);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,r,EO),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=gB,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(fO.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[aN]={startPTS:p,endPTS:m,startDTS:y,endDTS:E}),o.setElementaryStreamInfo(aN,p,m,y,E),this.bufferFragmentData(h,o,l,a)}if(null!=f&&null!=(t=f.samples)&&t.length){var k=LO({id:r,frag:o,details:c},f);i.trigger(fO.FRAG_PARSING_METADATA,k)}if(d){var T=LO({id:r,frag:o,details:c},d);i.trigger(fO.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===gB&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var s=t.audio;s.id="audio";var o=e.audioCodec;this.log(_d(n=_d(a="Init audio buffer, container:".concat(s.container,", codecs[level/parsed]=[")).call(a,o,"/")).call(n,s.codec,"]")),o&&1===o.split(",").length&&(s.levelCodec=o),this.hls.trigger(fO.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(fO.BUFFER_APPENDING,u)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,t,r){var n,a=this.fragmentTracker.getState(e);if(this.switchingTrack||a===OF||a===NF)if(uN(e))if(null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]){var s,o;this.log(_d(s=_d(o="Waiting for video PTS in continuity counter ".concat(e.cc," of live stream before loading audio fragment ")).call(o,e.sn," of level ")).call(s,this.trackId)),this.state=EB;var l=this.mainDetails;l&&l.fragmentStart!==t.details.fragmentStart&&oB(t.details,l)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){var t=this.media,r=this.bufferedTrack,n=null==r?void 0:r.attrs,a=e.attrs;t&&n&&(n.CHANNELS!==a.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(fO.AUDIO_TRACK_SWITCHED,RO({},e))}}]),i}(TB),oK=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n,e.logger)).hls=void 0,a.canLoad=!1,a.timer=-1,a.hls=e,a}return Fc(i,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var n=-1,a=0;a<i.length;a++){var s=i[a],o=void 0;try{o=new gI(s.URI,t.url).href}catch(JV){this.warn("Could not construct new URL for Rendition Report: ".concat(JV)),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=Rk(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),c=Rk(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&&rF(r);return new iF(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(JV){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(JV))}return e}},{key:"playlistLoaded",value:function(e,t,r){var i=t.details,n=t.stats,a=self.performance.now(),s=n.loading.first?Math.max(0,a-n.loading.first):0;i.advancedDateTime=SA()-s;var o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){var l,u=Math.max(o||0,0);i.appliedTimelineOffset=u,vd(l=i.fragments).call(l,(function(e){e.start=e.playlistOffset+u}))}if(i.live||null!=r&&r.live){var c,h="levelInfo"in t?t.levelInfo:t.track;i.reloaded(r),r&&i.fragments.length>0&&QU(r,i),-1===i.requestScheduled&&(i.requestScheduled=n.loading.start);var d,f=this.hls.mainForwardBufferInfo,v=f?f.end-f.len:0,g=ZU(i,1e3*(i.edge-v));if(i.requestScheduled+g<a?i.requestScheduled=a:i.requestScheduled+=g,this.log(_d(c="live playlist ".concat(e," ")).call(c,i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;var p=void 0,m=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var y=this.hls.config.lowLatencyMode,E=i.lastPartSn,k=i.endSN,T=i.lastPartIndex,S=E===k;-1!==T?S?(p=k+1,m=y?0:T):(p=E,m=y?T+1:i.maxPartIndex):p=k+1;var A=i.age,L=A+i.ageHeader,b=Math.min(L-i.partTarget,1.5*i.targetduration);if(b>0){if(L>3*i.targetduration)this.log("Playlist last advanced ".concat(A.toFixed(2),"s ago. Omitting segment and part directives.")),p=void 0,m=void 0;else if(null!=r&&r.tuneInGoal&&L-i.partTarget>r.tuneInGoal){var R,I;this.warn(_d(R=_d(I="CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ")).call(I,b," with playlist age: ")).call(R,i.age)),b=0}else{var D,_,w,C,P=Math.floor(b/i.targetduration);if(p+=P,void 0!==m)m+=Math.round(b%i.targetduration/i.partTarget);this.log(_d(D=_d(_=_d(w=_d(C="CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ")).call(C,A.toFixed(2),"s goal: ")).call(w,b," skip sn ")).call(_,P," to part ")).call(D,m))}i.tuneInGoal=b}if(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m),y||!S)return i.requestScheduled=a,void this.loadingPlaylist(h,d)}else(i.canBlockReload||i.canSkipUntil)&&(d=this.getDeliveryDirectives(i,t.deliveryDirectives,p,m));d&&void 0!==p&&i.canBlockReload&&(i.requestScheduled=n.loading.first+Math.max(g-2*s,g/2)),this.scheduleLoading(h,d,i)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,r){var i,n=this,a=r||e.details;if(a){var s=self.performance.now(),o=a.requestScheduled;if(s>=o)this.loadingPlaylist(e,t);else{var l=o-s;this.log(_d(i="reload live playlist ".concat(e.name||e.bitrate+"bps"," in ")).call(i,Math.round(l)," ms")),this.clearTimer(),this.timer=Wf((function(){return n.loadingPlaylist(e,t)}),l)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,i){var n=rF(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,n=ZO),new iF(r,i,n)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,i=TF(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===_F||!n.resolved&&s===IF);if(c){var h;if(l>=u.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives){var d,f;this.warn(_d(d=_d(f="Retrying playlist loading ".concat(l+1,"/")).call(f,u.maxNumRetry,' after "')).call(d,r,'" without delivery-directives')),this.loadPlaylist()}else{var v,g,p,m=AF(u,l);this.clearTimer(),this.timer=Wf((function(){return t.loadPlaylist()}),m),this.warn(_d(v=_d(g=_d(p="Retrying playlist loading ".concat(l+1,"/")).call(p,u.maxNumRetry,' after "')).call(g,r,'" in ')).call(v,m,"ms"))}e.levelRetry=!0,n.resolved=!0}return c}}]),i}(IO),lK=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e,"audio-track-controller")).tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVEL_LOADING,this.onLevelLoading,this),e.off(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fO.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(fO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var r,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Audio track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Audio track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.audioGroups||null,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&KT(r).call(r,(function(e){return-1===(null==i?void 0:av(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=xk(a=this.tracks).call(a,(function(e){return!r||-1!==av(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!KT(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.audioPreference;if(!n&&l){var u=cF(l,o,dF);if(u>-1)n=o[u];else{var c=cF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={audioTracks:o};this.log(_d(s="Updating audio tracks, ".concat(o.length," track(s) found in group(s): ")).call(s,null==r?void 0:r.join(","))),this.hls.trigger(fO.AUDIO_TRACKS_UPDATED,d);var f=this.trackId;if(-1!==h&&-1===f)this.setAudioTrack(h);else if(o.length&&-1===f){var v,g,p=new Error(_d(v="No audio track selected for current audio group-ID(s): ".concat(null==(g=this.groupIds)?void 0:g.join(",")," track count: ")).call(v,o.length));this.warn(p.message),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:p})}}}}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==pO||t.context.id!==this.trackId||this.groupIds&&-1===av(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"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&&hF(e,i,dF))return i;var n=cF(e,this.tracksInGroup,dF);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=kC(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=fF(t,i,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var i=t.audioGroups,a=xk(r).call(r,(function(e){return!i||-1!==av(i).call(i,e.groupId)}));return cF(e,a,n)>-1}));return c>-1?c:fF(t,i,(function(t){var i=t.audioGroups,a=xk(r).call(r,(function(e){return!i||-1!==av(i).call(i,e.groupId)}));return cF(e,a,n)>-1}))}(e,t.levels,r,s,dF);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=cF(e,r);if(l>-1)return r[l]}}}return null}},{key:"setAudioTrack",value:function(e){var t,r,i,n,a=this.tracksInGroup;if(e<0||e>=a.length)this.warn("Invalid audio track id: ".concat(e));else{this.selectDefaultTrack=!1;var s=this.currentTrack,o=a[e],l=o.details&&!o.details.live;if(!(e===this.trackId&&o===s&&l||(this.log(_d(t=_d(r=_d(i=_d(n="Switching to audio-track ".concat(e,' "')).call(n,o.name,'" lang:')).call(i,o.lang," group:")).call(r,o.groupId," channels:")).call(t,o.channels)),this.trackId=e,this.currentTrack=o,this.hls.trigger(fO.AUDIO_TRACK_SWITCHING,RO({},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||hF(e,i,dF)))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(hF({name:n,lang:a,assocLang:s,characteristics:o,audioCodec:l,channels:u},t[c],dF))return c}for(var h=0;h<t.length;h++){var d=t[h];if(nK(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var f=0;f<t.length;f++){var v=t[f];if(nK(e.attrs,v.attrs,["LANGUAGE"]))return f}}return-1}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this);var t=this.currentTrack;this.shouldLoadPlaylist(t)&&vF(t.url,this.hls)&&this.scheduleLoading(t,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading audio-track ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(fO.AUDIO_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}}]),i}(oK),uK=function(){function e(r){t(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=r}return Fc(e,[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,r){if(null!==this.queues&&null!==this.tracks){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){var t=this;return new nk((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 nk((function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}}))}},{key:"removeBlockers",value:function(){var e;null!==this.queues&&vd(e=[this.queues.video,this.queues.audio,this.queues.audiovideo]).call(e,(function(e){var t,r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),sg(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(JV){var i;if(r.onError(JV),null===this.queues||null===this.tracks)return;var n=null==(i=this.tracks[e])?void 0:i.buffer;null!=n&&n.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e,t,r=this.queues,i=this.tracks;return null===r||null===i?"<destroyed>":_d(e=_d(t="\n".concat(this.list("video"),"\n")).call(t,this.list("audio"),"\n")).call(e,this.list("audiovideo"),"}")}},{key:"list",value:function(e){var t,r,i,n;return null!=(i=this.queues)&&i[e]||null!=(n=this.tracks)&&n[e]?_d(t=_d(r="".concat(e,": (")).call(r,this.listSbInfo(e),") ")).call(t,this.listOps(e)):""}},{key:"listSbInfo",value:function(e){var t,r,i,n=null==(i=this.tracks)?void 0:i[e],a=null==n?void 0:n.buffer;return a?_d(t=_d(r="SourceBuffer".concat(a.updating?" updating":"")).call(r,n.ended?" ended":"")).call(t,n.ending?" ending":""):"none"}},{key:"listOps",value:function(e){var t,r;return(null==(r=this.queues)?void 0:Pk(t=r[e]).call(t,(function(e){return e.label})).join(", "))||""}}]),e}(),cK=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,hK="HlsJsTrackRemovedError",dK=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e)).name=hK,n}return Fc(i)}(tC(Error)),fK=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a,s;return t(this,i),(a=r.call(this,"buffer-controller",e.logger)).hls=void 0,a.fragmentTracker=void 0,a.details=null,a._objectUrl=null,a.operationQueue=null,a.bufferCodecEventsTotal=0,a.media=null,a.mediaSource=null,a.lastMpegAudioChunk=null,a.blockedAudioAppend=null,a.lastVideoAppendEnd=0,a.appendSource=void 0,a.transferData=void 0,a.overrides=void 0,a.appendErrors={audio:0,video:0,audiovideo:0},a.tracks={},a.sourceBuffers=[[null,null],[null,null]],a._onEndStreaming=function(e){var t;a.hls&&"open"===(null==(t=a.mediaSource)?void 0:t.readyState)&&a.hls.pauseBuffering()},a._onStartStreaming=function(e){a.hls&&a.hls.resumeBuffering()},a._onMediaSourceOpen=function(e){var t=Zh(a),r=t.media,i=t.mediaSource;e&&a.log("Media source opened"),r&&i&&(r.removeEventListener("emptied",a._onMediaEmptied),a.updateDuration(),a.hls.trigger(fO.MEDIA_ATTACHED,{media:r,mediaSource:i}),i.removeEventListener("sourceopen",a._onMediaSourceOpen),null!==a.mediaSource&&a.checkPendingTracks())},a._onMediaSourceClose=function(){a.log("Media source closed")},a._onMediaSourceEnded=function(){a.log("Media source ended")},a._onMediaEmptied=function(){var e,t=Zh(a),r=t.mediaSrc,i=t._objectUrl;r!==i&&a.error(_d(e="Media element src was set while attaching MediaSource (".concat(i," > ")).call(e,r,")"))},a.hls=e,a.fragmentTracker=n,a.appendSource=(s=MO(e.config.preferManagedMediaSource),"undefined"!=typeof self&&s===self.ManagedMediaSource),a.initTracks(),a.registerListeners(),a}return Fc(i,[{key:"hasSourceTypes",value:function(){return yv(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(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.BUFFER_RESET,this.onBufferReset,this),e.on(fO.BUFFER_APPENDING,this.onBufferAppending,this),e.on(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(fO.BUFFER_EOS,this.onBufferEos,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fO.FRAG_PARSED,this.onFragParsed,this),e.on(fO.FRAG_CHANGED,this.onFragChanged,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.BUFFER_RESET,this.onBufferReset,this),e.off(fO.BUFFER_APPENDING,this.onBufferAppending,this),e.off(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fO.BUFFER_EOS,this.onBufferEos,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fO.FRAG_PARSED,this.onFragParsed,this),e.off(fO.FRAG_CHANGED,this.onFragChanged,this),e.off(fO.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a,s,o=this.isQueued();if(n||o)this.warn(_d(a=_d(s="Transfering MediaSource with".concat(o?" operations in queue":"")).call(s,n?" updating SourceBuffer(s)":""," ")).call(a,this.operationQueue));this.operationQueue.destroy()}var l,u=this.transferData;!this.sourceBufferCount&&u&&u.mediaSource===r?LO(i,u.tracks):vd(l=this.sourceBuffers).call(l,(function(t){var r=fD(t,1)[0];r&&(i[r]=LO({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null}));return{media:t,mediaSource:r,tracks:i}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var r,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log("".concat(i," bufferCodec event(s) expected.")),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media,i=MO(this.appendSource);if(this.transferData=this.overrides=void 0,r&&i){var n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var a=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(a),n)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=gI.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,vK(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(JV){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r,i;this.log(_d(t="".concat((null==(r=this.transferData)?void 0:r.mediaSource)===e?"transferred":"created"," media source: ")).call(t,null==(i=e.constructor)?void 0:i.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this,t=this.media,r=this.transferData;if(r&&t){var i=this.tracks,n=r.tracks,a=n?yv(n):null,s=a?a.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(n&&a&&s){var l,u;if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(_d(l=_d(u="attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ")).call(u,jI(i,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ")).call(l,jI(n,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!OO(n,i)){var c,h,d;r.mediaSource=null,r.tracks=void 0;var f,v=t.currentTime,g=this.details,p=Math.max(v,(null==g?void 0:g.fragments[0].start)||0);return p-v>1?void this.log(_d(f="attachTransferred: waiting for playback to reach new tracks start time ".concat(v," -> ")).call(f,p)):(this.warn(_d(c=_d(h=_d(d='attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(yv(n),'"->"')).call(d,yv(i),'") start time: ')).call(h,p," currentTime: ")).call(c,v)),this.onMediaDetaching(fO.MEDIA_DETACHING,{}),this.onMediaAttaching(fO.MEDIA_ATTACHING,r),void(t.currentTime=p))}this.transferData=void 0,vd(a).call(a,(function(t){var r=t,i=n[r];if(i){var a=i.buffer;if(a){var s=e.fragmentTracker,o=i.id;if(s.hasFragments(o)||s.hasParts(o)){var l=qN.getBuffered(a);s.detectEvictedFragments(r,l,o,null,!0)}var u=gK(r),c=[r,a];e.sourceBuffers[u]=c,a.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,i)}}})),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var r=this,i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,s=this._objectUrl;if(a){if(this.log("media source ".concat(i?"transferring":"detaching")),i){var o;vd(o=this.sourceBuffers).call(o,(function(e){var t=fD(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(ZV){this.warn("onMediaDetaching: ".concat(ZV.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&&gI.revokeObjectURL(s),this.mediaSrc===s?(n.removeAttribute("src"),this.appendSource&&vK(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(fO.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){var e,t=this;vd(e=this.sourceBuffers).call(e,(function(e){var r=fD(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(ZV){this.warn("onBufferReset ".concat(e),ZV)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[gK(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 uK(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r,i=this,n=this.tracks,a=yv(t);this.log(_d(r='BUFFER_CODECS: "'.concat(a,'" (current SB count ')).call(r,this.sourceBufferCount,")"));var s,o="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),l=!o&&this.sourceBufferCount&&this.media&&KT(a).call(a,(function(e){return!n[e]}));o||l?this.warn(_d(s='Unsupported transition between "'.concat(yv(n),'" and "')).call(s,a,'" SourceBuffers')):(vd(a).call(a,(function(e){var r,a,s,o=t[e],l=o.id,u=o.codec,c=o.levelCodec,h=o.container,d=o.metadata,f=n[e],v=null==(r=i.transferData)||null==(a=r.tracks)?void 0:a[e],g=null!=v&&v.buffer?v:f,p=(null==g?void 0:g.pendingCodec)||(null==g?void 0:g.codec),m=null==g?void 0:g.levelCodec,y=!g||!!i.hls.config.assetPlayerId;f||(f=n[e]={buffer:void 0,listeners:[],codec:u,container:h,levelCodec:c,metadata:d,id:l});var E,k=YO(p,m),T=null==k?void 0:k.replace(cK,"$1"),S=YO(u,c),A=null==(s=S)?void 0:s.replace(cK,"$1");S&&(T!==A||y)&&("audio"===Bv(e).call(e,0,5)&&(S=jO(S,i.appendSource)),i.log(_d(E="switching codec ".concat(p," to ")).call(E,S)),S!==(f.pendingCodec||f.codec)&&(f.pendingCodec=S),f.container=h,i.appendChangeType(e,h,S))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e,t=this;return kC(e=yv(this.tracks)).call(e,(function(e,r){var i=t.tracks[r];return e[r]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e}),{})}},{key:"appendChangeType",value:function(e,t,r){var i,n=this,a=_d(i="".concat(t,";codecs=")).call(i,r),s={label:"change-type=".concat(a),execute:function(){var i=n.tracks[e];if(i){var s,o=i.buffer;if(null!=o&&o.changeType)n.log(_d(s="changing ".concat(e," sourceBuffer type to ")).call(s,a)),o.changeType(a),i.codec=r,i.container=t}n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){n.warn("Failed to change ".concat(e," SourceBuffer type"),t)}};this.append(s,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,r=this,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,yO))?void 0:t.gap))){var a={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>n||null!=t&&t.buffer&&qN.isBuffered(t.buffer,n)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(n,yO))?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||qN.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&&!qN.isBuffered(y,A)&&this.lastVideoAppendEnd<A&&this.blockAudio(E):this.blockAudio(E)}}var R=(l||o).start,I={label:"append-".concat(a),execute:function(){if(c.executeStart=self.performance.now(),p){var e=r.tracks[a];if(e){var t=e.buffer;if(t){var i,s,o=R-t.timestampOffset;if(Math.abs(o)>=.1)r.log(_d(i=_d(s="Updating audio SourceBuffer timestampOffset to ".concat(R," (delta: ")).call(s,o,") sn: ")).call(i,h,")")),t.timestampOffset=R}}}r.appendExecutor(n,a)},onStart:function(){},onComplete:function(){var e,t=self.performance.now();c.executeEnd=c.end=t,0===f.first&&(f.first=t),v&&0===v.first&&(v.first=t);var i={};vd(e=r.sourceBuffers).call(e,(function(e){var t=fD(e,2),r=t[0],n=t[1];r&&(i[r]=qN.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(fO.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:i})},onError:function(e){var t,i={type:hO.MEDIA_ERROR,parent:o.type,details:dO.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=dO.BUFFER_FULL_ERROR;else if(e.code!==DOMException.INVALID_STATE_ERR||!r.mediaSourceOpenOrEnded||null!=(t=r.media)&&t.error)if(e.name===hK)0===r.sourceBufferCount?i.errorAction=MF(!0):++r.appendErrors[a];else{var n,s,c=++r.appendErrors[a];r.warn(_d(n=_d(s="Failed ".concat(c,"/")).call(s,r.hls.config.appendErrorMaxRetry,' times to append segment in "')).call(n,a,'" sourceBuffer')),c>=r.hls.config.appendErrorMaxRetry&&(i.fatal=!0)}else i.errorAction=MF(!0);r.hls.trigger(fO.ERROR,i)}};this.append(I,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,r){var i,n,a=this;return this.log(_d(i=_d(n='queuing "'.concat(e,'" remove ')).call(n,t,"-")).call(i,r)),{label:"remove",execute:function(){a.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){a.hls.trigger(fO.BUFFER_FLUSHED,{type:e})},onError:function(i){var n,s;a.warn(_d(n=_d(s="Failed to remove ".concat(t,"-")).call(s,r,' from "')).call(n,e,'" SourceBuffer'),i)}}}},{key:"onBufferFlushing",value:function(e,t){var r,i=this,n=t.type,a=t.startOffset,s=t.endOffset;n?this.append(this.getFlushOp(n,a,s),n):vd(r=this.sourceBuffers).call(r,(function(e){var t=fD(e,1)[0];t&&i.append(i.getFlushOp(t,a,s),t)}))}},{key:"onFragParsed",value:function(e,t){var r=this,i=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[oN]?a.push("audiovideo"):(s[aN]&&a.push("audio"),s[sN]&&a.push("video"));var o,l;0===a.length&&this.warn(_d(o=_d(l="Fragments must have at least one ElementaryStreamType set. type: ".concat(i.type," level: ")).call(l,i.level," sn: ")).call(o,i.sn));this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;r.hls.trigger(fO.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})}),a)}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var e,t=this;return this.sourceBufferCount>0&&!KT(e=this.sourceBuffers).call(e,(function(e){var r,i,n=fD(e,1)[0];return n&&(!(null!=(r=t.tracks[n])&&r.ended)||(null==(i=t.tracks[n])?void 0:i.ending))}))}},{key:"onBufferEos",value:function(e,t){var r,i,n,a=this;vd(r=this.sourceBuffers).call(r,(function(e){var r=fD(e,1)[0];if(r){var i=a.tracks[r];t.type&&t.type!==r||(i.ending=!0,i.ended||(i.ended=!0,a.log("".concat(r," buffer reached EOS"))))}}));var s=!1!==(null==(n=this.overrides)?void 0:n.endOfStream);this.sourceBufferCount>0&&!KT(i=this.sourceBuffers).call(i,(function(e){var t,r=fD(e,1)[0];return r&&!(null!=(t=a.tracks[r])&&t.ended)}))&&(this.log("Queueing EOS"),this.blockUntilOpen((function(){var e;if(vd(e=a.sourceBuffers).call(e,(function(e){var t=fD(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(fO.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===dO.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;lO(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(lO(s)&&s>=0){var o=Math.max(s,a),l=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,l)}if(lO(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var u=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),c=Math.max(u,a),h=Math.floor(n/a)*a+c;this.flushFrontBuffer(n,a,h)}}}},{key:"flushBackBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=fD(i,2),s=a[0],o=a[1];if(o){var l=qN.getBuffered(o);if(l.length>0&&r>l.start(0)){var u;n.hls.trigger(fO.BACK_BUFFER_REACHED,{bufferEnd:r});var c=n.tracks[s];if(null!=(u=n.details)&&u.live)n.hls.trigger(fO.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(fO.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}},{key:"flushFrontBuffer",value:function(e,t,r){var i,n=this;vd(i=this.sourceBuffers).call(i,(function(i){var a=fD(i,2),s=a[0],o=a[1];if(o){var l=qN.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(fO.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>(lO(r.duration)?r.duration:0)&&i>s||!lO(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&&(lO(i)&&this.log("Updating MediaSource duration to ".concat(i.toFixed(3))),s.duration=i),void 0!==n&&void 0!==a&&(this.log(_d(t=_d(r="MediaSource duration is set to ".concat(s.duration,". Setting seekable range to ")).call(r,n,"-")).call(t,a,".")),s.setLiveSeekableRange(n,a)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e,t,r=this.bufferCodecEventsTotal,i=this.pendingTrackCount,n=this.tracks;if(this.log(_d(e=_d(t="checkPendingTracks (pending: ".concat(i," codec events expected: ")).call(t,r,") ")).call(e,jI(n))),this.tracksReady){var a,s=null==(a=this.transferData)?void 0:a.tracks;s&&yv(s).length?this.attachTransferred():(this.createSourceBuffers(),this.bufferCreated())}}},{key:"bufferCreated",value:function(){var e=this;if(this.sourceBufferCount){var t,r,i={};vd(t=this.sourceBuffers).call(t,(function(t){var r=fD(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(fO.BUFFER_CREATED,{tracks:i}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),vd(r=this.sourceBuffers).call(r,(function(t){var r=fD(t,1)[0];e.executeNext(r)}))}else{var n=new Error("could not create source buffer for media codec(s)");this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,r=this.mediaSource;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(var i in e){var n=i,a=e[n];if(this.isPending(a)){var s,o,l,u=this.getTrackCodec(a,n),c=_d(s="".concat(a.container,";codecs=")).call(s,u);a.codec=u,this.log(_d(o=_d(l="creating sourceBuffer(".concat(c,")")).call(l,this.currentOp(n)?" Queued":""," ")).call(o,jI(a)));try{var h=r.addSourceBuffer(c),d=gK(n),f=[n,h];t[d]=f,a.buffer=h}catch(JV){this.error("error while trying to add sourceBuffer: ".concat(JV.message)),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:JV,sourceBufferName:n,mimeType:c});break}this.trackSourceBuffer(n,a)}}}},{key:"getTrackCodec",value:function(e,t){var r=YO(e.codec,e.levelCodec);return r?"audio"===Bv(t).call(t,0,5)?jO(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(fO.BUFFER_FLUSHED,{type:e})}))}}},{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var r,i,n=new Error(_d(r="".concat(e," SourceBuffer error. MediaSource readyState: ")).call(r,null==(i=this.mediaSource)?void 0:i.readyState));this.error("".concat(n),t),this.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"removeExecutor",value:function(e,t,r){var i=this.media,n=this.mediaSource,a=this.tracks[e],s=null==a?void 0:a.buffer;if(!i||!n||!s)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var o,l,u=lO(i.duration)?i.duration:1/0,c=lO(n.duration)?n.duration:1/0,h=Math.max(0,t),d=Math.min(r,u,c);d>h&&(!a.ending||a.ended)?(a.ended=!1,this.log(_d(o=_d(l="Removing [".concat(h,",")).call(l,d,"] from the ")).call(o,e," SourceBuffer")),s.remove(h,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new dK("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));r.ending=!1,r.ended=!1,i.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()}},{key:"isUpdating",value:function(){var e;return KT(e=this.sourceBuffers).call(e,(function(e){var t=fD(e,2),r=t[0],i=t[1];return r&&i.updating}))}},{key:"isQueued",value:function(){var e,t=this;return KT(e=this.sourceBuffers).call(e,(function(e){var r=fD(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 nk.resolve().then(e);var i=this.operationQueue,n=Pk(r).call(r,(function(e){return t.appendBlocker(e)}));r.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),nk.all(n).then((function(n){i===t.operationQueue&&(e(),t.stepOperationQueue(r))}))}},{key:"stepOperationQueue",value:function(e){var t=this;vd(e).call(e,(function(e){var r,i=null==(r=t.tracks[e])?void 0:r.buffer;i&&!i.updating&&t.shiftAndExecuteNext(e)}))}},{key:"append",value:function(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){var e,t=this;return kC(e=yv(this.tracks)).call(e,(function(e,r){return e+(t.isPending(t.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){var e;return kC(e=this.sourceBuffers).call(e,(function(e,t){return e+(fD(t,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){var e,t;return xk(e=Pk(t=this.sourceBuffers).call(t,(function(e){return fD(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=sT(r).call(r,this,e);i.listeners.push({event:t,listener:a}),n.addEventListener(t,a)}}}},{key:"removeBufferListeners",value:function(e){var t,r=this.tracks[e];if(r){var i=r.buffer;i&&(vd(t=r.listeners).call(t,(function(e){i.removeEventListener(e.event,e.listener)})),r.listeners.length=0)}}}]),i}(IO);function vK(e){var t,r=e.querySelectorAll("source");vd(t=Bv([]).call(r)).call(t,(function(t){e.removeChild(t)}))}function gK(e){return"audio"===e?1:0}var pK=function(){function e(r){t(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=r,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return Fc(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(fO.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fO.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&&lO(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t,r,i,n,a=this.hls,s=this.getMaxLevel(e.length-1);if(s!==this.autoLevelCapping)a.logger.log(_d(t=_d(r=_d(i=_d(n="Setting autoLevelCapping to ".concat(s,": ")).call(n,e[s].height,"p@")).call(i,e[s].bitrate," for media ")).call(r,this.mediaWidth,"x")).call(t,this.mediaHeight));a.autoLevelCapping=s,a.autoLevelEnabled&&a.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=a.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=xk(i).call(i,(function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){var e;this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=lS(sT(e=this.detectPlayerSize).call(e,this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(t){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){var t=this.restrictedLevels;return!KT(t).call(t,(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(null==e||!e.length)return-1;for(var i,n,a=e.length-1,s=Math.max(t,r),o=0;o<e.length;o+=1){var l=e[o];if((l.width>=s||l.height>=s)&&(i=l,!(n=e[o+1])||i.width!==n.width||i.height!==n.height)){a=o;break}}return a}}]),e}(),mK={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},yK={DASH:"d",HLS:"h",SMOOTH:"s",OTHER:"o"},EK={OBJECT:"CMCD-Object",REQUEST:"CMCD-Request",SESSION:"CMCD-Session",STATUS:"CMCD-Status"},kK=(Lf(jM={},EK.OBJECT,["br","d","ot","tb"]),Lf(jM,EK.REQUEST,["bl","dl","mtp","nor","nrr","su"]),Lf(jM,EK.SESSION,["cid","pr","sf","sid","st","v"]),Lf(jM,EK.STATUS,["bs","rtp"]),jM),TK=Fc((function e(r,i){t(this,e),lv(r)&&(r=Pk(r).call(r,(function(t){return t instanceof e?t:new e(t)}))),this.value=r,this.params=i})),SK="Dict";function AK(e,t,r,i){var n,a,s;return new Error(_d(n=_d(a="failed to ".concat(e,' "')).call(a,(s=t,lv(s)?jI(s):s instanceof rP?"Map{}":s instanceof YM?"Set{}":"object"===Cc(s)?jI(s):String(s)),'" as ')).call(n,r),{cause:i})}function LK(e,t,r){return AK("serialize",e,t,r)}var bK=Fc((function e(r){t(this,e),this.description=r})),RK="Bare Item",IK="Boolean";var DK="Byte Sequence";function _K(e){if(!1===ArrayBuffer.isView(e))throw LK(e,DK);return":".concat((t=e,btoa(String.fromCharCode.apply(String,dD(t)))),":");var t}var wK="Integer";function CK(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw LK(e,wK);return e.toString()}var PK="Decimal";function xK(e){var t=KB(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw LK(e,PK);var r=t.toString();return uD(r).call(r,".")?r:"".concat(r,".0")}var MK="String",OK=/[\x00-\x1f\x7f]+/;var FK="Token";function NK(e){var t,r,i=(t=e).description||Bv(r=t.toString()).call(r,7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw LK(i,FK);return i}function UK(e){switch(Cc(e)){case"number":if(!lO(e))throw LK(e,RK);return zI(e)?CK(e):xK(e);case"string":return function(e){if(OK.test(e))throw LK(e,MK);return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(e);case"symbol":return NK(e);case"boolean":return function(e){if("boolean"!=typeof e)throw LK(e,IK);return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return"@".concat(CK(e.getTime()/1e3))}(e);if(e instanceof Uint8Array)return _K(e);if(e instanceof bK)return NK(e);default:throw LK(e,RK)}}var BK="Key";function GK(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw LK(e,BK);return e}function KK(e){var t;return null==e?"":Pk(t=GI(e)).call(t,(function(e){var t,r=fD(e,2),i=r[0],n=r[1];return!0===n?";".concat(GK(i)):_d(t=";".concat(GK(i),"=")).call(t,UK(n))})).join("")}function HK(e){var t;return e instanceof TK?_d(t="".concat(UK(e.value))).call(t,KK(e.params)):UK(e)}function VK(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!==Cc(e))throw LK(e,SK);var i=e instanceof rP?ZM(e).call(e):GI(e),n=(null==r?void 0:r.whitespace)?" ":"";return Pk(t=LT(i)).call(t,(function(e){var t=fD(e,2),r=t[0],i=t[1];i instanceof TK==!1&&(i=new TK(i));var n,a,s,o=GK(r);return!0===i.value?o+=KK(i.params):(o+="=",lv(i.value)?o+=_d(a="(".concat(Pk(s=(n=i).value).call(s,HK).join(" "),")")).call(a,KK(n.params)):o+=HK(i)),o})).join(",".concat(n))}var jK=function(e){return Math.round(e)},YK=function(e){return 100*jK(e/100)},qK={br:jK,d:jK,bl:YK,dl:YK,mtp:YK,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=function(e,t){var r,i,n=new gI(e),a=new gI(t);if(n.origin!==a.origin)return e;for(var s=Bv(r=n.pathname.split("/")).call(r,1),o=Bv(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:YK,tb:jK};function WK(e,t){var r,i={};if(null==e||"object"!==Cc(e))return i;var n=mA(r=yv(e)).call(r),a=LO({},qK,null==t?void 0:t.formatters),s=null==t?void 0:xk(t);return vd(n).call(n,(function(r){if(!(null==s?void 0:s(r))){var n=e[r],o=a[r];o&&(n=o(n,t)),"v"===r&&1===n||"pr"==r&&1===n||function(e){return"number"==typeof e?lO(e):null!=e&&""!==e&&!1!==e}(n)&&(function(e){return"ot"===e||"sf"===e||"st"===e}(r)&&"string"==typeof n&&(n=new bK(n)),i[r]=n)}})),i}function zK(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?function(e,t){return VK(e,t)}(WK(e,t),LO({whitespace:!1},t)):""}function XK(e,t,r){return LO(e,function(e){var t,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={};if(!e)return n;var a=GI(e),s=_d(t=GI(kK)).call(t,GI((null==i?void 0:i.customHeaderMap)||{})),o=kC(a).call(a,(function(e,t){var r,i,n=fD(t,2),a=n[0],o=n[1],l=(null===(r=mv(s).call(s,(function(e){var t;return uD(t=e[1]).call(t,a)})))||void 0===r?void 0:r[0])||EK.REQUEST;return null!==(i=e[l])&&void 0!==i||(e[l]={}),e[l][a]=o,e}),{});return kC(r=GI(o)).call(r,(function(e,t){var r=fD(t,2),n=r[0],a=r[1];return e[n]=zK(a,i),e}),n)}(t,r))}var QK="CMCD";var $K=/CMCD=[^&#]+/;function JK(e,t,r){var i,n,a=function(e){if(!e)return"";var t=zK(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});return"".concat(QK,"=").concat(encodeURIComponent(t))}(t,r);if(!a)return e;if($K.test(e))return e.replace($K,a);var s=uD(e).call(e,"?")?"&":"?";return _d(i=_d(n="".concat(e)).call(n,s)).call(i,a)}var ZK=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){i.initialized&&(i.starved=!0),i.buffering=!0},this.onPlaying=function(){i.initialized||(i.initialized=!0),i.buffering=!1},this.applyPlaylistData=function(e){try{i.apply(e,{ot:mK.MANIFEST,su:!i.initialized})}catch(JV){i.hls.logger.warn("Could not generate manifest CMCD data.",JV)}},this.applyFragmentData=function(e){try{var t=e.frag,r=e.part,n=i.hls.levels[t.level],a=i.getObjectType(t),s={d:1e3*(r||t).duration,ot:a};a!==mK.VIDEO&&a!==mK.AUDIO&&a!=mK.MUXED||(s.br=n.bitrate/1e3,s.tb=i.getTopBandwidth(a)/1e3,s.bl=i.getBufferLength(a));var o=r?i.getNextPart(r):i.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),i.apply(e,s)}catch(JV){i.hls.logger.warn("Could not generate segment CMCD data.",JV)}},this.hls=r;var n=this.config=r.config,a=n.cmcd;null!=a&&(n.pLoader=this.createPlaylistLoader(),n.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||r.sessionId,this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.includeKeys=a.includeKeys,this.registerListeners())}return Fc(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHED,this.onMediaDetached,this),e.on(fO.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHED,this.onMediaDetached,this),e.off(fO.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:yK.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};LO(t,this.createData());var r=t.ot===mK.INIT||t.ot===mK.VIDEO||t.ot===mK.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var i,n=this.includeKeys;n&&(t=kC(i=yv(t)).call(i,(function(e,r){return uD(n).call(n,r)&&(e[r]=t[r]),e}),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),XK(e.headers,t,a)):e.url=JK(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){var i=e.sn-r.startSN;return r.fragments[i+1]}}},{key:"getNextPart",value:function(e){var t,r,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(r=t.details)?void 0:r.partList;if(a)for(var s=n.sn,o=a.length-1;o>=0;o--){var l=a[o];if(l.index===i&&l.fragment.sn===s)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?mK.TIMED_TEXT:"initSegment"===e.sn?mK.INIT:"audio"===t?mK.AUDIO:"main"===t?this.hls.audioTracks.length?mK.VIDEO:mK.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,i=this.hls;if(e===mK.AUDIO)t=i.audioTracks;else{var n,a=i.maxAutoLevel,s=a>-1?a+1:i.levels.length;t=Bv(n=i.levels).call(n,0,s)}var o,l=function(e,t){var r=void 0!==hc&&$k(e)||e["@@iterator"];if(!r){if(ov(e)||(r=hD(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(ZV){l.e(ZV)}finally{l.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===mK.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*qN.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,r=this.applyPlaylistData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,r=this.applyFragmentData,i=e||this.config.loader;return function(){function e(r){t(this,e),this.loader=void 0,this.loader=new i(r)}return Fc(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,t,i){r(e),this.loader.load(e,t,i)}}]),e}()}}]),e}(),eH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"content-steering",e.logger)).hls=void 0,n.loader=null,n.uri=null,n.pathwayId=".",n._pathwayPriority=null,n.timeToLoad=300,n.reloadTimer=-1,n.updated=0,n.started=!1,n.enabled=!0,n.levels=null,n.audioTracks=null,n.subtitleTracks=null,n.penalizedPathways={},n.hls=e,n.registerListeners(),n}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.ERROR,this.onError,this))}},{key:"pathways",value:function(){var e;return kC(e=this.levels||[]).call(e,(function(e,t){return-1===av(e).call(e,t.pathwayId)&&e.push(t.pathwayId),e}),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=xk(t).call(t,(function(t){return t!==e})))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===IF&&wC(r)===CF){var i,n,a,s,o,l=this.levels,u=this._pathwayPriority,c=this.pathwayId;if(t.context){var h=t.context,d=h.groupId,f=h.pathwayId,v=h.type;d&&l?c=this.getPathwayForGroupId(d,v,c):f&&(c=f)}if(c in this.penalizedPathways||(this.penalizedPathways[c]=performance.now()),!u&&l&&(u=this.pathways()),u&&u.length>1&&(this.updatePathwayPriority(u),r.resolved=this.pathwayId!==c),!r.resolved)this.warn(_d(i=_d(n=_d(a=_d(s=_d(o="Could not resolve ".concat(t.details,' ("')).call(o,t.error.message,'") with content-steering for Pathway: ')).call(s,c," levels: ")).call(a,l?l.length:l," priorities: ")).call(n,jI(u)," penalized: ")).call(i,jI(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t,r,i=this.getLevelsForPathway(this.pathwayId);if(0===i.length){var n,a=e[0].pathwayId;this.log(_d(n="No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "')).call(n,a,'"')),i=this.getLevelsForPathway(a),this.pathwayId=a}i.length!==e.length&&this.log(_d(t=_d(r="Found ".concat(i.length,"/")).call(r,e.length,' levels in Pathway "')).call(t,this.pathwayId,'"'));return i}},{key:"getLevelsForPathway",value:function(e){var t;return null===this.levels?[]:xk(t=this.levels).call(t,(function(t){return e===t.pathwayId}))}},{key:"updatePathwayPriority",value:function(e){var t,r;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();vd(t=yv(i)).call(t,(function(e){n-i[e]>3e5&&delete i[e]}));for(var a=0;a<e.length;a++){var s=e[a];if(!(s in i)){if(s===this.pathwayId)return;var o=this.hls.nextLoadLevel,l=this.hls.levels[o];if((r=this.getLevelsForPathway(s)).length>0){this.log('Setting Pathway to "'.concat(s,'"')),this.pathwayId=s,rB(r),this.hls.trigger(fO.LEVELS_UPDATED,{levels:r});var u=this.hls.levels[o];if(l&&u&&this.levels){var c;if(u.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==l.bitrate)this.log(_d(c="Unstable Pathways change from bitrate ".concat(l.bitrate," to ")).call(c,u.bitrate));this.hls.nextLoadLevel=o}break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var i,n=_d(i=this.getLevelsForPathway(r)).call(i,this.levels||[]),a=0;a<n.length;a++)if(t===pO&&n[a].hasAudioGroup(e)||t===mO&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return r}},{key:"clonePathways",value:function(e){var t=this,r=this.levels;if(r){var i={},n={};vd(e).call(e,(function(e){var a,s=e.ID,o=e["BASE-ID"],l=e["URI-REPLACEMENT"];if(!KT(r).call(r,(function(e){return e.pathwayId===s}))){var u=Pk(a=t.getLevelsForPathway(o)).call(a,(function(e){var t,r,a=new eU(e.attrs);a["PATHWAY-ID"]=s;var o=a.AUDIO&&_d(t="".concat(a.AUDIO,"_clone_")).call(t,s),u=a.SUBTITLES&&_d(r="".concat(a.SUBTITLES,"_clone_")).call(r,s);o&&(i[a.AUDIO]=o,a.AUDIO=o),u&&(n[a.SUBTITLES]=u,a.SUBTITLES=u);var c=rH(e.uri,a["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),h=new nF({attrs:a,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:c,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++){var f;h.addGroupId("audio",_d(f="".concat(e.audioGroups[d],"_clone_")).call(f,s))}if(e.subtitleGroups)for(var v=1;v<e.subtitleGroups.length;v++){var g;h.addGroupId("text",_d(g="".concat(e.subtitleGroups[v],"_clone_")).call(g,s))}return h}));r.push.apply(r,dD(u)),tH(t.audioTracks,i,l,s),tH(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 gI(e)}catch(JV){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 gI(o,t).href}catch(JV){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(fO.STEERING_MANIFEST_LOADED,c),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION ".concat(s.VERSION," not supported!"))},onError:function(e,t,i,n){var a,s;if(r.log(_d(a=_d(s="Error loading steering manifest: ".concat(e.code," ")).call(s,e.text," (")).call(a,t.url,")")),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest ".concat(t.url," no longer available"));var o=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,o);else{var l=r.loader;if("function"==typeof(null==l?void 0:l.getResponseHeader)){var u=l.getResponseHeader("Retry-After");u&&(o=1e3*bS(u))}r.log("Steering manifest ".concat(t.url," rate limited"))}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest (".concat(t.url,")")),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: ".concat(t)),this.loader.load(s,u,c)}},{key:"scheduleRefresh",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3*this.timeToLoad;this.clearTimeout(),this.reloadTimer=Wf((function(){var r,i=null==(r=t.hls)?void 0:r.media;!i||i.ended?t.scheduleRefresh(e,1e3*t.timeToLoad):t.loadSteeringManifest(e)}),r)}}]),i}(IO);function tH(e,t,r,i){var n;e&&vd(n=yv(t)).call(n,(function(n){var a,s=Pk(a=xk(e).call(e,(function(e){return e.groupId===n}))).call(a,(function(e){var a=LO({},e);return a.details=void 0,a.attrs=new eU(a.attrs),a.url=a.attrs.URI=rH(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,dD(s))}))}function rH(e,t,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];t&&(n=null==o?void 0:o[t])&&(e=n);var l,u,c=new gI(e);(a&&!n&&(c.host=a),s)&&vd(l=mA(u=yv(s)).call(u)).call(l,(function(e){e&&c.searchParams.set(e,s[e])}));return c.href}var iH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,"eme",e.logger)).hls=void 0,n.config=void 0,n.media=null,n.keyFormatPromise=null,n.keySystemAccessPromises={},n._requestLicenseFailureCount=0,n.mediaKeySessions=[],n.keyIdToKeySessionPromise={},n.setMediaKeysQueue=i.CDMCleanupPromise?[i.CDMCleanupPromise]:[],n.onMediaEncrypted=function(e){var t,r=e.initDataType,i=e.initData,a=_d(t='"'.concat(e.type,'" event: init data type: "')).call(t,r,'"');if(n.debug(a),null!==i){var s,o;if("sinf"===r&&n.getLicenseServerUrl(hU)){var l=gN(new Uint8Array(i));try{var u=DN(sU(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=hU}catch(JV){var c;return void n.warn(_d(c="".concat(a," Failed to parse sinf: ")).call(c,JV))}}else if(n.getLicenseServerUrl(fU)){var h=function(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,i=0;i+32<r;){var n=FN(new DataView(e,i));t.push(n),i+=n.size}return t}(i),d=yv(n.keySystemAccessPromises);d.length||(d=bU(n.config));var f=xk(h).call(h,(function(e){var t=e.systemId?AU(e.systemId):null;return!!t&&av(d).call(d,t)>-1}))[0];if(!f){var v;if(0===h.length||KT(h).call(h,(function(e){return!e.systemId})))n.warn("".concat(a," contains incomplete or invalid pssh data"));else n.log(_d(v="ignoring ".concat(a," for ")).call(v,Pk(h).call(h,(function(e){return AU(e.systemId)})).join(",")," pssh data in favor of playlist keys"));return}if(o=AU(f.systemId),0===f.version&&f.data)if(o===fU){var g=f.data.length-22;s=f.data.subarray(g,g+16)}else o===dU&&(s=wU(f.data))}if(o&&s){for(var p=XF.hexDump(s),m=Zh(n),y=m.keyIdToKeySessionPromise,E=m.mediaKeySessions,k=y[p],T=function(){var e,t=E[S],a=t.decryptdata;if(!a.keyId)return"continue";var o=XF.hexDump(a.keyId);return p===o||-1!==av(e=a.uri.replace(/-/g,"")).call(e,p)?(k=y[o],a.pssh||(delete y[o],a.pssh=new Uint8Array(i),a.keyId=s,(k=y[p]=k.then((function(){return n.generateRequestWithPreferredKeySession(t,r,i,"encrypted-event-key-match")}))).catch((function(e){return n.handleError(e)}))),"break"):void 0},S=0;S<E.length;S++){var A=T();if("continue"!==A&&"break"===A)break}k||(k=y[p]=n.getKeySystemSelectionPromise([o]).then((function(e){var t,a=e.keySystem,o=e.mediaKeys;n.throwIfDestroyed();var l=new PU("ISO-23001-7",p,null!=(t=LU(a))?t:"");return l.pssh=new Uint8Array(i),l.keyId=s,n.attemptSetMediaKeys(a,o).then((function(){n.throwIfDestroyed();var e=n.createMediaKeySessionContext({decryptdata:l,keySystem:a,mediaKeys:o});return n.generateRequestWithPreferredKeySession(e,r,i,"encrypted-event-no-match")}))}))).catch((function(e){return n.handleError(e)}))}}},n.onWaitingForKey=function(e){n.log('"'.concat(e.type,'" event'))},n.hls=e,n.config=e.config,n.registerListeners(),n}return Fc(i,[{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(fO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(fO.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(fO.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===fU&&i?i:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error('no license server URL configured for key-system "'.concat(e,'"'));return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'.concat(e,'"]'))}},{key:"attemptKeySystemAccess",value:function(e){var t,r,i=this,n=this.hls.levels,a=function(e,t,r){return!!e&&av(r).call(r,e)===t},s=xk(t=Pk(n).call(n,(function(e){return e.audioCodec}))).call(t,a),o=xk(r=Pk(n).call(n,(function(e){return e.videoCodec}))).call(r,a);return s.length+o.length===0&&o.push("avc1.42e01e"),new nk((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 nH?t:new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.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===DU&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),nk.reject(new Error(i))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var i=this,n=_U(e,t,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e],s=null==a?void 0:a.keySystemAccess;if(!s){var o;this.log(_d(o='Requesting encrypted media "'.concat(e,'" key-system access with config: ')).call(o,jI(n))),s=this.requestMediaKeySystemAccess(e,n);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){var r;i.log(_d(r='Failed to obtain access to key-system "'.concat(e,'": ')).call(r,t))})),s.then((function(t){i.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=i.fetchServerCertificate(e);return i.log('Create media-keys for "'.concat(e,'"')),l.mediaKeys=t.createMediaKeys().then((function(t){return i.log('Media-keys created for "'.concat(e,'"')),r.then((function(r){return r?i.setMediaKeysServerCertificate(t,e,r):t}))})),l.mediaKeys.catch((function(t){var r;i.error(_d(r='Failed to create media-keys for "'.concat(e,'"}: ')).call(r,t))})),l.mediaKeys}))}return s.then((function(){return a.mediaKeys}))}},{key:"createMediaKeySessionContext",value:function(e){var t,r=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log(_d(t='Creating key-system session "'.concat(i,'" keyId: ')).call(t,XF.hexDump(r.keyId||[])));var a=n.createSession(),s={decryptdata:r,keySystem:i,mediaKeys:n,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(s),s}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"getKeyIdString",value:function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return XF.hexDump(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,i,n,a=e.mediaKeysSession;return this.log(_d(r=_d(i='Updating key-session "'.concat(a.sessionId,'" for keyID ')).call(i,XF.hexDump((null==(n=e.decryptdata)?void 0:n.keyId)||[]),"\n } (data length: ")).call(r,t?t.byteLength:t,")")),a.update(t)}},{key:"selectKeySystemFormat",value:function(e){var t,r,i,n=yv(e.levelkeys||{});this.keyFormatPromise||(this.log(_d(t=_d(r=_d(i="Selecting key-system from fragment (sn: ".concat(e.sn," ")).call(i,e.type,": ")).call(r,e.level,") key formats ")).call(t,n.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(n));return this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new nk((function(r,i){var n,a=bU(t.config),s=xk(n=Pk(e).call(e,yU)).call(n,(function(e){return!!e&&-1!==av(a).call(a,e)}));return t.getKeySystemSelectionPromise(s).then((function(e){var t=e.keySystem,n=LU(t);n?r(n):i(new Error('Unable to find format for key-system "'.concat(t,'"')))})).catch(i)}))}},{key:"loadKey",value:function(e){var t,r,i,n=this,a=e.keyInfo.decryptdata,s=this.getKeyIdString(a),o=_d(t=_d(r=_d(i="(keyId: ".concat(s,' format: "')).call(i,a.keyFormat,'" method: ')).call(r,a.method," uri: ")).call(t,a.uri,")");this.log("Starting session for key ".concat(o));var l=this.keyIdToKeySessionPromise[s];l||(l=this.getKeySystemForKeyPromise(a).then((function(t){var r,i,s,l=t.keySystem,u=t.mediaKeys;return n.throwIfDestroyed(),n.log(_d(r=_d(i=_d(s="Handle encrypted media sn: ".concat(e.frag.sn," ")).call(s,e.frag.type,": ")).call(i,e.frag.level," using key ")).call(r,o)),n.attemptSetMediaKeys(l,u).then((function(){return n.throwIfDestroyed(),n.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:a})}))})),(this.keyIdToKeySessionPromise[s]=l.then((function(e){var t=a.pssh?a.pssh.buffer:null;return n.generateRequestWithPreferredKeySession(e,"cenc",t,"playlist-key")}))).catch((function(e){return n.handleError(e)})));return l}},{key:"throwIfDestroyed",value:function(){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e){this.hls&&(this.error(e.message),e instanceof nH?this.hls.trigger(fO.ERROR,e.data):this.hls.trigger(fO.ERROR,{type:hO.KEY_SYSTEM_ERROR,details:dO.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=yU(e.keyFormat),n=i?[i]:bU(this.config);return this.attemptKeySystemAccess(n)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=bU(this.config)),0===e.length)throw new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(jI({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r,i=this,n=Bv(r=this.setMediaKeysQueue).call(r);this.log('Setting media-keys for "'.concat(e,'"'));var a=nk.all(n).then((function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(a),a.then((function(){var t;i.log('Media-keys set for "'.concat(e,'"')),n.push(a),i.setMediaKeysQueue=xk(t=i.setMediaKeysQueue).call(t,(function(e){return-1===av(n).call(n,e)}))}))}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,r,i){var n,a,s,o,l,u=this,c=null==(o=this.config.drmSystems)||null==(l=o[e.keySystem])?void 0:l.generateRequest;if(c)try{var h=c.call(this.hls,t,r,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,r=h.initData?h.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(JV){var d;if(this.warn(JV.message),null!=(d=this.hls)&&d.config.debug)throw JV}if(null===r)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),nk.resolve(e);var f=this.getKeyIdString(e.decryptdata);this.log(_d(n=_d(a=_d(s='Generating key-session request for "'.concat(i,'": ')).call(s,f," (init data type: ")).call(a,t," length: ")).call(n,r?r.byteLength:null,")"));var v=new LB,g=e._onmessage=function(t){var r,i,n=e.mediaKeysSession;if(n){var a=t.messageType,s=t.message;u.log(_d(r=_d(i='"'.concat(a,'" message event for session "')).call(i,n.sessionId,'" message size: ')).call(r,s.byteLength)),"license-request"===a||"license-renewal"===a?u.renewLicense(e,s).catch((function(e){v.eventNames().length?v.emit("error",e):u.handleError(e)})):"license-release"===a?e.keySystem===hU&&(u.updateKeySession(e,oU("acknowledged")),u.removeSession(e)):u.warn('unhandled media key message type "'.concat(a,'"'))}else v.emit("error",new Error("invalid state"))},p=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){u.onKeyStatusChange(e);var r,i=e.keyStatus;if(v.emit("keyStatus",i),"expired"===i)u.warn(_d(r="".concat(e.keySystem," expired for key ")).call(r,f)),u.renewKeySession(e)}else v.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",g),e.mediaKeysSession.addEventListener("keystatuseschange",p);var m=new nk((function(e,t){v.on("error",t),v.on("keyStatus",(function(r){UI(r).call(r,"usable")?e():"output-restricted"===r?t(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(r,'"'))):"expired"===r?t(new Error("key expired while generating request")):u.warn('unhandled key status change "'.concat(r,'"'))}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t,r;u.log(_d(t='Request generated for key-session "'.concat(null==(r=e.mediaKeysSession)?void 0:r.sessionId,'" keyId: ')).call(t,f))})).catch((function(e){throw new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: ".concat(e))})).then((function(){return m})).catch((function(t){throw v.removeAllListeners(),u.removeSession(e),t})).then((function(){return v.removeAllListeners(),e}))}},{key:"onKeyStatusChange",value:function(e){var t,r=this;vd(t=e.mediaKeysSession.keyStatuses).call(t,(function(t,i){var n,a,s;r.log(_d(n=_d(a=_d(s='key status change "'.concat(t,'" for keyStatuses keyId: ')).call(s,XF.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))," session keyId: ")).call(a,XF.hexDump(new Uint8Array(e.decryptdata.keyId||[]))," uri: ")).call(n,e.decryptdata.uri)),e.keyStatus=t}))}},{key:"fetchServerCertificate",value:function(e){var t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching server certificate for "'.concat(e,'"')),new nk((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 nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:RO({url:s.url,data:void 0},t)},_d(l=_d(u=_d(c='"'.concat(e,'" certificate request failed (')).call(c,i,"). Status: ")).call(u,t.code," (")).call(l,t.text,")")))},onTimeout:function(t,r,n){var o;a(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:s.url,data:void 0}},_d(o='"'.concat(e,'" certificate request timed out (')).call(o,i,")")))},onAbort:function(e,t,r){a(new Error("aborted"))}};r.load(s,l,u)}))):nk.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var i=this;return new nk((function(n,a){e.setServerCertificate(r).then((function(a){var s,o;i.log(_d(s=_d(o="setServerCertificate ".concat(a?"success":"not supported by CDM"," (")).call(o,null==r?void 0:r.byteLength,') on "')).call(s,t,'"')),n(e)})).catch((function(e){a(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.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 nH({type:hO.KEY_SYSTEM_ERROR,details:dO.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(!uD(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 oU(atob(f))}},{key:"setupLicenseXHR",value:function(e,t,r,i){var n=this,a=this.config.licenseXhrSetup;return a?nk.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),nk.resolve({xhr:e,licenseChallenge:i}))}},{key:"requestLicense",value:function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new nk((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(JV){r.error(JV)}n(l)}else{var c=i.errorRetry,h=c?c.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>h||o.status>=400&&o.status<500){var d,f;a(new nH({type:hO.KEY_SYSTEM_ERROR,details:dO.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},_d(d=_d(f="License Request XHR failed (".concat(s,"). Status: ")).call(f,o.status," (")).call(d,o.statusText,")")))}else{var v=h-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(v," attempts left")),r.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,t).then((function(t){var i=t.xhr,n=t.licenseChallenge;e.keySystem==dU&&(n=r.unpackPlayReadyKeyMessage(i,n)),i.send(n)}))}))}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}}},{key:"onMediaDetached",value:function(){var e,t,r=this,n=this.media,a=this.mediaKeySessions;n&&(n.removeEventListener("encrypted",this.onMediaEncrypted),n.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},PU.clearKeyUriToKeyIdMap();var s=a.length;i.CDMCleanupPromise=nk.all(_d(e=Pk(a).call(a,(function(e){return r.removeSession(e)}))).call(e,null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch((function(e){var t;r.log("Could not clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){s&&(r.log("finished closing key sessions and clearing media keys"),a.length=0)})).catch((function(e){var t;r.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=r.hls)||t.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.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=kC(r).call(r,(function(e,t){return-1===av(e).call(e,t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys ".concat(i.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){var n;this.log("Remove licenses and keys and close session ".concat(r.sessionId)),e._onmessage&&(r.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a,s=av(n=this.mediaKeySessions).call(n,e);if(s>-1)sg(a=this.mediaKeySessions).call(a,s,1);return r.remove().catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.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(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),i}(IO);iH.CDMCleanupPromise=void 0;var nH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,n)).data=void 0,e.error||(e.error=new Error(n)),a.data=e,e.err=e.error,a}return Fc(i)}(tC(Error)),aH=function(){function e(r){t(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=r,this.registerListeners()}return Fc(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i,n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=lS(sT(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(fO.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(fO.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}]),e}();function sH(e,t){var r;try{r=new Event("addtrack")}catch(ZV){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function oH(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(ZV){xO.debug("[texttrack-utils]: ".concat(ZV));try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(n){xO.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(n))}}"disabled"===r&&(e.mode=r)}function lH(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 uH(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;var i=0,n=r;for(;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}function cH(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}var hH=function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,e,"subtitle-track-controller")).media=null,n.tracks=[],n.groupIds=null,n.tracksInGroup=[],n.trackId=-1,n.currentTrack=null,n.selectDefaultTrack=!0,n.queuedDefaultTrack=-1,n.useTextTrackPolling=!1,n.subtitlePollingInterval=-1,n._subtitleDisplay=!0,n.asyncPollTrackChange=function(){return n.pollTrackChange(0)},n.onTextTracksChanged=function(){if(n.useTextTrackPolling||self.clearInterval(n.subtitlePollingInterval),n.media&&n.hls.config.renderTextTracksNatively){for(var e=null,t=cH(n.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=t[r];else if("showing"===t[r].mode){e=t[r];break}var i=n.findTrackForTextTrack(e);n.subtitleTrack!==i&&n.setSubtitleTrack(i)}},n.registerListeners(),n}return Fc(i,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVEL_LOADING,this.onLevelLoading,this),e.off(fO.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(fO.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=lS(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;if(r){var i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!i){var n=cH(r.textTracks);vd(n).call(n,(function(e){lH(e)}))}}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,i,n,a,s,o=t.id,l=t.groupId,u=t.details,c=this.tracksInGroup[o];if(c&&c.groupId===l){var h=c.details;c.details=t.details,this.log(_d(r=_d(i=_d(n=_d(a=_d(s="Subtitle track ".concat(o,' "')).call(s,c.name,'" lang:')).call(a,c.lang," group:")).call(n,l," loaded [")).call(i,u.startSN,"-")).call(r,u.endSN,"]")),o===this.trackId&&this.playlistLoaded(o,t,h)}else{var d,f;this.warn(_d(d=_d(f="Subtitle track with id:".concat(o," and group:")).call(f,l," not found in active group ")).call(d,null==c?void 0:c.groupId))}}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.subtitleGroups||null,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&KT(r).call(r,(function(e){return-1===(null==i?void 0:av(i).call(i,e))}))){var a,s;this.groupIds=r,this.trackId=-1,this.currentTrack=null;var o=xk(a=this.tracks).call(a,(function(e){return!r||-1!==av(r).call(r,e.groupId)}));if(o.length)this.selectDefaultTrack&&!KT(o).call(o,(function(e){return e.default}))&&(this.selectDefaultTrack=!1),vd(o).call(o,(function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;var l=this.hls.config.subtitlePreference;if(!n&&l){this.selectDefaultTrack=!1;var u=cF(l,o);if(u>-1)n=o[u];else{var c=cF(l,this.tracks);n=this.tracks[c]}}var h=this.findTrackId(n);-1===h&&n&&(h=this.findTrackId(null));var d={subtitleTracks:o};this.log(_d(s="Updating subtitle tracks, ".concat(o.length,' track(s) found in "')).call(s,null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(fO.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||hF(n,e)))return i}if(e){for(var a=0;a<t.length;a++){var s=t[a];if(nK(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return a}for(var o=0;o<t.length;o++){var l=t[o];if(nK(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(aK(t[r],e))return r}return-1}},{key:"onError",value:function(e,t){var r;!t.fatal&&t.context&&(t.context.type!==mO||t.context.id!==this.trackId||this.groupIds&&-1===av(r=this.groupIds).call(r,t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var r=this.currentTrack;if(r&&hF(e,r))return r;var i=cF(e,this.tracksInGroup);if(i>-1){var n=this.tracksInGroup[i];return this.setSubtitleTrack(i),n}if(r)return null;var a=cF(e,t);if(a>-1)return t[a]}}return null}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s,o,l;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var u=e.id,c=e.groupId,h=this.getUrlWithDirectives(e.url,t),d=e.details,f=null==d?void 0:d.age;this.log(_d(r=_d(n=_d(a=_d(s=_d(o=_d(l="Loading subtitle ".concat(u,' "')).call(l,e.name,'" lang:')).call(o,e.lang," group:")).call(s,c)).call(a,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(n,f&&d.live?" age "+f.toFixed(1)+(d.type&&" "+d.type||""):""," ")).call(r,h)),this.hls.trigger(fO.SUBTITLE_TRACK_LOADING,{url:h,id:u,groupId:c,deliveryDirectives:t||null,track:e})}},{key:"toggleTrackModes",value:function(){var e,t=this.media;if(t){var r,i,n=cH(t.textTracks),a=this.currentTrack;if(a)if(!(r=xk(n).call(n,(function(e){return aK(a,e)}))[0]))this.warn(_d(i='Unable to find subtitle TextTrack with name "'.concat(a.name,'" and language "')).call(i,a.lang,'"'));if(vd(e=Bv([]).call(n)).call(e,(function(e){"disabled"!==e.mode&&e!==r&&(e.mode="disabled")})),r){var s=this.subtitleDisplay?"showing":"hidden";r.mode!==s&&(r.mode=s)}}}},{key:"setSubtitleTrack",value:function(e){var t,r,i=this.tracksInGroup;if(this.media)if(e<-1||e>=i.length||!lO(e))this.warn("Invalid subtitle track id: ".concat(e));else{this.selectDefaultTrack=!1;var n=this.currentTrack,a=i[e]||null;if(this.trackId=e,this.currentTrack=a,this.toggleTrackModes(),a){var s=!!a.details&&!a.details.live;if(e!==this.trackId||a!==n||!s){this.log("Switching to subtitle-track ".concat(e)+(a?_d(t=_d(r=' "'.concat(a.name,'" lang:')).call(r,a.lang," group:")).call(t,a.groupId):""));var o=a.id,l=a.groupId,u=void 0===l?"":l,c=a.name,h=a.type,d=a.url;this.hls.trigger(fO.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(fO.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),i}(oK);function dH(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var fH=.02,vH=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function gH(e,t,r){var i,n;return _d(i=_d(n="".concat(e.identifier,"-")).call(n,r+1,"-")).call(i,dH(t))}var pH=function(){function e(r,i){t(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.base=i,this.dateRange=r,this.setDateRange(r)}return Fc(e,[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=this.error=void 0}},{key:"isAssetPastPlayoutLimit",value:function(e){if(e>=this.assetList.length)return!0;var t=this.playoutLimit;return!(e<=0||isNaN(t))&&this.assetList[e].startOffset>t}},{key:"findAssetIndex",value:function(e){var t;return av(t=this.assetList).call(t,e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return mH(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=lO(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 mH(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)<fH))},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"]?vH.Range:vH.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"toString",value:function(){return _d(t=_d(r=_d(i='["'.concat((e=this).identifier,'" ')).call(i,e.cue.pre?"<pre>":e.cue.post?"<post>":"")).call(r,e.timelineStart.toFixed(2),"-")).call(t,e.resumeTime.toFixed(2),"]");var e,t,r,i}}]),e}();function mH(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<fH)?t.start:t.start+t.duration}function yH(e,t,r){var i=new gI(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function EH(e){var t,r,i=e.timelineStart,n=e.duration||0;return _d(t=_d(r='["'.concat(e.identifier,'" ')).call(r,i.toFixed(2),"-")).call(t,(i+n).toFixed(2),"]")}var kH=function(){function e(r,i,n,a){var s=this;t(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this.playoutOffset=0,this.checkPlayout=function(){var e=s.interstitial.playoutLimit;s.playoutOffset+s.currentTime>=e&&s.hls.trigger(fO.PLAYOUT_LIMIT_REACHED,{})};var o=this.hls=new r(i);this.interstitial=n,this.assetItem=a;var l=a.uri;try{l=yH(l,o.sessionId).href}catch(JV){}o.loadSource(l);var u=function(){s.hasDetails=!0};o.once(fO.LEVEL_LOADED,u),o.once(fO.AUDIO_TRACK_LOADED,u),o.once(fO.SUBTITLE_TRACK_LOADED,u),o.on(fO.MEDIA_ATTACHING,(function(e,t){var r=t.media;s.removeMediaListeners(),s.mediaAttached=r;var i,n,o=s.interstitial;o.playoutLimit&&(s.playoutOffset=(null==(n=o.assetList[av(i=o.assetList).call(i,a)])?void 0:n.startOffset)||0,r.addEventListener("timeupdate",s.checkPlayout))}))}return Fc(e,[{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){return this.hls.media}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return 0;var t=qN.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):0}},{key:"duration",get:function(){var e,t=null==(e=this.assetItem)?void 0:e.duration;return t||0}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"timelineOffset",get:function(){return this.hls.config.timelineOffset||0},set:function(e){var t=this.timelineOffset;if(e!==t){var r=e-t;if(Math.abs(r)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&e.removeEventListener("timeupdate",this.checkPlayout)}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){this.hls.attachMedia(e)}},{key:"detachMedia",value:function(){this.removeMediaListeners(),this.hls.detachMedia()}},{key:"resumeBuffering",value:function(){this.hls.resumeBuffering()}},{key:"pauseBuffering",value:function(){this.hls.pauseBuffering()}},{key:"transferMedia",value:function(){return this.hls.transferMedia()}},{key:"on",value:function(e,t,r){this.hls.on(e,t)}},{key:"once",value:function(e,t,r){this.hls.once(e,t)}},{key:"off",value:function(e,t,r){this.hls.off(e,t)}},{key:"toString",value:function(){var e,t;return _d(e=_d(t="HlsAssetPlayer: ".concat(EH(this.assetItem)," ")).call(t,this.hls.sessionId," ")).call(e,this.interstitial.appendInPlace?"append-in-place":"")}}]),e}(),TH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,"interstitials-sched",n)).onScheduleUpdate=void 0,a.eventMap={},a.events=null,a.items=null,a.durations={primary:0,playout:0,integrated:0},a.onScheduleUpdate=e,a}return Fc(i,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){var e;(this.eventMap={},this.setDurations(0,0,0),this.events)&&vd(e=this.events).call(e,(function(e){return e.reset()}));this.events=this.items=null}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);var i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(n=i[r])&&n.event;){var n;r--}return r}},{key:"findItemIndexAtTime",value:function(e,t){var r=this.items;if(r)for(var i=0;i<r.length;i++){var n=r[i];if(t&&"primary"!==t&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return i}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var r=this.items;if(r)for(var i=e;i<=t&&r[i];i++){var n=r[i].event;if(null!=n&&n.restrictions.jump&&!n.appendInPlace)return i}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var r=t.length;r--;){var i;if((null==(i=t[r].event)?void 0:i.identifier)===e)return r}return-1}},{key:"findAssetIndex",value:function(e,t){var r=e.assetList,i=r.length;if(i>1)for(var n=0;n<i;n++){var a=r[n];if(!a.error){var s=a.timelineStart;if(t===s||t>s&&t<s+(a.duration||0))return n}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t,r=null==(e=this.items)||null==(t=e[this.length-1])?void 0:t.event;if(r){var i=r.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e){var t=this,r=e.main.details,i=r.dateRanges,n=this.events,a=this.parseDateRanges(i,{url:r.url}),s=yv(i),o=n?xk(n).call(n,(function(e){return!uD(s).call(s,e.identifier)})):[];a.length&&mA(a).call(a,(function(e,t){var r=e.cue.pre,i=e.cue.post,n=t.cue.pre,a=t.cue.post;if(r&&!n)return-1;if(n&&!r)return 1;if(i&&!a)return 1;if(a&&!i)return-1;if(!(r||n||i||a)){var s=e.startTime,o=t.startTime;if(s!==o)return s-o}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=a,vd(o).call(o,(function(e){t.removeEvent(e)})),this.updateSchedule(e,o)}},{key:"updateSchedule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.events||[];if(r.length||t.length||this.length<2){var i=this.items,n=this.parseSchedule(r,e);(t.length||(null==i?void 0:i.length)!==n.length||KT(n).call(n,(function(e,t){return Math.abs(e.playout.start-i[t].playout.start)>.005||Math.abs(e.playout.end-i[t].playout.end)>.005})))&&(this.items=n,this.onScheduleUpdate(t,i))}}},{key:"parseDateRanges",value:function(e,t){for(var r=[],i=yv(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 pH(s,t),this.eventMap[a]=o),r.push(o)}}return r}},{key:"parseSchedule",value:function(e,t){var r=[],i=t.main.details,n=i.live?1/0:i.edge,a=0;if((e=xk(e).call(e,(function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(vd(e).call(e,(function(t,i){var l=t.cue.pre,u=t.cue.post,c=e[i-1]||null,h=t.appendInPlace,d=u?n:t.startOffset,f=t.duration,v=t.timelineOccupancy===vH.Range?f:0,g=t.resumptionOffset,p=(null==c?void 0:c.startTime)===d,m=d+t.cumulativeDuration,y=h?m+f:d+g;if(l||!u&&d<=0){var E=o;o+=v,t.timelineStart=m;var k=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:k,end:a},integrated:{start:E,end:o}})}else{if(!(d<=n))return;if(!p){var T=d-s;if(T>.033){var S=s,A=o;o+=T;var L=a;a+=T;var b={previousEvent:e[i-1]||null,nextEvent:t,start:S,end:S+T,playout:{start:L,end:a},integrated:{start:A,end:o}};r.push(b)}else T>0&&c&&(c.cumulativeDuration+=T,r[r.length-1].end=d)}u&&(y=m),t.timelineStart=m;var R=o;o+=v;var I=a;a+=f,r.push({event:t,start:m,end:y,playout:{start:I,end:a},integrated:{start:R,end:o}})}var D=t.resumeTime;s=u||D>n?n:D})),s<n){var l,u=s,c=o,h=n-s;o+=h;var d=a;a+=h,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:s,end:u+h,playout:{start:d,end:a},integrated:{start:c,end:o}})}this.setDurations(n,a,o)}else{r.push({previousEvent:null,nextEvent:null,start:0,end:n,playout:{start:0,end:n},integrated:{start:0,end:n}}),this.setDurations(n,n,n)}return r}},{key:"setDurations",value:function(e,t,r){this.durations={primary:e,playout:t,integrated:r}}},{key:"resolveOffsets",value:function(e,t){var r=this,i=t.main.details,n=i.live?1/0:i.edge,a=0,s=-1;vd(e).call(e,(function(o,l){var u=o.cue.pre,c=o.cue.post,h=u?0:c?n:o.startTime;(r.updateAssetDurations(o),s===h?o.cumulativeDuration=a:(a=0,s=h),!c&&o.snapOptions.in&&(o.resumeAnchor=mF(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(r.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));if(!o.appendInPlace)for(var d=l-1;l--;){e[d+1].startTime-e[d].resumeTime<.033&&(e[d].appendInPlace=!1)}var f=lO(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)>fH?(this.log(_d(i=_d(n='"'.concat(e.identifier,'" resumption ')).call(n,o," not aligned with estimated timeline end ")).call(i,l)),!1):t?!KT(r=yv(t)).call(r,(function(r){var i,n,a,l=t[r].details,u=l.edge;if(o>u)return s.log(_d(i=_d(n=_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," past ")).call(n,r," playlist end ")).call(i,u)),!0;var c,h,d=mF(null,l.fragments,o);if(!d)return s.log(_d(c=_d(h='"'.concat(e.identifier,'" resumption ')).call(h,o," does not align with any fragments in ")).call(c,r," playlist")),!0;var f,v,g,p,m,y,E="audio"===r?.175:0;return!(Math.abs(d.start-o)<fH||Math.abs(d.end-o)<fH+E)&&(s.log(_d(f=_d(v=_d(g=_d(p=_d(m=_d(y='"'.concat(e.identifier,'" resumption ')).call(y,o," not aligned with ")).call(m,r," fragment bounds (")).call(p,d.start,"-")).call(g,d.end," sn: ")).call(v,d.sn," cc: ")).call(f,d.cc,")")),!0)})):(this.log(_d(a='"'.concat(e.identifier,'" resumption ')).call(a,o," can not be aligned with media (none selected)")),!1)}},{key:"updateAssetDurations",value:function(e){var t,r=e.timelineStart,i=0,n=!1,a=!1;vd(t=e.assetList).call(t,(function(e,t){var s=r+i;e.startOffset=i,e.timelineStart=s,n||(n=null===e.duration),a||(a=!!e.error);var o=e.error?0:e.duration||0;i+=o})),e.duration=n&&!a?Math.max(i,e.duration):i}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}]),i}(IO);function SH(e){var t,r;return _d(t=_d(r="[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ")).call(r,e.start.toFixed(2),"-")).call(t,e.end.toFixed(2),"]")}var AH=function(){function e(r){t(this,e),this.hls=void 0,this.hls=r}return Fc(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,i=this,n=e.assetListUrl;try{r=yH(n,this.hls.sessionId,e.baseUrl)}catch(JV){var a=this.assignAssetListError(e,dO.ASSET_LIST_LOAD_ERROR,JV,n);return void this.hls.trigger(fO.ERROR,a)}if(t&&!e.cue.pre&&!e.cue.post&&"data:"!==r.protocol){var s=t-e.startTime;s>0&&r.searchParams.set("_HLS_start_offset",""+Math.round(1e3*s)/1e3)}var o=this.hls.config,l=new(0,o.loader)(o),u={responseType:"json",url:r.href},c=o.interstitialAssetListLoadPolicy.default,h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:function(t,r,n,a){var s=t.data,o=null==s?void 0:s.ASSETS;if(lv(o))e.assetListResponse=s,i.hls.trigger(fO.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:a});else{var l=i.assignAssetListError(e,dO.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,r,a);i.hls.trigger(fO.ERROR,l)}},onError:function(t,r,n,a){var s,o,l=i.assignAssetListError(e,dO.ASSET_LIST_LOAD_ERROR,new Error(_d(s=_d(o="Error loading X-ASSET-LIST: HTTP status ".concat(t.code," ")).call(o,t.text," (")).call(s,r.url,")")),r.url,a,n);i.hls.trigger(fO.ERROR,l)},onTimeout:function(t,r,n){var a=i.assignAssetListError(e,dO.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,n);i.hls.trigger(fO.ERROR,a)}};return l.load(u,h,d),this.hls.trigger(fO.ASSET_LIST_LOADING,{event:e}),l}},{key:"assignAssetListError",value:function(e,t,r,i,n,a){return e.error=r,{type:hO.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:a,stats:n}}}]),e}();function LH(e){null==e||e.play().catch()}var bH=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,"interstitials",e.logger)).HlsPlayerClass=void 0,a.hls=void 0,a.assetListLoader=void 0,a.mediaSelection=null,a.altSelection=null,a.media=null,a.detachedData=null,a.requiredTracks=null,a.manager=null,a.playerQueue=[],a.bufferedPos=-1,a.timelinePos=-1,a.schedule=void 0,a.playingItem=null,a.bufferingItem=null,a.waitingItem=null,a.playingAsset=null,a.bufferingAsset=null,a.shouldPlay=!1,a.onPlay=function(){a.shouldPlay=!0},a.onPause=function(){a.shouldPlay=!1},a.onSeeking=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled){var t=e-a.timelinePos;if(!(Math.abs(t)<1/7056e5)){var r=t<=-.01;a.timelinePos=e,a.bufferedPos=e,a.checkBuffer();var i=a.playingItem;if(i)if(r&&e<i.start||e>=i.end){var n,s=a.schedule.findItemIndexAtTime(a.timelinePos);if(!a.isInterstitial(i)&&null!=(n=a.media)&&n.paused&&(a.shouldPlay=!1),!r){var o=a.findItemIndex(i);if(s>o){var l=a.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void a.setSchedulePosition(l)}}a.setSchedulePosition(s)}else{var u=a.playingAsset;if(u){var c=u.timelineStart,h=u.duration||0;(r&&e<c||e>=c+h)&&a.setScheduleToAssetAtTime(e,u)}else if(a.playingLastItem&&a.isInterstitial(i)){var d=i.event.assetList[0];d&&(a.playingItem=null,a.setScheduleToAssetAtTime(e,d))}}}}},a.onTimeupdate=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled&&e>a.timelinePos){e>a.bufferedPos&&a.checkBuffer(),a.timelinePos=e;var t=a.playingItem;if(t&&!a.playingLastItem){if(e>=t.end){a.timelinePos=t.end;var r=a.findItemIndex(t);a.setSchedulePosition(r+1)}var i=a.playingAsset;if(i)e>=i.timelineStart+(i.duration||0)&&a.setScheduleToAssetAtTime(e,i)}}},a.onScheduleUpdate=function(e,t){var r,i,n,s=a.schedule,o=a.playingItem,l=s.events||[],u=s.items||[],c=s.durations,h=Pk(e).call(e,(function(e){return e.identifier})),d=!(!l.length&&!h.length);d&&(!1===a.hls.config.interstitialAppendInPlace&&vd(l).call(l,(function(e){return e.appendInPlace=!1})),a.log(_d(i=_d(n="INTERSTITIALS_UPDATED (".concat(l.length,"): ")).call(n,l,"\nSchedule: ")).call(i,Pk(u).call(u,(function(e){return SH(e)})))));h.length&&a.log("Removed events ".concat(h)),vd(r=a.playerQueue).call(r,(function(e){if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(o){var i,n,s;if(Math.abs(r)>fH)a.warn(_d(i=_d(n=_d(s="".concat(o,' ("')).call(s,e.assetId,'" ')).call(n,e.timelineOffset,"->")).call(i,t,")"))}}})),o&&!o.event&&(a.playingItem=a.updateItem(o,a.timelinePos));var f=a.bufferingItem;if(f&&(f.event?a.updateItem(f)||(a.bufferingItem=null,a.clearInterstitial(f.event,null)):a.bufferingItem=a.updateItem(f,a.bufferedPos)),a.waitingItem=a.updateItem(a.waitingItem),vd(e).call(e,(function(e){var t;vd(t=e.assetList).call(t,(function(e){a.clearAssetPlayer(e.identifier,null)}))})),d||t){if(a.hls.trigger(fO.INTERSTITIALS_UPDATED,{events:Bv(l).call(l,0),schedule:Bv(u).call(u,0),durations:c,removedIds:h}),a.isInterstitial(o)&&uD(h).call(h,o.event.identifier))return a.warn('Interstitial "'.concat(o.event.identifier,'" removed while playing')),void a.primaryFallback(o.event);a.checkBuffer()}},a.hls=e,a.HlsPlayerClass=n,a.assetListLoader=new AH(e),a.schedule=new TH(a.onScheduleUpdate,e.logger),a.registerListeners(),a}return Fc(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(fO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(fO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(fO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.on(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(fO.MEDIA_ENDED,this.onMediaEnded,this),e.on(fO.ERROR,this.onError,this),e.on(fO.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fO.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(fO.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(fO.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(fO.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(fO.BUFFER_CODECS,this.onBufferCodecs,this),e.off(fO.BUFFER_APPENDED,this.onBufferAppended,this),e.off(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fO.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(fO.MEDIA_ENDED,this.onMediaEnded,this),e.off(fO.ERROR,this.onError,this),e.off(fO.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;vd(e=this.playerQueue).call(e,(function(e){return e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){var e;vd(e=this.playerQueue).call(e,(function(e){return e.pauseBuffering()}))}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){e.removeEventListener("play",this.onPlay),e.removeEventListener("pause",this.onPause),e.removeEventListener("seeking",this.onSeeking),e.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media;this.removeMediaListeners(r),r.addEventListener("seeking",this.onSeeking),r.addEventListener("timeupdate",this.onTimeupdate),r.addEventListener("play",this.onPlay),r.addEventListener("pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var r=this.playingItem,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();var n=this.findItemIndex(r);this.setSchedulePosition(n)}}},{key:"clearScheduleState",value:function(){this.playingItem=this.bufferingItem=this.waitingItem=this.playingAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){var n=this.getBufferingPlayer();n&&(this.playingAsset=null,this.bufferingAsset=null,this.bufferingItem=null,this.waitingItem=null,this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.manager){if(!this.hls||!this.schedule.events)return null;var e=this,t=function(){return e.bufferingItem||e.waitingItem},r=function(){return e.playingItem||e.waitingItem},i=function(t){return t?e.getAssetPlayer(t.identifier):t},n=function(t,r,n,a,o){if(t){var l=t[r].start,u=t.event;if(u){if("playout"===r||u.timelineOccupancy!==vH.Point){var c=i(n);(null==c?void 0:c.interstitial)===u&&(l+=c.assetItem.startOffset+c[o])}}else l+=("bufferedPos"===a?s():e[a])-t.start;return l}return 0},a=function(t,r){if(0!==t&&"primary"!==r&&e.schedule.length){var i,n=e.schedule.findItemIndexAtTime(t),a=null==(i=e.schedule.items)?void 0:i[n];if(a)return t+(a[r].start-a.start)}return t},s=function(){var t=e.bufferedPos;return t===Number.MAX_VALUE?o("primary"):t},o=function(t){var r;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:e.schedule.durations[t]},l=function(t,a){var s,o,l,u=r();if(null==u||null==(o=u.event)||!o.restrictions.skip){e.log(_d(s="seek to ".concat(t,' "')).call(s,a,'"'));var c=r(),h=e.schedule.findItemIndexAtTime(t,a),d=null==(l=e.schedule.items)?void 0:l[h],f=null==c?void 0:c.event,v=null==f?void 0:f.appendInPlace,g=c&&e.itemsMatch(c,d);if(c&&(v||g)){var p=i(e.playingAsset),m=(null==p?void 0:p.media)||e.hls.media;if(m){var y=t-("primary"===a?m.currentTime:n(c,a,e.playingAsset,"timelinePos","currentTime")),E=m.currentTime+y;if(E>=0&&(!p||v||E<=p.duration))return void(m.currentTime=E)}}if(d){var k=t;if("primary"!==a){var T=t-d[a].start;k=d.start+T}var S=!e.isInterstitial(d);if(e.isInterstitial(c)||!S&&!d.event.appendInPlace){if(c){var A=e.findItemIndex(c);if(h>A){var L=e.schedule.findJumpRestrictedIndex(A+1,h);if(L>A)return void e.setSchedulePosition(L)}var b=0;if(S)e.timelinePos=k;else{var R,I=null==d||null==(R=d.event)?void 0:R.assetList;if(I)for(var D=t-(d[a]||d).start,_=I.length;_--;){var w=I[_];if(w.duration&&D>=w.startOffset&&D<w.startOffset+w.duration){b=_;break}}}e.setSchedulePosition(h,b)}}else{var C=e.hls.media;C&&(C.currentTime=k)}}}};this.manager={get events(){var t,r;return(null==(t=e.schedule)||null==(r=t.events)?void 0:Bv(r).call(r,0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:Bv(r).call(r,0))||[]},get playerQueue(){var t;return Bv(t=e.playerQueue).call(t,0)},get bufferingPlayer(){return e.getBufferingPlayer()},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return e.bufferingItem},get playingAsset(){return e.playingAsset},get playingItem(){return e.playingItem},get bufferingIndex(){var r=t();return e.findItemIndex(r)},get playingIndex(){var t=r();return e.findItemIndex(t)},get waitingIndex(){return e.findItemIndex(e.waitingItem)},primary:{get bufferedEnd(){return s()},get currentTime(){var t=e.timelinePos;return t>0?t:0},get duration(){return o("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0},seekTo:function(e){return l(e,"primary")}},playout:{get bufferedEnd(){return n(t(),"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"playout",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("playout")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"playout")},seekTo:function(e){return l(e,"playout")}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(r(),"integrated",e.playingAsset,"timelinePos","currentTime")},get duration(){return o("integrated")},get seekableStart(){var t;return a((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")},seekTo:function(e){return l(e,"integrated")}},skip:function(){var t=r(),i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;l(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,1/0)}}}}return this.manager}},{key:"playingLastItem",get:function(){var e,t=this.playingItem;if(!this.playbackStarted||!t)return!1;var r=null==(e=this.schedule)?void 0:e.items;return this.itemsMatch(t,r?r[r.length-1]:null)}},{key:"playbackStarted",get:function(){return null!==this.playingItem}},{key:"currentTime",get:function(){var e,t,r;if(null!==this.mediaSelection){var i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(n=this.primaryMedia);var a=null==(r=n)?void 0:r.currentTime;if(void 0!==a&&lO(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var r=e.interstitial.appendInPlace,i=e.media;if(r&&i===this.primaryMedia){var n;if(!t||this.isInterstitial(t)&&!t.event.appendInPlace)return void(t&&i&&(this.detachedData={media:i}));var a=e.transferMedia();this.log(_d(n="transfer MediaSource from ".concat(e," ")).call(n,jI(a))),this.bufferingAsset=null,this.detachedData=a}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}},{key:"transferMediaTo",value:function(e,t){var r,i,n,a,s,o,l=null,u=this.hls,c=e!==u,h=c&&e.interstitial.appendInPlace,d=null==(a=this.detachedData)?void 0:a.mediaSource;if(u.media&&h)l=u.transferMedia(),this.detachedData=l,o="Primary";else if(d){var f=this.getBufferingPlayer();f&&(l=f.transferMedia()),o="".concat(f)}else o="<unknown>";this.log(_d(r=_d(i="transferring to ".concat(c?e:"Primary","\nMediaSource ")).call(i,jI(l)," from ")).call(r,o)),l||(d?(l=this.detachedData,this.log("using detachedData: MediaSource ".concat(jI(l)))):this.detachedData&&this.hls.media!==t||(this.hls.detachMedia(),this.detachedData={media:t}));var v=l&&"mediaSource"in l&&"closed"!==(null==(s=l.mediaSource)?void 0:s.readyState),g=v&&l?l:t;if(this.log(_d(n="".concat(v?"transfering MediaSource":"attaching media"," to ")).call(n,c?e:"Primary")),g===l){var p=c&&e.assetId===this.schedule.assetIdAtEnd;g.overrides={duration:this.schedule.duration,endOfStream:!c||p,cueRemoval:!1}}e.attachMedia(g)}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=e.events;if(t&&!this.playbackDisabled){-1===this.bufferedPos&&(this.bufferedPos=0);var r=this.timelinePos,i=this.waitingItem;if(-1===r){var n=this.hls.startPosition;if(this.timelinePos=n,t.length&&t[0].cue.pre){var a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(n>=0||!this.primaryLive){var s=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(i&&!this.playingItem){var l=e.findItemIndex(i);this.setSchedulePosition(l)}}}},{key:"advanceAfterAssetEnded",value:function(e,t,r){var i=r+1;if(e.isAssetPastPlayoutLimit(i)||e.assetList[i].error){var n=this.schedule.items;if(n){var a=t+1;if(a>=n.length)return void this.setSchedulePosition(-1);this.setSchedulePosition(a)}}else this.setSchedulePosition(t,i)}},{key:"setScheduleToAssetAtTime",value:function(e,t){var r=this.schedule,i=t.parentIdentifier,n=r.getEvent(i);if(n){var a=r.findEventIndex(i),s=r.findAssetIndex(n,e);this.setSchedulePosition(a,s)}}},{key:"setSchedulePosition",value:function(e,t){var r,i=this,n=this.schedule.items;if(n&&!this.playbackDisabled){this.log(_d(r="setSchedulePosition ".concat(e,", ")).call(r,t));var a=e>=0?n[e]:null,s=this.primaryMedia,o=this.playingItem,l=this.playingLastItem;if(this.isInterstitial(o)){var u,c,h=o.event,d=this.playingAsset,f=null==d?void 0:d.identifier,v=f?this.getAssetPlayer(f):null;if(v&&f&&(!this.eventItemsMatch(o,a)||void 0!==t&&f!==(null==(u=h.assetList)?void 0:u[t].identifier))){var g,p;this.playingAsset=null;var m=h.findAssetIndex(d);this.log(_d(g=_d(p="INTERSTITIAL_ASSET_ENDED ".concat(m+1,"/")).call(p,h.assetList.length," ")).call(g,EH(d))),this.hls.trigger(fO.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:m,event:h,schedule:Bv(n).call(n,0),scheduleIndex:e,player:v}),this.retreiveMediaSource(f,a),v.media&&!this.detachedData&&v.detachMedia(),this.clearAssetPlayer(f,a)}if(!this.eventItemsMatch(o,a))if(this.playingItem=null,this.log(_d(c="INTERSTITIAL_ENDED ".concat(h," ")).call(c,SH(o))),h.hasPlayed=!0,this.hls.trigger(fO.INTERSTITIAL_ENDED,{event:h,schedule:Bv(n).call(n,0),scheduleIndex:e}),this.clearInterstitial(h,a),h.cue.once){if(this.updateSchedule(),a){var y=this.schedule.findItemIndex(a);this.setSchedulePosition(y,t)}return}}var E=this.playerQueue;if(E.length&&vd(E).call(E,(function(t){var r=t.interstitial,n=i.schedule.findEventIndex(r.identifier);(n<e||n>e+1)&&i.clearInterstitial(r,a)})),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);var k=a.event;void 0===t&&(t=this.schedule.findAssetIndex(k,this.timelinePos));var T,S=this.waitingItem,A=this.preloadAssets(k,t);if(A||this.setBufferingItem(a),!this.eventItemsMatch(a,o||S))this.waitingItem=a,this.log(_d(T="INTERSTITIAL_STARTED ".concat(SH(a)," ")).call(T,k.appendInPlace?"append in place":"")),this.hls.trigger(fO.INTERSTITIAL_STARTED,{event:k,schedule:Bv(n).call(n,0),scheduleIndex:e});var L=k.assetList.length;if(0===L&&!k.assetListResponse)return void this.log("Waiting for ASSET-LIST to complete loading ".concat(k));if(k.assetListLoader&&(k.assetListLoader.destroy(),k.assetListLoader=void 0),!s)return void this.log("Waiting for attachMedia to start Interstitial ".concat(k));this.waitingItem=null,this.playingItem=a;var b,R,I=k.assetList[t];if(!I){var D=n[e+1],_=this.media;return D&&_&&!this.isInterstitial(D)&&_.currentTime<D.start&&(_.currentTime=this.timelinePos=D.start),void this.advanceAfterAssetEnded(k,e,t||0)}if(A||(A=this.getAssetPlayer(I.identifier)),null===A||A.destroyed)this.warn(_d(b=_d(R="asset ".concat(t+1,"/")).call(R,L," player destroyed ")).call(b,k)),A=this.createAssetPlayer(k,I,t);if(!this.eventItemsMatch(a,this.bufferingItem)&&k.appendInPlace&&this.isAssetBuffered(I))return;this.startAssetPlayer(A,t,n,e,s),this.shouldPlay&&LH(A.media)}else null!==a?(this.resumePrimary(a,e,o),this.shouldPlay&&LH(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(SH(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(SH(e))),this.hls.trigger(fO.INTERSTITIALS_PRIMARY_RESUMED,{schedule:Bv(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:qN.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(fO.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(fO.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],i=RO(RO({},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=RO(RO({},i),{},{audio:r});this.mediaSelection=n}else this.altSelection=RO(RO({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(i){var n=RO(RO({},i),{},{subtitles:r});this.mediaSelection=n}else this.altSelection=RO(RO({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r,i=uF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(i)}))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r,i=uF(t);vd(r=this.playerQueue).call(r,(function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(i)}))}},{key:"onBufferCodecs",value:function(e,t){var r=t.tracks;r&&(this.requiredTracks=r)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var r=this.playingItem;if(r&&r!==this.bufferingItem&&!this.isInterstitial(r)){var i=this.timelinePos;this.bufferedPos=i,this.setBufferingItem(r)}}},{key:"onBufferedToEnd",value:function(e){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var r=0;r<t.length;r++){var i=t[r];if(i.cue.post){var n,a=this.schedule.findEventIndex(i.identifier),s=null==(n=this.schedule.items)?void 0:n[a];this.isInterstitial(s)&&this.eventItemsMatch(s,this.bufferingItem)&&this.bufferedToItem(s,0);break}}this.bufferedPos=Number.MAX_VALUE}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var r=this.findItemIndex(t);this.setSchedulePosition(r+1)}}},{key:"updateItem",value:function(e,t){var r=this.schedule.items;return e&&r&&r[this.findItemIndex(e,t)]||null}},{key:"itemsMatch",value:function(e,t){var r,i;return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&(null==(r=e.nextEvent)?void 0:r.identifier)===(null==(i=t.nextEvent)?void 0:i.identifier))}},{key:"eventItemsMatch",value:function(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}},{key:"findItemIndex",value:function(e,t){return e?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(){var e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[])}},{key:"checkBuffer",value:function(){var e=this.schedule.items;if(e){var t=qN.bufferInfo(this.primaryMedia,this.timelinePos,0);this.updateBufferedPos(t.end,e,0===t.len)}}},{key:"updateBufferedPos",value:function(e,t,r){var i=this.schedule,n=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],n))this.bufferedPos=e;else{var a=this.playingItem,s=this.findItemIndex(a),o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,u=this.findItemIndex(n),c=Math.min(u+1,t.length-1),h=t[c];if(-1===o&&n&&e>=n.end&&(o=c),c-s>1&&!1===(null==n||null==(l=n.event)?void 0:l.appendInPlace))return;if(this.bufferedPos=e,o>u&&o>s)this.bufferedToItem(h);else{var d=this.primaryDetails;this.primaryLive&&d&&e>d.edge-d.targetduration&&h.start<d.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else r&&a&&n!==a&&o===s&&this.bufferedToItem(a)}}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,r=this.schedule,i=r.items,n=r.events;if(i&&n&&(!t||r.findItemIndex(t)!==r.findItemIndex(e))){var a,s,o=this.isInterstitial(e),l=this.getBufferingPlayer(),u=l?l.remaining:t?t.end-this.timelinePos:0;if(this.log("buffered to boundary ".concat(SH(e))+(t?" (".concat(u.toFixed(2)," remaining)"):"")),this.bufferingItem=e,this.bufferedPos=e.start,!this.playbackDisabled)if(o)vd(a=this.playerQueue).call(a,(function(e){return e.resumeBuffering()}));else this.hls.resumeBuffering(),vd(s=this.playerQueue).call(s,(function(e){return e.pauseBuffering()}));this.hls.trigger(fO.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:Bv(n).call(n,0),schedule:Bv(i).call(i,0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}return t}},{key:"bufferedToItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;var i=this.detachedData;if(i)if(i.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}},{key:"bufferedToEvent",value:function(e,t){var r=e.event,i=0===r.assetList.length&&!r.assetListLoader,n=r.cue.once;if(i||!n){var a=this.preloadAssets(r,t);if(null!=a&&a.interstitial.appendInPlace){var s=r.assetList[t],o=this.primaryMedia;s&&o&&this.bufferAssetPlayer(a,o)}}}},{key:"preloadAssets",value:function(e,t){var r=e.assetList.length,i=0===r&&!e.assetListLoader,n=e.cue.once;if(i){var a,s;this.log(_d(a=_d(s="Load interstitial asset ".concat(t+1,"/")).call(s,r," ")).call(a,e));var o=e.timelineStart;e.appendInPlace&&this.flushFrontBuffer(o);var l=e.assetUrl;if(l)return this.createAsset(e,0,0,o,e.duration,l);var u=0;!this.playingItem&&this.primaryLive&&-1===(u=this.hls.startPosition)&&(u=this.hls.liveSyncPosition||0);var c=this.assetListLoader.loadAssetList(e,u);c&&(e.assetListLoader=c)}else if(!n&&r){for(var h=t;h<r;h++){var d=e.assetList[h],f=this.getAssetPlayerQueueIndex(d.identifier);-1!==f&&!this.playerQueue[f].destroyed||d.error||this.createAssetPlayer(e,d,h)}return this.getAssetPlayer(e.assetList[t].identifier)}return null}},{key:"flushFrontBuffer",value:function(e){var t=this,r=this.requiredTracks;if(r){var i=yv(r);vd(i).call(i,(function(r){t.hls.trigger(fO.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r})}))}}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}},{key:"createAsset",value:function(e,t,r,i,n,a){var s={parentIdentifier:e.identifier,identifier:gH(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(EH(t)));var n=this.hls,a=n.userConfig,s=a.videoPreference,o=n.levels[n.loadLevel]||n.levels[n.currentLevel];(s||o)&&(s=LO({},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=RO(RO({},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=LO({},v,{contentId:dH(t.uri)}));var g=new kH(this.HlsPlayerClass,f,e,t);this.playerQueue.push(g),e.assetList[r]=t;var p=t.identifier,m=function(n){if(n.live){var a=new Error("Interstitials MUST be VOD assets ".concat(e)),s={fatal:!0,type:hO.OTHER_ERROR,details:dO.INTERSTITIAL_ASSET_ITEM_ERROR,error:a};i.handleAssetItemError(s,e,i.schedule.findEventIndex(e.identifier),r,a.message)}else{var o,l,u=n.edge-n.fragmentStart,c=t.duration;if(null===c||u>c)i.log(_d(o=_d(l='Interstitial asset "'.concat(p,'" duration change ')).call(l,c," > ")).call(o,u)),t.duration=u,i.updateSchedule()}};g.on(fO.LEVEL_UPDATED,(function(e,t){var r=t.details;return m(r)})),g.on(fO.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return m(r)}));g.on(fO.BUFFER_CODECS,(function e(t,r){var n=i.getAssetPlayer(p);if(n&&r.tracks){n.off(fO.BUFFER_CODECS,e),n.tracks=r.tracks;var a=i.primaryMedia;i.bufferingAsset===n.assetItem&&a&&!n.media&&i.bufferAssetPlayer(n,a)}}));g.on(fO.BUFFERED_TO_END,(function r(n){var a,s=i.getAssetPlayer(p);if(i.log("buffered to end of asset ".concat(s)),s){s.off(fO.BUFFERED_TO_END,r);var o=i.schedule.findEventIndex(e.identifier),l=e.findAssetIndex(t),u=l+1,c=null==(a=i.schedule.items)?void 0:a[o];if(i.isInterstitial(c))if(-1===l||e.isAssetPastPlayoutLimit(u)||e.assetList[u].error){var h,d=null==(h=i.schedule.items)?void 0:h[o+1];d&&i.bufferedToItem(d)}else i.bufferedToItem(c,l+1)}}));var y=function(t){return function(){if(i.getAssetPlayer(p)){i.shouldPlay=!0;var r=i.schedule.findEventIndex(e.identifier);i.advanceAfterAssetEnded(e,r,t)}}};return g.once(fO.MEDIA_ENDED,y(r)),g.once(fO.PLAYOUT_LIMIT_REACHED,y(1/0)),g.on(fO.ERROR,(function(t,n){var a;i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,_d(a="Asset player error ".concat(n.error," ")).call(a,e))})),g.on(fO.DESTROYING,(function(){if(i.getAssetPlayer(p)){var t=new Error("Asset player destroyed unexpectedly ".concat(p)),n={fatal:!0,type:hO.OTHER_ERROR,details:dO.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};i.handleAssetItemError(n,e,i.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(fO.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:g}),g}},{key:"clearInterstitial",value:function(e,t){var r,i=this;vd(r=e.assetList).call(r,(function(e){i.clearAssetPlayer(e.identifier,t)})),e.appendInPlaceStarted=!1}},{key:"clearAssetPlayer",value:function(e,t){if(null!==t){var r=this.getAssetPlayerQueueIndex(e);if(-1!==r){var i,n;this.log(_d(i='clearAssetPlayer "'.concat(e,'" toSegment: ')).call(i,t?SH(t):t));var a=this.playerQueue[r];this.transferMediaFromPlayer(a,t),sg(n=this.playerQueue).call(n,r,1),a.destroy()}}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,r,i,n){var a,s,o=e.interstitial,l=e.assetItem,u=e.assetId,c=o.assetList.length,h=this.playingAsset;(this.playingAsset=l,h&&h.identifier===u)||(h&&(this.clearAssetPlayer(h.identifier,r[i]),delete h.error),this.log(_d(a=_d(s="INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/")).call(s,c," ")).call(a,e)),this.hls.trigger(fO.INTERSTITIAL_ASSET_STARTED,{asset:l,assetListIndex:t,event:o,schedule:Bv(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&&!OO(c,e.tracks)){var h,d,f=new Error(_d(h=_d(d='Asset "'.concat(s,"\" SourceBuffer tracks ('")).call(d,yv(e.tracks),"') are not compatible with primary content tracks ('")).call(h,yv(c),"')")),v={fatal:!0,type:hO.OTHER_ERROR,details:dO.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!==dO.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=LO({},e,{fatal:!1,errorAction:MF(!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(fO.INTERSTITIAL_ASSET_ERROR,c),e.fatal){var h=new Error(n);s&&(this.playingAsset!==s&&this.clearAssetPlayer(s.identifier,null),s.error=h),KT(a=t.assetList).call(a,(function(e){return!e.error}))?t.appendInPlace&&(t.error=h):t.error=h,this.primaryFallback(t)}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,r=this.playingItem||this.waitingItem;if(this.updateSchedule(),r){var i,n,a,s;this.log(_d(i=_d(n=_d(a=_d(s='Fallback to primary from event "'.concat(e.identifier,'" start: ')).call(s,t," pos: ")).call(a,this.timelinePos," playing: ")).call(n,r?SH(r):"<none>"," error: ")).call(i,e.error)),e.appendInPlace&&(e.appendInPlace=!1,this.attachPrimary(t,null),this.flushFrontBuffer(t));var o=this.timelinePos;-1===o&&(o=this.hls.startPosition);var l=this.updateItem(r,o);if(!this.itemsMatch(r,l)){var u=this.schedule.findItemIndexAtTime(o);this.setSchedulePosition(u)}}else this.checkStart()}},{key:"onAssetListLoaded",value:function(e,t){var r,i=this,n=t.event,a=n.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(a)){var o=n.timelineStart,l=0;vd(s).call(s,(function(e,t){var r=bS(e.DURATION);i.createAsset(n,t,l,o+l,r,e.URI),l+=r})),n.duration=l;var u=this.waitingItem,c=(null==u?void 0:u.event.identifier)===a;this.updateSchedule();var h=null==(r=this.bufferingItem)?void 0:r.event;if(c){var d,f=this.schedule.findEventIndex(a),v=null==(d=this.schedule.items)?void 0:d[f];v&&this.setBufferingItem(v),this.setSchedulePosition(f)}else if((null==h?void 0:h.identifier)===a&&h.appendInPlace){var g=n.assetList[0],p=this.getAssetPlayer(g.identifier),m=this.primaryMedia;g&&p&&m&&this.bufferAssetPlayer(p,m)}}}},{key:"onError",value:function(e,t){switch(t.details){case dO.ASSET_LIST_PARSING_ERROR:case dO.ASSET_LIST_LOAD_ERROR:case dO.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r)}}}]),i}(IO),RH=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"subtitle-stream-controller",kO)).currentTrackId=-1,s.tracksBuffered=[],s.mainDetails=null,s.registerListeners(),s}return Fc(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(fO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(fO.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(fO.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(fO.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e){this.stopLoad(),this.state=cB,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,t){this.tracksBuffered=[],Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t)}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var r=t.frag,i=t.success;if(uN(r)&&(this.fragPrevious=r),this.state=cB,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var a,s=r.start,o=0;o<n.length;o++)if(s>=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n,a=i-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),vd(n=this.tracksBuffered).call(n,(function(e){for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}})),this.fragmentTracker.removeFragmentsInRange(r,a,kO)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===kO&&(t.details===dO.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==uB&&(this.state=cB))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks;this.levels&&iK(this.levels,i)?this.levels=Pk(i).call(i,(function(e){return new nF(e)})):(this.tracksBuffered=[],this.levels=Pk(i).call(i,(function(e){var t=new nF(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,kO),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!==uB&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,i,n,a,s,o,l=this.currentTrackId,u=this.levels,c=t.details,h=t.id;if(u){var d=u[h];if(!(h>=u.length)&&d){this.log(_d(r=_d(i=_d(n=_d(a="Subtitle track ".concat(h," loaded [")).call(a,c.startSN,",")).call(n,c.endSN,"]")).call(i,c.lastPartSn?_d(s="[part-".concat(c.lastPartSn,"-")).call(s,c.lastPartIndex,"]"):"",",duration:")).call(r,c.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;if(c.live||null!=(o=d.details)&&o.live){var f=this.mainDetails;if(c.deltaUpdateFailed||!f)return;var v,g=f.fragments[0];if(d.details)0===this.alignPlaylists(c,d.details,null==(v=this.levelLastLoaded)?void 0:v.details)&&g&&JU(c,g.start);else c.hasProgramDateTime&&f.hasProgramDateTime?(oB(c,f),c.fragmentStart):g&&JU(c,g.start)}if(d.details=c,this.levelLastLoaded=d,h===l)if(this.hls.trigger(fO.SUBTITLE_TRACK_UPDATED,{details:c,id:h,groupId:t.groupId}),this.tick(),c.live&&!this.fragCurrent&&this.media&&this.state===cB)mF(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&&nU(n.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,aU(n.method)).catch((function(e){throw a.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();a.trigger(fO.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){var r;t.warn(_d(r="".concat(e.name,": ")).call(r,e.message)),t.state=cB}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===cB){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=qN.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=mF(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(uN(d=this.mapToInitFragWhenRequired(d))){var p=u[d.sn-l.startSN-1];p&&p.cc===d.cc&&this.fragmentTracker.getState(p)===OF&&(d=p)}this.fragmentTracker.getState(d)===OF&&this.loadFragment(d,r,s)}}else this.state=cB}},{key:"loadFragment",value:function(e,t,r){uN(e)?Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r):this._loadInitSegment(e,t)}},{key:"mediaBufferTimeRanges",get:function(){return new IH(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(TB),IH=Fc((function e(r){t(this,e),this.buffered=void 0;var i=function(e,t,i){var n,a;if((t>>>=0)>i-1)throw new DOMException(_d(n=_d(a="Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (")).call(a,t,") is greater than the maximum bound (")).call(n,i,")"));return r[t][e]};this.buffered={get length(){return r.length},end:function(e){return i("end",e,r.length)},start:function(e){return i("start",e,r.length)}}})),DH={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},_H=function(e){return String.fromCharCode(DH[e]||e)},wH=15,CH=100,PH={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},xH={17:2,18:4,21:6,22:8,23:10,19:13,20:15},MH={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},OH={25:2,26:4,29:6,30:8,31:10,27:13,28:15},FH=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],NH=function(){function e(){t(this,e),this.time=null,this.verboseLevel=0}return Fc(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r,i,n="function"==typeof t?t():t;xO.log(_d(r=_d(i="".concat(this.time," [")).call(i,e,"] ")).call(r,n))}}}]),e}(),UH=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},BH=function(){function e(){t(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return Fc(e,[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}]),e}(),GH=function(){function e(){t(this,e),this.uchar=" ",this.penState=new BH}return Fc(e,[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}]),e}(),KH=function(){function e(r){t(this,e),this.chars=[],this.pos=0,this.currPenState=new BH,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<CH;i++)this.chars.push(new GH);this.logger=r}return Fc(e,[{key:"equals",value:function(e){for(var t=0;t<CH;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<CH;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<CH;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>CH&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=CH)}},{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=_H(e);this.pos>=CH?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<CH;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<CH;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}(),HH=function(){function e(r){t(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<wH;i++)this.rows.push(new KH(r));this.logger=r}return Fc(e,[{key:"reset",value:function(){for(var e=0;e<wH;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,r=0;r<wH;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<wH;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<wH;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 = "+jI(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<wH;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 = "+jI(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=sg(e=this.rows).call(e,i,1)[0];n.clear(),sg(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<wH;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(MS(a).call(a)))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),VH=function(){function e(r,i,n){t(this,e),this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=r,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new HH(n),this.nonDisplayedMemory=new HH(n),this.lastOutputScreen=new HH(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}return Fc(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return i+": "+t.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(function(){return"DISP: "+e.displayedMemory.getDisplayText()}))}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+jI(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}(),jH=function(){function e(r,i,n){t(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new NH;this.channels=[null,new VH(r,i,a),new VH(r+1,n,a)]}return Fc(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r=this;this.logger.time=e;for(var i=function(e){var i=127&t[e],n=127&t[e+1],a=!1,s=null;if(0===i&&0===n)return"continue";r.logger.log(3,(function(){return"["+UH([t[e],t[e+1]])+"] -> ("+UH([i,n])+")"}));var o=r.cmdHistory;if(i>=16&&i<=31){if(function(e,t,r){return r.a===e&&r.b===t}(i,n,o))return YH(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+UH([i,n])+") is dropped"})),"continue";YH(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 YH(null,null,o);if(!a&&(s=r.parseChars(i,n))){var l=r.currentChannel;if(l&&l>0)r.channels[l].insertChars(s);else r.logger.log(2,"No channel found yet. TEXT-MODE?")}a||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+UH([i,n])+" orig: "+UH([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 ("+UH([e,t])+")"})),!0)}return!1}},{key:"parsePAC",value:function(e,t){var r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var i=e<=23?1:2;r=t>=64&&t<=95?1===i?PH[e]:MH[e]:1===i?xH[e]:OH[e];var n=this.channels[i];return!!n&&(n.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}},{key:"interpretPAC",value:function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}},{key:"parseChars",value:function(e,t){var r,i,n=null,a=null;(e>=25?(r=2,a=e-8):(r=1,a=e),a>=17&&a<=19)?(i=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+_H(i)+"' in channel "+r})),n=[i]):e>=32&&e<=127&&(n=0===t?[e]:[e,t]);return n&&this.logger.log(3,(function(){return"Char codes = "+UH(n).join(",")})),n}},{key:"parseBackgroundAttributes",value:function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=FH[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<yv(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}YH(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 YH(e,t,r){r.a=e,r.b=t}var qH=function(){if(null!=uU&&uU.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(!lv(e))return!1;var r=t.toLowerCase();return!!~av(e).call(e,r)&&r}function i(e){return r(t,e)}function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,h=t,d=a,f=s,v=null,g="",p=!0,m="auto",y="start",E=50,k="middle",T=50,S="middle";iT(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),iT(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),iT(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}})),iT(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}})),iT(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),iT(o,"region",n({},l,{get:function(){return v},set:function(e){v=e,this.hasBeenReset=!0}})),iT(o,"vertical",n({},l,{get:function(){return g},set:function(t){var i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),iT(o,"snapToLines",n({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),iT(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}})),iT(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}})),iT(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}})),iT(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}})),iT(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}})),iT(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}(),WH=function(){function e(){t(this,e)}return Fc(e,[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}]),e}();function zH(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+bS(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?bS(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var XH=function(){function e(){t(this,e),this.values=aT(null)}return Fc(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(oO(this)[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?oO(this)[e]:t[r]:this.has(e)?oO(this)[e]:t}},{key:"has",value:function(e){return e in oO(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,Rk(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=bS(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function QH(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);if(2===s.length)t(s[0],s[1])}}var $H=new qH(0,0,""),JH="middle"===$H.align?"middle":"center";function ZH(e,t,r){var i=e;function n(){var t=zH(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"!==Bv(e).call(e,0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=Bv(e).call(e,3),a(),t.endTime=n(),a(),function(e,t){var i=new XH;QH(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",JH,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",JH,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",JH,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===$H.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",JH);var a=i.get("position","auto");"auto"===a&&50===$H.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function eV(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var tV=function(){function e(){t(this,e),this.state="INITIAL",this.buffer="",this.decoder=new WH,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return Fc(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=eV(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=Bv(e).call(e,0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=Bv(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)?QH(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 qH(0,0,""),t.state="CUE",-1===av(i).call(i,"--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{ZH(i,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==av(i).call(i,"--\x3e");if(!i||s&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch(o){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}]),e}(),rV=/\r\n|\n\r|\n|\r/g,iV=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Bv(e).call(e,r,r+t.length)===t};function nV(e,t,r){return dH(e.toString())+dH(t.toString())+dH(r)}function aV(e,t,r,i,n,a,s){var o,l,u=new tV,c=MS(o=zF(new Uint8Array(e))).call(o).replace(rV,"\n").split("\n"),h=[],d=t?function(e){return FG(e,OG,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=KG(9e4*(e.startTime+o-g),9e4*n)/9e4;e.startTime=Math.max(f,0),e.endTime=Math.max(f+c,0);var p=MS(a=e.text).call(a);e.text=decodeURIComponent(encodeURIComponent(p)),e.id||(e.id=nV(e.startTime,e.endTime,p)),e.endTime>0&&h.push(e)},u.onparsingerror=function(e){l=e},u.onflush=function(){l?s(l):a(h)},vd(c).call(c,(function(e){if(p){if(iV(e,"X-TIMESTAMP-MAP=")){var t;p=!1,vd(t=Bv(e).call(e,16).split(",")).call(t,(function(e){iV(e,"LOCAL:")?f=Bv(e).call(e,6):iV(e,"MPEGTS:")&&(v=Rk(Bv(e).call(e,7)))}));try{g=function(e){var t=Rk(Bv(e).call(e,-3)),r=Rk(Bv(e).call(e,-6,-4)),i=Rk(Bv(e).call(e,-9,-7)),n=e.length>9?Rk(e.substring(0,av(e).call(e,":"))):0;if(!(lO(t)&&lO(r)&&lO(i)&&lO(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*i,t+36e5*n}(f)/1e3}catch(JV){l=JV}return}""===e&&(p=!1)}u.parse(e+"\n")})),u.flush()}var sV="stpp.ttml.im1t",oV=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,lV=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,uV={left:"start",center:"center",right:"end",start:"start",end:"end"};function cV(e,t,r,i){var n=TN(new Uint8Array(e),["mdat"]);if(0!==n.length){var a=Pk(n).call(n,(function(e){return zF(e)})),s=function(e,t){return FG(e,t,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}(t.baseTime,1,t.timescale);try{vd(a).call(a,(function(e){return r(function(e,t){var r,i,n=(new DOMParser).parseFromString(e,"text/xml"),a=n.getElementsByTagName("tt")[0];if(!a)throw new Error("Invalid ttml");var s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},o=kC(r=yv(s)).call(r,(function(e,t){return e[t]=a.getAttribute("ttp:".concat(t))||s[t],e}),{}),l="preserve"!==a.getAttribute("xml:space"),u=dV(hV(a,"styling","style")),c=dV(hV(a,"layout","region")),h=hV(a,"body","[begin]");return xk(i=Pk([]).call(h,(function(e){var r=fV(e,l);if(!r||!e.hasAttribute("begin"))return null;var i=pV(e.getAttribute("begin"),o),n=pV(e.getAttribute("dur"),o),a=pV(e.getAttribute("end"),o);if(null===i)throw gV(e);if(null===a){if(null===n)throw gV(e);a=i+n}var s=new qH(i-t,a-t,r);s.id=nV(s.startTime,s.endTime,s.text);var h=function(e,t,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;s&&r.hasOwnProperty(s)&&(n=r[s]);return kC(a).call(a,(function(r,a){var s=vV(t,i,a)||vV(e,i,a)||vV(n,i,a);return s&&(r[a]=s),r}),{})}(c[e.getAttribute("region")],u[e.getAttribute("style")],u),d=h.textAlign;if(d){var f=uV[d];f&&(s.lineAlign=f),s.align=d}return LO(s,h),s}))).call(i,(function(e){return null!==e}))}(e,s))}))}catch(JV){i(JV)}}else i(new Error("Could not parse IMSC1 mdat"))}function hV(e,t,r){var i=e.getElementsByTagName(t)[0];return i?Bv([]).call(i.querySelectorAll(r)):[]}function dV(e){return kC(e).call(e,(function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function fV(e,t){var r;return kC(r=Bv([]).call(e.childNodes)).call(r,(function(e,r,i){var n,a;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?fV(r,t):t?e+MS(a=r.textContent).call(a).replace(/\s+/g," "):e+r.textContent}),"")}function vV(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function gV(e){return new Error("Could not parse ttml timestamp ".concat(e))}function pV(e,t){if(!e)return null;var r=zH(e);return null===r&&(oV.test(e)?r=function(e,t){var r=oV.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):lV.test(e)&&(r=function(e,t){var r=lV.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}var mV=function(){function e(r,i){t(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=r,this.trackName=i}return Fc(e,[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}]),e}(),yV=function(){function e(r){t(this,e),this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=r,this.config=r.config,this.Cues=r.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},r.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),r.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),r.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(fO.FRAG_LOADING,this.onFragLoading,this),r.on(fO.FRAG_LOADED,this.onFragLoaded,this),r.on(fO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),r.on(fO.FRAG_DECRYPTED,this.onFragDecrypted,this),r.on(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),r.on(fO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),r.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this)}return Fc(e,[{key:"destroy",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(fO.FRAG_LOADING,this.onFragLoading,this),e.off(fO.FRAG_LOADED,this.onFragLoaded,this),e.off(fO.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(fO.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(fO.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(fO.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(fO.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 mV(this,"textTrack1"),t=new mV(this,"textTrack2"),r=new mV(this,"textTrack3"),i=new mV(this,"textTrack4");this.cea608Parser1=new jH(1,e,t),this.cea608Parser2=new jH(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(fO.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===yO&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],vd(o).call(o,(function(e){r.onFragLoaded(fO.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(kV(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,lH(r[e]),sH(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(fO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}}},{key:"createTextTrack",value:function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var r,i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;vd(r=yv(n)).call(r,(function(e){lH(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++)lH(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks||[],n=KT(i).call(i,(function(e){return e.textCodec===sV}));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(iK(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a,s=this.media,o=s?cH(s.textTracks):null;if(vd(a=this.tracks).call(a,(function(e,t){var i;if(o){for(var n=null,a=0;a<o.length;a++)if(o[a]&&kV(o[a],e)){n=o[a],o[a]=null;break}n&&(i=n)}if(i)lH(i);else{var s=EV(e);(i=r.createTextTrack(s,e.name,e.lang))&&(i.mode="disabled")}i&&r.textTracks.push(i)})),null!=o&&o.length){var l,u=Pk(l=xk(o).call(o,(function(e){return null!==e}))).call(l,(function(e){return e.label}));u.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(u.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){var c,h=Pk(c=this.tracks).call(c,(function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(fO.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:h})}}}},{key:"onManifestLoaded",value:function(e,t){var r,i=this;this.config.enableCEA708Captions&&t.captions&&vd(r=t.captions).call(r,(function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var r="textTrack".concat(t[1]),n=i.captionsProperties[r];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}}))}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===yO){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===kO)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===sV?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(fO.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;cV(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(fO.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){i.logger.log("Failed to parse IMSC1: ".concat(t)),i.trigger(fO.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;aV(null!=(t=i.initSegment)&&t.data?wN(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(fO.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(fO.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||cV(t,this.initPTS[e.cc],(function(){i.textCodec=sV,r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))}},{key:"_appendCues",value:function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;vd(e).call(e,(function(e){return oH(i,e)}))}else{var n=this.tracks[t];if(!n)return;var a=n.default?"default":"subtitles"+t;r.trigger(fO.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===kO&&this.onFragLoaded(fO.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!==yO||"NONE"!==this.closedCaptionsForLevel(r))for(var n=0;n<i.length;n++){var a=i[n].bytes;if(a){this.cea608Parser1||this.initCea608Parsers();var s=this.extractCea608Data(a);this.cea608Parser1.addData(i[n].pts,s[0]),this.cea608Parser2.addData(i[n].pts,s[1])}}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.endOffsetSubtitles,a=t.type,s=this.media;if(s&&!(s.currentTime<i)){if(!a||"video"===a){var o,l=this.captionsTracks;vd(o=yv(l)).call(o,(function(e){return uH(l[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u,c=this.textTracks;vd(u=yv(c)).call(u,(function(e){return uH(c[e],r,n)}))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],r=31&e[0],i=2,n=0;n<r;n++){var a=e[i++],s=127&e[i++],o=127&e[i++];if(0!==s||0!==o)if(0!=(4&a)){var l=3&a;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}();function EV(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function kV(e,t){return!!e&&e.kind===EV(t)&&aK(t,e)}var TV=/\s/,SV={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++)TV.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=eV(MS(l).call(l)),g=nV(t,r,v);null!=e&&null!=(d=e.cues)&&d.getCueById(g)||((a=new c(t,r,v)).id=g,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return e&&u.length&&(mA(u).call(u,(function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),vd(u).call(u,(function(t){return oH(e,t)}))),u}};var AV=/(\d+)-(\d+)\/(\d+)/,LV=function(){function e(r){t(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=r.fetchSetup||bV,this.controller=new self.AbortController,this.stats=new nN}return Fc(e,[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(LO({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s=r.onProgress,o="arraybuffer"===e.responseType,l=o?"byteLength":"length",u=t.loadPolicy,c=u.maxTimeToFirstByteMs,h=u.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=c&&lO(c)?c:h,this.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),t.timeout),(JG(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(a){i.response=i.loader=a;var l=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=h,i.requestTimeout=Wf((function(){i.abortInternal(),r.onTimeout(n,e,i.response)}),h-(l-n.loading.start)),!a.ok){var u=a.status,c=a.statusText;throw new RV(c||"fetch, bad network response",u,a)}return n.loading.first=l,n.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=AV.exec(e);if(t)return Rk(t[2])-Rk(t[1])+1}(t);if(lO(r))return r}var i=e.get("Content-Length");if(i)return Rk(i)}(a.headers)||n.total,s&&lO(t.highWaterMark)?i.loadProgressively(a,n,e,t.highWaterMark,s):o?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=a[l];u&&(n.loaded=n.total=u);var c={url:o.url,data:a,code:o.status};s&&!lO(t.highWaterMark)&&s(n,e,a,o),r.onSuccess(c,n,e,o)})).catch((function(t){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;r.onError({code:a,text:s},e,t?t.details:null,n)}}))}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?bS(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4?arguments[4]:void 0,a=new SB,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),nk.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 nk.reject()}))}()}}]),e}();function bV(e,t){return new self.Request(e.url,t)}var RV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e)).code=void 0,s.details=void 0,s.code=n,s.details=a,s}return Fc(i)}(tC(Error)),IV=/^age:\s*[\d.]+\s*$/im,DV=function(){function e(r){t(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=r&&r.xhrSetup||null,this.stats=new nN,this.retryDelay=0}return Fc(e,[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?nk.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=sT(i=this.readystatechange).call(i,this),e.onprogress=sT(n=this.loadprogress).call(n,this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=l&&lO(l)?l:u,this.requestTimeout=Wf(sT(a=this.loadtimeout).call(a,this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,n=this.config;if(!r.aborted&&i>=2){var a;if(0===r.loading.first)if(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs)self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=Wf(sT(a=this.loadtimeout).call(a,this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start));if(4===i){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var s=t.status,o="text"===t.responseType?t.responseText:null;if(s>=200&&s<300){var l=null!=o?o:t.response;if(null!=l){r.loading.end=Math.max(self.performance.now(),r.loading.first);var u="arraybuffer"===t.responseType?l.byteLength:l.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;var h={url:t.responseURL,data:l,code:s};return void this.callbacks.onSuccess(h,r,e,t)}}var d,f=n.loadPolicy.errorRetry;if(bF(f,r.retry,!1,{url:e.url,data:void 0,code:s}))this.retry(f);else xO.error(_d(d="".concat(s," while loading ")).call(d,e.url)),this.callbacks.onError({code:s,text:t.statusText},e,t,r)}}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(bF(e,this.stats.retry,!0))this.retry(e);else{var t;xO.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=AF(e,o.retry),o.retry++,xO.warn(_d(t=_d(r=_d(i=_d(n="".concat(status?"HTTP Status "+status:"Timeout"," while loading ")).call(n,null==s?void 0:s.url,", retrying ")).call(i,o.retry,"/")).call(r,e.maxNumRetry," in ")).call(t,this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=Wf(sT(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&&IV.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?bS(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp("^".concat(e,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}]),e}(),_V=RO(RO({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:DV,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:gF,bufferController:fK,capLevelController:pK,errorController:xF,fpsController:aH,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:DU,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:SV,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:RH,subtitleTrackController:hH,timelineController:yV,audioStreamController:sK,audioTrackController:lK,emeController:iH,cmcdController:ZK,contentSteeringController:eH,interstitialsController:bH});function wV(e){var t;return e&&"object"===Cc(e)?lv(e)?Pk(e).call(e,wV):kC(t=yv(e)).call(t,(function(t,r){return t[r]=wV(e[r]),t}),{}):e}function CV(e,t){var r=e.loader;r!==LV&&r!==DV?(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=LV,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}function PV(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function xV(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,jI(n?RO({type:n},i):i))}return a}var MV=function(){var e=PV();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();var OV=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){i.hls&&i.hls.trigger(fO.EVENT_CUE_ENTER,{})},this.hls=r,this._registerListeners()}return Fc(e,[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e.on(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(fO.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(fO.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(fO.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(fO.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&&lH(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 sH(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){var a=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=PV();if(s)for(var o=0;o<a.length;o++){var l=a[o].type;if((l!==$B.emsg||i)&&n){var u=WB(a[o].data);if(u){var c=a[o].pts,h=c+a[o].duration;h>MV&&(h=MV),h-c<=0&&(h=c+.25);for(var d=0;d<u.length;d++){var f=u[d];if(!zB(f)){this.updateId3CueEnds(c,l);var v=xV(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===MV&&(a.endTime=e)}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,a=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(l||u))uH(a,r,i,"audio"===n?function(e){return e.type===$B.audioId3&&u}:"video"===n?function(e){return e.type===$B.emsg&&l}:function(e){return e.type===$B.audioId3&&u||e.type===$B.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=yv(a),o=this.dateRangeCuesAppended;if(n&&t)if(null!=(i=n.cues)&&i.length)for(var l,u=xk(l=yv(o)).call(l,(function(e){return!uD(s).call(s,e)})),c=function(){var e,t=u[h],i=o[t].cues;delete o[t],vd(e=yv(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&&lO(null==d?void 0:d.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var f=PV(),v=function(){var e=s[g],t=a[e],i=t.startTime,n=o[e],l=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,c=MV,h=t.duration;if(t.endDate&&null!==h)c=i+h,u=!0;else if(t.endOnNext&&!u){var d=kC(s).call(s,(function(e,r){if(r!==t.id){var i=a[r];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate<e.startDate))return i}return e}),null);d&&(c=d.startTime,u=!0)}for(var v,p,m=yv(t.attr),y=0;y<m.length;y++){var E=m[y];if("ID"!==(p=E)&&"CLASS"!==p&&"CUE"!==p&&"START-DATE"!==p&&"DURATION"!==p&&"END-DATE"!==p&&"END-ON-NEXT"!==p){var k=l[E];if(k)u&&!n.durationKnown?k.endTime=c:Math.abs(k.startTime-i)>.01&&(k.startTime=i,k.endTime=c);else if(f){var T=t.attr[E];tU(E)&&(v=T,T=Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=xV(f,i,c,{key:E,data:T},$B.dateRange);S&&(S.id=e,r.id3Track.addCue(S),l[E]=S,r.hls.config.interstitialsController&&("X-ASSET-LIST"!==E&&"X-ASSET-URL"!==E||S.addEventListener("enter",r.onEventCueEnter)))}}}o[e]={cues:l,dateRange:t,durationKnown:u}},g=0;g<s.length;g++)v()}}}}]),e}(),FV=function(){function e(r){var i=this;t(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=i.media,t=i.hls.latestLevelDetails;if(e&&t){i.currentTime=e.currentTime;var r=i.computeLatency();if(null!==r){i._latency=r;var n=i.config,a=n.lowLatencyMode,s=n.maxLiveSyncPlaybackRate;if(a&&1!==s&&t.live){var o=i.targetLatency;if(null!==o){var l=r-o;if(l<Math.min(i.maxLatency,o+t.targetduration)&&l>.05&&i.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),c=Math.round(2/(1+Math.exp(-.75*l-i.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},this.hls=r,this.config=r.config,this.registerListeners()}return Fc(e,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e,t=this.config;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;var r=null==(e=this.hls)?void 0:e.latestLevelDetails;return r?t.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var c=i;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var r=this.hls.latestLevelDetails;if(null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.hls.latestLevelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.hls.latestLevelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.hls.latestLevelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){this.hls.on(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(fO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(fO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(fO.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){this.hls.off(fO.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(fO.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(fO.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(fO.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===dO.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}(),NV=function(e){Ph(i,e);var r=ed(i);function i(e,n){var a;return t(this,i),(a=r.call(this,e,"level-controller"))._levels=[],a._firstLevel=-1,a._maxAutoLevel=-1,a._startLevel=void 0,a.currentLevel=null,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.steering=void 0,a.onParsedComplete=void 0,a.steering=n,a._registerListeners(),a}return Fc(i,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.on(fO.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this),e.off(fO.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),Ih(Rh(i.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){var e=this._levels;vd(e).call(e,(function(e){e.loadError=0,e.fragmentError=0})),Ih(Rh(i.prototype),"stopLoad",this).call(this)}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var r,i=this,n=this.hls.config.preferManagedMediaSource,a=[],s={},o={},l=!1,u=!1,c=!1;vd(r=t.levels).call(r,(function(e){var t,r,h,d,f,v,g,p=e.attrs,m=e.audioCodec,y=e.videoCodec;m&&(e.audioCodec=m=jO(m,n)||void 0),0===(null==(g=y)?void 0:av(g).call(g,"avc1"))&&(y=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var n,a=i.shift()+".";a+=Rk(i.shift()).toString(16),a+=Bv(n="000"+Rk(i.shift()).toString(16)).call(n,-4),t[r]=a}}return t.join(",")}(y));var E=e.width,k=e.height,T=e.unknownCodecs,S=T?T.length:0;if(T)for(var A=S;A--;){var L,b=T[A];if(i.isAudioSupported(b))e.audioCodec=m=m?_d(L="".concat(m,",")).call(L,b):b,S--,FO.audio[m.substring(0,4)]=2;else if(i.isVideoSupported(b)){var R;e.videoCodec=y=y?_d(R="".concat(y,",")).call(R,b):b,S--,FO.video[y.substring(0,4)]=2}}if(l||(l=!(!E||!k)),u||(u=!!y),c||(c=!!m),!(S||m&&!i.isAudioSupported(m)||y&&!i.isVideoSupported(y))){var I=p.CODECS,D=p["FRAME-RATE"],_=p["HDCP-LEVEL"],w=p["PATHWAY-ID"],C=p.RESOLUTION,P=p["VIDEO-RANGE"],x="".concat(w||".","-"),M=_d(t=_d(r=_d(h=_d(d=_d(f=_d(v="".concat(x)).call(v,e.bitrate,"-")).call(f,C,"-")).call(d,D,"-")).call(h,I,"-")).call(r,P,"-")).call(t,_);if(s[M])if(s[M].uri===e.url||e.attrs["PATHWAY-ID"])s[M].addGroupId("audio",p.AUDIO),s[M].addGroupId("text",p.SUBTITLES);else{var O=o[M]+=1;e.attrs["PATHWAY-ID"]=new Array(O+1).join(".");var F=new nF(e);s[M]=F,a.push(F)}else{var N=new nF(e);s[M]=N,o[M]=1,a.push(N)}}})),this.filterAndSortMediaOptions(a,t,l,u,c)}},{key:"isAudioSupported",value:function(e){return NO(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return NO(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,i,n){var a=this,s=[],o=[],l=e;if((r||i)&&n&&(l=xk(l).call(l,(function(e){var t,r=e.videoCodec,i=e.videoRange,n=e.width,a=e.height;return(!!r||!(!n||!a))&&(!!(t=i)&&av(JO).call(JO,t)>-1)}))),0!==l.length){var u;if(t.audioTracks)UV(s=xk(u=t.audioTracks).call(u,(function(e){return!e.audioCodec||a.isAudioSupported(e.audioCodec)})));t.subtitles&&UV(o=t.subtitles);var c=Bv(l).call(l,0);mA(l).call(l,(function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return av(JO).call(JO,e.videoRange)-av(JO).call(JO,t.videoRange);if(e.videoCodec!==t.videoCodec){var i=GO(e.videoCodec),n=GO(t.videoCodec);if(i!==n)return n-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=KO(e.codecSet),s=KO(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var h=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==c.length)for(var d=0;d<c.length;d++)if(c[d].pathwayId===l[0].pathwayId){h=c[d];break}this._levels=l;for(var f=0;f<l.length;f++)if(l[f]===h){var v,g;this._firstLevel=f;var p=h.bitrate,m=this.hls.bandwidthEstimate;if(this.log(_d(v="manifest loaded, ".concat(l.length," level(s) found, first bitrate: ")).call(v,p)),void 0===(null==(g=this.hls.userConfig)?void 0:g.abrEwmaDefaultEstimate)){var y=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);y>m&&m===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=y)}break}var E=n&&!i,k={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:i,altAudio:!E&&KT(s).call(s,(function(e){return!!e.url}))};this.hls.trigger(fO.MANIFEST_PARSED,k)}else nk.resolve().then((function(){if(a.hls){t.levels.length&&a.warn("One or more CODECS in variant not supported: ".concat(jI(t.levels[0].attrs)));var e=new Error("no level with compatible codecs found in manifest");a.hls.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.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(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,l.length-1)}var h=this.currentLevelIndex,d=this.currentLevel,f=d?d.attrs["PATHWAY-ID"]:void 0,v=l[e],g=v.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=v,h!==e||!d||f!==g){this.log(_d(t=_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Switching to level ".concat(e," (")).call(o,v.height?v.height+"p ":"")).call(s,v.videoRange?v.videoRange+" ":"")).call(a,v.codecSet?v.codecSet+" ":"","@")).call(n,v.bitrate,")")).call(i,g?" with Pathway "+g:""," from level ")).call(r,h)).call(t,f?" with Pathway "+f:""));var p={level:e,attrs:v.attrs,details:v.details,bitrate:v.bitrate,averageBitrate:v.averageBitrate,maxBitrate:v.maxBitrate,realBitrate:v.realBitrate,width:v.width,height:v.height,codecSet:v.codecSet,audioCodec:v.audioCodec,videoCodec:v.videoCodec,audioGroups:v.audioGroups,subtitleGroups:v.subtitleGroups,loaded:v.loaded,loadError:v.loadError,fragmentError:v.fragmentError,name:v.name,id:v.id,uri:v.uri,url:v.url,urlId:0,audioGroupIds:v.audioGroupIds,textGroupIds:v.textGroupIds};this.hls.trigger(fO.LEVEL_SWITCHING,p);var m=v.details;if(!m||m.live){var y=this.switchParams(v.uri,null==d?void 0:d.details,m);this.loadPlaylist(y)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t,r=this.steering.pathways(),i=xk(e).call(e,(function(e){return-1!==av(r).call(r,e)}));if(e.length<1)return void this.warn(_d(t="pathwayPriority ".concat(e," should contain at least one pathway from list: ")).call(t,r));this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===gO&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===yO){var i,n=r.elementaryStreams;if(!KT(i=yv(n)).call(i,(function(e){return!!n[e]})))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of ".concat(a.loadError," on frag buffered")),a.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n=t.level,a=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index ".concat(n)),void(null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(n,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){Ih(Rh(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,t){var r,n,a,s;Ih(Rh(i.prototype),"loadingPlaylist",this).call(this,e,t);var o=this.getUrlWithDirectives(e.uri,t),l=this.currentLevelIndex,u=e.attrs["PATHWAY-ID"],c=e.details,h=null==c?void 0:c.age;this.log(_d(r=_d(n=_d(a=_d(s="Loading level index ".concat(l)).call(s,void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:"")).call(a,u?" Pathway "+u:"")).call(n,h&&c.live?" age "+h.toFixed(1)+(c.type&&" "+c.type||""):""," ")).call(r,o)),this.hls.trigger(fO.LEVEL_LOADING,{url:o,level:l,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t,r,i=this;if(1!==this._levels.length){var n=xk(t=this._levels).call(t,(function(t,r){if(r!==e)return!0;var n;(i.steering&&i.steering.removeLevel(t),t===i.currentLevel)&&(i.currentLevel=null,i.currentLevelIndex=-1,t.details&&vd(n=t.details.fragments).call(n,(function(e){return e.level=-1})));return!1}));rB(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(fO.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(fO.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}]),i}(oK);function UV(e){var t={};vd(e).call(e,(function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var BV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a,s){var o;return t(this,i),(o=r.call(this,"gap-controller",s.logger)).config=void 0,o.media=null,o.fragmentTracker=void 0,o.hls=void 0,o.nudgeRetry=0,o.stallReported=!1,o.stalled=null,o.moved=!1,o.seeking=!1,o.ended=0,o.config=e,o.media=n,o.fragmentTracker=a,o.hls=s,o}return Fc(i,[{key:"destroy",value:function(){this.media=null,this.hls=this.fragmentTracker=null}},{key:"poll",value:function(e,t,r,i){var n=this.config,a=this.media,s=this.stalled;if(null!==a){var o=a.currentTime,l=a.seeking,u=this.seeking&&!l,c=!this.seeking&&l;if(this.seeking=l,o===e)if(c||u)this.stalled=null;else{if(a.paused&&!l||a.ended||0===a.playbackRate||!qN.getBuffered(a).length)return!this.ended&&a.ended&&(this.ended=o||1,this.hls.trigger(fO.MEDIA_ENDED,{stalled:!1})),void(this.nudgeRetry=0);var h=qN.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===mB&&(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(fO.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(h),!this.media)return}var k=qN.bufferInfo(a,o,n.maxBufferHole);this._tryFixBufferStall(k,E)}else this.stalled=y}else if(e&&(this.ended=0),this.moved=!0,l||(this.nudgeRetry=0),null!==s){if(this.stallReported){var T,S=self.performance.now()-s;this.warn(_d(T="playback not stuck anymore @".concat(o,", after ")).call(T,Math.round(S),"ms")),this.stallReported=!1}this.stalled=null}}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s)if(this._trySkipBufferHole(s)||!this.media)return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(this.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}}},{key:"_reportStall",value:function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){var i;this.stallReported=!0;var n=new Error(_d(i="Playback stalling at @".concat(r.currentTime," due to low buffer (")).call(i,jI(e),")"));this.warn(n.message),t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.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=qN.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,yO);f&&s<f.end&&(d=!0)}if(!d){var v=e||h.getAppendedFrag(n,yO);if(v){for(var g=!1,p=v.end;p<s;){var m=h.getPartialFragment(p);if(!m){g=!0;break}p+=m.duration}if(g)return 0}}}var y=Math.max(s+.05,n+.1);if(this.warn(_d(c="skipping hole, adjusting currentTime from ".concat(n," to ")).call(c,y)),this.moved=!0,this.stalled=null,i.currentTime=y,e&&!e.gap){var E,k=new Error(_d(E="fragment loaded with buffer holes, seeking from ".concat(n," to ")).call(E,y));r.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:k,reason:k.message,frag:e})}return y}}return 0}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var n=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var a,s=n+(i+1)*e.nudgeOffset,o=new Error(_d(a="Nudging 'currentTime' from ".concat(n," to ")).call(a,s));this.warn(o.message),r.currentTime=s,t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{var l,u=new Error(_d(l="Playhead still not moving while enough data buffered @".concat(n," after ")).call(l,e.nudgeMaxRetry," nudges"));this.error(u.message),t.trigger(fO.ERROR,{type:hO.MEDIA_ERROR,details:dO.BUFFER_STALLED_ERROR,error:u,fatal:!0})}}}}]),i}(IO);function GV(){return self.SourceBuffer||self.WebKitSourceBuffer}function KV(){if(!MO())return!1;var e=GV();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var HV=function(e){Ph(i,e);var r=ed(i);function i(e,n,a){var s;return t(this,i),(s=r.call(this,e,n,a,"stream-controller",yO)).audioCodecSwap=!1,s.gapController=null,s.level=-1,s._forceStartLoad=!1,s._hasEnoughToStart=!1,s.altAudio=0,s.audioOnly=!1,s.fragPlaying=null,s.fragLastKbps=0,s.couldBacktrack=!1,s.backtrackFragment=null,s.audioCodecSwitch=!1,s.videoBuffer=null,s.onMediaPlaying=function(){var e=s.gapController;e&&(e.ended=0),s.tick()},s.onMediaSeeked=function(){var e=s.media,t=e?e.currentTime:null;lO(t)&&s.log("Media seeked to ".concat(t.toFixed(3)));var r=s.getMainFwdBufferInfo();null!==r&&0!==r.len?s.tick():s.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"))},s.registerListeners(),s}return Fc(i,[{key:"registerListeners",value:function(){Ih(Rh(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.on(fO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(fO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(fO.BUFFER_CREATED,this.onBufferCreated,this),e.on(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(fO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){Ih(Rh(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(fO.MANIFEST_PARSED,this.onManifestParsed,this),e.off(fO.LEVEL_LOADED,this.onLevelLoaded,this),e.off(fO.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(fO.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(fO.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(fO.BUFFER_CREATED,this.onBufferCreated,this),e.off(fO.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(fO.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(fO.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),Ih(Rh(i.prototype),"onHandlerDestroying",this).call(this)}},{key:"startLoad",value:function(e,t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var n=i.startLevel;-1===n&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.firstAutoLevel),i.nextLoadLevel=n,this.level=i.loadLevel,this._hasEnoughToStart=!1}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r),this.state=cB,this.nextLoadPosition=this.lastCurrentTime=e,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=uB}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,Ih(Rh(i.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case kB: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=cB;break}if(this.hls.nextLoadLevel!==this.level){this.state=cB;break}break;case fB: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=cB}}this.state===cB&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){Ih(Rh(i.prototype),"onTickEnd",this).call(this),this.checkBuffer(),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[n]){var a=r[n],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return 2===this.altAudio&&(l.type="video"),this.hls.trigger(fO.BUFFER_EOS,l),void(this.state=mB)}if(this.buffering){var u;if(e.loadLevel!==n&&-1===e.manualLevel)this.log(_d(u="Adapting to level ".concat(n," from level ")).call(u,this.level));this.level=e.nextLoadLevel=n;var c=a.details;if(!c||this.state===kB||this.waitForLive(a))return this.level=n,this.state=kB,void(this.startFragRequested=!1);var h=s.len,d=this.getMaxBufferLength(a.maxBitrate);if(!(h>=d)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:s.end,v=this.getNextFragment(f,c);if(this.couldBacktrack&&!this.fragPrevious&&v&&uN(v)&&this.fragmentTracker.getState(v)!==UF){var g,p=(null!=(g=this.backtrackFragment)?g:v).sn-c.startSN,m=c.fragments[p-1];m&&v.cc===m.cc&&(v=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,f)){if(!v.gap){var y=this.audioOnly&&!this.altAudio?aN:sN,E=(y===sN?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,y,yO)}v=this.getNextFragmentLoopLoading(v,c,s,yO,d)}v&&(!v.initSegment||v.initSegment.data||this.bitrateTest||(v=v.initSegment),this.loadFragment(v,a,f))}}}}}}},{key:"loadFragment",value:function(e,t,r){var n=this.fragmentTracker.getState(e);if(n===OF||n===NF)if(uN(e))if(this.bitrateTest){var a;this.log(_d(a="Fragment ".concat(e.sn," of level ")).call(a,e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,t)}else Ih(Rh(i.prototype),"loadFragment",this).call(this,e,t,r);else this._loadInitSegment(e,t);else this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,yO)}},{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 hB:case dB:case fB:case gB:case pB:this.state=cB}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,t){Ih(Rh(i.prototype),"flushMainBuffer",this).call(this,e,t,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,t){Ih(Rh(i.prototype),"onMediaAttached",this).call(this,e,t);var r=t.media;r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked),r.addEventListener("playing",this.onMediaPlaying),r.addEventListener("seeked",this.onMediaSeeked),this.gapController=new BV(this.config,r,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;r&&(r.removeEventListener("playing",this.onMediaPlaying),r.removeEventListener("seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),Ih(Rh(i.prototype),"onMediaDetaching",this).call(this,e,t),!!t.transferMedia||(this._hasEnoughToStart=!1)}},{key:"triggerEnded",value:function(){var e=this.gapController;if(e){var t;if(e.ended)return;e.ended=(null==(t=this.media)?void 0:t.currentTime)||1}this.hls.trigger(fO.MEDIA_ENDED,{stalled:!1})}},{key:"onManifestLoading",value:function(){Ih(Rh(i.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(fO.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){var r,i,n,a=!1,s=!1;vd(r=t.levels).call(r,(function(e){var t=e.audioCodec;t&&(a=a||-1!==av(t).call(t,"mp4a.40.2"),s=s||-1!==av(t).call(t,"mp4a.40.5"))})),this.audioCodecSwitch=a&&s&&!("function"==typeof(null==(n=GV())||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===cB){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=kB)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,n,a,s,o,l,u,c=this.levels,h=this.startFragRequested,d=t.level,f=t.details,v=f.totalduration;if(c){this.log(_d(r=_d(i=_d(n=_d(a=_d(s=_d(o="Level ".concat(d," loaded [")).call(o,f.startSN,",")).call(s,f.endSN,"]")).call(a,f.lastPartSn?_d(l="[part-".concat(f.lastPartSn,"-")).call(l,f.lastPartIndex,"]"):"",", cc [")).call(n,f.startCC,", ")).call(i,f.endCC,"] duration:")).call(r,v));var g=t.levelInfo,p=this.fragCurrent;!p||this.state!==dB&&this.state!==fB||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(fO.LEVEL_UPDATED,{details:f,level:d}),this.state===kB){if(this.waitForCdnTuneIn(f))return;this.state=cB}h&&f.live&&this.synchronizeToLiveEdge(f),this.tick()}else this.warn("Levels were reset while loading level ".concat(d))}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragmentStart,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var l,u,c=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if(!o&&r.readyState<4||n<s-c)if(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState)this.warn(_d(l=_d(u="Playback: ".concat(n.toFixed(3)," is located too far from the end of live sliding playlist: ")).call(u,s,", reset currentTime to : ")).call(l,i.toFixed(3))),r.currentTime=i}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r,i,n=e.frag,a=e.part,s=e.payload,o=this.levels;if(o){var l=o[n.level];if(l){var u,c=l.details;if(!c)return this.warn(_d(u="Dropping fragment ".concat(n.sn," of level ")).call(u,n.level," after level details were reset")),void this.fragmentTracker.removeFragment(n);var h=l.videoCodec,d=c.PTSKnown||!c.live,f=null==(i=n.initSegment)?void 0:i.data,v=this._getAudioCodec(l),g=this.transmuxer=this.transmuxer||new rK(this.hls,yO,sT(t=this._handleTransmuxComplete).call(t,this),sT(r=this._handleTransmuxerFlush).call(r,this)),p=a?a.index:-1,m=-1!==p,y=new jN(n.level,n.sn,n.stats.chunkCount,s.byteLength,p,m),E=this.initPTS[n.cc];g.push(s,f,v,h,n,a,c.totalduration,d,y,E)}else this.warn("Level ".concat(n.level," not found on progress"))}else{var k;this.warn(_d(k="Levels were reset while fragment load was in progress. Fragment ".concat(n.sn," of level ")).call(k,n.level," will not be buffered"))}}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this.hls,i=2===this.altAudio;if(vF(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(fO.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger(fO.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=vF(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===yO;if(n){var a,s,o;if(this.fragContextChanged(r))return this.warn(_d(a=_d(s=_d(o="Fragment ".concat(r.sn)).call(o,i?" p: "+i.index:""," of level ")).call(s,r.level," finished buffering, but was aborted. state: ")).call(a,this.state)),void(this.state===pB&&(this.state=cB));var l=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*l.total/(l.buffering.end-l.loading.first)),uN(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=yB;else switch(t.details){case dO.FRAG_GAP:case dO.FRAG_PARSING_ERROR:case dO.FRAG_DECRYPT_ERROR:case dO.FRAG_LOAD_ERROR:case dO.FRAG_LOAD_TIMEOUT:case dO.KEY_LOAD_ERROR:case dO.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(yO,t);break;case dO.LEVEL_LOAD_ERROR:case dO.LEVEL_LOAD_TIMEOUT:case dO.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==kB||(null==(r=t.context)?void 0:r.type)!==gO||(this.state=cB);break;case dO.BUFFER_APPEND_ERROR:case dO.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===dO.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case dO.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"checkBuffer",value:function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this._hasEnoughToStart||!qN.getBuffered(e).length){var r=this.state,i=r!==cB?this.fragCurrent:null,n=this.getLevelDetails();t.poll(this.lastCurrentTime,i,n,r)}this.lastCurrentTime=e.currentTime}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=cB,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==aN||this.audioOnly&&!this.altAudio){var i=(r===sN?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,yO),this.tick()}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0){var i;if(e.seeking)return void this.log(_d(i="could not seek to ".concat(r,", already seeking at ")).call(i,t));var n=this.getLevelDetails(),a=this.config.timelineOffset;a&&r&&(r+=(null==n?void 0:n.appliedTimelineOffset)||a);var s,o,l=qN.getBuffered(e),u=l.length?l.start(0):0,c=u-r,h=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);if(c>0&&(c<h||this.loadingParts&&c<2*((null==n?void 0:n.partTarget)||0))&&(this.log("adjusting start position by ".concat(c," to match buffer start")),r+=c,this.startPosition=r),t<r)this.log(_d(s=_d(o="seek to target start position ".concat(r," from current time ")).call(o,t," buffer start ")).call(s,u)),e.currentTime=r}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==av(t).call(t,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(e){var i=r.hls,n=null==e?void 0:e.frag;if(n&&!r.fragContextChanged(n)){t.fragmentError=0,r.state=cB,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(fO.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=gB,f){if(null!=f&&f.tracks){var p=o.initSegment||o;this._bufferInitSegment(u,f.tracks,p,a),i.trigger(fO.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:f.tracks})}var m=f.initPTS,y=f.timescale;lO(m)&&(this.initPTS[o.cc]={baseTime:m,timescale:y},i.trigger(fO.INIT_PTS_FOUND,{frag:o,id:r,initPTS:m,timescale:y}))}if(c&&v){var E=v.fragments[o.sn-1-v.startSN],k=o.sn===v.startSN,T=!E||o.cc>E.cc;if(!1!==n.independent){var S=c.startPTS,A=c.endPTS,L=c.startDTS,b=c.endDTS;if(l)l.elementaryStreams[c.type]={startPTS:S,endPTS:A,startDTS:L,endDTS:b};else if(c.firstKeyFrame&&c.independent&&1===a.id&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){var R=this.getMainFwdBufferInfo(),I=(R?R.end:this.getLoadPosition())+this.config.maxBufferHole,D=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!k&&I<D-this.config.maxBufferHole&&!T)return void this.backtrack(o);T&&(o.gap=!0),o.setElementaryStreamInfo(c.type,o.start,A,o.start,b,!0)}else k&&S-(v.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(c.type,S,A,L,b),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,l,a,k||T)}else{if(!k&&!T)return void this.backtrack(o);o.gap=!0}}if(g){var _=g.startPTS,w=g.endPTS,C=g.startDTS,P=g.endDTS;l&&(l.elementaryStreams[aN]={startPTS:_,endPTS:w,startDTS:C,endDTS:P}),o.setElementaryStreamInfo(aN,_,w,C,P),this.bufferFragmentData(g,o,l,a)}if(v&&null!=d&&null!=(t=d.samples)&&t.length){var x={id:r,frag:o,details:v,samples:d.samples};i.trigger(fO.FRAG_PARSING_METADATA,x)}if(v&&h){var M={id:r,frag:o,details:v,samples:h.samples};i.trigger(fO.FRAG_PARSING_USERDATA,M)}}}else this.resetWhenMissingContext(a)}},{key:"_bufferInitSegment",value:function(e,t,r,i){var n=this;if(this.state===gB){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var a,s,o=t.audio,l=t.video,u=t.audiovideo;if(o){var c,h,d,f=YO(o.codec,e.audioCodec);"mp4a"===f&&(f="mp4a.40.5");var v,g=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){f&&(f=-1!==av(f).call(f,"mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var p=o.metadata;p&&"channelCount"in p&&1!==(p.channelCount||1)&&-1===av(g).call(g,"firefox")&&(f="mp4a.40.5")}if(f&&-1!==av(f).call(f,"mp4a.40.5")&&-1!==av(g).call(g,"android")&&"audio/mpeg"!==o.container&&(f="mp4a.40.2",this.log("Android: force audio codec to ".concat(f))),e.audioCodec&&e.audioCodec!==f)this.log(_d(v='Swapping manifest audio codec "'.concat(e.audioCodec,'" for "')).call(v,f,'"'));o.levelCodec=f,o.id="main",this.log(_d(c=_d(h=_d(d="Init audio buffer, container:".concat(o.container,", codecs[selected/level/parsed]=[")).call(d,f||"","/")).call(h,e.audioCodec||"","/")).call(c,o.codec,"]")),delete t.audiovideo}if(l){var m,y,E;l.levelCodec=e.videoCodec,l.id="main";var k=l.codec;if(4===(null==k?void 0:k.length))switch(k){case"hvc1":case"hev1":l.codec="hvc1.1.6.L120.90";break;case"av01":l.codec="av01.0.04M.08";break;case"avc1":l.codec="avc1.42e01e"}this.log(_d(m=_d(y=_d(E="Init video buffer, container:".concat(l.container,", codecs[level/parsed]=[")).call(E,e.videoCodec||"","/")).call(y,k)).call(m,l.codec!==k?" parsed-corrected="+l.codec:"","}]")),delete t.audiovideo}if(u)this.log(_d(a=_d(s="Init audiovideo buffer, container:".concat(u.container,", codecs[level/parsed]=[")).call(s,e.codecs,"/")).call(a,u.codec,"]")),delete t.video,delete t.audio;var T=yv(t);if(T.length){if(this.hls.trigger(fO.BUFFER_CODECS,t),!this.hls)return;vd(T).call(T,(function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(fO.BUFFER_APPENDING,{type:e,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,yO)}},{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=cB}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(qN.isBuffered(e,r)?t=this.getAppendedFrag(r):qN.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(fO.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(fO.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 lO(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(lO(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?mF(null,r.fragments,t):null);if(i){var n=i.programDateTime;if(null!==n){var a=n+1e3*(t-i.start);return new Date(a)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),i}(TB),VV=function(){function e(r){t(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=r}return Fc(e,[{key:"abort",value:function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}}},{key:"detach",value:function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}},{key:"createKeyLoadError",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:dO.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 HN({type:hO.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}},{key:"loadClear",value:function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,n=e.cc,a=function(){var e=t[s];if(n<=e.cc&&("initSegment"===i||"initSegment"===e.sn||i<e.sn))return r.emeController.selectKeySystemFormat(e).then((function(t){e.setKeyFormat(t)})),"break"},s=0;s<t.length;s++){if("break"===a())break}}},{key:"load",value:function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var r,i;t&&e.setKeyFormat(t);var n=e.decryptdata;if(!n){var a=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return nk.reject(this.createKeyLoadError(e,dO.KEY_LOAD_ERROR,a))}var s=n.uri;if(!s)return nk.reject(this.createKeyLoadError(e,dO.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,nk.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 nk.reject(this.createKeyLoadError(e,dO.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 nk.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new nk((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,dO.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,dO.KEY_LOAD_ERROR,new Error(_d(l="HTTP Error ".concat(e.code," loading key ")).call(l,e.text)),n,RO({url:o.url,data:void 0},e)))},onTimeout:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,dO.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(e,i,n){r.resetLoader(i),s(r.createKeyLoadError(t,dO.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 jV(e){switch(e.type){case pO:return EO;case mO:return kO;default:return yO}}function YV(e,t){var r=e.url;return void 0!==r&&0!==av(r).call(r,"data:")||(r=t.url),r}var qV=function(){function e(r){t(this,e),this.hls=void 0,this.loaders=aT(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=r,this.registerListeners()}return Fc(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.on(fO.LEVEL_LOADING,this.onLevelLoading,this),e.on(fO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(fO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(fO.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(fO.MANIFEST_LOADING,this.onManifestLoading,this),e.off(fO.LEVEL_LOADING,this.onLevelLoading,this),e.off(fO.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(fO.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(fO.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:vO,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:gO,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:pO,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:mO,url:n,deliveryDirectives:a,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[gO];if(r){var i,n=r.context;n&&!KT(i=t.levels).call(i,(function(e){return e===n.levelOrTrack}))&&(r.abort(),delete this.loaders[gO])}}},{key:"load",value:function(e){var t,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(e);if(s){var o=this.hls.logger,l=s.context;if(l&&l.levelOrTrack===e.levelOrTrack&&(l.url===e.url||l.deliveryDirectives&&!e.deliveryDirectives)){var u;if(l.url===e.url)o.log("[playlist-loader]: ignore ".concat(e.url," ongoing request"));else o.log(_d(u="[playlist-loader]: ignore ".concat(e.url," in favor of ")).call(u,l.url));return}o.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if((r=e.type===vO?a.manifestLoadPolicy.default:LO({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),lO(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===gO&&null!==e.level?i=this.hls.levels[e.level].details:e.type===pO&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===mO&&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=LO({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var f=r.errorRetry||r.timeoutRetry||{},v={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:f.maxNumRetry||0,retryDelay:f.retryDelayMs||0,maxRetryDelay:f.maxRetryDelayMs||0},g={onSuccess:function(e,t,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=e.data;0===av(s).call(s,"#EXTM3U")?(t.parsing.start=performance.now(),UU.isMediaPlaylist(s)||r.type!==vO?n.handleTrackOrLevelPlaylist(e,t,r,i||null,a):n.handleMasterPlaylist(e,t,r,i)):n.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){n.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){n.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,v,g)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e,t=this.hls,r=t.config,i=r.autoStartLoad,n=r.startPosition,a=t.forceStartLoad;if(i||a)this.hls.logger.log(_d(e="".concat(i?"auto":"force"," startLoad with configured startPosition ")).call(e,n)),this.hls.startLoad(n)}}},{key:"handleMasterPlaylist",value:function(e,t,r,i){var n=this.hls,a=e.data,s=YV(e,r),o=UU.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=UU.parseMasterPlaylistMedia(a,s,o),g=v.AUDIO,p=void 0===g?[]:g,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];if(p.length)KT(p).call(p,(function(e){return!e.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new eU({}),bitrate:0,url:""}));n.trigger(fO.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=YV(e,r),c=lO(o)?o:lO(s)?s:0,h=jV(r),d=UU.parseLevelPlaylist(e.data,u,c,h,0,this.variableList);if(l===vO){var f={attrs:new eU({}),bitrate:0,details:d,name:"",url:u};d.requestScheduled=t.loading.start+ZU(d,0),a.trigger(fO.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(fO.ERROR,{type:hO.NETWORK_ERROR,details:dO.MANIFEST_PARSING_ERROR,fatal:t.type===vO,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}},{key:"handleNetworkError",value:function(e,t){var r,i,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0,o=_d(r="A network ".concat(n?"timeout":"error"+(a?" (status "+a.code+")":"")," occurred while loading ")).call(r,e.type);if(e.type===gO)o+=_d(i=": ".concat(e.level," id: ")).call(i,e.id);else if(e.type===pO||e.type===mO){var l;o+=_d(l=" id: ".concat(e.id,' group-id: "')).call(l,e.groupId,'"')}var u=new Error(o);this.hls.logger.warn("[playlist-loader]: ".concat(o));var c=dO.UNKNOWN,h=!1,d=this.getInternalLoader(e);switch(e.type){case vO:c=n?dO.MANIFEST_LOAD_TIMEOUT:dO.MANIFEST_LOAD_ERROR,h=!0;break;case gO:c=n?dO.LEVEL_LOAD_TIMEOUT:dO.LEVEL_LOAD_ERROR,h=!1;break;case pO:c=n?dO.AUDIO_TRACK_LOAD_TIMEOUT:dO.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case mO:c=n?dO.SUBTITLE_TRACK_LOAD_TIMEOUT:dO.SUBTITLE_LOAD_ERROR,h=!1}d&&this.resetInternalLoader(e.type);var f={type:hO.NETWORK_ERROR,details:c,fatal:h,url:e.url,loader:d,context:e,error:u,networkDetails:t,stats:s};if(a){var v=(null==t?void 0:t.url)||e.url;f.response=RO({url:v,data:void 0},a)}this.hls.trigger(fO.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=YV(t,i),f=jV(i),v="number"==typeof i.level&&f===yO?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var g=e.playlistParsingError;if(g)s.trigger(fO.ERROR,{type:hO.NETWORK_ERROR,details:dO.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 vO:case gO:s.trigger(fO.LEVEL_LOADED,{details:e,levelInfo:i.levelOrTrack||s.levels[0],level:v||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h,withoutMultiVariant:o===vO});break;case pO:s.trigger(fO.AUDIO_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case mO:s.trigger(fO.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(fO.ERROR,{type:hO.NETWORK_ERROR,details:dO.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}(),WV=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new LB,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var i=this.logger=function(e,t,r){var i=wO();if("object"===("undefined"==typeof console?"undefined":Cc(console))&&!0===e||"object"===Cc(e)){var n=["debug","log","info","warn","error"];vd(n).call(n,(function(t){i[t]=CO(t,e,r)}));try{i.log('Debug logs enabled for "'.concat(t,'" in hls.js version ',"1.6.0-beta.2"))}catch(a){return wO()}vd(n).call(n,(function(t){PO[t]=CO(t,e)}))}else LO(PO,i);return i}(r.debug||!1,"Hls instance",r.assetPlayerId),n=this.config=function(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=wV(e),n=["manifest","level","frag"],a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return vd(n).call(n,(function(e){var n,s,o="".concat("level"===e?"playlist":e,"LoadPolicy"),l=void 0===t[o],u=[];vd(a).call(a,(function(r){var n,a=_d(n="".concat(e,"Loading")).call(n,r),s=t[a];if(void 0!==s&&l){u.push(a);var c=i[o].default;switch(t[o]={default:c},r){case"TimeOut":c.maxLoadTimeMs=s,c.maxTimeToFirstByteMs=s;break;case"MaxRetry":c.errorRetry.maxNumRetry=s,c.timeoutRetry.maxNumRetry=s;break;case"RetryDelay":c.errorRetry.retryDelayMs=s,c.timeoutRetry.retryDelayMs=s;break;case"MaxRetryTimeout":c.errorRetry.maxRetryDelayMs=s,c.timeoutRetry.maxRetryDelayMs=s}}})),u.length&&r.warn(_d(n=_d(s='hls.js config: "'.concat(u.join('", "'),'" setting(s) are deprecated, use "')).call(s,o,'": ')).call(n,jI(t[o])))})),RO(RO({},i),t)}(e.DefaultConfig,r,i);this.userConfig=r,n.progressive&&CV(n,i);var a=n.abrController,s=n.bufferController,o=n.capLevelController,l=n.errorController,u=n.fpsController,c=new l(this),h=this.abrController=new a(this),d=new BF(this),f=n.interstitialsController,v=f?this.interstitialsController=new f(this,e):null,g=this.bufferController=new s(this,d),p=this.capLevelController=new o(this),m=new u(this),y=new qV(this),E=n.contentSteeringController,k=E?new E(this):null,T=this.levelController=new NV(this,k),S=new OV(this),A=new VV(this.config),L=this.streamController=new HV(this,d,A);p.setStreamController(L),m.setStreamController(L);var b=[y,T,L];v&&sg(b).call(b,1,0,v),k&&sg(b).call(b,1,0,k),this.networkControllers=b;var R=[h,g,p,m,S,d];this.audioTrackController=this.createController(n.audioTrackController,b);var I=n.audioStreamController;I&&b.push(new I(this,d,A)),this.subtitleTrackController=this.createController(n.subtitleTrackController,b);var D=n.subtitleStreamController;D&&b.push(new D(this,d,A)),this.createController(n.timelineController,R),A.emeController=this.emeController=this.createController(n.emeController,R),this.cmcdController=this.createController(n.cmcdController,R),this.latencyController=this.createController(FV,R),this.coreComponents=R,b.push(c);var _=c.onErrorOut;"function"==typeof _&&this.on(fO.ERROR,_,c),this.on(fO.MANIFEST_LOADED,y.onManifestLoaded,y)}return Fc(e,[{key:"createController",value:function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null}},{key:"on",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.on(e,t,r)}},{key:"once",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.once(e,t,r)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,i=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,i)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,r){return this._emitter.emit(e,t,r)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(JV){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+JV.message+'". Here is a stacktrace:',JV),!this.triggeringException){this.triggeringException=!0;var r=e===fO.ERROR;this.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.INTERNAL_EXCEPTION,fatal:r,event:e,error:JV}),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(fO.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,vd(e=this.networkControllers).call(e,(function(e){return e.destroy()})),this.networkControllers.length=0,vd(t=this.coreComponents).call(t,(function(e){return e.destroy()})),this.coreComponents.length=0;var r=this.config;r.xhrSetup=r.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument (".concat(e,")"));this.trigger(fO.ERROR,{type:hO.OTHER_ERROR,details:dO.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(fO.MEDIA_ATTACHING,n)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(fO.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(fO.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=iN.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(fO.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=arguments.length>1?arguments[1]:void 0;this.logger.log("startLoad(".concat(e+(t?", <skip seek to start>":""),")")),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){var e;this.bufferingEnabled||(this.logger.log("resume buffering"),vd(e=this.networkControllers).call(e,(function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){var e;this.bufferingEnabled&&(this.logger.log("pause buffering"),vd(e=this.networkControllers).call(e,(function(e){e.pauseBuffering&&e.pauseBuffering()})))}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(JV){try{var e=gI.createObjectURL(new Blob),t=e.toString();return gI.revokeObjectURL(e),Bv(t).call(t,YC(t).call(t,"/")+1)}catch(i){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)}))}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:".concat(e)),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:".concat(e)),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:".concat(e)),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:".concat(e)),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return av($O).call($O,e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e){return QO(e,lF(arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return bB}},{key:"isMSESupported",value:function(){return KV()}},{key:"isSupported",value:function(){return function(){var e,t;if(!KV())return!1;var r=MO();return"function"==typeof(null==r?void 0:r.isTypeSupported)&&(KT(e=["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"]).call(e,(function(e){return r.isTypeSupported(BO(e,"video"))}))||KT(t=["mp4a.40.2","fLaC"]).call(t,(function(e){return r.isTypeSupported(BO(e,"audio"))})))}()}},{key:"getMediaSource",value:function(){return MO()}},{key:"Events",get:function(){return fO}},{key:"MetadataSchema",get:function(){return $B}},{key:"ErrorTypes",get:function(){return hO}},{key:"ErrorDetails",get:function(){return dO}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:_V},set:function(t){e.defaultConfig=t}}]),e}();WV.defaultConfig=void 0;var zV={liveSyncDuration:{key:"targetLatency",val:10},liveMaxLatencyDuration:{key:"maxLatency",val:20},backBufferLength:{key:"bufferBehind",val:10},initialLiveManifestSize:{key:"minSegmentsStartPlay",val:3},preferManagedMediaSource:[{key:"preferMMS",val:!1},{key:"preferMMSStreaming",val:!1}],lowLatencyMode:{key:"useLowLatency",val:!0},startPosition:{key:"startTime",val:0},interstitialLiveLookAhead:{key:"preloadTime",val:30}};var XV=function(){function e(r,i){t(this,e),this.hls=r,this.player=i}return Fc(e,[{key:"getAudioTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.audioTracks||[]}catch(JV){return console.error("Failed to get audio tracks:",JV),[]}}},{key:"getCurrentAudioTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.audioTrack}catch(JV){return console.error("Failed to get current audio track:",JV),-1}}},{key:"switchAudioTrack",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;var t=this.getAudioTracks();if(0===t.length)return console.warn("No audio tracks available"),!1;if(!KT(t).call(t,(function(t,r){return r===e})))return console.warn("Audio track with ID ".concat(e," not found")),!1;try{return this.hls.audioTrack=e,this.player.emit("core_event",{eventName:"core.audiotrackchange",trackId:e,trackInfo:t[e]||null}),!0}catch(JV){return console.error("Failed to switch audio track:",JV),!1}}},{key:"getSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.subtitleTracks||[]}catch(JV){return console.error("Failed to get subtitle tracks:",JV),[]}}},{key:"getAllSubtitleTracks",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),[];try{return this.hls.allSubtitleTracks||[]}catch(JV){return console.error("Failed to get all subtitle tracks:",JV),[]}}},{key:"getCurrentSubtitleTrack",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),-1;try{return this.hls.subtitleTrack}catch(JV){return console.error("Failed to get current subtitle track:",JV),-1}}},{key:"switchSubtitleTrack",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;var t=this.getSubtitleTracks();if(-1===e)try{return this.hls.subtitleTrack=-1,this.player.emit("core_event",{eventName:"core.subtitletrackchange",trackId:-1,trackInfo:null}),!0}catch(JV){return console.error("Failed to disable subtitle track:",JV),!1}if(0===t.length)return console.warn("No subtitle tracks available"),!1;if(!KT(t).call(t,(function(t,r){return r===e})))return console.warn("Subtitle track with ID ".concat(e," not found")),!1;try{return this.hls.subtitleTrack=e,this.player.emit("core_event",{eventName:"core.subtitletrackchange",trackId:e,trackInfo:t[e]||null}),!0}catch(JV){return console.error("Failed to switch subtitle track:",JV),!1}}},{key:"getSubtitleDisplay",value:function(){if(!this.hls)return console.warn("HLS instance not initialized"),!1;try{return this.hls.subtitleDisplay}catch(JV){return console.error("Failed to get subtitle display status:",JV),!1}}},{key:"setSubtitleDisplay",value:function(e){if(!this.hls)return console.warn("HLS instance not initialized"),!1;try{return this.hls.subtitleDisplay=e,this.player.emit("core_event",{eventName:"core.subtitledisplaychange",enabled:e}),!0}catch(JV){return console.error("Failed to set subtitle display:",JV),!1}}}]),e}(),QV=function(e){Ph(i,e);var r=ed(i);function i(){return t(this,i),r.apply(this,arguments)}return Fc(i,[{key:"beforePlayerInit",value:function(){Ih(Rh(i.prototype),"beforePlayerInit",this).call(this),this._transEvent()}},{key:"_transEvent",value:function(){var e,t=this;vd(e=Ld(fO)).call(e,(function(e){e!==fO.ERROR&&t._transCoreEvent(e)}))}},{key:"_transCoreEvent",value:function(e){var t,r=this;null===(t=this.hls)||void 0===t||t.on(e,(function(t){if(r.player){for(var i,n,a=arguments.length,s=new Array(a>1?a-1:0),o=1;o<a;o++)s[o-1]=arguments[o];(i=r.player).emit.apply(i,_d(n=[e]).call(n,s))}}))}}]),i}(function(e){Ph(i,e);var r=ed(i);function i(e){var n;return t(this,i),(n=r.call(this,Rf(Rf({},e),{},{pluginName:i.pluginName})))._tickInterval=500,n._currentIndex=0,n._onPlay=function(){n.hls.startLoad()},n.onUrlChange=function(e){/^blob/.test(e)||(n.playerConfig.url=e,n.register(e))},n._getBufferend=function(e){var t=e.buffered;return t&&t.length?t.end(t.length-1):0},n._tick=function(){clearTimeout(n._tickTimer);var e=n.player.media;if(e){n._tickTimer=Wf(n._tick,n._tickInterval);var t=n._getBufferend(e);t<.1||!e.readyState||n.player.config.isLive&&4===e.readyState&&e.paused&&t-e.currentTime>n.config.disconnectTime&&n.hls.stopLoad()}},n.on=function(e,t){var r;null==(r=n.hls)||r.on(e,t)},n.config=e.config||{},n.player.handleSource=!1,n}return Fc(i,[{key:"beforePlayerInit",value:function(){this.register(this.player.config.url)}},{key:"initEvt",value:function(){var e,t;e=this.hls,t=this.player,e.on(WV.Events.SUBTITLE_FRAG_PROCESSED,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.subtitlesegments",list:i})})),e.on(WV.Events.MANIFEST_PARSED,(function(e,r){var i=r.levels;t.emit("core_event",{eventName:"core.subtitleplaylist",list:i})})),e.on(WV.Events.MANIFEST_LOADING,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadstart",url:i})})),e.on(WV.Events.LEVEL_LOADING,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadstart",url:i})})),e.on(WV.Events.FRAG_LOADING,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.loadstart",url:i.url})})),e.on(WV.Events.MANIFEST_LOADED,(function(e,r){var i=r.url;t.emit("core_event",{eventName:"core.loadcomplete",url:i})})),e.on(WV.Events.LEVEL_LOADED,(function(e,r){var i=r.details,n=r.stats;t.emit("core_event",Rf(Rf({eventName:"core.loadcomplete"},n),{},{url:null==i?void 0:i.url}))})),e.on(WV.Events.FRAG_LOADED,(function(e,r){var i=r.frag;t.emit("core_event",{eventName:"core.loadcomplete",url:i.url})})),e.on(WV.Events.FRAG_PARSING_USERDATA,(function(e,r){var i=r.samples;t.emit("core_event",{eventName:"core.sei",sei:i})})),e.on(WV.Events.MANIFEST_LOADED,(function(e,r){var i=r.levels,n=r.networkDetails;t.emit("core_event",{eventName:"core.hlsmanifestloaded",playlist:i}),t.emit("core_event",{eventName:"core.loadresponseheaders",headers:n.headers})})),e.on(WV.Events.LEVEL_LOADED,(function(e,r){var i,n=r.details,a={};vd(i=yv(n.dateRanges)).call(i,(function(e){a[e]=n.dateRanges[e].attr["START-DATE"]})),t.emit("core_event",{eventName:"core.hlslevelloaded",playlist:Rf(Rf({},n),{},{segments:n.fragments,dateRanges:a})})})),e.on(WV.Events.ERROR,(function(r,i){var n=i.details,a=i.fatal,s=i.type,o=i.response,l=i.reason,u=i.error;if(a){var c,h;switch(s){case WV.ErrorTypes.NETWORK_ERROR:c=2100,uD(n).call(n,"TimeOut")?c=2101:403===(null==o?void 0:o.code)?c=2103:404===(null==o?void 0:o.code)&&(c=2104),t.emit("error",{errorType:"network",errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case WV.ErrorTypes.MEDIA_ERROR:h="media",n===WV.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR?c=5104:n===WV.ErrorDetails.FRAG_DECRYPT_ERROR?c=5105:n===WV.ErrorDetails.FRAG_PARSING_ERROR?(c=1100,h="manifest"):n===WV.ErrorDetails.FRAG_GAP?c=5104:n===WV.ErrorDetails.BUFFER_ADD_CODEC_ERROR?c=5200:n===WV.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR?c=5104:n===WV.ErrorDetails.BUFFER_APPEND_ERROR||n===WV.ErrorDetails.BUFFER_APPENDING_ERROR?c=5201:n===WV.ErrorDetails.BUFFER_STALLED_ERROR||n===WV.ErrorDetails.BUFFER_FULL_ERROR?c=5203:(n===WV.ErrorDetails.BUFFER_SEEK_OVER_HOLE||n===WV.ErrorDetails.BUFFER_NUDGE_ON_STALL)&&(c=5202),t.emit("error",{errorType:h||s,errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case WV.ErrorTypes.MUX_ERROR:c=4100,t.emit("error",{errorType:"remux",errorCode:c,message:(null==u?void 0:u.message)||n,originError:i});break;case WV.ErrorTypes.KEY_SYSTEM_ERROR:c=7111,n===WV.ErrorDetails.KEY_SYSTEM_NO_KEYS?c=7103:n===WV.ErrorDetails.KEY_SYSTEM_NO_ACCESS?c=7101:n===WV.ErrorDetails.KEY_SYSTEM_NO_SESSION?c=7104:n===WV.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE?c=7107:n===WV.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED?c=7108:n===WV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED||n===WV.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED?c=7110:n===WV.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED?c=7104:n===WV.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR&&(c=7111),t.emit("error",{errorType:"drm",errorCode:c,message:(null==u?void 0:u.message)||l||n,originError:i});break;default:n===WV.ErrorDetails.LEVEL_SWITCH_ERROR&&(c=2100,h="network"),t.emit("error",{errorType:h||"other",errorCode:c,message:(null==u?void 0:u.message)||l||n,originError:i})}try{e.stopLoad(),t.pause()}catch(d){}}})),e.on(WV.Events.MEDIA_ATTACHED,(function(){t.emit("sourceopen")})),e.on(WV.Events.BUFFER_APPENDED,(function(){t.emit("bufferappend")})),e.on(WV.Events.AUDIO_TRACKS_UPDATED,(function(e,r){var i=r.audioTracks;t.emit("core_event",{eventName:"core.audiotracksupdate",audioTracks:i})})),e.on(WV.Events.AUDIO_TRACK_SWITCHING,(function(e,r){t.emit("core_event",Rf({eventName:"core.audiotrackswitching"},r))})),e.on(WV.Events.AUDIO_TRACK_SWITCHED,(function(e,r){t.emit("core_event",Rf({eventName:"core.audiotrackswitched"},r))})),e.on(WV.Events.SUBTITLE_TRACKS_UPDATED,(function(e,r){var i=r.subtitleTracks;t.emit("core_event",{eventName:"core.subtitletracksupdate",subtitleTracks:i})})),e.on(WV.Events.SUBTITLE_TRACKS_CLEARED,(function(){t.emit("core_event",{eventName:"core.subtitletracksclear"})})),e.on(WV.Events.SUBTITLE_TRACK_SWITCH,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackswitch"},r))})),e.on(WV.Events.SUBTITLE_TRACK_LOADING,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackloading"},r))})),e.on(WV.Events.SUBTITLE_TRACK_LOADED,(function(e,r){t.emit("core_event",Rf({eventName:"core.subtitletrackloaded"},r))}))}},{key:"afterCreate",value:function(){var e=this.player.media;this.player.on(CA,this.onUrlChange);try{BA.defineGetterOrSetter(this.player,{url:{get:function(){try{return e.src}catch(JV){return null}},configurable:!0}})}catch(t){}}},{key:"register",value:function(e){var t=this.player;this.hls&&this.hls.destroy();var r=function(e){var t,r={};vd(t=yv(zV)).call(t,(function(t){var i=zV[t];i instanceof Array?vd(i).call(i,(function(e){r[t]=e.val})):r[t]=e[i.key]||i.val}));var i="number"==typeof e.retryCount?e.retryCount:3,n="number"==typeof e.retryDelay?e.retryDelay:1e3,a=e.loadTimeout||1e4,s="number"==typeof e.manifestLoadTimeout?e.manifestLoadTimeout:1e4,o={maxNumRetry:i,retryDelayMs:n,maxRetryDelayMs:n,shouldRetry:function(e,t){return t<e.maxNumRetry}},l={maxNumRetry:i,retryDelayMs:n,maxRetryDelayMs:n,shouldRetry:function(e,t){return t<e.maxNumRetry}};return r.manifestLoadPolicy={default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:s,timeoutRetry:o,errorRetry:l}},r.playlistLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:a,timeoutRetry:o,errorRetry:l}},r.fragLoadPolicy={default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:a,timeoutRetry:o,errorRetry:l}},Rf(Rf({},r),e)}(this.config);(this.hls=new WV(r),this._trackManager=new XV(this.hls,this.player),this.initEvt(),t.config.preProcessUrl)&&(e=t.config.preProcessUrl(e).url);this.hls.loadSource(e);var i=this.player.media;this.hls.attachMedia(i),clearTimeout(this._tickTimer),this._tickTimer=Wf(this._tick,this._tickInterval),i.removeEventListener("play",this._onPlay),i.addEventListener("play",this._onPlay)}},{key:"switchUrl",value:function(e,t){var r=t.startTime;(t.bitrate,t.seamless,this.hls.loadSource(e),void 0!==r)&&(this.player.media.currentTime=r)}},{key:"getAudioTracks",value:function(){return this._trackManager.getAudioTracks()}},{key:"getCurrentAudioTrack",value:function(){return this._trackManager.getCurrentAudioTrack()}},{key:"switchAudioTrack",value:function(e){return this._trackManager.switchAudioTrack(e)}},{key:"getSubtitleTracks",value:function(){return this._trackManager.getSubtitleTracks()}},{key:"getAllSubtitleTracks",value:function(){return this._trackManager.getAllSubtitleTracks()}},{key:"getCurrentSubtitleTrack",value:function(){return this._trackManager.getCurrentSubtitleTrack()}},{key:"switchSubtitleTrack",value:function(e){return this._trackManager.switchSubtitleTrack(e)}},{key:"getSubtitleDisplay",value:function(){return this._trackManager.getSubtitleDisplay()}},{key:"setSubtitleDisplay",value:function(e){return this._trackManager.setSubtitleDisplay(e)}},{key:"destroy",value:function(){var e;clearTimeout(this._tickTimer),this.player.off(CA,this.onUrlChange),null==(e=this.hls)||e.destroy()}}],[{key:"pluginName",get:function(){return"hls"}}]),i}(BA)),$V=window.VePlayer.DynamicModule;VePlayer.registerPlugin($V.PluginHlsJs,{HlsPlugin:QV}),e.HlsPlugin=QV}));