You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/p__Classrooms__Lists__Learn...

74 lines
839 KiB

!(function(){var bl=Math.pow;(self.webpackChunk=self.webpackChunk||[]).push([[4928],{18785:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return G}});var _=x(54476),J=x(59301),Ae={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M176 511a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0zm280 0a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"ellipsis",theme:"outlined"},Y=Ae,A=x(7657),g=function(de,we){return J.createElement(A.Z,(0,_.Z)({},de,{ref:we,icon:Y}))},te=J.forwardRef(g),G=te},33853:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return G}});var _=x(54476),J=x(59301),Ae={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"}}]},name:"left",theme:"outlined"},Y=Ae,A=x(7657),g=function(de,we){return J.createElement(A.Z,(0,_.Z)({},de,{ref:we,icon:Y}))},te=J.forwardRef(g),G=te},65030:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return Xt}});var _=x(33885),J=x(42978),Ae=x(75931),Y=x(43403),A=x(92310),g=x.n(A),te=x(29301),G=x(76846),re=x(96452),de=x(6089),we=x(80402),Ie=x(34280),D=x(49658),H=x(59301),st=x(54476),Ge=x(77900),Ce=x(8654);function ae(oe){var Me=oe.prefixCls,N=oe.align,Ue=oe.arrow,z=oe.arrowPos,$=Ue||{},M=$.className,w=$.content,P=z.x,V=P===void 0?0:P,C=z.y,Ee=C===void 0?0:C,xe=H.useRef();if(!N||!N.points)return null;var Ke={position:"absolute"};if(N.autoArrow!==!1){var ot=N.points[0],Rt=N.points[1],et=ot[0],ut=ot[1],Et=Rt[0],Tt=Rt[1];et===Et||!["t","b"].includes(et)?Ke.top=Ee:et==="t"?Ke.top=0:Ke.bottom=0,ut===Tt||!["l","r"].includes(ut)?Ke.left=V:ut==="l"?Ke.left=0:Ke.right=0}return H.createElement("div",{ref:xe,className:g()("".concat(Me,"-arrow"),M),style:Ke},w)}function F(oe){var Me=oe.prefixCls,N=oe.open,Ue=oe.zIndex,z=oe.mask,$=oe.motion;return z?H.createElement(Ge.default,(0,st.Z)({},$,{motionAppear:!0,visible:N,removeOnLeave:!0}),function(M){var w=M.className;return H.createElement("div",{style:{zIndex:Ue},className:g()("".concat(Me,"-mask"),w)})}):null}var k=H.memo(function(oe){var Me=oe.children;return Me},function(oe,Me){return Me.cache}),X=k,le=H.forwardRef(function(oe,Me){var N=oe.popup,Ue=oe.className,z=oe.prefixCls,$=oe.style,M=oe.target,w=oe.onVisibleChanged,P=oe.open,V=oe.keepDom,C=oe.fresh,Ee=oe.onClick,xe=oe.mask,Ke=oe.arrow,ot=oe.arrowPos,Rt=oe.align,et=oe.motion,ut=oe.maskMotion,Et=oe.forceRender,Tt=oe.getPopupContainer,lt=oe.autoDestroy,pe=oe.portal,pt=oe.zIndex,Ei=oe.onMouseEnter,_i=oe.onMouseLeave,li=oe.onPointerEnter,Ai=oe.onPointerDownCapture,Vi=oe.ready,Ti=oe.offsetX,Ut=oe.offsetY,wi=oe.offsetR,ui=oe.offsetB,tt=oe.onAlign,Lt=oe.onPrepare,St=oe.stretch,ti=oe.targetWidth,oi=oe.targetHeight,ci=typeof N=="function"?N():N,Ht=P||V,Ii=(Tt==null?void 0:Tt.length)>0,Ft=H.useState(!Tt||!Ii),si=(0,J.Z)(Ft,2),Pi=si[0],Fe=si[1];if((0,Ie.Z)(function(){!Pi&&Ii&&M&&Fe(!0)},[Pi,Ii,M]),!Pi)return null;var d="auto",f={left:"-1000vw",top:"-1000vh",right:d,bottom:d};if(Vi||!P){var p,E=Rt.points,T=Rt.dynamicInset||((p=Rt._experimental)===null||p===void 0?void 0:p.dynamicInset),O=T&&E[0][1]==="r",U=T&&E[0][0]==="b";O?(f.right=wi,f.left=d):(f.left=Ti,f.right=d),U?(f.bottom=ui,f.top=d):(f.top=Ut,f.bottom=d)}var Ze={};return St&&(St.includes("height")&&oi?Ze.height=oi:St.includes("minHeight")&&oi&&(Ze.minHeight=oi),St.includes("width")&&ti?Ze.width=ti:St.includes("minWidth")&&ti&&(Ze.minWidth=ti)),P||(Ze.pointerEvents="none"),H.createElement(pe,{open:Et||Ht,getContainer:Tt&&function(){return Tt(M)},autoDestroy:lt},H.createElement(F,{prefixCls:z,open:P,zIndex:pt,mask:xe,motion:ut}),H.createElement(te.Z,{onResize:tt,disabled:!P},function($e){return H.createElement(Ge.default,(0,st.Z)({motionAppear:!0,motionEnter:!0,motionLeave:!0,removeOnLeave:!1,forceRender:Et,leavedClassName:"".concat(z,"-hidden")},et,{onAppearPrepare:Lt,onEnterPrepare:Lt,visible:P,onVisibleChanged:function(Gt){var Pt;et==null||(Pt=et.onVisibleChanged)===null||Pt===void 0||Pt.call(et,Gt),w(Gt)}}),function(ct,Gt){var Pt=ct.className,it=ct.style,Bt=g()(z,Pt,Ue);return H.createElement("div",{ref:(0,Ce.sQ)($e,Me,Gt),className:Bt,style:(0,_.Z)((0,_.Z)((0,_.Z)((0,_.Z)({"--arrow-x":"".concat(ot.x||0,"px"),"--arrow-y":"".concat(ot.y||0,"px")},f),Ze),it),{},{boxSizing:"border-box",zIndex:pt},$),onMouseEnter:Ei,onMouseLeave:_i,onPointerEnter:li,onClick:Ee,onPointerDownCapture:Ai},Ke&&H.createElement(ae,{prefixCls:z,arrow:Ke,arrowPos:ot,align:Rt}),H.createElement(X,{cache:!P&&!C},ci))})}))}),me=le,Xe=H.forwardRef(function(oe,Me){var N=oe.children,Ue=oe.getTriggerDOMNode,z=(0,Ce.Yr)(N),$=H.useCallback(function(w){(0,Ce.mH)(Me,Ue?Ue(w):w)},[Ue]),M=(0,Ce.x1)($,(0,Ce.C4)(N));return z?H.cloneElement(N,{ref:M}):N}),se=Xe,vt=H.createContext(null),yt=vt;function Je(oe){return oe?Array.isArray(oe)?oe:[oe]:[]}function nt(oe,Me,N,Ue){return H.useMemo(function(){var z=Je(N!=null?N:Me),$=Je(Ue!=null?Ue:Me),M=new Set(z),w=new Set($);return oe&&(M.has("hover")&&(M.delete("hover"),M.add("click")),w.has("hover")&&(w.delete("hover"),w.add("click"))),[M,w]},[oe,Me,N,Ue])}var ne=x(29194);function ee(){var oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],Me=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],N=arguments.length>2?arguments[2]:void 0;return N?oe[0]===Me[0]:oe[0]===Me[0]&&oe[1]===Me[1]}function ce(oe,Me,N,Ue){for(var z=N.points,$=Object.keys(oe),M=0;M<$.length;M+=1){var w,P=$[M];if(ee((w=oe[P])===null||w===void 0?void 0:w.points,z,Ue))return"".concat(Me,"-placement-").concat(P)}return""}function K(oe,Me,N,Ue){return Me||(N?{motionName:"".concat(oe,"-").concat(N)}:Ue?{motionName:Ue}:null)}function Se(oe){return oe.ownerDocument.defaultView}function ze(oe){for(var Me=[],N=oe==null?void 0:oe.parentElement,Ue=["hidden","scroll","clip","auto"];N;){var z=Se(N).getComputedStyle(N),$=z.overflowX,M=z.overflowY,w=z.overflow;[$,M,w].some(function(P){return Ue.includes(P)})&&Me.push(N),N=N.parentElement}return Me}function ve(oe){var Me=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;return Number.isNaN(oe)?Me:oe}function Pe(oe){return ve(parseFloat(oe),0)}function ke(oe,Me){var N=(0,_.Z)({},oe);return(Me||[]).forEach(function(Ue){if(!(Ue instanceof HTMLBodyElement||Ue instanceof HTMLHtmlElement)){var z=Se(Ue).getComputedStyle(Ue),$=z.overflow,M=z.overflowClipMargin,w=z.borderTopWidth,P=z.borderBottomWidth,V=z.borderLeftWidth,C=z.borderRightWidth,Ee=Ue.getBoundingClientRect(),xe=Ue.offsetHeight,Ke=Ue.clientHeight,ot=Ue.offsetWidth,Rt=Ue.clientWidth,et=Pe(w),ut=Pe(P),Et=Pe(V),Tt=Pe(C),lt=ve(Math.round(Ee.width/ot*1e3)/1e3),pe=ve(Math.round(Ee.height/xe*1e3)/1e3),pt=(ot-Rt-Et-Tt)*lt,Ei=(xe-Ke-et-ut)*pe,_i=et*pe,li=ut*pe,Ai=Et*lt,Vi=Tt*lt,Ti=0,Ut=0;if($==="clip"){var wi=Pe(M);Ti=wi*lt,Ut=wi*pe}var ui=Ee.x+Ai-Ti,tt=Ee.y+_i-Ut,Lt=ui+Ee.width+2*Ti-Ai-Vi-pt,St=tt+Ee.height+2*Ut-_i-li-Ei;N.left=Math.max(N.left,ui),N.top=Math.max(N.top,tt),N.right=Math.min(N.right,Lt),N.bottom=Math.min(N.bottom,St)}}),N}function rt(oe){var Me=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,N="".concat(Me),Ue=N.match(/^(.*)\%$/);return Ue?oe*(parseFloat(Ue[1])/100):parseFloat(N)}function _e(oe,Me){var N=Me||[],Ue=(0,J.Z)(N,2),z=Ue[0],$=Ue[1];return[rt(oe.width,z),rt(oe.height,$)]}function Ye(){var oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return[oe[0],oe[1]]}function ye(oe,Me){var N=Me[0],Ue=Me[1],z,$;return N==="t"?$=oe.y:N==="b"?$=oe.y+oe.height:$=oe.y+oe.height/2,Ue==="l"?z=oe.x:Ue==="r"?z=oe.x+oe.width:z=oe.x+oe.width/2,{x:z,y:$}}function Ve(oe,Me){var N={t:"b",b:"t",l:"r",r:"l"};return oe.map(function(Ue,z){return z===Me?N[Ue]||"c":Ue}).join("")}function We(oe,Me,N,Ue,z,$,M){var w=H.useState({ready:!1,offsetX:0,offsetY:0,offsetR:0,offsetB:0,arrowX:0,arrowY:0,scaleX:1,scaleY:1,align:z[Ue]||{}}),P=(0,J.Z)(w,2),V=P[0],C=P[1],Ee=H.useRef(0),xe=H.useMemo(function(){return Me?ze(Me):[]},[Me]),Ke=H.useRef({}),ot=function(){Ke.current={}};oe||ot();var Rt=(0,de.Z)(function(){if(Me&&N&&oe){let is=function(ls,ms){var $s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ct,Ds=Ht.x+ls,un=Ht.y+ms,pn=Ds+U,sn=un+O,Ln=Math.max(Ds,$s.left),At=Math.max(un,$s.top),Wt=Math.min(pn,$s.right),Bi=Math.min(sn,$s.bottom);return Math.max(0,(Wt-Ln)*(Bi-At))},Wi=function(){es=Ht.y+qt,qi=es+O,Ci=Ht.x+zt,Di=Ci+U};var Et,Tt,lt,pe,pt=Me,Ei=pt.ownerDocument,_i=Se(pt),li=_i.getComputedStyle(pt),Ai=li.position,Vi=pt.style.left,Ti=pt.style.top,Ut=pt.style.right,wi=pt.style.bottom,ui=pt.style.overflow,tt=(0,_.Z)((0,_.Z)({},z[Ue]),$),Lt=Ei.createElement("div");(Et=pt.parentElement)===null||Et===void 0||Et.appendChild(Lt),Lt.style.left="".concat(pt.offsetLeft,"px"),Lt.style.top="".concat(pt.offsetTop,"px"),Lt.style.position=Ai,Lt.style.height="".concat(pt.offsetHeight,"px"),Lt.style.width="".concat(pt.offsetWidth,"px"),pt.style.left="0",pt.style.top="0",pt.style.right="auto",pt.style.bottom="auto",pt.style.overflow="hidden";var St;if(Array.isArray(N))St={x:N[0],y:N[1],width:0,height:0};else{var ti,oi,ci=N.getBoundingClientRect();ci.x=(ti=ci.x)!==null&&ti!==void 0?ti:ci.left,ci.y=(oi=ci.y)!==null&&oi!==void 0?oi:ci.top,St={x:ci.x,y:ci.y,width:ci.width,height:ci.height}}var Ht=pt.getBoundingClientRect(),Ii=_i.getComputedStyle(pt),Ft=Ii.height,si=Ii.width;Ht.x=(Tt=Ht.x)!==null&&Tt!==void 0?Tt:Ht.left,Ht.y=(lt=Ht.y)!==null&&lt!==void 0?lt:Ht.top;var Pi=Ei.documentElement,Fe=Pi.clientWidth,d=Pi.clientHeight,f=Pi.scrollWidth,p=Pi.scrollHeight,E=Pi.scrollTop,T=Pi.scrollLeft,O=Ht.height,U=Ht.width,Ze=St.height,$e=St.width,ct={left:0,top:0,right:Fe,bottom:d},Gt={left:-T,top:-E,right:f-T,bottom:p-E},Pt=tt.htmlRegion,it="visible",Bt="visibleFirst";Pt!=="scroll"&&Pt!==Bt&&(Pt=it);var dt=Pt===Bt,He=ke(Gt,xe),Ne=ke(ct,xe),Ct=Pt===it?Ne:He,mt=dt?Ne:Ct;pt.style.left="auto",pt.style.top="auto",pt.style.right="0",pt.style.bottom="0";var di=pt.getBoundingClientRect();pt.style.left=Vi,pt.style.top=Ti,pt.style.right=Ut,pt.style.bottom=wi,pt.style.overflow=ui,(pe=pt.parentElement)===null||pe===void 0||pe.removeChild(Lt);var Ri=ve(Math.round(U/parseFloat(si)*1e3)/1e3),mi=ve(Math.round(O/parseFloat(Ft)*1e3)/1e3);if(Ri===0||mi===0||(0,G.Sh)(N)&&!(0,ne.Z)(N))return;var Dt=tt.offset,ni=tt.targetOffset,ki=_e(Ht,Dt),W=(0,J.Z)(ki,2),Q=W[0],Re=W[1],ge=_e(St,ni),ue=(0,J.Z)(ge,2),Te=ue[0],Be=ue[1];St.x-=Te,St.y-=Be;var Qe=tt.points||[],Kt=(0,J.Z)(Qe,2),xt=Kt[0],ei=Kt[1],Nt=Ye(ei),Zt=Ye(xt),Qt=ye(St,Nt),gi=ye(Ht,Zt),Si=(0,_.Z)({},tt),zt=Qt.x-gi.x+Q,qt=Qt.y-gi.y+Re,pi=is(zt,qt),hi=is(zt,qt,Ne),ri=ye(St,["t","l"]),Ni=ye(Ht,["t","l"]),vi=ye(St,["b","r"]),Li=ye(Ht,["b","r"]),Zi=tt.overflow||{},Gi=Zi.adjustX,ns=Zi.adjustY,ji=Zi.shiftX,Yi=Zi.shiftY,Ji=function(ms){return typeof ms=="boolean"?ms:ms>=0},es,qi,Ci,Di;Wi();var fs=Ji(ns),Oi=Zt[0]===Nt[0];if(fs&&Zt[0]==="t"&&(qi>mt.bottom||Ke.current.bt)){var xi=qt;Oi?xi-=O-Ze:xi=ri.y-Li.y-Re;var ks=is(zt,xi),ps=is(zt,xi,Ne);ks>pi||ks===pi&&(!dt||ps>=hi)?(Ke.current.bt=!0,qt=xi,Re=-Re,Si.points=[Ve(Zt,0),Ve(Nt,0)]):Ke.current.bt=!1}if(fs&&Zt[0]==="b"&&(es<mt.top||Ke.current.tb)){var ts=qt;Oi?ts+=O-Ze:ts=vi.y-Ni.y-Re;var Is=is(zt,ts),Hi=is(zt,ts,Ne);Is>pi||Is===pi&&(!dt||Hi>=hi)?(Ke.current.tb=!0,qt=ts,Re=-Re,Si.points=[Ve(Zt,0),Ve(Nt,0)]):Ke.current.tb=!1}var us=Ji(Gi),Fs=Zt[1]===Nt[1];if(us&&Zt[1]==="l"&&(Di>mt.right||Ke.current.rl)){var vs=zt;Fs?vs-=U-$e:vs=ri.x-Li.x-Q;var ys=is(vs,qt),Qi=is(vs,qt,Ne);ys>pi||ys===pi&&(!dt||Qi>=hi)?(Ke.current.rl=!0,zt=vs,Q=-Q,Si.points=[Ve(Zt,1),Ve(Nt,1)]):Ke.current.rl=!1}if(us&&Zt[1]==="r"&&(Ci<mt.left||Ke.current.lr)){var rs=zt;Fs?rs+=U-$e:rs=vi.x-Ni.x-Q;var cs=is(rs,qt),Ps=is(rs,qt,Ne);cs>pi||cs===pi&&(!dt||Ps>=hi)?(Ke.current.lr=!0,zt=rs,Q=-Q,Si.points=[Ve(Zt,1),Ve(Nt,1)]):Ke.current.lr=!1}Wi();var as=ji===!0?0:ji;typeof as=="number"&&(Ci<Ne.left&&(zt-=Ci-Ne.left-Q,St.x+$e<Ne.left+as&&(zt+=St.x-Ne.left+$e-as)),Di>Ne.right&&(zt-=Di-Ne.right-Q,St.x>Ne.right-as&&(zt+=St.x-Ne.right+as)));var ds=Yi===!0?0:Yi;typeof ds=="number"&&(es<Ne.top&&(qt-=es-Ne.top-Re,St.y+Ze<Ne.top+ds&&(qt+=St.y-Ne.top+Ze-ds)),qi>Ne.bottom&&(qt-=qi-Ne.bottom-Re,St.y>Ne.bottom-ds&&(qt+=St.y-Ne.bottom+ds)));var Rs=Ht.x+zt,Bs=Rs+U,hs=Ht.y+qt,js=hs+O,Ns=St.x,Ls=Ns+$e,Qs=St.y,Yt=Qs+Ze,zs=Math.max(Rs,Ns),Es=Math.min(Bs,Ls),Js=(zs+Es)/2,on=Js-Rs,en=Math.max(hs,Qs),ln=Math.min(js,Yt),Ws=(en+ln)/2,Fi=Ws-hs;M==null||M(Me,Si);var os=di.right-Ht.x-(zt+Ht.width),Cs=di.bottom-Ht.y-(qt+Ht.height);Ri===1&&(zt=Math.round(zt),os=Math.round(os)),mi===1&&(qt=Math.round(qt),Cs=Math.round(Cs));var tn={ready:!0,offsetX:zt/Ri,offsetY:qt/mi,offsetR:os/Ri,offsetB:Cs/mi,arrowX:on/Ri,arrowY:Fi/mi,scaleX:Ri,scaleY:mi,align:Si};C(tn)}}),et=function(){Ee.current+=1;var Tt=Ee.current;Promise.resolve().then(function(){Ee.current===Tt&&Rt()})},ut=function(){C(function(Tt){return(0,_.Z)((0,_.Z)({},Tt),{},{ready:!1})})};return(0,Ie.Z)(ut,[Ue]),(0,Ie.Z)(function(){oe||ut()},[oe]),[V.ready,V.offsetX,V.offsetY,V.offsetR,V.offsetB,V.arrowX,V.arrowY,V.scaleX,V.scaleY,V.align,et]}var Mt=x(94480);function jt(oe,Me,N,Ue,z){(0,Ie.Z)(function(){if(oe&&Me&&N){let Ee=function(){Ue(),z()};var $=Me,M=N,w=ze($),P=ze(M),V=Se(M),C=new Set([V].concat((0,Mt.Z)(w),(0,Mt.Z)(P)));return C.forEach(function(xe){xe.addEventListener("scroll",Ee,{passive:!0})}),V.addEventListener("resize",Ee,{passive:!0}),Ue(),function(){C.forEach(function(xe){xe.removeEventListener("scroll",Ee),V.removeEventListener("resize",Ee)})}}},[oe,Me,N])}var _t=x(48736);function Le(oe,Me,N,Ue,z,$,M,w){var P=H.useRef(oe);P.current=oe;var V=H.useRef(!1);H.useEffect(function(){if(Me&&Ue&&(!z||$)){var Ee=function(){V.current=!1},xe=function(lt){var pe;P.current&&!M(((pe=lt.composedPath)===null||pe===void 0||(pe=pe.call(lt))===null||pe===void 0?void 0:pe[0])||lt.target)&&!V.current&&w(!1)},Ke=Se(Ue);Ke.addEventListener("pointerdown",Ee,!0),Ke.addEventListener("mousedown",xe,!0),Ke.addEventListener("contextmenu",xe,!0);var ot=(0,re.A)(N);if(ot&&(ot.addEventListener("mousedown",xe,!0),ot.addEventListener("contextmenu",xe,!0)),0)var Rt,et,ut,Et;return function(){Ke.removeEventListener("pointerdown",Ee,!0),Ke.removeEventListener("mousedown",xe,!0),Ke.removeEventListener("contextmenu",xe,!0),ot&&(ot.removeEventListener("mousedown",xe,!0),ot.removeEventListener("contextmenu",xe,!0))}}},[Me,N,Ue,z,$]);function C(){V.current=!0}return C}var It=["prefixCls","children","action","showAction","hideAction","popupVisible","defaultPopupVisible","onPopupVisibleChange","afterPopupVisibleChange","mouseEnterDelay","mouseLeaveDelay","focusDelay","blurDelay","mask","maskClosable","getPopupContainer","forceRender","autoDestroy","destroyPopupOnHide","popup","popupClassName","popupStyle","popupPlacement","builtinPlacements","popupAlign","zIndex","stretch","getPopupClassNameFromAlign","fresh","alignPoint","onPopupClick","onPopupAlign","arrow","popupMotion","maskMotion","popupTransitionName","popupAnimation","maskTransitionName","maskAnimation","className","getTriggerDOMNode"];function je(){var oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Y.Z,Me=H.forwardRef(function(N,Ue){var z=N.prefixCls,$=z===void 0?"rc-trigger-popup":z,M=N.children,w=N.action,P=w===void 0?"hover":w,V=N.showAction,C=N.hideAction,Ee=N.popupVisible,xe=N.defaultPopupVisible,Ke=N.onPopupVisibleChange,ot=N.afterPopupVisibleChange,Rt=N.mouseEnterDelay,et=N.mouseLeaveDelay,ut=et===void 0?.1:et,Et=N.focusDelay,Tt=N.blurDelay,lt=N.mask,pe=N.maskClosable,pt=pe===void 0?!0:pe,Ei=N.getPopupContainer,_i=N.forceRender,li=N.autoDestroy,Ai=N.destroyPopupOnHide,Vi=N.popup,Ti=N.popupClassName,Ut=N.popupStyle,wi=N.popupPlacement,ui=N.builtinPlacements,tt=ui===void 0?{}:ui,Lt=N.popupAlign,St=N.zIndex,ti=N.stretch,oi=N.getPopupClassNameFromAlign,ci=N.fresh,Ht=N.alignPoint,Ii=N.onPopupClick,Ft=N.onPopupAlign,si=N.arrow,Pi=N.popupMotion,Fe=N.maskMotion,d=N.popupTransitionName,f=N.popupAnimation,p=N.maskTransitionName,E=N.maskAnimation,T=N.className,O=N.getTriggerDOMNode,U=(0,Ae.Z)(N,It),Ze=li||Ai||!1,$e=H.useState(!1),ct=(0,J.Z)($e,2),Gt=ct[0],Pt=ct[1];(0,Ie.Z)(function(){Pt((0,D.Z)())},[]);var it=H.useRef({}),Bt=H.useContext(yt),dt=H.useMemo(function(){return{registerSubPopup:function(Wt,Bi){it.current[Wt]=Bi,Bt==null||Bt.registerSubPopup(Wt,Bi)}}},[Bt]),He=(0,we.Z)(),Ne=H.useState(null),Ct=(0,J.Z)(Ne,2),mt=Ct[0],di=Ct[1],Ri=H.useRef(null),mi=(0,de.Z)(function(At){Ri.current=At,(0,G.Sh)(At)&&mt!==At&&di(At),Bt==null||Bt.registerSubPopup(He,At)}),Dt=H.useState(null),ni=(0,J.Z)(Dt,2),ki=ni[0],W=ni[1],Q=H.useRef(null),Re=(0,de.Z)(function(At){(0,G.Sh)(At)&&ki!==At&&(W(At),Q.current=At)}),ge=H.Children.only(M),ue=(ge==null?void 0:ge.props)||{},Te={},Be=(0,de.Z)(function(At){var Wt,Bi,ai=ki;return(ai==null?void 0:ai.contains(At))||((Wt=(0,re.A)(ai))===null||Wt===void 0?void 0:Wt.host)===At||At===ai||(mt==null?void 0:mt.contains(At))||((Bi=(0,re.A)(mt))===null||Bi===void 0?void 0:Bi.host)===At||At===mt||Object.values(it.current).some(function(fi){return(fi==null?void 0:fi.contains(At))||At===fi})}),Qe=K($,Pi,f,d),Kt=K($,Fe,E,p),xt=H.useState(xe||!1),ei=(0,J.Z)(xt,2),Nt=ei[0],Zt=ei[1],Qt=Ee!=null?Ee:Nt,gi=(0,de.Z)(function(At){Ee===void 0&&Zt(At)});(0,Ie.Z)(function(){Zt(Ee||!1)},[Ee]);var Si=H.useRef(Qt);Si.current=Qt;var zt=H.useRef([]);zt.current=[];var qt=(0,de.Z)(function(At){var Wt;gi(At),((Wt=zt.current[zt.current.length-1])!==null&&Wt!==void 0?Wt:Qt)!==At&&(zt.current.push(At),Ke==null||Ke(At))}),pi=H.useRef(),hi=function(){clearTimeout(pi.current)},ri=function(Wt){var Bi=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;hi(),Bi===0?qt(Wt):pi.current=setTimeout(function(){qt(Wt)},Bi*1e3)};H.useEffect(function(){return hi},[]);var Ni=H.useState(!1),vi=(0,J.Z)(Ni,2),Li=vi[0],Zi=vi[1];(0,Ie.Z)(function(At){(!At||Qt)&&Zi(!0)},[Qt]);var Gi=H.useState(null),ns=(0,J.Z)(Gi,2),ji=ns[0],Yi=ns[1],Ji=H.useState(null),es=(0,J.Z)(Ji,2),qi=es[0],Ci=es[1],Di=function(Wt){Ci([Wt.clientX,Wt.clientY])},fs=We(Qt,mt,Ht&&qi!==null?qi:ki,wi,tt,Lt,Ft),Oi=(0,J.Z)(fs,11),xi=Oi[0],ks=Oi[1],ps=Oi[2],ts=Oi[3],Is=Oi[4],Hi=Oi[5],us=Oi[6],Fs=Oi[7],vs=Oi[8],ys=Oi[9],Qi=Oi[10],rs=nt(Gt,P,V,C),cs=(0,J.Z)(rs,2),Ps=cs[0],as=cs[1],ds=Ps.has("click"),Rs=as.has("click")||as.has("contextMenu"),Bs=(0,de.Z)(function(){Li||Qi()}),hs=function(){Si.current&&Ht&&Rs&&ri(!1)};jt(Qt,ki,mt,Bs,hs),(0,Ie.Z)(function(){Bs()},[qi,wi]),(0,Ie.Z)(function(){Qt&&!(tt!=null&&tt[wi])&&Bs()},[JSON.stringify(Lt)]);var js=H.useMemo(function(){var At=ce(tt,$,ys,Ht);return g()(At,oi==null?void 0:oi(ys))},[ys,oi,tt,$,Ht]);H.useImperativeHandle(Ue,function(){return{nativeElement:Q.current,popupElement:Ri.current,forceAlign:Bs}});var Ns=H.useState(0),Ls=(0,J.Z)(Ns,2),Qs=Ls[0],Yt=Ls[1],zs=H.useState(0),Es=(0,J.Z)(zs,2),Js=Es[0],on=Es[1],en=function(){if(ti&&ki){var Wt=ki.getBoundingClientRect();Yt(Wt.width),on(Wt.height)}},ln=function(){en(),Bs()},Ws=function(Wt){Zi(!1),Qi(),ot==null||ot(Wt)},Fi=function(){return new Promise(function(Wt){en(),Yi(function(){return Wt})})};(0,Ie.Z)(function(){ji&&(Qi(),ji(),Yi(null))},[ji]);function os(At,Wt,Bi,ai){Te[At]=function(fi){var Zs;ai==null||ai(fi),ri(Wt,Bi);for(var Ss=arguments.length,cn=new Array(Ss>1?Ss-1:0),vn=1;vn<Ss;vn++)cn[vn-1]=arguments[vn];(Zs=ue[At])===null||Zs===void 0||Zs.call.apply(Zs,[ue,fi].concat(cn))}}(ds||Rs)&&(Te.onClick=function(At){var Wt;Si.current&&Rs?ri(!1):!Si.current&&ds&&(Di(At),ri(!0));for(var Bi=arguments.length,ai=new Array(Bi>1?Bi-1:0),fi=1;fi<Bi;fi++)ai[fi-1]=arguments[fi];(Wt=ue.onClick)===null||Wt===void 0||Wt.call.apply(Wt,[ue,At].concat(ai))});var Cs=Le(Qt,Rs,ki,mt,lt,pt,Be,ri),tn=Ps.has("hover"),is=as.has("hover"),Wi,ls;tn&&(os("onMouseEnter",!0,Rt,function(At){Di(At)}),os("onPointerEnter",!0,Rt,function(At){Di(At)}),Wi=function(Wt){(Qt||Li)&&mt!==null&&mt!==void 0&&mt.contains(Wt.target)&&ri(!0,Rt)},Ht&&(Te.onMouseMove=function(At){var Wt;(Wt=ue.onMouseMove)===null||Wt===void 0||Wt.call(ue,At)})),is&&(os("onMouseLeave",!1,ut),os("onPointerLeave",!1,ut),ls=function(){ri(!1,ut)}),Ps.has("focus")&&os("onFocus",!0,Et),as.has("focus")&&os("onBlur",!1,Tt),Ps.has("contextMenu")&&(Te.onContextMenu=function(At){var Wt;Si.current&&as.has("contextMenu")?ri(!1):(Di(At),ri(!0)),At.preventDefault();for(var Bi=arguments.length,ai=new Array(Bi>1?Bi-1:0),fi=1;fi<Bi;fi++)ai[fi-1]=arguments[fi];(Wt=ue.onContextMenu)===null||Wt===void 0||Wt.call.apply(Wt,[ue,At].concat(ai))}),T&&(Te.className=g()(ue.className,T));var ms=H.useRef(!1);ms.current||(ms.current=_i||Qt||Li);var $s=(0,_.Z)((0,_.Z)({},ue),Te),Ds={},un=["onContextMenu","onClick","onMouseDown","onTouchStart","onMouseEnter","onMouseLeave","onFocus","onBlur"];un.forEach(function(At){U[At]&&(Ds[At]=function(){for(var Wt,Bi=arguments.length,ai=new Array(Bi),fi=0;fi<Bi;fi++)ai[fi]=arguments[fi];(Wt=$s[At])===null||Wt===void 0||Wt.call.apply(Wt,[$s].concat(ai)),U[At].apply(U,ai)})});var pn=H.cloneElement(ge,(0,_.Z)((0,_.Z)({},$s),Ds)),sn={x:Hi,y:us},Ln=si?(0,_.Z)({},si!==!0?si:{}):null;return H.createElement(H.Fragment,null,H.createElement(te.Z,{disabled:!Qt,ref:Re,onResize:ln},H.createElement(se,{getTriggerDOMNode:O},pn)),ms.current&&H.createElement(yt.Provider,{value:dt},H.createElement(me,{portal:oe,ref:mi,prefixCls:$,popup:Vi,className:g()(Ti,js),style:Ut,target:ki,onMouseEnter:Wi,onMouseLeave:ls,onPointerEnter:Wi,zIndex:St,open:Qt,keepDom:Li,fresh:ci,onClick:Ii,onPointerDownCapture:Cs,mask:lt,motion:Qe,maskMotion:Kt,onVisibleChanged:Ws,onPrepare:Fi,forceRender:_i,autoDestroy:Ze,getPopupContainer:Ei,align:ys,arrow:Ln,arrowPos:sn,ready:xi,offsetX:ks,offsetY:ps,offsetR:ts,offsetB:Is,onAlign:Bs,stretch:ti,targetWidth:Qs/Fs,targetHeight:Js/vs})))});return Me}var Xt=je(Y.Z)},74451:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return st}});var _=x(59301),J=x(6767),Ae=x(75727),Y=x(68262),A=x(16471),g=x(10102),te=x(56102),G=x(37295),re={watermark:"watermark___hNYlv",videovideo:"videovideo___ovOkV",animate__loop:"animate__loop___mvL6s",upDown:"upDown___SlgHv",container:"container___g1WYG","video-container":"video-container___XPkWR","video-controls":"video-controls___to0Zq",hide:"hide___NA3DV","video-progress":"video-progress___gqHsd",seek:"seek___iZHBm","seek-tooltip":"seek-tooltip___uWyXx","bottom-controls":"bottom-controls___uoIBm","left-controls":"left-controls___mBEx4","right-controls":"right-controls___e9L6r",rateOverlay:"rateOverlay___HHBWe",controlText:"controlText___M_BWR","volume-controls":"volume-controls___fa3mE","fullscreen-button":"fullscreen-button___ur0es","fullscreen-button1":"fullscreen-button1___rfaXm","pip-button":"pip-button___GFO8W","playback-animation":"playback-animation___ndURq",volume:"volume___OTmpP",hidden:"hidden___o7GkT"},de=(Ge,Ce,ae)=>new Promise((F,k)=>{var X=Xe=>{try{me(ae.next(Xe))}catch(se){k(se)}},le=Xe=>{try{me(ae.throw(Xe))}catch(se){k(se)}},me=Xe=>Xe.done?F(Xe.value):Promise.resolve(Xe.value).then(X,le);me((ae=ae.apply(Ge,Ce)).next())});function we(Ge){if(isNaN(Ge))return{minutes:"00",seconds:"00"};const Ce=new Date(Ge*1e3).toISOString().substr(11,8);return{hour:Ce.substr(0,2),minutes:Ce.substr(3,2),seconds:Ce.substr(6,2)}}Object.defineProperty(HTMLMediaElement.prototype,"playing",{get:function(){return this.currentTime>0&&!this.paused&&!this.ended&&this.readyState>2}});function Ie(Ge,Ce){return Ge-Ce}function D(Ge){Ge.sort(Ie);let Ce=0;for(let ae=0;ae<Ge.length-1;ae++){let F=Math.abs(Ge[ae+1]-Ge[ae]);F<21&&(Ce+=F)}return Ce}const H=/(android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini)/i;var st=(0,_.forwardRef)(({allow_skip:Ge,src:Ce,toLog:ae,videoId:F,logWatchHistory:k,courseId:X=null,startTime:le,handlePause:me=()=>{},handlePlay:Xe=()=>{},handlePlayEnded:se=()=>{},autoPlay:vt=!1,onPlayEnded:yt=()=>{},isShowWaterMark:Je=!0},nt)=>{var ne;Ce=Ce==null?void 0:Ce.replace("http://","https://");const ce=((ne=Ce==null?void 0:Ce.split("."))==null?void 0:ne.pop())==="flv",K=(0,_.useRef)(),Se=(0,_.useRef)(),ze=(0,_.useRef)(),ve=(0,_.useRef)(),Pe=(0,_.useRef)(),ke=(0,_.useRef)(),rt=(0,_.useRef)(),_e=(0,_.useRef)(),Ye=(0,_.useRef)(),ye=(0,_.useRef)(),Ve=(0,_.useRef)(),We=(0,_.useRef)(),Mt=(0,_.useRef)(),jt=(0,_.useRef)(),_t=navigator.userAgent.toLowerCase().match(H),Le=_t?_t[0]:"pc",It=(0,_.useRef)(!1),je=(0,g.eY)();let Xt=0,oe=0,Me=0,N=null,Ue=!1,z=20,$=1,M=!1,w=!1,P=[];(0,_.useImperativeHandle)(nt,()=>({getLastUpdatedTime:()=>K.current.currentTime,getDuration:()=>K.current.duration})),J.ZP.config({maxCount:1,getContainer:()=>ze.current});const V=(0,_.useCallback)((et,ut=!1)=>{let Et={point:K.current.currentTime};N?(Et.log_id=N,Et.watch_duration=D(P),Et.total_duration=oe):(X?(Et.video_id=parseInt(F,10),Et.course_id=X):Et.video_id=F,Et.duration=Xt,Et.device=Le),ut&&(Et.ed="1");function Tt(){return de(this,null,function*(){M=!0,N=yield k==null?void 0:k(Et),M=!1,et&&et()})}Tt()},[F,X]);(0,_.useEffect)(()=>{K.current&&(ve.current.style.display="none",Pe.current.style.display="block"),J.ZP.destroy();let et=null;return Y.Z.isSupported&&ce&&Ce&&(Ce==null?void 0:Ce.indexOf(".m3u8"))<0?(et=Y.Z.createPlayer({type:"flv",volume:.8,cors:!0,url:Ce,muted:!1}),K.current&&(et.attachMediaElement(K.current),et.load())):K.current.setAttribute("src",Ce),Ee(),()=>{et&&(et.unload(),et.pause(),et.destroy(),et=null)}},[K,ce,Ce]);function C(){K.current.paused?(ve.current.style.display="none",Pe.current.style.display="block"):(ve.current.style.display="block",Pe.current.style.display="none")}function Ee(){Ve.current.style.display="none",Mt.current.style.display="none",We.current.style.display="none",K.current.muted||K.current.volume===0?Ve.current.style.display="block":K.current.volume>0&&K.current.volume<=.5?Mt.current.style.display="block":We.current.style.display="block"}(0,_.useEffect)(()=>{const et=document.getElementById("play"),ut=document.querySelectorAll(".playback-icons use");function Et(){Xe(),le&&!It.current&&(K.current.currentTime=le),It.current=!0,P.push(K.current.currentTime),Ue||(Ue=!0,ae&&V())}function Tt(){return de(this,null,function*(){C(),P.push(K.current.currentTime),ae&&V(()=>{N=null,Me=0,Ue=!1,M=!1,w=!1,P=[],oe=0,$=1},!0),yt()})}function lt(){ke.current.value=Math.round(K.current.currentTime),rt.current.value=Math.round(K.current.currentTime)}function pe(){const tt=we(Math.round(K.current.currentTime));Ye.current.innerText=`${tt.hour>0?tt.hour+":":""}${tt.minutes}:${tt.seconds}`,Ye.current.setAttribute("datetime",`${tt.hour>0?" "+tt.hour+" ":""}${tt.minutes}m ${tt.seconds}s`)}function pt(){var tt,Lt,St,ti,oi,ci,Ht;const Ii=Math.round((tt=K.current)==null?void 0:tt.duration);(St=(Lt=ke.current)==null?void 0:Lt.setAttribute)==null||St.call(Lt,"max",Ii),(oi=(ti=rt.current)==null?void 0:ti.setAttribute)==null||oi.call(ti,"max",Ii);const Ft=we(Ii);_e.current&&(_e.current.innerText=`${Ft.hour>0?Ft.hour+":":""}${Ft.minutes}:${Ft.seconds}`,(Ht=(ci=_e.current).setAttribute)==null||Ht.call(ci,"datetime",`${Ft.hour>0?" "+Ft.hour+" ":""}${Ft.minutes}m ${Ft.seconds}s`))}function Ei(){try{const tt=Math.round(K.current.duration);ke.current.setAttribute("max",tt),rt.current.setAttribute("max",tt);const Lt=we(tt);_e.current.innerText=`${Lt.hour>0?Lt.hour+":":""}${Lt.minutes}:${Lt.seconds}`,_e.current.setAttribute("datetime",`${Lt.hour>0?" "+Lt.hour+" ":""}${Lt.minutes}m ${Lt.seconds}s`),lt(),pe();const{width:St,height:ti,x:oi,y:ci}=Se.current.getBoundingClientRect();if(oi<0||ci<0,!w){let Ht=K.current.currentTime,Ii=Ht-Me;Math.abs(Ii)<10?(oe+=Math.abs(Ii),Me=Ht,M||oe-$*z>=0&&($++,P.push(Me),ae&&V())):(Me=Ht,ae&&V())}}catch(tt){console.log("videoplaying:",tt)}}function _i(){w=!0}function li(){K.current.playing&&P.push(K.current.currentTime,Me),Me=K.current.currentTime,w=!1}function Ai(){Xt=K.current.duration,Xt<=20&&(z=Xt/3),K.current.addEventListener("play",Et)}function Vi(tt){tt.preventDefault(),(0,G.vp)()?(K.current.style.width="100%",K.current.style.height="100%"):K.current.style.cssText=""}function Ti(){me()}function Ut(tt){if(!Ge){J.ZP.warning("\u8BE5\u89C6\u9891\u7981\u6B62\u5FEB\u8FDB/\u540E\u9000\u64AD\u653E");return}const Lt=tt.target.dataset.seek?tt.target.dataset.seek:tt.target.value;K.current.currentTime=Lt,rt.current.value=Lt,ke.current.value=Lt}function wi(tt){const Lt=Math.round(tt.offsetX/tt.target.clientWidth*parseInt(tt.target.getAttribute("max"),10));ke.current.setAttribute("data-seek",Lt);const St=we(Lt);ye.current.textContent=`${St.hour>0?St.hour+":":""}${St.minutes}:${St.seconds}`;const ti=K.current.getBoundingClientRect();ye.current.style.left=`${tt.pageX-ti.left}px`}function ui(tt){switch(tt.code){case"Space":tt.preventDefault(),ot();break;case"ArrowRight":if(tt.preventDefault(),!Ge){J.ZP.warning("\u8BE5\u89C6\u9891\u7981\u6B62\u5FEB\u8FDB/\u540E\u9000\u64AD\u653E");break}if(K.current.currentTime>=K.current.duration)break;K.current.currentTime=parseInt(K.current.currentTime)+5,lt();break;case"ArrowLeft":if(tt.preventDefault(),!Ge){J.ZP.warning("\u8BE5\u89C6\u9891\u7981\u6B62\u5FEB\u8FDB/\u540E\u9000\u64AD\u653E");break}if(K.current.currentTime===0)break;K.current.currentTime=parseInt(K.current.currentTime)-5,lt();break;case"ArrowUp":tt.preventDefault(),K.current.volume<1&&(K.current.volume=(parseInt(K.current.volume*10)+1)/10);break;case"ArrowDown":tt.preventDefault(),K.current.volume>0&&(K.current.volume=(parseInt(K.current.volume*10)-1)/10);break}}return ze.current.addEventListener((0,G.gH)(),Vi),K.current.addEventListener("canplay",Ai),K.current.addEventListener("ended",Tt),K.current.addEventListener("seeking",_i),K.current.addEventListener("seeked",li),K.current.addEventListener("loadedmetadata",pt),ke.current.addEventListener("mousemove",wi),ke.current.addEventListener("input",Ut),K.current.addEventListener("timeupdate",Ei),K.current.addEventListener("pause",Ti),K.current.addEventListener("volumechange",Ee),document.addEventListener("keydown",ui),()=>{var tt,Lt,St,ti,oi,ci,Ht,Ii,Ft,si,Pi,Fe;(tt=K.current)==null||tt.removeEventListener("canplay",Ai),(Lt=K.current)==null||Lt.removeEventListener("play",Et),(St=K.current)==null||St.removeEventListener("ended",Tt),(ti=K.current)==null||ti.removeEventListener("seeking",_i),(oi=K.current)==null||oi.removeEventListener("seeked",li),(ci=ke.current)==null||ci.removeEventListener("mousemove",wi),(Ht=ke.current)==null||Ht.removeEventListener("input",Ut),(Ii=K.current)==null||Ii.removeEventListener("timeupdate",Ei),(Ft=K.current)==null||Ft.removeEventListener("pause",Ti),(si=K.current)==null||si.removeEventListener("loadedmetadata",pt),(Pi=K.current)==null||Pi.removeEventListener("volumechange",Ee),document.removeEventListener("keydown",ui),(Fe=K.current)!=null&&Fe.playing&&(P.push(Me,K.current.currentTime),ae&&V())}},[K,Ce]),(0,_.useEffect)(()=>{if(K.current.onended=()=>{se(K)},K.current.oncontextmenu=()=>!1,(Ce==null?void 0:Ce.indexOf(".m3u8"))>-1){if(K.current.canPlayType("application/vnd.apple.mpegurl"))K.current.src=Ce;else if(A.ZP.isSupported()){var et=new A.ZP;et.loadSource(Ce),et.attachMedia(K.current)}}},[Ce]);const[xe,Ke]=(0,_.useState)(1),ot=()=>{K.current.paused||K.current.ended?K.current.play():K.current.pause(),C()};function Rt(){K.current.muted=!K.current.muted,K.current.muted?(jt.current.setAttribute("data-volume",volume.value),jt.current.value=0):jt.current.value=jt.current.dataset.volume}return _.createElement("div",{style:{position:"relative"},ref:ze},_.createElement("div",{ref:Se,className:`${re.watermark} animated_alternate animate__animated_10s animate__infinite animate__stepstart ${re.animate__loop}`},Je&&je?je.login:" "),_.createElement("div",{className:re.container},_.createElement("div",{className:re["video-container"],id:"video-container"},_.createElement("div",{className:re["playback-animation"],id:"playback-animation"},_.createElement("svg",{className:re["playback-icons"]},_.createElement("use",{className:"hidden",href:"#play-icon"}),_.createElement("use",{href:"#pause"}))),_.createElement("video",{className:re.video,id:"video",preload:"auto",disablePictureInPicture:!0,ref:K,autoPlay:vt}),_.createElement("div",{className:`${re["video-controls"]} `,id:"video-controls"},_.createElement("div",{className:re["bottom-controls"]},_.createElement("div",{className:re["left-controls"]},_.createElement("button",{"data-title":"\u64AD\u653E/\u6682\u505C",id:"play",onClick:ot},_.createElement("svg",{className:re["playback-icons"]},_.createElement("use",{ref:Pe,href:"#play-icon"}),_.createElement("use",{ref:ve,style:{display:"none"},href:"#pause"}))),_.createElement("div",{className:re.time},_.createElement("time",{id:"time-elapsed",ref:Ye},"00:00"),_.createElement("span",null," / "),_.createElement("time",{id:"duration",ref:_e},"00:00"))),_.createElement("div",{className:re["right-controls"]},Ge&&_.createElement(Ae.Z,{placement:"top",overlayClassName:re.rateOverlay,getPopupContainer:et=>et.parentNode,menu:{items:[{key:"1",label:_.createElement("span",{onClick:()=>{Ke(1),K.current.playbackRate=1}},"1.0x")},{key:"2",label:_.createElement("span",{onClick:()=>{Ke(1.5),K.current.playbackRate=1.5}},"1.5x")},{key:"3",label:_.createElement("span",{onClick:()=>{Ke(2),K.current.playbackRate=2}},"2.0x")}]}},_.createElement("div",{className:`${re.controlText} mr5`},"\u500D\u901F")),_.createElement(te.CopyToClipboard,{text:Ce,onCopy:()=>J.ZP.success("\u590D\u5236\u6210\u529F")},_.createElement("button",{"data-title":"\u590D\u5236\u94FE\u63A5"},_.createElement("i",{className:"icon-lianjie2 iconfont",style:{fontSize:"12px",color:"white"}}))),_.createElement("div",{className:re["volume-controls"]},_.createElement("button",{"data-title":"\u5F00\u542F/\u5173\u95ED\u58F0\u97F3",className:re["volume-button"],id:"volume-button",onClick:Rt},_.createElement("i",{ref:Ve,className:"icon-a-bianzu8 iconfont",style:{fontSize:"14px",color:"white"}}),_.createElement("i",{ref:Mt,className:"icon-shengyinkaibeifen iconfont",style:{fontSize:"14px",color:"white"}}),_.createElement("i",{ref:We,className:"icon-shengyinkai iconfont",style:{fontSize:"14px",color:"white"}})),_.createElement("input",{className:re.volume,id:"volume",value:"1","data-mute":"0.5",type:"range",max:"1",min:"0",step:"0.01",ref:jt,style:{display:"none"},onClick:Ee})),_.createElement("button",{"data-title":"\u5168\u5C4F/\u9000\u51FA\u5168\u5C4F",className:re["fullscreen-button"],onClick:()=>{(0,G.vp)()?(0,G.BU)():(0,G.Dj)(ze.current)}},_.createElement("i",{className:"icon-fangda1 iconfont",style:{fontSize:"12px",color:"white"}})))),_.createElement("div",{className:re["video-progress"]},_.createElement("progress",{ref:rt,value:"0",min:"0"}),_.createElement("input",{className:re.seek,ref:ke,value:"0",min:"0",type:"range",step:"1"}),_.createElement("div",{className:re["seek-tooltip"],ref:ye,id:"seek-tooltip"},"00:00"))))),_.createElement("svg",{style:{display:"none"}},_.createElement("defs",null,_.createElement("symbol",{id:"pause",viewBox:"0 0 24 24"},_.createElement("path",{d:"M14.016 5.016h3.984v13.969h-3.984v-13.969zM6 18.984v-13.969h3.984v13.969h-3.984z"})),_.createElement("symbol",{id:"play-icon",viewBox:"0 0 24 24"},_.createElement("path",{d:"M8.016 5.016l10.969 6.984-10.969 6.984v-13.969z"})),_.createElement("symbol",{id:"volume-high",viewBox:"0 0 24 24"},_.createElement("path",{d:"M14.016 3.234q3.047 0.656 5.016 3.117t1.969 5.648-1.969 5.648-5.016 3.117v-2.063q2.203-0.656 3.586-2.484t1.383-4.219-1.383-4.219-3.586-2.484v-2.063zM16.5 12q0 2.813-2.484 4.031v-8.063q1.031 0.516 1.758 1.688t0.727 2.344zM3 9h3.984l5.016-5.016v16.031l-5.016-5.016h-3.984v-6z"})),_.createElement("symbol",{id:"volume-low",viewBox:"0 0 24 24"},_.createElement("path",{d:"M5.016 9h3.984l5.016-5.016v16.031l-5.016-5.016h-3.984v-6zM18.516 12q0 2.766-2.531 4.031v-8.063q1.031 0.516 1.781 1.711t0.75 2.32z"})),_.createElement("symbol",{id:"volume-mute",viewBox:"0 0 24 24"},_.createElement("path",{d:"M12 3.984v4.219l-2.109-2.109zM4.266 3l16.734 16.734-1.266 1.266-2.063-2.063q-1.547 1.313-3.656 1.828v-2.063q1.172-0.328 2.25-1.172l-4.266-4.266v6.75l-5.016-5.016h-3.984v-6h4.734l-4.734-4.734zM18.984 12q0-2.391-1.383-4.219t-3.586-2.484v-2.063q3.047 0.656 5.016 3.117t1.969 5.648q0 2.203-1.031 4.172l-1.5-1.547q0.516-1.266 0.516-2.625zM16.5 12q0 0.422-0.047 0.609l-2.438-2.438v-2.203q1.031 0.516 1.758 1.688t0.727 2.344z"})),_.createElement("symbol",{id:"fullscreen",viewBox:"0 0 24 24"},_.createElement("path",{d:"M14.016 5.016h4.969v4.969h-1.969v-3h-3v-1.969zM17.016 17.016v-3h1.969v4.969h-4.969v-1.969h3zM5.016 9.984v-4.969h4.969v1.969h-3v3h-1.969zM6.984 14.016v3h3v1.969h-4.969v-4.969h1.969z"})),_.createElement("symbol",{id:"fullscreen-exit",viewBox:"0 0 24 24"},_.createElement("path",{d:"M15.984 8.016h3v1.969h-4.969v-4.969h1.969v3zM14.016 18.984v-4.969h4.969v1.969h-3v3h-1.969zM8.016 8.016v-3h1.969v4.969h-4.969v-1.969h3zM5.016 15.984v-1.969h4.969v4.969h-1.969v-3h-3z"})),_.createElement("symbol",{id:"pip",viewBox:"0 0 24 24"},_.createElement("path",{d:"M21 19.031v-14.063h-18v14.063h18zM23.016 18.984q0 0.797-0.609 1.406t-1.406 0.609h-18q-0.797 0-1.406-0.609t-0.609-1.406v-14.016q0-0.797 0.609-1.383t1.406-0.586h18q0.797 0 1.406 0.586t0.609 1.383v14.016zM18.984 11.016v6h-7.969v-6h7.969z"})))))})},15227:function(ii,qe,x){"use strict";x.r(qe),x.d(qe,{default:function(){return Ce}});var _=x(59301),J=x(63823),Ae=x(458),Y=x(62957),A={flex_box_center:"flex_box_center___yF0Vb",flex_space_between:"flex_space_between___vsNYO",flex_box_vertical_center:"flex_box_vertical_center___C4UqH",flex_box_center_end:"flex_box_center_end___EGtmE",flex_box_column:"flex_box_column___uX9g9",bg:"bg___sRga2",menu:"menu___s8xQl",desc:"desc___poG1Z",listItem:"listItem___ml9kN",info:"info___Z8R2Z",add:"add___jH8te",addForm:"addForm___O999t",attendanceCode:"attendanceCode___hPKyl",signInStatus:"signInStatus___usMPT",colorE02020:"colorE02020___hZvSz",color0152d9:"color0152d9___RgXzd",colorFA6400:"colorFA6400___g2yU6",iframe:"iframe___HRzMh"},g=x(10102);const te={init:[{stage_name:"\u521D\u59CB\u5B66\u4E60",parent:9999999,key:0},{stage_name:"\u7EEA\u8BBA",parent:0,key:1},{discipline_name:"\u7EEA\u8BBA",shixun_count:"1",video_count:"2",parent:1,key:"11"},{shixun_name:"\u7EEA\u8BBA1",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/f066ae1a9a8f418f837e5bf8d02b2690/76df907c20efd95bea0fa23424f10693-hd.m3u8",parent:"11",key:"111"},{shixun_name:"\u7EEA\u8BBA2",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/068ca7853da448c794eeffb0dee8bed4/5bb446a882043683e37474ff408f601b-hd.m3u8",parent:"11",key:"112"},{shixun_name:"C++\u5F00\u53D1\u73AF\u5883\u5E94\u7528\u5165\u95E8",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/zxb937qn/challenges",parent:"11",key:"113"},{stage_name:"\u7B80\u5355\u7A0B\u5E8F\u8BBE\u8BA1",parent:0,key:2},{discipline_name:"\u57FA\u7840\u6570\u636E\u7C7B\u578B\u548C\u8868\u8FBE\u5F0F",shixun_count:"1",video_count:"1",parent:2,key:"21"},{shixun_name:"\u57FA\u7840\u6570\u636E\u7C7B\u578B\u548C\u8868\u8FBE\u5F0F",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/f5f9c87860cb4a98ba86da37b5bfac70/8d50a9c4d5d4d3382c09bad3f4c5dcb6-hd.m3u8",parent:"21",key:"211"},{shixun_name:"C++\u7B80\u5355\u7A0B\u5E8F\u8BBE\u8BA1",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/lg5afhzv/challenges",parent:"21",key:"212"},{discipline_name:"\u5224\u65AD\u8BED\u53E5",shixun_count:"2",video_count:"2",parent:2,key:"22"},{shixun_name:"if\u8BED\u53E5",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/3b4e821b200443948c553e4c6b51d940/b9601216238e60440192c2deb58adc53-hd.m3u8",parent:"22",key:"221"},{shixun_name:"C++\u9009\u62E9\u7ED3\u6784\u2014\u2014\uFF08if\u591A\u91CD\u9009\u62E9\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/23xkyrmn/challenges",parent:"22",key:"222"},{shixun_name:"switch\u8BED\u53E5",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/3b4e821b200443948c553e4c6b51d940/b9601216238e60440192c2deb58adc53-hd.m3u8",parent:"22",key:"223"},{shixun_name:"C++\u9009\u62E9\u7ED3\u6784\u2014\u2014\uFF08\u5DE7\u7528switch\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/sm3c5a7v/challenges",parent:"22",key:"224"},{discipline_name:"\u5FAA\u73AF",shixun_count:"2",video_count:"2",parent:2,key:"23"},{shixun_name:"while\u8BED\u53E5",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/dda06371a1594f5d865479a0fadc77bb/cb504e3af36ebe2ba979e8fe5fbb2222-hd.m3u8",parent:"23",key:"231"},{shixun_name:"C++\u5FAA\u73AF\u7ED3\u6784\u2014\u2014\uFF08\u719F\u6089while\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/8yhf4sn6/challenges",parent:"23",key:"232"},{shixun_name:"for\u8BED\u53E5",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/503194c483f44ccfacc7f9ee14cda70a/36cbd964c6657d1bbc43eb33b98f0c51-hd.m3u8",parent:"23",key:"233"},{shixun_name:"C++\u9009\u62E9\u7ED3\u6784\u2014\u2014\uFF08\u5DE7\u7528switch\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/sm3c5a7v/challenges",parent:"23",key:"234"},{stage_name:"\u51FD\u6570",parent:0,key:3},{discipline_name:"\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u7528",shixun_count:"2",video_count:"1",parent:3,key:"31"},{shixun_name:"\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u7528",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c10e39b3afb14ad0b890368aa1751821/ef361445294452e1d9bfacae80b3ec2f-hd.m3u8",parent:"31",key:"311"},{shixun_name:"C++\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u75281",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/3q4isevr/challenges",parent:"31",key:"312"},{shixun_name:"C++\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u75282",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/tlhxwo64/challenges",parent:"31",key:"313"},{discipline_name:"\u4F20\u8F93\u4F20\u9012",shixun_count:"2",video_count:"1",parent:3,key:"32"},{shixun_name:"\u51FD\u6570\u7684\u53C2\u6570",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7785?subject_id=jpl5vs26",parent:"32",key:"321"},{shixun_name:"C++\u53C2\u6570\u4F20\u90121",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/2phrn8yk/challenges",parent:"32",key:"322"},{shixun_name:"C++\u53C2\u6570\u4F20\u90122",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/xsq7p4a6/challenges",parent:"32",key:"323"},{discipline_name:"\u51FD\u6570\u91CD\u8F7D",shixun_count:"1",video_count:"1",parent:3,key:"33"},{shixun_name:"\u51FD\u6570\u91CD\u8F7D",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7785?subject_id=jpl5vs26",parent:"33",key:"331"},{shixun_name:"C++\u51FD\u6570\u91CD\u8F7D",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/6hbqpv7e/challenges",parent:"33",key:"332"},{discipline_name:"\u9012\u5F52\u51FD\u6570",shixun_count:"2",video_count:"1",parent:3,key:"34"},{shixun_name:"\u51FD\u6570\u7684\u9012\u5F52\u8C03\u7528",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/51a0935ddc884f1b9f6c1395f2011425/7308cd65a7fe1d13eebe2600054d29c7-hd.m3u8",parent:"34",key:"341"},{shixun_name:"\u9012\u5F52\u51FD\u6570\u7F16\u5199\u5165\u95E8",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/4qjw9t32/challenges",parent:"34",key:"342"},{shixun_name:"\u9006\u5E8F\u8F93\u51FA\uFF08\u4F7F\u7528\u9012\u5F52\u89E3\u51B3\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/oxtrf27l/challenges",parent:"34",key:"343"},{stage_name:"\u7C7B\u548C\u5BF9\u8C61",parent:0,key:4},{discipline_name:"\u6784\u9020\u51FD\u6570\u548C\u6790\u6784\u51FD\u6570",shixun_count:"2",video_count:"1",parent:4,key:"41"},{shixun_name:"\u6784\u9020\u51FD\u6570\u548C\u6790\u6784\u51FD\u6570",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/b4e17c1e8c8d449f862af9ea94fa9522/bad9e739addf73679a70e38a9d2cc32c-hd.m3u8",parent:"41",key:"411"},{shixun_name:"\u5B9A\u4E49\u548C\u4F7F\u7528\u7ED3\u6784",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/igwom4hs/challenges",parent:"41",key:"412"},{shixun_name:"\u5B9A\u4E49\u548C\u4F7F\u7528\u7ED3\u6784\u4F53",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/5yo6rw3f/challenges",parent:"41",key:"413"},{stage_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",parent:0,key:5},{discipline_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",shixun_count:"1",video_count:"1",parent:5,key:"51"},{shixun_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/fde33b24ff2b4bf5bc5e238dc473df8e/3cf407a74af29554226084d17fa17858-hd.m3u8",parent:"51",key:"511"},{shixun_name:"C++\u7A0B\u5E8F\u7684\u7ED3\u6784",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/yqbh3fx5/challenges",parent:"51",key:"512"},{stage_name:"\u6570\u7EC4\u3001\u6307\u9488\u4E0E\u5B57\u7B26\u4E32",parent:0,key:6},{discipline_name:"\u6570\u7EC4",shixun_count:"1",video_count:"1",parent:6,key:"61"},{shixun_name:"\u6570\u7EC4",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7785?subject_id=jpl5vs26",parent:"61",key:"611"},{shixun_name:"\u5E73\u5747\u6210\u7EE9\u4E0E\u7B80\u5355\u7EDF\u8BA1",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/4wcfgm5q/challenges",parent:"61",key:"612"},{discipline_name:"\u6307\u9488",shixun_count:"3",video_count:"1",parent:6,key:"62"},{shixun_name:"\u6307\u9488",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/00a5448862c84c42b1a369ac2be88ae9/9b9627710a725e570ede478663c2589d-hd.m3u8",parent:"62",key:"621"},{shixun_name:"\u6307\u9488\u7EC3\u624B-\u5B57\u7B26\u4E32\u5012\u5E8F",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/lkn6xuc3/challenges",parent:"62",key:"622"},{shixun_name:"\u6307\u9488\u6570\u7EC4-\u5355\u8BCD\u5012\u5E8F",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/vtk73ny2/challenges",parent:"62",key:"623"},{shixun_name:"\u7528\u6307\u9488\u89E3\u51B3\u95EE\u9898-\u6587\u672C\u683C\u5F0F\u5904\u7406",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/xfnp73fz/challenges",parent:"62",key:"624"},{stage_name:"\u7C7B\u7684\u7EE7\u627F",parent:0,key:7},{discipline_name:"\u7C7B\u7684\u7EE7\u627F",shixun_count:"1",video_count:"3",parent:7,key:"71"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/1eedcdb9ec43442c93780f04859c9aa9/631b8c88eb263877d24637d5b8d54dc5-hd.m3u8",parent:"71",key:"711"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/fc1e7d8d8140469ba1bc01ee64fcc3c1/9256d13f4a14ae17ba9cac9f895b8a9d-hd.m3u8",parent:"71",key:"712"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(3)",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7806?subject_id=jpl5vs26",parent:"71",key:"713"},{shixun_name:"\u7EE7\u627F\u4E0E\u6D3E\u751F",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/f83ipgyo/challenges",parent:"71",key:"714"},{stage_name:"\u591A\u6001\u6027",parent:0,key:8},{discipline_name:"\u591A\u6001\u6027",shixun_count:"1",video_count:"2",parent:8,key:"81"},{shixun_name:"\u591A\u6001\u6027(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/5a960b51ebf346d2b77afb3b70d00768/73d6fa00824f4c73b885d33f688c3294-hd.m3u8",parent:"81",key:"811"},{shixun_name:"\u591A\u6001\u6027(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/08fe97a36e184cf1bf27cdd7a24794c9/625c4e9e863840443f5332ccc02761fc-hd.m3u8",parent:"81",key:"812"},{shixun_name:"\u865A\u51FD\u6570\u4E0E\u591A\u6001\u6027",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/9pjmg7uf/challenges",parent:"81",key:"813"},{stage_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E",parent:0,key:9},{discipline_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E",shixun_count:"1",video_count:"3",parent:9,key:"91"},{shixun_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/8dcf418d2d16404d91af1780f669e549/eb538592d8a3b98e1c2f7f844f85b778-hd.m3u8",parent:"91",key:"911"},{shixun_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/459f2693af7b48f8b854033e666a77f8/f5b140c5adc0f24ac56b72492373306a-hd.m3u8",parent:"91",key:"912"},{shixun_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E(3)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/ccea50bc15d2468aab99aff19eb69e16/a5ecac1ee0c07360d07880187a787085-hd.m3u8",parent:"91",key:"913"},{shixun_name:"\u7FA4\u4F53\u7C7B\u548C\u7FA4\u4F53\u6570\u636E\u7684\u7EC4\u7EC7",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/kfv3my9o/challenges",parent:"91",key:"914"},{stage_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",parent:0,key:10},{discipline_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",shixun_count:"1",video_count:"3",parent:10,key:"101"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/2f3154d695a542fbaba5c483d8d7f7a9/aea4302c51501634469ed4b91462c810-hd.m3u8",parent:"101",key:"1011"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/23be6a61e4e54db398b9172b1213a1f2/3f1e88f97957369e29ef2bde63640004-hd.m3u8",parent:"101",key:"1012"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93(3)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/a5887adcc34445bba695de7dcadb781e/0fb3a6a6ad38f7a107054c5f2f0de262-hd.m3u8",parent:"101",key:"1013"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/hmtw5iq6/challenges",parent:"101",key:"1014"},{stage_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA11",parent:0,key:1911},{discipline_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA",shixun_count:"1",video_count:"2",parent:1911,key:9111},{shixun_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165\u8F93\u51FA(1)22222",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c9e76b949ee847fbb89a926220526692/b80ff8d09a87bfde1064f5b73ae7c34b-hd.m3u8",parent:9111,key:"91111"},{shixun_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165\u8F93\u51FA(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/65c02365a4ad40858b69b8cbe3ca4aa1/18a2c5697d4a84a971c500565509f038-hd.m3u8",parent:"9111",key:"91112"},{shixun_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/hsvuixpm/challenges",parent:"9111",key:"91113"},{stage_name:"\u5F02\u5E38\u5904\u7406",parent:0,key:12},{discipline_name:"\u5F02\u5E38\u5904\u7406",shixun_count:"1",video_count:"1",parent:12,key:"121"},{shixun_name:"\u5F02\u5E38\u5904\u7406",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c95499dd4c064584914e32fca9563717/98a8be24326e3eb35375713f5ccbb8bb-hd.m3u8",parent:"121",key:"1211"},{shixun_name:"\u7F16\u5199\u5F02\u5E38\u5904\u7406\u7684\u7C7B",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/nlt6f7ae/challenges",parent:"121",key:"1212"}].map(ae=>(ae.parent=Number(ae.parent),ae.key=Number(ae.key),ae)),review:[{stage_name:"\u590D\u4E60\u5B66\u4E60",parent:9999999,key:0},{stage_name:"\u7B80\u5355\u7A0B\u5E8F\u8BBE\u8BA1",parent:0,key:1},{discipline_name:"\u57FA\u7840\u6570\u636E\u7C7B\u578B\u548C\u8868\u8FBE\u5F0F",shixun_count:"1",video_count:"1",parent:1,key:"11"},{shixun_name:"\u57FA\u7840\u6570\u636E\u7C7B\u578B\u548C\u8868\u8FBE\u5F0F",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/f5f9c87860cb4a98ba86da37b5bfac70/8d50a9c4d5d4d3382c09bad3f4c5dcb6-hd.m3u8",parent:"11",key:"111"},{shixun_name:"C++\u7B80\u5355\u7A0B\u5E8F\u8BBE\u8BA1",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/lg5afhzv/challenges",parent:"11",key:"112"},{discipline_name:"\u5FAA\u73AF",shixun_count:"2",video_count:"2",parent:1,key:"12"},{shixun_name:"while\u8BED\u53E5",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/dda06371a1594f5d865479a0fadc77bb/cb504e3af36ebe2ba979e8fe5fbb2222-hd.m3u8",parent:"12",key:"121"},{shixun_name:"C++\u5FAA\u73AF\u7ED3\u6784\u2014\u2014\uFF08\u719F\u6089while\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/8yhf4sn6/challenges",parent:"12",key:"122"},{shixun_name:"for\u8BED\u53E5",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/503194c483f44ccfacc7f9ee14cda70a/36cbd964c6657d1bbc43eb33b98f0c51-hd.m3u8",parent:"12",key:"123"},{shixun_name:"C++\u9009\u62E9\u7ED3\u6784\u2014\u2014\uFF08\u5DE7\u7528switch\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/sm3c5a7v/challenges",parent:"12",key:"124"},{stage_name:"\u51FD\u6570",parent:0,key:2},{discipline_name:"\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u7528",shixun_count:"2",video_count:"1",parent:2,key:"21"},{shixun_name:"\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u7528",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c10e39b3afb14ad0b890368aa1751821/ef361445294452e1d9bfacae80b3ec2f-hd.m3u8",parent:"21",key:"211"},{shixun_name:"C++\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u75281",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/3q4isevr/challenges",parent:"21",key:"212"},{shixun_name:"C++\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u75282",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/tlhxwo64/challenges",parent:"21",key:"213"},{discipline_name:"\u4F20\u8F93\u4F20\u9012",shixun_count:"2",video_count:"1",parent:2,key:"22"},{shixun_name:"\u51FD\u6570\u7684\u53C2\u6570",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7785?subject_id=jpl5vs26",parent:"22",key:"221"},{shixun_name:"C++\u53C2\u6570\u4F20\u90121",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/2phrn8yk/challenges",parent:"22",key:"222"},{shixun_name:"C++\u53C2\u6570\u4F20\u90122",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/xsq7p4a6/challenges",parent:"22",key:"223"},{discipline_name:"\u9012\u5F52\u51FD\u6570",shixun_count:"2",video_count:"2",parent:2,key:"23"},{shixun_name:"\u51FD\u6570\u7684\u9012\u5F52\u8C03\u7528",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/51a0935ddc884f1b9f6c1395f2011425/7308cd65a7fe1d13eebe2600054d29c7-hd.m3u8",parent:"23",key:"231"},{shixun_name:"\u9012\u5F52\u51FD\u6570\u7F16\u5199\u5165\u95E8",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/4qjw9t32/challenges",parent:"23",key:"232"},{shixun_name:"\u9006\u5E8F\u8F93\u51FA\uFF08\u4F7F\u7528\u9012\u5F52\u89E3\u51B3\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/oxtrf27l/challenges",parent:"23",key:"233"},{stage_name:"\u7C7B\u548C\u5BF9\u8C61",parent:0,key:3},{discipline_name:"\u6784\u9020\u51FD\u6570\u548C\u6790\u6784\u51FD\u6570",shixun_count:"2",video_count:"1",parent:3,key:"31"},{shixun_name:"\u6784\u9020\u51FD\u6570\u548C\u6790\u6784\u51FD\u6570",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/b4e17c1e8c8d449f862af9ea94fa9522/bad9e739addf73679a70e38a9d2cc32c-hd.m3u8",parent:"31",key:"311"},{shixun_name:"\u5B9A\u4E49\u548C\u4F7F\u7528\u7ED3\u6784",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/igwom4hs/challenges",parent:"31",key:"312"},{shixun_name:"\u5B9A\u4E49\u548C\u4F7F\u7528\u7ED3\u6784\u4F53",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/5yo6rw3f/challenges",parent:"31",key:"313"},{stage_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",parent:0,key:4},{discipline_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",shixun_count:"1",video_count:"1",parent:4,key:"41"},{shixun_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/fde33b24ff2b4bf5bc5e238dc473df8e/3cf407a74af29554226084d17fa17858-hd.m3u8",parent:"41",key:"411"},{shixun_name:"C++\u7A0B\u5E8F\u7684\u7ED3\u6784",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/yqbh3fx5/challenges",parent:"41",key:"412"},{stage_name:"\u6570\u7EC4\u3001\u6307\u9488\u4E0E\u5B57\u7B26\u4E32",parent:0,key:5},{discipline_name:"\u6570\u7EC4",shixun_count:"1",video_count:"1",parent:5,key:"51"},{shixun_name:"\u6570\u7EC4",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7785?subject_id=jpl5vs26",parent:"51",key:"511"},{shixun_name:"\u5E73\u5747\u6210\u7EE9\u4E0E\u7B80\u5355\u7EDF\u8BA1",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/4wcfgm5q/challenges",parent:"51",key:"512"},{discipline_name:"\u6307\u9488",shixun_count:"1",video_count:"1",parent:5,key:"52"},{shixun_name:"\u6307\u9488",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/00a5448862c84c42b1a369ac2be88ae9/9b9627710a725e570ede478663c2589d-hd.m3u8",parent:"52",key:"521"},{shixun_name:"\u7528\u6307\u9488\u89E3\u51B3\u95EE\u9898-\u6587\u672C\u683C\u5F0F\u5904\u7406",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/xfnp73fz/challenges",parent:"52",key:"522"},{stage_name:"\u7C7B\u7684\u7EE7\u627F",parent:0,key:6},{discipline_name:"\u7C7B\u7684\u7EE7\u627F",shixun_count:"0",video_count:"2",parent:6,key:"61"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/1eedcdb9ec43442c93780f04859c9aa9/631b8c88eb263877d24637d5b8d54dc5-hd.m3u8",parent:"61",key:"611"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/fc1e7d8d8140469ba1bc01ee64fcc3c1/9256d13f4a14ae17ba9cac9f895b8a9d-hd.m3u8",parent:"61",key:"612"},{stage_name:"\u591A\u6001\u6027",parent:0,key:7},{discipline_name:"\u591A\u6001\u6027",shixun_count:"1",video_count:"2",parent:7,key:"71"},{shixun_name:"\u591A\u6001\u6027(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/5a960b51ebf346d2b77afb3b70d00768/73d6fa00824f4c73b885d33f688c3294-hd.m3u8",parent:"71",key:"711"},{shixun_name:"\u591A\u6001\u6027(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/08fe97a36e184cf1bf27cdd7a24794c9/625c4e9e863840443f5332ccc02761fc-hd.m3u8",parent:"71",key:"712"},{shixun_name:"\u865A\u51FD\u6570\u4E0E\u591A\u6001\u6027",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/9pjmg7uf/challenges",parent:"71",key:"713"},{stage_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E",parent:0,key:8},{discipline_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E",shixun_count:"1",video_count:"1",parent:8,key:"81"},{shixun_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/8dcf418d2d16404d91af1780f669e549/eb538592d8a3b98e1c2f7f844f85b778-hd.m3u8",parent:"81",key:"811"},{shixun_name:"\u7FA4\u4F53\u7C7B\u548C\u7FA4\u4F53\u6570\u636E\u7684\u7EC4\u7EC7",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/kfv3my9o/challenges",parent:"81",key:"812"},{stage_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",parent:0,key:9},{discipline_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",shixun_count:"1",video_count:"1",parent:9,key:"91"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/2f3154d695a542fbaba5c483d8d7f7a9/aea4302c51501634469ed4b91462c810-hd.m3u8",parent:"91",key:"911"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/hmtw5iq6/challenges",parent:"91",key:"912"},{stage_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA",parent:0,key:10},{discipline_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA",shixun_count:"0",video_count:"2",parent:10,key:"101"},{shixun_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165\u8F93\u51FA(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c9e76b949ee847fbb89a926220526692/b80ff8d09a87bfde1064f5b73ae7c34b-hd.m3u8",parent:"101",key:"1011"},{shixun_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165\u8F93\u51FA(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/65c02365a4ad40858b69b8cbe3ca4aa1/18a2c5697d4a84a971c500565509f038-hd.m3u8",parent:"101",key:"1012"},{shixun_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/hsvuixpm/challenges",parent:"101",key:"1013"},{stage_name:"\u5F02\u5E38\u5904\u7406",parent:0,key:9911},{discipline_name:"\u5F02\u5E38\u5904\u7406",shixun_count:"1",video_count:"1",parent:9911,key:"99111"},{shixun_name:"\u5F02\u5E38\u5904\u7406",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c95499dd4c064584914e32fca9563717/98a8be24326e3eb35375713f5ccbb8bb-hd.m3u8",parent:"99111",key:"991111"},{shixun_name:"\u7F16\u5199\u5F02\u5E38\u5904\u7406\u7684\u7C7B",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/nlt6f7ae/challenges",parent:"99111",key:"991112"}].map(ae=>(ae.parent=Number(ae.parent),ae.key=Number(ae.key),ae)),before:[{stage_name:"\u8003\u524D\u5B66\u4E60",parent:9999999,key:0},{stage_name:"\u7EEA\u8BBA",parent:0,key:1},{discipline_name:"\u7EEA\u8BBA",shixun_count:"1",video_count:"2",parent:1,key:"11"},{shixun_name:"\u7EEA\u8BBA1",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/f066ae1a9a8f418f837e5bf8d02b2690/76df907c20efd95bea0fa23424f10693-hd.m3u8",parent:"11",key:"111"},{shixun_name:"\u7EEA\u8BBA2",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/068ca7853da448c794eeffb0dee8bed4/5bb446a882043683e37474ff408f601b-hd.m3u8",parent:"11",key:"112"},{shixun_name:"C++\u5F00\u53D1\u73AF\u5883\u5E94\u7528\u5165\u95E8",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/zxb937qn/challenges",parent:"11",key:"113"},{stage_name:"\u7B80\u5355\u7A0B\u5E8F\u8BBE\u8BA1",parent:0,key:2},{discipline_name:"\u57FA\u7840\u6570\u636E\u7C7B\u578B\u548C\u8868\u8FBE\u5F0F",shixun_count:"1",video_count:"1",parent:2,key:"21"},{shixun_name:"\u57FA\u7840\u6570\u636E\u7C7B\u578B\u548C\u8868\u8FBE\u5F0F",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/f5f9c87860cb4a98ba86da37b5bfac70/8d50a9c4d5d4d3382c09bad3f4c5dcb6-hd.m3u8",parent:"21",key:"211"},{shixun_name:"C++\u7B80\u5355\u7A0B\u5E8F\u8BBE\u8BA1",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/lg5afhzv/challenges",parent:"21",key:"212"},{stage_name:"\u51FD\u6570",parent:0,key:3},{discipline_name:"\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u7528",shixun_count:"2",video_count:"1",parent:3,key:"31"},{shixun_name:"\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u7528",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c10e39b3afb14ad0b890368aa1751821/ef361445294452e1d9bfacae80b3ec2f-hd.m3u8",parent:"31",key:"311"},{shixun_name:"C++\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u75281",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/3q4isevr/challenges",parent:"31",key:"312"},{shixun_name:"C++\u51FD\u6570\u7684\u5B9A\u4E49\u4E0E\u8C03\u75282",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/tlhxwo64/challenges",parent:"31",key:"313"},{discipline_name:"\u9012\u5F52\u51FD\u6570",shixun_count:"2",video_count:"1",parent:3,key:"32"},{shixun_name:"\u51FD\u6570\u7684\u9012\u5F52\u8C03\u7528",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/51a0935ddc884f1b9f6c1395f2011425/7308cd65a7fe1d13eebe2600054d29c7-hd.m3u8",parent:"32",key:"321"},{shixun_name:"\u9012\u5F52\u51FD\u6570\u7F16\u5199\u5165\u95E8",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/4qjw9t32/challenges",parent:"32",key:"322"},{shixun_name:"\u9006\u5E8F\u8F93\u51FA\uFF08\u4F7F\u7528\u9012\u5F52\u89E3\u51B3\uFF09",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/oxtrf27l/challenges",parent:"32",key:"323"},{stage_name:"\u7C7B\u548C\u5BF9\u8C61",parent:0,key:4},{discipline_name:"\u6784\u9020\u51FD\u6570\u548C\u6790\u6784\u51FD\u6570",shixun_count:"2",video_count:"1",parent:4,key:"41"},{shixun_name:"\u6784\u9020\u51FD\u6570\u548C\u6790\u6784\u51FD\u6570",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/b4e17c1e8c8d449f862af9ea94fa9522/bad9e739addf73679a70e38a9d2cc32c-hd.m3u8",parent:"41",key:"411"},{shixun_name:"\u5B9A\u4E49\u548C\u4F7F\u7528\u7ED3\u6784",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/igwom4hs/challenges",parent:"41",key:"412"},{shixun_name:"\u5B9A\u4E49\u548C\u4F7F\u7528\u7ED3\u6784\u4F53",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/5yo6rw3f/challenges",parent:"41",key:"413"},{stage_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",parent:0,key:5},{discipline_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",shixun_count:"1",video_count:"1",parent:5,key:"51"},{shixun_name:"\u6570\u636E\u7684\u5171\u4EAB\u4E0E\u4FDD\u62A4",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/fde33b24ff2b4bf5bc5e238dc473df8e/3cf407a74af29554226084d17fa17858-hd.m3u8",parent:"51",key:"511"},{shixun_name:"C++\u7A0B\u5E8F\u7684\u7ED3\u6784",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/yqbh3fx5/challenges",parent:"51",key:"512"},{stage_name:"\u6570\u7EC4\u3001\u6307\u9488\u4E0E\u5B57\u7B26\u4E32",parent:0,key:6},{discipline_name:"\u6570\u7EC4",shixun_count:"1",video_count:"1",parent:6,key:"61"},{shixun_name:"\u6570\u7EC4",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7785?subject_id=jpl5vs26",parent:"61",key:"611"},{shixun_name:"\u5E73\u5747\u6210\u7EE9\u4E0E\u7B80\u5355\u7EDF\u8BA1",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/4wcfgm5q/challenges",parent:"61",key:"612"},{stage_name:"\u7C7B\u7684\u7EE7\u627F",parent:0,key:7},{discipline_name:"\u7C7B\u7684\u7EE7\u627F",shixun_count:"1",video_count:"3",parent:7,key:"71"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/1eedcdb9ec43442c93780f04859c9aa9/631b8c88eb263877d24637d5b8d54dc5-hd.m3u8",parent:"71",key:"711"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/fc1e7d8d8140469ba1bc01ee64fcc3c1/9256d13f4a14ae17ba9cac9f895b8a9d-hd.m3u8",parent:"71",key:"712"},{shixun_name:"\u7C7B\u7684\u7EE7\u627F(3)",shixun_type:"\u89C6\u9891",url:"https://www.educoder.net/video/7806?subject_id=jpl5vs26",parent:"71",key:"713"},{shixun_name:"\u7EE7\u627F\u4E0E\u6D3E\u751F",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/f83ipgyo/challenges",parent:"71",key:"714"},{stage_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E",parent:0,key:8},{discipline_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E",shixun_count:"0",video_count:"1",parent:8,key:"81"},{shixun_name:"\u6A21\u677F\u4E0E\u7FA4\u4F53\u6570\u636E(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/8dcf418d2d16404d91af1780f669e549/eb538592d8a3b98e1c2f7f844f85b778-hd.m3u8",parent:"81",key:"811"},{stage_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",parent:0,key:9},{discipline_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93",shixun_count:"0",video_count:"1",parent:9,key:"91"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/2f3154d695a542fbaba5c483d8d7f7a9/aea4302c51501634469ed4b91462c810-hd.m3u8",parent:"91",key:"911"},{shixun_name:"\u6CDB\u578B\u7A0B\u5E8F\u8BBE\u8BA1\u4E0EC++\u6807\u51C6\u6A21\u677F\u5E93(2)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/23be6a61e4e54db398b9172b1213a1f2/3f1e88f97957369e29ef2bde63640004-hd.m3u8",parent:"91",key:"912"},{stage_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA",parent:0,key:10},{discipline_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165/\u8F93\u51FA",shixun_count:"0",video_count:"1",parent:10,key:"101"},{shixun_name:"\u6D41\u7C7B\u5E93\u4E0E\u8F93\u5165\u8F93\u51FA(1)",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c9e76b949ee847fbb89a926220526692/b80ff8d09a87bfde1064f5b73ae7c34b-hd.m3u8",parent:"101",key:"1011"},{stage_name:"\u5F02\u5E38\u5904\u7406",parent:0,key:9911},{discipline_name:"\u5F02\u5E38\u5904\u7406",shixun_count:"1",video_count:"1",parent:9911,key:"99111"},{shixun_name:"\u5F02\u5E38\u5904\u7406",shixun_type:"\u89C6\u9891",url:"https://video.educoder.net/c95499dd4c064584914e32fca9563717/98a8be24326e3eb35375713f5ccbb8bb-hd.m3u8",parent:"99111",key:"991111"},{shixun_name:"\u7F16\u5199\u5F02\u5E38\u5904\u7406\u7684\u7C7B",shixun_type:"\u5B9E\u8BAD",url:"https://www.educoder.net/shixuns/nlt6f7ae/challenges",parent:"99111",key:"991112"}].map(ae=>(ae.parent=Number(ae.parent),ae.key=Number(ae.key),ae))};var G=x(27930),re=x(74451),de=Object.defineProperty,we=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,H=(ae,F,k)=>F in ae?de(ae,F,{enumerable:!0,configurable:!0,writable:!0,value:k}):ae[F]=k,st=(ae,F)=>{for(var k in F||(F={}))Ie.call(F,k)&&H(ae,k,F[k]);if(we)for(var k of we(F))D.call(F,k)&&H(ae,k,F[k]);return ae};const Ge=({classroomList:ae,loading:F,dispatch:k})=>{const[X]=(0,J.useSearchParams)(),[le]=(0,_.useState)(st({},(0,J.useParams)())),[me,Xe]=(0,_.useState)("init"),[se,vt]=(0,_.useState)(""),yt=(0,_.useRef)();(0,_.useEffect)(()=>{const ce=X.get("tabId");ce&&(Xe(ce),le.status=ce)},[le.categoryId,X.get("tabId")]);const Je=ce=>{Xe(ce.key)},nt=[{name:"\u521D\u59CB\u5B66\u4E60",id:"init"},{name:"\u590D\u4E60\u5B66\u4E60",id:"review"},{name:"\u8003\u524D\u5B66\u4E60",id:"before"}],ne=ce=>{ce.data.type==="playVideo"&&vt(ce.data.url)};(0,_.useEffect)(()=>{me&&ee(),window.addEventListener("message",ne)},[me]);const ee=()=>{var ce;(ce=yt.current.contentWindow)==null||ce.postMessage({data:te[me]},"*")};return _.createElement("section",null,_.createElement(G.Z,{isLoading:F["classroomList/getClassroomAttendancesList"],tabDataSource:nt,isAdmin:(0,g.GJ)(),onTabMenuClick:Je,defaultSelectedKeys:[me]}),_.createElement("section",null,_.createElement(Ae.Z,{loading:F["classroomList/getClassroomAttendancesList"],active:!0,avatar:{size:40},paragraph:{rows:5},className:"mt30"},_.createElement("iframe",{src:"/knowledgegraph/parseTree.html",onLoad:ee,className:A.iframe,ref:yt}))),_.createElement(Y.default,{open:!!se,onCancel:()=>vt(""),width:800,footer:null,bodyStyle:{padding:0},centered:!0,destroyOnClose:!0},_.createElement(re.Z,{src:se,autoPlay:!0,toLog:!1})))};var Ce=(0,J.connect)(({classroomList:ae,loading:F,globalSetting:k})=>({classroomList:ae,globalSetting:k,loading:F.effects}))(Ge)},27930:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return D}});var _=x(59301),J=x(77019),Ae=x(5269),Y=x(93041),A=x(75727),g=x(6767),te=x(25399),G={tabMenuContainer:"tabMenuContainer___uf5IP",control:"control___GheLs",iconH:"iconH___Wzw_r",selectBtn:"selectBtn___mfEnI",selectBtn1:"selectBtn1___rJF8S"},re=x(63823),de=x(10102),we=x(68911),D=({isLoading:H,addText:st,tabDataSource:Ge,isAdmin:Ce,dispatch:ae,classroomList:F,type:k,isExercise:X,defaultSelectedKeys:le,onTabMenuClick:me,getDropdownMenu:Xe,showControlButton:se,buttonText:vt,buttonIcon:yt="icon-tianjiadaohang",extraNode:Je,user:nt,onButtonClick:ne,isModelUser:ee,menuItemWidth:ce=125,showExtra:K=!1})=>{var Se,ze,ve,Pe,ke;const rt=(0,re.useParams)();return _.createElement("div",{className:G.tabMenuContainer},_.createElement(J.Z,null,_.createElement(Ae.Z,{flex:"1"},_.createElement(Y.default,{onSelect:_e=>H?{}:me(_e),mode:"horizontal",selectedKeys:le},Ge.map(_e=>_.createElement(Y.default.Item,{style:{width:ce},key:typeof _e.index=="number"?_e.index:_e.id},_.createElement("span",{className:"c-grey-666"},_e.name),_e.total!==void 0&&Ce&&_.createElement("span",{className:"c-grey-999 ml20"},_e.total||0))))),Ce&&X&&_.createElement("i",{className:"iconfont icon-shezhi8",style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:()=>{ae({type:"classroomList/setActionTabs",payload:{key:"\u5728\u7EBF\u8003\u8BD5\u8BBE\u7F6E"}})}}),(Ce||K)&&_.createElement(Ae.Z,{className:"mr20 gutter-row",style:{display:"flex",alignItems:"center",color:"#0152d9",paddingBottom:3}},X&&_.createElement(A.Z,{className:"mr15",placement:"bottom",arrow:!0,dropdownRender:()=>_.createElement(Y.default,null,_.createElement(Y.default.Item,{key:1,onClick:()=>{var _e;if(!(0,we.Ye)(ae)){if((0,de.Rm)()&&!((_e=F.AssistantObject.exercise)!=null&&_e.can_download)){g.ZP.warning("\u60A8\u672A\u83B7\u53D6\u6B64\u6743\u9650\uFF0C\u9700\u5411\u8BFE\u5802\u7BA1\u7406\u5458\u7533\u8BF7\u6743\u9650\u624D\u80FD\u4F7F\u7528\u6B64\u529F\u80FD");return}ae({type:"classroomList/setActionTabs",payload:{key:"\u5BFC\u51FA\u6210\u7EE9",type:k,exportType:"exercise",category_id:rt.categoryId}})}}},"\u5B66\u751F\u6210\u7EE9"),_.createElement(Y.default.Item,{key:3,onClick:()=>{var _e;if(!(0,we.Ye)(ae)){if((0,de.Rm)()&&!((_e=F.AssistantObject.exercise)!=null&&_e.can_download)){g.ZP.warning("\u60A8\u672A\u83B7\u53D6\u6B64\u6743\u9650\uFF0C\u9700\u5411\u8BFE\u5802\u7BA1\u7406\u5458\u7533\u8BF7\u6743\u9650\u624D\u80FD\u4F7F\u7528\u6B64\u529F\u80FD");return}re.history.push(`/classrooms/${rt==null?void 0:rt.coursesId}/exportlist/exercise_score,export_exercise_users`)}}},"\u5386\u53F2\u5BFC\u51FA"))},_.createElement("div",{className:"c-blue font16 ml20 current",style:{marginTop:2}},_.createElement("span",{style:{color:"#666666",cursor:"pointer"}},_.createElement("i",{className:"iconfont icon-xiazai6"})))),_.createElement("div",{className:G.control},_.createElement("div",{className:G.extra},Je),se&&(vt=="\u6DFB\u52A0\u76F4\u64AD"?_.createElement(A.Z,{menu:{items:(ze=(Se=[{label:_.createElement("div",{onClick:()=>{ne("\u5916\u94FE")}},"\u5916\u94FE\u76F4\u64AD"),key:"1",show:!0},(ee||(0,de.ag)())&&{label:_.createElement("div",{onClick:()=>{ne("\u5934\u6B4C")}},"\u5934\u6B4C\u76F4\u64AD"),key:"2",show:!0}])==null?void 0:Se.filter(_e=>_e==null?void 0:_e.show))==null?void 0:ze.map(_e=>({label:_e==null?void 0:_e.label,key:_e==null?void 0:_e.key}))}},_.createElement("span",{className:G.selectBtn},_.createElement("span",null,_.createElement("i",{className:`iconfont ${yt}`})),_.createElement("span",null,vt))):_.createElement("span",{onClick:ne,style:{cursor:"pointer"},className:G.selectBtn},_.createElement("span",null,_.createElement("i",{className:`iconfont ${yt}`})),_.createElement("span",null,vt))),!!Xe&&_.createElement(A.Z,{disabled:((ve=nt==null?void 0:nt.userInfo)==null?void 0:ve.user_status)===2,className:"ml10",dropdownRender:Xe},_.createElement("span",{className:((Pe=nt==null?void 0:nt.userInfo)==null?void 0:Pe.user_status)===2?G.selectBtn1:G.selectBtn},_.createElement("span",null,_.createElement("i",{className:"iconfont icon-tianjiadaohang"})),_.createElement(te.Z,{title:((ke=nt==null?void 0:nt.userInfo)==null?void 0:ke.user_status)===2&&"\u6559\u5B66\u8BFE\u5802\u8BD5\u7528\u671F\u5DF2\u7ED3\u675F\uFF0C\u5E73\u53F0\u5DF2\u6682\u505C\u63D0\u4F9B\u5728\u7EBF\u8003\u8BD5\u521B\u5EFA\u529F\u80FD"},_.createElement("span",null,st||"\u521B\u5EFA\u8BD5\u5377"))))))))}},37295:function(ii,qe,x){"use strict";x.d(qe,{BU:function(){return J},Dj:function(){return _},gH:function(){return Ae},vp:function(){return Y}});function _(A){try{A.mozRequestFullScreen?A.mozRequestFullScreen():A.webkitRequestFullScreen&&A.webkitRequestFullScreen()}catch(g){console.log(g,":e")}}function J(){window.top.document.webkitExitFullscreen?window.top.document.webkitExitFullscreen():document.exitFullscreen?window.top.document.exitFullscreen():document.msExitFullscreen?window.top.document.msExitFullscreen():document.mozCancelFullScreen&&window.top.document.mozCancelFullScreen()}const Ae=()=>{if(document.webkitExitFullscreen)return"webkitfullscreenchange";if(document.exitFullscreen)return"fullscreenchange";if(document.msExitFullscreen)return"msfullscreenchange";if(document.mozCancelFullScreen)return"mozfullscreenchange"};function Y(){var A=window.top.document.fullscreenElement||window.top.document.mozFullscreenElement||window.top.document.webkitFullscreenElement,g=document.fullscreenEnabled||document.mozFullscreenEnabled||document.webkitFullscreenEnabled;return console.log("fullscreenElement",A),window.isFullScreen?window.isFullScreen:A!=null}},68262:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return Pi}});class _{static install(){Object.setPrototypeOf=Object.setPrototypeOf||function(d,f){return d.__proto__=f,d},Object.assign=Object.assign||function(d){if(d==null)throw new TypeError("Cannot convert undefined or null to object");let f=Object(d);for(let p=1;p<arguments.length;p++){let E=arguments[p];if(E!=null)for(let T in E)E.hasOwnProperty(T)&&(f[T]=E[T])}return f},typeof self.Promise!="function"&&x(3867).polyfill()}}_.install();var J=_,Ae=x(86204),Y=x.n(Ae);class A{static e(d,f){(!d||A.FORCE_GLOBAL_TAG)&&(d=A.GLOBAL_TAG);let p=`[${d}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","error",p),A.ENABLE_ERROR&&(console.error?console.error(p):console.warn?console.warn(p):console.log(p))}static i(d,f){(!d||A.FORCE_GLOBAL_TAG)&&(d=A.GLOBAL_TAG);let p=`[${d}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","info",p),A.ENABLE_INFO&&(console.info?console.info(p):console.log(p))}static w(d,f){(!d||A.FORCE_GLOBAL_TAG)&&(d=A.GLOBAL_TAG);let p=`[${d}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","warn",p),A.ENABLE_WARN&&(console.warn?console.warn(p):console.log(p))}static d(d,f){(!d||A.FORCE_GLOBAL_TAG)&&(d=A.GLOBAL_TAG);let p=`[${d}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","debug",p),A.ENABLE_DEBUG&&(console.debug?console.debug(p):console.log(p))}static v(d,f){(!d||A.FORCE_GLOBAL_TAG)&&(d=A.GLOBAL_TAG);let p=`[${d}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","verbose",p),A.ENABLE_VERBOSE&&console.log(p)}}A.GLOBAL_TAG="flv.js",A.FORCE_GLOBAL_TAG=!1,A.ENABLE_ERROR=!0,A.ENABLE_INFO=!0,A.ENABLE_WARN=!0,A.ENABLE_DEBUG=!0,A.ENABLE_VERBOSE=!0,A.ENABLE_CALLBACK=!1,A.emitter=new(Y());var g=A;class te{constructor(){this._firstCheckpoint=0,this._lastCheckpoint=0,this._intervalBytes=0,this._totalBytes=0,this._lastSecondBytes=0,self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now}reset(){this._firstCheckpoint=this._lastCheckpoint=0,this._totalBytes=this._intervalBytes=0,this._lastSecondBytes=0}addBytes(d){this._firstCheckpoint===0?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=d,this._totalBytes+=d):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=d,this._totalBytes+=d):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=d,this._totalBytes+=d,this._lastCheckpoint=this._now())}get currentKBps(){this.addBytes(0);let d=(this._now()-this._lastCheckpoint)/1e3;return d==0&&(d=1),this._intervalBytes/d/1024}get lastSecondKBps(){return this.addBytes(0),this._lastSecondBytes!==0?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}get averageKBps(){let d=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/d/1024}}var G=te;class re{constructor(d){this._message=d}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class de extends re{constructor(d){super(d)}get name(){return"IllegalStateException"}}class we extends re{constructor(d){super(d)}get name(){return"InvalidArgumentException"}}class Ie extends re{constructor(d){super(d)}get name(){return"NotImplementedException"}}const D={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},H={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class st{constructor(d){this._type=d||"undefined",this._status=D.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=D.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===D.kConnecting||this._status===D.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(d){this._onContentLengthKnown=d}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(d){this._onURLRedirect=d}get onDataArrival(){return this._onDataArrival}set onDataArrival(d){this._onDataArrival=d}get onError(){return this._onError}set onError(d){this._onError=d}get onComplete(){return this._onComplete}set onComplete(d){this._onComplete=d}open(d,f){throw new Ie("Unimplemented abstract function!")}abort(){throw new Ie("Unimplemented abstract function!")}}let Ge={};function Ce(){let Fe=self.navigator.userAgent.toLowerCase(),d=/(edge)\/([\w.]+)/.exec(Fe)||/(opr)[\/]([\w.]+)/.exec(Fe)||/(chrome)[ \/]([\w.]+)/.exec(Fe)||/(iemobile)[\/]([\w.]+)/.exec(Fe)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(Fe)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(Fe)||/(webkit)[ \/]([\w.]+)/.exec(Fe)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(Fe)||/(msie) ([\w.]+)/.exec(Fe)||Fe.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(Fe)||Fe.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(Fe)||[],f=/(ipad)/.exec(Fe)||/(ipod)/.exec(Fe)||/(windows phone)/.exec(Fe)||/(iphone)/.exec(Fe)||/(kindle)/.exec(Fe)||/(android)/.exec(Fe)||/(windows)/.exec(Fe)||/(mac)/.exec(Fe)||/(linux)/.exec(Fe)||/(cros)/.exec(Fe)||[],p={browser:d[5]||d[3]||d[1]||"",version:d[2]||d[4]||"0",majorVersion:d[4]||d[2]||"0",platform:f[0]||""},E={};if(p.browser){E[p.browser]=!0;let T=p.majorVersion.split(".");E.version={major:parseInt(p.majorVersion,10),string:p.version},T.length>1&&(E.version.minor=parseInt(T[1],10)),T.length>2&&(E.version.build=parseInt(T[2],10))}if(p.platform&&(E[p.platform]=!0),(E.chrome||E.opr||E.safari)&&(E.webkit=!0),E.rv||E.iemobile){E.rv&&delete E.rv;let T="msie";p.browser=T,E[T]=!0}if(E.edge){delete E.edge;let T="msedge";p.browser=T,E[T]=!0}if(E.opr){let T="opera";p.browser=T,E[T]=!0}if(E.safari&&E.android){let T="android";p.browser=T,E[T]=!0}E.name=p.browser,E.platform=p.platform;for(let T in Ge)Ge.hasOwnProperty(T)&&delete Ge[T];Object.assign(Ge,E)}Ce();var ae=Ge;class F extends st{static isSupported(){try{let d=ae.msedge&&ae.version.minor>=15048,f=ae.msedge?d:!0;return self.fetch&&self.ReadableStream&&f}catch(d){return!1}}constructor(d,f){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=d,this._config=f,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(d,f){this._dataSource=d,this._range=f;let p=d.url;this._config.reuseRedirectedURL&&d.redirectedURL!=null&&(p=d.redirectedURL);let E=this._seekHandler.getConfig(p,f),T=new self.Headers;if(typeof E.headers=="object"){let U=E.headers;for(let Ze in U)U.hasOwnProperty(Ze)&&T.append(Ze,U[Ze])}let O={method:"GET",headers:T,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if(typeof this._config.headers=="object")for(let U in this._config.headers)T.append(U,this._config.headers[U]);d.cors===!1&&(O.mode="same-origin"),d.withCredentials&&(O.credentials="include"),d.referrerPolicy&&(O.referrerPolicy=d.referrerPolicy),this._status=D.kConnecting,self.fetch(E.url,O).then(U=>{if(this._requestAbort){this._requestAbort=!1,this._status=D.kIdle;return}if(U.ok&&U.status>=200&&U.status<=299){if(U.url!==E.url&&this._onURLRedirect){let $e=this._seekHandler.removeURLParameters(U.url);this._onURLRedirect($e)}let Ze=U.headers.get("Content-Length");return Ze!=null&&(this._contentLength=parseInt(Ze),this._contentLength!==0&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,U.body.getReader())}else if(this._status=D.kError,this._onError)this._onError(H.HTTP_STATUS_CODE_INVALID,{code:U.status,msg:U.statusText});else throw new re("FetchStreamLoader: Http code invalid, "+U.status+" "+U.statusText)}).catch(U=>{if(this._status=D.kError,this._onError)this._onError(H.EXCEPTION,{code:-1,msg:U.message});else throw U})}abort(){this._requestAbort=!0}_pump(d){return d.read().then(f=>{if(f.done)if(this._contentLength!==null&&this._receivedLength<this._contentLength){this._status=D.kError;let p=H.EARLY_EOF,E={code:-1,msg:"Fetch stream meet Early-EOF"};if(this._onError)this._onError(p,E);else throw new re(E.msg)}else this._status=D.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1);else{if(this._requestAbort===!0)return this._requestAbort=!1,this._status=D.kComplete,d.cancel();this._status=D.kBuffering;let p=f.value.buffer,E=this._range.from+this._receivedLength;this._receivedLength+=p.byteLength,this._onDataArrival&&this._onDataArrival(p,E,this._receivedLength),this._pump(d)}}).catch(f=>{if(f.code===11&&ae.msedge)return;this._status=D.kError;let p=0,E=null;if((f.code===19||f.message==="network error")&&(this._contentLength===null||this._contentLength!==null&&this._receivedLength<this._contentLength)?(p=H.EARLY_EOF,E={code:f.code,msg:"Fetch stream meet Early-EOF"}):(p=H.EXCEPTION,E={code:f.code,msg:f.message}),this._onError)this._onError(p,E);else throw new re(E.msg)})}}var k=F;class X extends st{static isSupported(){try{let d=new XMLHttpRequest;return d.open("GET","https://example.com",!0),d.responseType="moz-chunked-arraybuffer",d.responseType==="moz-chunked-arraybuffer"}catch(d){return g.w("MozChunkedLoader",d.message),!1}}constructor(d,f){super("xhr-moz-chunked-loader"),this.TAG="MozChunkedLoader",this._seekHandler=d,this._config=f,this._needStash=!0,this._xhr=null,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onloadend=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}open(d,f){this._dataSource=d,this._range=f;let p=d.url;this._config.reuseRedirectedURL&&d.redirectedURL!=null&&(p=d.redirectedURL);let E=this._seekHandler.getConfig(p,f);this._requestURL=E.url;let T=this._xhr=new XMLHttpRequest;if(T.open("GET",E.url,!0),T.responseType="moz-chunked-arraybuffer",T.onreadystatechange=this._onReadyStateChange.bind(this),T.onprogress=this._onProgress.bind(this),T.onloadend=this._onLoadEnd.bind(this),T.onerror=this._onXhrError.bind(this),d.withCredentials&&(T.withCredentials=!0),typeof E.headers=="object"){let O=E.headers;for(let U in O)O.hasOwnProperty(U)&&T.setRequestHeader(U,O[U])}if(typeof this._config.headers=="object"){let O=this._config.headers;for(let U in O)O.hasOwnProperty(U)&&T.setRequestHeader(U,O[U])}this._status=D.kConnecting,T.send()}abort(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=D.kComplete}_onReadyStateChange(d){let f=d.target;if(f.readyState===2){if(f.responseURL!=null&&f.responseURL!==this._requestURL&&this._onURLRedirect){let p=this._seekHandler.removeURLParameters(f.responseURL);this._onURLRedirect(p)}if(f.status!==0&&(f.status<200||f.status>299))if(this._status=D.kError,this._onError)this._onError(H.HTTP_STATUS_CODE_INVALID,{code:f.status,msg:f.statusText});else throw new re("MozChunkedLoader: Http code invalid, "+f.status+" "+f.statusText);else this._status=D.kBuffering}}_onProgress(d){if(this._status===D.kError)return;this._contentLength===null&&d.total!==null&&d.total!==0&&(this._contentLength=d.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let f=d.target.response,p=this._range.from+this._receivedLength;this._receivedLength+=f.byteLength,this._onDataArrival&&this._onDataArrival(f,p,this._receivedLength)}_onLoadEnd(d){if(this._requestAbort===!0){this._requestAbort=!1;return}else if(this._status===D.kError)return;this._status=D.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)}_onXhrError(d){this._status=D.kError;let f=0,p=null;if(this._contentLength&&d.loaded<this._contentLength?(f=H.EARLY_EOF,p={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(f=H.EXCEPTION,p={code:-1,msg:d.constructor.name+" "+d.type}),this._onError)this._onError(f,p);else throw new re(p.msg)}}var le=X;class me extends null{static isSupported(){try{if(typeof self.MSStream=="undefined"||typeof self.MSStreamReader=="undefined")return!1;let d=new XMLHttpRequest;return d.open("GET","https://example.com",!0),d.responseType="ms-stream",d.responseType==="ms-stream"}catch(d){return Log.w("MSStreamLoader",d.message),!1}}constructor(d,f){super("xhr-msstream-loader"),this.TAG="MSStreamLoader",this._seekHandler=d,this._config=f,this._needStash=!0,this._xhr=null,this._reader=null,this._totalRange=null,this._currentRange=null,this._currentRequestURL=null,this._currentRedirectedURL=null,this._contentLength=null,this._receivedLength=0,this._bufferLimit=16*1024*1024,this._lastTimeBufferSize=0,this._isReconnecting=!1}destroy(){this.isWorking()&&this.abort(),this._reader&&(this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr=null),super.destroy()}open(d,f){this._internalOpen(d,f,!1)}_internalOpen(d,f,p){this._dataSource=d,p?this._currentRange=f:this._totalRange=f;let E=d.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?E=this._currentRedirectedURL:d.redirectedURL!=null&&(E=d.redirectedURL));let T=this._seekHandler.getConfig(E,f);this._currentRequestURL=T.url;let O=this._reader=new self.MSStreamReader;O.onprogress=this._msrOnProgress.bind(this),O.onload=this._msrOnLoad.bind(this),O.onerror=this._msrOnError.bind(this);let U=this._xhr=new XMLHttpRequest;if(U.open("GET",T.url,!0),U.responseType="ms-stream",U.onreadystatechange=this._xhrOnReadyStateChange.bind(this),U.onerror=this._xhrOnError.bind(this),d.withCredentials&&(U.withCredentials=!0),typeof T.headers=="object"){let Ze=T.headers;for(let $e in Ze)Ze.hasOwnProperty($e)&&U.setRequestHeader($e,Ze[$e])}if(typeof this._config.headers=="object"){let Ze=this._config.headers;for(let $e in Ze)Ze.hasOwnProperty($e)&&U.setRequestHeader($e,Ze[$e])}this._isReconnecting?this._isReconnecting=!1:this._status=LoaderStatus.kConnecting,U.send()}abort(){this._internalAbort(),this._status=LoaderStatus.kComplete}_internalAbort(){this._reader&&(this._reader.readyState===1&&this._reader.abort(),this._reader.onprogress=null,this._reader.onload=null,this._reader.onerror=null,this._reader=null),this._xhr&&(this._xhr.abort(),this._xhr.onreadystatechange=null,this._xhr=null)}_xhrOnReadyStateChange(d){let f=d.target;if(f.readyState===2)if(f.status>=200&&f.status<=299){if(this._status=LoaderStatus.kBuffering,f.responseURL!=null){let E=this._seekHandler.removeURLParameters(f.responseURL);f.responseURL!==this._currentRequestURL&&E!==this._currentRedirectedURL&&(this._currentRedirectedURL=E,this._onURLRedirect&&this._onURLRedirect(E))}let p=f.getResponseHeader("Content-Length");if(p!=null&&this._contentLength==null){let E=parseInt(p);E>0&&(this._contentLength=E,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength))}}else if(this._status=LoaderStatus.kError,this._onError)this._onError(LoaderErrors.HTTP_STATUS_CODE_INVALID,{code:f.status,msg:f.statusText});else throw new RuntimeException("MSStreamLoader: Http code invalid, "+f.status+" "+f.statusText);else if(f.readyState===3&&f.status>=200&&f.status<=299){this._status=LoaderStatus.kBuffering;let p=f.response;this._reader.readAsArrayBuffer(p)}}_xhrOnError(d){this._status=LoaderStatus.kError;let f=LoaderErrors.EXCEPTION,p={code:-1,msg:d.constructor.name+" "+d.type};if(this._onError)this._onError(f,p);else throw new RuntimeException(p.msg)}_msrOnProgress(d){let p=d.target.result;if(p==null){this._doReconnectIfNeeded();return}let E=p.slice(this._lastTimeBufferSize);this._lastTimeBufferSize=p.byteLength;let T=this._totalRange.from+this._receivedLength;this._receivedLength+=E.byteLength,this._onDataArrival&&this._onDataArrival(E,T,this._receivedLength),p.byteLength>=this._bufferLimit&&(Log.v(this.TAG,`MSStream buffer exceeded max size near ${T+E.byteLength}, reconnecting...`),this._doReconnectIfNeeded())}_doReconnectIfNeeded(){if(this._contentLength==null||this._receivedLength<this._contentLength){this._isReconnecting=!0,this._lastTimeBufferSize=0,this._internalAbort();let d={from:this._totalRange.from+this._receivedLength,to:-1};this._internalOpen(this._dataSource,d,!0)}}_msrOnLoad(d){this._status=LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._totalRange.from,this._totalRange.from+this._receivedLength-1)}_msrOnError(d){this._status=LoaderStatus.kError;let f=0,p=null;if(this._contentLength&&this._receivedLength<this._contentLength?(f=LoaderErrors.EARLY_EOF,p={code:-1,msg:"MSStream meet Early-Eof"}):(f=LoaderErrors.EARLY_EOF,p={code:-1,msg:d.constructor.name+" "+d.type}),this._onError)this._onError(f,p);else throw new RuntimeException(p.msg)}}var Xe=null;class se extends st{static isSupported(){try{let d=new XMLHttpRequest;return d.open("GET","https://example.com",!0),d.responseType="arraybuffer",d.responseType==="arraybuffer"}catch(d){return g.w("RangeLoader",d.message),!1}}constructor(d,f){super("xhr-range-loader"),this.TAG="RangeLoader",this._seekHandler=d,this._config=f,this._needStash=!1,this._chunkSizeKBList=[128,256,384,512,768,1024,1536,2048,3072,4096,5120,6144,7168,8192],this._currentChunkSizeKB=384,this._currentSpeedNormalized=0,this._zeroSpeedChunkCount=0,this._xhr=null,this._speedSampler=new G,this._requestAbort=!1,this._waitForTotalLength=!1,this._totalLengthReceived=!1,this._currentRequestURL=null,this._currentRedirectedURL=null,this._currentRequestRange=null,this._totalLength=null,this._contentLength=null,this._receivedLength=0,this._lastTimeLoaded=0}destroy(){this.isWorking()&&this.abort(),this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr=null),super.destroy()}get currentSpeed(){return this._speedSampler.lastSecondKBps}open(d,f){this._dataSource=d,this._range=f,this._status=D.kConnecting;let p=!1;this._dataSource.filesize!=null&&this._dataSource.filesize!==0&&(p=!0,this._totalLength=this._dataSource.filesize),!this._totalLengthReceived&&!p?(this._waitForTotalLength=!0,this._internalOpen(this._dataSource,{from:0,to:-1})):this._openSubRange()}_openSubRange(){let d=this._currentChunkSizeKB*1024,f=this._range.from+this._receivedLength,p=f+d;this._contentLength!=null&&p-this._range.from>=this._contentLength&&(p=this._range.from+this._contentLength-1),this._currentRequestRange={from:f,to:p},this._internalOpen(this._dataSource,this._currentRequestRange)}_internalOpen(d,f){this._lastTimeLoaded=0;let p=d.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?p=this._currentRedirectedURL:d.redirectedURL!=null&&(p=d.redirectedURL));let E=this._seekHandler.getConfig(p,f);this._currentRequestURL=E.url;let T=this._xhr=new XMLHttpRequest;if(T.open("GET",E.url,!0),T.responseType="arraybuffer",T.onreadystatechange=this._onReadyStateChange.bind(this),T.onprogress=this._onProgress.bind(this),T.onload=this._onLoad.bind(this),T.onerror=this._onXhrError.bind(this),d.withCredentials&&(T.withCredentials=!0),typeof E.headers=="object"){let O=E.headers;for(let U in O)O.hasOwnProperty(U)&&T.setRequestHeader(U,O[U])}if(typeof this._config.headers=="object"){let O=this._config.headers;for(let U in O)O.hasOwnProperty(U)&&T.setRequestHeader(U,O[U])}T.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=D.kComplete}_internalAbort(){this._xhr&&(this._xhr.onreadystatechange=null,this._xhr.onprogress=null,this._xhr.onload=null,this._xhr.onerror=null,this._xhr.abort(),this._xhr=null)}_onReadyStateChange(d){let f=d.target;if(f.readyState===2){if(f.responseURL!=null){let p=this._seekHandler.removeURLParameters(f.responseURL);f.responseURL!==this._currentRequestURL&&p!==this._currentRedirectedURL&&(this._currentRedirectedURL=p,this._onURLRedirect&&this._onURLRedirect(p))}if(f.status>=200&&f.status<=299){if(this._waitForTotalLength)return;this._status=D.kBuffering}else if(this._status=D.kError,this._onError)this._onError(H.HTTP_STATUS_CODE_INVALID,{code:f.status,msg:f.statusText});else throw new re("RangeLoader: Http code invalid, "+f.status+" "+f.statusText)}}_onProgress(d){if(this._status===D.kError)return;if(this._contentLength===null){let p=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,p=!0;let E=d.total;this._internalAbort(),E!=null&E!==0&&(this._totalLength=E)}if(this._range.to===-1?this._contentLength=this._totalLength-this._range.from:this._contentLength=this._range.to-this._range.from+1,p){this._openSubRange();return}this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)}let f=d.loaded-this._lastTimeLoaded;this._lastTimeLoaded=d.loaded,this._speedSampler.addBytes(f)}_normalizeSpeed(d){let f=this._chunkSizeKBList,p=f.length-1,E=0,T=0,O=p;if(d<f[0])return f[0];for(;T<=O;){if(E=T+Math.floor((O-T)/2),E===p||d>=f[E]&&d<f[E+1])return f[E];f[E]<d?T=E+1:O=E-1}}_onLoad(d){if(this._status===D.kError)return;if(this._waitForTotalLength){this._waitForTotalLength=!1;return}this._lastTimeLoaded=0;let f=this._speedSampler.lastSecondKBps;if(f===0&&(this._zeroSpeedChunkCount++,this._zeroSpeedChunkCount>=3&&(f=this._speedSampler.currentKBps)),f!==0){let O=this._normalizeSpeed(f);this._currentSpeedNormalized!==O&&(this._currentSpeedNormalized=O,this._currentChunkSizeKB=O)}let p=d.target.response,E=this._range.from+this._receivedLength;this._receivedLength+=p.byteLength;let T=!1;this._contentLength!=null&&this._receivedLength<this._contentLength?this._openSubRange():T=!0,this._onDataArrival&&this._onDataArrival(p,E,this._receivedLength),T&&(this._status=D.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}_onXhrError(d){this._status=D.kError;let f=0,p=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(f=H.EARLY_EOF,p={code:-1,msg:"RangeLoader meet Early-Eof"}):(f=H.EXCEPTION,p={code:-1,msg:d.constructor.name+" "+d.type}),this._onError)this._onError(f,p);else throw new re(p.msg)}}var vt=se;class yt extends st{static isSupported(){try{return typeof self.WebSocket!="undefined"}catch(d){return!1}}constructor(){super("websocket-loader"),this.TAG="WebSocketLoader",this._needStash=!0,this._ws=null,this._requestAbort=!1,this._receivedLength=0}destroy(){this._ws&&this.abort(),super.destroy()}open(d){try{let f=this._ws=new self.WebSocket(d.url);f.binaryType="arraybuffer",f.onopen=this._onWebSocketOpen.bind(this),f.onclose=this._onWebSocketClose.bind(this),f.onmessage=this._onWebSocketMessage.bind(this),f.onerror=this._onWebSocketError.bind(this),this._status=D.kConnecting}catch(f){this._status=D.kError;let p={code:f.code,msg:f.message};if(this._onError)this._onError(H.EXCEPTION,p);else throw new re(p.msg)}}abort(){let d=this._ws;d&&(d.readyState===0||d.readyState===1)&&(this._requestAbort=!0,d.close()),this._ws=null,this._status=D.kComplete}_onWebSocketOpen(d){this._status=D.kBuffering}_onWebSocketClose(d){if(this._requestAbort===!0){this._requestAbort=!1;return}this._status=D.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)}_onWebSocketMessage(d){if(d.data instanceof ArrayBuffer)this._dispatchArrayBuffer(d.data);else if(d.data instanceof Blob){let f=new FileReader;f.onload=()=>{this._dispatchArrayBuffer(f.result)},f.readAsArrayBuffer(d.data)}else{this._status=D.kError;let f={code:-1,msg:"Unsupported WebSocket message type: "+d.data.constructor.name};if(this._onError)this._onError(H.EXCEPTION,f);else throw new re(f.msg)}}_dispatchArrayBuffer(d){let f=d,p=this._receivedLength;this._receivedLength+=f.byteLength,this._onDataArrival&&this._onDataArrival(f,p,this._receivedLength)}_onWebSocketError(d){this._status=D.kError;let f={code:d.code,msg:d.message};if(this._onError)this._onError(H.EXCEPTION,f);else throw new re(f.msg)}}var Je=yt;class nt{constructor(d){this._zeroStart=d||!1}getConfig(d,f){let p={};if(f.from!==0||f.to!==-1){let E;f.to!==-1?E=`bytes=${f.from.toString()}-${f.to.toString()}`:E=`bytes=${f.from.toString()}-`,p.Range=E}else this._zeroStart&&(p.Range="bytes=0-");return{url:d,headers:p}}removeURLParameters(d){return d}}var ne=nt;class ee{constructor(d,f){this._startName=d,this._endName=f}getConfig(d,f){let p=d;if(f.from!==0||f.to!==-1){let E=!0;p.indexOf("?")===-1&&(p+="?",E=!1),E&&(p+="&"),p+=`${this._startName}=${f.from.toString()}`,f.to!==-1&&(p+=`&${this._endName}=${f.to.toString()}`)}return{url:p,headers:{}}}removeURLParameters(d){let f=d.split("?")[0],p,E=d.indexOf("?");E!==-1&&(p=d.substring(E+1));let T="";if(p!=null&&p.length>0){let O=p.split("&");for(let U=0;U<O.length;U++){let Ze=O[U].split("="),$e=U>0;Ze[0]!==this._startName&&Ze[0]!==this._endName&&($e&&(T+="&"),T+=O[U])}}return T.length===0?f:f+"?"+T}}var ce=ee;class K{constructor(d,f,p){this.TAG="IOController",this._config=f,this._extraData=p,this._stashInitialSize=1024*384,f.stashInitialSize!=null&&f.stashInitialSize>0&&(this._stashInitialSize=f.stashInitialSize),this._stashUsed=0,this._stashSize=this._stashInitialSize,this._bufferSize=1024*1024*3,this._stashBuffer=new ArrayBuffer(this._bufferSize),this._stashByteStart=0,this._enableStash=!0,f.enableStashBuffer===!1&&(this._enableStash=!1),this._loader=null,this._loaderClass=null,this._seekHandler=null,this._dataSource=d,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(d.url),this._refTotalLength=d.filesize?d.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new G,this._speedNormalizeList=[64,128,256,384,512,768,1024,1536,2048,3072,4096],this._isEarlyEofReconnecting=!1,this._paused=!1,this._resumeFrom=0,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._selectSeekHandler(),this._selectLoader(),this._createLoader()}destroy(){this._loader.isWorking()&&this._loader.abort(),this._loader.destroy(),this._loader=null,this._loaderClass=null,this._dataSource=null,this._stashBuffer=null,this._stashUsed=this._stashSize=this._bufferSize=this._stashByteStart=0,this._currentRange=null,this._speedSampler=null,this._isEarlyEofReconnecting=!1,this._onDataArrival=null,this._onSeeked=null,this._onError=null,this._onComplete=null,this._onRedirect=null,this._onRecoveredEarlyEof=null,this._extraData=null}isWorking(){return this._loader&&this._loader.isWorking()&&!this._paused}isPaused(){return this._paused}get status(){return this._loader.status}get extraData(){return this._extraData}set extraData(d){this._extraData=d}get onDataArrival(){return this._onDataArrival}set onDataArrival(d){this._onDataArrival=d}get onSeeked(){return this._onSeeked}set onSeeked(d){this._onSeeked=d}get onError(){return this._onError}set onError(d){this._onError=d}get onComplete(){return this._onComplete}set onComplete(d){this._onComplete=d}get onRedirect(){return this._onRedirect}set onRedirect(d){this._onRedirect=d}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(d){this._onRecoveredEarlyEof=d}get currentURL(){return this._dataSource.url}get hasRedirect(){return this._redirectedURL!=null||this._dataSource.redirectedURL!=null}get currentRedirectedURL(){return this._redirectedURL||this._dataSource.redirectedURL}get currentSpeed(){return this._loaderClass===vt?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let d=this._config;if(d.seekType==="range")this._seekHandler=new ne(this._config.rangeLoadZeroStart);else if(d.seekType==="param"){let f=d.seekParamStart||"bstart",p=d.seekParamEnd||"bend";this._seekHandler=new ce(f,p)}else if(d.seekType==="custom"){if(typeof d.customSeekHandler!="function")throw new we("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new d.customSeekHandler}else throw new we(`Invalid seekType in config: ${d.seekType}`)}_selectLoader(){if(this._config.customLoader!=null)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=Je;else if(k.isSupported())this._loaderClass=k;else if(le.isSupported())this._loaderClass=le;else if(vt.isSupported())this._loaderClass=vt;else throw new re("Your browser doesn't support xhr with arraybuffer responseType!")}_createLoader(){this._loader=new this._loaderClass(this._seekHandler,this._config),this._loader.needStashBuffer===!1&&(this._enableStash=!1),this._loader.onContentLengthKnown=this._onContentLengthKnown.bind(this),this._loader.onURLRedirect=this._onURLRedirect.bind(this),this._loader.onDataArrival=this._onLoaderChunkArrival.bind(this),this._loader.onComplete=this._onLoaderComplete.bind(this),this._loader.onError=this._onLoaderError.bind(this)}open(d){this._currentRange={from:0,to:-1},d&&(this._currentRange.from=d),this._speedSampler.reset(),d||(this._fullRequestFlag=!0),this._loader.open(this._dataSource,Object.assign({},this._currentRange))}abort(){this._loader.abort(),this._paused&&(this._paused=!1,this._resumeFrom=0)}pause(){this.isWorking()&&(this._loader.abort(),this._stashUsed!==0?(this._resumeFrom=this._stashByteStart,this._currentRange.to=this._stashByteStart-1):this._resumeFrom=this._currentRange.to+1,this._stashUsed=0,this._stashByteStart=0,this._paused=!0)}resume(){if(this._paused){this._paused=!1;let d=this._resumeFrom;this._resumeFrom=0,this._internalSeek(d,!0)}}seek(d){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(d,!0)}_internalSeek(d,f){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(f),this._loader.destroy(),this._loader=null;let p={from:d,to:-1};this._currentRange={from:p.from,to:-1},this._speedSampler.reset(),this._stashSize=this._stashInitialSize,this._createLoader(),this._loader.open(this._dataSource,p),this._onSeeked&&this._onSeeked()}updateUrl(d){if(!d||typeof d!="string"||d.length===0)throw new we("Url must be a non-empty string!");this._dataSource.url=d}_expandBuffer(d){let f=this._stashSize;for(;f+1024*1024*1<d;)f*=2;if(f+=1024*1024*1,f===this._bufferSize)return;let p=new ArrayBuffer(f);if(this._stashUsed>0){let E=new Uint8Array(this._stashBuffer,0,this._stashUsed);new Uint8Array(p,0,f).set(E,0)}this._stashBuffer=p,this._bufferSize=f}_normalizeSpeed(d){let f=this._speedNormalizeList,p=f.length-1,E=0,T=0,O=p;if(d<f[0])return f[0];for(;T<=O;){if(E=T+Math.floor((O-T)/2),E===p||d>=f[E]&&d<f[E+1])return f[E];f[E]<d?T=E+1:O=E-1}}_adjustStashSize(d){let f=0;this._config.isLive||d<512?f=d:d>=512&&d<=1024?f=Math.floor(d*1.5):f=d*2,f>8192&&(f=8192);let p=f*1024+1024*1024*1;this._bufferSize<p&&this._expandBuffer(p),this._stashSize=f*1024}_dispatchChunks(d,f){return this._currentRange.to=f+d.byteLength-1,this._onDataArrival(d,f)}_onURLRedirect(d){this._redirectedURL=d,this._onRedirect&&this._onRedirect(d)}_onContentLengthKnown(d){d&&this._fullRequestFlag&&(this._totalLength=d,this._fullRequestFlag=!1)}_onLoaderChunkArrival(d,f,p){if(!this._onDataArrival)throw new de("IOController: No existing consumer (onDataArrival) callback!");if(this._paused)return;this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(d.byteLength);let E=this._speedSampler.lastSecondKBps;if(E!==0){let T=this._normalizeSpeed(E);this._speedNormalized!==T&&(this._speedNormalized=T,this._adjustStashSize(T))}if(this._enableStash)if(this._stashUsed===0&&this._stashByteStart===0&&(this._stashByteStart=f),this._stashUsed+d.byteLength<=this._stashSize)new Uint8Array(this._stashBuffer,0,this._stashSize).set(new Uint8Array(d),this._stashUsed),this._stashUsed+=d.byteLength;else{let T=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){let O=this._stashBuffer.slice(0,this._stashUsed),U=this._dispatchChunks(O,this._stashByteStart);if(U<O.byteLength){if(U>0){let Ze=new Uint8Array(O,U);T.set(Ze,0),this._stashUsed=Ze.byteLength,this._stashByteStart+=U}}else this._stashUsed=0,this._stashByteStart+=U;this._stashUsed+d.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+d.byteLength),T=new Uint8Array(this._stashBuffer,0,this._bufferSize)),T.set(new Uint8Array(d),this._stashUsed),this._stashUsed+=d.byteLength}else{let O=this._dispatchChunks(d,f);if(O<d.byteLength){let U=d.byteLength-O;U>this._bufferSize&&(this._expandBuffer(U),T=new Uint8Array(this._stashBuffer,0,this._bufferSize)),T.set(new Uint8Array(d,O),0),this._stashUsed+=U,this._stashByteStart=f+O}}}else if(this._stashUsed===0){let T=this._dispatchChunks(d,f);if(T<d.byteLength){let O=d.byteLength-T;O>this._bufferSize&&this._expandBuffer(O),new Uint8Array(this._stashBuffer,0,this._bufferSize).set(new Uint8Array(d,T),0),this._stashUsed+=O,this._stashByteStart=f+T}}else{this._stashUsed+d.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+d.byteLength);let T=new Uint8Array(this._stashBuffer,0,this._bufferSize);T.set(new Uint8Array(d),this._stashUsed),this._stashUsed+=d.byteLength;let O=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(O<this._stashUsed&&O>0){let U=new Uint8Array(this._stashBuffer,O);T.set(U,0)}this._stashUsed-=O,this._stashByteStart+=O}}_flushStashBuffer(d){if(this._stashUsed>0){let f=this._stashBuffer.slice(0,this._stashUsed),p=this._dispatchChunks(f,this._stashByteStart),E=f.byteLength-p;if(p<f.byteLength)if(d)g.w(this.TAG,`${E} bytes unconsumed data remain when flush buffer, dropped`);else{if(p>0){let T=new Uint8Array(this._stashBuffer,0,this._bufferSize),O=new Uint8Array(f,p);T.set(O,0),this._stashUsed=O.byteLength,this._stashByteStart+=p}return 0}return this._stashUsed=0,this._stashByteStart=0,E}return 0}_onLoaderComplete(d,f){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(d,f){switch(g.e(this.TAG,`Loader error, code = ${f.code}, msg = ${f.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,d=H.UNRECOVERABLE_EARLY_EOF),d){case H.EARLY_EOF:{if(!this._config.isLive&&this._totalLength){let p=this._currentRange.to+1;p<this._totalLength&&(g.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(p,!1));return}d=H.UNRECOVERABLE_EARLY_EOF;break}case H.UNRECOVERABLE_EARLY_EOF:case H.CONNECTING_TIMEOUT:case H.HTTP_STATUS_CODE_INVALID:case H.EXCEPTION:break}if(this._onError)this._onError(d,f);else throw new re("IOException: "+f.msg)}}var Se=K;const ze={enableWorker:!1,enableStashBuffer:!0,stashInitialSize:void 0,isLive:!1,lazyLoad:!0,lazyLoadMaxDuration:3*60,lazyLoadRecoverDuration:30,deferLoadAfterSourceOpen:!0,autoCleanupMaxBackwardDuration:3*60,autoCleanupMinBackwardDuration:2*60,statisticsInfoReportInterval:600,fixAudioTimestampGap:!0,accurateSeek:!1,seekType:"range",seekParamStart:"bstart",seekParamEnd:"bend",rangeLoadZeroStart:!1,customSeekHandler:void 0,reuseRedirectedURL:!1,headers:void 0,customLoader:void 0};function ve(){return Object.assign({},ze)}class Pe{static supportMSEH264Playback(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}static supportNetworkStreamIO(){let d=new Se({},ve()),f=d.loaderType;return d.destroy(),f=="fetch-stream-loader"||f=="xhr-moz-chunked-loader"}static getNetworkLoaderTypeName(){let d=new Se({},ve()),f=d.loaderType;return d.destroy(),f}static supportNativeMediaPlayback(d){Pe.videoElement==null&&(Pe.videoElement=window.document.createElement("video"));let f=Pe.videoElement.canPlayType(d);return f==="probably"||f=="maybe"}static getFeatureList(){let d={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return d.mseFlvPlayback=Pe.supportMSEH264Playback(),d.networkStreamIO=Pe.supportNetworkStreamIO(),d.networkLoaderName=Pe.getNetworkLoaderTypeName(),d.mseLiveFlvPlayback=d.mseFlvPlayback&&d.networkStreamIO,d.nativeMP4H264Playback=Pe.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),d.nativeWebmVP8Playback=Pe.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),d.nativeWebmVP9Playback=Pe.supportNativeMediaPlayback('video/webm; codecs="vp9"'),d}}var ke=Pe,_e={ERROR:"error",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info"};class Ye{static get forceGlobalTag(){return g.FORCE_GLOBAL_TAG}static set forceGlobalTag(d){g.FORCE_GLOBAL_TAG=d,Ye._notifyChange()}static get globalTag(){return g.GLOBAL_TAG}static set globalTag(d){g.GLOBAL_TAG=d,Ye._notifyChange()}static get enableAll(){return g.ENABLE_VERBOSE&&g.ENABLE_DEBUG&&g.ENABLE_INFO&&g.ENABLE_WARN&&g.ENABLE_ERROR}static set enableAll(d){g.ENABLE_VERBOSE=d,g.ENABLE_DEBUG=d,g.ENABLE_INFO=d,g.ENABLE_WARN=d,g.ENABLE_ERROR=d,Ye._notifyChange()}static get enableDebug(){return g.ENABLE_DEBUG}static set enableDebug(d){g.ENABLE_DEBUG=d,Ye._notifyChange()}static get enableVerbose(){return g.ENABLE_VERBOSE}static set enableVerbose(d){g.ENABLE_VERBOSE=d,Ye._notifyChange()}static get enableInfo(){return g.ENABLE_INFO}static set enableInfo(d){g.ENABLE_INFO=d,Ye._notifyChange()}static get enableWarn(){return g.ENABLE_WARN}static set enableWarn(d){g.ENABLE_WARN=d,Ye._notifyChange()}static get enableError(){return g.ENABLE_ERROR}static set enableError(d){g.ENABLE_ERROR=d,Ye._notifyChange()}static getConfig(){return{globalTag:g.GLOBAL_TAG,forceGlobalTag:g.FORCE_GLOBAL_TAG,enableVerbose:g.ENABLE_VERBOSE,enableDebug:g.ENABLE_DEBUG,enableInfo:g.ENABLE_INFO,enableWarn:g.ENABLE_WARN,enableError:g.ENABLE_ERROR,enableCallback:g.ENABLE_CALLBACK}}static applyConfig(d){g.GLOBAL_TAG=d.globalTag,g.FORCE_GLOBAL_TAG=d.forceGlobalTag,g.ENABLE_VERBOSE=d.enableVerbose,g.ENABLE_DEBUG=d.enableDebug,g.ENABLE_INFO=d.enableInfo,g.ENABLE_WARN=d.enableWarn,g.ENABLE_ERROR=d.enableError,g.ENABLE_CALLBACK=d.enableCallback}static _notifyChange(){let d=Ye.emitter;if(d.listenerCount("change")>0){let f=Ye.getConfig();d.emit("change",f)}}static registerListener(d){Ye.emitter.addListener("change",d)}static removeListener(d){Ye.emitter.removeListener("change",d)}static addLogListener(d){g.emitter.addListener("log",d),g.emitter.listenerCount("log")>0&&(g.ENABLE_CALLBACK=!0,Ye._notifyChange())}static removeLogListener(d){g.emitter.removeListener("log",d),g.emitter.listenerCount("log")===0&&(g.ENABLE_CALLBACK=!1,Ye._notifyChange())}}Ye.emitter=new(Y());var ye=Ye;class Ve{constructor(){this.mimeType=null,this.duration=null,this.hasAudio=null,this.hasVideo=null,this.audioCodec=null,this.videoCodec=null,this.audioDataRate=null,this.videoDataRate=null,this.audioSampleRate=null,this.audioChannelCount=null,this.width=null,this.height=null,this.fps=null,this.profile=null,this.level=null,this.refFrames=null,this.chromaFormat=null,this.sarNum=null,this.sarDen=null,this.metadata=null,this.segments=null,this.segmentCount=null,this.hasKeyframesIndex=null,this.keyframesIndex=null}isComplete(){let d=this.hasAudio===!1||this.hasAudio===!0&&this.audioCodec!=null&&this.audioSampleRate!=null&&this.audioChannelCount!=null,f=this.hasVideo===!1||this.hasVideo===!0&&this.videoCodec!=null&&this.width!=null&&this.height!=null&&this.fps!=null&&this.profile!=null&&this.level!=null&&this.refFrames!=null&&this.chromaFormat!=null&&this.sarNum!=null&&this.sarDen!=null;return this.mimeType!=null&&this.duration!=null&&this.metadata!=null&&this.hasKeyframesIndex!=null&&d&&f}isSeekable(){return this.hasKeyframesIndex===!0}getNearestKeyframe(d){if(this.keyframesIndex==null)return null;let f=this.keyframesIndex,p=this._search(f.times,d);return{index:p,milliseconds:f.times[p],fileposition:f.filepositions[p]}}_search(d,f){let p=0,E=d.length-1,T=0,O=0,U=E;for(f<d[0]&&(p=0,O=U+1);O<=U;)if(T=O+Math.floor((U-O)/2),T===E||f>=d[T]&&f<d[T+1]){p=T;break}else d[T]<f?O=T+1:U=T-1;return p}}var We=Ve;function Mt(Fe,d,f){let p=Fe;if(d+f<p.length){for(;f--;)if((p[++d]&192)!==128)return!1;return!0}else return!1}function jt(Fe){let d=[],f=Fe,p=0,E=Fe.length;for(;p<E;){if(f[p]<128){d.push(String.fromCharCode(f[p])),++p;continue}else if(!(f[p]<192)){if(f[p]<224){if(Mt(f,p,1)){let T=(f[p]&31)<<6|f[p+1]&63;if(T>=128){d.push(String.fromCharCode(T&65535)),p+=2;continue}}}else if(f[p]<240){if(Mt(f,p,2)){let T=(f[p]&15)<<12|(f[p+1]&63)<<6|f[p+2]&63;if(T>=2048&&(T&63488)!==55296){d.push(String.fromCharCode(T&65535)),p+=3;continue}}}else if(f[p]<248&&Mt(f,p,3)){let T=(f[p]&7)<<18|(f[p+1]&63)<<12|(f[p+2]&63)<<6|f[p+3]&63;if(T>65536&&T<1114112){T-=65536,d.push(String.fromCharCode(T>>>10|55296)),d.push(String.fromCharCode(T&1023|56320)),p+=4;continue}}}d.push("\uFFFD"),++p}return d.join("")}var _t=jt;let Le=function(){let Fe=new ArrayBuffer(2);return new DataView(Fe).setInt16(0,256,!0),new Int16Array(Fe)[0]===256}();class It{static parseScriptData(d,f,p){let E={};try{let T=It.parseValue(d,f,p),O=It.parseValue(d,f+T.size,p-T.size);E[T.data]=O.data}catch(T){g.e("AMF",T.toString())}return E}static parseObject(d,f,p){if(p<3)throw new de("Data not enough when parse ScriptDataObject");let E=It.parseString(d,f,p),T=It.parseValue(d,f+E.size,p-E.size),O=T.objectEnd;return{data:{name:E.data,value:T.data},size:E.size+T.size,objectEnd:O}}static parseVariable(d,f,p){return It.parseObject(d,f,p)}static parseString(d,f,p){if(p<2)throw new de("Data not enough when parse String");let T=new DataView(d,f,p).getUint16(0,!Le),O;return T>0?O=_t(new Uint8Array(d,f+2,T)):O="",{data:O,size:2+T}}static parseLongString(d,f,p){if(p<4)throw new de("Data not enough when parse LongString");let T=new DataView(d,f,p).getUint32(0,!Le),O;return T>0?O=_t(new Uint8Array(d,f+4,T)):O="",{data:O,size:4+T}}static parseDate(d,f,p){if(p<10)throw new de("Data size invalid when parse Date");let E=new DataView(d,f,p),T=E.getFloat64(0,!Le),O=E.getInt16(8,!Le);return T+=O*60*1e3,{data:new Date(T),size:10}}static parseValue(d,f,p){if(p<1)throw new de("Data not enough when parse Value");let E=new DataView(d,f,p),T=1,O=E.getUint8(0),U,Ze=!1;try{switch(O){case 0:U=E.getFloat64(1,!Le),T+=8;break;case 1:{U=!!E.getUint8(1),T+=1;break}case 2:{let $e=It.parseString(d,f+1,p-1);U=$e.data,T+=$e.size;break}case 3:{U={};let $e=0;for((E.getUint32(p-4,!Le)&16777215)===9&&($e=3);T<p-4;){let ct=It.parseObject(d,f+T,p-T-$e);if(ct.objectEnd)break;U[ct.data.name]=ct.data.value,T+=ct.size}T<=p-3&&(E.getUint32(T-1,!Le)&16777215)===9&&(T+=3);break}case 8:{U={},T+=4;let $e=0;for((E.getUint32(p-4,!Le)&16777215)===9&&($e=3);T<p-8;){let ct=It.parseVariable(d,f+T,p-T-$e);if(ct.objectEnd)break;U[ct.data.name]=ct.data.value,T+=ct.size}T<=p-3&&(E.getUint32(T-1,!Le)&16777215)===9&&(T+=3);break}case 9:U=void 0,T=1,Ze=!0;break;case 10:{U=[];let $e=E.getUint32(1,!Le);T+=4;for(let ct=0;ct<$e;ct++){let Gt=It.parseValue(d,f+T,p-T);U.push(Gt.data),T+=Gt.size}break}case 11:{let $e=It.parseDate(d,f+1,p-1);U=$e.data,T+=$e.size;break}case 12:{let $e=It.parseString(d,f+1,p-1);U=$e.data,T+=$e.size;break}default:T=p,g.w("AMF","Unsupported AMF value type "+O)}}catch($e){g.e("AMF",$e.toString())}return{data:U,size:T,objectEnd:Ze}}}var je=It;class Xt{constructor(d){this.TAG="ExpGolomb",this._buffer=d,this._buffer_index=0,this._total_bytes=d.byteLength,this._total_bits=d.byteLength*8,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let d=this._total_bytes-this._buffer_index;if(d<=0)throw new de("ExpGolomb: _fillCurrentWord() but no bytes available");let f=Math.min(4,d),p=new Uint8Array(4);p.set(this._buffer.subarray(this._buffer_index,this._buffer_index+f)),this._current_word=new DataView(p.buffer).getUint32(0,!1),this._buffer_index+=f,this._current_word_bits_left=f*8}readBits(d){if(d>32)throw new we("ExpGolomb: readBits() bits exceeded max 32bits!");if(d<=this._current_word_bits_left){let O=this._current_word>>>32-d;return this._current_word<<=d,this._current_word_bits_left-=d,O}let f=this._current_word_bits_left?this._current_word:0;f=f>>>32-this._current_word_bits_left;let p=d-this._current_word_bits_left;this._fillCurrentWord();let E=Math.min(p,this._current_word_bits_left),T=this._current_word>>>32-E;return this._current_word<<=E,this._current_word_bits_left-=E,f=f<<E|T,f}readBool(){return this.readBits(1)===1}readByte(){return this.readBits(8)}_skipLeadingZero(){let d;for(d=0;d<this._current_word_bits_left;d++)if(this._current_word&2147483648>>>d)return this._current_word<<=d,this._current_word_bits_left-=d,d;return this._fillCurrentWord(),d+this._skipLeadingZero()}readUEG(){let d=this._skipLeadingZero();return this.readBits(d+1)-1}readSEG(){let d=this.readUEG();return d&1?d+1>>>1:-1*(d>>>1)}}var oe=Xt;class Me{static _ebsp2rbsp(d){let f=d,p=f.byteLength,E=new Uint8Array(p),T=0;for(let O=0;O<p;O++)O>=2&&f[O]===3&&f[O-1]===0&&f[O-2]===0||(E[T]=f[O],T++);return new Uint8Array(E.buffer,0,T)}static parseSPS(d){let f=Me._ebsp2rbsp(d),p=new oe(f);p.readByte();let E=p.readByte();p.readByte();let T=p.readByte();p.readUEG();let O=Me.getProfileString(E),U=Me.getLevelString(T),Ze=1,$e=420,ct=[0,420,422,444],Gt=8;if((E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128||E===138||E===144)&&(Ze=p.readUEG(),Ze===3&&p.readBits(1),Ze<=3&&($e=ct[Ze]),Gt=p.readUEG()+8,p.readUEG(),p.readBits(1),p.readBool())){let xt=Ze!==3?8:12;for(let ei=0;ei<xt;ei++)p.readBool()&&(ei<6?Me._skipScalingList(p,16):Me._skipScalingList(p,64))}p.readUEG();let Pt=p.readUEG();if(Pt===0)p.readUEG();else if(Pt===1){p.readBits(1),p.readSEG(),p.readSEG();let xt=p.readUEG();for(let ei=0;ei<xt;ei++)p.readSEG()}let it=p.readUEG();p.readBits(1);let Bt=p.readUEG(),dt=p.readUEG(),He=p.readBits(1);He===0&&p.readBits(1),p.readBits(1);let Ne=0,Ct=0,mt=0,di=0;p.readBool()&&(Ne=p.readUEG(),Ct=p.readUEG(),mt=p.readUEG(),di=p.readUEG());let mi=1,Dt=1,ni=0,ki=!0,W=0,Q=0;if(p.readBool()){if(p.readBool()){let xt=p.readByte(),ei=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Nt=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];xt>0&&xt<16?(mi=ei[xt-1],Dt=Nt[xt-1]):xt===255&&(mi=p.readByte()<<8|p.readByte(),Dt=p.readByte()<<8|p.readByte())}if(p.readBool()&&p.readBool(),p.readBool()&&(p.readBits(4),p.readBool()&&p.readBits(24)),p.readBool()&&(p.readUEG(),p.readUEG()),p.readBool()){let xt=p.readBits(32),ei=p.readBits(32);ki=p.readBool(),W=ei,Q=xt*2,ni=W/Q}}let ge=1;(mi!==1||Dt!==1)&&(ge=mi/Dt);let ue=0,Te=0;if(Ze===0)ue=1,Te=2-He;else{let xt=Ze===3?1:2,ei=Ze===1?2:1;ue=xt,Te=ei*(2-He)}let Be=(Bt+1)*16,Qe=(2-He)*((dt+1)*16);Be-=(Ne+Ct)*ue,Qe-=(mt+di)*Te;let Kt=Math.ceil(Be*ge);return p.destroy(),p=null,{profile_string:O,level_string:U,bit_depth:Gt,ref_frames:it,chroma_format:$e,chroma_format_string:Me.getChromaFormatString($e),frame_rate:{fixed:ki,fps:ni,fps_den:Q,fps_num:W},sar_ratio:{width:mi,height:Dt},codec_size:{width:Be,height:Qe},present_size:{width:Kt,height:Qe}}}static _skipScalingList(d,f){let p=8,E=8,T=0;for(let O=0;O<f;O++)E!==0&&(T=d.readSEG(),E=(p+T+256)%256),p=E===0?p:E}static getProfileString(d){switch(d){case 66:return"Baseline";case 77:return"Main";case 88:return"Extended";case 100:return"High";case 110:return"High10";case 122:return"High422";case 244:return"High444";default:return"Unknown"}}static getLevelString(d){return(d/10).toFixed(1)}static getChromaFormatString(d){switch(d){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}var N=Me,z={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};function $(Fe){return Fe>>>8&255|(Fe&255)<<8}function M(Fe){return(Fe&4278190080)>>>24|(Fe&16711680)>>>8|(Fe&65280)<<8|(Fe&255)<<24}function w(Fe,d){return Fe[d]<<24|Fe[d+1]<<16|Fe[d+2]<<8|Fe[d+3]}class P{constructor(d,f){this.TAG="FLVDemuxer",this._config=f,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null,this._dataOffset=d.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=d.hasAudioTrack,this._hasVideo=d.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new We,this._mediaInfo.hasAudio=this._hasAudio,this._mediaInfo.hasVideo=this._hasVideo,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._naluLengthSize=4,this._timestampBase=0,this._timescale=1e3,this._duration=0,this._durationOverrided=!1,this._referenceFrameRate={fixed:!0,fps:23.976,fps_num:23976,fps_den:1e3},this._flvSoundRateTable=[5500,11025,22050,44100,48e3],this._mpegSamplingRates=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],this._mpegAudioV10SampleRateTable=[44100,48e3,32e3,0],this._mpegAudioV20SampleRateTable=[22050,24e3,16e3,0],this._mpegAudioV25SampleRateTable=[11025,12e3,8e3,0],this._mpegAudioL1BitRateTable=[0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1],this._mpegAudioL2BitRateTable=[0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1],this._mpegAudioL3BitRateTable=[0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1],this._videoTrack={type:"video",id:1,sequenceNumber:0,samples:[],length:0},this._audioTrack={type:"audio",id:2,sequenceNumber:0,samples:[],length:0},this._littleEndian=function(){let p=new ArrayBuffer(2);return new DataView(p).setInt16(0,256,!0),new Int16Array(p)[0]===256}()}destroy(){this._mediaInfo=null,this._metadata=null,this._audioMetadata=null,this._videoMetadata=null,this._videoTrack=null,this._audioTrack=null,this._onError=null,this._onMediaInfo=null,this._onMetaDataArrived=null,this._onScriptDataArrived=null,this._onTrackMetadata=null,this._onDataAvailable=null}static probe(d){let f=new Uint8Array(d),p={match:!1};if(f[0]!==70||f[1]!==76||f[2]!==86||f[3]!==1)return p;let E=(f[4]&4)>>>2!==0,T=(f[4]&1)!==0,O=w(f,5);return O<9?p:{match:!0,consumed:O,dataOffset:O,hasAudioTrack:E,hasVideoTrack:T}}bindDataSource(d){return d.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(d){this._onTrackMetadata=d}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(d){this._onMediaInfo=d}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(d){this._onMetaDataArrived=d}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(d){this._onScriptDataArrived=d}get onError(){return this._onError}set onError(d){this._onError=d}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(d){this._onDataAvailable=d}get timestampBase(){return this._timestampBase}set timestampBase(d){this._timestampBase=d}get overridedDuration(){return this._duration}set overridedDuration(d){this._durationOverrided=!0,this._duration=d,this._mediaInfo.duration=d}set overridedHasAudio(d){this._hasAudioFlagOverrided=!0,this._hasAudio=d,this._mediaInfo.hasAudio=d}set overridedHasVideo(d){this._hasVideoFlagOverrided=!0,this._hasVideo=d,this._mediaInfo.hasVideo=d}resetMediaInfo(){this._mediaInfo=new We}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!this._hasAudio&&this._hasVideo?this._videoInitialMetadataDispatched:!1}parseChunks(d,f){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new de("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let p=0,E=this._littleEndian;if(f===0)if(d.byteLength>13)p=P.probe(d).dataOffset;else return 0;for(this._firstParse&&(this._firstParse=!1,f+p!==this._dataOffset&&g.w(this.TAG,"First time parsing but chunk byteStart invalid!"),new DataView(d,p).getUint32(0,!E)!==0&&g.w(this.TAG,"PrevTagSize0 !== 0 !!!"),p+=4);p<d.byteLength;){this._dispatch=!0;let T=new DataView(d,p);if(p+11+4>d.byteLength)break;let O=T.getUint8(0),U=T.getUint32(0,!E)&16777215;if(p+11+U+4>d.byteLength)break;if(O!==8&&O!==9&&O!==18){g.w(this.TAG,`Unsupported tag type ${O}, skipped`),p+=11+U+4;continue}let Ze=T.getUint8(4),$e=T.getUint8(5),ct=T.getUint8(6),Gt=T.getUint8(7),Pt=ct|$e<<8|Ze<<16|Gt<<24;(T.getUint32(7,!E)&16777215)!==0&&g.w(this.TAG,"Meet tag which has StreamID != 0!");let Bt=p+11;switch(O){case 8:this._parseAudioData(d,Bt,U,Pt);break;case 9:this._parseVideoData(d,Bt,U,Pt,f+p);break;case 18:this._parseScriptData(d,Bt,U);break}let dt=T.getUint32(11+U,!E);dt!==11+U&&g.w(this.TAG,`Invalid PrevTagSize ${dt}`),p+=11+U+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),p}_parseScriptData(d,f,p){let E=je.parseScriptData(d,f,p);if(E.hasOwnProperty("onMetaData")){if(E.onMetaData==null||typeof E.onMetaData!="object"){g.w(this.TAG,"Invalid onMetaData structure!");return}this._metadata&&g.w(this.TAG,"Found another onMetaData tag!"),this._metadata=E;let T=this._metadata.onMetaData;if(this._onMetaDataArrived&&this._onMetaDataArrived(Object.assign({},T)),typeof T.hasAudio=="boolean"&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=T.hasAudio,this._mediaInfo.hasAudio=this._hasAudio),typeof T.hasVideo=="boolean"&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=T.hasVideo,this._mediaInfo.hasVideo=this._hasVideo),typeof T.audiodatarate=="number"&&(this._mediaInfo.audioDataRate=T.audiodatarate),typeof T.videodatarate=="number"&&(this._mediaInfo.videoDataRate=T.videodatarate),typeof T.width=="number"&&(this._mediaInfo.width=T.width),typeof T.height=="number"&&(this._mediaInfo.height=T.height),typeof T.duration=="number"){if(!this._durationOverrided){let O=Math.floor(T.duration*this._timescale);this._duration=O,this._mediaInfo.duration=O}}else this._mediaInfo.duration=0;if(typeof T.framerate=="number"){let O=Math.floor(T.framerate*1e3);if(O>0){let U=O/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=U,this._referenceFrameRate.fps_num=O,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=U}}if(typeof T.keyframes=="object"){this._mediaInfo.hasKeyframesIndex=!0;let O=T.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(O),T.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=T,g.v(this.TAG,"Parsed onMetaData"),this._mediaInfo.isComplete()&&this._onMediaInfo(this._mediaInfo)}Object.keys(E).length>0&&this._onScriptDataArrived&&this._onScriptDataArrived(Object.assign({},E))}_parseKeyframesIndex(d){let f=[],p=[];for(let E=1;E<d.times.length;E++){let T=this._timestampBase+Math.floor(d.times[E]*1e3);f.push(T),p.push(d.filepositions[E])}return{times:f,filepositions:p}}_parseAudioData(d,f,p,E){if(p<=1){g.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");return}if(this._hasAudioFlagOverrided===!0&&this._hasAudio===!1)return;let T=this._littleEndian,U=new DataView(d,f,p).getUint8(0),Ze=U>>>4;if(Ze!==2&&Ze!==10){this._onError(z.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+Ze);return}let $e=0,ct=(U&12)>>>2;if(ct>=0&&ct<=4)$e=this._flvSoundRateTable[ct];else{this._onError(z.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+ct);return}let Gt=(U&2)>>>1,Pt=U&1,it=this._audioMetadata,Bt=this._audioTrack;if(it||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),it=this._audioMetadata={},it.type="audio",it.id=Bt.id,it.timescale=this._timescale,it.duration=this._duration,it.audioSampleRate=$e,it.channelCount=Pt===0?1:2),Ze===10){let dt=this._parseAACAudioData(d,f+1,p-1);if(dt==null)return;if(dt.packetType===0){it.config&&g.w(this.TAG,"Found another AudioSpecificConfig!");let He=dt.data;it.audioSampleRate=He.samplingRate,it.channelCount=He.channelCount,it.codec=He.codec,it.originalCodec=He.originalCodec,it.config=He.config,it.refSampleDuration=1024/it.audioSampleRate*it.timescale,g.v(this.TAG,"Parsed AudioSpecificConfig"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._audioInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("audio",it);let Ne=this._mediaInfo;Ne.audioCodec=it.originalCodec,Ne.audioSampleRate=it.audioSampleRate,Ne.audioChannelCount=it.channelCount,Ne.hasVideo?Ne.videoCodec!=null&&(Ne.mimeType='video/x-flv; codecs="'+Ne.videoCodec+","+Ne.audioCodec+'"'):Ne.mimeType='video/x-flv; codecs="'+Ne.audioCodec+'"',Ne.isComplete()&&this._onMediaInfo(Ne)}else if(dt.packetType===1){let He=this._timestampBase+E,Ne={unit:dt.data,length:dt.data.byteLength,dts:He,pts:He};Bt.samples.push(Ne),Bt.length+=dt.data.length}else g.e(this.TAG,`Flv: Unsupported AAC data type ${dt.packetType}`)}else if(Ze===2){if(!it.codec){let Ct=this._parseMP3AudioData(d,f+1,p-1,!0);if(Ct==null)return;it.audioSampleRate=Ct.samplingRate,it.channelCount=Ct.channelCount,it.codec=Ct.codec,it.originalCodec=Ct.originalCodec,it.refSampleDuration=1152/it.audioSampleRate*it.timescale,g.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",it);let mt=this._mediaInfo;mt.audioCodec=it.codec,mt.audioSampleRate=it.audioSampleRate,mt.audioChannelCount=it.channelCount,mt.audioDataRate=Ct.bitRate,mt.hasVideo?mt.videoCodec!=null&&(mt.mimeType='video/x-flv; codecs="'+mt.videoCodec+","+mt.audioCodec+'"'):mt.mimeType='video/x-flv; codecs="'+mt.audioCodec+'"',mt.isComplete()&&this._onMediaInfo(mt)}let dt=this._parseMP3AudioData(d,f+1,p-1,!1);if(dt==null)return;let He=this._timestampBase+E,Ne={unit:dt,length:dt.byteLength,dts:He,pts:He};Bt.samples.push(Ne),Bt.length+=dt.length}}_parseAACAudioData(d,f,p){if(p<=1){g.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");return}let E={},T=new Uint8Array(d,f,p);return E.packetType=T[0],T[0]===0?E.data=this._parseAACAudioSpecificConfig(d,f+1,p-1):E.data=T.subarray(1),E}_parseAACAudioSpecificConfig(d,f,p){let E=new Uint8Array(d,f,p),T=null,O=0,U=0,Ze=null,$e=0,ct=null;if(O=U=E[0]>>>3,$e=(E[0]&7)<<1|E[1]>>>7,$e<0||$e>=this._mpegSamplingRates.length){this._onError(z.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");return}let Gt=this._mpegSamplingRates[$e],Pt=(E[1]&120)>>>3;if(Pt<0||Pt>=8){this._onError(z.FORMAT_ERROR,"Flv: AAC invalid channel configuration");return}O===5&&(ct=(E[1]&7)<<1|E[2]>>>7,Ze=(E[2]&124)>>>2);let it=self.navigator.userAgent.toLowerCase();return it.indexOf("firefox")!==-1?$e>=6?(O=5,T=new Array(4),ct=$e-3):(O=2,T=new Array(2),ct=$e):it.indexOf("android")!==-1?(O=2,T=new Array(2),ct=$e):(O=5,ct=$e,T=new Array(4),$e>=6?ct=$e-3:Pt===1&&(O=2,T=new Array(2),ct=$e)),T[0]=O<<3,T[0]|=($e&15)>>>1,T[1]=($e&15)<<7,T[1]|=(Pt&15)<<3,O===5&&(T[1]|=(ct&15)>>>1,T[2]=(ct&1)<<7,T[2]|=8,T[3]=0),{config:T,samplingRate:Gt,channelCount:Pt,codec:"mp4a.40."+O,originalCodec:"mp4a.40."+U}}_parseMP3AudioData(d,f,p,E){if(p<4){g.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");return}let T=this._littleEndian,O=new Uint8Array(d,f,p),U=null;if(E){if(O[0]!==255)return;let Ze=O[1]>>>3&3,$e=(O[1]&6)>>1,ct=(O[2]&240)>>>4,Gt=(O[2]&12)>>>2,it=(O[3]>>>6&3)!==3?2:1,Bt=0,dt=0,He=34,Ne="mp3";switch(Ze){case 0:Bt=this._mpegAudioV25SampleRateTable[Gt];break;case 2:Bt=this._mpegAudioV20SampleRateTable[Gt];break;case 3:Bt=this._mpegAudioV10SampleRateTable[Gt];break}switch($e){case 1:He=34,ct<this._mpegAudioL3BitRateTable.length&&(dt=this._mpegAudioL3BitRateTable[ct]);break;case 2:He=33,ct<this._mpegAudioL2BitRateTable.length&&(dt=this._mpegAudioL2BitRateTable[ct]);break;case 3:He=32,ct<this._mpegAudioL1BitRateTable.length&&(dt=this._mpegAudioL1BitRateTable[ct]);break}U={bitRate:dt,samplingRate:Bt,channelCount:it,codec:Ne,originalCodec:Ne}}else U=O;return U}_parseVideoData(d,f,p,E,T){if(p<=1){g.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");return}if(this._hasVideoFlagOverrided===!0&&this._hasVideo===!1)return;let O=new Uint8Array(d,f,p)[0],U=(O&240)>>>4,Ze=O&15;if(Ze!==7){this._onError(z.CODEC_UNSUPPORTED,`Flv: Unsupported codec in video frame: ${Ze}`);return}this._parseAVCVideoPacket(d,f+1,p-1,E,T,U)}_parseAVCVideoPacket(d,f,p,E,T,O){if(p<4){g.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");return}let U=this._littleEndian,Ze=new DataView(d,f,p),$e=Ze.getUint8(0),Gt=(Ze.getUint32(0,!U)&16777215)<<8>>8;if($e===0)this._parseAVCDecoderConfigurationRecord(d,f+4,p-4);else if($e===1)this._parseAVCVideoData(d,f+4,p-4,E,T,O,Gt);else if($e!==2){this._onError(z.FORMAT_ERROR,`Flv: Invalid video packet type ${$e}`);return}}_parseAVCDecoderConfigurationRecord(d,f,p){if(p<7){g.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");return}let E=this._videoMetadata,T=this._videoTrack,O=this._littleEndian,U=new DataView(d,f,p);E?typeof E.avcc!="undefined"&&g.w(this.TAG,"Found another AVCDecoderConfigurationRecord!"):(this._hasVideo===!1&&this._hasVideoFlagOverrided===!1&&(this._hasVideo=!0,this._mediaInfo.hasVideo=!0),E=this._videoMetadata={},E.type="video",E.id=T.id,E.timescale=this._timescale,E.duration=this._duration);let Ze=U.getUint8(0),$e=U.getUint8(1),ct=U.getUint8(2),Gt=U.getUint8(3);if(Ze!==1||$e===0){this._onError(z.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");return}if(this._naluLengthSize=(U.getUint8(4)&3)+1,this._naluLengthSize!==3&&this._naluLengthSize!==4){this._onError(z.FORMAT_ERROR,`Flv: Strange NaluLengthSizeMinusOne: ${this._naluLengthSize-1}`);return}let Pt=U.getUint8(5)&31;if(Pt===0){this._onError(z.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");return}else Pt>1&&g.w(this.TAG,`Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ${Pt}`);let it=6;for(let dt=0;dt<Pt;dt++){let He=U.getUint16(it,!O);if(it+=2,He===0)continue;let Ne=new Uint8Array(d,f+it,He);it+=He;let Ct=N.parseSPS(Ne);if(dt!==0)continue;E.codecWidth=Ct.codec_size.width,E.codecHeight=Ct.codec_size.height,E.presentWidth=Ct.present_size.width,E.presentHeight=Ct.present_size.height,E.profile=Ct.profile_string,E.level=Ct.level_string,E.bitDepth=Ct.bit_depth,E.chromaFormat=Ct.chroma_format,E.sarRatio=Ct.sar_ratio,E.frameRate=Ct.frame_rate,(Ct.frame_rate.fixed===!1||Ct.frame_rate.fps_num===0||Ct.frame_rate.fps_den===0)&&(E.frameRate=this._referenceFrameRate);let mt=E.frameRate.fps_den,di=E.frameRate.fps_num;E.refSampleDuration=E.timescale*(mt/di);let Ri=Ne.subarray(1,4),mi="avc1.";for(let ni=0;ni<3;ni++){let ki=Ri[ni].toString(16);ki.length<2&&(ki="0"+ki),mi+=ki}E.codec=mi;let Dt=this._mediaInfo;Dt.width=E.codecWidth,Dt.height=E.codecHeight,Dt.fps=E.frameRate.fps,Dt.profile=E.profile,Dt.level=E.level,Dt.refFrames=Ct.ref_frames,Dt.chromaFormat=Ct.chroma_format_string,Dt.sarNum=E.sarRatio.width,Dt.sarDen=E.sarRatio.height,Dt.videoCodec=mi,Dt.hasAudio?Dt.audioCodec!=null&&(Dt.mimeType='video/x-flv; codecs="'+Dt.videoCodec+","+Dt.audioCodec+'"'):Dt.mimeType='video/x-flv; codecs="'+Dt.videoCodec+'"',Dt.isComplete()&&this._onMediaInfo(Dt)}let Bt=U.getUint8(it);if(Bt===0){this._onError(z.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS");return}else Bt>1&&g.w(this.TAG,`Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ${Bt}`);it++;for(let dt=0;dt<Bt;dt++){let He=U.getUint16(it,!O);it+=2,He!==0&&(it+=He)}E.avcc=new Uint8Array(p),E.avcc.set(new Uint8Array(d,f,p),0),g.v(this.TAG,"Parsed AVCDecoderConfigurationRecord"),this._isInitialMetadataDispatched()?this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack):this._videoInitialMetadataDispatched=!0,this._dispatch=!1,this._onTrackMetadata("video",E)}_parseAVCVideoData(d,f,p,E,T,O,U){let Ze=this._littleEndian,$e=new DataView(d,f,p),ct=[],Gt=0,Pt=0;const it=this._naluLengthSize;let Bt=this._timestampBase+E,dt=O===1;for(;Pt<p;){if(Pt+4>=p){g.w(this.TAG,`Malformed Nalu near timestamp ${Bt}, offset = ${Pt}, dataSize = ${p}`);break}let He=$e.getUint32(Pt,!Ze);if(it===3&&(He>>>=8),He>p-it){g.w(this.TAG,`Malformed Nalus near timestamp ${Bt}, NaluSize > DataSize!`);return}let Ne=$e.getUint8(Pt+it)&31;Ne===5&&(dt=!0);let Ct=new Uint8Array(d,f+Pt,it+He),mt={type:Ne,data:Ct};ct.push(mt),Gt+=Ct.byteLength,Pt+=it+He}if(ct.length){let He=this._videoTrack,Ne={units:ct,length:Gt,isKeyframe:dt,dts:Bt,cts:U,pts:Bt+U};dt&&(Ne.fileposition=T),He.samples.push(Ne),He.length+=Gt}}}var V=P;class C{static init(){C.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[],".mp3":[]};for(let f in C.types)C.types.hasOwnProperty(f)&&(C.types[f]=[f.charCodeAt(0),f.charCodeAt(1),f.charCodeAt(2),f.charCodeAt(3)]);let d=C.constants={};d.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),d.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),d.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),d.STSC=d.STCO=d.STTS,d.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),d.HDLR_VIDEO=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]),d.HDLR_AUDIO=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]),d.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),d.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),d.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(d){let f=8,p=null,E=Array.prototype.slice.call(arguments,1),T=E.length;for(let U=0;U<T;U++)f+=E[U].byteLength;p=new Uint8Array(f),p[0]=f>>>24&255,p[1]=f>>>16&255,p[2]=f>>>8&255,p[3]=f&255,p.set(d,4);let O=8;for(let U=0;U<T;U++)p.set(E[U],O),O+=E[U].byteLength;return p}static generateInitSegment(d){let f=C.box(C.types.ftyp,C.constants.FTYP),p=C.moov(d),E=new Uint8Array(f.byteLength+p.byteLength);return E.set(f,0),E.set(p,f.byteLength),E}static moov(d){let f=C.mvhd(d.timescale,d.duration),p=C.trak(d),E=C.mvex(d);return C.box(C.types.moov,f,p,E)}static mvhd(d,f){return C.box(C.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))}static trak(d){return C.box(C.types.trak,C.tkhd(d),C.mdia(d))}static tkhd(d){let f=d.id,p=d.duration,E=d.presentWidth,T=d.presentHeight;return C.box(C.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,f>>>24&255,f>>>16&255,f>>>8&255,f&255,0,0,0,0,p>>>24&255,p>>>16&255,p>>>8&255,p&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,E>>>8&255,E&255,0,0,T>>>8&255,T&255,0,0]))}static mdia(d){return C.box(C.types.mdia,C.mdhd(d),C.hdlr(d),C.minf(d))}static mdhd(d){let f=d.timescale,p=d.duration;return C.box(C.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,f>>>24&255,f>>>16&255,f>>>8&255,f&255,p>>>24&255,p>>>16&255,p>>>8&255,p&255,85,196,0,0]))}static hdlr(d){let f=null;return d.type==="audio"?f=C.constants.HDLR_AUDIO:f=C.constants.HDLR_VIDEO,C.box(C.types.hdlr,f)}static minf(d){let f=null;return d.type==="audio"?f=C.box(C.types.smhd,C.constants.SMHD):f=C.box(C.types.vmhd,C.constants.VMHD),C.box(C.types.minf,f,C.dinf(),C.stbl(d))}static dinf(){return C.box(C.types.dinf,C.box(C.types.dref,C.constants.DREF))}static stbl(d){return C.box(C.types.stbl,C.stsd(d),C.box(C.types.stts,C.constants.STTS),C.box(C.types.stsc,C.constants.STSC),C.box(C.types.stsz,C.constants.STSZ),C.box(C.types.stco,C.constants.STCO))}static stsd(d){return d.type==="audio"?d.codec==="mp3"?C.box(C.types.stsd,C.constants.STSD_PREFIX,C.mp3(d)):C.box(C.types.stsd,C.constants.STSD_PREFIX,C.mp4a(d)):C.box(C.types.stsd,C.constants.STSD_PREFIX,C.avc1(d))}static mp3(d){let f=d.channelCount,p=d.audioSampleRate,E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,f,0,16,0,0,0,0,p>>>8&255,p&255,0,0]);return C.box(C.types[".mp3"],E)}static mp4a(d){let f=d.channelCount,p=d.audioSampleRate,E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,f,0,16,0,0,0,0,p>>>8&255,p&255,0,0]);return C.box(C.types.mp4a,E,C.esds(d))}static esds(d){let f=d.config||[],p=f.length,E=new Uint8Array([0,0,0,0,3,23+p,0,1,0,4,15+p,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([p]).concat(f).concat([6,1,2]));return C.box(C.types.esds,E)}static avc1(d){let f=d.avcc,p=d.codecWidth,E=d.codecHeight,T=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,p>>>8&255,p&255,E>>>8&255,E&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,10,120,113,113,47,102,108,118,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,255,255]);return C.box(C.types.avc1,T,C.box(C.types.avcC,f))}static mvex(d){return C.box(C.types.mvex,C.trex(d))}static trex(d){let f=d.id,p=new Uint8Array([0,0,0,0,f>>>24&255,f>>>16&255,f>>>8&255,f&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return C.box(C.types.trex,p)}static moof(d,f){return C.box(C.types.moof,C.mfhd(d.sequenceNumber),C.traf(d,f))}static mfhd(d){let f=new Uint8Array([0,0,0,0,d>>>24&255,d>>>16&255,d>>>8&255,d&255]);return C.box(C.types.mfhd,f)}static traf(d,f){let p=d.id,E=C.box(C.types.tfhd,new Uint8Array([0,0,0,0,p>>>24&255,p>>>16&255,p>>>8&255,p&255])),T=C.box(C.types.tfdt,new Uint8Array([0,0,0,0,f>>>24&255,f>>>16&255,f>>>8&255,f&255])),O=C.sdtp(d),U=C.trun(d,O.byteLength+16+16+8+16+8+8);return C.box(C.types.traf,E,T,U,O)}static sdtp(d){let f=d.samples||[],p=f.length,E=new Uint8Array(4+p);for(let T=0;T<p;T++){let O=f[T].flags;E[T+4]=O.isLeading<<6|O.dependsOn<<4|O.isDependedOn<<2|O.hasRedundancy}return C.box(C.types.sdtp,E)}static trun(d,f){let p=d.samples||[],E=p.length,T=12+16*E,O=new Uint8Array(T);f+=8+T,O.set([0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255],0);for(let U=0;U<E;U++){let Ze=p[U].duration,$e=p[U].size,ct=p[U].flags,Gt=p[U].cts;O.set([Ze>>>24&255,Ze>>>16&255,Ze>>>8&255,Ze&255,$e>>>24&255,$e>>>16&255,$e>>>8&255,$e&255,ct.isLeading<<2|ct.dependsOn,ct.isDependedOn<<6|ct.hasRedundancy<<4|ct.isNonSync,0,0,Gt>>>24&255,Gt>>>16&255,Gt>>>8&255,Gt&255],12+16*U)}return C.box(C.types.trun,O)}static mdat(d){return C.box(C.types.mdat,d)}}C.init();var Ee=C;class xe{static getSilentFrame(d,f){if(d==="mp4a.40.2"){if(f===1)return new Uint8Array([0,200,0,128,35,128]);if(f===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(f===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(f===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(f===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(f===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(f===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(f===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(f===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}return null}}var Ke=xe;class ot{constructor(d,f,p,E,T){this.dts=d,this.pts=f,this.duration=p,this.originalDts=E,this.isSyncPoint=T,this.fileposition=null}}class Rt{constructor(){this.beginDts=0,this.endDts=0,this.beginPts=0,this.endPts=0,this.originalBeginDts=0,this.originalEndDts=0,this.syncPoints=[],this.firstSample=null,this.lastSample=null}appendSyncPoint(d){d.isSyncPoint=!0,this.syncPoints.push(d)}}class et{constructor(){this._list=[]}clear(){this._list=[]}appendArray(d){let f=this._list;d.length!==0&&(f.length>0&&d[0].originalDts<f[f.length-1].originalDts&&this.clear(),Array.prototype.push.apply(f,d))}getLastSyncPointBeforeDts(d){if(this._list.length==0)return null;let f=this._list,p=0,E=f.length-1,T=0,O=0,U=E;for(d<f[0].dts&&(p=0,O=U+1);O<=U;)if(T=O+Math.floor((U-O)/2),T===E||d>=f[T].dts&&d<f[T+1].dts){p=T;break}else f[T].dts<d?O=T+1:U=T-1;return this._list[p]}}class ut{constructor(d){this._type=d,this._list=[],this._lastAppendLocation=-1}get type(){return this._type}get length(){return this._list.length}isEmpty(){return this._list.length===0}clear(){this._list=[],this._lastAppendLocation=-1}_searchNearestSegmentBefore(d){let f=this._list;if(f.length===0)return-2;let p=f.length-1,E=0,T=0,O=p,U=0;if(d<f[0].originalBeginDts)return U=-1,U;for(;T<=O;)if(E=T+Math.floor((O-T)/2),E===p||d>f[E].lastSample.originalDts&&d<f[E+1].originalBeginDts){U=E;break}else f[E].originalBeginDts<d?T=E+1:O=E-1;return U}_searchNearestSegmentAfter(d){return this._searchNearestSegmentBefore(d)+1}append(d){let f=this._list,p=d,E=this._lastAppendLocation,T=0;E!==-1&&E<f.length&&p.originalBeginDts>=f[E].lastSample.originalDts&&(E===f.length-1||E<f.length-1&&p.originalBeginDts<f[E+1].originalBeginDts)?T=E+1:f.length>0&&(T=this._searchNearestSegmentBefore(p.originalBeginDts)+1),this._lastAppendLocation=T,this._list.splice(T,0,p)}getLastSegmentBefore(d){let f=this._searchNearestSegmentBefore(d);return f>=0?this._list[f]:null}getLastSampleBefore(d){let f=this.getLastSegmentBefore(d);return f!=null?f.lastSample:null}getLastSyncPointBefore(d){let f=this._searchNearestSegmentBefore(d),p=this._list[f].syncPoints;for(;p.length===0&&f>0;)f--,p=this._list[f].syncPoints;return p.length>0?p[p.length-1]:null}}class Et{constructor(d){this.TAG="MP4Remuxer",this._config=d,this._isLive=d.isLive===!0,this._dtsBase=-1,this._dtsBaseInited=!1,this._audioDtsBase=1/0,this._videoDtsBase=1/0,this._audioNextDts=void 0,this._videoNextDts=void 0,this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList=new ut("audio"),this._videoSegmentInfoList=new ut("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!!(ae.chrome&&(ae.version.major<50||ae.version.major===50&&ae.version.build<2661)),this._fillSilentAfterSeek=ae.msedge||ae.msie,this._mp3UseMpegAudio=!ae.firefox,this._fillAudioTimestampGap=this._config.fixAudioTimestampGap}destroy(){this._dtsBase=-1,this._dtsBaseInited=!1,this._audioMeta=null,this._videoMeta=null,this._audioSegmentInfoList.clear(),this._audioSegmentInfoList=null,this._videoSegmentInfoList.clear(),this._videoSegmentInfoList=null,this._onInitSegment=null,this._onMediaSegment=null}bindDataSource(d){return d.onDataAvailable=this.remux.bind(this),d.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(d){this._onInitSegment=d}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(d){this._onMediaSegment=d}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(d){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(d,f){if(!this._onMediaSegment)throw new de("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(d,f),this._remuxVideo(f),this._remuxAudio(d)}_onTrackMetadataReceived(d,f){let p=null,E="mp4",T=f.codec;if(d==="audio")this._audioMeta=f,f.codec==="mp3"&&this._mp3UseMpegAudio?(E="mpeg",T="",p=new Uint8Array):p=Ee.generateInitSegment(f);else if(d==="video")this._videoMeta=f,p=Ee.generateInitSegment(f);else return;if(!this._onInitSegment)throw new de("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(d,{type:d,data:p.buffer,codec:T,container:`${d}/${E}`,mediaDuration:f.duration})}_calculateDtsBase(d,f){this._dtsBaseInited||(d.samples&&d.samples.length&&(this._audioDtsBase=d.samples[0].dts),f.samples&&f.samples.length&&(this._videoDtsBase=f.samples[0].dts),this._dtsBase=Math.min(this._audioDtsBase,this._videoDtsBase),this._dtsBaseInited=!0)}flushStashedSamples(){let d=this._videoStashedLastSample,f=this._audioStashedLastSample,p={type:"video",id:1,sequenceNumber:0,samples:[],length:0};d!=null&&(p.samples.push(d),p.length=d.length);let E={type:"audio",id:2,sequenceNumber:0,samples:[],length:0};f!=null&&(E.samples.push(f),E.length=f.length),this._videoStashedLastSample=null,this._audioStashedLastSample=null,this._remuxVideo(p,!0),this._remuxAudio(E,!0)}_remuxAudio(d,f){if(this._audioMeta==null)return;let p=d,E=p.samples,T,O=-1,U=-1,Ze=-1,$e=this._audioMeta.refSampleDuration,ct=this._audioMeta.codec==="mp3"&&this._mp3UseMpegAudio,Gt=this._dtsBaseInited&&this._audioNextDts===void 0,Pt=!1;if(!E||E.length===0||E.length===1&&!f)return;let it=0,Bt=null,dt=0;ct?(it=0,dt=p.length):(it=8,dt=8+p.length);let He=null;if(E.length>1&&(He=E.pop(),dt-=He.length),this._audioStashedLastSample!=null){let Dt=this._audioStashedLastSample;this._audioStashedLastSample=null,E.unshift(Dt),dt+=Dt.length}He!=null&&(this._audioStashedLastSample=He);let Ne=E[0].dts-this._dtsBase;if(this._audioNextDts)T=Ne-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())T=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(Pt=!0);else{let Dt=this._audioSegmentInfoList.getLastSampleBefore(Ne);if(Dt!=null){let ni=Ne-(Dt.originalDts+Dt.duration);ni<=3&&(ni=0);let ki=Dt.dts+Dt.duration+ni;T=Ne-ki}else T=0}if(Pt){let Dt=Ne-T,ni=this._videoSegmentInfoList.getLastSegmentBefore(Ne);if(ni!=null&&ni.beginDts<Dt){let ki=Ke.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(ki){let W=ni.beginDts,Q=Dt-ni.beginDts;g.v(this.TAG,`InsertPrefixSilentAudio: dts: ${W}, duration: ${Q}`),E.unshift({unit:ki,dts:W,pts:W}),dt+=ki.byteLength}}else Pt=!1}let Ct=[];for(let Dt=0;Dt<E.length;Dt++){let ni=E[Dt],ki=ni.unit,W=ni.dts-this._dtsBase,Q=W-T;O===-1&&(O=Q);let Re=0;Dt!==E.length-1?Re=E[Dt+1].dts-this._dtsBase-T-Q:He!=null?Re=He.dts-this._dtsBase-T-Q:Ct.length>=1?Re=Ct[Ct.length-1].duration:Re=Math.floor($e);let ge=!1,ue=null;if(Re>$e*1.5&&this._audioMeta.codec!=="mp3"&&this._fillAudioTimestampGap&&!ae.safari){ge=!0;let Te=Math.abs(Re-$e),Be=Math.ceil(Te/$e),Qe=Q+$e;g.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.
dts: ${Q+Re} ms, expected: ${Q+Math.round($e)} ms, delta: ${Math.round(Te)} ms, generate: ${Be} frames`);let Kt=Ke.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);Kt==null&&(g.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),Kt=ki),ue=[];for(let ei=0;ei<Be;ei++){let Nt=Math.round(Qe);if(ue.length>0){let Qt=ue[ue.length-1];Qt.duration=Nt-Qt.dts}let Zt={dts:Nt,pts:Nt,cts:0,unit:Kt,size:Kt.byteLength,duration:0,originalDts:W,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};ue.push(Zt),dt+=Zt.size,Qe+=$e}let xt=ue[ue.length-1];xt.duration=Q+Re-xt.dts,Re=Math.round($e)}Ct.push({dts:Q,pts:Q,cts:0,unit:ni.unit,size:ni.unit.byteLength,duration:Re,originalDts:W,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),ge&&Ct.push.apply(Ct,ue)}ct?Bt=new Uint8Array(dt):(Bt=new Uint8Array(dt),Bt[0]=dt>>>24&255,Bt[1]=dt>>>16&255,Bt[2]=dt>>>8&255,Bt[3]=dt&255,Bt.set(Ee.types.mdat,4));for(let Dt=0;Dt<Ct.length;Dt++){let ni=Ct[Dt].unit;Bt.set(ni,it),it+=ni.byteLength}let mt=Ct[Ct.length-1];U=mt.dts+mt.duration,this._audioNextDts=U;let di=new Rt;di.beginDts=O,di.endDts=U,di.beginPts=O,di.endPts=U,di.originalBeginDts=Ct[0].originalDts,di.originalEndDts=mt.originalDts+mt.duration,di.firstSample=new ot(Ct[0].dts,Ct[0].pts,Ct[0].duration,Ct[0].originalDts,!1),di.lastSample=new ot(mt.dts,mt.pts,mt.duration,mt.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(di),p.samples=Ct,p.sequenceNumber++;let Ri=null;ct?Ri=new Uint8Array:Ri=Ee.moof(p,O),p.samples=[],p.length=0;let mi={type:"audio",data:this._mergeBoxes(Ri,Bt).buffer,sampleCount:Ct.length,info:di};ct&&Gt&&(mi.timestampOffset=O),this._onMediaSegment("audio",mi)}_remuxVideo(d,f){if(this._videoMeta==null)return;let p=d,E=p.samples,T,O=-1,U=-1,Ze=-1,$e=-1;if(!E||E.length===0||E.length===1&&!f)return;let ct=8,Gt=null,Pt=8+d.length,it=null;if(E.length>1&&(it=E.pop(),Pt-=it.length),this._videoStashedLastSample!=null){let mt=this._videoStashedLastSample;this._videoStashedLastSample=null,E.unshift(mt),Pt+=mt.length}it!=null&&(this._videoStashedLastSample=it);let Bt=E[0].dts-this._dtsBase;if(this._videoNextDts)T=Bt-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())T=0;else{let mt=this._videoSegmentInfoList.getLastSampleBefore(Bt);if(mt!=null){let di=Bt-(mt.originalDts+mt.duration);di<=3&&(di=0);let Ri=mt.dts+mt.duration+di;T=Bt-Ri}else T=0}let dt=new Rt,He=[];for(let mt=0;mt<E.length;mt++){let di=E[mt],Ri=di.dts-this._dtsBase,mi=di.isKeyframe,Dt=Ri-T,ni=di.cts,ki=Dt+ni;O===-1&&(O=Dt,Ze=ki);let W=0;if(mt!==E.length-1?W=E[mt+1].dts-this._dtsBase-T-Dt:it!=null?W=it.dts-this._dtsBase-T-Dt:He.length>=1?W=He[He.length-1].duration:W=Math.floor(this._videoMeta.refSampleDuration),mi){let Q=new ot(Dt,ki,W,di.dts,!0);Q.fileposition=di.fileposition,dt.appendSyncPoint(Q)}He.push({dts:Dt,pts:ki,cts:ni,units:di.units,size:di.length,isKeyframe:mi,duration:W,originalDts:Ri,flags:{isLeading:0,dependsOn:mi?2:1,isDependedOn:mi?1:0,hasRedundancy:0,isNonSync:mi?0:1}})}Gt=new Uint8Array(Pt),Gt[0]=Pt>>>24&255,Gt[1]=Pt>>>16&255,Gt[2]=Pt>>>8&255,Gt[3]=Pt&255,Gt.set(Ee.types.mdat,4);for(let mt=0;mt<He.length;mt++){let di=He[mt].units;for(;di.length;){let mi=di.shift().data;Gt.set(mi,ct),ct+=mi.byteLength}}let Ne=He[He.length-1];if(U=Ne.dts+Ne.duration,$e=Ne.pts+Ne.duration,this._videoNextDts=U,dt.beginDts=O,dt.endDts=U,dt.beginPts=Ze,dt.endPts=$e,dt.originalBeginDts=He[0].originalDts,dt.originalEndDts=Ne.originalDts+Ne.duration,dt.firstSample=new ot(He[0].dts,He[0].pts,He[0].duration,He[0].originalDts,He[0].isKeyframe),dt.lastSample=new ot(Ne.dts,Ne.pts,Ne.duration,Ne.originalDts,Ne.isKeyframe),this._isLive||this._videoSegmentInfoList.append(dt),p.samples=He,p.sequenceNumber++,this._forceFirstIDR){let mt=He[0].flags;mt.dependsOn=2,mt.isNonSync=0}let Ct=Ee.moof(p,O);p.samples=[],p.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(Ct,Gt).buffer,sampleCount:He.length,info:dt})}_mergeBoxes(d,f){let p=new Uint8Array(d.byteLength+f.byteLength);return p.set(d,0),p.set(f,d.byteLength),p}}var Tt=Et,pe={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"};class pt{constructor(d,f){this.TAG="TransmuxingController",this._emitter=new(Y()),this._config=f,d.segments||(d.segments=[{duration:d.duration,filesize:d.filesize,url:d.url}]),typeof d.cors!="boolean"&&(d.cors=!0),typeof d.withCredentials!="boolean"&&(d.withCredentials=!1),this._mediaDataSource=d,this._currentSegmentIndex=0;let p=0;this._mediaDataSource.segments.forEach(E=>{E.timestampBase=p,p+=E.duration,E.cors=d.cors,E.withCredentials=d.withCredentials,f.referrerPolicy&&(E.referrerPolicy=f.referrerPolicy)}),!isNaN(p)&&this._mediaDataSource.duration!==p&&(this._mediaDataSource.duration=p),this._mediaInfo=null,this._demuxer=null,this._remuxer=null,this._ioctl=null,this._pendingSeekTime=null,this._pendingResolveSeekPoint=null,this._statisticsReporter=null}destroy(){this._mediaInfo=null,this._mediaDataSource=null,this._statisticsReporter&&this._disableStatisticsReporter(),this._ioctl&&(this._ioctl.destroy(),this._ioctl=null),this._demuxer&&(this._demuxer.destroy(),this._demuxer=null),this._remuxer&&(this._remuxer.destroy(),this._remuxer=null),this._emitter.removeAllListeners(),this._emitter=null}on(d,f){this._emitter.addListener(d,f)}off(d,f){this._emitter.removeListener(d,f)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(d,f){this._currentSegmentIndex=d;let p=this._mediaDataSource.segments[d],E=this._ioctl=new Se(p,this._config,d);E.onError=this._onIOException.bind(this),E.onSeeked=this._onIOSeeked.bind(this),E.onComplete=this._onIOComplete.bind(this),E.onRedirect=this._onIORedirect.bind(this),E.onRecoveredEarlyEof=this._onIORecoveredEarlyEof.bind(this),f?this._demuxer.bindDataSource(this._ioctl):E.onDataArrival=this._onInitChunkArrival.bind(this),E.open(f)}stop(){this._internalAbort(),this._disableStatisticsReporter()}_internalAbort(){this._ioctl&&(this._ioctl.destroy(),this._ioctl=null)}pause(){this._ioctl&&this._ioctl.isWorking()&&(this._ioctl.pause(),this._disableStatisticsReporter())}resume(){this._ioctl&&this._ioctl.isPaused()&&(this._ioctl.resume(),this._enableStatisticsReporter())}seek(d){if(this._mediaInfo==null||!this._mediaInfo.isSeekable())return;let f=this._searchSegmentIndexContains(d);if(f===this._currentSegmentIndex){let p=this._mediaInfo.segments[f];if(p==null)this._pendingSeekTime=d;else{let E=p.getNearestKeyframe(d);this._remuxer.seek(E.milliseconds),this._ioctl.seek(E.fileposition),this._pendingResolveSeekPoint=E.milliseconds}}else{let p=this._mediaInfo.segments[f];if(p==null)this._pendingSeekTime=d,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(f);else{let E=p.getNearestKeyframe(d);this._internalAbort(),this._remuxer.seek(d),this._remuxer.insertDiscontinuity(),this._demuxer.resetMediaInfo(),this._demuxer.timestampBase=this._mediaDataSource.segments[f].timestampBase,this._loadSegment(f,E.fileposition),this._pendingResolveSeekPoint=E.milliseconds,this._reportSegmentMediaInfo(f)}}this._enableStatisticsReporter()}_searchSegmentIndexContains(d){let f=this._mediaDataSource.segments,p=f.length-1;for(let E=0;E<f.length;E++)if(d<f[E].timestampBase){p=E-1;break}return p}_onInitChunkArrival(d,f){let p=null,E=0;if(f>0)this._demuxer.bindDataSource(this._ioctl),this._demuxer.timestampBase=this._mediaDataSource.segments[this._currentSegmentIndex].timestampBase,E=this._demuxer.parseChunks(d,f);else if((p=V.probe(d)).match){this._demuxer=new V(p,this._config),this._remuxer||(this._remuxer=new Tt(this._config));let T=this._mediaDataSource;T.duration!=null&&!isNaN(T.duration)&&(this._demuxer.overridedDuration=T.duration),typeof T.hasAudio=="boolean"&&(this._demuxer.overridedHasAudio=T.hasAudio),typeof T.hasVideo=="boolean"&&(this._demuxer.overridedHasVideo=T.hasVideo),this._demuxer.timestampBase=T.segments[this._currentSegmentIndex].timestampBase,this._demuxer.onError=this._onDemuxException.bind(this),this._demuxer.onMediaInfo=this._onMediaInfo.bind(this),this._demuxer.onMetaDataArrived=this._onMetaDataArrived.bind(this),this._demuxer.onScriptDataArrived=this._onScriptDataArrived.bind(this),this._remuxer.bindDataSource(this._demuxer.bindDataSource(this._ioctl)),this._remuxer.onInitSegment=this._onRemuxerInitSegmentArrival.bind(this),this._remuxer.onMediaSegment=this._onRemuxerMediaSegmentArrival.bind(this),E=this._demuxer.parseChunks(d,f)}else p=null,g.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(pe.DEMUX_ERROR,z.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),E=0;return E}_onMediaInfo(d){this._mediaInfo==null&&(this._mediaInfo=Object.assign({},d),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,We.prototype));let f=Object.assign({},d);Object.setPrototypeOf(f,We.prototype),this._mediaInfo.segments[this._currentSegmentIndex]=f,this._reportSegmentMediaInfo(this._currentSegmentIndex),this._pendingSeekTime!=null&&Promise.resolve().then(()=>{let p=this._pendingSeekTime;this._pendingSeekTime=null,this.seek(p)})}_onMetaDataArrived(d){this._emitter.emit(pe.METADATA_ARRIVED,d)}_onScriptDataArrived(d){this._emitter.emit(pe.SCRIPTDATA_ARRIVED,d)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(d){let p=d+1;p<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(p)):(this._remuxer.flushStashedSamples(),this._emitter.emit(pe.LOADING_COMPLETE),this._disableStatisticsReporter())}_onIORedirect(d){let f=this._ioctl.extraData;this._mediaDataSource.segments[f].redirectedURL=d}_onIORecoveredEarlyEof(){this._emitter.emit(pe.RECOVERED_EARLY_EOF)}_onIOException(d,f){g.e(this.TAG,`IOException: type = ${d}, code = ${f.code}, msg = ${f.msg}`),this._emitter.emit(pe.IO_ERROR,d,f),this._disableStatisticsReporter()}_onDemuxException(d,f){g.e(this.TAG,`DemuxException: type = ${d}, info = ${f}`),this._emitter.emit(pe.DEMUX_ERROR,d,f)}_onRemuxerInitSegmentArrival(d,f){this._emitter.emit(pe.INIT_SEGMENT,d,f)}_onRemuxerMediaSegmentArrival(d,f){if(this._pendingSeekTime==null&&(this._emitter.emit(pe.MEDIA_SEGMENT,d,f),this._pendingResolveSeekPoint!=null&&d==="video")){let p=f.info.syncPoints,E=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,ae.safari&&p.length>0&&p[0].originalDts===E&&(E=p[0].pts),this._emitter.emit(pe.RECOMMEND_SEEKPOINT,E)}}_enableStatisticsReporter(){this._statisticsReporter==null&&(this._statisticsReporter=self.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval))}_disableStatisticsReporter(){this._statisticsReporter&&(self.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}_reportSegmentMediaInfo(d){let f=this._mediaInfo.segments[d],p=Object.assign({},f);p.duration=this._mediaInfo.duration,p.segmentCount=this._mediaInfo.segmentCount,delete p.segments,delete p.keyframesIndex,this._emitter.emit(pe.MEDIA_INFO,p)}_reportStatisticsInfo(){let d={};d.url=this._ioctl.currentURL,d.hasRedirect=this._ioctl.hasRedirect,d.hasRedirect&&(d.redirectedURL=this._ioctl.currentRedirectedURL),d.speed=this._ioctl.currentSpeed,d.loaderType=this._ioctl.loaderType,d.currentSegmentIndex=this._currentSegmentIndex,d.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(pe.STATISTICS_INFO,d)}}var Ei=pt,li=function(Fe){let d="TransmuxingWorker",f=null,p=dt.bind(this);J.install(),Fe.addEventListener("message",function(He){switch(He.data.cmd){case"init":f=new Ei(He.data.param[0],He.data.param[1]),f.on(pe.IO_ERROR,Pt.bind(this)),f.on(pe.DEMUX_ERROR,it.bind(this)),f.on(pe.INIT_SEGMENT,E.bind(this)),f.on(pe.MEDIA_SEGMENT,T.bind(this)),f.on(pe.LOADING_COMPLETE,O.bind(this)),f.on(pe.RECOVERED_EARLY_EOF,U.bind(this)),f.on(pe.MEDIA_INFO,Ze.bind(this)),f.on(pe.METADATA_ARRIVED,$e.bind(this)),f.on(pe.SCRIPTDATA_ARRIVED,ct.bind(this)),f.on(pe.STATISTICS_INFO,Gt.bind(this)),f.on(pe.RECOMMEND_SEEKPOINT,Bt.bind(this));break;case"destroy":f&&(f.destroy(),f=null),Fe.postMessage({msg:"destroyed"});break;case"start":f.start();break;case"stop":f.stop();break;case"seek":f.seek(He.data.param);break;case"pause":f.pause();break;case"resume":f.resume();break;case"logging_config":{let Ne=He.data.param;ye.applyConfig(Ne),Ne.enableCallback===!0?ye.addLogListener(p):ye.removeLogListener(p);break}}});function E(He,Ne){let Ct={msg:pe.INIT_SEGMENT,data:{type:He,data:Ne}};Fe.postMessage(Ct,[Ne.data])}function T(He,Ne){let Ct={msg:pe.MEDIA_SEGMENT,data:{type:He,data:Ne}};Fe.postMessage(Ct,[Ne.data])}function O(){let He={msg:pe.LOADING_COMPLETE};Fe.postMessage(He)}function U(){let He={msg:pe.RECOVERED_EARLY_EOF};Fe.postMessage(He)}function Ze(He){let Ne={msg:pe.MEDIA_INFO,data:He};Fe.postMessage(Ne)}function $e(He){let Ne={msg:pe.METADATA_ARRIVED,data:He};Fe.postMessage(Ne)}function ct(He){let Ne={msg:pe.SCRIPTDATA_ARRIVED,data:He};Fe.postMessage(Ne)}function Gt(He){let Ne={msg:pe.STATISTICS_INFO,data:He};Fe.postMessage(Ne)}function Pt(He,Ne){Fe.postMessage({msg:pe.IO_ERROR,data:{type:He,info:Ne}})}function it(He,Ne){Fe.postMessage({msg:pe.DEMUX_ERROR,data:{type:He,info:Ne}})}function Bt(He){Fe.postMessage({msg:pe.RECOMMEND_SEEKPOINT,data:He})}function dt(He,Ne){Fe.postMessage({msg:"logcat_callback",data:{type:He,logcat:Ne}})}};class Ai{constructor(d,f){if(this.TAG="Transmuxer",this._emitter=new(Y()),f.enableWorker&&typeof Worker!="undefined")try{let p=x(82059);this._worker=p(li),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[d,f]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},ye.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:ye.getConfig()})}catch(p){g.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new Ei(d,f)}else this._controller=new Ei(d,f);if(this._controller){let p=this._controller;p.on(pe.IO_ERROR,this._onIOError.bind(this)),p.on(pe.DEMUX_ERROR,this._onDemuxError.bind(this)),p.on(pe.INIT_SEGMENT,this._onInitSegment.bind(this)),p.on(pe.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),p.on(pe.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),p.on(pe.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),p.on(pe.MEDIA_INFO,this._onMediaInfo.bind(this)),p.on(pe.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),p.on(pe.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),p.on(pe.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),p.on(pe.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),ye.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}on(d,f){this._emitter.addListener(d,f)}off(d,f){this._emitter.removeListener(d,f)}hasWorker(){return this._worker!=null}open(){this._worker?this._worker.postMessage({cmd:"start"}):this._controller.start()}close(){this._worker?this._worker.postMessage({cmd:"stop"}):this._controller.stop()}seek(d){this._worker?this._worker.postMessage({cmd:"seek",param:d}):this._controller.seek(d)}pause(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}resume(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}_onInitSegment(d,f){Promise.resolve().then(()=>{this._emitter.emit(pe.INIT_SEGMENT,d,f)})}_onMediaSegment(d,f){Promise.resolve().then(()=>{this._emitter.emit(pe.MEDIA_SEGMENT,d,f)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(pe.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(pe.RECOVERED_EARLY_EOF)})}_onMediaInfo(d){Promise.resolve().then(()=>{this._emitter.emit(pe.MEDIA_INFO,d)})}_onMetaDataArrived(d){Promise.resolve().then(()=>{this._emitter.emit(pe.METADATA_ARRIVED,d)})}_onScriptDataArrived(d){Promise.resolve().then(()=>{this._emitter.emit(pe.SCRIPTDATA_ARRIVED,d)})}_onStatisticsInfo(d){Promise.resolve().then(()=>{this._emitter.emit(pe.STATISTICS_INFO,d)})}_onIOError(d,f){Promise.resolve().then(()=>{this._emitter.emit(pe.IO_ERROR,d,f)})}_onDemuxError(d,f){Promise.resolve().then(()=>{this._emitter.emit(pe.DEMUX_ERROR,d,f)})}_onRecommendSeekpoint(d){Promise.resolve().then(()=>{this._emitter.emit(pe.RECOMMEND_SEEKPOINT,d)})}_onLoggingConfigChanged(d){this._worker&&this._worker.postMessage({cmd:"logging_config",param:d})}_onWorkerMessage(d){let f=d.data,p=f.data;if(f.msg==="destroyed"||this._workerDestroying){this._workerDestroying=!1,this._worker.terminate(),this._worker=null;return}switch(f.msg){case pe.INIT_SEGMENT:case pe.MEDIA_SEGMENT:this._emitter.emit(f.msg,p.type,p.data);break;case pe.LOADING_COMPLETE:case pe.RECOVERED_EARLY_EOF:this._emitter.emit(f.msg);break;case pe.MEDIA_INFO:Object.setPrototypeOf(p,We.prototype),this._emitter.emit(f.msg,p);break;case pe.METADATA_ARRIVED:case pe.SCRIPTDATA_ARRIVED:case pe.STATISTICS_INFO:this._emitter.emit(f.msg,p);break;case pe.IO_ERROR:case pe.DEMUX_ERROR:this._emitter.emit(f.msg,p.type,p.info);break;case pe.RECOMMEND_SEEKPOINT:this._emitter.emit(f.msg,p);break;case"logcat_callback":g.emitter.emit("log",p.type,p.logcat);break;default:break}}}var Vi=Ai,Ut={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};class wi{constructor(d){this.TAG="MSEController",this._config=d,this._emitter=new(Y()),this._config.isLive&&this._config.autoCleanupSourceBuffer==null&&(this._config.autoCleanupSourceBuffer=!0),this.e={onSourceOpen:this._onSourceOpen.bind(this),onSourceEnded:this._onSourceEnded.bind(this),onSourceClose:this._onSourceClose.bind(this),onSourceBufferError:this._onSourceBufferError.bind(this),onSourceBufferUpdateEnd:this._onSourceBufferUpdateEnd.bind(this)},this._mediaSource=null,this._mediaSourceObjectURL=null,this._mediaElement=null,this._isBufferFull=!1,this._hasPendingEos=!1,this._requireSetMediaDuration=!1,this._pendingMediaDuration=0,this._pendingSourceBufferInit=[],this._mimeTypes={video:null,audio:null},this._sourceBuffers={video:null,audio:null},this._lastInitSegments={video:null,audio:null},this._pendingSegments={video:[],audio:[]},this._pendingRemoveRanges={video:[],audio:[]},this._idrList=new et}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(d,f){this._emitter.addListener(d,f)}off(d,f){this._emitter.removeListener(d,f)}attachMediaElement(d){if(this._mediaSource)throw new de("MediaSource has been attached to an HTMLMediaElement!");let f=this._mediaSource=new window.MediaSource;f.addEventListener("sourceopen",this.e.onSourceOpen),f.addEventListener("sourceended",this.e.onSourceEnded),f.addEventListener("sourceclose",this.e.onSourceClose),this._mediaElement=d,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),d.src=this._mediaSourceObjectURL}detachMediaElement(){if(this._mediaSource){let d=this._mediaSource;for(let f in this._sourceBuffers){let p=this._pendingSegments[f];p.splice(0,p.length),this._pendingSegments[f]=null,this._pendingRemoveRanges[f]=null,this._lastInitSegments[f]=null;let E=this._sourceBuffers[f];if(E){if(d.readyState!=="closed"){try{d.removeSourceBuffer(E)}catch(T){g.e(this.TAG,T.message)}E.removeEventListener("error",this.e.onSourceBufferError),E.removeEventListener("updateend",this.e.onSourceBufferUpdateEnd)}this._mimeTypes[f]=null,this._sourceBuffers[f]=null}}if(d.readyState==="open")try{d.endOfStream()}catch(f){g.e(this.TAG,f.message)}d.removeEventListener("sourceopen",this.e.onSourceOpen),d.removeEventListener("sourceended",this.e.onSourceEnded),d.removeEventListener("sourceclose",this.e.onSourceClose),this._pendingSourceBufferInit=[],this._isBufferFull=!1,this._idrList.clear(),this._mediaSource=null}this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement=null),this._mediaSourceObjectURL&&(window.URL.revokeObjectURL(this._mediaSourceObjectURL),this._mediaSourceObjectURL=null)}appendInitSegment(d,f){if(!this._mediaSource||this._mediaSource.readyState!=="open"){this._pendingSourceBufferInit.push(d),this._pendingSegments[d.type].push(d);return}let p=d,E=`${p.container}`;p.codec&&p.codec.length>0&&(E+=`;codecs=${p.codec}`);let T=!1;if(g.v(this.TAG,"Received Initialization Segment, mimeType: "+E),this._lastInitSegments[p.type]=p,E!==this._mimeTypes[p.type]){if(this._mimeTypes[p.type])g.v(this.TAG,`Notice: ${p.type} mimeType changed, origin: ${this._mimeTypes[p.type]}, target: ${E}`);else{T=!0;try{let O=this._sourceBuffers[p.type]=this._mediaSource.addSourceBuffer(E);O.addEventListener("error",this.e.onSourceBufferError),O.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(O){g.e(this.TAG,O.message),this._emitter.emit(Ut.ERROR,{code:O.code,msg:O.message});return}}this._mimeTypes[p.type]=E}f||this._pendingSegments[p.type].push(p),T||this._sourceBuffers[p.type]&&!this._sourceBuffers[p.type].updating&&this._doAppendSegments(),ae.safari&&p.container==="audio/mpeg"&&p.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=p.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(d){let f=d;this._pendingSegments[f.type].push(f),this._config.autoCleanupSourceBuffer&&this._needCleanupSourceBuffer()&&this._doCleanupSourceBuffer();let p=this._sourceBuffers[f.type];p&&!p.updating&&!this._hasPendingRemoveRanges()&&this._doAppendSegments()}seek(d){for(let f in this._sourceBuffers){if(!this._sourceBuffers[f])continue;let p=this._sourceBuffers[f];if(this._mediaSource.readyState==="open")try{p.abort()}catch(T){g.e(this.TAG,T.message)}this._idrList.clear();let E=this._pendingSegments[f];if(E.splice(0,E.length),this._mediaSource.readyState!=="closed"){for(let T=0;T<p.buffered.length;T++){let O=p.buffered.start(T),U=p.buffered.end(T);this._pendingRemoveRanges[f].push({start:O,end:U})}if(p.updating||this._doRemoveRanges(),ae.safari){let T=this._lastInitSegments[f];T&&(this._pendingSegments[f].push(T),p.updating||this._doAppendSegments())}}}}endOfStream(){let d=this._mediaSource,f=this._sourceBuffers;if(!d||d.readyState!=="open"){d&&d.readyState==="closed"&&this._hasPendingSegments()&&(this._hasPendingEos=!0);return}f.video&&f.video.updating||f.audio&&f.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,d.endOfStream())}getNearestKeyframe(d){return this._idrList.getLastSyncPointBeforeDts(d)}_needCleanupSourceBuffer(){if(!this._config.autoCleanupSourceBuffer)return!1;let d=this._mediaElement.currentTime;for(let f in this._sourceBuffers){let p=this._sourceBuffers[f];if(p){let E=p.buffered;if(E.length>=1&&d-E.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let d=this._mediaElement.currentTime;for(let f in this._sourceBuffers){let p=this._sourceBuffers[f];if(p){let E=p.buffered,T=!1;for(let O=0;O<E.length;O++){let U=E.start(O),Ze=E.end(O);if(U<=d&&d<Ze+3){if(d-U>=this._config.autoCleanupMaxBackwardDuration){T=!0;let $e=d-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[f].push({start:U,end:$e})}}else Ze<d&&(T=!0,this._pendingRemoveRanges[f].push({start:U,end:Ze}))}T&&!p.updating&&this._doRemoveRanges()}}}_updateMediaSourceDuration(){let d=this._sourceBuffers;if(this._mediaElement.readyState===0||this._mediaSource.readyState!=="open"||d.video&&d.video.updating||d.audio&&d.audio.updating)return;let f=this._mediaSource.duration,p=this._pendingMediaDuration;p>0&&(isNaN(f)||p>f)&&(g.v(this.TAG,`Update MediaSource duration from ${f} to ${p}`),this._mediaSource.duration=p),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}_doRemoveRanges(){for(let d in this._pendingRemoveRanges){if(!this._sourceBuffers[d]||this._sourceBuffers[d].updating)continue;let f=this._sourceBuffers[d],p=this._pendingRemoveRanges[d];for(;p.length&&!f.updating;){let E=p.shift();f.remove(E.start,E.end)}}}_doAppendSegments(){let d=this._pendingSegments;for(let f in d)if(!(!this._sourceBuffers[f]||this._sourceBuffers[f].updating)&&d[f].length>0){let p=d[f].shift();if(p.timestampOffset){let E=this._sourceBuffers[f].timestampOffset,T=p.timestampOffset/1e3;Math.abs(E-T)>.1&&(g.v(this.TAG,`Update MPEG audio timestampOffset from ${E} to ${T}`),this._sourceBuffers[f].timestampOffset=T),delete p.timestampOffset}if(!p.data||p.data.byteLength===0)continue;try{this._sourceBuffers[f].appendBuffer(p.data),this._isBufferFull=!1,f==="video"&&p.hasOwnProperty("info")&&this._idrList.appendArray(p.info.syncPoints)}catch(E){this._pendingSegments[f].unshift(p),E.code===22?(this._isBufferFull||this._emitter.emit(Ut.BUFFER_FULL),this._isBufferFull=!0):(g.e(this.TAG,E.message),this._emitter.emit(Ut.ERROR,{code:E.code,msg:E.message}))}}}_onSourceOpen(){if(g.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let d=this._pendingSourceBufferInit;for(;d.length;){let f=d.shift();this.appendInitSegment(f,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(Ut.SOURCE_OPEN)}_onSourceEnded(){g.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){g.v(this.TAG,"MediaSource onSourceClose"),this._mediaSource&&this.e!=null&&(this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._mediaSource.removeEventListener("sourceended",this.e.onSourceEnded),this._mediaSource.removeEventListener("sourceclose",this.e.onSourceClose))}_hasPendingSegments(){let d=this._pendingSegments;return d.video.length>0||d.audio.length>0}_hasPendingRemoveRanges(){let d=this._pendingRemoveRanges;return d.video.length>0||d.audio.length>0}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(Ut.UPDATE_END)}_onSourceBufferError(d){g.e(this.TAG,`SourceBuffer Error: ${d}`)}}var ui=wi;const tt={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},Lt={NETWORK_EXCEPTION:H.EXCEPTION,NETWORK_STATUS_CODE_INVALID:H.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:H.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:H.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:z.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:z.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:z.CODEC_UNSUPPORTED};class St{constructor(d,f){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new(Y()),this._config=ve(),typeof f=="object"&&Object.assign(this._config,f),d.type.toLowerCase()!=="flv")throw new we("FlvPlayer requires an flv MediaDataSource input!");d.isLive===!0&&(this._config.isLive=!0),this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this),onvSeeking:this._onvSeeking.bind(this),onvCanPlay:this._onvCanPlay.bind(this),onvStalled:this._onvStalled.bind(this),onvProgress:this._onvProgress.bind(this)},self.performance&&self.performance.now?this._now=self.performance.now.bind(self.performance):this._now=Date.now,this._pendingSeekTime=null,this._requestSetTime=!1,this._seekpointRecord=null,this._progressChecker=null,this._mediaDataSource=d,this._mediaElement=null,this._msectl=null,this._transmuxer=null,this._mseSourceOpened=!1,this._hasPendingLoad=!1,this._receivedCanPlay=!1,this._mediaInfo=null,this._statisticsInfo=null;let p=ae.chrome&&(ae.version.major<50||ae.version.major===50&&ae.version.build<2661);this._alwaysSeekKeyframe=!!(p||ae.msedge||ae.msie),this._alwaysSeekKeyframe&&(this._config.accurateSeek=!1)}destroy(){this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._transmuxer&&this.unload(),this._mediaElement&&this.detachMediaElement(),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(d,f){d===_e.MEDIA_INFO?this._mediaInfo!=null&&Promise.resolve().then(()=>{this._emitter.emit(_e.MEDIA_INFO,this.mediaInfo)}):d===_e.STATISTICS_INFO&&this._statisticsInfo!=null&&Promise.resolve().then(()=>{this._emitter.emit(_e.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(d,f)}off(d,f){this._emitter.removeListener(d,f)}attachMediaElement(d){if(this._mediaElement=d,d.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),d.addEventListener("seeking",this.e.onvSeeking),d.addEventListener("canplay",this.e.onvCanPlay),d.addEventListener("stalled",this.e.onvStalled),d.addEventListener("progress",this.e.onvProgress),this._msectl=new ui(this._config),this._msectl.on(Ut.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(Ut.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(Ut.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(Ut.ERROR,f=>{this._emitter.emit(_e.ERROR,tt.MEDIA_ERROR,Lt.MEDIA_MSE_ERROR,f)}),this._msectl.attachMediaElement(d),this._pendingSeekTime!=null)try{d.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(f){}}detachMediaElement(){this._mediaElement&&(this._msectl.detachMediaElement(),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement.removeEventListener("seeking",this.e.onvSeeking),this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay),this._mediaElement.removeEventListener("stalled",this.e.onvStalled),this._mediaElement.removeEventListener("progress",this.e.onvProgress),this._mediaElement=null),this._msectl&&(this._msectl.destroy(),this._msectl=null)}load(){if(!this._mediaElement)throw new de("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new de("FlvPlayer.load() has been called, please call unload() first!");if(!this._hasPendingLoad){if(this._config.deferLoadAfterSourceOpen&&this._mseSourceOpened===!1){this._hasPendingLoad=!0;return}this._mediaElement.readyState>0&&(this._requestSetTime=!0,this._mediaElement.currentTime=0),this._transmuxer=new Vi(this._mediaDataSource,this._config),this._transmuxer.on(pe.INIT_SEGMENT,(d,f)=>{this._msectl.appendInitSegment(f)}),this._transmuxer.on(pe.MEDIA_SEGMENT,(d,f)=>{if(this._msectl.appendMediaSegment(f),this._config.lazyLoad&&!this._config.isLive){let p=this._mediaElement.currentTime;f.info.endDts>=(p+this._config.lazyLoadMaxDuration)*1e3&&this._progressChecker==null&&(g.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(pe.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(_e.LOADING_COMPLETE)}),this._transmuxer.on(pe.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(_e.RECOVERED_EARLY_EOF)}),this._transmuxer.on(pe.IO_ERROR,(d,f)=>{this._emitter.emit(_e.ERROR,tt.NETWORK_ERROR,d,f)}),this._transmuxer.on(pe.DEMUX_ERROR,(d,f)=>{this._emitter.emit(_e.ERROR,tt.MEDIA_ERROR,d,{code:-1,msg:f})}),this._transmuxer.on(pe.MEDIA_INFO,d=>{this._mediaInfo=d,this._emitter.emit(_e.MEDIA_INFO,Object.assign({},d))}),this._transmuxer.on(pe.METADATA_ARRIVED,d=>{this._emitter.emit(_e.METADATA_ARRIVED,d)}),this._transmuxer.on(pe.SCRIPTDATA_ARRIVED,d=>{this._emitter.emit(_e.SCRIPTDATA_ARRIVED,d)}),this._transmuxer.on(pe.STATISTICS_INFO,d=>{this._statisticsInfo=this._fillStatisticsInfo(d),this._emitter.emit(_e.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(pe.RECOMMEND_SEEKPOINT,d=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=d/1e3)}),this._transmuxer.open()}}unload(){this._mediaElement&&this._mediaElement.pause(),this._msectl&&this._msectl.seek(0),this._transmuxer&&(this._transmuxer.close(),this._transmuxer.destroy(),this._transmuxer=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(d){this._mediaElement.volume=d}get muted(){return this._mediaElement.muted}set muted(d){this._mediaElement.muted=d}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(d){this._mediaElement?this._internalSeek(d):this._pendingSeekTime=d}get mediaInfo(){return Object.assign({},this._mediaInfo)}get statisticsInfo(){return this._statisticsInfo==null&&(this._statisticsInfo={}),this._statisticsInfo=this._fillStatisticsInfo(this._statisticsInfo),Object.assign({},this._statisticsInfo)}_fillStatisticsInfo(d){if(d.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return d;let f=!0,p=0,E=0;if(this._mediaElement.getVideoPlaybackQuality){let T=this._mediaElement.getVideoPlaybackQuality();p=T.totalVideoFrames,E=T.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(p=this._mediaElement.webkitDecodedFrameCount,E=this._mediaElement.webkitDroppedFrameCount):f=!1;return f&&(d.decodedFrames=p,d.droppedFrames=E),d}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let d=this._mediaElement.buffered,f=this._mediaElement.currentTime,p=0,E=0;for(let T=0;T<d.length;T++){let O=d.start(T),U=d.end(T);if(O<=f&&f<U){p=O,E=U;break}}E>=f+this._config.lazyLoadMaxDuration&&this._progressChecker==null&&(g.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){g.v(this.TAG,"MSE SourceBuffer is full, suspend transmuxing task"),this._progressChecker==null&&this._suspendTransmuxer()}_suspendTransmuxer(){this._transmuxer&&(this._transmuxer.pause(),this._progressChecker==null&&(this._progressChecker=window.setInterval(this._checkProgressAndResume.bind(this),1e3)))}_checkProgressAndResume(){let d=this._mediaElement.currentTime,f=this._mediaElement.buffered,p=!1;for(let E=0;E<f.length;E++){let T=f.start(E),O=f.end(E);if(d>=T&&d<O){d>=O-this._config.lazyLoadRecoverDuration&&(p=!0);break}}p&&(window.clearInterval(this._progressChecker),this._progressChecker=null,p&&(g.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(d){let f=this._mediaElement.buffered;for(let p=0;p<f.length;p++){let E=f.start(p),T=f.end(p);if(d>=E&&d<T)return!0}return!1}_internalSeek(d){let f=this._isTimepointBuffered(d),p=!1,E=0;if(d<1&&this._mediaElement.buffered.length>0){let T=this._mediaElement.buffered.start(0);(T<1&&d<T||ae.safari)&&(p=!0,E=ae.safari?.1:T)}if(p)this._requestSetTime=!0,this._mediaElement.currentTime=E;else if(f){if(!this._alwaysSeekKeyframe)this._requestSetTime=!0,this._mediaElement.currentTime=d;else{let T=this._msectl.getNearestKeyframe(Math.floor(d*1e3));this._requestSetTime=!0,T!=null?this._mediaElement.currentTime=T.dts/1e3:this._mediaElement.currentTime=d}this._progressChecker!=null&&this._checkProgressAndResume()}else this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(d),this._transmuxer.seek(Math.floor(d*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=d)}_checkAndApplyUnbufferedSeekpoint(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){let d=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(d)||(this._progressChecker!=null&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(d),this._transmuxer.seek(Math.floor(d*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=d))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_checkAndResumeStuckPlayback(d){let f=this._mediaElement;if(d||!this._receivedCanPlay||f.readyState<2){let p=f.buffered;p.length>0&&f.currentTime<p.start(0)&&(g.w(this.TAG,`Playback seems stuck at ${f.currentTime}, seek to ${p.start(0)}`),this._requestSetTime=!0,this._mediaElement.currentTime=p.start(0),this._mediaElement.removeEventListener("progress",this.e.onvProgress))}else this._mediaElement.removeEventListener("progress",this.e.onvProgress)}_onvLoadedMetadata(d){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}_onvSeeking(d){let f=this._mediaElement.currentTime,p=this._mediaElement.buffered;if(this._requestSetTime){this._requestSetTime=!1;return}if(f<1&&p.length>0){let E=p.start(0);if(E<1&&f<E||ae.safari){this._requestSetTime=!0,this._mediaElement.currentTime=ae.safari?.1:E;return}}if(this._isTimepointBuffered(f)){if(this._alwaysSeekKeyframe){let E=this._msectl.getNearestKeyframe(Math.floor(f*1e3));E!=null&&(this._requestSetTime=!0,this._mediaElement.currentTime=E.dts/1e3)}this._progressChecker!=null&&this._checkProgressAndResume();return}this._seekpointRecord={seekPoint:f,recordTime:this._now()},window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_onvCanPlay(d){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}_onvStalled(d){this._checkAndResumeStuckPlayback(!0)}_onvProgress(d){this._checkAndResumeStuckPlayback()}}var ti=St;class oi{constructor(d,f){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new(Y()),this._config=ve(),typeof f=="object"&&Object.assign(this._config,f),d.type.toLowerCase()==="flv")throw new we("NativePlayer does't support flv MediaDataSource input!");if(d.hasOwnProperty("segments"))throw new we(`NativePlayer(${d.type}) doesn't support multipart playback!`);this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=d,this._mediaElement=null}destroy(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(d,f){d===_e.MEDIA_INFO?this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(()=>{this._emitter.emit(_e.MEDIA_INFO,this.mediaInfo)}):d===_e.STATISTICS_INFO&&this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(()=>{this._emitter.emit(_e.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(d,f)}off(d,f){this._emitter.removeListener(d,f)}attachMediaElement(d){if(this._mediaElement=d,d.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._pendingSeekTime!=null)try{d.currentTime=this._pendingSeekTime,this._pendingSeekTime=null}catch(f){}}detachMediaElement(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src"),this._mediaElement.removeEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._mediaElement=null),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}load(){if(!this._mediaElement)throw new de("HTMLMediaElement must be attached before load()!");this._mediaElement.src=this._mediaDataSource.url,this._mediaElement.readyState>0&&(this._mediaElement.currentTime=0),this._mediaElement.preload="auto",this._mediaElement.load(),this._statisticsReporter=window.setInterval(this._reportStatisticsInfo.bind(this),this._config.statisticsInfoReportInterval)}unload(){this._mediaElement&&(this._mediaElement.src="",this._mediaElement.removeAttribute("src")),this._statisticsReporter!=null&&(window.clearInterval(this._statisticsReporter),this._statisticsReporter=null)}play(){return this._mediaElement.play()}pause(){this._mediaElement.pause()}get type(){return this._type}get buffered(){return this._mediaElement.buffered}get duration(){return this._mediaElement.duration}get volume(){return this._mediaElement.volume}set volume(d){this._mediaElement.volume=d}get muted(){return this._mediaElement.muted}set muted(d){this._mediaElement.muted=d}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(d){this._mediaElement?this._mediaElement.currentTime=d:this._pendingSeekTime=d}get mediaInfo(){let f={mimeType:(this._mediaElement instanceof HTMLAudioElement?"audio/":"video/")+this._mediaDataSource.type};return this._mediaElement&&(f.duration=Math.floor(this._mediaElement.duration*1e3),this._mediaElement instanceof HTMLVideoElement&&(f.width=this._mediaElement.videoWidth,f.height=this._mediaElement.videoHeight)),f}get statisticsInfo(){let d={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return d;let f=!0,p=0,E=0;if(this._mediaElement.getVideoPlaybackQuality){let T=this._mediaElement.getVideoPlaybackQuality();p=T.totalVideoFrames,E=T.droppedVideoFrames}else this._mediaElement.webkitDecodedFrameCount!=null?(p=this._mediaElement.webkitDecodedFrameCount,E=this._mediaElement.webkitDroppedFrameCount):f=!1;return f&&(d.decodedFrames=p,d.droppedFrames=E),d}_onvLoadedMetadata(d){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(_e.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(_e.STATISTICS_INFO,this.statisticsInfo)}}var ci=oi;J.install();function Ht(Fe,d){let f=Fe;if(f==null||typeof f!="object")throw new we("MediaDataSource must be an javascript object!");if(!f.hasOwnProperty("type"))throw new we("MediaDataSource must has type field to indicate video file type!");switch(f.type){case"flv":return new ti(f,d);default:return new ci(f,d)}}function Ii(){return ke.supportMSEH264Playback()}function Ft(){return ke.getFeatureList()}let si={};si.createPlayer=Ht,si.isSupported=Ii,si.getFeatureList=Ft,si.BaseLoader=st,si.LoaderStatus=D,si.LoaderErrors=H,si.Events=_e,si.ErrorTypes=tt,si.ErrorDetails=Lt,si.FlvPlayer=ti,si.NativePlayer=ci,si.LoggingControl=ye,Object.defineProperty(si,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var Pi=si},29509:function(ii,qe,x){"use strict";x.d(qe,{o2:function(){return A},yT:function(){return g}});var _=x(94480),J=x(34998);const Ae=J.i.map(te=>`${te}-inverse`),Y=["success","processing","error","default","warning"];function A(te){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0)?[].concat((0,_.Z)(Ae),(0,_.Z)(J.i)).includes(te):J.i.includes(te)}function g(te){return Y.includes(te)}},99402:function(ii,qe,x){"use strict";x.d(qe,{T:function(){return J},n:function(){return _}});function _(Ae){return["small","middle","large"].includes(Ae)}function J(Ae){return Ae?typeof Ae=="number"&&!Number.isNaN(Ae):!1}},52838:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return g}});var _=x(37645);function J(te,G,re,de){if(de===!1)return{adjustX:!1,adjustY:!1};const we=de&&typeof de=="object"?de:{},Ie={};switch(te){case"top":case"bottom":Ie.shiftX=G.arrowOffsetHorizontal*2+re,Ie.shiftY=!0,Ie.adjustY=!0;break;case"left":case"right":Ie.shiftY=G.arrowOffsetVertical*2+re,Ie.shiftX=!0,Ie.adjustX=!0;break}const D=Object.assign(Object.assign({},Ie),we);return D.shiftX||(D.adjustX=!0),D.shiftY||(D.adjustY=!0),D}const Ae={left:{points:["cr","cl"]},right:{points:["cl","cr"]},top:{points:["bc","tc"]},bottom:{points:["tc","bc"]},topLeft:{points:["bl","tl"]},leftTop:{points:["tr","tl"]},topRight:{points:["br","tr"]},rightTop:{points:["tl","tr"]},bottomRight:{points:["tr","br"]},rightBottom:{points:["bl","br"]},bottomLeft:{points:["tl","bl"]},leftBottom:{points:["br","bl"]}},Y={topLeft:{points:["bl","tc"]},leftTop:{points:["tr","cl"]},topRight:{points:["br","tc"]},rightTop:{points:["tl","cr"]},bottomRight:{points:["tr","bc"]},rightBottom:{points:["bl","cr"]},bottomLeft:{points:["tl","bc"]},leftBottom:{points:["br","cl"]}},A=new Set(["topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"]);function g(te){const{arrowWidth:G,autoAdjustOverflow:re,arrowPointAtCenter:de,offset:we,borderRadius:Ie,visibleFirst:D}=te,H=G/2,st={};return Object.keys(Ae).forEach(Ge=>{const Ce=de&&Y[Ge]||Ae[Ge],ae=Object.assign(Object.assign({},Ce),{offset:[0,0],dynamicInset:!0});switch(st[Ge]=ae,A.has(Ge)&&(ae.autoArrow=!1),Ge){case"top":case"topLeft":case"topRight":ae.offset[1]=-H-we;break;case"bottom":case"bottomLeft":case"bottomRight":ae.offset[1]=H+we;break;case"left":case"leftTop":case"leftBottom":ae.offset[0]=-H-we;break;case"right":case"rightTop":case"rightBottom":ae.offset[0]=H+we;break}const F=(0,_.wZ)({contentRadius:Ie,limitVerticalRadius:!0});if(de)switch(Ge){case"topLeft":case"bottomLeft":ae.offset[0]=-F.arrowOffsetHorizontal-H;break;case"topRight":case"bottomRight":ae.offset[0]=F.arrowOffsetHorizontal+H;break;case"leftTop":case"rightTop":ae.offset[1]=-F.arrowOffsetHorizontal*2+H;break;case"leftBottom":case"rightBottom":ae.offset[1]=F.arrowOffsetHorizontal*2-H;break}ae.overflow=J(Ge,F,G,re),D&&(ae.htmlRegion="visibleFirst")}),st}},19563:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return Ye}});var _=x(59301),J=x(33853),Ae=x(38819),Y=x(92310),A=x.n(Y),g=x(96478),te=x(6089),G=x(18929),re=x(2738),de=x(75030),Ie=ye=>typeof ye!="object"&&typeof ye!="function"||ye===null,D=x(52838),H=x(45915),st=x(22703),Ge=x(32383),Ce=x(55743),ae=x(48755),F=x(83397),k=x(93041),X=x(78857),le=x(57700),me=x(36237),Xe=x(63356),se=x(46e3),vt=x(93873),yt=x(34925),Je=x(37645),nt=x(36305),ne=x(16931),ee=x(51636),K=ye=>{const{componentCls:Ve,menuCls:We,colorError:Mt,colorTextLightSolid:jt}=ye,_t=`${We}-item`;return{[`${Ve}, ${Ve}-menu-submenu`]:{[`${We} ${_t}`]:{[`&${_t}-danger:not(${_t}-disabled)`]:{color:Mt,"&:hover":{color:jt,backgroundColor:Mt}}}}}};const Se=ye=>{const{componentCls:Ve,menuCls:We,zIndexPopup:Mt,dropdownArrowDistance:jt,sizePopupArrow:_t,antCls:Le,iconCls:It,motionDurationMid:je,paddingBlock:Xt,fontSize:oe,dropdownEdgeChildPadding:Me,colorTextDisabled:N,fontSizeIcon:Ue,controlPaddingHorizontal:z,colorBgElevated:$}=ye;return[{[Ve]:{position:"absolute",top:-9999,left:{_skip_check_:!0,value:-9999},zIndex:Mt,display:"block","&::before":{position:"absolute",insetBlock:ye.calc(_t).div(2).sub(jt).equal(),zIndex:-9999,opacity:1e-4,content:'""'},"&-menu-vertical":{maxHeight:"100vh",overflowY:"auto"},[`&-trigger${Le}-btn`]:{[`& > ${It}-down, & > ${Le}-btn-icon > ${It}-down`]:{fontSize:Ue}},[`${Ve}-wrap`]:{position:"relative",[`${Le}-btn > ${It}-down`]:{fontSize:Ue},[`${It}-down::before`]:{transition:`transform ${je}`}},[`${Ve}-wrap-open`]:{[`${It}-down::before`]:{transform:"rotate(180deg)"}},"\n &-hidden,\n &-menu-hidden,\n &-menu-submenu-hidden\n ":{display:"none"},[`&${Le}-slide-down-enter${Le}-slide-down-enter-active${Ve}-placement-bottomLeft,
&${Le}-slide-down-appear${Le}-slide-down-appear-active${Ve}-placement-bottomLeft,
&${Le}-slide-down-enter${Le}-slide-down-enter-active${Ve}-placement-bottom,
&${Le}-slide-down-appear${Le}-slide-down-appear-active${Ve}-placement-bottom,
&${Le}-slide-down-enter${Le}-slide-down-enter-active${Ve}-placement-bottomRight,
&${Le}-slide-down-appear${Le}-slide-down-appear-active${Ve}-placement-bottomRight`]:{animationName:se.fJ},[`&${Le}-slide-up-enter${Le}-slide-up-enter-active${Ve}-placement-topLeft,
&${Le}-slide-up-appear${Le}-slide-up-appear-active${Ve}-placement-topLeft,
&${Le}-slide-up-enter${Le}-slide-up-enter-active${Ve}-placement-top,
&${Le}-slide-up-appear${Le}-slide-up-appear-active${Ve}-placement-top,
&${Le}-slide-up-enter${Le}-slide-up-enter-active${Ve}-placement-topRight,
&${Le}-slide-up-appear${Le}-slide-up-appear-active${Ve}-placement-topRight`]:{animationName:se.Qt},[`&${Le}-slide-down-leave${Le}-slide-down-leave-active${Ve}-placement-bottomLeft,
&${Le}-slide-down-leave${Le}-slide-down-leave-active${Ve}-placement-bottom,
&${Le}-slide-down-leave${Le}-slide-down-leave-active${Ve}-placement-bottomRight`]:{animationName:se.Uw},[`&${Le}-slide-up-leave${Le}-slide-up-leave-active${Ve}-placement-topLeft,
&${Le}-slide-up-leave${Le}-slide-up-leave-active${Ve}-placement-top,
&${Le}-slide-up-leave${Le}-slide-up-leave-active${Ve}-placement-topRight`]:{animationName:se.ly}}},(0,Je.ZP)(ye,$,{arrowPlacement:{top:!0,bottom:!0}}),{[`${Ve} ${We}`]:{position:"relative",margin:0},[`${We}-submenu-popup`]:{position:"absolute",zIndex:Mt,background:"transparent",boxShadow:"none",transformOrigin:"0 0","ul, li":{listStyle:"none",margin:0}},[`${Ve}, ${Ve}-menu-submenu`]:Object.assign(Object.assign({},(0,Xe.Wf)(ye)),{[We]:Object.assign(Object.assign({padding:Me,listStyleType:"none",backgroundColor:$,backgroundClip:"padding-box",borderRadius:ye.borderRadiusLG,outline:"none",boxShadow:ye.boxShadowSecondary},(0,Xe.Qy)(ye)),{"&:empty":{padding:0,boxShadow:"none"},[`${We}-item-group-title`]:{padding:`${(0,me.unit)(Xt)} ${(0,me.unit)(z)}`,color:ye.colorTextDescription,transition:`all ${je}`},[`${We}-item`]:{position:"relative",display:"flex",alignItems:"center"},[`${We}-item-icon`]:{minWidth:oe,marginInlineEnd:ye.marginXS,fontSize:ye.fontSizeSM},[`${We}-title-content`]:{flex:"auto","&-with-extra":{display:"inline-flex",alignItems:"center",width:"100%"},"> a":{color:"inherit",transition:`all ${je}`,"&:hover":{color:"inherit"},"&::after":{position:"absolute",inset:0,content:'""'}},[`${We}-item-extra`]:{paddingInlineStart:ye.padding,marginInlineStart:"auto",fontSize:ye.fontSizeSM,color:ye.colorTextDescription}},[`${We}-item, ${We}-submenu-title`]:Object.assign(Object.assign({display:"flex",margin:0,padding:`${(0,me.unit)(Xt)} ${(0,me.unit)(z)}`,color:ye.colorText,fontWeight:"normal",fontSize:oe,lineHeight:ye.lineHeight,cursor:"pointer",transition:`all ${je}`,borderRadius:ye.borderRadiusSM,"&:hover, &-active":{backgroundColor:ye.controlItemBgHover}},(0,Xe.Qy)(ye)),{"&-selected":{color:ye.colorPrimary,backgroundColor:ye.controlItemBgActive,"&:hover, &-active":{backgroundColor:ye.controlItemBgActiveHover}},"&-disabled":{color:N,cursor:"not-allowed","&:hover":{color:N,backgroundColor:$,cursor:"not-allowed"},a:{pointerEvents:"none"}},"&-divider":{height:1,margin:`${(0,me.unit)(ye.marginXXS)} 0`,overflow:"hidden",lineHeight:0,backgroundColor:ye.colorSplit},[`${Ve}-menu-submenu-expand-icon`]:{position:"absolute",insetInlineEnd:ye.paddingXS,[`${Ve}-menu-submenu-arrow-icon`]:{marginInlineEnd:"0 !important",color:ye.colorTextDescription,fontSize:Ue,fontStyle:"normal"}}}),[`${We}-item-group-list`]:{margin:`0 ${(0,me.unit)(ye.marginXS)}`,padding:0,listStyle:"none"},[`${We}-submenu-title`]:{paddingInlineEnd:ye.calc(z).add(ye.fontSizeSM).equal()},[`${We}-submenu-vertical`]:{position:"relative"},[`${We}-submenu${We}-submenu-disabled ${Ve}-menu-submenu-title`]:{[`&, ${Ve}-menu-submenu-arrow-icon`]:{color:N,backgroundColor:$,cursor:"not-allowed"}},[`${We}-submenu-selected ${Ve}-menu-submenu-title`]:{color:ye.colorPrimary}})})},[(0,se.oN)(ye,"slide-up"),(0,se.oN)(ye,"slide-down"),(0,vt.Fm)(ye,"move-up"),(0,vt.Fm)(ye,"move-down"),(0,yt._y)(ye,"zoom-big")]]},ze=ye=>Object.assign(Object.assign({zIndexPopup:ye.zIndexPopupBase+50,paddingBlock:(ye.controlHeight-ye.fontSize*ye.lineHeight)/2},(0,Je.wZ)({contentRadius:ye.borderRadiusLG,limitVerticalRadius:!0})),(0,nt.w)(ye));var ve=(0,ne.I$)("Dropdown",ye=>{const{marginXXS:Ve,sizePopupArrow:We,paddingXXS:Mt,componentCls:jt}=ye,_t=(0,ee.mergeToken)(ye,{menuCls:`${jt}-menu`,dropdownArrowDistance:ye.calc(We).div(2).add(Ve).equal(),dropdownEdgeChildPadding:Mt});return[Se(_t),K(_t)]},ze,{resetStyle:!1});const Pe=null,ke=ye=>{var Ve;const{menu:We,arrow:Mt,prefixCls:jt,children:_t,trigger:Le,disabled:It,dropdownRender:je,getPopupContainer:Xt,overlayClassName:oe,rootClassName:Me,overlayStyle:N,open:Ue,onOpenChange:z,visible:$,onVisibleChange:M,mouseEnterDelay:w=.15,mouseLeaveDelay:P=.1,autoAdjustOverflow:V=!0,placement:C="",overlay:Ee,transitionName:xe}=ye,{getPopupContainer:Ke,getPrefixCls:ot,direction:Rt,dropdown:et}=_.useContext(ae.E_),ut=(0,Ge.ln)("Dropdown"),Et=_.useMemo(()=>{const Ft=ot();return xe!==void 0?xe:C.includes("top")?`${Ft}-slide-down`:`${Ft}-slide-up`},[ot,C,xe]),Tt=_.useMemo(()=>C?C.includes("Center")?C.slice(0,C.indexOf("Center")):C:Rt==="rtl"?"bottomRight":"bottomLeft",[C,Rt]),lt=ot("dropdown",jt),pe=(0,F.Z)(lt),[pt,Ei,_i]=ve(lt,pe),[,li]=(0,le.ZP)(),Ai=_.Children.only(Ie(_t)?_.createElement("span",null,_t):_t),Vi=(0,st.Tm)(Ai,{className:A()(`${lt}-trigger`,{[`${lt}-rtl`]:Rt==="rtl"},Ai.props.className),disabled:(Ve=Ai.props.disabled)!==null&&Ve!==void 0?Ve:It}),Ti=It?[]:Le,Ut=!!(Ti!=null&&Ti.includes("contextMenu")),[wi,ui]=(0,G.Z)(!1,{value:Ue!=null?Ue:$}),tt=(0,te.Z)(Ft=>{z==null||z(Ft,{source:"trigger"}),M==null||M(Ft),ui(Ft)}),Lt=A()(oe,Me,Ei,_i,pe,et==null?void 0:et.className,{[`${lt}-rtl`]:Rt==="rtl"}),St=(0,D.Z)({arrowPointAtCenter:typeof Mt=="object"&&Mt.pointAtCenter,autoAdjustOverflow:V,offset:li.marginXXS,arrowWidth:Mt?li.sizePopupArrow:0,borderRadius:li.borderRadius}),ti=_.useCallback(()=>{We!=null&&We.selectable&&(We!=null&&We.multiple)||(z==null||z(!1,{source:"menu"}),ui(!1))},[We==null?void 0:We.selectable,We==null?void 0:We.multiple]),oi=()=>{let Ft;return We!=null&&We.items?Ft=_.createElement(k.default,Object.assign({},We)):typeof Ee=="function"?Ft=Ee():Ft=Ee,je&&(Ft=je(Ft)),Ft=_.Children.only(typeof Ft=="string"?_.createElement("span",null,Ft):Ft),_.createElement(X.J,{prefixCls:`${lt}-menu`,rootClassName:A()(_i,pe),expandIcon:_.createElement("span",{className:`${lt}-menu-submenu-arrow`},Rt==="rtl"?_.createElement(J.Z,{className:`${lt}-menu-submenu-arrow-icon`}):_.createElement(Ae.Z,{className:`${lt}-menu-submenu-arrow-icon`})),mode:"vertical",selectable:!1,onClick:ti,validator:si=>{let{mode:Pi}=si}},Ft)},[ci,Ht]=(0,de.Cn)("Dropdown",N==null?void 0:N.zIndex);let Ii=_.createElement(g.Z,Object.assign({alignPoint:Ut},(0,re.Z)(ye,["rootClassName"]),{mouseEnterDelay:w,mouseLeaveDelay:P,visible:wi,builtinPlacements:St,arrow:!!Mt,overlayClassName:Lt,prefixCls:lt,getPopupContainer:Xt||Ke,transitionName:Et,trigger:Ti,overlay:oi,placement:Tt,onVisibleChange:tt,overlayStyle:Object.assign(Object.assign(Object.assign({},et==null?void 0:et.style),N),{zIndex:ci})}),Vi);return ci&&(Ii=_.createElement(Ce.Z.Provider,{value:Ht},Ii)),pt(Ii)},rt=(0,H.Z)(ke,"align",void 0,"dropdown",ye=>ye),_e=ye=>_.createElement(rt,Object.assign({},ye),_.createElement("span",null));ke._InternalPanelDoNotUseOrYouWillBeFired=_e;var Ye=ke},75727:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return H}});var _=x(19563),J=x(59301),Ae=x(18785),Y=x(92310),A=x.n(Y),g=x(7939),te=x(48755),G=x(44104),re=x(70045),de=function(st,Ge){var Ce={};for(var ae in st)Object.prototype.hasOwnProperty.call(st,ae)&&Ge.indexOf(ae)<0&&(Ce[ae]=st[ae]);if(st!=null&&typeof Object.getOwnPropertySymbols=="function")for(var F=0,ae=Object.getOwnPropertySymbols(st);F<ae.length;F++)Ge.indexOf(ae[F])<0&&Object.prototype.propertyIsEnumerable.call(st,ae[F])&&(Ce[ae[F]]=st[ae[F]]);return Ce};const we=st=>{const{getPopupContainer:Ge,getPrefixCls:Ce,direction:ae}=J.useContext(te.E_),{prefixCls:F,type:k="default",danger:X,disabled:le,loading:me,onClick:Xe,htmlType:se,children:vt,className:yt,menu:Je,arrow:nt,autoFocus:ne,overlay:ee,trigger:ce,align:K,open:Se,onOpenChange:ze,placement:ve,getPopupContainer:Pe,href:ke,icon:rt=J.createElement(Ae.Z,null),title:_e,buttonsRender:Ye=w=>w,mouseEnterDelay:ye,mouseLeaveDelay:Ve,overlayClassName:We,overlayStyle:Mt,destroyPopupOnHide:jt,dropdownRender:_t}=st,Le=de(st,["prefixCls","type","danger","disabled","loading","onClick","htmlType","children","className","menu","arrow","autoFocus","overlay","trigger","align","open","onOpenChange","placement","getPopupContainer","href","icon","title","buttonsRender","mouseEnterDelay","mouseLeaveDelay","overlayClassName","overlayStyle","destroyPopupOnHide","dropdownRender"]),It=Ce("dropdown",F),je=`${It}-button`,Xt={menu:Je,arrow:nt,autoFocus:ne,align:K,disabled:le,trigger:le?[]:ce,onOpenChange:ze,getPopupContainer:Pe||Ge,mouseEnterDelay:ye,mouseLeaveDelay:Ve,overlayClassName:We,overlayStyle:Mt,destroyPopupOnHide:jt,dropdownRender:_t},{compactSize:oe,compactItemClassnames:Me}=(0,re.ri)(It,ae),N=A()(je,Me,yt);"overlay"in st&&(Xt.overlay=ee),"open"in st&&(Xt.open=Se),"placement"in st?Xt.placement=ve:Xt.placement=ae==="rtl"?"bottomLeft":"bottomRight";const Ue=J.createElement(g.ZP,{type:k,danger:X,disabled:le,loading:me,onClick:Xe,htmlType:se,href:ke,title:_e},vt),z=J.createElement(g.ZP,{type:k,danger:X,icon:rt}),[$,M]=Ye([Ue,z]);return J.createElement(G.Z.Compact,Object.assign({className:N,size:oe,block:!0},Le),$,J.createElement(_.Z,Object.assign({},Xt),M))};we.__ANT_BUTTON=!0;var Ie=we;const D=_.Z;D.Button=Ie;var H=D},24303:function(ii,qe,x){"use strict";x.d(qe,{D:function(){return Xe},Z:function(){return yt}});var _=x(59301),J=x(54476),Ae={icon:{tag:"svg",attrs:{viewBox:"0 0 1024 1024",focusable:"false"},children:[{tag:"path",attrs:{d:"M912 192H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 284H328c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h584c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM104 228a56 56 0 10112 0 56 56 0 10-112 0zm0 284a56 56 0 10112 0 56 56 0 10-112 0zm0 284a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"bars",theme:"outlined"},Y=Ae,A=x(7657),g=function(nt,ne){return _.createElement(A.Z,(0,J.Z)({},nt,{ref:ne,icon:Y}))},te=_.forwardRef(g),G=te,re=x(33853),de=x(38819),we=x(92310),Ie=x.n(we),D=x(2738),H=x(48755),st=x(6989),Ge=x(36237),Ce=x(48923),ae=x(16931);const F=Je=>{const{componentCls:nt,siderBg:ne,motionDurationMid:ee,motionDurationSlow:ce,antCls:K,triggerHeight:Se,triggerColor:ze,triggerBg:ve,headerHeight:Pe,zeroTriggerWidth:ke,zeroTriggerHeight:rt,borderRadiusLG:_e,lightSiderBg:Ye,lightTriggerColor:ye,lightTriggerBg:Ve,bodyBg:We}=Je;return{[nt]:{position:"relative",minWidth:0,background:ne,transition:`all ${ee}, background 0s`,"&-has-trigger":{paddingBottom:Se},"&-right":{order:1},[`${nt}-children`]:{height:"100%",marginTop:-.1,paddingTop:.1,[`${K}-menu${K}-menu-inline-collapsed`]:{width:"auto"}},[`&-zero-width ${nt}-children`]:{overflow:"hidden"},[`${nt}-trigger`]:{position:"fixed",bottom:0,zIndex:1,height:Se,color:ze,lineHeight:(0,Ge.unit)(Se),textAlign:"center",background:ve,cursor:"pointer",transition:`all ${ee}`},[`${nt}-zero-width-trigger`]:{position:"absolute",top:Pe,insetInlineEnd:Je.calc(ke).mul(-1).equal(),zIndex:1,width:ke,height:rt,color:ze,fontSize:Je.fontSizeXL,display:"flex",alignItems:"center",justifyContent:"center",background:ne,borderRadius:`0 ${(0,Ge.unit)(_e)} ${(0,Ge.unit)(_e)} 0`,cursor:"pointer",transition:`background ${ce} ease`,"&::after":{position:"absolute",inset:0,background:"transparent",transition:`all ${ce}`,content:'""'},"&:hover::after":{background:"rgba(255, 255, 255, 0.2)"},"&-right":{insetInlineStart:Je.calc(ke).mul(-1).equal(),borderRadius:`${(0,Ge.unit)(_e)} 0 0 ${(0,Ge.unit)(_e)}`}},"&-light":{background:Ye,[`${nt}-trigger`]:{color:ye,background:Ve},[`${nt}-zero-width-trigger`]:{color:ye,background:Ve,border:`1px solid ${We}`,borderInlineStart:0}}}}};var k=(0,ae.I$)(["Layout","Sider"],Je=>[F(Je)],Ce.eh,{deprecatedTokens:Ce.jn}),X=function(Je,nt){var ne={};for(var ee in Je)Object.prototype.hasOwnProperty.call(Je,ee)&&nt.indexOf(ee)<0&&(ne[ee]=Je[ee]);if(Je!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ce=0,ee=Object.getOwnPropertySymbols(Je);ce<ee.length;ce++)nt.indexOf(ee[ce])<0&&Object.prototype.propertyIsEnumerable.call(Je,ee[ce])&&(ne[ee[ce]]=Je[ee[ce]]);return ne};const le={xs:"479.98px",sm:"575.98px",md:"767.98px",lg:"991.98px",xl:"1199.98px",xxl:"1599.98px"},me=Je=>!Number.isNaN(Number.parseFloat(Je))&&isFinite(Je),Xe=_.createContext({}),se=(()=>{let Je=0;return function(){let nt=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return Je+=1,`${nt}${Je}`}})();var yt=_.forwardRef((Je,nt)=>{const{prefixCls:ne,className:ee,trigger:ce,children:K,defaultCollapsed:Se=!1,theme:ze="dark",style:ve={},collapsible:Pe=!1,reverseArrow:ke=!1,width:rt=200,collapsedWidth:_e=80,zeroWidthTriggerStyle:Ye,breakpoint:ye,onCollapse:Ve,onBreakpoint:We}=Je,Mt=X(Je,["prefixCls","className","trigger","children","defaultCollapsed","theme","style","collapsible","reverseArrow","width","collapsedWidth","zeroWidthTriggerStyle","breakpoint","onCollapse","onBreakpoint"]),{siderHook:jt}=(0,_.useContext)(st.V),[_t,Le]=(0,_.useState)("collapsed"in Je?Je.collapsed:Se),[It,je]=(0,_.useState)(!1);(0,_.useEffect)(()=>{"collapsed"in Je&&Le(Je.collapsed)},[Je.collapsed]);const Xt=(lt,pe)=>{"collapsed"in Je||Le(lt),Ve==null||Ve(lt,pe)},{getPrefixCls:oe,direction:Me}=(0,_.useContext)(H.E_),N=oe("layout-sider",ne),[Ue,z,$]=k(N),M=(0,_.useRef)(null);M.current=lt=>{je(lt.matches),We==null||We(lt.matches),_t!==lt.matches&&Xt(lt.matches,"responsive")},(0,_.useEffect)(()=>{function lt(pt){return M.current(pt)}let pe;if(typeof window!="undefined"){const{matchMedia:pt}=window;if(pt&&ye&&ye in le){pe=pt(`screen and (max-width: ${le[ye]})`);try{pe.addEventListener("change",lt)}catch(Ei){pe.addListener(lt)}lt(pe)}}return()=>{try{pe==null||pe.removeEventListener("change",lt)}catch(pt){pe==null||pe.removeListener(lt)}}},[ye]),(0,_.useEffect)(()=>{const lt=se("ant-sider-");return jt.addSider(lt),()=>jt.removeSider(lt)},[]);const w=()=>{Xt(!_t,"clickTrigger")},P=(0,D.Z)(Mt,["collapsed"]),V=_t?_e:rt,C=me(V)?`${V}px`:String(V),Ee=parseFloat(String(_e||0))===0?_.createElement("span",{onClick:w,className:Ie()(`${N}-zero-width-trigger`,`${N}-zero-width-trigger-${ke?"right":"left"}`),style:Ye},ce||_.createElement(G,null)):null,xe=Me==="rtl"==!ke,Rt={expanded:xe?_.createElement(de.Z,null):_.createElement(re.Z,null),collapsed:xe?_.createElement(re.Z,null):_.createElement(de.Z,null)}[_t?"collapsed":"expanded"],et=ce!==null?Ee||_.createElement("div",{className:`${N}-trigger`,onClick:w,style:{width:C}},ce||Rt):null,ut=Object.assign(Object.assign({},ve),{flex:`0 0 ${C}`,maxWidth:C,minWidth:C,width:C}),Et=Ie()(N,`${N}-${ze}`,{[`${N}-collapsed`]:!!_t,[`${N}-has-trigger`]:Pe&&ce!==null&&!Ee,[`${N}-below`]:!!It,[`${N}-zero-width`]:parseFloat(C)===0},ee,z,$),Tt=_.useMemo(()=>({siderCollapsed:_t}),[_t]);return Ue(_.createElement(Xe.Provider,{value:Tt},_.createElement("aside",Object.assign({className:Et},P,{style:ut,ref:nt}),_.createElement("div",{className:`${N}-children`},K),Pe||It&&Ee?et:null)))})},6989:function(ii,qe,x){"use strict";x.d(qe,{V:function(){return J}});var _=x(59301);const J=_.createContext({siderHook:{addSider:()=>null,removeSider:()=>null}})},48923:function(ii,qe,x){"use strict";x.d(qe,{eh:function(){return Y},jn:function(){return A}});var _=x(36237),J=x(16931);const Ae=g=>{const{antCls:te,componentCls:G,colorText:re,footerBg:de,headerHeight:we,headerPadding:Ie,headerColor:D,footerPadding:H,fontSize:st,bodyBg:Ge,headerBg:Ce}=g;return{[G]:{display:"flex",flex:"auto",flexDirection:"column",minHeight:0,background:Ge,"&, *":{boxSizing:"border-box"},[`&${G}-has-sider`]:{flexDirection:"row",[`> ${G}, > ${G}-content`]:{width:0}},[`${G}-header, &${G}-footer`]:{flex:"0 0 auto"},"&-rtl":{direction:"rtl"}},[`${G}-header`]:{height:we,padding:Ie,color:D,lineHeight:(0,_.unit)(we),background:Ce,[`${te}-menu`]:{lineHeight:"inherit"}},[`${G}-footer`]:{padding:H,color:re,fontSize:st,background:de},[`${G}-content`]:{flex:"auto",color:re,minHeight:0}}},Y=g=>{const{colorBgLayout:te,controlHeight:G,controlHeightLG:re,colorText:de,controlHeightSM:we,marginXXS:Ie,colorTextLightSolid:D,colorBgContainer:H}=g,st=re*1.25;return{colorBgHeader:"#001529",colorBgBody:te,colorBgTrigger:"#002140",bodyBg:te,headerBg:"#001529",headerHeight:G*2,headerPadding:`0 ${st}px`,headerColor:de,footerPadding:`${we}px ${st}px`,footerBg:te,siderBg:"#001529",triggerHeight:re+Ie*2,triggerBg:"#002140",triggerColor:D,zeroTriggerWidth:re,zeroTriggerHeight:re,lightSiderBg:H,lightTriggerBg:H,lightTriggerColor:de}},A=[["colorBgBody","bodyBg"],["colorBgHeader","headerBg"],["colorBgTrigger","triggerBg"]];qe.ZP=(0,J.I$)("Layout",g=>[Ae(g)],Y,{deprecatedTokens:A})},78857:function(ii,qe,x){"use strict";x.d(qe,{J:function(){return g}});var _=x(59301),J=x(8654),Ae=x(62487),Y=function(te,G){var re={};for(var de in te)Object.prototype.hasOwnProperty.call(te,de)&&G.indexOf(de)<0&&(re[de]=te[de]);if(te!=null&&typeof Object.getOwnPropertySymbols=="function")for(var we=0,de=Object.getOwnPropertySymbols(te);we<de.length;we++)G.indexOf(de[we])<0&&Object.prototype.propertyIsEnumerable.call(te,de[we])&&(re[de[we]]=te[de[we]]);return re};const A=_.createContext(null),g=_.forwardRef((te,G)=>{const{children:re}=te,de=Y(te,["children"]),we=_.useContext(A),Ie=_.useMemo(()=>Object.assign(Object.assign({},we),de),[we,de.prefixCls,de.mode,de.selectable,de.rootClassName]),D=(0,J.t4)(re),H=(0,J.x1)(G,D?(0,J.C4)(re):null);return _.createElement(A.Provider,{value:Ie},_.createElement(Ae.Z,{space:!0},D?_.cloneElement(re,{ref:H}):re))});qe.Z=A},93041:function(ii,qe,x){"use strict";x.d(qe,{default:function(){return Ue}});var _=x(59301),J=x(28321),Ae=x(24303),Y=x(18785),A=x(92310),g=x.n(A),te=x(6089),G=x(2738),re=x(86641),de=x(22703),we=x(48755),Ie=x(83397),H=(0,_.createContext)({prefixCls:"",firstLevel:!0,inlineCollapsed:!1}),st=function(z,$){var M={};for(var w in z)Object.prototype.hasOwnProperty.call(z,w)&&$.indexOf(w)<0&&(M[w]=z[w]);if(z!=null&&typeof Object.getOwnPropertySymbols=="function")for(var P=0,w=Object.getOwnPropertySymbols(z);P<w.length;P++)$.indexOf(w[P])<0&&Object.prototype.propertyIsEnumerable.call(z,w[P])&&(M[w[P]]=z[w[P]]);return M},Ce=z=>{const{prefixCls:$,className:M,dashed:w}=z,P=st(z,["prefixCls","className","dashed"]),{getPrefixCls:V}=_.useContext(we.E_),C=V("menu",$),Ee=g()({[`${C}-item-divider-dashed`]:!!w},M);return _.createElement(J.iz,Object.assign({className:Ee},P))},ae=x(11592),F=x(25399),X=z=>{var $;const{className:M,children:w,icon:P,title:V,danger:C,extra:Ee}=z,{prefixCls:xe,firstLevel:Ke,direction:ot,disableMenuItemTitleTooltip:Rt,inlineCollapsed:et}=_.useContext(H),ut=Ei=>{const _i=w==null?void 0:w[0],li=_.createElement("span",{className:g()(`${xe}-title-content`,{[`${xe}-title-content-with-extra`]:!!Ee||Ee===0})},w);return(!P||_.isValidElement(w)&&w.type==="span")&&w&&Ei&&Ke&&typeof _i=="string"?_.createElement("div",{className:`${xe}-inline-collapsed-noicon`},_i.charAt(0)):li},{siderCollapsed:Et}=_.useContext(Ae.D);let Tt=V;typeof V=="undefined"?Tt=Ke?w:"":V===!1&&(Tt="");const lt={title:Tt};!Et&&!et&&(lt.title=null,lt.open=!1);const pe=(0,ae.Z)(w).length;let pt=_.createElement(J.ck,Object.assign({},(0,G.Z)(z,["title","icon","danger"]),{className:g()({[`${xe}-item-danger`]:C,[`${xe}-item-only-child`]:(P?pe+1:pe)===1},M),title:typeof V=="string"?V:void 0}),(0,de.Tm)(P,{className:g()(_.isValidElement(P)?($=P.props)===null||$===void 0?void 0:$.className:"",`${xe}-item-icon`)}),ut(et));return Rt||(pt=_.createElement(F.Z,Object.assign({},lt,{placement:ot==="rtl"?"left":"right",classNames:{root:`${xe}-inline-collapsed-tooltip`}}),pt)),pt},le=x(78857),me=x(36237),Xe=x(17835),se=x(63356),vt=x(34961),yt=x(46e3),Je=x(34925),nt=x(16931),ne=x(51636),ce=z=>{const{componentCls:$,motionDurationSlow:M,horizontalLineHeight:w,colorSplit:P,lineWidth:V,lineType:C,itemPaddingInline:Ee}=z;return{[`${$}-horizontal`]:{lineHeight:w,border:0,borderBottom:`${(0,me.unit)(V)} ${C} ${P}`,boxShadow:"none","&::after":{display:"block",clear:"both",height:0,content:'"\\20"'},[`${$}-item, ${$}-submenu`]:{position:"relative",display:"inline-block",verticalAlign:"bottom",paddingInline:Ee},[`> ${$}-item:hover,
> ${$}-item-active,
> ${$}-submenu ${$}-submenu-title:hover`]:{backgroundColor:"transparent"},[`${$}-item, ${$}-submenu-title`]:{transition:[`border-color ${M}`,`background ${M}`].join(",")},[`${$}-submenu-arrow`]:{display:"none"}}}},Se=z=>{let{componentCls:$,menuArrowOffset:M,calc:w}=z;return{[`${$}-rtl`]:{direction:"rtl"},[`${$}-submenu-rtl`]:{transformOrigin:"100% 0"},[`${$}-rtl${$}-vertical,
${$}-submenu-rtl ${$}-vertical`]:{[`${$}-submenu-arrow`]:{"&::before":{transform:`rotate(-45deg) translateY(${(0,me.unit)(w(M).mul(-1).equal())})`},"&::after":{transform:`rotate(45deg) translateY(${(0,me.unit)(M)})`}}}}};const ze=z=>Object.assign({},(0,se.oN)(z));var Pe=(z,$)=>{const{componentCls:M,itemColor:w,itemSelectedColor:P,subMenuItemSelectedColor:V,groupTitleColor:C,itemBg:Ee,subMenuItemBg:xe,itemSelectedBg:Ke,activeBarHeight:ot,activeBarWidth:Rt,activeBarBorderWidth:et,motionDurationSlow:ut,motionEaseInOut:Et,motionEaseOut:Tt,itemPaddingInline:lt,motionDurationMid:pe,itemHoverColor:pt,lineType:Ei,colorSplit:_i,itemDisabledColor:li,dangerItemColor:Ai,dangerItemHoverColor:Vi,dangerItemSelectedColor:Ti,dangerItemActiveBg:Ut,dangerItemSelectedBg:wi,popupBg:ui,itemHoverBg:tt,itemActiveBg:Lt,menuSubMenuBg:St,horizontalItemSelectedColor:ti,horizontalItemSelectedBg:oi,horizontalItemBorderRadius:ci,horizontalItemHoverBg:Ht}=z;return{[`${M}-${$}, ${M}-${$} > ${M}`]:{color:w,background:Ee,[`&${M}-root:focus-visible`]:Object.assign({},ze(z)),[`${M}-item`]:{"&-group-title, &-extra":{color:C}},[`${M}-submenu-selected > ${M}-submenu-title`]:{color:V},[`${M}-item, ${M}-submenu-title`]:{color:w,[`&:not(${M}-item-disabled):focus-visible`]:Object.assign({},ze(z))},[`${M}-item-disabled, ${M}-submenu-disabled`]:{color:`${li} !important`},[`${M}-item:not(${M}-item-selected):not(${M}-submenu-selected)`]:{[`&:hover, > ${M}-submenu-title:hover`]:{color:pt}},[`&:not(${M}-horizontal)`]:{[`${M}-item:not(${M}-item-selected)`]:{"&:hover":{backgroundColor:tt},"&:active":{backgroundColor:Lt}},[`${M}-submenu-title`]:{"&:hover":{backgroundColor:tt},"&:active":{backgroundColor:Lt}}},[`${M}-item-danger`]:{color:Ai,[`&${M}-item:hover`]:{[`&:not(${M}-item-selected):not(${M}-submenu-selected)`]:{color:Vi}},[`&${M}-item:active`]:{background:Ut}},[`${M}-item a`]:{"&, &:hover":{color:"inherit"}},[`${M}-item-selected`]:{color:P,[`&${M}-item-danger`]:{color:Ti},"a, a:hover":{color:"inherit"}},[`& ${M}-item-selected`]:{backgroundColor:Ke,[`&${M}-item-danger`]:{backgroundColor:wi}},[`&${M}-submenu > ${M}`]:{backgroundColor:St},[`&${M}-popup > ${M}`]:{backgroundColor:ui},[`&${M}-submenu-popup > ${M}`]:{backgroundColor:ui},[`&${M}-horizontal`]:Object.assign(Object.assign({},$==="dark"?{borderBottom:0}:{}),{[`> ${M}-item, > ${M}-submenu`]:{top:et,marginTop:z.calc(et).mul(-1).equal(),marginBottom:0,borderRadius:ci,"&::after":{position:"absolute",insetInline:lt,bottom:0,borderBottom:`${(0,me.unit)(ot)} solid transparent`,transition:`border-color ${ut} ${Et}`,content:'""'},"&:hover, &-active, &-open":{background:Ht,"&::after":{borderBottomWidth:ot,borderBottomColor:ti}},"&-selected":{color:ti,backgroundColor:oi,"&:hover":{backgroundColor:oi},"&::after":{borderBottomWidth:ot,borderBottomColor:ti}}}}),[`&${M}-root`]:{[`&${M}-inline, &${M}-vertical`]:{borderInlineEnd:`${(0,me.unit)(et)} ${Ei} ${_i}`}},[`&${M}-inline`]:{[`${M}-sub${M}-inline`]:{background:xe},[`${M}-item`]:{position:"relative","&::after":{position:"absolute",insetBlock:0,insetInlineEnd:0,borderInlineEnd:`${(0,me.unit)(Rt)} solid ${P}`,transform:"scaleY(0.0001)",opacity:0,transition:[`transform ${pe} ${Tt}`,`opacity ${pe} ${Tt}`].join(","),content:'""'},[`&${M}-item-danger`]:{"&::after":{borderInlineEndColor:Ti}}},[`${M}-selected, ${M}-item-selected`]:{"&::after":{transform:"scaleY(1)",opacity:1,transition:[`transform ${pe} ${Et}`,`opacity ${pe} ${Et}`].join(",")}}}}}};const ke=z=>{const{componentCls:$,itemHeight:M,itemMarginInline:w,padding:P,menuArrowSize:V,marginXS:C,itemMarginBlock:Ee,itemWidth:xe,itemPaddingInline:Ke}=z,ot=z.calc(V).add(P).add(C).equal();return{[`${$}-item`]:{position:"relative",overflow:"hidden"},[`${$}-item, ${$}-submenu-title`]:{height:M,lineHeight:(0,me.unit)(M),paddingInline:Ke,overflow:"hidden",textOverflow:"ellipsis",marginInline:w,marginBlock:Ee,width:xe},[`> ${$}-item,
> ${$}-submenu > ${$}-submenu-title`]:{height:M,lineHeight:(0,me.unit)(M)},[`${$}-item-group-list ${$}-submenu-title,
${$}-submenu-title`]:{paddingInlineEnd:ot}}};var _e=z=>{const{componentCls:$,iconCls:M,itemHeight:w,colorTextLightSolid:P,dropdownWidth:V,controlHeightLG:C,motionEaseOut:Ee,paddingXL:xe,itemMarginInline:Ke,fontSizeLG:ot,motionDurationFast:Rt,motionDurationSlow:et,paddingXS:ut,boxShadowSecondary:Et,collapsedWidth:Tt,collapsedIconSize:lt}=z,pe={height:w,lineHeight:(0,me.unit)(w),listStylePosition:"inside",listStyleType:"disc"};return[{[$]:{"&-inline, &-vertical":Object.assign({[`&${$}-root`]:{boxShadow:"none"}},ke(z))},[`${$}-submenu-popup`]:{[`${$}-vertical`]:Object.assign(Object.assign({},ke(z)),{boxShadow:Et})}},{[`${$}-submenu-popup ${$}-vertical${$}-sub`]:{minWidth:V,maxHeight:`calc(100vh - ${(0,me.unit)(z.calc(C).mul(2.5).equal())})`,padding:"0",overflow:"hidden",borderInlineEnd:0,"&:not([class*='-active'])":{overflowX:"hidden",overflowY:"auto"}}},{[`${$}-inline`]:{width:"100%",[`&${$}-root`]:{[`${$}-item, ${$}-submenu-title`]:{display:"flex",alignItems:"center",transition:[`border-color ${et}`,`background ${et}`,`padding ${Rt} ${Ee}`].join(","),[`> ${$}-title-content`]:{flex:"auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},"> *":{flex:"none"}}},[`${$}-sub${$}-inline`]:{padding:0,border:0,borderRadius:0,boxShadow:"none",[`& > ${$}-submenu > ${$}-submenu-title`]:pe,[`& ${$}-item-group-title`]:{paddingInlineStart:xe}},[`${$}-item`]:pe}},{[`${$}-inline-collapsed`]:{width:Tt,[`&${$}-root`]:{[`${$}-item, ${$}-submenu ${$}-submenu-title`]:{[`> ${$}-inline-collapsed-noicon`]:{fontSize:ot,textAlign:"center"}}},[`> ${$}-item,
> ${$}-item-group > ${$}-item-group-list > ${$}-item,
> ${$}-item-group > ${$}-item-group-list > ${$}-submenu > ${$}-submenu-title,
> ${$}-submenu > ${$}-submenu-title`]:{insetInlineStart:0,paddingInline:`calc(50% - ${(0,me.unit)(z.calc(lt).div(2).equal())} - ${(0,me.unit)(Ke)})`,textOverflow:"clip",[`
${$}-submenu-arrow,
${$}-submenu-expand-icon
`]:{opacity:0},[`${$}-item-icon, ${M}`]:{margin:0,fontSize:lt,lineHeight:(0,me.unit)(w),"+ span":{display:"inline-block",opacity:0}}},[`${$}-item-icon, ${M}`]:{display:"inline-block"},"&-tooltip":{pointerEvents:"none",[`${$}-item-icon, ${M}`]:{display:"none"},"a, a:hover":{color:P}},[`${$}-item-group-title`]:Object.assign(Object.assign({},se.vS),{paddingInline:ut})}}]};const Ye=z=>{const{componentCls:$,motionDurationSlow:M,motionDurationMid:w,motionEaseInOut:P,motionEaseOut:V,iconCls:C,iconSize:Ee,iconMarginInlineEnd:xe}=z;return{[`${$}-item, ${$}-submenu-title`]:{position:"relative",display:"block",margin:0,whiteSpace:"nowrap",cursor:"pointer",transition:[`border-color ${M}`,`background ${M}`,`padding calc(${M} + 0.1s) ${P}`].join(","),[`${$}-item-icon, ${C}`]:{minWidth:Ee,fontSize:Ee,transition:[`font-size ${w} ${V}`,`margin ${M} ${P}`,`color ${M}`].join(","),"+ span":{marginInlineStart:xe,opacity:1,transition:[`opacity ${M} ${P}`,`margin ${M}`,`color ${M}`].join(",")}},[`${$}-item-icon`]:Object.assign({},(0,se.Ro)()),[`&${$}-item-only-child`]:{[`> ${C}, > ${$}-item-icon`]:{marginInlineEnd:0}}},[`${$}-item-disabled, ${$}-submenu-disabled`]:{background:"none !important",cursor:"not-allowed","&::after":{borderColor:"transparent !important"},a:{color:"inherit !important",cursor:"not-allowed",pointerEvents:"none"},[`> ${$}-submenu-title`]:{color:"inherit !important",cursor:"not-allowed"}}}},ye=z=>{const{componentCls:$,motionDurationSlow:M,motionEaseInOut:w,borderRadius:P,menuArrowSize:V,menuArrowOffset:C}=z;return{[`${$}-submenu`]:{"&-expand-icon, &-arrow":{position:"absolute",top:"50%",insetInlineEnd:z.margin,width:V,color:"currentcolor",transform:"translateY(-50%)",transition:`transform ${M} ${w}, opacity ${M}`},"&-arrow":{"&::before, &::after":{position:"absolute",width:z.calc(V).mul(.6).equal(),height:z.calc(V).mul(.15).equal(),backgroundColor:"currentcolor",borderRadius:P,transition:[`background ${M} ${w}`,`transform ${M} ${w}`,`top ${M} ${w}`,`color ${M} ${w}`].join(","),content:'""'},"&::before":{transform:`rotate(45deg) translateY(${(0,me.unit)(z.calc(C).mul(-1).equal())})`},"&::after":{transform:`rotate(-45deg) translateY(${(0,me.unit)(C)})`}}}}},Ve=z=>{const{antCls:$,componentCls:M,fontSize:w,motionDurationSlow:P,motionDurationMid:V,motionEaseInOut:C,paddingXS:Ee,padding:xe,colorSplit:Ke,lineWidth:ot,zIndexPopup:Rt,borderRadiusLG:et,subMenuItemBorderRadius:ut,menuArrowSize:Et,menuArrowOffset:Tt,lineType:lt,groupTitleLineHeight:pe,groupTitleFontSize:pt}=z;return[{"":{[M]:Object.assign(Object.assign({},(0,se.dF)()),{"&-hidden":{display:"none"}})},[`${M}-submenu-hidden`]:{display:"none"}},{[M]:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},(0,se.Wf)(z)),(0,se.dF)()),{marginBottom:0,paddingInlineStart:0,fontSize:w,lineHeight:0,listStyle:"none",outline:"none",transition:`width ${P} cubic-bezier(0.2, 0, 0, 1) 0s`,"ul, ol":{margin:0,padding:0,listStyle:"none"},"&-overflow":{display:"flex",[`${M}-item`]:{flex:"none"}},[`${M}-item, ${M}-submenu, ${M}-submenu-title`]:{borderRadius:z.itemBorderRadius},[`${M}-item-group-title`]:{padding:`${(0,me.unit)(Ee)} ${(0,me.unit)(xe)}`,fontSize:pt,lineHeight:pe,transition:`all ${P}`},[`&-horizontal ${M}-submenu`]:{transition:[`border-color ${P} ${C}`,`background ${P} ${C}`].join(",")},[`${M}-submenu, ${M}-submenu-inline`]:{transition:[`border-color ${P} ${C}`,`background ${P} ${C}`,`padding ${V} ${C}`].join(",")},[`${M}-submenu ${M}-sub`]:{cursor:"initial",transition:[`background ${P} ${C}`,`padding ${P} ${C}`].join(",")},[`${M}-title-content`]:{transition:`color ${P}`,"&-with-extra":{display:"inline-flex",alignItems:"center",width:"100%"},[`> ${$}-typography-ellipsis-single-line`]:{display:"inline",verticalAlign:"unset"},[`${M}-item-extra`]:{marginInlineStart:"auto",paddingInlineStart:z.padding}},[`${M}-item a`]:{"&::before":{position:"absolute",inset:0,backgroundColor:"transparent",content:'""'}},[`${M}-item-divider`]:{overflow:"hidden",lineHeight:0,borderColor:Ke,borderStyle:lt,borderWidth:0,borderTopWidth:ot,marginBlock:ot,padding:0,"&-dashed":{borderStyle:"dashed"}}}),Ye(z)),{[`${M}-item-group`]:{[`${M}-item-group-list`]:{margin:0,padding:0,[`${M}-item, ${M}-submenu-title`]:{paddingInline:`${(0,me.unit)(z.calc(w).mul(2).equal())} ${(0,me.unit)(xe)}`}}},"&-submenu":{"&-popup":{position:"absolute",zIndex:Rt,borderRadius:et,boxShadow:"none",transformOrigin:"0 0",[`&${M}-submenu`]:{background:"transparent"},"&::before":{position:"absolute",inset:0,zIndex:-1,width:"100%",height:"100%",opacity:0,content:'""'},[`> ${M}`]:Object.assign(Object.assign(Object.assign({borderRadius:et},Ye(z)),ye(z)),{[`${M}-item, ${M}-submenu > ${M}-submenu-title`]:{borderRadius:ut},[`${M}-submenu-title::after`]:{transition:`transform ${P} ${C}`}})},"\n &-placement-leftTop,\n &-placement-bottomRight,\n ":{transformOrigin:"100% 0"},"\n &-placement-leftBottom,\n &-placement-topRight,\n ":{transformOrigin:"100% 100%"},"\n &-placement-rightBottom,\n &-placement-topLeft,\n ":{transformOrigin:"0 100%"},"\n &-placement-bottomLeft,\n &-placement-rightTop,\n ":{transformOrigin:"0 0"},"\n &-placement-leftTop,\n &-placement-leftBottom\n ":{paddingInlineEnd:z.paddingXS},"\n &-placement-rightTop,\n &-placement-rightBottom\n ":{paddingInlineStart:z.paddingXS},"\n &-placement-topRight,\n &-placement-topLeft\n ":{paddingBottom:z.paddingXS},"\n &-placement-bottomRight,\n &-placement-bottomLeft\n ":{paddingTop:z.paddingXS}}}),ye(z)),{[`&-inline-collapsed ${M}-submenu-arrow,
&-inline ${M}-submenu-arrow`]:{"&::before":{transform:`rotate(-45deg) translateX(${(0,me.unit)(Tt)})`},"&::after":{transform:`rotate(45deg) translateX(${(0,me.unit)(z.calc(Tt).mul(-1).equal())})`}},[`${M}-submenu-open${M}-submenu-inline > ${M}-submenu-title > ${M}-submenu-arrow`]:{transform:`translateY(${(0,me.unit)(z.calc(Et).mul(.2).mul(-1).equal())})`,"&::after":{transform:`rotate(-45deg) translateX(${(0,me.unit)(z.calc(Tt).mul(-1).equal())})`},"&::before":{transform:`rotate(45deg) translateX(${(0,me.unit)(Tt)})`}}})},{[`${$}-layout-header`]:{[M]:{lineHeight:"inherit"}}}]},We=z=>{var $,M,w;const{colorPrimary:P,colorError:V,colorTextDisabled:C,colorErrorBg:Ee,colorText:xe,colorTextDescription:Ke,colorBgContainer:ot,colorFillAlter:Rt,colorFillContent:et,lineWidth:ut,lineWidthBold:Et,controlItemBgActive:Tt,colorBgTextHover:lt,controlHeightLG:pe,lineHeight:pt,colorBgElevated:Ei,marginXXS:_i,padding:li,fontSize:Ai,controlHeightSM:Vi,fontSizeLG:Ti,colorTextLightSolid:Ut,colorErrorHover:wi}=z,ui=($=z.activeBarWidth)!==null&&$!==void 0?$:0,tt=(M=z.activeBarBorderWidth)!==null&&M!==void 0?M:ut,Lt=(w=z.itemMarginInline)!==null&&w!==void 0?w:z.marginXXS,St=new Xe.FastColor(Ut).setA(.65).toRgbString();return{dropdownWidth:160,zIndexPopup:z.zIndexPopupBase+50,radiusItem:z.borderRadiusLG,itemBorderRadius:z.borderRadiusLG,radiusSubMenuItem:z.borderRadiusSM,subMenuItemBorderRadius:z.borderRadiusSM,colorItemText:xe,itemColor:xe,colorItemTextHover:xe,itemHoverColor:xe,colorItemTextHoverHorizontal:P,horizontalItemHoverColor:P,colorGroupTitle:Ke,groupTitleColor:Ke,colorItemTextSelected:P,itemSelectedColor:P,subMenuItemSelectedColor:P,colorItemTextSelectedHorizontal:P,horizontalItemSelectedColor:P,colorItemBg:ot,itemBg:ot,colorItemBgHover:lt,itemHoverBg:lt,colorItemBgActive:et,itemActiveBg:Tt,colorSubItemBg:Rt,subMenuItemBg:Rt,colorItemBgSelected:Tt,itemSelectedBg:Tt,colorItemBgSelectedHorizontal:"transparent",horizontalItemSelectedBg:"transparent",colorActiveBarWidth:0,activeBarWidth:ui,colorActiveBarHeight:Et,activeBarHeight:Et,colorActiveBarBorderSize:ut,activeBarBorderWidth:tt,colorItemTextDisabled:C,itemDisabledColor:C,colorDangerItemText:V,dangerItemColor:V,colorDangerItemTextHover:V,dangerItemHoverColor:V,colorDangerItemTextSelected:V,dangerItemSelectedColor:V,colorDangerItemBgActive:Ee,dangerItemActiveBg:Ee,colorDangerItemBgSelected:Ee,dangerItemSelectedBg:Ee,itemMarginInline:Lt,horizontalItemBorderRadius:0,horizontalItemHoverBg:"transparent",itemHeight:pe,groupTitleLineHeight:pt,collapsedWidth:pe*2,popupBg:Ei,itemMarginBlock:_i,itemPaddingInline:li,horizontalLineHeight:`${pe*1.15}px`,iconSize:Ai,iconMarginInlineEnd:Vi-Ai,collapsedIconSize:Ti,groupTitleFontSize:Ai,darkItemDisabledColor:new Xe.FastColor(Ut).setA(.25).toRgbString(),darkItemColor:St,darkDangerItemColor:V,darkItemBg:"#001529",darkPopupBg:"#001529",darkSubMenuItemBg:"#000c17",darkItemSelectedColor:Ut,darkItemSelectedBg:P,darkDangerItemSelectedBg:V,darkItemHoverBg:"transparent",darkGroupTitleColor:St,darkItemHoverColor:Ut,darkDangerItemHoverColor:wi,darkDangerItemSelectedColor:Ut,darkDangerItemActiveBg:V,itemWidth:ui?`calc(100% + ${tt}px)`:`calc(100% - ${Lt*2}px)`}};var Mt=function(z){let $=arguments.length>1&&arguments[1]!==void 0?arguments[1]:z,M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return(0,nt.I$)("Menu",P=>{const{colorBgElevated:V,controlHeightLG:C,fontSize:Ee,darkItemColor:xe,darkDangerItemColor:Ke,darkItemBg:ot,darkSubMenuItemBg:Rt,darkItemSelectedColor:et,darkItemSelectedBg:ut,darkDangerItemSelectedBg:Et,darkItemHoverBg:Tt,darkGroupTitleColor:lt,darkItemHoverColor:pe,darkItemDisabledColor:pt,darkDangerItemHoverColor:Ei,darkDangerItemSelectedColor:_i,darkDangerItemActiveBg:li,popupBg:Ai,darkPopupBg:Vi}=P,Ti=P.calc(Ee).div(7).mul(5).equal(),Ut=(0,ne.mergeToken)(P,{menuArrowSize:Ti,menuHorizontalHeight:P.calc(C).mul(1.15).equal(),menuArrowOffset:P.calc(Ti).mul(.25).equal(),menuSubMenuBg:V,calc:P.calc,popupBg:Ai}),wi=(0,ne.mergeToken)(Ut,{itemColor:xe,itemHoverColor:pe,groupTitleColor:lt,itemSelectedColor:et,subMenuItemSelectedColor:et,itemBg:ot,popupBg:Vi,subMenuItemBg:Rt,itemActiveBg:"transparent",itemSelectedBg:ut,activeBarHeight:0,activeBarBorderWidth:0,itemHoverBg:Tt,itemDisabledColor:pt,dangerItemColor:Ke,dangerItemHoverColor:Ei,dangerItemSelectedColor:_i,dangerItemActiveBg:li,dangerItemSelectedBg:Et,menuSubMenuBg:Rt,horizontalItemSelectedColor:et,horizontalItemSelectedBg:ut});return[Ve(Ut),ce(Ut),_e(Ut),Pe(Ut,"light"),Pe(wi,"dark"),Se(Ut),(0,vt.Z)(Ut),(0,yt.oN)(Ut,"slide-up"),(0,yt.oN)(Ut,"slide-down"),(0,Je._y)(Ut,"zoom-big")]},We,{deprecatedTokens:[["colorGroupTitle","groupTitleColor"],["radiusItem","itemBorderRadius"],["radiusSubMenuItem","subMenuItemBorderRadius"],["colorItemText","itemColor"],["colorItemTextHover","itemHoverColor"],["colorItemTextHoverHorizontal","horizontalItemHoverColor"],["colorItemTextSelected","itemSelectedColor"],["colorItemTextSelectedHorizontal","horizontalItemSelectedColor"],["colorItemTextDisabled","itemDisabledColor"],["colorDangerItemText","dangerItemColor"],["colorDangerItemTextHover","dangerItemHoverColor"],["colorDangerItemTextSelected","dangerItemSelectedColor"],["colorDangerItemBgActive","dangerItemActiveBg"],["colorDangerItemBgSelected","dangerItemSelectedBg"],["colorItemBg","itemBg"],["colorItemBgHover","itemHoverBg"],["colorSubItemBg","subMenuItemBg"],["colorItemBgActive","itemActiveBg"],["colorItemBgSelectedHorizontal","horizontalItemSelectedBg"],["colorActiveBarWidth","activeBarWidth"],["colorActiveBarHeight","activeBarHeight"],["colorActiveBarBorderSize","activeBarBorderWidth"],["colorItemBgSelected","itemSelectedBg"]],injectStyle:M,unitless:{groupTitleLineHeight:!0}})(z,$)},jt=x(75030),Le=z=>{var $;const{popupClassName:M,icon:w,title:P,theme:V}=z,C=_.useContext(H),{prefixCls:Ee,inlineCollapsed:xe,theme:Ke}=C,ot=(0,J.Xl)();let Rt;if(!w)Rt=xe&&!ot.length&&P&&typeof P=="string"?_.createElement("div",{className:`${Ee}-inline-collapsed-noicon`},P.charAt(0)):_.createElement("span",{className:`${Ee}-title-content`},P);else{const Et=_.isValidElement(P)&&P.type==="span";Rt=_.createElement(_.Fragment,null,(0,de.Tm)(w,{className:g()(_.isValidElement(w)?($=w.props)===null||$===void 0?void 0:$.className:"",`${Ee}-item-icon`)}),Et?P:_.createElement("span",{className:`${Ee}-title-content`},P))}const et=_.useMemo(()=>Object.assign(Object.assign({},C),{firstLevel:!1}),[C]),[ut]=(0,jt.Cn)("Menu");return _.createElement(H.Provider,{value:et},_.createElement(J.Wd,Object.assign({},(0,G.Z)(z,["icon"]),{title:Rt,popupClassName:g()(Ee,M,`${Ee}-${V||Ke}`),popupStyle:Object.assign({zIndex:ut},z.popupStyle)})))},It=function(z,$){var M={};for(var w in z)Object.prototype.hasOwnProperty.call(z,w)&&$.indexOf(w)<0&&(M[w]=z[w]);if(z!=null&&typeof Object.getOwnPropertySymbols=="function")for(var P=0,w=Object.getOwnPropertySymbols(z);P<w.length;P++)$.indexOf(w[P])<0&&Object.prototype.propertyIsEnumerable.call(z,w[P])&&(M[w[P]]=z[w[P]]);return M};function je(z){return z===null||z===!1}const Xt={item:X,submenu:Le,divider:Ce};var Me=(0,_.forwardRef)((z,$)=>{var M;const w=_.useContext(le.Z),P=w||{},{getPrefixCls:V,getPopupContainer:C,direction:Ee,menu:xe}=_.useContext(we.E_),Ke=V(),{prefixCls:ot,className:Rt,style:et,theme:ut="light",expandIcon:Et,_internalDisableMenuItemTitleTooltip:Tt,inlineCollapsed:lt,siderCollapsed:pe,rootClassName:pt,mode:Ei,selectable:_i,onClick:li,overflowedIndicatorPopupClassName:Ai}=z,Vi=It(z,["prefixCls","className","style","theme","expandIcon","_internalDisableMenuItemTitleTooltip","inlineCollapsed","siderCollapsed","rootClassName","mode","selectable","onClick","overflowedIndicatorPopupClassName"]),Ti=(0,G.Z)(Vi,["collapsedWidth"]);(M=P.validator)===null||M===void 0||M.call(P,{mode:Ei});const Ut=(0,te.Z)(function(){var Pi;li==null||li.apply(void 0,arguments),(Pi=P.onClick)===null||Pi===void 0||Pi.call(P)}),wi=P.mode||Ei,ui=_i!=null?_i:P.selectable,tt=lt!=null?lt:pe,Lt={horizontal:{motionName:`${Ke}-slide-up`},inline:(0,re.Z)(Ke),other:{motionName:`${Ke}-zoom-big`}},St=V("menu",ot||P.prefixCls),ti=(0,Ie.Z)(St),[oi,ci,Ht]=Mt(St,ti,!w),Ii=g()(`${St}-${ut}`,xe==null?void 0:xe.className,Rt),Ft=_.useMemo(()=>{var Pi,Fe;if(typeof Et=="function"||je(Et))return Et||null;if(typeof P.expandIcon=="function"||je(P.expandIcon))return P.expandIcon||null;if(typeof(xe==null?void 0:xe.expandIcon)=="function"||je(xe==null?void 0:xe.expandIcon))return(xe==null?void 0:xe.expandIcon)||null;const d=(Pi=Et!=null?Et:P==null?void 0:P.expandIcon)!==null&&Pi!==void 0?Pi:xe==null?void 0:xe.expandIcon;return(0,de.Tm)(d,{className:g()(`${St}-submenu-expand-icon`,_.isValidElement(d)?(Fe=d.props)===null||Fe===void 0?void 0:Fe.className:void 0)})},[Et,P==null?void 0:P.expandIcon,xe==null?void 0:xe.expandIcon,St]),si=_.useMemo(()=>({prefixCls:St,inlineCollapsed:tt||!1,direction:Ee,firstLevel:!0,theme:ut,mode:wi,disableMenuItemTitleTooltip:Tt}),[St,tt,Ee,Tt,ut]);return oi(_.createElement(le.Z.Provider,{value:null},_.createElement(H.Provider,{value:si},_.createElement(J.ZP,Object.assign({getPopupContainer:C,overflowedIndicator:_.createElement(Y.Z,null),overflowedIndicatorPopupClassName:g()(St,`${St}-${ut}`,Ai),mode:wi,selectable:ui,onClick:Ut},Ti,{inlineCollapsed:tt,style:Object.assign(Object.assign({},xe==null?void 0:xe.style),et),className:Ii,prefixCls:St,direction:Ee,defaultMotions:Lt,expandIcon:Ft,ref:$,rootClassName:g()(pt,ci,P.rootClassName,Ht,ti),_internalComponents:Xt})))))});const N=(0,_.forwardRef)((z,$)=>{const M=(0,_.useRef)(null),w=_.useContext(Ae.D);return(0,_.useImperativeHandle)($,()=>({menu:M.current,focus:P=>{var V;(V=M.current)===null||V===void 0||V.focus(P)}})),_.createElement(Me,Object.assign({ref:M},z,w))});N.Item=X,N.SubMenu=Le,N.Divider=Ce,N.ItemGroup=J.BW;var Ue=N},44104:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return Ge}});var _=x(59301),J=x(92310),Ae=x.n(J),Y=x(11592),A=x(99402),g=x(48755),te=x(70045);const G=_.createContext({latestIndex:0}),re=G.Provider;var we=Ce=>{let{className:ae,index:F,children:k,split:X,style:le}=Ce;const{latestIndex:me}=_.useContext(G);return k==null?null:_.createElement(_.Fragment,null,_.createElement("div",{className:ae,style:le},k),F<me&&X&&_.createElement("span",{className:`${ae}-split`},X))},Ie=x(31547),D=function(Ce,ae){var F={};for(var k in Ce)Object.prototype.hasOwnProperty.call(Ce,k)&&ae.indexOf(k)<0&&(F[k]=Ce[k]);if(Ce!=null&&typeof Object.getOwnPropertySymbols=="function")for(var X=0,k=Object.getOwnPropertySymbols(Ce);X<k.length;X++)ae.indexOf(k[X])<0&&Object.prototype.propertyIsEnumerable.call(Ce,k[X])&&(F[k[X]]=Ce[k[X]]);return F};const st=_.forwardRef((Ce,ae)=>{var F;const{getPrefixCls:k,direction:X,size:le,className:me,style:Xe,classNames:se,styles:vt}=(0,g.dj)("space"),{size:yt=le!=null?le:"small",align:Je,className:nt,rootClassName:ne,children:ee,direction:ce="horizontal",prefixCls:K,split:Se,style:ze,wrap:ve=!1,classNames:Pe,styles:ke}=Ce,rt=D(Ce,["size","align","className","rootClassName","children","direction","prefixCls","split","style","wrap","classNames","styles"]),[_e,Ye]=Array.isArray(yt)?yt:[yt,yt],ye=(0,A.n)(Ye),Ve=(0,A.n)(_e),We=(0,A.T)(Ye),Mt=(0,A.T)(_e),jt=(0,Y.Z)(ee,{keepEmpty:!0}),_t=Je===void 0&&ce==="horizontal"?"center":Je,Le=k("space",K),[It,je,Xt]=(0,Ie.Z)(Le),oe=Ae()(Le,me,je,`${Le}-${ce}`,{[`${Le}-rtl`]:X==="rtl",[`${Le}-align-${_t}`]:_t,[`${Le}-gap-row-${Ye}`]:ye,[`${Le}-gap-col-${_e}`]:Ve},nt,ne,Xt),Me=Ae()(`${Le}-item`,(F=Pe==null?void 0:Pe.item)!==null&&F!==void 0?F:se.item);let N=0;const Ue=jt.map((M,w)=>{var P;M!=null&&(N=w);const V=(M==null?void 0:M.key)||`${Me}-${w}`;return _.createElement(we,{className:Me,key:V,index:w,split:Se,style:(P=ke==null?void 0:ke.item)!==null&&P!==void 0?P:vt.item},M)}),z=_.useMemo(()=>({latestIndex:N}),[N]);if(jt.length===0)return null;const $={};return ve&&($.flexWrap="wrap"),!Ve&&Mt&&($.columnGap=_e),!ye&&We&&($.rowGap=Ye),It(_.createElement("div",Object.assign({ref:ae,className:oe,style:Object.assign(Object.assign(Object.assign({},$),Xe),ze)},rt),_.createElement(re,{value:z},Ue)))});st.Compact=te.ZP;var Ge=st},93873:function(ii,qe,x){"use strict";x.d(qe,{Fm:function(){return Ie}});var _=x(36237),J=x(48746);const Ae=new _.Keyframes("antMoveDownIn",{"0%":{transform:"translate3d(0, 100%, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),Y=new _.Keyframes("antMoveDownOut",{"0%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1},"100%":{transform:"translate3d(0, 100%, 0)",transformOrigin:"0 0",opacity:0}}),A=new _.Keyframes("antMoveLeftIn",{"0%":{transform:"translate3d(-100%, 0, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),g=new _.Keyframes("antMoveLeftOut",{"0%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1},"100%":{transform:"translate3d(-100%, 0, 0)",transformOrigin:"0 0",opacity:0}}),te=new _.Keyframes("antMoveRightIn",{"0%":{transform:"translate3d(100%, 0, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),G=new _.Keyframes("antMoveRightOut",{"0%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1},"100%":{transform:"translate3d(100%, 0, 0)",transformOrigin:"0 0",opacity:0}}),re=new _.Keyframes("antMoveUpIn",{"0%":{transform:"translate3d(0, -100%, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),de=new _.Keyframes("antMoveUpOut",{"0%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1},"100%":{transform:"translate3d(0, -100%, 0)",transformOrigin:"0 0",opacity:0}}),we={"move-up":{inKeyframes:re,outKeyframes:de},"move-down":{inKeyframes:Ae,outKeyframes:Y},"move-left":{inKeyframes:A,outKeyframes:g},"move-right":{inKeyframes:te,outKeyframes:G}},Ie=(D,H)=>{const{antCls:st}=D,Ge=`${st}-${H}`,{inKeyframes:Ce,outKeyframes:ae}=we[H];return[(0,J.R)(Ge,Ce,ae,D.motionDurationMid),{[`
${Ge}-enter,
${Ge}-appear
`]:{opacity:0,animationTimingFunction:D.motionEaseOutCirc},[`${Ge}-leave`]:{animationTimingFunction:D.motionEaseInOutCirc}}]}},46e3:function(ii,qe,x){"use strict";x.d(qe,{Qt:function(){return A},Uw:function(){return Y},fJ:function(){return Ae},ly:function(){return g},oN:function(){return Ie}});var _=x(36237),J=x(48746);const Ae=new _.Keyframes("antSlideUpIn",{"0%":{transform:"scaleY(0.8)",transformOrigin:"0% 0%",opacity:0},"100%":{transform:"scaleY(1)",transformOrigin:"0% 0%",opacity:1}}),Y=new _.Keyframes("antSlideUpOut",{"0%":{transform:"scaleY(1)",transformOrigin:"0% 0%",opacity:1},"100%":{transform:"scaleY(0.8)",transformOrigin:"0% 0%",opacity:0}}),A=new _.Keyframes("antSlideDownIn",{"0%":{transform:"scaleY(0.8)",transformOrigin:"100% 100%",opacity:0},"100%":{transform:"scaleY(1)",transformOrigin:"100% 100%",opacity:1}}),g=new _.Keyframes("antSlideDownOut",{"0%":{transform:"scaleY(1)",transformOrigin:"100% 100%",opacity:1},"100%":{transform:"scaleY(0.8)",transformOrigin:"100% 100%",opacity:0}}),te=new _.Keyframes("antSlideLeftIn",{"0%":{transform:"scaleX(0.8)",transformOrigin:"0% 0%",opacity:0},"100%":{transform:"scaleX(1)",transformOrigin:"0% 0%",opacity:1}}),G=new _.Keyframes("antSlideLeftOut",{"0%":{transform:"scaleX(1)",transformOrigin:"0% 0%",opacity:1},"100%":{transform:"scaleX(0.8)",transformOrigin:"0% 0%",opacity:0}}),re=new _.Keyframes("antSlideRightIn",{"0%":{transform:"scaleX(0.8)",transformOrigin:"100% 0%",opacity:0},"100%":{transform:"scaleX(1)",transformOrigin:"100% 0%",opacity:1}}),de=new _.Keyframes("antSlideRightOut",{"0%":{transform:"scaleX(1)",transformOrigin:"100% 0%",opacity:1},"100%":{transform:"scaleX(0.8)",transformOrigin:"100% 0%",opacity:0}}),we={"slide-up":{inKeyframes:Ae,outKeyframes:Y},"slide-down":{inKeyframes:A,outKeyframes:g},"slide-left":{inKeyframes:te,outKeyframes:G},"slide-right":{inKeyframes:re,outKeyframes:de}},Ie=(D,H)=>{const{antCls:st}=D,Ge=`${st}-${H}`,{inKeyframes:Ce,outKeyframes:ae}=we[H];return[(0,J.R)(Ge,Ce,ae,D.motionDurationMid),{[`
${Ge}-enter,
${Ge}-appear
`]:{transform:"scale(0)",transformOrigin:"0% 0%",opacity:0,animationTimingFunction:D.motionEaseOutQuint,"&-prepare":{transform:"scale(1)"}},[`${Ge}-leave`]:{animationTimingFunction:D.motionEaseInQuint}}]}},37645:function(ii,qe,x){"use strict";x.d(qe,{ZP:function(){return g},qN:function(){return Ae},wZ:function(){return Y}});var _=x(36237),J=x(36305);const Ae=8;function Y(te){const{contentRadius:G,limitVerticalRadius:re}=te,de=G>12?G+2:12;return{arrowOffsetHorizontal:de,arrowOffsetVertical:re?Ae:de}}function A(te,G){return te?G:{}}function g(te,G,re){const{componentCls:de,boxShadowPopoverArrow:we,arrowOffsetVertical:Ie,arrowOffsetHorizontal:D}=te,{arrowDistance:H=0,arrowPlacement:st={left:!0,right:!0,top:!0,bottom:!0}}=re||{};return{[de]:Object.assign(Object.assign(Object.assign(Object.assign({[`${de}-arrow`]:[Object.assign(Object.assign({position:"absolute",zIndex:1,display:"block"},(0,J.W)(te,G,we)),{"&:before":{background:G}})]},A(!!st.top,{[[`&-placement-top > ${de}-arrow`,`&-placement-topLeft > ${de}-arrow`,`&-placement-topRight > ${de}-arrow`].join(",")]:{bottom:H,transform:"translateY(100%) rotate(180deg)"},[`&-placement-top > ${de}-arrow`]:{left:{_skip_check_:!0,value:"50%"},transform:"translateX(-50%) translateY(100%) rotate(180deg)"},"&-placement-topLeft":{"--arrow-offset-horizontal":D,[`> ${de}-arrow`]:{left:{_skip_check_:!0,value:D}}},"&-placement-topRight":{"--arrow-offset-horizontal":`calc(100% - ${(0,_.unit)(D)})`,[`> ${de}-arrow`]:{right:{_skip_check_:!0,value:D}}}})),A(!!st.bottom,{[[`&-placement-bottom > ${de}-arrow`,`&-placement-bottomLeft > ${de}-arrow`,`&-placement-bottomRight > ${de}-arrow`].join(",")]:{top:H,transform:"translateY(-100%)"},[`&-placement-bottom > ${de}-arrow`]:{left:{_skip_check_:!0,value:"50%"},transform:"translateX(-50%) translateY(-100%)"},"&-placement-bottomLeft":{"--arrow-offset-horizontal":D,[`> ${de}-arrow`]:{left:{_skip_check_:!0,value:D}}},"&-placement-bottomRight":{"--arrow-offset-horizontal":`calc(100% - ${(0,_.unit)(D)})`,[`> ${de}-arrow`]:{right:{_skip_check_:!0,value:D}}}})),A(!!st.left,{[[`&-placement-left > ${de}-arrow`,`&-placement-leftTop > ${de}-arrow`,`&-placement-leftBottom > ${de}-arrow`].join(",")]:{right:{_skip_check_:!0,value:H},transform:"translateX(100%) rotate(90deg)"},[`&-placement-left > ${de}-arrow`]:{top:{_skip_check_:!0,value:"50%"},transform:"translateY(-50%) translateX(100%) rotate(90deg)"},[`&-placement-leftTop > ${de}-arrow`]:{top:Ie},[`&-placement-leftBottom > ${de}-arrow`]:{bottom:Ie}})),A(!!st.right,{[[`&-placement-right > ${de}-arrow`,`&-placement-rightTop > ${de}-arrow`,`&-placement-rightBottom > ${de}-arrow`].join(",")]:{left:{_skip_check_:!0,value:H},transform:"translateX(-100%) rotate(-90deg)"},[`&-placement-right > ${de}-arrow`]:{top:{_skip_check_:!0,value:"50%"},transform:"translateY(-50%) translateX(-100%) rotate(-90deg)"},[`&-placement-rightTop > ${de}-arrow`]:{top:Ie},[`&-placement-rightBottom > ${de}-arrow`]:{bottom:Ie}}))}}},36305:function(ii,qe,x){"use strict";x.d(qe,{W:function(){return Ae},w:function(){return J}});var _=x(36237);function J(Y){const{sizePopupArrow:A,borderRadiusXS:g,borderRadiusOuter:te}=Y,G=A/2,re=0,de=G,we=te*1/Math.sqrt(2),Ie=G-te*(1-1/Math.sqrt(2)),D=G-g*(1/Math.sqrt(2)),H=te*(Math.sqrt(2)-1)+g*(1/Math.sqrt(2)),st=2*G-D,Ge=H,Ce=2*G-we,ae=Ie,F=2*G-re,k=de,X=G*Math.sqrt(2)+te*(Math.sqrt(2)-2),le=te*(Math.sqrt(2)-1),me=`polygon(${le}px 100%, 50% ${le}px, ${2*G-le}px 100%, ${le}px 100%)`,Xe=`path('M ${re} ${de} A ${te} ${te} 0 0 0 ${we} ${Ie} L ${D} ${H} A ${g} ${g} 0 0 1 ${st} ${Ge} L ${Ce} ${ae} A ${te} ${te} 0 0 0 ${F} ${k} Z')`;return{arrowShadowWidth:X,arrowPath:Xe,arrowPolygon:me}}const Ae=(Y,A,g)=>{const{sizePopupArrow:te,arrowPolygon:G,arrowPath:re,arrowShadowWidth:de,borderRadiusXS:we,calc:Ie}=Y;return{pointerEvents:"none",width:te,height:te,overflow:"hidden","&::before":{position:"absolute",bottom:0,insetInlineStart:0,width:te,height:Ie(te).div(2).equal(),background:A,clipPath:{_multi_value_:!0,value:[G,re]},content:'""'},"&::after":{content:'""',position:"absolute",width:de,height:de,bottom:0,insetInline:0,margin:"auto",borderRadius:{_skip_check_:!0,value:`0 0 ${(0,_.unit)(we)} 0`},transform:"translateY(50%) rotate(-135deg)",boxShadow:g,zIndex:0,background:"transparent"}}}},93427:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return J}});var _=x(34998);function J(Ae,Y){return _.i.reduce((A,g)=>{const te=Ae[`${g}1`],G=Ae[`${g}3`],re=Ae[`${g}6`],de=Ae[`${g}7`];return Object.assign(Object.assign({},A),Y(g,{lightColor:te,lightBorderColor:G,darkColor:re,textColor:de}))},{})}},25399:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return K}});var _=x(59301),J=x(92310),Ae=x.n(J),Y=x(29125),A=x(18929),g=x(62487),te=x(75030),G=x(86641),re=x(52838),de=x(22703),we=x(32383),Ie=x(55743),D=x(57700),H=x(48755),st=x(36237),Ge=x(63356),Ce=x(34925),ae=x(37645),F=x(36305),k=x(93427),X=x(51636),le=x(16931);const me=Se=>{const{calc:ze,componentCls:ve,tooltipMaxWidth:Pe,tooltipColor:ke,tooltipBg:rt,tooltipBorderRadius:_e,zIndexPopup:Ye,controlHeight:ye,boxShadowSecondary:Ve,paddingSM:We,paddingXS:Mt,arrowOffsetHorizontal:jt,sizePopupArrow:_t}=Se,Le=ze(_e).add(_t).add(jt).equal(),It=ze(_e).mul(2).add(_t).equal();return[{[ve]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,Ge.Wf)(Se)),{position:"absolute",zIndex:Ye,display:"block",width:"max-content",maxWidth:Pe,visibility:"visible","--valid-offset-x":"var(--arrow-offset-horizontal, var(--arrow-x))",transformOrigin:["var(--valid-offset-x, 50%)","var(--arrow-y, 50%)"].join(" "),"&-hidden":{display:"none"},"--antd-arrow-background-color":rt,[`${ve}-inner`]:{minWidth:It,minHeight:ye,padding:`${(0,st.unit)(Se.calc(We).div(2).equal())} ${(0,st.unit)(Mt)}`,color:ke,textAlign:"start",textDecoration:"none",wordWrap:"break-word",backgroundColor:rt,borderRadius:_e,boxShadow:Ve,boxSizing:"border-box"},[["&-placement-topLeft","&-placement-topRight","&-placement-bottomLeft","&-placement-bottomRight"].join(",")]:{minWidth:Le},[["&-placement-left","&-placement-leftTop","&-placement-leftBottom","&-placement-right","&-placement-rightTop","&-placement-rightBottom"].join(",")]:{[`${ve}-inner`]:{borderRadius:Se.min(_e,ae.qN)}},[`${ve}-content`]:{position:"relative"}}),(0,k.Z)(Se,(je,Xt)=>{let{darkColor:oe}=Xt;return{[`&${ve}-${je}`]:{[`${ve}-inner`]:{backgroundColor:oe},[`${ve}-arrow`]:{"--antd-arrow-background-color":oe}}}})),{"&-rtl":{direction:"rtl"}})},(0,ae.ZP)(Se,"var(--antd-arrow-background-color)"),{[`${ve}-pure`]:{position:"relative",maxWidth:"none",margin:Se.sizePopupArrow}}]},Xe=Se=>Object.assign(Object.assign({zIndexPopup:Se.zIndexPopupBase+70},(0,ae.wZ)({contentRadius:Se.borderRadius,limitVerticalRadius:!0})),(0,F.w)((0,X.mergeToken)(Se,{borderRadiusOuter:Math.min(Se.borderRadiusOuter,4)})));var se=function(Se){let ze=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return(0,le.I$)("Tooltip",Pe=>{const{borderRadius:ke,colorTextLightSolid:rt,colorBgSpotlight:_e}=Pe,Ye=(0,X.mergeToken)(Pe,{tooltipMaxWidth:250,tooltipColor:rt,tooltipBorderRadius:ke,tooltipBg:_e});return[me(Ye),(0,Ce._y)(Pe,"zoom-big-fast")]},Xe,{resetStyle:!1,injectStyle:ze})(Se)},vt=x(29509);function yt(Se,ze){const ve=(0,vt.o2)(ze),Pe=Ae()({[`${Se}-${ze}`]:ze&&ve}),ke={},rt={};return ze&&!ve&&(ke.background=ze,rt["--antd-arrow-background-color"]=ze),{className:Pe,overlayStyle:ke,arrowStyle:rt}}var nt=Se=>{const{prefixCls:ze,className:ve,placement:Pe="top",title:ke,color:rt,overlayInnerStyle:_e}=Se,{getPrefixCls:Ye}=_.useContext(H.E_),ye=Ye("tooltip",ze),[Ve,We,Mt]=se(ye),jt=yt(ye,rt),_t=jt.arrowStyle,Le=Object.assign(Object.assign({},_e),jt.overlayStyle),It=Ae()(We,Mt,ye,`${ye}-pure`,`${ye}-placement-${Pe}`,ve,jt.className);return Ve(_.createElement("div",{className:It,style:_t},_.createElement("div",{className:`${ye}-arrow`}),_.createElement(Y.G,Object.assign({},Se,{className:We,prefixCls:ye,overlayInnerStyle:Le}),ke)))},ne=function(Se,ze){var ve={};for(var Pe in Se)Object.prototype.hasOwnProperty.call(Se,Pe)&&ze.indexOf(Pe)<0&&(ve[Pe]=Se[Pe]);if(Se!=null&&typeof Object.getOwnPropertySymbols=="function")for(var ke=0,Pe=Object.getOwnPropertySymbols(Se);ke<Pe.length;ke++)ze.indexOf(Pe[ke])<0&&Object.prototype.propertyIsEnumerable.call(Se,Pe[ke])&&(ve[Pe[ke]]=Se[Pe[ke]]);return ve};const ce=_.forwardRef((Se,ze)=>{var ve,Pe;const{prefixCls:ke,openClassName:rt,getTooltipContainer:_e,color:Ye,overlayInnerStyle:ye,children:Ve,afterOpenChange:We,afterVisibleChange:Mt,destroyTooltipOnHide:jt,arrow:_t=!0,title:Le,overlay:It,builtinPlacements:je,arrowPointAtCenter:Xt=!1,autoAdjustOverflow:oe=!0,motion:Me,getPopupContainer:N,placement:Ue="top",mouseEnterDelay:z=.1,mouseLeaveDelay:$=.1,overlayStyle:M,rootClassName:w,overlayClassName:P,styles:V,classNames:C}=Se,Ee=ne(Se,["prefixCls","openClassName","getTooltipContainer","color","overlayInnerStyle","children","afterOpenChange","afterVisibleChange","destroyTooltipOnHide","arrow","title","overlay","builtinPlacements","arrowPointAtCenter","autoAdjustOverflow","motion","getPopupContainer","placement","mouseEnterDelay","mouseLeaveDelay","overlayStyle","rootClassName","overlayClassName","styles","classNames"]),xe=!!_t,[,Ke]=(0,D.ZP)(),{getPopupContainer:ot,getPrefixCls:Rt,direction:et,className:ut,style:Et,classNames:Tt,styles:lt}=(0,H.dj)("tooltip"),pe=(0,we.ln)("Tooltip"),pt=_.useRef(null),Ei=()=>{var T;(T=pt.current)===null||T===void 0||T.forceAlign()};_.useImperativeHandle(ze,()=>{var T,O;return{forceAlign:Ei,forcePopupAlign:()=>{pe.deprecated(!1,"forcePopupAlign","forceAlign"),Ei()},nativeElement:(T=pt.current)===null||T===void 0?void 0:T.nativeElement,popupElement:(O=pt.current)===null||O===void 0?void 0:O.popupElement}});const[_i,li]=(0,A.Z)(!1,{value:(ve=Se.open)!==null&&ve!==void 0?ve:Se.visible,defaultValue:(Pe=Se.defaultOpen)!==null&&Pe!==void 0?Pe:Se.defaultVisible}),Ai=!Le&&!It&&Le!==0,Vi=T=>{var O,U;li(Ai?!1:T),Ai||((O=Se.onOpenChange)===null||O===void 0||O.call(Se,T),(U=Se.onVisibleChange)===null||U===void 0||U.call(Se,T))},Ti=_.useMemo(()=>{var T,O;let U=Xt;return typeof _t=="object"&&(U=(O=(T=_t.pointAtCenter)!==null&&T!==void 0?T:_t.arrowPointAtCenter)!==null&&O!==void 0?O:Xt),je||(0,re.Z)({arrowPointAtCenter:U,autoAdjustOverflow:oe,arrowWidth:xe?Ke.sizePopupArrow:0,borderRadius:Ke.borderRadius,offset:Ke.marginXXS,visibleFirst:!0})},[Xt,_t,je,Ke]),Ut=_.useMemo(()=>Le===0?Le:It||Le||"",[It,Le]),wi=_.createElement(g.Z,{space:!0},typeof Ut=="function"?Ut():Ut),ui=Rt("tooltip",ke),tt=Rt(),Lt=Se["data-popover-inject"];let St=_i;!("open"in Se)&&!("visible"in Se)&&Ai&&(St=!1);const ti=_.isValidElement(Ve)&&!(0,de.M2)(Ve)?Ve:_.createElement("span",null,Ve),oi=ti.props,ci=!oi.className||typeof oi.className=="string"?Ae()(oi.className,rt||`${ui}-open`):oi.className,[Ht,Ii,Ft]=se(ui,!Lt),si=yt(ui,Ye),Pi=si.arrowStyle,Fe=Ae()(P,{[`${ui}-rtl`]:et==="rtl"},si.className,w,Ii,Ft,ut,Tt.root,C==null?void 0:C.root),d=Ae()(Tt.body,C==null?void 0:C.body),[f,p]=(0,te.Cn)("Tooltip",Ee.zIndex),E=_.createElement(Y.Z,Object.assign({},Ee,{zIndex:f,showArrow:xe,placement:Ue,mouseEnterDelay:z,mouseLeaveDelay:$,prefixCls:ui,classNames:{root:Fe,body:d},styles:{root:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Pi),lt.root),Et),M),V==null?void 0:V.root),body:Object.assign(Object.assign(Object.assign(Object.assign({},lt.body),ye),V==null?void 0:V.body),si.overlayStyle)},getTooltipContainer:N||_e||ot,ref:pt,builtinPlacements:Ti,overlay:wi,visible:St,onVisibleChange:Vi,afterVisibleChange:We!=null?We:Mt,arrowContent:_.createElement("span",{className:`${ui}-arrow-content`}),motion:{motionName:(0,G.m)(tt,"zoom-big-fast",Se.transitionName),motionDeadline:1e3},destroyTooltipOnHide:!!jt}),St?(0,de.Tm)(ti,{className:ci}):ti);return Ht(_.createElement(Ie.Z.Provider,{value:p},E))});ce._InternalPanelDoNotUseOrYouWillBeFired=nt;var K=ce},25769:function(ii,qe,x){"use strict";var _=x(98040),J={"text/plain":"Text","text/html":"Url",default:"Text"},Ae="Copy to clipboard: #{key}, Enter";function Y(g){var te=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return g.replace(/#{\s*key\s*}/g,te)}function A(g,te){var G,re,de,we,Ie,D,H=!1;te||(te={}),G=te.debug||!1;try{de=_(),we=document.createRange(),Ie=document.getSelection(),D=document.createElement("span"),D.textContent=g,D.ariaHidden="true",D.style.all="unset",D.style.position="fixed",D.style.top=0,D.style.clip="rect(0, 0, 0, 0)",D.style.whiteSpace="pre",D.style.webkitUserSelect="text",D.style.MozUserSelect="text",D.style.msUserSelect="text",D.style.userSelect="text",D.addEventListener("copy",function(Ge){if(Ge.stopPropagation(),te.format)if(Ge.preventDefault(),typeof Ge.clipboardData=="undefined"){G&&console.warn("unable to use e.clipboardData"),G&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var Ce=J[te.format]||J.default;window.clipboardData.setData(Ce,g)}else Ge.clipboardData.clearData(),Ge.clipboardData.setData(te.format,g);te.onCopy&&(Ge.preventDefault(),te.onCopy(Ge.clipboardData))}),document.body.appendChild(D),we.selectNodeContents(D),Ie.addRange(we);var st=document.execCommand("copy");if(!st)throw new Error("copy command was unsuccessful");H=!0}catch(Ge){G&&console.error("unable to copy using execCommand: ",Ge),G&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(te.format||"text",g),te.onCopy&&te.onCopy(window.clipboardData),H=!0}catch(Ce){G&&console.error("unable to copy using clipboardData: ",Ce),G&&console.error("falling back to prompt"),re=Y("message"in te?te.message:Ae),window.prompt(re,g)}}finally{Ie&&(typeof Ie.removeRange=="function"?Ie.removeRange(we):Ie.removeAllRanges()),D&&document.body.removeChild(D),de()}return H}ii.exports=A},3867:function(ii,qe,x){var _=x(97671);(function(J,Ae){ii.exports=Ae()})(this,function(){"use strict";function J(w){var P=typeof w;return w!==null&&(P==="object"||P==="function")}function Ae(w){return typeof w=="function"}var Y=void 0;Array.isArray?Y=Array.isArray:Y=function(w){return Object.prototype.toString.call(w)==="[object Array]"};var A=Y,g=0,te=void 0,G=void 0,re=function(P,V){le[g]=P,le[g+1]=V,g+=2,g===2&&(G?G(me):se())};function de(w){G=w}function we(w){re=w}var Ie=typeof window!="undefined"?window:void 0,D=Ie||{},H=D.MutationObserver||D.WebKitMutationObserver,st=typeof self=="undefined"&&typeof _!="undefined"&&{}.toString.call(_)==="[object process]",Ge=typeof Uint8ClampedArray!="undefined"&&typeof importScripts!="undefined"&&typeof MessageChannel!="undefined";function Ce(){return function(){return _.nextTick(me)}}function ae(){return typeof te!="undefined"?function(){te(me)}:X()}function F(){var w=0,P=new H(me),V=document.createTextNode("");return P.observe(V,{characterData:!0}),function(){V.data=w=++w%2}}function k(){var w=new MessageChannel;return w.port1.onmessage=me,function(){return w.port2.postMessage(0)}}function X(){var w=setTimeout;return function(){return w(me,1)}}var le=new Array(1e3);function me(){for(var w=0;w<g;w+=2){var P=le[w],V=le[w+1];P(V),le[w]=void 0,le[w+1]=void 0}g=0}function Xe(){try{var w=Function("return this")().require("vertx");return te=w.runOnLoop||w.runOnContext,ae()}catch(P){return X()}}var se=void 0;st?se=Ce():H?se=F():Ge?se=k():Ie===void 0?se=Xe():se=X();function vt(w,P){var V=this,C=new this.constructor(nt);C[Je]===void 0&&It(C);var Ee=V._state;if(Ee){var xe=arguments[Ee-1];re(function(){return Mt(Ee,C,xe,V._result)})}else Ve(V,C,w,P);return C}function yt(w){var P=this;if(w&&typeof w=="object"&&w.constructor===P)return w;var V=new P(nt);return rt(V,w),V}var Je=Math.random().toString(36).substring(2);function nt(){}var ne=void 0,ee=1,ce=2;function K(){return new TypeError("You cannot resolve a promise with itself")}function Se(){return new TypeError("A promises callback cannot return that same promise.")}function ze(w,P,V,C){try{w.call(P,V,C)}catch(Ee){return Ee}}function ve(w,P,V){re(function(C){var Ee=!1,xe=ze(V,P,function(Ke){Ee||(Ee=!0,P!==Ke?rt(C,Ke):Ye(C,Ke))},function(Ke){Ee||(Ee=!0,ye(C,Ke))},"Settle: "+(C._label||" unknown promise"));!Ee&&xe&&(Ee=!0,ye(C,xe))},w)}function Pe(w,P){P._state===ee?Ye(w,P._result):P._state===ce?ye(w,P._result):Ve(P,void 0,function(V){return rt(w,V)},function(V){return ye(w,V)})}function ke(w,P,V){P.constructor===w.constructor&&V===vt&&P.constructor.resolve===yt?Pe(w,P):V===void 0?Ye(w,P):Ae(V)?ve(w,P,V):Ye(w,P)}function rt(w,P){if(w===P)ye(w,K());else if(J(P)){var V=void 0;try{V=P.then}catch(C){ye(w,C);return}ke(w,P,V)}else Ye(w,P)}function _e(w){w._onerror&&w._onerror(w._result),We(w)}function Ye(w,P){w._state===ne&&(w._result=P,w._state=ee,w._subscribers.length!==0&&re(We,w))}function ye(w,P){w._state===ne&&(w._state=ce,w._result=P,re(_e,w))}function Ve(w,P,V,C){var Ee=w._subscribers,xe=Ee.length;w._onerror=null,Ee[xe]=P,Ee[xe+ee]=V,Ee[xe+ce]=C,xe===0&&w._state&&re(We,w)}function We(w){var P=w._subscribers,V=w._state;if(P.length!==0){for(var C=void 0,Ee=void 0,xe=w._result,Ke=0;Ke<P.length;Ke+=3)C=P[Ke],Ee=P[Ke+V],C?Mt(V,C,Ee,xe):Ee(xe);w._subscribers.length=0}}function Mt(w,P,V,C){var Ee=Ae(V),xe=void 0,Ke=void 0,ot=!0;if(Ee){try{xe=V(C)}catch(Rt){ot=!1,Ke=Rt}if(P===xe){ye(P,Se());return}}else xe=C;P._state!==ne||(Ee&&ot?rt(P,xe):ot===!1?ye(P,Ke):w===ee?Ye(P,xe):w===ce&&ye(P,xe))}function jt(w,P){try{P(function(C){rt(w,C)},function(C){ye(w,C)})}catch(V){ye(w,V)}}var _t=0;function Le(){return _t++}function It(w){w[Je]=_t++,w._state=void 0,w._result=void 0,w._subscribers=[]}function je(){return new Error("Array Methods must be provided an Array")}var Xt=function(){function w(P,V){this._instanceConstructor=P,this.promise=new P(nt),this.promise[Je]||It(this.promise),A(V)?(this.length=V.length,this._remaining=V.length,this._result=new Array(this.length),this.length===0?Ye(this.promise,this._result):(this.length=this.length||0,this._enumerate(V),this._remaining===0&&Ye(this.promise,this._result))):ye(this.promise,je())}return w.prototype._enumerate=function(V){for(var C=0;this._state===ne&&C<V.length;C++)this._eachEntry(V[C],C)},w.prototype._eachEntry=function(V,C){var Ee=this._instanceConstructor,xe=Ee.resolve;if(xe===yt){var Ke=void 0,ot=void 0,Rt=!1;try{Ke=V.then}catch(ut){Rt=!0,ot=ut}if(Ke===vt&&V._state!==ne)this._settledAt(V._state,C,V._result);else if(typeof Ke!="function")this._remaining--,this._result[C]=V;else if(Ee===$){var et=new Ee(nt);Rt?ye(et,ot):ke(et,V,Ke),this._willSettleAt(et,C)}else this._willSettleAt(new Ee(function(ut){return ut(V)}),C)}else this._willSettleAt(xe(V),C)},w.prototype._settledAt=function(V,C,Ee){var xe=this.promise;xe._state===ne&&(this._remaining--,V===ce?ye(xe,Ee):this._result[C]=Ee),this._remaining===0&&Ye(xe,this._result)},w.prototype._willSettleAt=function(V,C){var Ee=this;Ve(V,void 0,function(xe){return Ee._settledAt(ee,C,xe)},function(xe){return Ee._settledAt(ce,C,xe)})},w}();function oe(w){return new Xt(this,w).promise}function Me(w){var P=this;return A(w)?new P(function(V,C){for(var Ee=w.length,xe=0;xe<Ee;xe++)P.resolve(w[xe]).then(V,C)}):new P(function(V,C){return C(new TypeError("You must pass an array to race."))})}function N(w){var P=this,V=new P(nt);return ye(V,w),V}function Ue(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function z(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var $=function(){function w(P){this[Je]=Le(),this._result=this._state=void 0,this._subscribers=[],nt!==P&&(typeof P!="function"&&Ue(),this instanceof w?jt(this,P):z())}return w.prototype.catch=function(V){return this.then(null,V)},w.prototype.finally=function(V){var C=this,Ee=C.constructor;return Ae(V)?C.then(function(xe){return Ee.resolve(V()).then(function(){return xe})},function(xe){return Ee.resolve(V()).then(function(){throw xe})}):C.then(V,V)},w}();$.prototype.then=vt,$.all=oe,$.race=Me,$.resolve=yt,$.reject=N,$._setScheduler=de,$._setAsap=we,$._asap=re;function M(){var w=void 0;if(typeof x.g!="undefined")w=x.g;else if(typeof self!="undefined")w=self;else try{w=Function("return this")()}catch(C){throw new Error("polyfill failed because global object is unavailable in this environment")}var P=w.Promise;if(P){var V=null;try{V=Object.prototype.toString.call(P.resolve())}catch(C){}if(V==="[object Promise]"&&!P.cast)return}w.Promise=$}return $.polyfill=M,$.Promise=$,$})},86204:function(ii){"use strict";var qe=typeof Reflect=="object"?Reflect:null,x=qe&&typeof qe.apply=="function"?qe.apply:function(k,X,le){return Function.prototype.apply.call(k,X,le)},_;qe&&typeof qe.ownKeys=="function"?_=qe.ownKeys:Object.getOwnPropertySymbols?_=function(k){return Object.getOwnPropertyNames(k).concat(Object.getOwnPropertySymbols(k))}:_=function(k){return Object.getOwnPropertyNames(k)};function J(F){console&&console.warn&&console.warn(F)}var Ae=Number.isNaN||function(k){return k!==k};function Y(){Y.init.call(this)}ii.exports=Y,ii.exports.once=Ge,Y.EventEmitter=Y,Y.prototype._events=void 0,Y.prototype._eventsCount=0,Y.prototype._maxListeners=void 0;var A=10;function g(F){if(typeof F!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof F)}Object.defineProperty(Y,"defaultMaxListeners",{enumerable:!0,get:function(){return A},set:function(F){if(typeof F!="number"||F<0||Ae(F))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+F+".");A=F}}),Y.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Y.prototype.setMaxListeners=function(k){if(typeof k!="number"||k<0||Ae(k))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+k+".");return this._maxListeners=k,this};function te(F){return F._maxListeners===void 0?Y.defaultMaxListeners:F._maxListeners}Y.prototype.getMaxListeners=function(){return te(this)},Y.prototype.emit=function(k){for(var X=[],le=1;le<arguments.length;le++)X.push(arguments[le]);var me=k==="error",Xe=this._events;if(Xe!==void 0)me=me&&Xe.error===void 0;else if(!me)return!1;if(me){var se;if(X.length>0&&(se=X[0]),se instanceof Error)throw se;var vt=new Error("Unhandled error."+(se?" ("+se.message+")":""));throw vt.context=se,vt}var yt=Xe[k];if(yt===void 0)return!1;if(typeof yt=="function")x(yt,this,X);else for(var Je=yt.length,nt=D(yt,Je),le=0;le<Je;++le)x(nt[le],this,X);return!0};function G(F,k,X,le){var me,Xe,se;if(g(X),Xe=F._events,Xe===void 0?(Xe=F._events=Object.create(null),F._eventsCount=0):(Xe.newListener!==void 0&&(F.emit("newListener",k,X.listener?X.listener:X),Xe=F._events),se=Xe[k]),se===void 0)se=Xe[k]=X,++F._eventsCount;else if(typeof se=="function"?se=Xe[k]=le?[X,se]:[se,X]:le?se.unshift(X):se.push(X),me=te(F),me>0&&se.length>me&&!se.warned){se.warned=!0;var vt=new Error("Possible EventEmitter memory leak detected. "+se.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");vt.name="MaxListenersExceededWarning",vt.emitter=F,vt.type=k,vt.count=se.length,J(vt)}return F}Y.prototype.addListener=function(k,X){return G(this,k,X,!1)},Y.prototype.on=Y.prototype.addListener,Y.prototype.prependListener=function(k,X){return G(this,k,X,!0)};function re(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function de(F,k,X){var le={fired:!1,wrapFn:void 0,target:F,type:k,listener:X},me=re.bind(le);return me.listener=X,le.wrapFn=me,me}Y.prototype.once=function(k,X){return g(X),this.on(k,de(this,k,X)),this},Y.prototype.prependOnceListener=function(k,X){return g(X),this.prependListener(k,de(this,k,X)),this},Y.prototype.removeListener=function(k,X){var le,me,Xe,se,vt;if(g(X),me=this._events,me===void 0)return this;if(le=me[k],le===void 0)return this;if(le===X||le.listener===X)--this._eventsCount===0?this._events=Object.create(null):(delete me[k],me.removeListener&&this.emit("removeListener",k,le.listener||X));else if(typeof le!="function"){for(Xe=-1,se=le.length-1;se>=0;se--)if(le[se]===X||le[se].listener===X){vt=le[se].listener,Xe=se;break}if(Xe<0)return this;Xe===0?le.shift():H(le,Xe),le.length===1&&(me[k]=le[0]),me.removeListener!==void 0&&this.emit("removeListener",k,vt||X)}return this},Y.prototype.off=Y.prototype.removeListener,Y.prototype.removeAllListeners=function(k){var X,le,me;if(le=this._events,le===void 0)return this;if(le.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):le[k]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete le[k]),this;if(arguments.length===0){var Xe=Object.keys(le),se;for(me=0;me<Xe.length;++me)se=Xe[me],se!=="removeListener"&&this.removeAllListeners(se);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(X=le[k],typeof X=="function")this.removeListener(k,X);else if(X!==void 0)for(me=X.length-1;me>=0;me--)this.removeListener(k,X[me]);return this};function we(F,k,X){var le=F._events;if(le===void 0)return[];var me=le[k];return me===void 0?[]:typeof me=="function"?X?[me.listener||me]:[me]:X?st(me):D(me,me.length)}Y.prototype.listeners=function(k){return we(this,k,!0)},Y.prototype.rawListeners=function(k){return we(this,k,!1)},Y.listenerCount=function(F,k){return typeof F.listenerCount=="function"?F.listenerCount(k):Ie.call(F,k)},Y.prototype.listenerCount=Ie;function Ie(F){var k=this._events;if(k!==void 0){var X=k[F];if(typeof X=="function")return 1;if(X!==void 0)return X.length}return 0}Y.prototype.eventNames=function(){return this._eventsCount>0?_(this._events):[]};function D(F,k){for(var X=new Array(k),le=0;le<k;++le)X[le]=F[le];return X}function H(F,k){for(;k+1<F.length;k++)F[k]=F[k+1];F.pop()}function st(F){for(var k=new Array(F.length),X=0;X<k.length;++X)k[X]=F[X].listener||F[X];return k}function Ge(F,k){return new Promise(function(X,le){function me(se){F.removeListener(k,Xe),le(se)}function Xe(){typeof F.removeListener=="function"&&F.removeListener("error",me),X([].slice.call(arguments))}ae(F,k,Xe,{once:!0}),k!=="error"&&Ce(F,me,{once:!0})})}function Ce(F,k,X){typeof F.on=="function"&&ae(F,"error",k,X)}function ae(F,k,X,le){if(typeof F.on=="function")le.once?F.once(k,X):F.on(k,X);else if(typeof F.addEventListener=="function")F.addEventListener(k,function me(Xe){le.once&&F.removeEventListener(k,me),X(Xe)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof F)}},96478:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return Xe}});var _=x(54476),J=x(20068),Ae=x(42978),Y=x(75931),A=x(65030),g=x(92310),te=x.n(g),G=x(8654),re=x(59301),de=x(10228),we=x(16089),Ie=de.Z.ESC,D=de.Z.TAB;function H(se){var vt=se.visible,yt=se.triggerRef,Je=se.onVisibleChange,nt=se.autoFocus,ne=se.overlayRef,ee=re.useRef(!1),ce=function(){if(vt){var ve,Pe;(ve=yt.current)===null||ve===void 0||(Pe=ve.focus)===null||Pe===void 0||Pe.call(ve),Je==null||Je(!1)}},K=function(){var ve;return(ve=ne.current)!==null&&ve!==void 0&&ve.focus?(ne.current.focus(),ee.current=!0,!0):!1},Se=function(ve){switch(ve.keyCode){case Ie:ce();break;case D:{var Pe=!1;ee.current||(Pe=K()),Pe?ve.preventDefault():ce();break}}};re.useEffect(function(){return vt?(window.addEventListener("keydown",Se),nt&&(0,we.Z)(K,3),function(){window.removeEventListener("keydown",Se),ee.current=!1}):function(){ee.current=!1}},[vt])}var st=(0,re.forwardRef)(function(se,vt){var yt=se.overlay,Je=se.arrow,nt=se.prefixCls,ne=(0,re.useMemo)(function(){var ce;return typeof yt=="function"?ce=yt():ce=yt,ce},[yt]),ee=(0,G.sQ)(vt,(0,G.C4)(ne));return re.createElement(re.Fragment,null,Je&&re.createElement("div",{className:"".concat(nt,"-arrow")}),re.cloneElement(ne,{ref:(0,G.Yr)(ne)?ee:void 0}))}),Ge=st,Ce={adjustX:1,adjustY:1},ae=[0,0],F={topLeft:{points:["bl","tl"],overflow:Ce,offset:[0,-4],targetOffset:ae},top:{points:["bc","tc"],overflow:Ce,offset:[0,-4],targetOffset:ae},topRight:{points:["br","tr"],overflow:Ce,offset:[0,-4],targetOffset:ae},bottomLeft:{points:["tl","bl"],overflow:Ce,offset:[0,4],targetOffset:ae},bottom:{points:["tc","bc"],overflow:Ce,offset:[0,4],targetOffset:ae},bottomRight:{points:["tr","br"],overflow:Ce,offset:[0,4],targetOffset:ae}},k=F,X=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus","overlay","children","onVisibleChange"];function le(se,vt){var yt,Je=se.arrow,nt=Je===void 0?!1:Je,ne=se.prefixCls,ee=ne===void 0?"rc-dropdown":ne,ce=se.transitionName,K=se.animation,Se=se.align,ze=se.placement,ve=ze===void 0?"bottomLeft":ze,Pe=se.placements,ke=Pe===void 0?k:Pe,rt=se.getPopupContainer,_e=se.showAction,Ye=se.hideAction,ye=se.overlayClassName,Ve=se.overlayStyle,We=se.visible,Mt=se.trigger,jt=Mt===void 0?["hover"]:Mt,_t=se.autoFocus,Le=se.overlay,It=se.children,je=se.onVisibleChange,Xt=(0,Y.Z)(se,X),oe=re.useState(),Me=(0,Ae.Z)(oe,2),N=Me[0],Ue=Me[1],z="visible"in se?We:N,$=re.useRef(null),M=re.useRef(null),w=re.useRef(null);re.useImperativeHandle(vt,function(){return $.current});var P=function(ut){Ue(ut),je==null||je(ut)};H({visible:z,triggerRef:w,onVisibleChange:P,autoFocus:_t,overlayRef:M});var V=function(ut){var Et=se.onOverlayClick;Ue(!1),Et&&Et(ut)},C=function(){return re.createElement(Ge,{ref:M,overlay:Le,prefixCls:ee,arrow:nt})},Ee=function(){return typeof Le=="function"?C:C()},xe=function(){var ut=se.minOverlayWidthMatchTrigger,Et=se.alignPoint;return"minOverlayWidthMatchTrigger"in se?ut:!Et},Ke=function(){var ut=se.openClassName;return ut!==void 0?ut:"".concat(ee,"-open")},ot=re.cloneElement(It,{className:te()((yt=It.props)===null||yt===void 0?void 0:yt.className,z&&Ke()),ref:(0,G.Yr)(It)?(0,G.sQ)(w,(0,G.C4)(It)):void 0}),Rt=Ye;return!Rt&&jt.indexOf("contextMenu")!==-1&&(Rt=["click"]),re.createElement(A.Z,(0,_.Z)({builtinPlacements:ke},Xt,{prefixCls:ee,ref:$,popupClassName:te()(ye,(0,J.Z)({},"".concat(ee,"-show-arrow"),nt)),popupStyle:Ve,action:jt,showAction:_e,hideAction:Rt,popupPlacement:ve,popupAlign:Se,popupTransitionName:ce,popupAnimation:K,popupVisible:z,stretch:xe()?"minWidth":"",popup:Ee(),onPopupVisibleChange:P,onPopupClick:V,getPopupContainer:rt}),ot)}var me=re.forwardRef(le),Xe=me},28321:function(ii,qe,x){"use strict";x.d(qe,{iz:function(){return Pt},ck:function(){return tt},BW:function(){return He},sN:function(){return tt},Wd:function(){return ct},ZP:function(){return ki},Xl:function(){return yt}});var _=x(54476),J=x(20068),Ae=x(33885),Y=x(94480),A=x(42978),g=x(75931),te=x(92310),G=x.n(te),re=x(83836),de=x(18929),we=x(13697),Ie=x(48736),D=x(59301),H=x(4676),st=D.createContext(null);function Ge(W,Q){return W===void 0?null:"".concat(W,"-").concat(Q)}function Ce(W){var Q=D.useContext(st);return Ge(Q,W)}var ae=x(80547),F=["children","locked"],k=D.createContext(null);function X(W,Q){var Re=(0,Ae.Z)({},W);return Object.keys(Q).forEach(function(ge){var ue=Q[ge];ue!==void 0&&(Re[ge]=ue)}),Re}function le(W){var Q=W.children,Re=W.locked,ge=(0,g.Z)(W,F),ue=D.useContext(k),Te=(0,ae.Z)(function(){return X(ue,ge)},[ue,ge],function(Be,Qe){return!Re&&(Be[0]!==Qe[0]||!(0,we.Z)(Be[1],Qe[1],!0))});return D.createElement(k.Provider,{value:Te},Q)}var me=[],Xe=D.createContext(null);function se(){return D.useContext(Xe)}var vt=D.createContext(me);function yt(W){var Q=D.useContext(vt);return D.useMemo(function(){return W!==void 0?[].concat((0,Y.Z)(Q),[W]):Q},[Q,W])}var Je=D.createContext(null),nt=D.createContext({}),ne=nt,ee=x(29194);function ce(W){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if((0,ee.Z)(W)){var Re=W.nodeName.toLowerCase(),ge=["input","select","textarea","button"].includes(Re)||W.isContentEditable||Re==="a"&&!!W.getAttribute("href"),ue=W.getAttribute("tabindex"),Te=Number(ue),Be=null;return ue&&!Number.isNaN(Te)?Be=Te:ge&&Be===null&&(Be=0),ge&&W.disabled&&(Be=null),Be!==null&&(Be>=0||Q&&Be<0)}return!1}function K(W){var Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,Re=(0,Y.Z)(W.querySelectorAll("*")).filter(function(ge){return ce(ge,Q)});return ce(W,Q)&&Re.unshift(W),Re}var Se=null;function ze(){Se=document.activeElement}function ve(){Se=null}function Pe(){if(Se)try{Se.focus()}catch(W){}}function ke(W,Q){if(Q.keyCode===9){var Re=K(W),ge=Re[Q.shiftKey?0:Re.length-1],ue=ge===document.activeElement||W===document.activeElement;if(ue){var Te=Re[Q.shiftKey?Re.length-1:0];Te.focus(),Q.preventDefault()}}}var rt=x(10228),_e=x(16089),Ye=rt.Z.LEFT,ye=rt.Z.RIGHT,Ve=rt.Z.UP,We=rt.Z.DOWN,Mt=rt.Z.ENTER,jt=rt.Z.ESC,_t=rt.Z.HOME,Le=rt.Z.END,It=[Ve,We,Ye,ye];function je(W,Q,Re,ge){var ue,Te="prev",Be="next",Qe="children",Kt="parent";if(W==="inline"&&ge===Mt)return{inlineTrigger:!0};var xt=(0,J.Z)((0,J.Z)({},Ve,Te),We,Be),ei=(0,J.Z)((0,J.Z)((0,J.Z)((0,J.Z)({},Ye,Re?Be:Te),ye,Re?Te:Be),We,Qe),Mt,Qe),Nt=(0,J.Z)((0,J.Z)((0,J.Z)((0,J.Z)((0,J.Z)((0,J.Z)({},Ve,Te),We,Be),Mt,Qe),jt,Kt),Ye,Re?Qe:Kt),ye,Re?Kt:Qe),Zt={inline:xt,horizontal:ei,vertical:Nt,inlineSub:xt,horizontalSub:Nt,verticalSub:Nt},Qt=(ue=Zt["".concat(W).concat(Q?"":"Sub")])===null||ue===void 0?void 0:ue[ge];switch(Qt){case Te:return{offset:-1,sibling:!0};case Be:return{offset:1,sibling:!0};case Kt:return{offset:-1,sibling:!1};case Qe:return{offset:1,sibling:!1};default:return null}}function Xt(W){for(var Q=W;Q;){if(Q.getAttribute("data-menu-list"))return Q;Q=Q.parentElement}return null}function oe(W,Q){for(var Re=W||document.activeElement;Re;){if(Q.has(Re))return Re;Re=Re.parentElement}return null}function Me(W,Q){var Re=K(W,!0);return Re.filter(function(ge){return Q.has(ge)})}function N(W,Q,Re){var ge=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!W)return null;var ue=Me(W,Q),Te=ue.length,Be=ue.findIndex(function(Qe){return Re===Qe});return ge<0?Be===-1?Be=Te-1:Be-=1:ge>0&&(Be+=1),Be=(Be+Te)%Te,ue[Be]}var Ue=function(Q,Re){var ge=new Set,ue=new Map,Te=new Map;return Q.forEach(function(Be){var Qe=document.querySelector("[data-menu-id='".concat(Ge(Re,Be),"']"));Qe&&(ge.add(Qe),Te.set(Qe,Be),ue.set(Be,Qe))}),{elements:ge,key2element:ue,element2key:Te}};function z(W,Q,Re,ge,ue,Te,Be,Qe,Kt,xt){var ei=D.useRef(),Nt=D.useRef();Nt.current=Q;var Zt=function(){_e.Z.cancel(ei.current)};return D.useEffect(function(){return function(){Zt()}},[]),function(Qt){var gi=Qt.which;if([].concat(It,[Mt,jt,_t,Le]).includes(gi)){var Si=Te(),zt=Ue(Si,ge),qt=zt,pi=qt.elements,hi=qt.key2element,ri=qt.element2key,Ni=hi.get(Q),vi=oe(Ni,pi),Li=ri.get(vi),Zi=je(W,Be(Li,!0).length===1,Re,gi);if(!Zi&&gi!==_t&&gi!==Le)return;(It.includes(gi)||[_t,Le].includes(gi))&&Qt.preventDefault();var Gi=function(Di){if(Di){var fs=Di,Oi=Di.querySelector("a");Oi!=null&&Oi.getAttribute("href")&&(fs=Oi);var xi=ri.get(Di);Qe(xi),Zt(),ei.current=(0,_e.Z)(function(){Nt.current===xi&&fs.focus()})}};if([_t,Le].includes(gi)||Zi.sibling||!vi){var ns;!vi||W==="inline"?ns=ue.current:ns=Xt(vi);var ji,Yi=Me(ns,pi);gi===_t?ji=Yi[0]:gi===Le?ji=Yi[Yi.length-1]:ji=N(ns,pi,vi,Zi.offset),Gi(ji)}else if(Zi.inlineTrigger)Kt(Li);else if(Zi.offset>0)Kt(Li,!0),Zt(),ei.current=(0,_e.Z)(function(){zt=Ue(Si,ge);var Ci=vi.getAttribute("aria-controls"),Di=document.getElementById(Ci),fs=N(Di,zt.elements);Gi(fs)},5);else if(Zi.offset<0){var Ji=Be(Li,!0),es=Ji[Ji.length-2],qi=hi.get(es);Kt(es,!1),Gi(qi)}}xt==null||xt(Qt)}}function $(W){Promise.resolve().then(W)}var M="__RC_UTIL_PATH_SPLIT__",w=function(Q){return Q.join(M)},P=function(Q){return Q.split(M)},V="rc-menu-more";function C(){var W=D.useState({}),Q=(0,A.Z)(W,2),Re=Q[1],ge=(0,D.useRef)(new Map),ue=(0,D.useRef)(new Map),Te=D.useState([]),Be=(0,A.Z)(Te,2),Qe=Be[0],Kt=Be[1],xt=(0,D.useRef)(0),ei=(0,D.useRef)(!1),Nt=function(){ei.current||Re({})},Zt=(0,D.useCallback)(function(hi,ri){var Ni=w(ri);ue.current.set(Ni,hi),ge.current.set(hi,Ni),xt.current+=1;var vi=xt.current;$(function(){vi===xt.current&&Nt()})},[]),Qt=(0,D.useCallback)(function(hi,ri){var Ni=w(ri);ue.current.delete(Ni),ge.current.delete(hi)},[]),gi=(0,D.useCallback)(function(hi){Kt(hi)},[]),Si=(0,D.useCallback)(function(hi,ri){var Ni=ge.current.get(hi)||"",vi=P(Ni);return ri&&Qe.includes(vi[0])&&vi.unshift(V),vi},[Qe]),zt=(0,D.useCallback)(function(hi,ri){return hi.filter(function(Ni){return Ni!==void 0}).some(function(Ni){var vi=Si(Ni,!0);return vi.includes(ri)})},[Si]),qt=function(){var ri=(0,Y.Z)(ge.current.keys());return Qe.length&&ri.push(V),ri},pi=(0,D.useCallback)(function(hi){var ri="".concat(ge.current.get(hi)).concat(M),Ni=new Set;return(0,Y.Z)(ue.current.keys()).forEach(function(vi){vi.startsWith(ri)&&Ni.add(ue.current.get(vi))}),Ni},[]);return D.useEffect(function(){return function(){ei.current=!0}},[]),{registerPath:Zt,unregisterPath:Qt,refreshOverflowKeys:gi,isSubPathKey:zt,getKeyPath:Si,getKeys:qt,getSubPathKeys:pi}}function Ee(W){var Q=D.useRef(W);Q.current=W;var Re=D.useCallback(function(){for(var ge,ue=arguments.length,Te=new Array(ue),Be=0;Be<ue;Be++)Te[Be]=arguments[Be];return(ge=Q.current)===null||ge===void 0?void 0:ge.call.apply(ge,[Q].concat(Te))},[]);return W?Re:void 0}var xe=Math.random().toFixed(5).toString().slice(2),Ke=0;function ot(W){var Q=(0,de.Z)(W,{value:W}),Re=(0,A.Z)(Q,2),ge=Re[0],ue=Re[1];return D.useEffect(function(){Ke+=1;var Te="".concat(xe,"-").concat(Ke);ue("rc-menu-uuid-".concat(Te))},[]),ge}var Rt=x(67732),et=x(83652),ut=x(42403),Et=x(158),Tt=x(2738),lt=x(8654);function pe(W,Q,Re,ge){var ue=D.useContext(k),Te=ue.activeKey,Be=ue.onActive,Qe=ue.onInactive,Kt={active:Te===W};return Q||(Kt.onMouseEnter=function(xt){Re==null||Re({key:W,domEvent:xt}),Be(W)},Kt.onMouseLeave=function(xt){ge==null||ge({key:W,domEvent:xt}),Qe(W)}),Kt}function pt(W){var Q=D.useContext(k),Re=Q.mode,ge=Q.rtl,ue=Q.inlineIndent;if(Re!=="inline")return null;var Te=W;return ge?{paddingRight:Te*ue}:{paddingLeft:Te*ue}}function Ei(W){var Q=W.icon,Re=W.props,ge=W.children,ue;return Q===null||Q===!1?null:(typeof Q=="function"?ue=D.createElement(Q,(0,Ae.Z)({},Re)):typeof Q!="boolean"&&(ue=Q),ue||ge||null)}var _i=["item"];function li(W){var Q=W.item,Re=(0,g.Z)(W,_i);return Object.defineProperty(Re,"item",{get:function(){return(0,Ie.ZP)(!1,"`info.item` is deprecated since we will move to function component that not provides React Node instance in future."),Q}}),Re}var Ai=["title","attribute","elementRef"],Vi=["style","className","eventKey","warnKey","disabled","itemIcon","children","role","onMouseEnter","onMouseLeave","onClick","onKeyDown","onFocus"],Ti=["active"],Ut=function(W){(0,ut.Z)(Re,W);var Q=(0,Et.Z)(Re);function Re(){return(0,Rt.Z)(this,Re),Q.apply(this,arguments)}return(0,et.Z)(Re,[{key:"render",value:function(){var ue=this.props,Te=ue.title,Be=ue.attribute,Qe=ue.elementRef,Kt=(0,g.Z)(ue,Ai),xt=(0,Tt.Z)(Kt,["eventKey","popupClassName","popupOffset","onTitleClick"]);return(0,Ie.ZP)(!Be,"`attribute` of Menu.Item is deprecated. Please pass attribute directly."),D.createElement(re.Z.Item,(0,_.Z)({},Be,{title:typeof Te=="string"?Te:void 0},xt,{ref:Qe}))}}]),Re}(D.Component),wi=D.forwardRef(function(W,Q){var Re=W.style,ge=W.className,ue=W.eventKey,Te=W.warnKey,Be=W.disabled,Qe=W.itemIcon,Kt=W.children,xt=W.role,ei=W.onMouseEnter,Nt=W.onMouseLeave,Zt=W.onClick,Qt=W.onKeyDown,gi=W.onFocus,Si=(0,g.Z)(W,Vi),zt=Ce(ue),qt=D.useContext(k),pi=qt.prefixCls,hi=qt.onItemClick,ri=qt.disabled,Ni=qt.overflowDisabled,vi=qt.itemIcon,Li=qt.selectedKeys,Zi=qt.onActive,Gi=D.useContext(ne),ns=Gi._internalRenderMenuItem,ji="".concat(pi,"-item"),Yi=D.useRef(),Ji=D.useRef(),es=ri||Be,qi=(0,lt.x1)(Q,Ji),Ci=yt(ue),Di=function(Qi){return{key:ue,keyPath:(0,Y.Z)(Ci).reverse(),item:Yi.current,domEvent:Qi}},fs=Qe||vi,Oi=pe(ue,es,ei,Nt),xi=Oi.active,ks=(0,g.Z)(Oi,Ti),ps=Li.includes(ue),ts=pt(Ci.length),Is=function(Qi){if(!es){var rs=Di(Qi);Zt==null||Zt(li(rs)),hi(rs)}},Hi=function(Qi){if(Qt==null||Qt(Qi),Qi.which===rt.Z.ENTER){var rs=Di(Qi);Zt==null||Zt(li(rs)),hi(rs)}},us=function(Qi){Zi(ue),gi==null||gi(Qi)},Fs={};W.role==="option"&&(Fs["aria-selected"]=ps);var vs=D.createElement(Ut,(0,_.Z)({ref:Yi,elementRef:qi,role:xt===null?"none":xt||"menuitem",tabIndex:Be?null:-1,"data-menu-id":Ni&&zt?null:zt},(0,Tt.Z)(Si,["extra"]),ks,Fs,{component:"li","aria-disabled":Be,style:(0,Ae.Z)((0,Ae.Z)({},ts),Re),className:G()(ji,(0,J.Z)((0,J.Z)((0,J.Z)({},"".concat(ji,"-active"),xi),"".concat(ji,"-selected"),ps),"".concat(ji,"-disabled"),es),ge),onClick:Is,onKeyDown:Hi,onFocus:us}),Kt,D.createElement(Ei,{props:(0,Ae.Z)((0,Ae.Z)({},W),{},{isSelected:ps}),icon:fs}));return ns&&(vs=ns(vs,W,{selected:ps})),vs});function ui(W,Q){var Re=W.eventKey,ge=se(),ue=yt(Re);return D.useEffect(function(){if(ge)return ge.registerPath(Re,ue),function(){ge.unregisterPath(Re,ue)}},[ue]),ge?null:D.createElement(wi,(0,_.Z)({},W,{ref:Q}))}var tt=D.forwardRef(ui),Lt=["className","children"],St=function(Q,Re){var ge=Q.className,ue=Q.children,Te=(0,g.Z)(Q,Lt),Be=D.useContext(k),Qe=Be.prefixCls,Kt=Be.mode,xt=Be.rtl;return D.createElement("ul",(0,_.Z)({className:G()(Qe,xt&&"".concat(Qe,"-rtl"),"".concat(Qe,"-sub"),"".concat(Qe,"-").concat(Kt==="inline"?"inline":"vertical"),ge),role:"menu"},Te,{"data-menu-list":!0,ref:Re}),ue)},ti=D.forwardRef(St);ti.displayName="SubMenuList";var oi=ti,ci=x(11592);function Ht(W,Q){return(0,ci.Z)(W).map(function(Re,ge){if(D.isValidElement(Re)){var ue,Te,Be=Re.key,Qe=(ue=(Te=Re.props)===null||Te===void 0?void 0:Te.eventKey)!==null&&ue!==void 0?ue:Be,Kt=Qe==null;Kt&&(Qe="tmp_key-".concat([].concat((0,Y.Z)(Q),[ge]).join("-")));var xt={key:Qe,eventKey:Qe};return D.cloneElement(Re,xt)}return Re})}var Ii=x(65030),Ft={adjustX:1,adjustY:1},si={topLeft:{points:["bl","tl"],overflow:Ft},topRight:{points:["br","tr"],overflow:Ft},bottomLeft:{points:["tl","bl"],overflow:Ft},bottomRight:{points:["tr","br"],overflow:Ft},leftTop:{points:["tr","tl"],overflow:Ft},leftBottom:{points:["br","bl"],overflow:Ft},rightTop:{points:["tl","tr"],overflow:Ft},rightBottom:{points:["bl","br"],overflow:Ft}},Pi={topLeft:{points:["bl","tl"],overflow:Ft},topRight:{points:["br","tr"],overflow:Ft},bottomLeft:{points:["tl","bl"],overflow:Ft},bottomRight:{points:["tr","br"],overflow:Ft},rightTop:{points:["tr","tl"],overflow:Ft},rightBottom:{points:["br","bl"],overflow:Ft},leftTop:{points:["tl","tr"],overflow:Ft},leftBottom:{points:["bl","br"],overflow:Ft}},Fe=null;function d(W,Q,Re){if(Q)return Q;if(Re)return Re[W]||Re.other}var f={horizontal:"bottomLeft",vertical:"rightTop","vertical-left":"rightTop","vertical-right":"leftTop"};function p(W){var Q=W.prefixCls,Re=W.visible,ge=W.children,ue=W.popup,Te=W.popupStyle,Be=W.popupClassName,Qe=W.popupOffset,Kt=W.disabled,xt=W.mode,ei=W.onVisibleChange,Nt=D.useContext(k),Zt=Nt.getPopupContainer,Qt=Nt.rtl,gi=Nt.subMenuOpenDelay,Si=Nt.subMenuCloseDelay,zt=Nt.builtinPlacements,qt=Nt.triggerSubMenuAction,pi=Nt.forceSubMenuRender,hi=Nt.rootClassName,ri=Nt.motion,Ni=Nt.defaultMotions,vi=D.useState(!1),Li=(0,A.Z)(vi,2),Zi=Li[0],Gi=Li[1],ns=Qt?(0,Ae.Z)((0,Ae.Z)({},Pi),zt):(0,Ae.Z)((0,Ae.Z)({},si),zt),ji=f[xt],Yi=d(xt,ri,Ni),Ji=D.useRef(Yi);xt!=="inline"&&(Ji.current=Yi);var es=(0,Ae.Z)((0,Ae.Z)({},Ji.current),{},{leavedClassName:"".concat(Q,"-hidden"),removeOnLeave:!1,motionAppear:!0}),qi=D.useRef();return D.useEffect(function(){return qi.current=(0,_e.Z)(function(){Gi(Re)}),function(){_e.Z.cancel(qi.current)}},[Re]),D.createElement(Ii.Z,{prefixCls:Q,popupClassName:G()("".concat(Q,"-popup"),(0,J.Z)({},"".concat(Q,"-rtl"),Qt),Be,hi),stretch:xt==="horizontal"?"minWidth":null,getPopupContainer:Zt,builtinPlacements:ns,popupPlacement:ji,popupVisible:Zi,popup:ue,popupStyle:Te,popupAlign:Qe&&{offset:Qe},action:Kt?[]:[qt],mouseEnterDelay:gi,mouseLeaveDelay:Si,onPopupVisibleChange:ei,forceRender:pi,popupMotion:es,fresh:!0},ge)}var E=x(77900);function T(W){var Q=W.id,Re=W.open,ge=W.keyPath,ue=W.children,Te="inline",Be=D.useContext(k),Qe=Be.prefixCls,Kt=Be.forceSubMenuRender,xt=Be.motion,ei=Be.defaultMotions,Nt=Be.mode,Zt=D.useRef(!1);Zt.current=Nt===Te;var Qt=D.useState(!Zt.current),gi=(0,A.Z)(Qt,2),Si=gi[0],zt=gi[1],qt=Zt.current?Re:!1;D.useEffect(function(){Zt.current&&zt(!1)},[Nt]);var pi=(0,Ae.Z)({},d(Te,xt,ei));ge.length>1&&(pi.motionAppear=!1);var hi=pi.onVisibleChanged;return pi.onVisibleChanged=function(ri){return!Zt.current&&!ri&&zt(!0),hi==null?void 0:hi(ri)},Si?null:D.createElement(le,{mode:Te,locked:!Zt.current},D.createElement(E.default,(0,_.Z)({visible:qt},pi,{forceRender:Kt,removeOnLeave:!1,leavedClassName:"".concat(Qe,"-hidden")}),function(ri){var Ni=ri.className,vi=ri.style;return D.createElement(oi,{id:Q,className:Ni,style:vi},ue)}))}var O=["style","className","title","eventKey","warnKey","disabled","internalPopupClose","children","itemIcon","expandIcon","popupClassName","popupOffset","popupStyle","onClick","onMouseEnter","onMouseLeave","onTitleClick","onTitleMouseEnter","onTitleMouseLeave"],U=["active"],Ze=D.forwardRef(function(W,Q){var Re=W.style,ge=W.className,ue=W.title,Te=W.eventKey,Be=W.warnKey,Qe=W.disabled,Kt=W.internalPopupClose,xt=W.children,ei=W.itemIcon,Nt=W.expandIcon,Zt=W.popupClassName,Qt=W.popupOffset,gi=W.popupStyle,Si=W.onClick,zt=W.onMouseEnter,qt=W.onMouseLeave,pi=W.onTitleClick,hi=W.onTitleMouseEnter,ri=W.onTitleMouseLeave,Ni=(0,g.Z)(W,O),vi=Ce(Te),Li=D.useContext(k),Zi=Li.prefixCls,Gi=Li.mode,ns=Li.openKeys,ji=Li.disabled,Yi=Li.overflowDisabled,Ji=Li.activeKey,es=Li.selectedKeys,qi=Li.itemIcon,Ci=Li.expandIcon,Di=Li.onItemClick,fs=Li.onOpenChange,Oi=Li.onActive,xi=D.useContext(ne),ks=xi._internalRenderSubMenuItem,ps=D.useContext(Je),ts=ps.isSubPathKey,Is=yt(),Hi="".concat(Zi,"-submenu"),us=ji||Qe,Fs=D.useRef(),vs=D.useRef(),ys=ei!=null?ei:qi,Qi=Nt!=null?Nt:Ci,rs=ns.includes(Te),cs=!Yi&&rs,Ps=ts(es,Te),as=pe(Te,us,hi,ri),ds=as.active,Rs=(0,g.Z)(as,U),Bs=D.useState(!1),hs=(0,A.Z)(Bs,2),js=hs[0],Ns=hs[1],Ls=function(ls){us||Ns(ls)},Qs=function(ls){Ls(!0),zt==null||zt({key:Te,domEvent:ls})},Yt=function(ls){Ls(!1),qt==null||qt({key:Te,domEvent:ls})},zs=D.useMemo(function(){return ds||(Gi!=="inline"?js||ts([Ji],Te):!1)},[Gi,ds,Ji,js,Te,ts]),Es=pt(Is.length),Js=function(ls){us||(pi==null||pi({key:Te,domEvent:ls}),Gi==="inline"&&fs(Te,!rs))},on=Ee(function(Wi){Si==null||Si(li(Wi)),Di(Wi)}),en=function(ls){Gi!=="inline"&&fs(Te,ls)},ln=function(){Oi(Te)},Ws=vi&&"".concat(vi,"-popup"),Fi=D.useMemo(function(){return D.createElement(Ei,{icon:Gi!=="horizontal"?Qi:void 0,props:(0,Ae.Z)((0,Ae.Z)({},W),{},{isOpen:cs,isSubMenu:!0})},D.createElement("i",{className:"".concat(Hi,"-arrow")}))},[Gi,Qi,W,cs,Hi]),os=D.createElement("div",(0,_.Z)({role:"menuitem",style:Es,className:"".concat(Hi,"-title"),tabIndex:us?null:-1,ref:Fs,title:typeof ue=="string"?ue:null,"data-menu-id":Yi&&vi?null:vi,"aria-expanded":cs,"aria-haspopup":!0,"aria-controls":Ws,"aria-disabled":us,onClick:Js,onFocus:ln},Rs),ue,Fi),Cs=D.useRef(Gi);if(Gi!=="inline"&&Is.length>1?Cs.current="vertical":Cs.current=Gi,!Yi){var tn=Cs.current;os=D.createElement(p,{mode:tn,prefixCls:Hi,visible:!Kt&&cs&&Gi!=="inline",popupClassName:Zt,popupOffset:Qt,popupStyle:gi,popup:D.createElement(le,{mode:tn==="horizontal"?"vertical":tn},D.createElement(oi,{id:Ws,ref:vs},xt)),disabled:us,onVisibleChange:en},os)}var is=D.createElement(re.Z.Item,(0,_.Z)({ref:Q,role:"none"},Ni,{component:"li",style:Re,className:G()(Hi,"".concat(Hi,"-").concat(Gi),ge,(0,J.Z)((0,J.Z)((0,J.Z)((0,J.Z)({},"".concat(Hi,"-open"),cs),"".concat(Hi,"-active"),zs),"".concat(Hi,"-selected"),Ps),"".concat(Hi,"-disabled"),us)),onMouseEnter:Qs,onMouseLeave:Yt}),os,!Yi&&D.createElement(T,{id:Ws,open:cs,keyPath:Is},xt));return ks&&(is=ks(is,W,{selected:Ps,active:zs,open:cs,disabled:us})),D.createElement(le,{onItemClick:on,mode:Gi==="horizontal"?"vertical":Gi,itemIcon:ys,expandIcon:Qi},is)}),$e=D.forwardRef(function(W,Q){var Re=W.eventKey,ge=W.children,ue=yt(Re),Te=Ht(ge,ue),Be=se();D.useEffect(function(){if(Be)return Be.registerPath(Re,ue),function(){Be.unregisterPath(Re,ue)}},[ue]);var Qe;return Be?Qe=Te:Qe=D.createElement(Ze,(0,_.Z)({ref:Q},W),Te),D.createElement(vt.Provider,{value:ue},Qe)}),ct=$e,Gt=x(76190);function Pt(W){var Q=W.className,Re=W.style,ge=D.useContext(k),ue=ge.prefixCls,Te=se();return Te?null:D.createElement("li",{role:"separator",className:G()("".concat(ue,"-item-divider"),Q),style:Re})}var it=["className","title","eventKey","children"],Bt=D.forwardRef(function(W,Q){var Re=W.className,ge=W.title,ue=W.eventKey,Te=W.children,Be=(0,g.Z)(W,it),Qe=D.useContext(k),Kt=Qe.prefixCls,xt="".concat(Kt,"-item-group");return D.createElement("li",(0,_.Z)({ref:Q,role:"presentation"},Be,{onClick:function(Nt){return Nt.stopPropagation()},className:G()(xt,Re)}),D.createElement("div",{role:"presentation",className:"".concat(xt,"-title"),title:typeof ge=="string"?ge:void 0},ge),D.createElement("ul",{role:"group",className:"".concat(xt,"-list")},Te))}),dt=D.forwardRef(function(W,Q){var Re=W.eventKey,ge=W.children,ue=yt(Re),Te=Ht(ge,ue),Be=se();return Be?Te:D.createElement(Bt,(0,_.Z)({ref:Q},(0,Tt.Z)(W,["warnKey"])),Te)}),He=dt,Ne=["label","children","key","type","extra"];function Ct(W,Q,Re){var ge=Q.item,ue=Q.group,Te=Q.submenu,Be=Q.divider;return(W||[]).map(function(Qe,Kt){if(Qe&&(0,Gt.Z)(Qe)==="object"){var xt=Qe,ei=xt.label,Nt=xt.children,Zt=xt.key,Qt=xt.type,gi=xt.extra,Si=(0,g.Z)(xt,Ne),zt=Zt!=null?Zt:"tmp-".concat(Kt);return Nt||Qt==="group"?Qt==="group"?D.createElement(ue,(0,_.Z)({key:zt},Si,{title:ei}),Ct(Nt,Q,Re)):D.createElement(Te,(0,_.Z)({key:zt},Si,{title:ei}),Ct(Nt,Q,Re)):Qt==="divider"?D.createElement(Be,(0,_.Z)({key:zt},Si)):D.createElement(ge,(0,_.Z)({key:zt},Si,{extra:gi}),ei,(!!gi||gi===0)&&D.createElement("span",{className:"".concat(Re,"-item-extra")},gi))}return null}).filter(function(Qe){return Qe})}function mt(W,Q,Re,ge,ue){var Te=W,Be=(0,Ae.Z)({divider:Pt,item:tt,group:He,submenu:ct},ge);return Q&&(Te=Ct(Q,Be,ue)),Ht(Te,Re)}var di=["prefixCls","rootClassName","style","className","tabIndex","items","children","direction","id","mode","inlineCollapsed","disabled","disabledOverflow","subMenuOpenDelay","subMenuCloseDelay","forceSubMenuRender","defaultOpenKeys","openKeys","activeKey","defaultActiveFirst","selectable","multiple","defaultSelectedKeys","selectedKeys","onSelect","onDeselect","inlineIndent","motion","defaultMotions","triggerSubMenuAction","builtinPlacements","itemIcon","expandIcon","overflowedIndicator","overflowedIndicatorPopupClassName","getPopupContainer","onClick","onOpenChange","onKeyDown","openAnimation","openTransitionName","_internalRenderMenuItem","_internalRenderSubMenuItem","_internalComponents"],Ri=[],mi=D.forwardRef(function(W,Q){var Re,ge=W,ue=ge.prefixCls,Te=ue===void 0?"rc-menu":ue,Be=ge.rootClassName,Qe=ge.style,Kt=ge.className,xt=ge.tabIndex,ei=xt===void 0?0:xt,Nt=ge.items,Zt=ge.children,Qt=ge.direction,gi=ge.id,Si=ge.mode,zt=Si===void 0?"vertical":Si,qt=ge.inlineCollapsed,pi=ge.disabled,hi=ge.disabledOverflow,ri=ge.subMenuOpenDelay,Ni=ri===void 0?.1:ri,vi=ge.subMenuCloseDelay,Li=vi===void 0?.1:vi,Zi=ge.forceSubMenuRender,Gi=ge.defaultOpenKeys,ns=ge.openKeys,ji=ge.activeKey,Yi=ge.defaultActiveFirst,Ji=ge.selectable,es=Ji===void 0?!0:Ji,qi=ge.multiple,Ci=qi===void 0?!1:qi,Di=ge.defaultSelectedKeys,fs=ge.selectedKeys,Oi=ge.onSelect,xi=ge.onDeselect,ks=ge.inlineIndent,ps=ks===void 0?24:ks,ts=ge.motion,Is=ge.defaultMotions,Hi=ge.triggerSubMenuAction,us=Hi===void 0?"hover":Hi,Fs=ge.builtinPlacements,vs=ge.itemIcon,ys=ge.expandIcon,Qi=ge.overflowedIndicator,rs=Qi===void 0?"...":Qi,cs=ge.overflowedIndicatorPopupClassName,Ps=ge.getPopupContainer,as=ge.onClick,ds=ge.onOpenChange,Rs=ge.onKeyDown,Bs=ge.openAnimation,hs=ge.openTransitionName,js=ge._internalRenderMenuItem,Ns=ge._internalRenderSubMenuItem,Ls=ge._internalComponents,Qs=(0,g.Z)(ge,di),Yt=D.useMemo(function(){return[mt(Zt,Nt,Ri,Ls,Te),mt(Zt,Nt,Ri,{},Te)]},[Zt,Nt,Ls]),zs=(0,A.Z)(Yt,2),Es=zs[0],Js=zs[1],on=D.useState(!1),en=(0,A.Z)(on,2),ln=en[0],Ws=en[1],Fi=D.useRef(),os=ot(gi),Cs=Qt==="rtl",tn=(0,de.Z)(Gi,{value:ns,postState:function(Ui){return Ui||Ri}}),is=(0,A.Z)(tn,2),Wi=is[0],ls=is[1],ms=function(Ui){var zi=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;function bs(){ls(Ui),ds==null||ds(Ui)}zi?(0,H.flushSync)(bs):bs()},$s=D.useState(Wi),Ds=(0,A.Z)($s,2),un=Ds[0],pn=Ds[1],sn=D.useRef(!1),Ln=D.useMemo(function(){return(zt==="inline"||zt==="vertical")&&qt?["vertical",qt]:[zt,!1]},[zt,qt]),At=(0,A.Z)(Ln,2),Wt=At[0],Bi=At[1],ai=Wt==="inline",fi=D.useState(Wt),Zs=(0,A.Z)(fi,2),Ss=Zs[0],cn=Zs[1],vn=D.useState(Bi),hr=(0,A.Z)(vn,2),Wr=hr[0],Zr=hr[1];D.useEffect(function(){cn(Wt),Zr(Bi),sn.current&&(ai?ls(un):ms(Ri))},[Wt,Bi]);var fr=D.useState(0),yn=(0,A.Z)(fr,2),Us=yn[0],Yr=yn[1],Fn=Us>=Es.length-1||Ss!=="horizontal"||hi;D.useEffect(function(){ai&&pn(Wi)},[Wi]),D.useEffect(function(){return sn.current=!0,function(){sn.current=!1}},[]);var En=C(),Zn=En.registerPath,Yn=En.unregisterPath,Xr=En.refreshOverflowKeys,Bn=En.isSubPathKey,qr=En.getKeyPath,Gs=En.getKeys,mr=En.getSubPathKeys,Qr=D.useMemo(function(){return{registerPath:Zn,unregisterPath:Yn}},[Zn,Yn]),gr=D.useMemo(function(){return{isSubPathKey:Bn}},[Bn]);D.useEffect(function(){Xr(Fn?Ri:Es.slice(Us+1).map(function(Xi){return Xi.key}))},[Us,Fn]);var pr=(0,de.Z)(ji||Yi&&((Re=Es[0])===null||Re===void 0?void 0:Re.key),{value:ji}),Xn=(0,A.Z)(pr,2),bn=Xn[0],qn=Xn[1],Qn=Ee(function(Xi){qn(Xi)}),vr=Ee(function(){qn(void 0)});(0,D.useImperativeHandle)(Q,function(){return{list:Fi.current,focus:function(Ui){var zi,bs=Gs(),Ts=Ue(bs,os),Nn=Ts.elements,$n=Ts.key2element,Dn=Ts.element2key,Tr=Me(Fi.current,Nn),tr=bn!=null?bn:Tr[0]?Dn.get(Tr[0]):(zi=Es.find(function(xr){return!xr.props.disabled}))===null||zi===void 0?void 0:zi.key,Tn=$n.get(tr);if(tr&&Tn){var ir;Tn==null||(ir=Tn.focus)===null||ir===void 0||ir.call(Tn,Ui)}}}});var yr=(0,de.Z)(Di||[],{value:fs,postState:function(Ui){return Array.isArray(Ui)?Ui:Ui==null?Ri:[Ui]}}),Ys=(0,A.Z)(yr,2),Cn=Ys[0],Jn=Ys[1],Er=function(Ui){if(es){var zi=Ui.key,bs=Cn.includes(zi),Ts;Ci?bs?Ts=Cn.filter(function($n){return $n!==zi}):Ts=[].concat((0,Y.Z)(Cn),[zi]):Ts=[zi],Jn(Ts);var Nn=(0,Ae.Z)((0,Ae.Z)({},Ui),{},{selectedKeys:Ts});bs?xi==null||xi(Nn):Oi==null||Oi(Nn)}!Ci&&Wi.length&&Ss!=="inline"&&ms(Ri)},Jr=Ee(function(Xi){as==null||as(li(Xi)),Er(Xi)}),_r=Ee(function(Xi,Ui){var zi=Wi.filter(function(Ts){return Ts!==Xi});if(Ui)zi.push(Xi);else if(Ss!=="inline"){var bs=mr(Xi);zi=zi.filter(function(Ts){return!bs.has(Ts)})}(0,we.Z)(Wi,zi,!0)||ms(zi,!0)}),ea=function(Ui,zi){var bs=zi!=null?zi:!Wi.includes(Ui);_r(Ui,bs)},ta=z(Ss,bn,Cs,os,Fi,Gs,qr,qn,ea,Rs);D.useEffect(function(){Ws(!0)},[]);var Sr=D.useMemo(function(){return{_internalRenderMenuItem:js,_internalRenderSubMenuItem:Ns}},[js,Ns]),br=Ss!=="horizontal"||hi?Es:Es.map(function(Xi,Ui){return D.createElement(le,{key:Xi.key,overflowDisabled:Ui>Us},Xi)}),er=D.createElement(re.Z,(0,_.Z)({id:gi,ref:Fi,prefixCls:"".concat(Te,"-overflow"),component:"ul",itemComponent:tt,className:G()(Te,"".concat(Te,"-root"),"".concat(Te,"-").concat(Ss),Kt,(0,J.Z)((0,J.Z)({},"".concat(Te,"-inline-collapsed"),Wr),"".concat(Te,"-rtl"),Cs),Be),dir:Qt,style:Qe,role:"menu",tabIndex:ei,data:br,renderRawItem:function(Ui){return Ui},renderRawRest:function(Ui){var zi=Ui.length,bs=zi?Es.slice(-zi):null;return D.createElement(ct,{eventKey:V,title:rs,disabled:Fn,internalPopupClose:zi===0,popupClassName:cs},bs)},maxCount:Ss!=="horizontal"||hi?re.Z.INVALIDATE:re.Z.RESPONSIVE,ssr:"full","data-menu-list":!0,onVisibleChange:function(Ui){Yr(Ui)},onKeyDown:ta},Qs));return D.createElement(ne.Provider,{value:Sr},D.createElement(st.Provider,{value:os},D.createElement(le,{prefixCls:Te,rootClassName:Be,mode:Ss,openKeys:Wi,rtl:Cs,disabled:pi,motion:ln?ts:null,defaultMotions:ln?Is:null,activeKey:bn,onActive:Qn,onInactive:vr,selectedKeys:Cn,inlineIndent:ps,subMenuOpenDelay:Ni,subMenuCloseDelay:Li,forceSubMenuRender:Zi,builtinPlacements:Fs,triggerSubMenuAction:us,getPopupContainer:Ps,itemIcon:vs,expandIcon:ys,onItemClick:Jr,onOpenChange:_r},D.createElement(Je.Provider,{value:gr},er),D.createElement("div",{style:{display:"none"},"aria-hidden":!0},D.createElement(Xe.Provider,{value:Qr},Js)))))}),Dt=mi,ni=Dt;ni.Item=tt,ni.SubMenu=ct,ni.ItemGroup=He,ni.Divider=Pt;var ki=ni},83836:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return ze}});var _=x(54476),J=x(33885),Ae=x(42978),Y=x(75931),A=x(59301),g=x(92310),te=x.n(g),G=x(29301),re=x(34280),de=["prefixCls","invalidate","item","renderItem","responsive","responsiveDisabled","registerSize","itemKey","className","style","children","display","order","component"],we=void 0;function Ie(ve,Pe){var ke=ve.prefixCls,rt=ve.invalidate,_e=ve.item,Ye=ve.renderItem,ye=ve.responsive,Ve=ve.responsiveDisabled,We=ve.registerSize,Mt=ve.itemKey,jt=ve.className,_t=ve.style,Le=ve.children,It=ve.display,je=ve.order,Xt=ve.component,oe=Xt===void 0?"div":Xt,Me=(0,Y.Z)(ve,de),N=ye&&!It;function Ue(P){We(Mt,P)}A.useEffect(function(){return function(){Ue(null)}},[]);var z=Ye&&_e!==we?Ye(_e,{index:je}):Le,$;rt||($={opacity:N?0:1,height:N?0:we,overflowY:N?"hidden":we,order:ye?je:we,pointerEvents:N?"none":we,position:N?"absolute":we});var M={};N&&(M["aria-hidden"]=!0);var w=A.createElement(oe,(0,_.Z)({className:te()(!rt&&ke,jt),style:(0,J.Z)((0,J.Z)({},$),_t)},M,Me,{ref:Pe}),z);return ye&&(w=A.createElement(G.Z,{onResize:function(V){var C=V.offsetWidth;Ue(C)},disabled:Ve},w)),w}var D=A.forwardRef(Ie);D.displayName="Item";var H=D,st=x(6089),Ge=x(4676),Ce=x(16089);function ae(ve){if(typeof MessageChannel=="undefined")(0,Ce.Z)(ve);else{var Pe=new MessageChannel;Pe.port1.onmessage=function(){return ve()},Pe.port2.postMessage(void 0)}}function F(){var ve=A.useRef(null),Pe=function(rt){ve.current||(ve.current=[],ae(function(){(0,Ge.unstable_batchedUpdates)(function(){ve.current.forEach(function(_e){_e()}),ve.current=null})})),ve.current.push(rt)};return Pe}function k(ve,Pe){var ke=A.useState(Pe),rt=(0,Ae.Z)(ke,2),_e=rt[0],Ye=rt[1],ye=(0,st.Z)(function(Ve){ve(function(){Ye(Ve)})});return[_e,ye]}var X=A.createContext(null),le=["component"],me=["className"],Xe=["className"],se=function(Pe,ke){var rt=A.useContext(X);if(!rt){var _e=Pe.component,Ye=_e===void 0?"div":_e,ye=(0,Y.Z)(Pe,le);return A.createElement(Ye,(0,_.Z)({},ye,{ref:ke}))}var Ve=rt.className,We=(0,Y.Z)(rt,me),Mt=Pe.className,jt=(0,Y.Z)(Pe,Xe);return A.createElement(X.Provider,{value:null},A.createElement(H,(0,_.Z)({ref:ke,className:te()(Ve,Mt)},We,jt)))},vt=A.forwardRef(se);vt.displayName="RawItem";var yt=vt,Je=["prefixCls","data","renderItem","renderRawItem","itemKey","itemWidth","ssr","style","className","maxCount","renderRest","renderRawRest","prefix","suffix","component","itemComponent","onVisibleChange"],nt="responsive",ne="invalidate";function ee(ve){return"+ ".concat(ve.length," ...")}function ce(ve,Pe){var ke=ve.prefixCls,rt=ke===void 0?"rc-overflow":ke,_e=ve.data,Ye=_e===void 0?[]:_e,ye=ve.renderItem,Ve=ve.renderRawItem,We=ve.itemKey,Mt=ve.itemWidth,jt=Mt===void 0?10:Mt,_t=ve.ssr,Le=ve.style,It=ve.className,je=ve.maxCount,Xt=ve.renderRest,oe=ve.renderRawRest,Me=ve.prefix,N=ve.suffix,Ue=ve.component,z=Ue===void 0?"div":Ue,$=ve.itemComponent,M=ve.onVisibleChange,w=(0,Y.Z)(ve,Je),P=_t==="full",V=F(),C=k(V,null),Ee=(0,Ae.Z)(C,2),xe=Ee[0],Ke=Ee[1],ot=xe||0,Rt=k(V,new Map),et=(0,Ae.Z)(Rt,2),ut=et[0],Et=et[1],Tt=k(V,0),lt=(0,Ae.Z)(Tt,2),pe=lt[0],pt=lt[1],Ei=k(V,0),_i=(0,Ae.Z)(Ei,2),li=_i[0],Ai=_i[1],Vi=k(V,0),Ti=(0,Ae.Z)(Vi,2),Ut=Ti[0],wi=Ti[1],ui=k(V,0),tt=(0,Ae.Z)(ui,2),Lt=tt[0],St=tt[1],ti=(0,A.useState)(null),oi=(0,Ae.Z)(ti,2),ci=oi[0],Ht=oi[1],Ii=(0,A.useState)(null),Ft=(0,Ae.Z)(Ii,2),si=Ft[0],Pi=Ft[1],Fe=A.useMemo(function(){return si===null&&P?Number.MAX_SAFE_INTEGER:si||0},[si,xe]),d=(0,A.useState)(!1),f=(0,Ae.Z)(d,2),p=f[0],E=f[1],T="".concat(rt,"-item"),O=Math.max(pe,li),U=je===nt,Ze=Ye.length&&U,$e=je===ne,ct=Ze||typeof je=="number"&&Ye.length>je,Gt=(0,A.useMemo)(function(){var ue=Ye;return Ze?xe===null&&P?ue=Ye:ue=Ye.slice(0,Math.min(Ye.length,ot/jt)):typeof je=="number"&&(ue=Ye.slice(0,je)),ue},[Ye,jt,xe,je,Ze]),Pt=(0,A.useMemo)(function(){return Ze?Ye.slice(Fe+1):Ye.slice(Gt.length)},[Ye,Gt,Ze,Fe]),it=(0,A.useCallback)(function(ue,Te){var Be;return typeof We=="function"?We(ue):(Be=We&&(ue==null?void 0:ue[We]))!==null&&Be!==void 0?Be:Te},[We]),Bt=(0,A.useCallback)(ye||function(ue){return ue},[ye]);function dt(ue,Te,Be){si===ue&&(Te===void 0||Te===ci)||(Pi(ue),Be||(E(ue<Ye.length-1),M==null||M(ue)),Te!==void 0&&Ht(Te))}function He(ue,Te){Ke(Te.clientWidth)}function Ne(ue,Te){Et(function(Be){var Qe=new Map(Be);return Te===null?Qe.delete(ue):Qe.set(ue,Te),Qe})}function Ct(ue,Te){Ai(Te),pt(li)}function mt(ue,Te){wi(Te)}function di(ue,Te){St(Te)}function Ri(ue){return ut.get(it(Gt[ue],ue))}(0,re.Z)(function(){if(ot&&typeof O=="number"&&Gt){var ue=Ut+Lt,Te=Gt.length,Be=Te-1;if(!Te){dt(0,null);return}for(var Qe=0;Qe<Te;Qe+=1){var Kt=Ri(Qe);if(P&&(Kt=Kt||0),Kt===void 0){dt(Qe-1,void 0,!0);break}if(ue+=Kt,Be===0&&ue<=ot||Qe===Be-1&&ue+Ri(Be)<=ot){dt(Be,null);break}else if(ue+O>ot){dt(Qe-1,ue-Kt-Lt+li);break}}N&&Ri(0)+Lt>ot&&Ht(null)}},[ot,ut,li,Ut,Lt,it,Gt]);var mi=p&&!!Pt.length,Dt={};ci!==null&&Ze&&(Dt={position:"absolute",left:ci,top:0});var ni={prefixCls:T,responsive:Ze,component:$,invalidate:$e},ki=Ve?function(ue,Te){var Be=it(ue,Te);return A.createElement(X.Provider,{key:Be,value:(0,J.Z)((0,J.Z)({},ni),{},{order:Te,item:ue,itemKey:Be,registerSize:Ne,display:Te<=Fe})},Ve(ue,Te))}:function(ue,Te){var Be=it(ue,Te);return A.createElement(H,(0,_.Z)({},ni,{order:Te,key:Be,item:ue,renderItem:Bt,itemKey:Be,registerSize:Ne,display:Te<=Fe}))},W={order:mi?Fe:Number.MAX_SAFE_INTEGER,className:"".concat(T,"-rest"),registerSize:Ct,display:mi},Q=Xt||ee,Re=oe?A.createElement(X.Provider,{value:(0,J.Z)((0,J.Z)({},ni),W)},oe(Pt)):A.createElement(H,(0,_.Z)({},ni,W),typeof Q=="function"?Q(Pt):Q),ge=A.createElement(z,(0,_.Z)({className:te()(!$e&&rt,It),style:Le,ref:Pe},w),Me&&A.createElement(H,(0,_.Z)({},ni,{responsive:U,responsiveDisabled:!Ze,order:-1,className:"".concat(T,"-prefix"),registerSize:mt,display:!0}),Me),Gt.map(ki),ct?Re:null,N&&A.createElement(H,(0,_.Z)({},ni,{responsive:U,responsiveDisabled:!Ze,order:Fe,className:"".concat(T,"-suffix"),registerSize:di,display:!0,style:Dt}),N));return U?A.createElement(G.Z,{onResize:He,disabled:!Ze},ge):ge}var K=A.forwardRef(ce);K.displayName="Overflow",K.Item=yt,K.RESPONSIVE=nt,K.INVALIDATE=ne;var Se=K,ze=Se},29301:function(ii,qe,x){"use strict";x.d(qe,{Z:function(){return ne}});var _=x(54476),J=x(59301),Ae=x(11592),Y=x(48736),A=x(33885),g=x(76190),te=x(76846),G=x(8654),re=J.createContext(null);function de(ee){var ce=ee.children,K=ee.onBatchResize,Se=J.useRef(0),ze=J.useRef([]),ve=J.useContext(re),Pe=J.useCallback(function(ke,rt,_e){Se.current+=1;var Ye=Se.current;ze.current.push({size:ke,element:rt,data:_e}),Promise.resolve().then(function(){Ye===Se.current&&(K==null||K(ze.current),ze.current=[])}),ve==null||ve(ke,rt,_e)},[K,ve]);return J.createElement(re.Provider,{value:Pe},ce)}var we=x(76374),Ie=new Map;function D(ee){ee.forEach(function(ce){var K,Se=ce.target;(K=Ie.get(Se))===null||K===void 0||K.forEach(function(ze){return ze(Se)})})}var H=new we.Z(D),st=null,Ge=null;function Ce(ee,ce){Ie.has(ee)||(Ie.set(ee,new Set),H.observe(ee)),Ie.get(ee).add(ce)}function ae(ee,ce){Ie.has(ee)&&(Ie.get(ee).delete(ce),Ie.get(ee).size||(H.unobserve(ee),Ie.delete(ee)))}var F=x(67732),k=x(83652),X=x(42403),le=x(158),me=function(ee){(0,X.Z)(K,ee);var ce=(0,le.Z)(K);function K(){return(0,F.Z)(this,K),ce.apply(this,arguments)}return(0,k.Z)(K,[{key:"render",value:function(){return this.props.children}}]),K}(J.Component);function Xe(ee,ce){var K=ee.children,Se=ee.disabled,ze=J.useRef(null),ve=J.useRef(null),Pe=J.useContext(re),ke=typeof K=="function",rt=ke?K(ze):K,_e=J.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Ye=!ke&&J.isValidElement(rt)&&(0,G.Yr)(rt),ye=Ye?(0,G.C4)(rt):null,Ve=(0,G.x1)(ye,ze),We=function(){var Le;return(0,te.ZP)(ze.current)||(ze.current&&(0,g.Z)(ze.current)==="object"?(0,te.ZP)((Le=ze.current)===null||Le===void 0?void 0:Le.nativeElement):null)||(0,te.ZP)(ve.current)};J.useImperativeHandle(ce,function(){return We()});var Mt=J.useRef(ee);Mt.current=ee;var jt=J.useCallback(function(_t){var Le=Mt.current,It=Le.onResize,je=Le.data,Xt=_t.getBoundingClientRect(),oe=Xt.width,Me=Xt.height,N=_t.offsetWidth,Ue=_t.offsetHeight,z=Math.floor(oe),$=Math.floor(Me);if(_e.current.width!==z||_e.current.height!==$||_e.current.offsetWidth!==N||_e.current.offsetHeight!==Ue){var M={width:z,height:$,offsetWidth:N,offsetHeight:Ue};_e.current=M;var w=N===Math.round(oe)?oe:N,P=Ue===Math.round(Me)?Me:Ue,V=(0,A.Z)((0,A.Z)({},M),{},{offsetWidth:w,offsetHeight:P});Pe==null||Pe(V,_t,je),It&&Promise.resolve().then(function(){It(V,_t)})}},[]);return J.useEffect(function(){var _t=We();return _t&&!Se&&Ce(_t,jt),function(){return ae(_t,jt)}},[ze.current,Se]),J.createElement(me,{ref:ve},Ye?J.cloneElement(rt,{ref:Ve}):rt)}var se=J.forwardRef(Xe),vt=se,yt="rc-observer-key";function Je(ee,ce){var K=ee.children,Se=typeof K=="function"?[K]:(0,Ae.Z)(K);return Se.map(function(ze,ve){var Pe=(ze==null?void 0:ze.key)||"".concat(yt,"-").concat(ve);return J.createElement(vt,(0,_.Z)({},ee,{key:Pe,ref:ve===0?ce:void 0}),ze)})}var nt=J.forwardRef(Je);nt.Collection=de;var ne=nt},29125:function(ii,qe,x){"use strict";x.d(qe,{G:function(){return Y},Z:function(){return ae}});var _=x(92310),J=x.n(_),Ae=x(59301);function Y(F){var k=F.children,X=F.prefixCls,le=F.id,me=F.overlayInnerStyle,Xe=F.bodyClassName,se=F.className,vt=F.style;return Ae.createElement("div",{className:J()("".concat(X,"-content"),se),style:vt},Ae.createElement("div",{className:J()("".concat(X,"-inner"),Xe),id:le,role:"tooltip",style:me},typeof k=="function"?k():k))}var A=x(54476),g=x(33885),te=x(75931),G=x(65030),re={shiftX:64,adjustY:1},de={adjustX:1,shiftY:!0},we=[0,0],Ie={left:{points:["cr","cl"],overflow:de,offset:[-4,0],targetOffset:we},right:{points:["cl","cr"],overflow:de,offset:[4,0],targetOffset:we},top:{points:["bc","tc"],overflow:re,offset:[0,-4],targetOffset:we},bottom:{points:["tc","bc"],overflow:re,offset:[0,4],targetOffset:we},topLeft:{points:["bl","tl"],overflow:re,offset:[0,-4],targetOffset:we},leftTop:{points:["tr","tl"],overflow:de,offset:[-4,0],targetOffset:we},topRight:{points:["br","tr"],overflow:re,offset:[0,-4],targetOffset:we},rightTop:{points:["tl","tr"],overflow:de,offset:[4,0],targetOffset:we},bottomRight:{points:["tr","br"],overflow:re,offset:[0,4],targetOffset:we},rightBottom:{points:["bl","br"],overflow:de,offset:[4,0],targetOffset:we},bottomLeft:{points:["tl","bl"],overflow:re,offset:[0,4],targetOffset:we},leftBottom:{points:["br","bl"],overflow:de,offset:[-4,0],targetOffset:we}},D=null,H=x(80402),st=["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","motion","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle","arrowContent","overlay","id","showArrow","classNames","styles"],Ge=function(k,X){var le=k.overlayClassName,me=k.trigger,Xe=me===void 0?["hover"]:me,se=k.mouseEnterDelay,vt=se===void 0?0:se,yt=k.mouseLeaveDelay,Je=yt===void 0?.1:yt,nt=k.overlayStyle,ne=k.prefixCls,ee=ne===void 0?"rc-tooltip":ne,ce=k.children,K=k.onVisibleChange,Se=k.afterVisibleChange,ze=k.transitionName,ve=k.animation,Pe=k.motion,ke=k.placement,rt=ke===void 0?"right":ke,_e=k.align,Ye=_e===void 0?{}:_e,ye=k.destroyTooltipOnHide,Ve=ye===void 0?!1:ye,We=k.defaultVisible,Mt=k.getTooltipContainer,jt=k.overlayInnerStyle,_t=k.arrowContent,Le=k.overlay,It=k.id,je=k.showArrow,Xt=je===void 0?!0:je,oe=k.classNames,Me=k.styles,N=(0,te.Z)(k,st),Ue=(0,H.Z)(It),z=(0,Ae.useRef)(null);(0,Ae.useImperativeHandle)(X,function(){return z.current});var $=(0,g.Z)({},N);"visible"in k&&($.popupVisible=k.visible);var M=function(){return Ae.createElement(Y,{key:"content",prefixCls:ee,id:Ue,bodyClassName:oe==null?void 0:oe.body,overlayInnerStyle:(0,g.Z)((0,g.Z)({},jt),Me==null?void 0:Me.body)},Le)},w=function(){var V=Ae.Children.only(ce),C=(V==null?void 0:V.props)||{},Ee=(0,g.Z)((0,g.Z)({},C),{},{"aria-describedby":Le?Ue:null});return Ae.cloneElement(ce,Ee)};return Ae.createElement(G.Z,(0,A.Z)({popupClassName:J()(le,oe==null?void 0:oe.root),prefixCls:ee,popup:M,action:Xe,builtinPlacements:Ie,popupPlacement:rt,ref:z,popupAlign:Ye,getPopupContainer:Mt,onPopupVisibleChange:K,afterPopupVisibleChange:Se,popupTransitionName:ze,popupAnimation:ve,popupMotion:Pe,defaultPopupVisible:We,autoDestroy:Ve,mouseLeaveDelay:Je,popupStyle:(0,g.Z)((0,g.Z)({},nt),Me==null?void 0:Me.root),mouseEnterDelay:vt,arrow:Xt},$),w())},Ce=(0,Ae.forwardRef)(Ge),ae=Ce},49658:function(ii,qe){"use strict";qe.Z=function(){if(typeof navigator=="undefined"||typeof window=="undefined")return!1;var x=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(x)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(x==null?void 0:x.substr(0,4))}},83145:function(ii,qe,x){"use strict";Object.defineProperty(qe,"__esModule",{value:!0}),qe.CopyToClipboard=void 0;var _=Ae(x(59301)),J=Ae(x(25769));function Ae(F){return F&&F.__esModule?F:{default:F}}function Y(F){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Y=function(X){return typeof X}:Y=function(X){return X&&typeof Symbol=="function"&&X.constructor===Symbol&&X!==Symbol.prototype?"symbol":typeof X},Y(F)}function A(F,k){var X=Object.keys(F);if(Object.getOwnPropertySymbols){var le=Object.getOwnPropertySymbols(F);k&&(le=le.filter(function(me){return Object.getOwnPropertyDescriptor(F,me).enumerable})),X.push.apply(X,le)}return X}function g(F){for(var k=1;k<arguments.length;k++){var X=arguments[k]!=null?arguments[k]:{};k%2?A(X,!0).forEach(function(le){Ce(F,le,X[le])}):Object.getOwnPropertyDescriptors?Object.defineProperties(F,Object.getOwnPropertyDescriptors(X)):A(X).forEach(function(le){Object.defineProperty(F,le,Object.getOwnPropertyDescriptor(X,le))})}return F}function te(F,k){if(F==null)return{};var X=G(F,k),le,me;if(Object.getOwnPropertySymbols){var Xe=Object.getOwnPropertySymbols(F);for(me=0;me<Xe.length;me++)le=Xe[me],!(k.indexOf(le)>=0)&&Object.prototype.propertyIsEnumerable.call(F,le)&&(X[le]=F[le])}return X}function G(F,k){if(F==null)return{};var X={},le=Object.keys(F),me,Xe;for(Xe=0;Xe<le.length;Xe++)me=le[Xe],!(k.indexOf(me)>=0)&&(X[me]=F[me]);return X}function re(F,k){if(!(F instanceof k))throw new TypeError("Cannot call a class as a function")}function de(F,k){for(var X=0;X<k.length;X++){var le=k[X];le.enumerable=le.enumerable||!1,le.configurable=!0,"value"in le&&(le.writable=!0),Object.defineProperty(F,le.key,le)}}function we(F,k,X){return k&&de(F.prototype,k),X&&de(F,X),F}function Ie(F,k){return k&&(Y(k)==="object"||typeof k=="function")?k:H(F)}function D(F){return D=Object.setPrototypeOf?Object.getPrototypeOf:function(X){return X.__proto__||Object.getPrototypeOf(X)},D(F)}function H(F){if(F===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F}function st(F,k){if(typeof k!="function"&&k!==null)throw new TypeError("Super expression must either be null or a function");F.prototype=Object.create(k&&k.prototype,{constructor:{value:F,writable:!0,configurable:!0}}),k&&Ge(F,k)}function Ge(F,k){return Ge=Object.setPrototypeOf||function(le,me){return le.__proto__=me,le},Ge(F,k)}function Ce(F,k,X){return k in F?Object.defineProperty(F,k,{value:X,enumerable:!0,configurable:!0,writable:!0}):F[k]=X,F}var ae=function(F){st(k,F);function k(){var X,le;re(this,k);for(var me=arguments.length,Xe=new Array(me),se=0;se<me;se++)Xe[se]=arguments[se];return le=Ie(this,(X=D(k)).call.apply(X,[this].concat(Xe))),Ce(H(le),"onClick",function(vt){var yt=le.props,Je=yt.text,nt=yt.onCopy,ne=yt.children,ee=yt.options,ce=_.default.Children.only(ne),K=(0,J.default)(Je,ee);nt&&nt(Je,K),ce&&ce.props&&typeof ce.props.onClick=="function"&&ce.props.onClick(vt)}),le}return we(k,[{key:"render",value:function(){var le=this.props,me=le.text,Xe=le.onCopy,se=le.options,vt=le.children,yt=te(le,["text","onCopy","options","children"]),Je=_.default.Children.only(vt);return _.default.cloneElement(Je,g({},yt,{onClick:this.onClick}))}}]),k}(_.default.PureComponent);qe.CopyToClipboard=ae,Ce(ae,"defaultProps",{onCopy:void 0,options:void 0})},56102:function(ii,qe,x){"use strict";var _=x(83145),J=_.CopyToClipboard;J.CopyToClipboard=J,ii.exports=J},76374:function(ii,qe,x){"use strict";var _=function(){if(typeof Map!="undefined")return Map;function ne(ee,ce){var K=-1;return ee.some(function(Se,ze){return Se[0]===ce?(K=ze,!0):!1}),K}return function(){function ee(){this.__entries__=[]}return Object.defineProperty(ee.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),ee.prototype.get=function(ce){var K=ne(this.__entries__,ce),Se=this.__entries__[K];return Se&&Se[1]},ee.prototype.set=function(ce,K){var Se=ne(this.__entries__,ce);~Se?this.__entries__[Se][1]=K:this.__entries__.push([ce,K])},ee.prototype.delete=function(ce){var K=this.__entries__,Se=ne(K,ce);~Se&&K.splice(Se,1)},ee.prototype.has=function(ce){return!!~ne(this.__entries__,ce)},ee.prototype.clear=function(){this.__entries__.splice(0)},ee.prototype.forEach=function(ce,K){K===void 0&&(K=null);for(var Se=0,ze=this.__entries__;Se<ze.length;Se++){var ve=ze[Se];ce.call(K,ve[1],ve[0])}},ee}()}(),J=typeof window!="undefined"&&typeof document!="undefined"&&window.document===document,Ae=function(){return typeof x.g!="undefined"&&x.g.Math===Math?x.g:typeof self!="undefined"&&self.Math===Math?self:typeof window!="undefined"&&window.Math===Math?window:Function("return this")()}(),Y=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(Ae):function(ne){return setTimeout(function(){return ne(Date.now())},1e3/60)}}(),A=2;function g(ne,ee){var ce=!1,K=!1,Se=0;function ze(){ce&&(ce=!1,ne()),K&&Pe()}function ve(){Y(ze)}function Pe(){var ke=Date.now();if(ce){if(ke-Se<A)return;K=!0}else ce=!0,K=!1,setTimeout(ve,ee);Se=ke}return Pe}var te=20,G=["top","right","bottom","left","width","height","size","weight"],re=typeof MutationObserver!="undefined",de=function(){function ne(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=g(this.refresh.bind(this),te)}return ne.prototype.addObserver=function(ee){~this.observers_.indexOf(ee)||this.observers_.push(ee),this.connected_||this.connect_()},ne.prototype.removeObserver=function(ee){var ce=this.observers_,K=ce.indexOf(ee);~K&&ce.splice(K,1),!ce.length&&this.connected_&&this.disconnect_()},ne.prototype.refresh=function(){var ee=this.updateObservers_();ee&&this.refresh()},ne.prototype.updateObservers_=function(){var ee=this.observers_.filter(function(ce){return ce.gatherActive(),ce.hasActive()});return ee.forEach(function(ce){return ce.broadcastActive()}),ee.length>0},ne.prototype.connect_=function(){!J||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),re?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},ne.prototype.disconnect_=function(){!J||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},ne.prototype.onTransitionEnd_=function(ee){var ce=ee.propertyName,K=ce===void 0?"":ce,Se=G.some(function(ze){return!!~K.indexOf(ze)});Se&&this.refresh()},ne.getInstance=function(){return this.instance_||(this.instance_=new ne),this.instance_},ne.instance_=null,ne}(),we=function(ne,ee){for(var ce=0,K=Object.keys(ee);ce<K.length;ce++){var Se=K[ce];Object.defineProperty(ne,Se,{value:ee[Se],enumerable:!1,writable:!1,configurable:!0})}return ne},Ie=function(ne){var ee=ne&&ne.ownerDocument&&ne.ownerDocument.defaultView;return ee||Ae},D=me(0,0,0,0);function H(ne){return parseFloat(ne)||0}function st(ne){for(var ee=[],ce=1;ce<arguments.length;ce++)ee[ce-1]=arguments[ce];return ee.reduce(function(K,Se){var ze=ne["border-"+Se+"-width"];return K+H(ze)},0)}function Ge(ne){for(var ee=["top","right","bottom","left"],ce={},K=0,Se=ee;K<Se.length;K++){var ze=Se[K],ve=ne["padding-"+ze];ce[ze]=H(ve)}return ce}function Ce(ne){var ee=ne.getBBox();return me(0,0,ee.width,ee.height)}function ae(ne){var ee=ne.clientWidth,ce=ne.clientHeight;if(!ee&&!ce)return D;var K=Ie(ne).getComputedStyle(ne),Se=Ge(K),ze=Se.left+Se.right,ve=Se.top+Se.bottom,Pe=H(K.width),ke=H(K.height);if(K.boxSizing==="border-box"&&(Math.round(Pe+ze)!==ee&&(Pe-=st(K,"left","right")+ze),Math.round(ke+ve)!==ce&&(ke-=st(K,"top","bottom")+ve)),!k(ne)){var rt=Math.round(Pe+ze)-ee,_e=Math.round(ke+ve)-ce;Math.abs(rt)!==1&&(Pe-=rt),Math.abs(_e)!==1&&(ke-=_e)}return me(Se.left,Se.top,Pe,ke)}var F=function(){return typeof SVGGraphicsElement!="undefined"?function(ne){return ne instanceof Ie(ne).SVGGraphicsElement}:function(ne){return ne instanceof Ie(ne).SVGElement&&typeof ne.getBBox=="function"}}();function k(ne){return ne===Ie(ne).document.documentElement}function X(ne){return J?F(ne)?Ce(ne):ae(ne):D}function le(ne){var ee=ne.x,ce=ne.y,K=ne.width,Se=ne.height,ze=typeof DOMRectReadOnly!="undefined"?DOMRectReadOnly:Object,ve=Object.create(ze.prototype);return we(ve,{x:ee,y:ce,width:K,height:Se,top:ce,right:ee+K,bottom:Se+ce,left:ee}),ve}function me(ne,ee,ce,K){return{x:ne,y:ee,width:ce,height:K}}var Xe=function(){function ne(ee){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=me(0,0,0,0),this.target=ee}return ne.prototype.isActive=function(){var ee=X(this.target);return this.contentRect_=ee,ee.width!==this.broadcastWidth||ee.height!==this.broadcastHeight},ne.prototype.broadcastRect=function(){var ee=this.contentRect_;return this.broadcastWidth=ee.width,this.broadcastHeight=ee.height,ee},ne}(),se=function(){function ne(ee,ce){var K=le(ce);we(this,{target:ee,contentRect:K})}return ne}(),vt=function(){function ne(ee,ce,K){if(this.activeObservations_=[],this.observations_=new _,typeof ee!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=ee,this.controller_=ce,this.callbackCtx_=K}return ne.prototype.observe=function(ee){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(ee instanceof Ie(ee).Element))throw new TypeError('parameter 1 is not of type "Element".');var ce=this.observations_;ce.has(ee)||(ce.set(ee,new Xe(ee)),this.controller_.addObserver(this),this.controller_.refresh())}},ne.prototype.unobserve=function(ee){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(ee instanceof Ie(ee).Element))throw new TypeError('parameter 1 is not of type "Element".');var ce=this.observations_;ce.has(ee)&&(ce.delete(ee),ce.size||this.controller_.removeObserver(this))}},ne.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},ne.prototype.gatherActive=function(){var ee=this;this.clearActive(),this.observations_.forEach(function(ce){ce.isActive()&&ee.activeObservations_.push(ce)})},ne.prototype.broadcastActive=function(){if(this.hasActive()){var ee=this.callbackCtx_,ce=this.activeObservations_.map(function(K){return new se(K.target,K.broadcastRect())});this.callback_.call(ee,ce,ee),this.clearActive()}},ne.prototype.clearActive=function(){this.activeObservations_.splice(0)},ne.prototype.hasActive=function(){return this.activeObservations_.length>0},ne}(),yt=typeof WeakMap!="undefined"?new WeakMap:new _,Je=function(){function ne(ee){if(!(this instanceof ne))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var ce=de.getInstance(),K=new vt(ee,ce,this);yt.set(this,K)}return ne}();["observe","unobserve","disconnect"].forEach(function(ne){Je.prototype[ne]=function(){var ee;return(ee=yt.get(this))[ne].apply(ee,arguments)}});var nt=function(){return typeof Ae.ResizeObserver!="undefined"?Ae.ResizeObserver:Je}();qe.Z=nt},98040:function(ii){ii.exports=function(){var qe=document.getSelection();if(!qe.rangeCount)return function(){};for(var x=document.activeElement,_=[],J=0;J<qe.rangeCount;J++)_.push(qe.getRangeAt(J));switch(x.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":x.blur();break;default:x=null;break}return qe.removeAllRanges(),function(){qe.type==="Caret"&&qe.removeAllRanges(),qe.rangeCount||_.forEach(function(Ae){qe.addRange(Ae)}),x&&x.focus()}}},82059:function(ii){var qe=arguments[3],x=arguments[4],_=arguments[5],J=JSON.stringify;ii.exports=function(Ae,Y){for(var A,g=Object.keys(_),te=0,G=g.length;te<G;te++){var re=g[te],de=_[re].exports;if(de===Ae||de&&de.default===Ae){A=re;break}}if(!A){A=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var we={},te=0,G=g.length;te<G;te++){var re=g[te];we[re]=re}x[A]=["function(require,module,exports){"+Ae+"(self); }",we]}var Ie=Math.floor(Math.pow(16,8)*Math.random()).toString(16),D={};D[A]=A,x[Ie]=["function(require,module,exports){var f = require("+J(A)+");(f.default ? f.default : f)(self);}",D];var H={};st(Ie);function st(X){H[X]=!0;for(var le in x[X][1]){var me=x[X][1][le];H[me]||st(me)}}var Ge="("+qe+")({"+Object.keys(H).map(function(X){return J(X)+":["+x[X][0]+","+J(x[X][1])+"]"}).join(",")+"},{},["+J(Ie)+"])",Ce=window.URL||window.webkitURL||window.mozURL||window.msURL,ae=new Blob([Ge],{type:"text/javascript"});if(Y&&Y.bare)return ae;var F=Ce.createObjectURL(ae),k=new Worker(F);return k.objectURL=F,k}},16471:function(ii,qe,x){"use strict";x.d(qe,{ZP:function(){return Rn}});const _=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},J=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=Ae},Ae=Number.MAX_SAFE_INTEGER||9007199254740991;let Y=function(a){return a.NETWORK_ERROR="networkError",a.MEDIA_ERROR="mediaError",a.KEY_SYSTEM_ERROR="keySystemError",a.MUX_ERROR="muxError",a.OTHER_ERROR="otherError",a}({}),A=function(a){return a.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",a.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",a.KEY_SYSTEM_NO_SESSION="keySystemNoSession",a.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",a.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",a.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",a.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",a.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",a.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",a.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",a.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",a.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",a.MANIFEST_LOAD_ERROR="manifestLoadError",a.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",a.MANIFEST_PARSING_ERROR="manifestParsingError",a.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",a.LEVEL_EMPTY_ERROR="levelEmptyError",a.LEVEL_LOAD_ERROR="levelLoadError",a.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",a.LEVEL_PARSING_ERROR="levelParsingError",a.LEVEL_SWITCH_ERROR="levelSwitchError",a.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",a.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",a.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",a.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",a.FRAG_LOAD_ERROR="fragLoadError",a.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",a.FRAG_DECRYPT_ERROR="fragDecryptError",a.FRAG_PARSING_ERROR="fragParsingError",a.FRAG_GAP="fragGap",a.REMUX_ALLOC_ERROR="remuxAllocError",a.KEY_LOAD_ERROR="keyLoadError",a.KEY_LOAD_TIMEOUT="keyLoadTimeOut",a.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",a.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",a.BUFFER_APPEND_ERROR="bufferAppendError",a.BUFFER_APPENDING_ERROR="bufferAppendingError",a.BUFFER_STALLED_ERROR="bufferStalledError",a.BUFFER_FULL_ERROR="bufferFullError",a.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",a.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",a.ASSET_LIST_LOAD_ERROR="assetListLoadError",a.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",a.ASSET_LIST_PARSING_ERROR="assetListParsingError",a.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",a.INTERNAL_EXCEPTION="internalException",a.INTERNAL_ABORTED="aborted",a.ATTACH_MEDIA_ERROR="attachMediaError",a.UNKNOWN="unknown",a}({}),g=function(a){return a.MEDIA_ATTACHING="hlsMediaAttaching",a.MEDIA_ATTACHED="hlsMediaAttached",a.MEDIA_DETACHING="hlsMediaDetaching",a.MEDIA_DETACHED="hlsMediaDetached",a.MEDIA_ENDED="hlsMediaEnded",a.STALL_RESOLVED="hlsStallResolved",a.BUFFER_RESET="hlsBufferReset",a.BUFFER_CODECS="hlsBufferCodecs",a.BUFFER_CREATED="hlsBufferCreated",a.BUFFER_APPENDING="hlsBufferAppending",a.BUFFER_APPENDED="hlsBufferAppended",a.BUFFER_EOS="hlsBufferEos",a.BUFFERED_TO_END="hlsBufferedToEnd",a.BUFFER_FLUSHING="hlsBufferFlushing",a.BUFFER_FLUSHED="hlsBufferFlushed",a.MANIFEST_LOADING="hlsManifestLoading",a.MANIFEST_LOADED="hlsManifestLoaded",a.MANIFEST_PARSED="hlsManifestParsed",a.LEVEL_SWITCHING="hlsLevelSwitching",a.LEVEL_SWITCHED="hlsLevelSwitched",a.LEVEL_LOADING="hlsLevelLoading",a.LEVEL_LOADED="hlsLevelLoaded",a.LEVEL_UPDATED="hlsLevelUpdated",a.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",a.LEVELS_UPDATED="hlsLevelsUpdated",a.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",a.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",a.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",a.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",a.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",a.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",a.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",a.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",a.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",a.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",a.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",a.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",a.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",a.CUES_PARSED="hlsCuesParsed",a.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",a.INIT_PTS_FOUND="hlsInitPtsFound",a.FRAG_LOADING="hlsFragLoading",a.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",a.FRAG_LOADED="hlsFragLoaded",a.FRAG_DECRYPTED="hlsFragDecrypted",a.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",a.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",a.FRAG_PARSING_METADATA="hlsFragParsingMetadata",a.FRAG_PARSED="hlsFragParsed",a.FRAG_BUFFERED="hlsFragBuffered",a.FRAG_CHANGED="hlsFragChanged",a.FPS_DROP="hlsFpsDrop",a.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",a.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",a.ERROR="hlsError",a.DESTROYING="hlsDestroying",a.KEY_LOADING="hlsKeyLoading",a.KEY_LOADED="hlsKeyLoaded",a.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",a.BACK_BUFFER_REACHED="hlsBackBufferReached",a.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",a.ASSET_LIST_LOADING="hlsAssetListLoading",a.ASSET_LIST_LOADED="hlsAssetListLoaded",a.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",a.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",a.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",a.INTERSTITIAL_STARTED="hlsInterstitialStarted",a.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",a.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",a.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",a.INTERSTITIAL_ENDED="hlsInterstitialEnded",a.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",a.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",a.EVENT_CUE_ENTER="hlsEventCueEnter",a}({});var te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},G={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class re{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class de{constructor(e,t,i,s=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new re(e),this.fast_=new re(t),this.defaultTTFB_=s,this.ttfb_=new re(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new re(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new re(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new re(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,s=e/1e3,n=i/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function we(a,e,t){return(e=Ge(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function Ie(){return Ie=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(a[i]=t[i])}return a},Ie.apply(null,arguments)}function D(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);e&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(a,s).enumerable})),t.push.apply(t,i)}return t}function H(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?D(Object(t),!0).forEach(function(i){we(a,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):D(Object(t)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(t,i))})}return a}function st(a,e){if(typeof a!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var i=t.call(a,e);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function Ge(a){var e=st(a,"string");return typeof e=="symbol"?e:e+""}class Ce{constructor(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const i=`[${e}]:`;this.trace=ae,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)}}const ae=function(){},F={trace:ae,debug:ae,log:ae,warn:ae,info:ae,error:ae};function k(){return Ie({},F)}function X(a,e){const t=self.console[a];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${a}] >`):ae}function le(a,e,t){return e[a]?e[a].bind(e):X(a,t)}const me=k();function Xe(a,e,t){const i=k();if(typeof console=="object"&&a===!0||typeof a=="object"){const s=["debug","log","info","warn","error"];s.forEach(n=>{i[n]=le(n,a,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.15`)}catch(n){return k()}s.forEach(n=>{me[n]=le(n,a)})}else Ie(me,i);return i}const se=me;function vt(a=!0){return typeof self=="undefined"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function yt(a){return typeof self!="undefined"&&a===self.ManagedMediaSource}function Je(a,e){const t=Object.keys(a),i=Object.keys(e),s=t.length,n=i.length;return!s||!n||s===n&&!t.some(r=>i.indexOf(r)===-1)}function nt(a,e=!1){if(typeof TextDecoder!="undefined"){const l=new TextDecoder("utf-8").decode(a);if(e){const c=l.indexOf("\0");return c!==-1?l.substring(0,c):l}return l.replace(/\0/g,"")}const t=a.length;let i,s,n,r="",o=0;for(;o<t;){if(i=a[o++],i===0&&e)return r;if(i===0||i===3)continue;switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:r+=String.fromCharCode(i);break;case 12:case 13:s=a[o++],r+=String.fromCharCode((i&31)<<6|s&63);break;case 14:s=a[o++],n=a[o++],r+=String.fromCharCode((i&15)<<12|(s&63)<<6|(n&63)<<0);break}}return r}function ne(a){let e="";for(let t=0;t<a.length;t++){let i=a[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function ee(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function ce(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var K={exports:{}},Se;function ze(){return Se||(Se=1,function(a,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(u,l,c){if(c=c||{},u=u.trim(),l=l.trim(),!l){if(!c.alwaysNormalize)return u;var h=o.parseURL(u);if(!h)throw new Error("Error trying to parse base URL.");return h.path=o.normalizePath(h.path),o.buildURLFromParts(h)}var m=o.parseURL(l);if(!m)throw new Error("Error trying to parse relative URL.");if(m.scheme)return c.alwaysNormalize?(m.path=o.normalizePath(m.path),o.buildURLFromParts(m)):l;var v=o.parseURL(u);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var y=s.exec(v.path);v.netLoc=y[1],v.path=y[2]}v.netLoc&&!v.path&&(v.path="/");var b={scheme:v.scheme,netLoc:m.netLoc,path:null,params:m.params,query:m.query,fragment:m.fragment};if(!m.netLoc&&(b.netLoc=v.netLoc,m.path[0]!=="/"))if(!m.path)b.path=v.path,m.params||(b.params=v.params,m.query||(b.query=v.query));else{var S=v.path,I=S.substring(0,S.lastIndexOf("/")+1)+m.path;b.path=o.normalizePath(I)}return b.path===null&&(b.path=c.alwaysNormalize?o.normalizePath(m.path):m.path),o.buildURLFromParts(b)},parseURL:function(u){var l=i.exec(u);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(u){for(u=u.split("").reverse().join("").replace(n,"");u.length!==(u=u.replace(r,"")).length;);return u.split("").reverse().join("")},buildURLFromParts:function(u){return u.scheme+u.netLoc+u.path+u.params+u.query+u.fragment}};a.exports=o})()}(K)),K.exports}var ve=ze();class Pe{constructor(){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}}}var ke={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class rt{constructor(e){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,typeof e=="string"&&(e={url:e}),this.base=e,We(this,"stats")}setByteRange(e,t){const i=e.split("@",2);let s;i.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(i[1]),this._byteRange=[s,parseInt(i[0])+s]}get baseurl(){return this.base.url}get byteRange(){return this._byteRange===null?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return this._streams===null&&(this._streams={[ke.AUDIO]:null,[ke.VIDEO]:null,[ke.AUDIOVIDEO]:null}),this._streams}set elementaryStreams(e){this._streams=e}get hasStats(){return this._stats!==null}get hasStreams(){return this._streams!==null}get stats(){return this._stats===null&&(this._stats=new Pe),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ve.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ke.AUDIO]=null,e[ke.VIDEO]=null,e[ke.AUDIOVIDEO]=null}}function _e(a){return a.sn!=="initSegment"}class Ye extends rt{constructor(e,t){super(t),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get byteLength(){if(this.hasStats){const e=this.stats.total;if(e)return e}if(this.byteRange.length){const e=this.byteRange[0],t=this.byteRange[1];if(_(e)&&_(t))return t-e}return null}get bitrate(){return this.byteLength?this.byteLength*8/this.duration:this._bitrate?this._bitrate:null}set bitrate(e){this._bitrate=e}get decryptdata(){var e;const{levelkeys:t}=this;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(!((e=this._decryptdata)!=null&&e.keyId)){const i=Object.keys(t);if(i.length===1){const s=this._decryptdata=t[i[0]]||null;s&&(this._decryptdata=s.getDecryptData(this.sn,t))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=_(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){var t;const i=Object.keys(this.levelkeys),s=i.length;if(s>1||s===1&&(t=this.levelkeys[i[0]])!=null&&t.encrypted)return!0}return!1}get programDateTime(){return this._programDateTime===null&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(e){if(!_(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return _e(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(e){this.setStart(this.start+e)}setStart(e){this.start=e,this._ref&&(this._ref.start=e)}setDuration(e){this.duration=e,this._ref&&(this._ref.duration=e)}setKeyFormat(e){const t=this.levelkeys;if(t){var i;const s=t[e];s&&!((i=this._decryptdata)!=null&&i.keyId)&&(this._decryptdata=s.getDecryptData(this.sn,t))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,s,n,r=!1){const{elementaryStreams:o}=this,u=o[e];if(!u){o[e]={startPTS:t,endPTS:i,startDTS:s,endDTS:n,partial:r};return}u.startPTS=Math.min(u.startPTS,t),u.endPTS=Math.max(u.endPTS,i),u.startDTS=Math.min(u.startDTS,s),u.endDTS=Math.max(u.endDTS,n)}}class ye extends rt{constructor(e,t,i,s,n){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const r=e.enumeratedString("BYTERANGE");r&&this.setByteRange(r,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}function Ve(a,e){const t=Object.getPrototypeOf(a);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||Ve(t,e)}}function We(a,e){const t=Ve(a,e);t&&(t.enumerable=!0,Object.defineProperty(a,e,t))}const Mt=Math.pow(2,32)-1,jt=[].push,_t={video:1,audio:2,id3:3,text:4};function Le(a){return String.fromCharCode.apply(null,a)}function It(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function je(a,e){const t=oe(a,e);return t<0?4294967296+t:t}function Xt(a,e){let t=je(a,e);return t*=Math.pow(2,32),t+=je(a,e+4),t}function oe(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function Me(a){const e=a.byteLength;for(let t=0;t<e;){const i=je(a,t);if(i>8&&a[t+4]===109&&a[t+5]===111&&a[t+6]===111&&a[t+7]===102)return!0;t=i>1?t+i:e}return!1}function N(a,e){const t=[];if(!e.length)return t;const i=a.byteLength;for(let s=0;s<i;){const n=je(a,s),r=Le(a.subarray(s+4,s+8)),o=n>1?s+n:i;if(r===e[0])if(e.length===1)t.push(a.subarray(s+8,o));else{const u=N(a.subarray(s+8,o),e.slice(1));u.length&&jt.apply(t,u)}s=o}return t}function Ue(a){const e=[],t=a[0];let i=8;const s=je(a,i);i+=4;let n=0,r=0;t===0?(n=je(a,i),r=je(a,i+4),i+=8):(n=Xt(a,i),r=Xt(a,i+8),i+=16),i+=2;let o=a.length+r;const u=It(a,i);i+=2;for(let l=0;l<u;l++){let c=i;const h=je(a,c);c+=4;const m=h&2147483647;if((h&2147483648)>>>31===1)return se.warn("SIDX has hierarchical references (not supported)"),null;const y=je(a,c);c+=4,e.push({referenceSize:m,subsegmentDuration:y,info:{duration:y/s,start:o,end:o+m-1}}),o+=m,c+=4,i=c}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:u,references:e}}function z(a){const e=[],t=N(a,["moov","trak"]);for(let s=0;s<t.length;s++){const n=t[s],r=N(n,["tkhd"])[0];if(r){let o=r[0];const u=je(r,o===0?12:20),l=N(n,["mdia","mdhd"])[0];if(l){o=l[0];const c=je(l,o===0?12:20),h=N(n,["mdia","hdlr"])[0];if(h){const m=Le(h.subarray(8,12)),v={soun:ke.AUDIO,vide:ke.VIDEO}[m],y=N(n,["mdia","minf","stbl","stsd"])[0],b=$(y);v?(e[u]={timescale:c,type:v,stsd:b},e[v]=H({timescale:c,id:u},b)):e[u]={timescale:c,type:m,stsd:b}}}}}return N(a,["moov","mvex","trex"]).forEach(s=>{const n=je(s,4),r=e[n];r&&(r.default={duration:je(s,12),flags:je(s,20)})}),e}function $(a){const e=a.subarray(8),t=e.subarray(86),i=Le(e.subarray(4,8));let s=i,n;const r=i==="enca"||i==="encv";if(r){const l=N(e,[i])[0].subarray(i==="enca"?28:78);N(l,["sinf"]).forEach(h=>{const m=N(h,["schm"])[0];if(m){const v=Le(m.subarray(4,8));if(v==="cbcs"||v==="cenc"){const y=N(h,["frma"])[0];y&&(s=Le(y))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const u=N(t,["avcC"])[0];u&&u.length>3&&(s+="."+V(u[1])+V(u[2])+V(u[3]),n=M(o==="avc1"?"dva1":"dvav",t));break}case"mp4a":{const u=N(e,[i])[0],l=N(u.subarray(28),["esds"])[0];if(l&&l.length>7){let c=4;if(l[c++]!==3)break;c=P(l,c),c+=2;const h=l[c++];if(h&128&&(c+=2),h&64&&(c+=l[c++]),l[c++]!==4)break;c=P(l,c);const m=l[c++];if(m===64)s+="."+V(m);else break;if(c+=12,l[c++]!==5)break;c=P(l,c);const v=l[c++];let y=(v&248)>>3;y===31&&(y+=1+((v&7)<<3)+((l[c]&224)>>5)),s+="."+y}break}case"hvc1":case"hev1":{const u=N(t,["hvcC"])[0];if(u&&u.length>12){const l=u[1],c=["","A","B","C"][l>>6],h=l&31,m=je(u,2),v=(l&32)>>5?"H":"L",y=u[12],b=u.subarray(6,12);s+="."+c+h,s+="."+w(m).toString(16).toUpperCase(),s+="."+v+y;let S="";for(let I=b.length;I--;){const R=b[I];(R||S)&&(S="."+R.toString(16).toUpperCase()+S)}s+=S}n=M(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{s=M(s,t)||s;break}case"vp09":{const u=N(t,["vpcC"])[0];if(u&&u.length>6){const l=u[4],c=u[5],h=u[6]>>4&15;s+="."+C(l)+"."+C(c)+"."+C(h)}break}case"av01":{const u=N(t,["av1C"])[0];if(u&&u.length>2){const l=u[1]>>>5,c=u[1]&31,h=u[2]>>>7?"H":"M",m=(u[2]&64)>>6,v=(u[2]&32)>>5,y=l===2&&m?v?12:10:m?10:8,b=(u[2]&16)>>4,S=(u[2]&8)>>3,I=(u[2]&4)>>2,R=u[2]&3;s+="."+l+"."+C(c)+h+"."+C(y)+"."+b+"."+S+I+R+"."+C(1)+"."+C(1)+"."+C(1)+"."+0,n=M("dav1",t)}break}}return{codec:s,encrypted:r,supplemental:n}}function M(a,e){const t=N(e,["dvvC"]),i=t.length?t[0]:N(e,["dvcC"])[0];if(i){const s=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return a+"."+C(s)+"."+C(n)}}function w(a){let e=0;for(let t=0;t<32;t++)e|=(a>>t&1)<<31-t;return e>>>0}function P(a,e){const t=e+5;for(;a[e++]&128&&e<t;);return e}function V(a){return("0"+a.toString(16).toUpperCase()).slice(-2)}function C(a){return(a<10?"0":"")+a}function Ee(a,e){if(!a||!e)return;const t=e.keyId;t&&e.isCommonEncryption&&Ke(a,(i,s)=>{const n=i.subarray(8,24);n.some(r=>r!==0)||(se.log(`[eme] Patching keyId in 'enc${s?"a":"v"}>sinf>>tenc' box: ${ne(n)} -> ${ne(t)}`),i.set(t,8))})}function xe(a){const e=[];return Ke(a,t=>e.push(t.subarray(8,24))),e}function Ke(a,e){N(a,["moov","trak"]).forEach(i=>{const s=N(i,["mdia","minf","stbl","stsd"])[0];if(!s)return;const n=s.subarray(8);let r=N(n,["enca"]);const o=r.length>0;o||(r=N(n,["encv"])),r.forEach(u=>{const l=o?u.subarray(28):u.subarray(78);N(l,["sinf"]).forEach(h=>{const m=ot(h);m&&e(m,o)})})})}function ot(a){const e=N(a,["schm"])[0];if(e){const t=Le(e.subarray(4,8));if(t==="cbcs"||t==="cenc"){const i=N(a,["schi","tenc"])[0];if(i)return i}}}function Rt(a,e,t){const i={},s=N(a,["moof","traf"]);for(let n=0;n<s.length;n++){const r=s[n],o=N(r,["tfhd"])[0],u=je(o,4),l=e[u];if(!l)continue;i[u]||(i[u]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});const c=i[u],h=N(r,["tfdt"])[0];if(h){const L=h[0];let B=je(h,4);L===1&&(B===Mt?t.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(B*=Mt+1,B+=je(h,8))),_(B)&&(!_(c.start)||B<c.start)&&(c.start=B)}const m=l.default,v=je(o,0)|(m==null?void 0:m.flags);let y=(m==null?void 0:m.duration)||0;v&8&&(v&2?y=je(o,12):y=je(o,8));const b=N(r,["trun"]);let S=c.start||0,I=0,R=y;for(let L=0;L<b.length;L++){const B=b[L],j=je(B,4),be=c.sampleCount;c.sampleCount+=j;const Z=B[3]&1,fe=B[3]&4,he=B[2]&1,q=B[2]&2,Oe=B[2]&4,gt=B[2]&8;let wt=8,Vt=j;for(Z&&(wt+=4),fe&&j&&(!(B[wt+1]&1)&&c.keyFrameIndex===void 0&&(c.keyFrameIndex=be),wt+=4,he?(R=je(B,wt),wt+=4):R=y,q&&(wt+=4),gt&&(wt+=4),S+=R,I+=R,Vt--);Vt--;)he?(R=je(B,wt),wt+=4):R=y,q&&(wt+=4),Oe&&(B[wt+1]&1||c.keyFrameIndex===void 0&&(c.keyFrameIndex=c.sampleCount-(Vt+1),c.keyFrameStart=S),wt+=4),gt&&(wt+=4),S+=R,I+=R;!I&&y&&(I+=y*j)}c.duration+=I}if(!Object.keys(i).some(n=>i[n].duration)){let n=1/0,r=0;const o=N(a,["sidx"]);for(let u=0;u<o.length;u++){const l=Ue(o[u]);if(l!=null&&l.references){n=Math.min(n,l.earliestPresentationTime/l.timescale);const c=l.references.reduce((h,m)=>h+m.info.duration||0,0);r=Math.max(r,c+l.earliestPresentationTime/l.timescale)}}r&&_(r)&&Object.keys(i).forEach(u=>{i[u].duration||(i[u].duration=r*i[u].timescale-i[u].start)})}return i}function et(a){const e={valid:null,remainder:null},t=N(a,["moof"]);if(t.length<2)return e.remainder=a,e;const i=t[t.length-1];return e.valid=a.slice(0,i.byteOffset-8),e.remainder=a.slice(i.byteOffset-8),e}function ut(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function Et(a,e){const t=[],i=e.samples,s=e.timescale,n=e.id;let r=!1;return N(i,["moof"]).map(u=>{const l=u.byteOffset-8;N(u,["traf"]).map(h=>{const m=N(h,["tfdt"]).map(v=>{const y=v[0];let b=je(v,4);return y===1&&(b*=Math.pow(2,32),b+=je(v,8)),b/s})[0];return m!==void 0&&(a=m),N(h,["tfhd"]).map(v=>{const y=je(v,4),b=je(v,0)&16777215,S=(b&1)!==0,I=(b&2)!==0,R=(b&8)!==0;let L=0;const B=(b&16)!==0;let j=0;const be=(b&32)!==0;let Z=8;y===n&&(S&&(Z+=8),I&&(Z+=4),R&&(L=je(v,Z),Z+=4),B&&(j=je(v,Z),Z+=4),be&&(Z+=4),e.type==="video"&&(r=Tt(e.codec)),N(h,["trun"]).map(fe=>{const he=fe[0],q=je(fe,0)&16777215,Oe=(q&1)!==0;let gt=0;const wt=(q&4)!==0,Vt=(q&256)!==0;let kt=0;const at=(q&512)!==0;let Ot=0;const bt=(q&1024)!==0,$t=(q&2048)!==0;let Jt=0;const ht=je(fe,4);let ft=8;Oe&&(gt=je(fe,ft),ft+=4),wt&&(ft+=4);let yi=gt+l;for(let Ki=0;Ki<ht;Ki++){if(Vt?(kt=je(fe,ft),ft+=4):kt=L,at?(Ot=je(fe,ft),ft+=4):Ot=j,bt&&(ft+=4),$t&&(he===0?Jt=je(fe,ft):Jt=oe(fe,ft),ft+=4),e.type===ke.VIDEO){let bi=0;for(;bi<Ot;){const Mi=je(i,yi);if(yi+=4,lt(r,i[yi])){const xs=i.subarray(yi,yi+Mi);pe(xs,r?2:1,a+Jt/s,t)}yi+=Mi,bi+=Mi+4}}a+=kt/s}}))})})}),t}function Tt(a){if(!a)return!1;const e=a.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function lt(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function pe(a,e,t,i){const s=pt(a);let n=0;n+=e;let r=0,o=0,u=0;for(;n<s.length;){r=0;do{if(n>=s.length)break;u=s[n++],r+=u}while(u===255);o=0;do{if(n>=s.length)break;u=s[n++],o+=u}while(u===255);const l=s.length-n;let c=n;if(o<l)n+=o;else if(o>l){se.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(r===4){if(s[c++]===181){const m=It(s,c);if(c+=2,m===49){const v=je(s,c);if(c+=4,v===1195456820){const y=s[c++];if(y===3){const b=s[c++],S=31&b,I=64&b,R=I?2+S*3:0,L=new Uint8Array(R);if(I){L[0]=b;for(let B=1;B<R;B++)L[B]=s[c++]}i.push({type:y,payloadType:r,pts:t,bytes:L})}}}}}else if(r===5&&o>16){const h=[];for(let y=0;y<16;y++){const b=s[c++].toString(16);h.push(b.length==1?"0"+b:b),(y===3||y===5||y===7||y===9)&&h.push("-")}const m=o-16,v=new Uint8Array(m);for(let y=0;y<m;y++)v[y]=s[c++];i.push({payloadType:r,pts:t,uuid:h.join(""),userData:nt(v),userDataBytes:v})}}}function pt(a){const e=a.byteLength,t=[];let i=1;for(;i<e-2;)a[i]===0&&a[i+1]===0&&a[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return a;const s=e-t.length,n=new Uint8Array(s);let r=0;for(i=0;i<s;r++,i++)r===t[0]&&(r++,t.shift()),n[i]=a[r];return n}function Ei(a){const e=a[0];let t="",i="",s=0,n=0,r=0,o=0,u=0,l=0;if(e===0){for(;Le(a.subarray(l,l+1))!=="\0";)t+=Le(a.subarray(l,l+1)),l+=1;for(t+=Le(a.subarray(l,l+1)),l+=1;Le(a.subarray(l,l+1))!=="\0";)i+=Le(a.subarray(l,l+1)),l+=1;i+=Le(a.subarray(l,l+1)),l+=1,s=je(a,12),n=je(a,16),o=je(a,20),u=je(a,24),l=28}else if(e===1){l+=4,s=je(a,l),l+=4;const h=je(a,l);l+=4;const m=je(a,l);for(l+=4,r=bl(2,32)*h+m,J(r)||(r=Number.MAX_SAFE_INTEGER,se.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=je(a,l),l+=4,u=je(a,l),l+=4;Le(a.subarray(l,l+1))!=="\0";)t+=Le(a.subarray(l,l+1)),l+=1;for(t+=Le(a.subarray(l,l+1)),l+=1;Le(a.subarray(l,l+1))!=="\0";)i+=Le(a.subarray(l,l+1)),l+=1;i+=Le(a.subarray(l,l+1)),l+=1}const c=a.subarray(l,a.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:r,presentationTimeDelta:n,eventDuration:o,id:u,payload:c}}function _i(a,...e){const t=e.length;let i=8,s=t;for(;s--;)i+=e[s].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=i&255,n.set(a,4),s=0,i=8;s<t;s++)n.set(e[s],i),i+=e[s].byteLength;return n}function li(a,e,t){if(a.byteLength!==16)throw new RangeError("Invalid system id");let i,s;i=0,s=new Uint8Array;let n;i>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const r=new Uint8Array(4);return t.byteLength>0&&new DataView(r.buffer).setUint32(0,t.byteLength,!1),_i([112,115,115,104],new Uint8Array([i,0,0,0]),a,n,s,r,t)}function Ai(a){const e=[];if(a instanceof ArrayBuffer){const t=a.byteLength;let i=0;for(;i+32<t;){const s=new DataView(a,i),n=Vi(s);e.push(n),i+=n.size}}return e}function Vi(a){const e=a.getUint32(0),t=a.byteOffset,i=a.byteLength;if(i<e)return{offset:t,size:i};if(a.getUint32(4)!==1886614376)return{offset:t,size:e};const n=a.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};const r=a.buffer,o=ne(new Uint8Array(r,t+12,16));let u=null,l=null,c=0;if(n===0)c=28;else{const m=a.getUint32(28);if(!m||i<32+m*16)return{offset:t,size:e};u=[];for(let v=0;v<m;v++)u.push(new Uint8Array(r,t+32+v*16,16));c=32+m*16}if(!c)return{offset:t,size:e};const h=a.getUint32(c);return e-32<h?{offset:t,size:e}:(l=new Uint8Array(r,t+c+4,h),{version:n,systemId:o,kids:u,data:l,offset:t,size:e})}const Ti=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),Ut={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,dav1:.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 wi(a,e){const t=Ut[e];return!!t&&!!t[a.slice(0,4)]}function ui(a,e,t=!0){return!a.split(",").some(i=>!tt(i,e,t))}function tt(a,e,t=!0){var i;const s=vt(t);return(i=s==null?void 0:s.isTypeSupported(Lt(a,e)))!=null?i:!1}function Lt(a,e){return`${e}/mp4;codecs=${a}`}function St(a){if(a){const e=a.substring(0,4);return Ut.video[e]}return 2}function ti(a){const e=Ti();return a.split(",").reduce((t,i)=>{const n=e&&Tt(i)?9:Ut.video[i];return n?(n*2+t)/(t?3:2):(Ut.audio[i]+t)/(t?2:1)},0)}const oi={};function ci(a,e=!0){if(oi[a])return oi[a];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[a];for(let s=0;s<t.length;s++){var i;if(tt(t[s],"audio",e))return oi[a]=t[s],t[s];if(t[s]==="mp3"&&(i=vt(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return a}const Ht=/flac|opus|mp4a\.40\.34/i;function Ii(a,e=!0){return a.replace(Ht,t=>ci(t.toLowerCase(),e))}function Ft(a,e){const t=[];if(a){const i=a.split(",");for(let s=0;s<i.length;s++)wi(i[s],"video")||t.push(i[s])}return e&&t.push(e),t.join(",")}function si(a,e){if(a&&(a.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(a)!==-1)&&(Pi(a,"audio")||Pi(a,"video")))return a;if(e){const t=e.split(",");if(t.length>1){if(a){for(let i=t.length;i--;)if(t[i].substring(0,4)===a.substring(0,4))return t[i]}return t[0]}}return e||a}function Pi(a,e){return wi(a,e)&&tt(a,e)}function Fe(a){const e=a.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");i.length>2&&i[0]==="avc1"&&(e[t]=`avc1.${parseInt(i[1]).toString(16)}${("000"+parseInt(i[2]).toString(16)).slice(-4)}`)}return e.join(",")}function d(a){if(a.startsWith("av01.")){const e=a.split("."),t=["0","111","01","01","01","0"];for(let i=e.length;i>4&&i<10;i++)e[i]=t[i-4];return e.join(".")}return a}function f(a){const e=vt(a)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function p(a){return a.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const E={supported:!0,powerEfficient:!0,smooth:!0},T={supported:!1,smooth:!1,powerEfficient:!1},O={supported:!0,configurations:[],decodingInfoResults:[E]};function U(a,e){return{supported:!1,configurations:e,decodingInfoResults:[T],error:a}}function Ze(a,e,t,i,s,n){const r=a.videoCodec,o=a.audioCodec?a.audioGroups:null,u=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,c=l?parseInt(l):u?1/0:2;let h=null;if(o!=null&&o.length)try{o.length===1&&o[0]?h=e.groups[o[0]].channels:h=o.reduce((m,v)=>{if(v){const y=e.groups[v];if(!y)throw new Error(`Audio track group ${v} not found`);Object.keys(y.channels).forEach(b=>{m[b]=(m[b]||0)+y.channels[b]})}return m},{2:0})}catch(m){return!0}return r!==void 0&&(r.split(",").some(m=>Tt(m))||a.width>1920&&a.height>1088||a.height>1920&&a.width>1088||a.frameRate>Math.max(i,30)||a.videoRange!=="SDR"&&a.videoRange!==t||a.bitrate>Math.max(s,8e6))||!!h&&_(c)&&Object.keys(h).some(m=>parseInt(m)>c)}function $e(a,e,t,i={}){const s=a.videoCodec;if(!s&&!a.audioCodec||!t)return Promise.resolve(O);const n=[],r=ct(a),o=r.length,u=Gt(a,e,o>0),l=u.length;for(let c=o||1*l||1;c--;){const h={type:"media-source"};if(o&&(h.video=r[c%o]),l){h.audio=u[c%l];const m=h.audio.bitrate;h.video&&m&&(h.video.bitrate-=m)}n.push(h)}if(s){const c=navigator.userAgent;if(s.split(",").some(h=>Tt(h))&&Ti())return Promise.resolve(U(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${c})`),n))}return Promise.all(n.map(c=>{const h=Bt(c);return i[h]||(i[h]=t.decodingInfo(c))})).then(c=>({supported:!c.some(h=>!h.supported),configurations:n,decodingInfoResults:c})).catch(c=>({supported:!1,configurations:n,decodingInfoResults:[],error:c}))}function ct(a){var e;const t=(e=a.videoCodec)==null?void 0:e.split(","),i=it(a),s=a.width||640,n=a.height||480,r=a.frameRate||30,o=a.videoRange.toLowerCase();return t?t.map(u=>{const l={contentType:Lt(d(u),"video"),width:s,height:n,bitrate:i,framerate:r};return o!=="sdr"&&(l.transferFunction=o),l}):[]}function Gt(a,e,t){var i;const s=(i=a.audioCodec)==null?void 0:i.split(","),n=it(a);return s&&a.audioGroups?a.audioGroups.reduce((r,o)=>{var u;const l=o?(u=e.groups[o])==null?void 0:u.tracks:null;return l?l.reduce((c,h)=>{if(h.groupId===o){const m=parseFloat(h.channels||"");s.forEach(v=>{const y={contentType:Lt(v,"audio"),bitrate:t?Pt(v,n):n};m&&(y.channels=""+m),c.push(y)})}return c},r):r},[]):[]}function Pt(a,e){if(e<=1)return 1;let t=128e3;return a==="ec-3"?t=768e3:a==="ac-3"&&(t=64e4),Math.min(e/2,t)}function it(a){return Math.ceil(Math.max(a.bitrate*.9,a.averageBitrate)/1e3)*1e3||1}function Bt(a){let e="";const{audio:t,video:i}=a;if(i){const s=p(i.contentType);e+=`${s}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`}if(t){const s=p(t.contentType);e+=`${i?"_":""}${s}_c${t.channels}`}return e}const dt=["NONE","TYPE-0","TYPE-1",null];function He(a){return dt.indexOf(a)>-1}const Ne=["SDR","PQ","HLG"];function Ct(a){return!!a&&Ne.indexOf(a)>-1}var mt={No:"",Yes:"YES",v2:"v2"};function di(a){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=a,s=i<e/2;return e&&s?t?mt.v2:mt.Yes:mt.No}class Ri{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class mi{constructor(e){if(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.supplemental=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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(i=>!!i).map(i=>i.substring(0,4)).join(","),"supplemental"in e){var t;this.supplemental=e.supplemental;const i=(t=e.supplemental)==null?void 0:t.videoCodec;i&&i!==e.videoCodec&&(this.codecSet+=`,${i.substring(0,4)}`)}this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return Dt(this._audioGroups,e)}hasSubtitleGroup(e){return Dt(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let i=this._audioGroups;i||(i=this._audioGroups=[]),i.indexOf(t)===-1&&i.push(t)}else if(e==="text"){let i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),i.indexOf(t)===-1&&i.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Dt(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function ni(){if(typeof matchMedia=="function"){const a=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(a.media!==e.media)return a.matches===!0}return!1}function ki(a,e){let t=!1,i=[];if(a&&(t=a!=="SDR",i=[a]),e){i=e.allowedVideoRanges||Ne.slice(0);const s=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:s&&ni(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const W=a=>{const e=new WeakSet;return(t,i)=>{if(a&&(i=a(t,i)),typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i)}return i}},Q=(a,e)=>JSON.stringify(a,W(e));function Re(a,e,t,i,s){const n=Object.keys(a),r=i==null?void 0:i.channels,o=i==null?void 0:i.audioCodec,u=s==null?void 0:s.videoCodec,l=r&&parseInt(r)===2;let c=!1,h=!1,m=1/0,v=1/0,y=1/0,b=1/0,S=0,I=[];const{preferHDR:R,allowedVideoRanges:L}=ki(e,s);for(let fe=n.length;fe--;){const he=a[n[fe]];c||(c=he.channels[2]>0),m=Math.min(m,he.minHeight),v=Math.min(v,he.minFramerate),y=Math.min(y,he.minBitrate),L.filter(Oe=>he.videoRanges[Oe]>0).length>0&&(h=!0)}m=_(m)?m:0,v=_(v)?v:0;const B=Math.max(1080,m),j=Math.max(30,v);y=_(y)?y:t,t=Math.max(y,t),h||(e=void 0);const be=n.length>1;return{codecSet:n.reduce((fe,he)=>{const q=a[he];if(he===fe)return fe;if(I=h?L.filter(Oe=>q.videoRanges[Oe]>0):[],be){if(q.minBitrate>t)return ge(he,`min bitrate of ${q.minBitrate} > current estimate of ${t}`),fe;if(!q.hasDefaultAudio)return ge(he,"no renditions with default or auto-select sound found"),fe;if(o&&he.indexOf(o.substring(0,4))%5!==0)return ge(he,`audio codec preference "${o}" not found`),fe;if(r&&!l){if(!q.channels[r])return ge(he,`no renditions with ${r} channel sound found (channels options: ${Object.keys(q.channels)})`),fe}else if((!o||l)&&c&&q.channels[2]===0)return ge(he,"no renditions with stereo sound found"),fe;if(q.minHeight>B)return ge(he,`min resolution of ${q.minHeight} > maximum of ${B}`),fe;if(q.minFramerate>j)return ge(he,`min framerate of ${q.minFramerate} > maximum of ${j}`),fe;if(!I.some(Oe=>q.videoRanges[Oe]>0))return ge(he,`no variants with VIDEO-RANGE of ${Q(I)} found`),fe;if(u&&he.indexOf(u.substring(0,4))%5!==0)return ge(he,`video codec preference "${u}" not found`),fe;if(q.maxScore<S)return ge(he,`max score of ${q.maxScore} < selected max of ${S}`),fe}return fe&&(ti(he)>=ti(fe)||q.fragmentError>a[fe].fragmentError)?fe:(b=q.minIndex,S=q.maxScore,he)},void 0),videoRanges:I,preferHDR:R,minFramerate:v,minBitrate:y,minIndex:b}}function ge(a,e){se.log(`[abr] start candidates with "${a}" ignored because ${e}`)}function ue(a){return a.reduce((e,t)=>{let i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);const s=t.channels||"2";return i.channels[s]=(i.channels[s]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Te(a,e,t,i){return a.slice(t,i+1).reduce((s,n,r)=>{if(!n.codecSet)return s;const o=n.audioGroups;let u=s[n.codecSet];u||(s[n.codecSet]=u={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:r,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!o,fragmentError:0}),u.minBitrate=Math.min(u.minBitrate,n.bitrate);const l=Math.min(n.height,n.width);return u.minHeight=Math.min(u.minHeight,l),u.minFramerate=Math.min(u.minFramerate,n.frameRate),u.minIndex=Math.min(u.minIndex,r),u.maxScore=Math.max(u.maxScore,n.score),u.fragmentError+=n.fragmentError,u.videoRanges[n.videoRange]=(u.videoRanges[n.videoRange]||0)+1,o&&o.forEach(c=>{if(!c)return;const h=e.groups[c];h&&(u.hasDefaultAudio=u.hasDefaultAudio||e.hasDefaultAudio?h.hasDefault:h.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(h.channels).forEach(m=>{u.channels[m]=(u.channels[m]||0)+h.channels[m]}))}),s},{})}function Be(a){if(!a)return a;const{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:n}=a;return{lang:e,assocLang:t,characteristics:i,channels:s,audioCodec:n}}function Qe(a,e,t){if("attrs"in a){const i=e.indexOf(a);if(i!==-1)return i}for(let i=0;i<e.length;i++){const s=e[i];if(Kt(a,s,t))return i}return-1}function Kt(a,e,t){const{groupId:i,name:s,lang:n,assocLang:r,default:o}=a,u=a.forced;return(i===void 0||e.groupId===i)&&(s===void 0||e.name===s)&&(n===void 0||xt(n,e.lang))&&(n===void 0||e.assocLang===r)&&(o===void 0||e.default===o)&&(u===void 0||e.forced===u)&&(!("characteristics"in a)||ei(a.characteristics||"",e.characteristics))&&(t===void 0||t(a,e))}function xt(a,e="--"){return a.length===e.length?a===e:a.startsWith(e)||e.startsWith(a)}function ei(a,e=""){const t=a.split(","),i=e.split(",");return t.length===i.length&&!t.some(s=>i.indexOf(s)===-1)}function Nt(a,e){const{audioCodec:t,channels:i}=a;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(i===void 0||i===(e.channels||"2"))}function Zt(a,e,t,i,s){const n=e[i],o=e.reduce((m,v,y)=>{const b=v.uri;return(m[b]||(m[b]=[])).push(y),m},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));const u=n.videoRange,l=n.frameRate,c=n.codecSet.substring(0,4),h=Qt(e,i,m=>{if(m.videoRange!==u||m.frameRate!==l||m.codecSet.substring(0,4)!==c)return!1;const v=m.audioGroups,y=t.filter(b=>!v||v.indexOf(b.groupId)!==-1);return Qe(a,y,s)>-1});return h>-1?h:Qt(e,i,m=>{const v=m.audioGroups,y=t.filter(b=>!v||v.indexOf(b.groupId)!==-1);return Qe(a,y,s)>-1})}function Qt(a,e,t){for(let i=e;i>-1;i--)if(t(a[i]))return i;for(let i=e+1;i<a.length;i++)if(t(a[i]))return i;return-1}function gi(a,e){var t;return!!a&&a!==((t=e.loadLevelObj)==null?void 0:t.uri)}class Si extends Ce{constructor(e){super("abr",e.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var i;const{fragCurrent:s,partCurrent:n,hls:r}=this,{autoLevelEnabled:o,media:u}=r;if(!s||!u)return;const l=performance.now(),c=n?n.stats:s.stats,h=n?n.duration:s.duration,m=l-c.loading.start,v=r.minAutoLevel,y=s.level,b=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||y<=v){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const S=b>-1&&b!==y,I=!!t||S;if(!I&&(u.paused||!u.playbackRate||!u.readyState))return;const R=r.mainForwardBufferInfo;if(!I&&R===null)return;const L=this.bwEstimator.getEstimateTTFB(),B=Math.abs(u.playbackRate);if(m<=Math.max(L,1e3*(h/(B*2))))return;const j=R?R.len/B:0,be=c.loading.first?c.loading.first-c.loading.start:-1,Z=c.loaded&&be>-1,fe=this.getBwEstimate(),he=r.levels,q=he[y],Oe=Math.max(c.loaded,Math.round(h*(s.bitrate||q.averageBitrate)/8));let gt=Z?m-be:m;gt<1&&Z&&(gt=Math.min(m,c.loaded*8/fe));const wt=Z?c.loaded*1e3/gt:0,Vt=L/1e3,kt=wt?(Oe-c.loaded)/wt:Oe*8/fe+Vt;if(kt<=j)return;const at=wt?wt*8:fe,Ot=((i=(t==null?void 0:t.details)||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,bt=this.hls.config.abrBandWidthUpFactor;let $t=Number.POSITIVE_INFINITY,Jt;for(Jt=y-1;Jt>v;Jt--){const Ki=he[Jt].maxBitrate,bi=!he[Jt].details||Ot;if($t=this.getTimeToLoadFrag(Vt,at,h*Ki,bi),$t<Math.min(j,h+Vt))break}if($t>=kt||$t>h*10)return;Z?this.bwEstimator.sample(m-Math.min(L,be),c.loaded):this.bwEstimator.sampleTTFB(m);const ht=he[Jt].maxBitrate;this.getBwEstimate()*bt>ht&&this.resetEstimator(ht);const ft=this.findBestLevel(ht,v,Jt,0,j,1,1);ft>-1&&(Jt=ft),this.warn(`Fragment ${s.sn}${n?" part "+n.index:""} of level ${y} is loading too slowly;
Fragment duration: ${s.duration.toFixed(3)}
Time to underbuffer: ${j.toFixed(3)} s
Estimated load time for current fragment: ${kt.toFixed(3)} s
Estimated load time for down switch fragment: ${$t.toFixed(3)} s
TTFB estimate: ${be|0} ms
Current BW estimate: ${_(fe)?fe|0:"Unknown"} bps
New BW estimate: ${this.getBwEstimate()|0} bps
Switching to level ${Jt} @ ${ht|0} bps`),r.nextLoadLevel=r.nextAutoLevel=Jt,this.clearTimer();const yi=()=>{if(this.clearTimer(),this.fragCurrent===s&&this.hls.loadLevel===Jt&&Jt>0){const Ki=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${Jt>0?"and switching down":""}
Fragment duration: ${s.duration.toFixed(3)} s
Time to underbuffer: ${Ki.toFixed(3)} s`),s.abortRequests(),this.fragCurrent=this.partCurrent=null,Jt>v){let bi=this.findBestLevel(this.hls.levels[v].bitrate,v,Jt,0,Ki,1,1);bi===-1&&(bi=v),this.hls.nextLoadLevel=this.hls.nextAutoLevel=bi,this.resetEstimator(this.hls.levels[bi].bitrate)}}};S||kt>$t*2?yi():this.timer=self.setInterval(yi,$t*1e3),r.trigger(g.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:n,stats:c})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new de(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.FRAG_LOADING,this.onFragLoading,this),e.on(g.FRAG_LOADED,this.onFragLoaded,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(g.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.FRAG_LOADING,this.onFragLoading,this),e.off(g.FRAG_LOADED,this.onFragLoaded,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(g.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const i=t.frag;if(!this.ignoreFragment(i)){if(!i.bitrateTest){var s;this.fragCurrent=i,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case A.BUFFER_ADD_CODEC_ERROR:case A.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case A.FRAG_LOAD_TIMEOUT:{const i=t.frag,{fragCurrent:s,partCurrent:n}=this;if(i&&s&&i.sn===s.sn&&i.level===s.level){const r=performance.now(),o=n?n.stats:i.stats,u=r-o.loading.start,l=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&l>-1){const h=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(u-Math.min(h,l),o.loaded)}else this.bwEstimator.sampleTTFB(u)}break}}}getTimeToLoadFrag(e,t,i,s){const n=e+i/t,r=s?e+this.lastLevelLoadSec:0;return n+r}onLevelLoaded(e,t){const i=this.hls.config,{loading:s}=t.stats,n=s.end-s.first;_(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}onFragLoaded(e,{frag:t,part:i}){const s=i?i.stats:t.stats;if(t.type===G.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const n=i?i.duration:t.duration,r=this.hls.levels[t.level],o=(r.loaded?r.loaded.bytes:0)+s.loaded,u=(r.loaded?r.loaded.duration:0)+n;r.loaded={bytes:o,duration:u},r.realBitrate=Math.round(8*o/u)}if(t.bitrateTest){const n={stats:s,frag:t,part:i,id:t.type};this.onFragBuffered(g.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:i,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:i.stats;if(n.aborted||this.ignoreFragment(i))return;const r=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(r,n.loaded),n.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==G.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,i=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,t,e,0,s,1,1);if(n>-1)return n;const r=this.hls.firstLevel,o=Math.min(Math.max(r,t),e);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${r} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,i=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!i||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=i&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const r=this.hls.levels;if(r.length>Math.max(e,n)&&r[e].loadError<=r[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this;if(i.levels.length<=1)return i.loadLevel;const{maxAutoLevel:s,config:n,minAutoLevel:r}=i,o=t?t.duration:e?e.duration:0,u=this.getBwEstimate(),l=this.getStarvationDelay();let c=n.abrBandWidthFactor,h=n.abrBandWidthUpFactor;if(l){const S=this.findBestLevel(u,r,s,l,0,c,h);if(S>=0)return this.rebufferNotice=-1,S}let m=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const S=this.bitrateTestDelay;S&&(m=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-S,this.info(`bitrate test took ${Math.round(1e3*S)}ms, set first fragment max fetchDuration to ${Math.round(1e3*m)} ms`),c=h=1)}const v=this.findBestLevel(u,r,s,l,m,c,h);if(this.rebufferNotice!==v&&(this.rebufferNotice=v,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${v}`)),v>-1)return v;const y=i.levels[r],b=i.loadLevelObj;return b&&(y==null?void 0:y.bitrate)<b.bitrate?r:i.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const i=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,i,s,n,r,o){var u;const l=s+n,c=this.lastLoadedFragLevel,h=c===-1?this.hls.firstLevel:c,{fragCurrent:m,partCurrent:v}=this,{levels:y,allAudioTracks:b,loadLevel:S,config:I}=this.hls;if(y.length===1)return 0;const R=y[h],L=!!((u=this.hls.latestLevelDetails)!=null&&u.live),B=S===-1||c===-1;let j,be="SDR",Z=(R==null?void 0:R.frameRate)||0;const{audioPreference:fe,videoPreference:he}=I,q=this.audioTracksByGroup||(this.audioTracksByGroup=ue(b));let Oe=-1;if(B){if(this.firstSelection!==-1)return this.firstSelection;const at=this.codecTiers||(this.codecTiers=Te(y,q,t,i)),Ot=Re(at,be,e,fe,he),{codecSet:bt,videoRanges:$t,minFramerate:Jt,minBitrate:ht,minIndex:ft,preferHDR:yi}=Ot;Oe=ft,j=bt,be=yi?$t[$t.length-1]:$t[0],Z=Jt,e=Math.max(e,ht),this.log(`picked start tier ${Q(Ot)}`)}else j=R==null?void 0:R.codecSet,be=R==null?void 0:R.videoRange;const gt=v?v.duration:m?m.duration:0,wt=this.bwEstimator.getEstimateTTFB()/1e3,Vt=[];for(let at=i;at>=t;at--){var kt;const Ot=y[at],bt=at>h;if(!Ot)continue;if(I.useMediaCapabilities&&!Ot.supportedResult&&!Ot.supportedPromise){const bi=navigator.mediaCapabilities;typeof(bi==null?void 0:bi.decodingInfo)=="function"&&Ze(Ot,q,be,Z,e,fe)?(Ot.supportedPromise=$e(Ot,q,bi,this.supportedCache),Ot.supportedPromise.then(Mi=>{if(!this.hls)return;Ot.supportedResult=Mi;const xs=this.hls.levels,_s=xs.indexOf(Ot);Mi.error?this.warn(`MediaCapabilities decodingInfo error: "${Mi.error}" for level ${_s} ${Q(Mi)}`):Mi.supported?Mi.decodingInfoResults.some(Xs=>Xs.smooth===!1||Xs.powerEfficient===!1)&&this.log(`MediaCapabilities decodingInfo for level ${_s} not smooth or powerEfficient: ${Q(Mi)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${_s} ${Q(Mi)}`),_s>-1&&xs.length>1&&(this.log(`Removing unsupported level ${_s}`),this.hls.removeLevel(_s),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))}).catch(Mi=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${Mi}`)})):Ot.supportedResult=O}if((j&&Ot.codecSet!==j||be&&Ot.videoRange!==be||bt&&Z>Ot.frameRate||!bt&&Z>0&&Z<Ot.frameRate||(kt=Ot.supportedResult)!=null&&(kt=kt.decodingInfoResults)!=null&&kt.some(bi=>bi.smooth===!1))&&(!B||at!==Oe)){Vt.push(at);continue}const $t=Ot.details,Jt=(v?$t==null?void 0:$t.partTarget:$t==null?void 0:$t.averagetargetduration)||gt;let ht;bt?ht=o*e:ht=r*e;const ft=gt&&s>=gt*2&&n===0?Ot.averageBitrate:Ot.maxBitrate,yi=this.getTimeToLoadFrag(wt,ht,ft*Jt,$t===void 0);if(ht>=ft&&(at===c||Ot.loadError===0&&Ot.fragmentError===0)&&(yi<=wt||!_(yi)||L&&!this.bitrateTestDelay||yi<l)){const bi=this.forcedAutoLevel;return at!==S&&(bi===-1||bi!==S)&&(Vt.length&&this.trace(`Skipped level(s) ${Vt.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${y[Vt[0]].codecs}" ${y[Vt[0]].videoRange}; not compatible with "${j}" ${be}`),this.info(`switch candidate:${h}->${at} adjustedbw(${Math.round(ht)})-bitrate=${Math.round(ht-ft)} ttfb:${wt.toFixed(1)} avgDuration:${Jt.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${yi.toFixed(1)} firstSelection:${B} codecSet:${Ot.codecSet} videoRange:${Ot.videoRange} hls.loadLevel:${S}`)),B&&(this.firstSelection=at),at}}return-1}set nextAutoLevel(e){const t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}deriveNextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:i}=this.hls;return Math.min(Math.max(e,i),t)}}const zt={search:function(a,e){let t=0,i=a.length-1,s=null,n=null;for(;t<=i;){s=(t+i)/2|0,n=a[s];const r=e(n);if(r>0)t=s+1;else if(r<0)i=s-1;else return n}return null}};function qt(a,e,t){if(e===null||!Array.isArray(a)||!a.length||!_(e))return null;const i=a[0].programDateTime;if(e<(i||0))return null;const s=a[a.length-1].endProgramDateTime;if(e>=(s||0))return null;for(let n=0;n<a.length;++n){const r=a[n];if(Ni(e,t,r))return r}return null}function pi(a,e,t=0,i=0,s=.005){let n=null;if(a){n=e[1+a.sn-e[0].sn]||null;const o=a.endDTS-t;o>0&&o<15e-7&&(t+=15e-7),n&&a.level!==n.level&&n.end<=a.end&&(n=e[2+a.sn-e[0].sn]||null)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!a||a.level===n.level)&&ri(t,i,n)===0||hi(n,a,Math.min(s,i))))return n;const r=zt.search(e,ri.bind(null,t,i));return r&&(r!==a||!n)?r:n}function hi(a,e,t){if(e&&e.start===0&&e.level<a.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return a.start<=i}return!1}function ri(a=0,e=0,t){if(t.start<=a&&t.start+t.duration>a)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=a?1:t.start-i>a&&t.start?-1:0}function Ni(a,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>a}function vi(a,e,t){if(a&&a.startCC<=e&&a.endCC>=e){let i=a.fragments;const{fragmentHint:s}=a;s&&(i=i.concat(s));let n;return zt.search(i,r=>r.cc<e?1:r.cc>e?-1:(n=r,r.end<=t?1:r.start>t?-1:0)),n||null}return null}function Li(a){switch(a.details){case A.FRAG_LOAD_TIMEOUT:case A.KEY_LOAD_TIMEOUT:case A.LEVEL_LOAD_TIMEOUT:case A.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Zi(a){return a.details.startsWith("key")}function Gi(a){return Zi(a)&&!!a.frag&&!a.frag.decryptdata}function ns(a,e){const t=Li(e);return a.default[`${t?"timeout":"error"}Retry`]}function ji(a,e){const t=a.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*a.retryDelayMs,a.maxRetryDelayMs)}function Yi(a){return H(H({},a),{errorRetry:null,timeoutRetry:null})}function Ji(a,e,t,i){if(!a)return!1;const s=i==null?void 0:i.code,n=e<a.maxNumRetry&&(es(s)||!!t);return a.shouldRetry?a.shouldRetry(a,e,t,i,n):n}function es(a){return qi(a)||!!a&&(a<400||a>499)}function qi(a){return a===0&&navigator.onLine===!1}var Ci={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Di={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,MoveAllAlternatesMatchingKey:4,SwitchToSDR:8};class fs extends Ce{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(g.ERROR,this.onError,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(g.ERROR,this.onError,this),e.off(g.ERROR,this.onErrorOut,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===G.MAIN?e.level:this.getVariantIndex()}getVariantIndex(){var e;const t=this.hls,i=t.currentLevel;return(e=t.loadLevelObj)!=null&&e.details||i===-1?t.loadLevel:i}variantHasKey(e,t){if(e){var i;if((i=e.details)!=null&&i.hasKey(t))return!0;const s=e.audioGroups;if(s)return this.hls.allAudioTracks.filter(r=>s.indexOf(r.groupId)>=0).some(r=>{var o;return(o=r.details)==null?void 0:o.hasKey(t)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(e,t){var i;if(t.fatal)return;const s=this.hls,n=t.context;switch(t.details){case A.FRAG_LOAD_ERROR:case A.FRAG_LOAD_TIMEOUT:case A.KEY_LOAD_ERROR:case A.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case A.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction=Oi();return}case A.FRAG_GAP:case A.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ci.SendAlternateToPenaltyBox;return}case A.LEVEL_EMPTY_ERROR:case A.LEVEL_PARSING_ERROR:{var r;const u=t.parent===G.MAIN?t.level:s.loadLevel;t.details===A.LEVEL_EMPTY_ERROR&&((r=t.context)!=null&&(r=r.levelDetails)!=null&&r.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,u):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,u))}return;case A.LEVEL_LOAD_ERROR:case A.LEVEL_LOAD_TIMEOUT:typeof(n==null?void 0:n.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level));return;case A.AUDIO_TRACK_LOAD_ERROR:case A.AUDIO_TRACK_LOAD_TIMEOUT:case A.SUBTITLE_LOAD_ERROR:case A.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){const u=s.loadLevelObj;if(u&&(n.type===te.AUDIO_TRACK&&u.hasAudioGroup(n.groupId)||n.type===te.SUBTITLE_TRACK&&u.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=Ci.SendAlternateToPenaltyBox,t.errorAction.flags=Di.MoveAllAlternatesMatchingHost;return}}return;case A.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:t.errorAction={action:Ci.SendAlternateToPenaltyBox,flags:Di.MoveAllAlternatesMatchingHDCP};return;case A.KEY_SYSTEM_SESSION_UPDATE_FAILED:case A.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case A.KEY_SYSTEM_NO_SESSION:t.errorAction={action:Ci.SendAlternateToPenaltyBox,flags:Di.MoveAllAlternatesMatchingKey};return;case A.BUFFER_ADD_CODEC_ERROR:case A.REMUX_ALLOC_ERROR:case A.BUFFER_APPEND_ERROR:if(!t.errorAction){var o;t.errorAction=this.getLevelSwitchAction(t,(o=t.level)!=null?o:s.loadLevel)}return;case A.INTERNAL_EXCEPTION:case A.BUFFER_APPENDING_ERROR:case A.BUFFER_FULL_ERROR:case A.LEVEL_SWITCH_ERROR:case A.BUFFER_STALLED_ERROR:case A.BUFFER_SEEK_OVER_HOLE:case A.BUFFER_NUDGE_ON_STALL:t.errorAction=Oi();return}t.type===Y.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=Oi())}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,s=ns(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(Ji(s,n,Li(e),e.response))return{action:Ci.RetryRequest,flags:Di.None,retryConfig:s,retryCount:n};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),s=t.levels[i],{fragLoadPolicy:n,keyLoadPolicy:r}=t.config,o=ns(Zi(e)?r:n,e),u=t.levels.reduce((c,h)=>c+h.fragmentError,0);if(s&&(e.details!==A.FRAG_GAP&&s.fragmentError++,!Gi(e)&&Ji(o,u,Li(e),e.response)))return{action:Ci.RetryRequest,flags:Di.None,retryConfig:o,retryCount:u};const l=this.getLevelSwitchAction(e,i);return o&&(l.retryConfig=o,l.retryCount=u),l}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const s=this.hls.levels[t];if(s){var n,r;const l=e.details;s.loadError++,l===A.BUFFER_APPEND_ERROR&&s.fragmentError++;let c=-1;const{levels:h,loadLevel:m,minAutoLevel:v,maxAutoLevel:y}=i;!i.autoLevelEnabled&&!i.config.preserveManualLevelOnError&&(i.loadLevel=-1);const b=(n=e.frag)==null?void 0:n.type,I=(b===G.AUDIO&&l===A.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(l===A.BUFFER_ADD_CODEC_ERROR||l===A.BUFFER_APPEND_ERROR))&&h.some(({audioCodec:be})=>s.audioCodec!==be),L=e.sourceBufferName==="video"&&(l===A.BUFFER_ADD_CODEC_ERROR||l===A.BUFFER_APPEND_ERROR)&&h.some(({codecSet:be,audioCodec:Z})=>s.codecSet!==be&&s.audioCodec===Z),{type:B,groupId:j}=(r=e.context)!=null?r:{};for(let be=h.length;be--;){const Z=(be+m)%h.length;if(Z!==m&&Z>=v&&Z<=y&&h[Z].loadError===0){var o,u;const fe=h[Z];if(l===A.FRAG_GAP&&b===G.MAIN&&e.frag){const he=h[Z].details;if(he){const q=pi(e.frag,he.fragments,e.frag.start);if(q!=null&&q.gap)continue}}else{if(B===te.AUDIO_TRACK&&fe.hasAudioGroup(j)||B===te.SUBTITLE_TRACK&&fe.hasSubtitleGroup(j))continue;if(b===G.AUDIO&&(o=s.audioGroups)!=null&&o.some(he=>fe.hasAudioGroup(he))||b===G.SUBTITLE&&(u=s.subtitleGroups)!=null&&u.some(he=>fe.hasSubtitleGroup(he))||I&&s.audioCodec===fe.audioCodec||L&&s.codecSet===fe.codecSet||!I&&s.codecSet!==fe.codecSet)continue}c=Z;break}}if(c>-1&&i.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:Ci.SendAlternateToPenaltyBox,flags:Di.None,nextAutoLevel:c}}return{action:Ci.SendAlternateToPenaltyBox,flags:Di.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ci.DoNothing:break;case Ci.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==A.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break;case Ci.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:s}=i,n=i.nextAutoLevel;switch(s){case Di.None:this.switchLevel(e,n);break;case Di.MoveAllAlternatesMatchingHDCP:{const u=this.getVariantLevelIndex(e.frag),l=t.levels[u],c=l==null?void 0:l.attrs["HDCP-LEVEL"];if(i.hdcpLevel=c,c==="NONE")this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(c){t.maxHdcpLevel=dt[dt.indexOf(c)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}}case Di.MoveAllAlternatesMatchingKey:{const u=e.decryptdata;if(u){const l=this.hls.levels,c=l.length;for(let m=c;m--;)if(this.variantHasKey(l[m],u)){var r,o;this.log(`Banned key found in level ${m} (${l[m].bitrate}bps) or audio group "${(r=l[m].audioGroups)==null?void 0:r.join(",")}" (${(o=e.frag)==null?void 0:o.type} fragment) ${ne(u.keyId||[])}`),l[m].fragmentError++,l[m].loadError++,this.log(`Removing level ${m} with key error (${e.error})`),this.hls.removeLevel(m)}const h=e.frag;if(this.hls.levels.length<c)i.resolved=!0;else if(h&&h.type!==G.MAIN){const m=h.decryptdata;m&&!u.matches(m)&&(i.resolved=!0)}}break}}i.resolved||this.switchLevel(e,n)}switchLevel(e,t){if(t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===A.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&e.sourceBufferName!=="audiovideo")){const i=p(e.mimeType),s=this.hls.levels;for(let n=s.length;n--;)s[n][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${n} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(n))}}}function Oi(a){const e={action:Ci.DoNothing,flags:Di.None};return a&&(e.resolved=!0),e}var xi={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class ks{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e&&(e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.BUFFER_APPENDED,this.onBufferAppended,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.BUFFER_APPENDED,this.onBufferAppended,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let s=i.length;s--;){const n=i[s];if(!n)break;if(n.start<=e&&e<=n.end&&n.loaded)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){return this.getFragAtPos(e,t,!0)}getFragAtPos(e,t,i){const{fragments:s}=this,n=Object.keys(s);for(let r=n.length;r--;){const o=s[n[r]];if((o==null?void 0:o.body.type)===t&&(!i||o.buffered)){const u=o.body;if(u.start<=e&&e<=u.end)return u}}return null}detectEvictedFragments(e,t,i,s,n){this.timeRanges&&(this.timeRanges[e]=t);const r=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(o=>{const u=this.fragments[o];if(!u||r>=u.body.sn)return;if(!u.buffered&&(!u.loaded||n)){u.body.type===i&&this.removeFragment(u.body);return}const l=u.range[e];if(l){if(l.time.length===0){this.removeFragment(u.body);return}l.time.some(c=>{const h=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return h&&this.removeFragment(u.body),h})}})}detectPartialFragments(e){const t=this.timeRanges;if(!t||e.frag.sn==="initSegment")return;const i=e.frag,s=ts(i),n=this.fragments[s];if(!n||n.buffered&&i.gap)return;const r=!i.relurl;Object.keys(t).forEach(o=>{const u=i.elementaryStreams[o];if(!u)return;const l=t[o],c=r||u.partial===!0;n.range[o]=this.getBufferedTimes(i,e.part,c,l)}),n.loaded=null,Object.keys(n.range).length?(this.bufferedEnd(n,i),ps(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body)}bufferedEnd(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=Is(i,s=>s.fragment.sn>=e))}fragBuffered(e,t){const i=ts(e);let s=this.fragments[i];!s&&t&&(s=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,this.bufferedEnd(s,e))}getBufferedTimes(e,t,i,s){const n={time:[],partial:i},r=e.start,o=e.end,u=e.minEndPTS||o,l=e.maxStartPTS||r;for(let c=0;c<s.length;c++){const h=s.start(c)-this.bufferPadding,m=s.end(c)+this.bufferPadding;if(l>=h&&u<=m){n.time.push({startPTS:Math.max(r,s.start(c)),endPTS:Math.min(o,s.end(c))});break}else if(r<m&&o>h){const v=Math.max(r,s.start(c)),y=Math.min(o,s.end(c));y>v&&(n.partial=!0,n.time.push({startPTS:v,endPTS:y}))}else if(o<=h)break}return n}getPartialFragment(e){let t=null,i,s,n,r=0;const{bufferPadding:o,fragments:u}=this;return Object.keys(u).forEach(l=>{const c=u[l];c&&ps(c)&&(s=c.body.start-o,n=c.body.end+o,e>=s&&e<=n&&(i=Math.min(e-s,n-e),r<=i&&(t=c.body,r=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||ps(t))}getState(e){const t=ts(e),i=this.fragments[t];return i?i.buffered?ps(i)?xi.PARTIAL:xi.OK:xi.APPENDING:xi.NOT_LOADED}isTimeBuffered(e,t,i){let s,n;for(let r=0;r<i.length;r++){if(s=i.start(r)-this.bufferPadding,n=i.end(r)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(e,t){if(t.frag.sn==="initSegment"||t.frag.bitrateTest)return;const i=t.frag,s=t.part?null:t,n=ts(i);this.fragments[n]={body:i,appendedPTS:null,loaded:s,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:s,timeRanges:n,type:r}=t;if(i.sn==="initSegment")return;const o=i.type;if(s){let l=this.activePartLists[o];l||(this.activePartLists[o]=l=[]),l.push(s)}this.timeRanges=n;const u=n[r];this.detectEvictedFragments(r,u,o,s)}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ts(e);return!!this.fragments[t]}hasFragments(e){const{fragments:t}=this,i=Object.keys(t);if(!e)return i.length>0;for(let s=i.length;s--;){const n=t[i[s]];if((n==null?void 0:n.body.type)===e)return!0}return!1}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(r=>{const o=this.fragments[r];if(!o)return;const u=o.body;u.type!==i||s&&!u.gap||u.start<t&&u.end>e&&(o.buffered||n)&&this.removeFragment(u)})}removeFragment(e){const t=ts(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const s=e.sn;this.activePartLists[e.type]=Is(i,n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const t=(e=this.hls)==null||(e=e.latestLevelDetails)==null?void 0:e.partList;t&&t.forEach(i=>i.clearElementaryStreamInfo())}}function ps(a){var e,t,i;return a.buffered&&!!(a.body.gap||(e=a.range.video)!=null&&e.partial||(t=a.range.audio)!=null&&t.partial||(i=a.range.audiovideo)!=null&&i.partial)}function ts(a){return`${a.type}_${a.level}_${a.sn}`}function Is(a,e){return a.filter(t=>{const i=e(t);return i||t.clearElementaryStreamInfo(),i})}var Hi={cbc:0,ctr:1};class us{constructor(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}decrypt(e,t){switch(this.aesMode){case Hi.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Hi.ctr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}function Fs(a){const e=a.byteLength,t=e&&new DataView(a.buffer).getUint8(e-1);return t?a.slice(0,e-t):a}class vs{constructor(){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()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=t.getUint32(s*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,s=i[0],n=i[1],r=i[2],o=i[3],u=this.invSubMix,l=u[0],c=u[1],h=u[2],m=u[3],v=new Uint32Array(256);let y=0,b=0,S=0;for(S=0;S<256;S++)S<128?v[S]=S<<1:v[S]=S<<1^283;for(S=0;S<256;S++){let I=b^b<<1^b<<2^b<<3^b<<4;I=I>>>8^I&255^99,e[y]=I,t[I]=y;const R=v[y],L=v[R],B=v[L];let j=v[I]*257^I*16843008;s[y]=j<<24|j>>>8,n[y]=j<<16|j>>>16,r[y]=j<<8|j>>>24,o[y]=j,j=B*16843009^L*65537^R*257^y*16843008,l[I]=j<<24|j>>>8,c[I]=j<<16|j>>>16,h[I]=j<<8|j>>>24,m[I]=j,y?(y=R^v[v[v[B^R]]],b^=v[v[b]]):y=b=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,s=0;for(;s<t.length&&i;)i=t[s]===this.key[s],s++;if(i)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const r=this.ksRows=(n+6+1)*4;let o,u;const l=this.keySchedule=new Uint32Array(r),c=this.invKeySchedule=new Uint32Array(r),h=this.sBox,m=this.rcon,v=this.invSubMix,y=v[0],b=v[1],S=v[2],I=v[3];let R,L;for(o=0;o<r;o++){if(o<n){R=l[o]=t[o];continue}L=R,o%n===0?(L=L<<8|L>>>24,L=h[L>>>24]<<24|h[L>>>16&255]<<16|h[L>>>8&255]<<8|h[L&255],L^=m[o/n|0]<<24):n>6&&o%n===4&&(L=h[L>>>24]<<24|h[L>>>16&255]<<16|h[L>>>8&255]<<8|h[L&255]),l[o]=R=(l[o-n]^L)>>>0}for(u=0;u<r;u++)o=r-u,u&3?L=l[o]:L=l[o-4],u<4||o<=4?c[u]=L:c[u]=y[h[L>>>24]]^b[h[L>>>16&255]]^S[h[L>>>8&255]]^I[h[L&255]],c[u]=c[u]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const s=this.keySize+6,n=this.invKeySchedule,r=this.invSBox,o=this.invSubMix,u=o[0],l=o[1],c=o[2],h=o[3],m=this.uint8ArrayToUint32Array_(i);let v=m[0],y=m[1],b=m[2],S=m[3];const I=new Int32Array(e),R=new Int32Array(I.length);let L,B,j,be,Z,fe,he,q,Oe,gt,wt,Vt,kt,at;const Ot=this.networkToHostOrderSwap;for(;t<I.length;){for(Oe=Ot(I[t]),gt=Ot(I[t+1]),wt=Ot(I[t+2]),Vt=Ot(I[t+3]),Z=Oe^n[0],fe=Vt^n[1],he=wt^n[2],q=gt^n[3],kt=4,at=1;at<s;at++)L=u[Z>>>24]^l[fe>>16&255]^c[he>>8&255]^h[q&255]^n[kt],B=u[fe>>>24]^l[he>>16&255]^c[q>>8&255]^h[Z&255]^n[kt+1],j=u[he>>>24]^l[q>>16&255]^c[Z>>8&255]^h[fe&255]^n[kt+2],be=u[q>>>24]^l[Z>>16&255]^c[fe>>8&255]^h[he&255]^n[kt+3],Z=L,fe=B,he=j,q=be,kt=kt+4;L=r[Z>>>24]<<24^r[fe>>16&255]<<16^r[he>>8&255]<<8^r[q&255]^n[kt],B=r[fe>>>24]<<24^r[he>>16&255]<<16^r[q>>8&255]<<8^r[Z&255]^n[kt+1],j=r[he>>>24]<<24^r[q>>16&255]<<16^r[Z>>8&255]<<8^r[fe&255]^n[kt+2],be=r[q>>>24]<<24^r[Z>>16&255]<<16^r[fe>>8&255]<<8^r[he&255]^n[kt+3],R[t]=Ot(L^v),R[t+1]=Ot(be^y),R[t+2]=Ot(j^b),R[t+3]=Ot(B^S),v=Oe,y=gt,b=wt,S=Vt,t=t+4}return R.buffer}}class ys{constructor(e,t,i){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=i}expandKey(){const e=Qi(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function Qi(a){switch(a){case Hi.cbc:return"AES-CBC";case Hi.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${a}`)}}const rs=16;class cs{constructor(e,{removePKCS7Padding:t=!0}={}){if(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=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(i){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Fs(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i,s){return this.useSoftware?new Promise((n,r)=>{const o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,s);const u=this.flush();u?n(u.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,s)}softwareDecrypt(e,t,i,s){const{currentIV:n,currentResult:r,remainderData:o}=this;if(s!==Hi.cbc||t.byteLength!==16)return se.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=ut(o,e),this.remainderData=null);const u=this.getValidChunk(e);if(!u.length)return null;n&&(i=n);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new vs),l.expandKey(t);const c=r;return this.currentResult=l.decrypt(u.buffer,0,i),this.currentIV=u.slice(-16).buffer,c||null}webCryptoDecrypt(e,t,i,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,s));this.key=t,this.fastAesKey=new ys(this.subtle,t,s)}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new us(this.subtle,new Uint8Array(i),s).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(se.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,i,s)))}onWebCryptoError(e,t,i,s){const n=this.enableSoftwareAES;if(n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,s);const r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(n?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%rs;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(se.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Ps=Math.pow(2,17);class as{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new hs({type:Y.NETWORK_ERROR,details:A.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,n=s.fLoader,r=s.loader;return new Promise((o,u)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(y=>y[0]==="GAP")){u(Rs(e));return}else e.gap=!1;const l=this.loader=n?new n(s):new r(s),c=ds(e);e.loader=l;const h=Yi(s.fragLoadPolicy.default),m={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Ps};e.stats=l.stats;const v={onSuccess:(y,b,S,I)=>{this.resetLoader(e,l);let R=y.data;S.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(R.slice(0,16)),R=R.slice(16)),o({frag:e,part:null,payload:R,networkDetails:I})},onError:(y,b,S,I)=>{this.resetLoader(e,l),u(new hs({type:Y.NETWORK_ERROR,details:A.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:H({url:i,data:void 0},y),error:new Error(`HTTP Error ${y.code} ${y.text}`),networkDetails:S,stats:I}))},onAbort:(y,b,S)=>{this.resetLoader(e,l),u(new hs({type:Y.NETWORK_ERROR,details:A.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:S,stats:y}))},onTimeout:(y,b,S)=>{this.resetLoader(e,l),u(new hs({type:Y.NETWORK_ERROR,details:A.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${m.timeout}ms`),networkDetails:S,stats:y}))}};t&&(v.onProgress=(y,b,S,I)=>t({frag:e,part:null,payload:S,networkDetails:I})),l.load(c,m,v)})}loadPart(e,t,i){this.abort();const s=this.config,n=s.fLoader,r=s.loader;return new Promise((o,u)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){u(Rs(e,t));return}const l=this.loader=n?new n(s):new r(s),c=ds(e,t);e.loader=l;const h=Yi(s.fragLoadPolicy.default),m={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ps};t.stats=l.stats,l.load(c,m,{onSuccess:(v,y,b,S)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const I={frag:e,part:t,payload:v.data,networkDetails:S};i(I),o(I)},onError:(v,y,b,S)=>{this.resetLoader(e,l),u(new hs({type:Y.NETWORK_ERROR,details:A.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:H({url:c.url,data:void 0},v),error:new Error(`HTTP Error ${v.code} ${v.text}`),networkDetails:b,stats:S}))},onAbort:(v,y,b)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),u(new hs({type:Y.NETWORK_ERROR,details:A.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:b,stats:v}))},onTimeout:(v,y,b)=>{this.resetLoader(e,l),u(new hs({type:Y.NETWORK_ERROR,details:A.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${m.timeout}ms`),networkDetails:b,stats:v}))}})})}updateStatsFromPart(e,t){const i=e.stats,s=t.stats,n=s.total;if(i.loaded+=s.loaded,n){const u=Math.round(e.duration/t.duration),l=Math.min(Math.round(i.loaded/n),u),h=(u-l)*Math.round(i.loaded/l);i.total=i.loaded+h}else i.total=Math.max(i.loaded,i.total);const r=i.loading,o=s.loading;r.start?r.first+=o.first-o.start:(r.start=o.start,r.first=o.first),r.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function ds(a,e=null){const t=e||a,i={frag:a,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(_(s)&&_(n)){var r;let o=s,u=n;if(a.sn==="initSegment"&&Bs((r=a.decryptdata)==null?void 0:r.method)){const l=n-s;l%16&&(u=n+(16-l%16)),s!==0&&(i.resetIV=!0,o=s-16)}i.rangeStart=o,i.rangeEnd=u}return i}function Rs(a,e){const t=new Error(`GAP ${a.gap?"tag":"attribute"} found`),i={type:Y.MEDIA_ERROR,details:A.FRAG_GAP,fatal:!1,frag:a,error:t,networkDetails:null};return e&&(i.part=e),(e||a).stats.aborted=!0,new hs(i)}function Bs(a){return a==="AES-128"||a==="AES-256"}class hs extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class js extends Ce{constructor(e,t){super(e,t),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Ns{constructor(e,t,i,s=0,n=-1,r=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Ls(),this.buffering={audio:Ls(),video:Ls(),audiovideo:Ls()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=n,this.partial=r}}function Ls(){return{start:0,executeStart:0,executeEnd:0,end:0}}const Qs={length:0,start:()=>0,end:()=>0};class Yt{static isBuffered(e,t){if(e){const i=Yt.getBuffered(e);for(let s=i.length;s--;)if(t>=i.start(s)&&t<=i.end(s))return!0}return!1}static bufferedRanges(e){if(e){const t=Yt.getBuffered(e);return Yt.timeRangesToArray(t)}return[]}static timeRangesToArray(e){const t=[];for(let i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}static bufferInfo(e,t,i){if(e){const s=Yt.bufferedRanges(e);if(s.length)return Yt.bufferedInfo(s,t,i)}return{len:0,start:t,end:t,bufferedIndex:-1}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((c,h)=>c.start-h.start||h.end-c.end);let s=-1,n=[];if(i)for(let c=0;c<e.length;c++){t>=e[c].start&&t<=e[c].end&&(s=c);const h=n.length;if(h){const m=n[h-1].end;e[c].start-m<i?e[c].end>m&&(n[h-1].end=e[c].end):n.push(e[c])}else n.push(e[c])}else n=e;let r=0,o,u=t,l=t;for(let c=0;c<n.length;c++){const h=n[c].start,m=n[c].end;if(s===-1&&t>=h&&t<=m&&(s=c),t+i>=h&&t<m)u=h,l=m,r=l-t;else if(t+i<h){o=h;break}}return{len:r,start:u||0,end:l||0,nextStart:o,buffered:e,bufferedIndex:s}}static getBuffered(e){try{return e.buffered||Qs}catch(t){return se.log("failed to get media.buffered",t),Qs}}}const zs=/\{\$([a-zA-Z0-9-_]+)\}/g;function Es(a){return zs.test(a)}function Js(a,e){if(a.variableList!==null||a.hasVariableRefs){const t=a.variableList;return e.replace(zs,i=>{const s=i.substring(2,i.length-1),n=t==null?void 0:t[s];return n===void 0?(a.playlistParsingError||(a.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):n})}return e}function on(a,e,t){let i=a.variableList;i||(a.variableList=i={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{const r=new self.URL(t).searchParams;if(r.has(s))n=r.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(r){a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${r.message}`))}}else s=e.NAME,n=e.VALUE;s in i?a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=n||""}function en(a,e,t){const i=e.IMPORT;if(t&&i in t){let s=a.variableList;s||(a.variableList=s={}),s[i]=t[i]}else a.playlistParsingError||(a.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const ln=/^(\d+)x(\d+)$/,Ws=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Fi{constructor(e,t){typeof e=="string"&&(e=Fi.parseAttrList(e,t)),Ie(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)i[s]=parseInt(t.slice(s*2,s*2+2),16);return i}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}enumeratedStringList(e,t){const i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((s,n)=>(s[n.toLowerCase()]=!0,s),t)}bool(e){return this[e]==="YES"}decimalResolution(e){const t=ln.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e,t){let i;const s={},n='"';for(Ws.lastIndex=0;(i=Ws.exec(e))!==null;){const r=i[1].trim();let o=i[2];const u=o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1;let l=!1;if(u)o=o.slice(1,-1);else switch(r){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":l=!0}if(t&&(u||l))o=Js(t,o);else if(!l&&!u)switch(r){case"CLOSED-CAPTIONS":if(o==="NONE")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":se.warn(`${e}: attribute ${r} is missing quotes`)}s[r]=o}return s}}const os="com.apple.hls.interstitial";function Cs(a){return a!=="ID"&&a!=="CLASS"&&a!=="CUE"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function tn(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"||a==="SCTE35-CMD"}class is{constructor(e,t,i=0){var s;if(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=(t==null?void 0:t.tagAnchor)||null,this.tagOrder=(s=t==null?void 0:t.tagOrder)!=null?s:i,t){const n=t.attr;for(const r in n)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==n[r]){se.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=Ie(new Fi({}),n,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const n=(t==null?void 0:t.endDate)||new Date(this.attr["END-DATE"]);_(n.getTime())&&(this._endDate=n)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const e=this._cue;return e===void 0?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}get startTime(){const{tagAnchor:e}=this;return e===null||e.programDateTime===null?(se.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const e=this._endDate||this._dateAtEnd;if(e)return e;const t=this.duration;return t!==null?this._dateAtEnd=new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(_(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return this.class===os}get isValid(){return!!this.id&&!this._badValueForSameId&&_(this.startDate.getTime())&&(this.duration===null||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)}}const Wi=10;class ls{constructor(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.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=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1}hasKey(e){return this.encryptedFragments.some(t=>{let i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}get hasProgramDateTime(){return this.fragments.length?_(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Wi}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const e=this.partList;if(e){const t=this.lastPartIndex;if(t!==-1){for(let i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}function ms(a,e){return a.length===e.length?!a.some((t,i)=>t!==e[i]):!1}function $s(a,e){return!a&&!e?!0:!a||!e?!1:ms(a,e)}function Ds(a){return a==="AES-128"||a==="AES-256"||a==="AES-256-CTR"}function un(a){switch(a){case"AES-128":case"AES-256":return Hi.cbc;case"AES-256-CTR":return Hi.ctr;default:throw new Error(`invalid full segment method ${a}`)}}function pn(a){return Uint8Array.from(atob(a),e=>e.charCodeAt(0))}function sn(a){return Uint8Array.from(unescape(encodeURIComponent(a)),e=>e.charCodeAt(0))}function Ln(a){const e=sn(a).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function At(a){const e=function(i,s,n){const r=i[s];i[s]=i[n],i[n]=r};e(a,0,3),e(a,1,2),e(a,4,5),e(a,6,7)}function Wt(a){const e=a.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const n=s[0]==="base64",r=s[1];n?(i.splice(-1,1),t=pn(r)):t=Ln(r)}}return t}const Bi=typeof self!="undefined"?self:void 0;var ai={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},fi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Zs(a){switch(a){case fi.FAIRPLAY:return ai.FAIRPLAY;case fi.PLAYREADY:return ai.PLAYREADY;case fi.WIDEVINE:return ai.WIDEVINE;case fi.CLEARKEY:return ai.CLEARKEY}}function Ss(a){switch(a){case ai.FAIRPLAY:return fi.FAIRPLAY;case ai.PLAYREADY:return fi.PLAYREADY;case ai.WIDEVINE:return fi.WIDEVINE;case ai.CLEARKEY:return fi.CLEARKEY}}function cn(a){const{drmSystems:e,widevineLicenseUrl:t}=a,i=e?[ai.FAIRPLAY,ai.WIDEVINE,ai.PLAYREADY,ai.CLEARKEY].filter(s=>!!e[s]):[];return!i[ai.WIDEVINE]&&t&&i.push(ai.WIDEVINE),i}const vn=function(a){return Bi!=null&&(a=Bi.navigator)!=null&&a.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function hr(a,e,t,i){let s;switch(a){case ai.FAIRPLAY:s=["cenc","sinf"];break;case ai.WIDEVINE:case ai.PLAYREADY:s=["cenc"];break;case ai.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${a}`)}return Wr(s,e,t,i)}function Wr(a,e,t,i){return[{initDataTypes:a,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs=${n}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs=${n}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function Zr(a){var e;return!!a&&(a.sessionType==="persistent-license"||!!((e=a.sessionTypes)!=null&&e.some(t=>t==="persistent-license")))}function fr(a){const e=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),t=String.fromCharCode.apply(null,Array.from(e)),i=t.substring(t.indexOf("<"),t.length),r=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(r){const o=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(o){const u=pn(o).subarray(0,16);return At(u),u}}return null}let yn={};class Us{static clearKeyUriToKeyIdMap(){yn={}}static setKeyIdForUri(e,t){yn[e]=t}static addKeyIdForUri(e){const t=Object.keys(yn).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),yn[e]=i,i}constructor(e,t,i,s=[1],n=null,r){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=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&!Ds(e),r!=null&&r.startsWith("0x")&&(this.keyId=new Uint8Array(ee(r)))}matches(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&ms(e.keyFormatVersions,this.keyFormatVersions)&&$s(e.iv,this.iv)&&$s(e.keyId,this.keyId)}isSupported(){if(this.method){if(Ds(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case fi.FAIRPLAY:case fi.WIDEVINE:case fi.PLAYREADY:case fi.CLEARKEY:return["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e,t){if(!this.encrypted||!this.uri)return null;if(Ds(this.method)){let n=this.iv;return n||(typeof e!="number"&&(se.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0),n=En(e)),new Us(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){const n=yn[this.uri];if(n&&!ms(this.keyId,n)&&Us.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const i=Wt(this.uri);if(i)switch(this.keyFormat){case fi.WIDEVINE:if(this.pssh=i,!this.keyId){const n=Ai(i.buffer);if(n.length){var s;const r=n[0];this.keyId=(s=r.kids)!=null&&s.length?r.kids[0]:null}}this.keyId||(this.keyId=Fn(t));break;case fi.PLAYREADY:{const n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=li(n,null,i),this.keyId=fr(i);break}default:{let n=i.subarray(0,16);if(n.length!==16){const r=new Uint8Array(16);r.set(n,16-n.length),n=r}this.keyId=n;break}}if(!this.keyId||this.keyId.byteLength!==16){let n;n=Yr(t),n||(n=Fn(t),n||(n=yn[this.uri])),n&&(this.keyId=n,Us.setKeyIdForUri(this.uri,n))}return this}}function Yr(a){const e=a==null?void 0:a[fi.WIDEVINE];return e?e.keyId:null}function Fn(a){const e=a==null?void 0:a[fi.PLAYREADY];if(e){const t=Wt(e.uri);if(t)return fr(t)}return null}function En(a){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=a>>8*(15-t)&255;return e}const Zn=/#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,Yn=/#EXT-X-MEDIA:(.*)/g,Xr=/^#EXT(?:INF|-X-TARGETDURATION):/m,Bn=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),qr=new RegExp([/#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("|"));class Gs{static findGroup(e,t){for(let i=0;i<e.length;i++){const s=e[i];if(s.id===t)return s}}static resolve(e,t){return ve.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Xr.test(e)}static parseMasterPlaylist(e,t){const i=Es(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];if(Zn.lastIndex=0,!e.startsWith("#EXTM3U"))return s.playlistParsingError=new Error("no EXTM3U delimiter"),s;let r;for(;(r=Zn.exec(e))!=null;)if(r[1]){var o;const l=new Fi(r[1],s),c=Js(s,r[2]),h={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:Gs.resolve(c,t)},m=l.decimalResolution("RESOLUTION");m&&(h.width=m.width,h.height=m.height),Xn(l.CODECS,h);const v=l["SUPPLEMENTAL-CODECS"];v&&(h.supplemental={},Xn(v,h.supplemental)),(o=h.unknownCodecs)!=null&&o.length||n.push(h),s.levels.push(h)}else if(r[3]){const l=r[3],c=r[4];switch(l){case"SESSION-DATA":{const h=new Fi(c,s),m=h["DATA-ID"];m&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[m]=h);break}case"SESSION-KEY":{const h=gr(c,t,s);h.encrypted&&h.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(h)):se.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{const h=new Fi(c,s);on(s,h,t)}break}case"CONTENT-STEERING":{const h=new Fi(c,s);s.contentSteering={uri:Gs.resolve(h["SERVER-URI"],t),pathwayId:h["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=pr(c);break}}}const u=n.length>0&&n.length<s.levels.length;return s.levels=u?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,i){let s;const n={},r=i.levels,o={AUDIO:r.map(l=>({id:l.attrs.AUDIO,audioCodec:l.audioCodec})),SUBTITLES:r.map(l=>({id:l.attrs.SUBTITLES,textCodec:l.textCodec})),"CLOSED-CAPTIONS":[]};let u=0;for(Yn.lastIndex=0;(s=Yn.exec(e))!==null;){const l=new Fi(s[1],i),c=l.TYPE;if(c){const h=o[c],m=n[c]||[];n[c]=m;const v=l.LANGUAGE,y=l["ASSOC-LANGUAGE"],b=l.CHANNELS,S=l.CHARACTERISTICS,I=l["INSTREAM-ID"],R={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||v||"",type:c,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:v,url:l.URI?Gs.resolve(l.URI,t):""};if(y&&(R.assocLang=y),b&&(R.channels=b),S&&(R.characteristics=S),I&&(R.instreamId=I),h!=null&&h.length){const L=Gs.findGroup(h,R.groupId)||h[0];bn(R,L,"audioCodec"),bn(R,L,"textCodec")}m.push(R)}}return n}static parseLevelPlaylist(e,t,i,s,n,r){var o;const u={url:t},l=new ls(t),c=l.fragments,h=[];let m=null,v=0,y=0,b=0,S=0,I=0,R=null,L=new Ye(s,u),B,j,be,Z=-1,fe=!1,he=null,q;if(Bn.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Es(e),((o=Bn.exec(e))==null?void 0:o[0])!=="#EXTM3U")return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;(B=Bn.exec(e))!==null;){fe&&(fe=!1,L=new Ye(s,u),L.playlistOffset=b,L.setStart(b),L.sn=v,L.cc=S,I&&(L.bitrate=I),L.level=i,m&&(L.initSegment=m,m.rawProgramDateTime&&(L.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),he&&(L.setByteRange(he),he=null)));const Vt=B[1];if(Vt){L.duration=parseFloat(Vt);const kt=(" "+B[2]).slice(1);L.title=kt||null,L.tagList.push(kt?["INF",Vt,kt]:["INF",Vt])}else if(B[3]){if(_(L.duration)){L.playlistOffset=b,L.setStart(b),be&&yr(L,be,l),L.sn=v,L.level=i,L.cc=S,c.push(L);const kt=(" "+B[3]).slice(1);L.relurl=Js(l,kt),Qn(L,R,h),R=L,b+=L.duration,v++,y=0,fe=!0}}else{if(B=B[0].match(qr),!B){se.warn("No matches on slow regex match for level playlist!");continue}for(j=1;j<B.length&&B[j]===void 0;j++);const kt=(" "+B[j]).slice(1),at=(" "+B[j+1]).slice(1),Ot=B[j+2]?(" "+B[j+2]).slice(1):null;switch(kt){case"BYTERANGE":R?L.setByteRange(at,R):L.setByteRange(at);break;case"PROGRAM-DATE-TIME":L.rawProgramDateTime=at,L.tagList.push(["PROGRAM-DATE-TIME",at]),Z===-1&&(Z=c.length);break;case"PLAYLIST-TYPE":l.type&&Ys(l,kt,B),l.type=at.toUpperCase();break;case"MEDIA-SEQUENCE":l.startSN!==0?Ys(l,kt,B):c.length>0&&Cn(l,kt,B),v=l.startSN=parseInt(at);break;case"SKIP":{l.skippedSegments&&Ys(l,kt,B);const bt=new Fi(at,l),$t=bt.decimalInteger("SKIPPED-SEGMENTS");if(_($t)){l.skippedSegments+=$t;for(let ht=$t;ht--;)c.push(null);v+=$t}const Jt=bt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Jt&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(Jt.split(" ")));break}case"TARGETDURATION":l.targetduration!==0&&Ys(l,kt,B),l.targetduration=Math.max(parseInt(at),1);break;case"VERSION":l.version!==null&&Ys(l,kt,B),l.version=parseInt(at);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||Ys(l,kt,B),l.live=!1;break;case"#":(at||Ot)&&L.tagList.push(Ot?[at,Ot]:[at]);break;case"DISCONTINUITY":S++,L.tagList.push(["DIS"]);break;case"GAP":L.gap=!0,L.tagList.push([kt]);break;case"BITRATE":L.tagList.push([kt,at]),I=parseInt(at)*1e3,_(I)?L.bitrate=I:I=0;break;case"DATERANGE":{const bt=new Fi(at,l),$t=new is(bt,l.dateRanges[bt.ID],l.dateRangeTagCount);l.dateRangeTagCount++,$t.isValid||l.skippedSegments?l.dateRanges[$t.id]=$t:se.warn(`Ignoring invalid DATERANGE tag: "${at}"`),L.tagList.push(["EXT-X-DATERANGE",at]);break}case"DEFINE":{{const bt=new Fi(at,l);"IMPORT"in bt?en(l,bt,r):on(l,bt,t)}break}case"DISCONTINUITY-SEQUENCE":l.startCC!==0?Ys(l,kt,B):c.length>0&&Cn(l,kt,B),l.startCC=S=parseInt(at);break;case"KEY":{const bt=gr(at,t,l);if(bt.isSupported()){if(bt.method==="NONE"){be=void 0;break}be||(be={});const $t=be[bt.keyFormat];$t!=null&&$t.matches(bt)||($t&&(be=Ie({},be)),be[bt.keyFormat]=bt)}else se.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${at}"`);break}case"START":l.startTimeOffset=pr(at);break;case"MAP":{const bt=new Fi(at,l);if(L.duration){const $t=new Ye(s,u);vr($t,bt,i,be),m=$t,L.initSegment=m,m.rawProgramDateTime&&!L.rawProgramDateTime&&(L.rawProgramDateTime=m.rawProgramDateTime)}else{const $t=L.byteRangeEndOffset;if($t){const Jt=L.byteRangeStartOffset;he=`${$t-Jt}@${Jt}`}else he=null;vr(L,bt,i,be),m=L,fe=!0}m.cc=S;break}case"SERVER-CONTROL":{q&&Ys(l,kt,B),q=new Fi(at),l.canBlockReload=q.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=q.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&q.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=q.optionalFloat("PART-HOLD-BACK",0),l.holdBack=q.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{l.partTarget&&Ys(l,kt,B);const bt=new Fi(at);l.partTarget=bt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let bt=l.partList;bt||(bt=l.partList=[]);const $t=y>0?bt[bt.length-1]:void 0,Jt=y++,ht=new Fi(at,l),ft=new ye(ht,L,u,Jt,$t);bt.push(ft),L.duration+=ft.duration;break}case"PRELOAD-HINT":{const bt=new Fi(at,l);l.preloadHint=bt;break}case"RENDITION-REPORT":{const bt=new Fi(at,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(bt);break}default:se.warn(`line parsed but not handled: ${B}`);break}}}R&&!R.relurl?(c.pop(),b-=R.duration,l.partList&&(l.fragmentHint=R)):l.partList&&(Qn(L,R,h),L.cc=S,l.fragmentHint=L,be&&yr(L,be,l)),l.targetduration||(l.playlistParsingError=new Error("Missing Target Duration"));const Oe=c.length,gt=c[0],wt=c[Oe-1];if(b+=l.skippedSegments*l.targetduration,b>0&&Oe&&wt){l.averagetargetduration=b/Oe;const Vt=wt.sn;l.endSN=Vt!=="initSegment"?Vt:0,l.live||(wt.endList=!0),Z>0&&(qn(c,Z),gt&&h.unshift(gt))}return l.fragmentHint&&(b+=l.fragmentHint.duration),l.totalduration=b,h.length&&l.dateRangeTagCount&&gt&&mr(h,l),l.endCC=S,l}}function mr(a,e){let t=a.length;if(!t)if(e.hasProgramDateTime){const o=e.fragments[e.fragments.length-1];a.push(o),t++}else return;const i=a[t-1],s=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let o=n.length;o--;){const u=e.dateRanges[n[o]],l=u.startDate.getTime();u.tagAnchor=i.ref;for(let c=t;c--;){var r;if(((r=a[c])==null?void 0:r.sn)<e.startSN)break;const h=Qr(e,l,a,c,s);if(h!==-1){u.tagAnchor=e.fragments[h].ref;break}}}}function Qr(a,e,t,i,s){const n=t[i];if(n){const o=n.programDateTime;if(e>=o||i===0){var r;const u=(((r=t[i+1])==null?void 0:r.start)||s)-n.start;if(e<=o+u*1e3){const l=t[i].sn-a.startSN;if(l<0)return-1;const c=a.fragments;if(c.length>t.length){const m=(t[i+1]||c[c.length-1]).sn-a.startSN;for(let v=m;v>l;v--){const y=c[v].programDateTime;if(e>=y&&e<y+c[v].duration*1e3)return v}}return l}}}return-1}function gr(a,e,t){var i,s;const n=new Fi(a,t),r=(i=n.METHOD)!=null?i:"",o=n.URI,u=n.hexadecimalInteger("IV"),l=n.KEYFORMATVERSIONS,c=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!u&&se.error(`Invalid IV: ${n.IV}`);const h=o?Gs.resolve(o,e):"",m=(l||"1").split("/").map(Number).filter(Number.isFinite);return new Us(r,h,c,m,u,n.KEYID)}function pr(a){const t=new Fi(a).decimalFloatingPoint("TIME-OFFSET");return _(t)?t:null}function Xn(a,e){let t=(a||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const s=t.filter(n=>wi(n,i));s.length&&(e[`${i}Codec`]=s.map(n=>n.split("/")[0]).join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function bn(a,e,t){const i=e[t];i&&(a[t]=i)}function qn(a,e){let t=a[e];for(let i=e;i--;){const s=a[i];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function Qn(a,e,t){a.rawProgramDateTime?t.push(a):e!=null&&e.programDateTime&&(a.programDateTime=e.endProgramDateTime)}function vr(a,e,t,i){a.relurl=e.URI,e.BYTERANGE&&a.setByteRange(e.BYTERANGE),a.level=t,a.sn="initSegment",i&&(a.levelkeys=i),a.initSegment=null}function yr(a,e,t){a.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&i.push(a)}function Ys(a,e,t){a.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${t[0]})`)}function Cn(a,e,t){a.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function Jn(a,e){const t=e.startPTS;if(_(t)){let i=0,s;e.sn>a.sn?(i=t-a.start,s=a):(i=a.start-t,s=e),s.duration!==i&&s.setDuration(i)}else e.sn>a.sn?a.cc===e.cc&&a.minEndPTS?e.setStart(a.start+(a.minEndPTS-a.start)):e.setStart(a.start+a.duration):e.setStart(Math.max(a.start-e.duration,0))}function Er(a,e,t,i,s,n,r){i-t<=0&&(r.warn("Fragment should have a positive duration",e),i=t+e.duration,n=s+e.duration);let u=t,l=i;const c=e.startPTS,h=e.endPTS;if(_(c)){const I=Math.abs(c-t);a&&I>a.totalduration?r.warn(`media timestamps and playlist times differ by ${I}s for level ${e.level} ${a.url}`):_(e.deltaPTS)?e.deltaPTS=Math.max(I,e.deltaPTS):e.deltaPTS=I,u=Math.max(t,c),t=Math.min(t,c),s=e.startDTS!==void 0?Math.min(s,e.startDTS):s,l=Math.min(i,h),i=Math.max(i,h),n=e.endDTS!==void 0?Math.max(n,e.endDTS):n}const m=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=u,e.startDTS=s,e.endPTS=i,e.minEndPTS=l,e.endDTS=n;const v=e.sn;if(!a||v<a.startSN||v>a.endSN)return 0;let y;const b=v-a.startSN,S=a.fragments;for(S[b]=e,y=b;y>0;y--)Jn(S[y],S[y-1]);for(y=b;y<S.length-1;y++)Jn(S[y],S[y+1]);return a.fragmentHint&&Jn(S[S.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,m}function Jr(a,e,t){if(a===e)return;let i=null;const s=a.fragments;for(let c=s.length-1;c>=0;c--){const h=s[c].initSegment;if(h){i=h;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;let n;ta(a,e,(c,h,m,v)=>{if((!e.startCC||e.skippedSegments)&&h.cc!==c.cc){const y=c.cc-h.cc;for(let b=m;b<v.length;b++)v[b].cc+=y;e.endCC=v[v.length-1].cc}_(c.startPTS)&&_(c.endPTS)&&(h.setStart(h.startPTS=c.startPTS),h.startDTS=c.startDTS,h.maxStartPTS=c.maxStartPTS,h.endPTS=c.endPTS,h.endDTS=c.endDTS,h.minEndPTS=c.minEndPTS,h.setDuration(c.endPTS-c.startPTS),h.duration&&(n=h),e.PTSKnown=e.alignedSliding=!0),c.hasStreams&&(h.elementaryStreams=c.elementaryStreams),h.loader=c.loader,c.hasStats&&(h.stats=c.stats),c.initSegment&&(h.initSegment=c.initSegment,i=c.initSegment)});const r=e.fragments,o=e.fragmentHint?r.concat(e.fragmentHint):r;if(i&&o.forEach(c=>{var h;c&&(!c.initSegment||c.initSegment.relurl===((h=i)==null?void 0:h.relurl))&&(c.initSegment=i)}),e.skippedSegments){if(e.deltaUpdateFailed=r.some(c=>!c),e.deltaUpdateFailed){t.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let c=e.skippedSegments;c--;)r.shift();e.startSN=r[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=_r(a.dateRanges,e,t));const c=a.fragments.filter(h=>h.rawProgramDateTime);if(a.hasProgramDateTime&&!e.hasProgramDateTime)for(let h=1;h<o.length;h++)o[h].programDateTime===null&&Qn(o[h],o[h-1],c);mr(c,e)}e.endCC=r[r.length-1].cc}if(!e.startCC){var u;const c=Ui(a,e.startSN-1);e.startCC=(u=c==null?void 0:c.cc)!=null?u:r[0].cc}ea(a.partList,e.partList,(c,h)=>{h.elementaryStreams=c.elementaryStreams,h.stats=c.stats}),n?Er(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,t):br(a,e),r.length&&(e.totalduration=e.edge-r[0].start),e.driftStartTime=a.driftStartTime,e.driftStart=a.driftStart;const l=e.advancedDateTime;if(e.advanced&&l){const c=e.edge;e.driftStart||(e.driftStartTime=l,e.driftStart=c),e.driftEndTime=l,e.driftEnd=c}else e.driftEndTime=a.driftEndTime,e.driftEnd=a.driftEnd,e.advancedDateTime=a.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=a.requestScheduled)}function _r(a,e,t){const{dateRanges:i,recentlyRemovedDateranges:s}=e,n=Ie({},a);s&&s.forEach(u=>{delete n[u]});const o=Object.keys(n).length;return o?(Object.keys(i).forEach(u=>{const l=n[u],c=new is(i[u].attr,l);c.isValid?(n[u]=c,l||(c.tagOrder+=o)):t.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${Q(i[u].attr)}"`)}),n):i}function ea(a,e,t){if(a&&e){let i=0;for(let s=0,n=a.length;s<=n;s++){const r=a[s],o=e[s+i];r&&o&&r.index===o.index&&r.fragment.sn===o.fragment.sn?t(r,o):i--}}}function ta(a,e,t){const i=e.skippedSegments,s=Math.max(a.startSN,e.startSN)-e.startSN,n=(a.fragmentHint?1:0)+(i?e.endSN:Math.min(a.endSN,e.endSN))-e.startSN,r=e.startSN-a.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=a.fragmentHint?a.fragments.concat(a.fragmentHint):a.fragments;for(let l=s;l<=n;l++){const c=u[r+l];let h=o[l];if(i&&!h&&c&&(h=e.fragments[l]=c),c&&h){t(c,h,l,o);const m=c.relurl,v=h.relurl;if(m&&Nn(m,v)){e.playlistParsingError=Sr(`media sequence mismatch ${h.sn}:`,a,e,c,h);return}else if(c.cc!==h.cc){e.playlistParsingError=Sr(`discontinuity sequence mismatch (${c.cc}!=${h.cc})`,a,e,c,h);return}}}}function Sr(a,e,t,i,s){return new Error(`${a} ${s.url}
Playlist starting @${e.startSN}
${e.m3u8}
Playlist starting @${t.startSN}
${t.m3u8}`)}function br(a,e,t=!0){const i=e.startSN+e.skippedSegments-a.startSN,s=a.fragments,n=i>=0;let r=0;if(n&&i<s.length)r=s[i].start;else if(n&&e.startSN===a.endSN+1)r=a.fragmentEnd;else if(n&&t)r=a.fragmentStart+i*e.levelTargetDuration;else if(!e.skippedSegments&&e.fragmentStart===0)r=a.fragmentStart;else return;er(e,r)}function er(a,e){if(e){const t=a.fragments;for(let i=a.skippedSegments;i<t.length;i++)t[i].addStart(e);a.fragmentHint&&a.fragmentHint.addStart(e)}}function Xi(a,e=1/0){let t=1e3*a.targetduration;if(a.updated){const i=a.fragments;if(i.length&&t*4>e){const n=i[i.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function Ui(a,e,t){if(!a)return null;let i=a.fragments[e-a.startSN];return i||(i=a.fragmentHint,i&&i.sn===e)?i:e<a.startSN&&t&&t.sn===e?t:null}function zi(a,e,t){return a?bs(a.partList,e,t):null}function bs(a,e,t){if(a)for(let i=a.length;i--;){const s=a[i];if(s.index===t&&s.fragment.sn===e)return s}return null}function Ts(a){a.forEach((e,t)=>{var i;(i=e.details)==null||i.fragments.forEach(s=>{s.level=t,s.initSegment&&(s.initSegment.level=t)})})}function Nn(a,e){return a!==e&&e?$n(a)!==$n(e):!1}function $n(a){return a.replace(/\?[^?]*$/,"")}function Dn(a,e){for(let i=0,s=a.length;i<s;i++){var t;if(((t=a[i])==null?void 0:t.cc)===e)return a[i]}return null}function Tr(a,e){return!!(a&&e.startCC<a.endCC&&e.endCC>a.startCC)}function tr(a,e){const t=a.start+e;a.startPTS=t,a.setStart(t),a.endPTS=t+a.duration}function Tn(a,e){const t=e.fragments;for(let i=0,s=t.length;i<s;i++)tr(t[i],a);e.fragmentHint&&tr(e.fragmentHint,a),e.alignedSliding=!0}function ir(a,e){a&&(xr(e,a),e.alignedSliding||Ar(e,a),!e.alignedSliding&&!e.skippedSegments&&br(a,e,!1))}function xr(a,e){if(!Tr(e,a))return;const t=Math.min(e.endCC,a.endCC),i=Dn(e.fragments,t),s=Dn(a.fragments,t);if(!i||!s)return;se.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const n=i.start-s.start;Tn(n,a)}function Ar(a,e){if(!a.hasProgramDateTime||!e.hasProgramDateTime)return;const t=a.fragments,i=e.fragments;if(!t.length||!i.length)return;let s,n;const r=Math.min(e.endCC,a.endCC);e.startCC<r&&a.startCC<r&&(s=Dn(i,r),n=Dn(t,r)),(!s||!n)&&(s=i[Math.floor(i.length/2)],n=Dn(t,s.cc)||t[Math.floor(t.length/2)]);const o=s.programDateTime,u=n.programDateTime;if(!o||!u)return;const l=(u-o)/1e3-(n.start-s.start);Tn(l,a)}function ws(a,e,t){Os(a,e,t),a.addEventListener(e,t)}function Os(a,e,t){a.removeEventListener(e,t)}const Tl={toString:function(a){let e="";const t=a.length;for(let i=0;i<t;i++)e+=`[${a.start(i).toFixed(3)}-${a.end(i).toFixed(3)}]`;return e}},De={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class ia extends js{constructor(e,t,i,s,n){super(s,e.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=De.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:r,fragCurrent:o,media:u,mediaBuffer:l,state:c}=this,h=u?u.currentTime:0,m=Yt.bufferInfo(l||u,h,r.maxBufferHole),v=!m.len;if(this.log(`Media seeking to ${_(h)?h.toFixed(3):h}, state: ${c}, ${v?"out of":"in"} buffer`),this.state===De.ENDED)this.resetLoadingState();else if(o){const y=r.maxFragLookUpTolerance,b=o.start-y,S=o.start+o.duration+y;if(v||S<m.start||b>m.end){const I=h>S;(h<b||I)&&(I&&o.loader&&(this.log(`Cancelling fragment load for seek (sn: ${o.sn})`),o.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(u){this.fragmentTracker.removeFragmentsInRange(h,1/0,this.playlistType,!0);const y=this.lastCurrentTime;if(h>y&&(this.lastCurrentTime=h),!this.loadingParts){const b=Math.max(m.end,h),S=this.shouldLoadParts(this.getLevelDetails(),b);S&&(this.log(`LL-Part loading ON after seeking to ${h.toFixed(2)} with buffer @${b.toFixed(2)}`),this.loadingParts=S)}}this.hls.hasEnoughToStart||(this.log(`Setting ${v?"startPosition":"nextLoadPosition"} to ${h} for seek without enough to start`),this.nextLoadPosition=h,v&&(this.startPosition=h)),v&&this.state===De.IDLE&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=e,this.fragmentLoader=new as(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new cs(e.config)}registerListeners(){const{hls:e}=this;e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===De.STOPPED)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=De.STOPPED}get startPositionValue(){const{nextLoadPosition:e,startPosition:t}=this;return t===-1&&e?e:t}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(e,t){if(t.live||!this.media)return!1;const i=e.end||0,s=this.config.timelineOffset||0;if(i<=s)return!1;const n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=Yt.bufferedInfo(n,e.start,0));const r=e.nextStart;if(r&&r>s&&r<t.edge||this.media.currentTime<e.start)return!1;const u=t.partList;if(u!=null&&u.length){const c=u[u.length-1];return Yt.isBuffered(this.media,c.start+c.duration/2)}const l=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(l)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null)return this.levelLastLoaded.details}get timelineOffset(){const e=this.config.timelineOffset;if(e){var t;return((t=this.getLevelDetails())==null?void 0:t.appliedTimelineOffset)||e}return 0}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.media;ws(i,"seeking",this.onMediaSeeking),ws(i,"ended",this.onMediaEnded);const s=this.config;this.levels&&s.autoStartLoad&&this.state===De.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(e,t){const i=!!t.transferMedia,s=this.media;if(s!==null){if(s.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Os(s,"seeking",this.onMediaSeeking),Os(s,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i){this.resetLoadingState(),this.resetTransmuxer();return}this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(e,t){}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=De.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const s=n=>{const r=n.frag;if(this.fragContextChanged(r)){this.warn(`${r.type} sn: ${r.sn}${n.part?" part: "+n.part.index:""} of ${this.fragInfo(r,!1,n.part)}) was dropped during download.`),this.fragmentTracker.removeFragment(r);return}r.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,i,s).then(n=>{if(!n)return;const r=this.state,o=n.frag;if(this.fragContextChanged(o)){(r===De.FRAG_LOADING||!this.fragCurrent&&r===De.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=De.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(g.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===De.STOPPED||this.state===De.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===xi.APPENDING){const n=e.type,r=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,r?r.len:this.config.maxBufferLength),u=this.backtrackFragment;((u?e.sn-u.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===xi.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const 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)}waitForLive(e){const t=e.details;return(t==null?void 0:t.live)&&t.type!=="EVENT"&&(this.levelLastLoaded!==e||t.expired)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:i};this.hls.trigger(g.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{const s=i==null?void 0:i.frag;if(!s||this.fragContextChanged(s)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{frag:n,payload:r}=i,o=n.decryptdata;if(r&&r.byteLength>0&&o!=null&&o.key&&o.iv&&Ds(o.method)){const u=self.performance.now();return this.decrypter.decrypt(new Uint8Array(r),o.key.buffer,o.iv.buffer,un(o.method)).catch(l=>{throw s.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:n}),l}).then(l=>{const c=self.performance.now();return s.trigger(g.FRAG_DECRYPTED,{frag:n,payload:l,stats:{tstart:u,tdecrypt:c}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===De.STOPPED||this.state===De.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const i=e.frag.stats;this.state!==De.STOPPED&&(this.state=De.IDLE),e.frag.data=new Uint8Array(e.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(e,t){var i,s;const n=e.tracks;if(n&&!t.encrypted&&((i=n.audio)!=null&&i.encrypted||(s=n.video)!=null&&s.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const r=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${r?"attached mediaKeys: "+r.mediaKeys:"detached"})`);return this.warn(o.message),!r||r.mediaKeys?!1:(this.hls.trigger(g.ERROR,{type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){const i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?Tl.toString(Yt.getBuffered(i)):"(detached)"})`),_e(e)){var s;if(e.type!==G.SUBTITLE){const r=e.elementaryStreams;if(!Object.keys(r).some(o=>!!r[o])){this.state=De.IDLE;return}}const n=(s=this.levels)==null?void 0:s[e.level];n!=null&&n.fragmentError&&(this.log(`Resetting level fragment error count of ${n.fragmentError} on frag buffered`),n.fragmentError=0)}this.state=De.IDLE}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:s,partsLoaded:n}=e,r=!n||n.length===0||n.some(u=>!u),o=new Ns(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!r);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,s){var n;this.fragCurrent=e;const r=t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)){if(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=De.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(m=>{if(!this.fragContextChanged(m.frag))return this.hls.trigger(g.KEY_LOADED,m),this.state===De.KEY_LOADING&&(this.state=De.IDLE),m}),this.hls.trigger(g.KEY_LOADING,{frag:e}),this.fragCurrent===null)return this.log("context changed in KEY_LOADING"),Promise.resolve(null)}else e.encrypted||(o=this.keyLoader.loadClear(e,r.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));const u=this.fragPrevious;if(_e(e)&&(!u||e.sn!==u.sn)){const m=this.shouldLoadParts(t.details,e.end);m!==this.loadingParts&&(this.log(`LL-Part loading ${m?"ON":"OFF"} loading sn ${u==null?void 0:u.sn}->${e.sn}`),this.loadingParts=m)}if(i=Math.max(e.start,i||0),this.loadingParts&&_e(e)){const m=r.partList;if(m&&s){i>r.fragmentEnd&&r.fragmentHint&&(e=r.fragmentHint);const v=this.getNextPart(m,e,i);if(v>-1){const y=m[v];e=this.fragCurrent=y.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${y.index} (${v}/${m.length-1}) of ${this.fragInfo(e,!1,y)}) cc: ${e.cc} [${r.startSN}-${r.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=y.start+y.duration,this.state=De.FRAG_LOADING;let b;return o?b=o.then(S=>!S||this.fragContextChanged(S.frag)?null:this.doFragPartsLoad(e,y,t,s)).catch(S=>this.handleFragLoadError(S)):b=this.doFragPartsLoad(e,y,t,s).catch(S=>this.handleFragLoadError(S)),this.hls.trigger(g.FRAG_LOADING,{frag:e,part:y,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):b}else if(!e.url||this.loadedEndOfParts(m,i))return Promise.resolve(null)}}if(_e(e)&&this.loadingParts){var l;this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${(l=r.partList)==null?void 0:l.filter(m=>m.loaded).map(m=>`[${m.start}-${m.end}]`)}`),this.loadingParts=!1}else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+r.startSN+"-"+r.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),_(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=De.FRAG_LOADING;const c=this.config.progressive&&e.type!==G.SUBTITLE;let h;return c&&o?h=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.fragmentLoader.load(e,s)).catch(m=>this.handleFragLoadError(m)):h=Promise.all([this.fragmentLoader.load(e,c?s:void 0),o]).then(([m])=>(!c&&s&&s(m),m)).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(g.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):h}doFragPartsLoad(e,t,i,s){return new Promise((n,r)=>{var o;const u=[],l=(o=i.details)==null?void 0:o.partList,c=h=>{this.fragmentLoader.loadPart(e,h,s).then(m=>{u[h.index]=m;const v=m.part;this.hls.trigger(g.FRAG_LOADED,m);const y=zi(i.details,e.sn,h.index+1)||bs(l,e.sn,h.index+1);if(y)c(y);else return n({frag:e,part:v,partsLoaded:u})}).catch(r)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;t.frag&&t.details===A.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===Y.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(g.ERROR,t)}else this.hls.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==De.PARSING){!this.fragCurrent&&this.state!==De.STOPPED&&this.state!==De.ERROR&&(this.state=De.IDLE);return}const{frag:i,part:s,level:n}=t,r=self.performance.now();i.stats.parsing.end=r,s&&(s.stats.parsing.end=r);const o=this.getLevelDetails(),l=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=l),this.updateLevelTiming(i,s,n,e.partial)}shouldLoadParts(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i;const n=e.partList[0];if(n.fragment.type===G.SUBTITLE)return!1;const r=n.end+(((i=e.fragmentHint)==null?void 0:i.duration)||0);if(t>=r){var s;if((this.hls.hasEnoughToStart?((s=this.media)==null?void 0:s.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}}return!1}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:s,sn:n,part:r}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of ${this.playlistLabel()} ${s}. The current chunk will not be buffered.`),null;const o=t[s],u=o.details,l=r>-1?zi(u,n,r):null,c=l?l.fragment:Ui(u,n,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:l,level:o}):null}bufferFragmentData(e,t,i,s,n){if(this.state!==De.PARSING)return;const{data1:r,data2:o}=e;let u=r;if(o&&(u=ut(r,o)),!u.length)return;const l=this.initPTS[t.cc],c=l?-l.baseTime/l.timescale:void 0,h={type:e.type,frag:t,part:i,chunkMeta:s,offset:c,parent:t.type,data:u};if(this.hls.trigger(g.BUFFER_APPENDING,h),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Yt.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,s=Yt.bufferInfo(t,i,0),n=e.duration,r=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-r,s.end-r),i+r);e.start-o>r&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){var i;const s=this.getLoadPosition();if(!_(s))return null;const r=this.lastCurrentTime>s||(i=this.media)!=null&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,s,t,r)}getFwdBufferInfoAtPos(e,t,i,s){const n=Yt.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){const r=this.fragmentTracker.getBufferedFrag(t,i);if(r&&(n.nextStart<=r.end||r.gap)){const o=Math.max(Math.min(n.nextStart,r.end)-t,s);return Yt.bufferInfo(e,t,o)}}return n}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const i=this.config,s=Math.max(Math.min(e-t,i.maxBufferLength),t),n=Math.max(e-t*3,i.maxMaxBufferLength/2,s);return n>=s?(i.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=G.MAIN){const i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,s=i.length;if(!s)return null;const{config:n}=this,r=i[0].start,o=n.lowLatencyMode&&!!t.partList;let u=null;if(t.live){const h=n.initialLiveManifestSize;if(s<h)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${h})`),null;if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<r){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),u=this.getInitialLiveFragment(t);const m=this.hls.startPosition,v=this.hls.liveSyncPosition,y=u?(m!==-1&&m>=r?m:v)||u.start:e;this.log(`Setting startPosition to ${y} to match start frag at live edge. mainStart: ${m} liveSyncPosition: ${v} frag.start: ${(l=u)==null?void 0:l.start}`),this.startPosition=this.nextLoadPosition=y}}else e<=r&&(u=i[0]);if(!u){const h=this.loadingParts?t.partEnd:t.fragmentEnd;u=this.getFragmentAtPosition(e,h,t)}let c=this.filterReplacedPrimary(u,t);if(!c&&u){const h=u.sn-t.startSN;c=this.filterReplacedPrimary(i[h+1]||null,t)}return this.mapToInitFragWhenRequired(c)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===xi.OK||i===xi.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,s,n){let r=null;if(e.gap&&(r=this.getNextFragment(this.nextLoadPosition,t),r&&!r.gap&&i.nextStart)){const o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s,0);if(o!==null&&i.len+o.len>=n){const u=r.sn;return this.loopSn!==u&&(this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${u}`),this.loopSn=u),null}}return this.loopSn=void 0,r}get primaryPrefetch(){if(ja(this.config)){var e;if((e=this.hls.interstitialsManager)==null||(e=e.playingItem)==null?void 0:e.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(ja(this.config)&&e.type!==G.SUBTITLE){const i=this.hls.interstitialsManager,s=i==null?void 0:i.bufferingItem;if(s){const r=s.event;if(r){if(r.appendInPlace||Math.abs(e.start-s.start)>1||s.start===0)return null}else if(e.end<=s.start&&(t==null?void 0:t.live)===!1||e.start>s.end&&s.nextEvent&&(s.nextEvent.appendInPlace||e.start-s.end>1))return null}const n=i==null?void 0:i.playerQueue;if(n)for(let r=n.length;r--;){const o=n[r].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!e.initSegment.data&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let s=-1,n=!1,r=!0;for(let o=0,u=e.length;o<u;o++){const l=e[o];if(r=r&&!l.independent,s>-1&&i<l.start)break;const c=l.loaded;c?s=-1:(n||(l.independent||r)&&l.fragment===t)&&(l.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${l.start}`),s=o),n=c}return s}loadedEndOfParts(e,t){let i;for(let s=e.length;s--;){if(i=e[s],!i.loaded)return!1;if(t>i.start)return!0}return!1}getInitialLiveFragment(e){const t=e.fragments,i=this.fragPrevious;let s=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=qt(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const n=i.sn+1;if(n>=e.startSN&&n<=e.endSN){const r=t[n-e.startSN];i.cc===r.cc&&(s=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=vi(e,i.cc,i.end),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,i){const{config:s}=this;let{fragPrevious:n}=this,{fragments:r,endSN:o}=i;const{fragmentHint:u}=i,{maxFragLookUpTolerance:l}=s,c=i.partList,h=!!(this.loadingParts&&c!=null&&c.length&&u);h&&!this.bitrateTest&&c[c.length-1].fragment.sn===u.sn&&(r=r.concat(u),o=u.sn);let m;if(e<t){var v;const b=e<this.lastCurrentTime||e>t-l||(v=this.media)!=null&&v.paused||!this.startFragRequested?0:l;m=pi(n,r,e,b)}else m=r[r.length-1];if(m){const y=m.sn-i.startSN,b=this.fragmentTracker.getState(m);if((b===xi.OK||b===xi.PARTIAL&&m.gap)&&(n=m),n&&m.sn===n.sn&&(!h||c[0].fragment.sn>m.sn||!i.live)&&m.level===n.level){const I=r[y+1];m.sn<o&&this.fragmentTracker.getState(I)!==xi.OK?m=I:m=null}}return m}alignPlaylists(e,t,i){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const n=e.fragmentStart,r=!t,o=e.alignedSliding&&_(n);if(r||!o&&!n){ir(i,e);const u=e.fragmentStart;return this.log(`Live playlist sliding: ${u.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${s}`),u}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;i<t&&(i=-1);const s=this.timelineOffset;if(i===-1){const n=this.startTimeOffset!==null,r=n?this.startTimeOffset:e.startTimeOffset;r!==null&&_(r)?(i=t+r,r<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${r} found in ${n?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+s}this.nextLoadPosition=i+s}getLoadPosition(){var e;const{media:t}=this;let i=0;return(e=this.hls)!=null&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}handleFragLoadAborted(e,t){this.transmuxer&&e.type===this.playlistType&&_e(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==De.FRAG_LOADING_WAITING_RETRY)&&(this.state=De.IDLE)}onFragmentOrKeyLoadError(e,t){var i;if(t.chunkMeta&&!t.frag){const I=this.getCurrentContext(t.chunkMeta);I&&(t.frag=I.frag)}const s=t.frag;if(!s||s.type!==e||!this.levels)return;if(this.fragContextChanged(s)){var n;this.warn(`Frag load error must match current frag to retry ${s.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const r=t.details===A.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(s,!0);const o=t.errorAction;if(!o){this.state=De.ERROR;return}const{action:u,flags:l,retryCount:c=0,retryConfig:h}=o,m=!!h,v=m&&u===Ci.RetryRequest,y=m&&!o.resolved&&l===Di.MoveAllAlternatesMatchingHost,b=(i=this.hls.latestLevelDetails)==null?void 0:i.live;if(!v&&y&&_e(s)&&!s.endList&&b&&!Gi(t))this.resetFragmentErrors(e),this.treatAsGap(s),o.resolved=!0;else if((v||y)&&c<h.maxNumRetry){var S;const I=qi((S=t.response)==null?void 0:S.code),R=ji(h,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+R,this.state=De.FRAG_LOADING_WAITING_RETRY,o.resolved=!0,I){this.log("Waiting for connection (offline)"),this.retryDate=1/0,t.reason="offline";return}this.warn(`Fragment ${s.sn} of ${e} ${s.level} errored with ${t.details}, retrying loading ${c+1}/${h.maxNumRetry} in ${R}ms`)}else if(h)if(this.resetFragmentErrors(e),c<h.maxNumRetry)!r&&u!==Ci.RemoveAlternatePermanently&&(o.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${c})`);return}else u===Ci.SendAlternateToPenaltyBox?this.state=De.WAITING_LEVEL:this.state=De.ERROR;this.tickImmediate()}checkRetryDate(){const e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!qi(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=De.IDLE)}reduceLengthAndFlushBuffer(e){if(this.state===De.PARSING||this.state===De.PARSED){const t=e.frag,i=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,i),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,(t==null?void 0:t.duration)||10);const r=!n;return r&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(e){e===G.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==De.STOPPED&&(this.state=De.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const s=Yt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===De.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==De.STOPPED&&(this.state=De.IDLE)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const e=this.levelLastLoaded,t=e?e.details:null;t!=null&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${e.level===-1?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,s){const n=i.details;if(!n){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((u,l)=>{const c=e.elementaryStreams[l];if(c){const h=c.endPTS-c.startPTS;if(h<=0)return this.warn(`Could not parse fragment ${e.sn} ${l} duration reliably (${h})`),u||!1;const m=s?0:Er(n,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS,this);return this.hls.trigger(g.LEVEL_PTS_UPDATED,{details:n,level:i,drift:m,type:l,frag:e,start:c.startPTS,end:c.endPTS}),!0}return u},!1)){var o;const u=((o=this.transmuxer)==null?void 0:o.error)===null;if((i.fragmentError===0||u&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),u){const l=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(l.message),this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=De.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(g.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===G.MAIN?"level":"track"}fragInfo(e,t=!0,i){var s,n;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${((s=t&&!i?e.startPTS:(i||e).start)!=null?s:NaN).toFixed(3)}-${((n=t&&!i?e.endPTS:(i||e).end)!=null?n:NaN).toFixed(3)}]${i&&e.type==="main"?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}treatAsGap(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}resetTransmuxer(){var e;(e=this.transmuxer)==null||e.reset()}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function ja(a){return!!a.interstitialsController&&a.enableInterstitialPlayback!==!1}class za{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=xl(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function xl(a,e){const t=new Uint8Array(e);let i=0;for(let s=0;s<a.length;s++){const n=a[s];t.set(n,i),i+=n.length}return t}var sa={exports:{}},Wa;function Al(){return Wa||(Wa=1,function(a){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(u,l,c){this.fn=u,this.context=l,this.once=c||!1}function n(u,l,c,h,m){if(typeof c!="function")throw new TypeError("The listener must be a function");var v=new s(c,h||u,m),y=t?t+l:l;return u._events[y]?u._events[y].fn?u._events[y]=[u._events[y],v]:u._events[y].push(v):(u._events[y]=v,u._eventsCount++),u}function r(u,l){--u._eventsCount===0?u._events=new i:delete u._events[l]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],c,h;if(this._eventsCount===0)return l;for(h in c=this._events)e.call(c,h)&&l.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(c)):l},o.prototype.listeners=function(l){var c=t?t+l:l,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var m=0,v=h.length,y=new Array(v);m<v;m++)y[m]=h[m].fn;return y},o.prototype.listenerCount=function(l){var c=t?t+l:l,h=this._events[c];return h?h.fn?1:h.length:0},o.prototype.emit=function(l,c,h,m,v,y){var b=t?t+l:l;if(!this._events[b])return!1;var S=this._events[b],I=arguments.length,R,L;if(S.fn){switch(S.once&&this.removeListener(l,S.fn,void 0,!0),I){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,c),!0;case 3:return S.fn.call(S.context,c,h),!0;case 4:return S.fn.call(S.context,c,h,m),!0;case 5:return S.fn.call(S.context,c,h,m,v),!0;case 6:return S.fn.call(S.context,c,h,m,v,y),!0}for(L=1,R=new Array(I-1);L<I;L++)R[L-1]=arguments[L];S.fn.apply(S.context,R)}else{var B=S.length,j;for(L=0;L<B;L++)switch(S[L].once&&this.removeListener(l,S[L].fn,void 0,!0),I){case 1:S[L].fn.call(S[L].context);break;case 2:S[L].fn.call(S[L].context,c);break;case 3:S[L].fn.call(S[L].context,c,h);break;case 4:S[L].fn.call(S[L].context,c,h,m);break;default:if(!R)for(j=1,R=new Array(I-1);j<I;j++)R[j-1]=arguments[j];S[L].fn.apply(S[L].context,R)}}return!0},o.prototype.on=function(l,c,h){return n(this,l,c,h,!1)},o.prototype.once=function(l,c,h){return n(this,l,c,h,!0)},o.prototype.removeListener=function(l,c,h,m){var v=t?t+l:l;if(!this._events[v])return this;if(!c)return r(this,v),this;var y=this._events[v];if(y.fn)y.fn===c&&(!m||y.once)&&(!h||y.context===h)&&r(this,v);else{for(var b=0,S=[],I=y.length;b<I;b++)(y[b].fn!==c||m&&!y[b].once||h&&y[b].context!==h)&&S.push(y[b]);S.length?this._events[v]=S.length===1?S[0]:S:r(this,v)}return this},o.prototype.removeAllListeners=function(l){var c;return l?(c=t?t+l:l,this._events[c]&&r(this,c)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,a.exports=o}(sa)),sa.exports}var Il=Al(),na=ce(Il);const sr="1.6.15",Un={};function Rl(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Ll(){const a=Un[sr];if(a)return a.clientCount++,a;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e),s={worker:new self.Worker(t),objectURL:t,clientCount:1};return Un[sr]=s,s}function Cl(a){const e=Un[a];if(e)return e.clientCount++,e;const t=new self.URL(a,self.location.href).href,s={worker:new self.Worker(t),scriptURL:t,clientCount:1};return Un[a]=s,s}function Dl(a){const e=Un[a||sr];if(e&&e.clientCount--===1){const{worker:i,objectURL:s}=e;delete Un[a||sr],s&&self.URL.revokeObjectURL(s),i.terminate()}}function Za(a,e){return e+10<=a.length&&a[e]===51&&a[e+1]===68&&a[e+2]===73&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function ra(a,e){return e+10<=a.length&&a[e]===73&&a[e+1]===68&&a[e+2]===51&&a[e+3]<255&&a[e+4]<255&&a[e+6]<128&&a[e+7]<128&&a[e+8]<128&&a[e+9]<128}function Ir(a,e){let t=0;return t=(a[e]&127)<<21,t|=(a[e+1]&127)<<14,t|=(a[e+2]&127)<<7,t|=a[e+3]&127,t}function nr(a,e){const t=e;let i=0;for(;ra(a,e);){i+=10;const s=Ir(a,e+6);i+=s,Za(a,e+10)&&(i+=10),e+=i}if(i>0)return a.subarray(t,t+i)}function wl(a,e,t,i){const s=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],n=e[t+2],r=n>>2&15;if(r>12){const v=new Error(`invalid ADTS sampling index:${r}`);a.emit(g.ERROR,g.ERROR,{type:Y.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!0,error:v,reason:v.message});return}const o=(n>>6&3)+1,u=e[t+3]>>6&3|(n&1)<<2,l="mp4a.40."+o,c=s[r];let h=r;(o===5||o===29)&&(h-=3);const m=[o<<3|(h&14)>>1,(h&1)<<7|u<<3];return se.log(`manifest codec:${i}, parsed codec:${l}, channels:${u}, rate:${c} (ADTS object type:${o} sampling index:${r})`),{config:m,samplerate:c,channelCount:u,codec:l,parsedCodec:l,manifestCodec:i}}function Ya(a,e){return a[e]===255&&(a[e+1]&246)===240}function Xa(a,e){return a[e+1]&1?7:9}function aa(a,e){return(a[e+3]&3)<<11|a[e+4]<<3|(a[e+5]&224)>>>5}function kl(a,e){return e+5<a.length}function Rr(a,e){return e+1<a.length&&Ya(a,e)}function Pl(a,e){return kl(a,e)&&Ya(a,e)&&aa(a,e)<=a.length-e}function Ol(a,e){if(Rr(a,e)){const t=Xa(a,e);if(e+t>=a.length)return!1;const i=aa(a,e);if(i<=t)return!1;const s=e+i;return s===a.length||Rr(a,s)}return!1}function qa(a,e,t,i,s){if(!a.samplerate){const n=wl(e,t,i,s);if(!n)return;Ie(a,n)}}function Qa(a){return 1024*9e4/a}function Ml(a,e){const t=Xa(a,e);if(e+t<=a.length){const i=aa(a,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function Ja(a,e,t,i,s){const n=Qa(a.samplerate),r=i+s*n,o=Ml(e,t);let u;if(o){const{frameLength:h,headerLength:m}=o,v=m+h,y=Math.max(0,t+v-e.length);y?(u=new Uint8Array(v-m),u.set(e.subarray(t+m,e.length),0)):u=e.subarray(t+m,t+v);const b={unit:u,pts:r};return y||a.samples.push(b),{sample:b,length:v,missing:y}}const l=e.length-t;return u=new Uint8Array(l),u.set(e.subarray(t,e.length),0),{sample:{unit:u,pts:r},length:l,missing:-1}}function Fl(a,e){return ra(a,e)&&Ir(a,e+6)+10<=a.length-e}function Bl(a){return a instanceof ArrayBuffer?a:a.byteOffset==0&&a.byteLength==a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer}function oa(a,e=0,t=1/0){return Nl(a,e,t,Uint8Array)}function Nl(a,e,t,i){const s=$l(a);let n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);const r=Ul(a)?a.byteOffset:0,o=(r+a.byteLength)/n,u=(r+e)/n,l=Math.floor(Math.max(0,Math.min(u,o))),c=Math.floor(Math.min(l+Math.max(t,0),o));return new i(s,l,c-l)}function $l(a){return a instanceof ArrayBuffer?a:a.buffer}function Ul(a){return a&&a.buffer instanceof ArrayBuffer&&a.byteLength!==void 0&&a.byteOffset!==void 0}function Gl(a){const e={key:a.type,description:"",data:"",mimeType:null,pictureType:null},t=3;if(a.size<2)return;if(a.data[0]!==t){console.log("Ignore frame with unrecognized character encoding");return}const i=a.data.subarray(1).indexOf(0);if(i===-1)return;const s=nt(oa(a.data,1,i)),n=a.data[2+i],r=a.data.subarray(3+i).indexOf(0);if(r===-1)return;const o=nt(oa(a.data,3+i,r));let u;return s==="-->"?u=nt(oa(a.data,4+i+r)):u=Bl(a.data.subarray(4+i+r)),e.mimeType=s,e.pictureType=n,e.description=o,e.data=u,e}function Kl(a){if(a.size<2)return;const e=nt(a.data,!0),t=new Uint8Array(a.data.subarray(e.length+1));return{key:a.type,info:e,data:t.buffer}}function Vl(a){if(a.size<2)return;if(a.type==="TXXX"){let t=1;const i=nt(a.data.subarray(t),!0);t+=i.length+1;const s=nt(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=nt(a.data.subarray(1));return{key:a.type,info:"",data:e}}function Hl(a){if(a.type==="WXXX"){if(a.size<2)return;let t=1;const i=nt(a.data.subarray(t),!0);t+=i.length+1;const s=nt(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=nt(a.data);return{key:a.type,info:"",data:e}}function jl(a){return a.type==="PRIV"?Kl(a):a.type[0]==="W"?Hl(a):a.type==="APIC"?Gl(a):Vl(a)}function zl(a){const e=String.fromCharCode(a[0],a[1],a[2],a[3]),t=Ir(a,4),i=10;return{type:e,size:t,data:a.subarray(i,i+t)}}const Lr=10,Wl=10;function eo(a){let e=0;const t=[];for(;ra(a,e);){const i=Ir(a,e+6);a[e+5]>>6&1&&(e+=Lr),e+=Lr;const s=e+i;for(;e+Wl<s;){const n=zl(a.subarray(e)),r=jl(n);r&&t.push(r),e+=n.size+Lr}Za(a,e)&&(e+=Lr)}return t}function to(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"}function Zl(a){if(a.data.byteLength===8){const e=new Uint8Array(a.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}}function la(a){const e=eo(a);for(let t=0;t<e.length;t++){const i=e[t];if(to(i))return Zl(i)}}let Ks=function(a){return a.audioId3="org.id3",a.dateRange="com.apple.quicktime.HLS",a.emsg="https://aomedia.org/emsg/ID3",a.misbklv="urn:misb:KLV:bin:1910.1",a}({});function dn(a="",e=9e4){return{type:a,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class ua{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=ut(this.cachedData,e),this.cachedData=null);let i=nr(e,0),s=i?i.length:0,n;const r=this._audioTrack,o=this._id3Track,u=i?la(i):void 0,l=e.length;for((this.basePTS===null||this.frameIndex===0&&_(u))&&(this.basePTS=Yl(u,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ks.audioId3,duration:Number.POSITIVE_INFINITY});s<l;){if(this.canParse(e,s)){const c=this.appendFrame(r,e,s);c?(this.frameIndex++,this.lastPTS=c.sample.pts,s+=c.length,n=s):s=l}else Fl(e,s)?(i=nr(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ks.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===l&&n!==l){const c=e.slice(n);this.cachedData?this.cachedData=ut(this.cachedData,c):this.cachedData=c}}return{audioTrack:r,videoTrack:dn(),id3Track:o,textTrack:dn()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:dn(),id3Track:this._id3Track,textTrack:dn()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Yl=(a,e,t)=>{if(_(a))return a*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let Cr=null;const Xl=[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],ql=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ql=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Jl=[0,1,1,4];function io(a,e,t,i,s){if(t+24>e.length)return;const n=so(e,t);if(n&&t+n.frameLength<=e.length){const r=n.samplesPerFrame*9e4/n.sampleRate,o=i+s*r,u={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return a.config=[],a.channelCount=n.channelCount,a.samplerate=n.sampleRate,a.samples.push(u),{sample:u,length:n.frameLength,missing:0}}}function so(a,e){const t=a[e+1]>>3&3,i=a[e+1]>>1&3,s=a[e+2]>>4&15,n=a[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){const r=a[e+2]>>1&1,o=a[e+3]>>6,u=t===3?3-i:i===3?3:4,l=Xl[u*14+s-1]*1e3,h=ql[(t===3?0:t===2?1:2)*3+n],m=o===3?1:2,v=Ql[t][i],y=Jl[i],b=v*8*y,S=Math.floor(v*l/h+r)*y;if(Cr===null){const L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Cr=L?parseInt(L[1]):0}return!!Cr&&Cr<=87&&i===2&&l>=224e3&&o===0&&(a[e+3]=a[e+3]|128),{sampleRate:h,channelCount:m,frameLength:S,samplesPerFrame:b}}}function ca(a,e){return a[e]===255&&(a[e+1]&224)===224&&(a[e+1]&6)!==0}function no(a,e){return e+1<a.length&&ca(a,e)}function eu(a,e){return ca(a,e)&&4<=a.length-e}function ro(a,e){if(e+1<a.length&&ca(a,e)){const i=so(a,e);let s=4;i!=null&&i.frameLength&&(s=i.frameLength);const n=e+s;return n===a.length||no(a,n)}return!1}class tu extends ua{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e,t){if(!e)return!1;const i=nr(e,0);let s=(i==null?void 0:i.length)||0;if(ro(e,s))return!1;for(let n=e.length;s<n;s++)if(Ol(e,s))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Pl(e,t)}appendFrame(e,t,i){qa(e,this.observer,t,i,e.manifestCodec);const s=Ja(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const ao=(a,e)=>{let t=0,i=5;e+=i;const s=new Uint32Array(1),n=new Uint32Array(1),r=new Uint8Array(1);for(;i>0;){r[0]=a[e];const o=Math.min(i,8),u=8-o;n[0]=4278190080>>>24+u<<u,s[0]=(r[0]&n[0])>>u,t=t?t<<o|s[0]:s[0],e+=1,i-=o}return t};class iu extends ua{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,i){const s=oo(e,t,i,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;const t=nr(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&la(t)!==void 0&&ao(e,i)<16}}function oo(a,e,t,i,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],u=e[t+4]&63,c=[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][u*3+n]*2;if(t+c>e.length)return-1;const h=e[t+6]>>5;let m=0;h===2?m+=2:(h&1&&h!==1&&(m+=2),h&4&&(m+=2));const v=(e[t+6]<<8|e[t+7])>>12-m&1,b=[2,1,2,3,3,4,4,5][h]+v,S=e[t+5]>>3,I=e[t+5]&7,R=new Uint8Array([n<<6|S<<1|I>>2,(I&3)<<6|h<<3|v<<2|u>>4,u<<4&224]),L=1536/o*9e4,B=i+s*L,j=e.subarray(t,t+c);return a.config=R,a.channelCount=b,a.samplerate=o,a.samples.push({unit:j,pts:B}),c}class su extends ua{resetInitSegment(e,t,i,s){super.resetInitSegment(e,t,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=nr(e,0);let i=(t==null?void 0:t.length)||0;if(t&&e[i]===11&&e[i+1]===119&&la(t)!==void 0&&ao(e,i)<=16)return!1;for(let s=e.length;i<s;i++)if(ro(e,i))return se.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return eu(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return io(e,t,i,this.basePTS,this.frameIndex)}}const nu=/\/emsg[-/]ID3/i;class ru{constructor(e,t){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=t}resetTimeStamp(){}resetInitSegment(e,t,i,s){const n=this.videoTrack=dn("video",1),r=this.audioTrack=dn("audio",1),o=this.txtTrack=dn("text",1);if(this.id3Track=dn("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const u=z(e);if(u.video){const{id:l,timescale:c,codec:h,supplemental:m}=u.video;n.id=l,n.timescale=o.timescale=c,n.codec=h,n.supplemental=m}if(u.audio){const{id:l,timescale:c,codec:h}=u.audio;r.id=l,r.timescale=c,r.codec=h}o.id=_t.text,n.sampleDuration=0,n.duration=r.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return Me(e)}demux(e,t){this.timeOffset=t;let i=e;const s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ut(this.remainderData,e));const o=et(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;const r=this.extractID3Track(s,t);return n.samples=Et(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:r,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return i.samples=Et(e,t),{videoTrack:t,audioTrack:dn(),id3Track:s,textTrack:dn()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=N(e.samples,["emsg"]);s&&s.forEach(n=>{const r=Ei(n);if(nu.test(r.schemeIdUri)){const o=lo(r,t);let u=r.eventDuration===4294967295?Number.POSITIVE_INFINITY:r.eventDuration/r.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);const l=r.payload;i.samples.push({data:l,len:l.byteLength,dts:o,pts:o,type:Ks.emsg,duration:u})}else if(this.config.enableEmsgKLVMetadata&&r.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const o=lo(r,t);i.samples.push({data:r.payload,len:r.payload.byteLength,dts:o,pts:o,type:Ks.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}function lo(a,e){return _(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale}class au{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new cs(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Hi.cbc)}decryptAacSample(e,t,i){const s=e[t].unit;if(s.length<=16)return;const n=s.subarray(16,s.length-s.length%16),r=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(r).then(o=>{const u=new Uint8Array(o);s.set(u,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)i.set(e.subarray(n,n+16),s);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(i.subarray(s,s+16),n);return e}decryptAvcSample(e,t,i,s,n){const r=pt(n.data),o=this.getAvcEncryptedData(r);this.decryptBuffer(o.buffer).then(u=>{n.data=this.getAvcDecryptedUnit(r,u),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,s)}).catch(s)}decryptAvcSamples(e,t,i,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){s();return}const n=e[t].units;for(;!(i>=n.length);i++){const r=n[i];if(!(r.data.length<=48||r.type!==1&&r.type!==5)&&(this.decryptAvcSample(e,t,i,s,r),!this.decrypter.isSync()))return}}}}class uo{constructor(){this.VideoSample=null}createVideoSample(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}getLastNalUnit(e){var t;let i=this.VideoSample,s;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const n=i.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const i=t.samples,s=i.length;if(s){const n=i[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}}parseNALu(e,t,i){const s=t.byteLength;let n=e.naluState||0;const r=n,o=[];let u=0,l,c,h,m=-1,v=0;for(n===-1&&(m=0,v=this.getNALuType(t,0),n=0,u=1);u<s;){if(l=t[u++],!n){n=l?0:1;continue}if(n===1){n=l?0:2;continue}if(!l)n=3;else if(l===1){if(c=u-n-1,m>=0){const y={data:t.subarray(m,c),type:v};o.push(y)}else{const y=this.getLastNalUnit(e.samples);y&&(r&&u<=4-r&&y.state&&(y.data=y.data.subarray(0,y.data.byteLength-r)),c>0&&(y.data=ut(y.data,t.subarray(0,c)),y.state=0))}u<s?(h=this.getNALuType(t,u),m=u,v=h,n=0):n=-1}else n=0}if(m>=0&&n>=0){const y={data:t.subarray(m,s),type:v,state:n};o.push(y)}if(o.length===0){const y=this.getLastNalUnit(e.samples);y&&(y.data=ut(y.data,t))}return e.naluState=n,o}}class rr{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(i,i+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&se.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class ou extends uo{parsePES(e,t,i,s){const n=this.parseNALu(e,i.data,s);let r=this.VideoSample,o,u=!1;i.data=null,r&&n.length&&!e.audFound&&(this.pushAccessUnit(r,e),r=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.forEach(l=>{var c,h;switch(l.type){case 1:{let b=!1;o=!0;const S=l.data;if(u&&S.length>4){const I=this.readSliceType(S);(I===2||I===4||I===7||I===9)&&(b=!0)}if(b){var m;(m=r)!=null&&m.frame&&!r.key&&(this.pushAccessUnit(r,e),r=this.VideoSample=null)}r||(r=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),r.frame=!0,r.key=b;break}case 5:o=!0,(c=r)!=null&&c.frame&&!r.key&&(this.pushAccessUnit(r,e),r=this.VideoSample=null),r||(r=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),r.key=!0,r.frame=!0;break;case 6:{o=!0,pe(l.data,1,i.pts,t.samples);break}case 7:{var v,y;o=!0,u=!0;const b=l.data,S=this.readSPS(b);if(!e.sps||e.width!==S.width||e.height!==S.height||((v=e.pixelRatio)==null?void 0:v[0])!==S.pixelRatio[0]||((y=e.pixelRatio)==null?void 0:y[1])!==S.pixelRatio[1]){e.width=S.width,e.height=S.height,e.pixelRatio=S.pixelRatio,e.sps=[b];const I=b.subarray(1,4);let R="avc1.";for(let L=0;L<3;L++){let B=I[L].toString(16);B.length<2&&(B="0"+B),R+=B}e.codec=R}break}case 8:o=!0,e.pps=[l.data];break;case 9:o=!0,e.audFound=!0,(h=r)!=null&&h.frame&&(this.pushAccessUnit(r,e),r=null),r||(r=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:o=!0;break;default:o=!1;break}r&&o&&r.units.push(l)}),s&&r&&(this.pushAccessUnit(r,e),this.VideoSample=null)}getNALuType(e,t){return e[t]&31}readSliceType(e){const t=new rr(e);return t.readUByte(),t.readUEG(),t.readUEG()}skipScalingList(e,t){let i=8,s=8,n;for(let r=0;r<e;r++)s!==0&&(n=t.readEG(),s=(i+n+256)%256),i=s===0?i:s}readSPS(e){const t=new rr(e);let i=0,s=0,n=0,r=0,o,u,l;const c=t.readUByte.bind(t),h=t.readBits.bind(t),m=t.readUEG.bind(t),v=t.readBoolean.bind(t),y=t.skipBits.bind(t),b=t.skipEG.bind(t),S=t.skipUEG.bind(t),I=this.skipScalingList.bind(this);c();const R=c();if(h(5),y(3),c(),S(),R===100||R===110||R===122||R===244||R===44||R===83||R===86||R===118||R===128){const fe=m();if(fe===3&&y(1),S(),S(),y(1),v())for(u=fe!==3?8:12,l=0;l<u;l++)v()&&(l<6?I(16,t):I(64,t))}S();const L=m();if(L===0)m();else if(L===1)for(y(1),b(),b(),o=m(),l=0;l<o;l++)b();S(),y(1);const B=m(),j=m(),be=h(1);be===0&&y(1),y(1),v()&&(i=m(),s=m(),n=m(),r=m());let Z=[1,1];if(v()&&v())switch(c()){case 1:Z=[1,1];break;case 2:Z=[12,11];break;case 3:Z=[10,11];break;case 4:Z=[16,11];break;case 5:Z=[40,33];break;case 6:Z=[24,11];break;case 7:Z=[20,11];break;case 8:Z=[32,11];break;case 9:Z=[80,33];break;case 10:Z=[18,11];break;case 11:Z=[15,11];break;case 12:Z=[64,33];break;case 13:Z=[160,99];break;case 14:Z=[4,3];break;case 15:Z=[3,2];break;case 16:Z=[2,1];break;case 255:{Z=[c()<<8|c(),c()<<8|c()];break}}return{width:Math.ceil((B+1)*16-i*2-s*2),height:(2-be)*(j+1)*16-(be?2:4)*(n+r),pixelRatio:Z}}}class lu extends uo{constructor(...e){super(...e),this.initVPS=null}parsePES(e,t,i,s){const n=this.parseNALu(e,i.data,s);let r=this.VideoSample,o,u=!1;i.data=null,r&&n.length&&!e.audFound&&(this.pushAccessUnit(r,e),r=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),n.forEach(l=>{var c,h;switch(l.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:r||(r=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.frame=!0,o=!0;break;case 16:case 17:case 18:case 21:if(o=!0,u){var m;(m=r)!=null&&m.frame&&!r.key&&(this.pushAccessUnit(r,e),r=this.VideoSample=null)}r||(r=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),r.key=!0,r.frame=!0;break;case 19:case 20:o=!0,(c=r)!=null&&c.frame&&!r.key&&(this.pushAccessUnit(r,e),r=this.VideoSample=null),r||(r=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),r.key=!0,r.frame=!0;break;case 39:o=!0,pe(l.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=Ie(e.params,this.readVPS(l.data)),this.initVPS=l.data),e.vps=[l.data];break;case 33:if(o=!0,u=!0,e.vps!==void 0&&e.vps[0]!==this.initVPS&&e.sps!==void 0&&!this.matchSPS(e.sps[0],l.data)&&(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){const v=this.readSPS(l.data);e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.codec=v.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const y in v.params)e.params[y]=v.params[y]}this.pushParameterSet(e.sps,l.data,e.vps),r||(r=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),r.key=!0;break;case 34:if(o=!0,typeof e.params=="object"){if(!e.pps){e.pps=[];const v=this.readPPS(l.data);for(const y in v)e.params[y]=v[y]}this.pushParameterSet(e.pps,l.data,e.vps)}break;case 35:o=!0,e.audFound=!0,(h=r)!=null&&h.frame&&(this.pushAccessUnit(r,e),r=null),r||(r=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:o=!1;break}r&&o&&r.units.push(l)}),s&&r&&(this.pushAccessUnit(r,e),this.VideoSample=null)}pushParameterSet(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}getNALuType(e,t){return(e[t]&126)>>>1}ebsp2rbsp(e){const t=new Uint8Array(e.byteLength);let i=0;for(let s=0;s<e.byteLength;s++)s>=2&&e[s]===3&&e[s-1]===0&&e[s-2]===0||(t[i]=e[s],i++);return new Uint8Array(t.buffer,0,i)}pushAccessUnit(e,t){super.pushAccessUnit(e,t),this.initVPS&&(this.initVPS=null)}readVPS(e){const t=new rr(e);t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6);const i=t.readBits(3),s=t.readBoolean();return{numTemporalLayers:i+1,temporalIdNested:s}}readSPS(e){const t=new rr(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);const i=t.readBits(3);t.readBoolean();const s=t.readBits(2),n=t.readBoolean(),r=t.readBits(5),o=t.readUByte(),u=t.readUByte(),l=t.readUByte(),c=t.readUByte(),h=t.readUByte(),m=t.readUByte(),v=t.readUByte(),y=t.readUByte(),b=t.readUByte(),S=t.readUByte(),I=t.readUByte(),R=[],L=[];for(let $i=0;$i<i;$i++)R.push(t.readBoolean()),L.push(t.readBoolean());if(i>0)for(let $i=i;$i<8;$i++)t.readBits(2);for(let $i=0;$i<i;$i++)R[$i]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),L[$i]&&t.readUByte();t.readUEG();const B=t.readUEG();B==3&&t.skipBits(1);const j=t.readUEG(),be=t.readUEG(),Z=t.readBoolean();let fe=0,he=0,q=0,Oe=0;Z&&(fe+=t.readUEG(),he+=t.readUEG(),q+=t.readUEG(),Oe+=t.readUEG());const gt=t.readUEG(),wt=t.readUEG(),Vt=t.readUEG(),kt=t.readBoolean();for(let $i=kt?0:i;$i<=i;$i++)t.skipUEG(),t.skipUEG(),t.skipUEG();if(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean()&&t.readBoolean())for(let As=0;As<4;As++)for(let qs=0;qs<(As===3?2:6);qs++)if(!t.readBoolean())t.readUEG();else{const an=Math.min(64,1<<4+(As<<1));As>1&&t.readEG();for(let Wn=0;Wn<an;Wn++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const bt=t.readUEG();let $t=0;for(let $i=0;$i<bt;$i++){let As=!1;if($i!==0&&(As=t.readBoolean()),As){$i===bt&&t.readUEG(),t.readBoolean(),t.readUEG();let qs=0;for(let On=0;On<=$t;On++){const an=t.readBoolean();let Wn=!1;an||(Wn=t.readBoolean()),(an||Wn)&&qs++}$t=qs}else{const qs=t.readUEG(),On=t.readUEG();$t=qs+On;for(let an=0;an<qs;an++)t.readUEG(),t.readBoolean();for(let an=0;an<On;an++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const $i=t.readUEG();for(let As=0;As<$i;As++){for(let qs=0;qs<Vt+4;qs++)t.readBits(1);t.readBits(1)}}let ht=0,ft=1,yi=1,Ki=!0,bi=1,Mi=0;t.readBoolean(),t.readBoolean();let xs=!1;if(t.readBoolean()){if(t.readBoolean()){const Mn=t.readUByte(),vl=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],zr=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];Mn>0&&Mn<16?(ft=vl[Mn-1],yi=zr[Mn-1]):Mn===255&&(ft=t.readBits(16),yi=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),xs=t.readBoolean(),xs&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean()&&(bi=t.readBits(32),Mi=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const zr=t.readBoolean(),yl=t.readBoolean();let cr=!1;(zr||yl)&&(cr=t.readBoolean(),cr&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),cr&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let El=0;El<=i;El++){Ki=t.readBoolean();const Kd=Ki||t.readBoolean();let _l=!1;Kd?t.readEG():_l=t.readBoolean();const Sl=_l?1:t.readUEG()+1;if(zr)for(let dr=0;dr<Sl;dr++)t.readUEG(),t.readUEG(),cr&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(yl)for(let dr=0;dr<Sl;dr++)t.readUEG(),t.readUEG(),cr&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),ht=t.readUEG())}let Xs=j,gn=be;if(Z){let $i=1,As=1;B===1?$i=As=2:B==2&&($i=2),Xs=j-$i*he-$i*fe,gn=be-As*Oe-As*q}const Pn=s?["A","B","C"][s]:"",Gd=o<<24|u<<16|l<<8|c;let Va=0;for(let $i=0;$i<32;$i++)Va=(Va|(Gd>>$i&1)<<31-$i)>>>0;let Ha=Va.toString(16);return r===1&&Ha==="2"&&(Ha="6"),{codecString:`hvc1.${Pn}${r}.${Ha}.${n?"H":"L"}${I}.B0`,params:{general_tier_flag:n,general_profile_idc:r,general_profile_space:s,general_profile_compatibility_flags:[o,u,l,c],general_constraint_indicator_flags:[h,m,v,y,b,S],general_level_idc:I,bit_depth:gt+8,bit_depth_luma_minus8:gt,bit_depth_chroma_minus8:wt,min_spatial_segmentation_idc:ht,chroma_format_idc:B,frame_rate:{fixed:Ki,fps:Mi/bi}},width:Xs,height:gn,pixelRatio:[ft,yi]}}readPPS(e){const t=new rr(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);const s=t.readBoolean(),n=t.readBoolean();let r=1;return n&&s?r=0:n?r=3:s&&(r=2),{parallelismType:r}}matchSPS(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}const gs=188;class xn{constructor(e,t,i,s){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=e,this.config=t,this.typeSupported=i,this.logger=s,this.videoParser=null}static probe(e,t){const i=xn.syncOffset(e);return i>0&&t.warn(`MPEG2-TS detected but first sync word found @ offset ${i}`),i!==-1}static syncOffset(e){const t=e.length;let i=Math.min(gs*5,t-gs)+1,s=0;for(;s<i;){let n=!1,r=-1,o=0;for(let u=s;u<t;u+=gs)if(e[u]===71&&(t-u===gs||e[u+gs]===71)){if(o++,r===-1&&(r=u,r!==0&&(i=Math.min(r+gs*99,e.length-gs)+1)),n||(n=da(e,u)===0),n&&o>1&&(r===0&&o>2||u+gs>i))return r}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:_t[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=xn.createTrack("video"),this._videoTrack.duration=s,this._audioTrack=xn.createTrack("audio",s),this._id3Track=xn.createTrack("id3"),this._txtTrack=xn.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,i=!1,s=!1){i||(this.sampleAes=null);let n;const r=this._videoTrack,o=this._audioTrack,u=this._id3Track,l=this._txtTrack;let c=r.pid,h=r.pesData,m=o.pid,v=u.pid,y=o.pesData,b=u.pesData,S=null,I=this.pmtParsed,R=this._pmtId,L=e.length;if(this.remainderData&&(e=ut(this.remainderData,e),L=e.length,this.remainderData=null),L<gs&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:r,id3Track:u,textTrack:l};const B=Math.max(0,xn.syncOffset(e));L-=(L-B)%gs,L<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,L,e.buffer.byteLength-L));let j=0;for(let Z=B;Z<L;Z+=gs)if(e[Z]===71){const fe=!!(e[Z+1]&64),he=da(e,Z),q=(e[Z+3]&48)>>4;let Oe;if(q>1){if(Oe=Z+5+e[Z+4],Oe===Z+gs)continue}else Oe=Z+4;switch(he){case c:fe&&(h&&(n=Gn(h,this.logger))&&(this.readyVideoParser(r.segmentCodec),this.videoParser!==null&&this.videoParser.parsePES(r,l,n,!1)),h={data:[],size:0}),h&&(h.data.push(e.subarray(Oe,Z+gs)),h.size+=Z+gs-Oe);break;case m:if(fe){if(y&&(n=Gn(y,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}y={data:[],size:0}}y&&(y.data.push(e.subarray(Oe,Z+gs)),y.size+=Z+gs-Oe);break;case v:fe&&(b&&(n=Gn(b,this.logger))&&this.parseID3PES(u,n),b={data:[],size:0}),b&&(b.data.push(e.subarray(Oe,Z+gs)),b.size+=Z+gs-Oe);break;case 0:fe&&(Oe+=e[Oe]+1),R=this._pmtId=uu(e,Oe);break;case R:{fe&&(Oe+=e[Oe]+1);const gt=cu(e,Oe,this.typeSupported,i,this.observer,this.logger);c=gt.videoPid,c>0&&(r.pid=c,r.segmentCodec=gt.segmentVideoCodec),m=gt.audioPid,m>0&&(o.pid=m,o.segmentCodec=gt.segmentAudioCodec),v=gt.id3Pid,v>0&&(u.pid=v),S!==null&&!I&&(this.logger.warn(`MPEG-TS PMT found at ${Z} after unknown PID '${S}'. Backtracking to sync byte @${B} to parse all TS packets.`),S=null,Z=B-188),I=this.pmtParsed=!0;break}case 17:case 8191:break;default:S=he;break}}else j++;j>0&&ha(this.observer,new Error(`Found ${j} TS packet/s that do not start with 0x47`),void 0,this.logger),r.pesData=h,o.pesData=y,u.pesData=b;const be={audioTrack:o,videoTrack:r,id3Track:u,textTrack:l};return s&&this.extractRemainingSamples(be),be}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:s,textTrack:n}=e,r=i.pesData,o=t.pesData,u=s.pesData;let l;if(r&&(l=Gn(r,this.logger))?(this.readyVideoParser(i.segmentCodec),this.videoParser!==null&&(this.videoParser.parsePES(i,n,l,!0),i.pesData=null)):i.pesData=r,o&&(l=Gn(o,this.logger))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break;case"ac3":this.parseAC3PES(t,l);break}t.pesData=null}else o!=null&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;u&&(l=Gn(u,this.logger))?(this.parseID3PES(s,l),s.pesData=null):s.pesData=u}demuxSampleAes(e,t,i){const s=this.demux(e,i,!0,!this.config.progressive),n=this.sampleAes=new au(this.observer,this.config,t);return this.decrypt(s,n)}readyVideoParser(e){this.videoParser===null&&(e==="avc"?this.videoParser=new ou:e==="hevc"&&(this.videoParser=new lu))}decrypt(e,t){return new Promise(i=>{const{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{i(e)}):i(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{i(e)})})}destroy(){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}parseAACPES(e,t){let i=0;const s=this.aacOverFlow;let n=t.data;if(s){this.aacOverFlow=null;const h=s.missing,m=s.sample.unit.byteLength;if(h===-1)n=ut(s.sample.unit,n);else{const v=m-h;s.sample.unit.set(n.subarray(0,h),v),e.samples.push(s.sample),i=s.missing}}let r,o;for(r=i,o=n.length;r<o-1&&!Rr(n,r);r++);if(r!==i){let h;const m=r<o-1;if(m?h=`AAC PES did not start with ADTS header,offset:${r}`:h="No ADTS header found in AAC PES",ha(this.observer,new Error(h),m,this.logger),!m)return}qa(e,this.observer,n,r,this.audioCodec);let u;if(t.pts!==void 0)u=t.pts;else if(s){const h=Qa(e.samplerate);u=s.sample.pts+h}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let l=0,c;for(;r<o;)if(c=Ja(e,n,r,u,l),r+=c.length,c.missing){this.aacOverFlow=c;break}else for(l++;r<o-1&&!Rr(n,r);r++);}parseMPEGPES(e,t){const i=t.data,s=i.length;let n=0,r=0;const o=t.pts;if(o===void 0){this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;r<s;)if(no(i,r)){const u=io(e,i,r,o,n);if(u)r+=u.length,n++;else break}else r++}parseAC3PES(e,t){{const i=t.data,s=t.pts;if(s===void 0){this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=i.length;let r=0,o=0,u;for(;o<n&&(u=oo(e,i,o,s,r++))>0;)o+=u}}parseID3PES(e,t){if(t.pts===void 0){this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=Ie({},t,{type:this._videoTrack?Ks.emsg:Ks.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function da(a,e){return((a[e+1]&31)<<8)+a[e+2]}function uu(a,e){return(a[e+10]&31)<<8|a[e+11]}function cu(a,e,t,i,s,n){const r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=(a[e+1]&15)<<8|a[e+2],u=e+3+o-4,l=(a[e+10]&15)<<8|a[e+11];for(e+=12+l;e<u;){const c=da(a,e),h=(a[e+3]&15)<<8|a[e+4];switch(a[e]){case 207:if(!i){fa("ADTS AAC",n);break}case 15:r.audioPid===-1&&(r.audioPid=c);break;case 21:r.id3Pid===-1&&(r.id3Pid=c);break;case 219:if(!i){fa("H.264",n);break}case 27:r.videoPid===-1&&(r.videoPid=c);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):r.audioPid===-1&&(r.audioPid=c,r.segmentAudioCodec="mp3");break;case 193:if(!i){fa("AC-3",n);break}case 129:t.ac3?r.audioPid===-1&&(r.audioPid=c,r.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(r.audioPid===-1&&h>0){let m=e+5,v=h;for(;v>2;){switch(a[m]){case 106:t.ac3!==!0?n.log("AC-3 audio found, not supported in this browser for now"):(r.audioPid=c,r.segmentAudioCodec="ac3");break}const b=a[m+1]+2;m+=b,v-=b}}break;case 194:case 135:return ha(s,new Error("Unsupported EC-3 in M2TS found"),void 0,n),r;case 36:r.videoPid===-1&&(r.videoPid=c,r.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=h+5}return r}function ha(a,e,t,i){i.warn(`parsing error: ${e.message}`),a.emit(g.ERROR,g.ERROR,{type:Y.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function fa(a,e){e.log(`${a} with AES-128-CBC encryption found in unencrypted stream`)}function Gn(a,e){let t=0,i,s,n,r,o;const u=a.data;if(!a||a.size===0)return null;for(;u[0].length<19&&u.length>1;)u[0]=ut(u[0],u[1]),u.splice(1,1);if(i=u[0],(i[0]<<16)+(i[1]<<8)+i[2]===1){if(s=(i[4]<<8)+i[5],s&&s>a.size-6)return null;const c=i[7];c&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,c&64?(o=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,r-o>60*9e4&&(e.warn(`${Math.round((r-o)/9e4)}s delta between PTS and DTS, align them`),r=o)):o=r),n=i[8];let h=n+9;if(a.size<=h)return null;a.size-=h;const m=new Uint8Array(a.size);for(let v=0,y=u.length;v<y;v++){i=u[v];let b=i.byteLength;if(h)if(h>b){h-=b;continue}else i=i.subarray(h),b-=h,h=0;m.set(i,t),t+=b}return s&&(s-=n+3),{data:m,pts:r,dts:o,len:s}}return null}class du{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const An=Math.pow(2,32)-1;class ie{static init(){ie.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:[]};let e;for(e in ie.types)ie.types.hasOwnProperty(e)&&(ie.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]);ie.HDLR_TYPES={video:t,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);ie.STTS=ie.STSC=ie.STCO=n,ie.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),ie.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),ie.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),ie.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const r=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);ie.FTYP=ie.box(ie.types.ftyp,r,u,r,o),ie.DINF=ie.box(ie.types.dinf,ie.box(ie.types.dref,s))}static box(e,...t){let i=8,s=t.length;const n=s;for(;s--;)i+=t[s].byteLength;const r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=i&255,r.set(e,4),s=0,i=8;s<n;s++)r.set(t[s],i),i+=t[s].byteLength;return r}static hdlr(e){return ie.box(ie.types.hdlr,ie.HDLR_TYPES[e])}static mdat(e){return ie.box(ie.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(An+1)),s=Math.floor(t%(An+1));return ie.box(ie.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return ie.box(ie.types.mdia,ie.mdhd(e.timescale||0,e.duration||0),ie.hdlr(e.type),ie.minf(e))}static mfhd(e){return ie.box(ie.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?ie.box(ie.types.minf,ie.box(ie.types.smhd,ie.SMHD),ie.DINF,ie.stbl(e)):ie.box(ie.types.minf,ie.box(ie.types.vmhd,ie.VMHD),ie.DINF,ie.stbl(e))}static moof(e,t,i){return ie.box(ie.types.moof,ie.mfhd(e),ie.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=ie.trak(e[t]);return ie.box.apply(null,[ie.types.moov,ie.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(ie.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=ie.trex(e[t]);return ie.box.apply(null,[ie.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(An+1)),s=Math.floor(t%(An+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return ie.box(ie.types.mvhd,n)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let s,n;for(s=0;s<t.length;s++)n=t[s].flags,i[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return ie.box(ie.types.sdtp,i)}static stbl(e){return ie.box(ie.types.stbl,ie.stsd(e),ie.box(ie.types.stts,ie.STTS),ie.box(ie.types.stsc,ie.STSC),ie.box(ie.types.stsz,ie.STSZ),ie.box(ie.types.stco,ie.STCO))}static avc1(e){let t=[],i=[],s,n,r;for(s=0;s<e.sps.length;s++)n=e.sps[s],r=n.byteLength,t.push(r>>>8&255),t.push(r&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],r=n.byteLength,i.push(r>>>8&255),i.push(r&255),i=i.concat(Array.prototype.slice.call(n));const o=ie.box(ie.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),u=e.width,l=e.height,c=e.pixelRatio[0],h=e.pixelRatio[1];return ie.box(ie.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,u>>8&255,u&255,l>>8&255,l&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,ie.box(ie.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),ie.box(ie.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,c&255,h>>24,h>>16&255,h>>8&255,h&255])))}static esds(e){const t=e.config;return new Uint8Array([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,...t,6,1,2])}static audioStsd(e){const t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return ie.box(ie.types.mp4a,ie.audioStsd(e),ie.box(ie.types.esds,ie.esds(e)))}static mp3(e){return ie.box(ie.types[".mp3"],ie.audioStsd(e))}static ac3(e){return ie.box(ie.types["ac-3"],ie.audioStsd(e),ie.box(ie.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return ie.box(ie.types.stsd,ie.STSD,ie.mp4a(e));if(t==="ac3"&&e.config)return ie.box(ie.types.stsd,ie.STSD,ie.ac3(e));if(t==="mp3"&&e.codec==="mp3")return ie.box(ie.types.stsd,ie.STSD,ie.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return ie.box(ie.types.stsd,ie.STSD,ie.avc1(e));if(t==="hevc"&&e.vps)return ie.box(ie.types.stsd,ie.STSD,ie.hvc1(e))}else throw new Error("video track missing pps or sps");throw new Error(`unsupported ${e.type} segment codec (${t}/${e.codec})`)}static tkhd(e){const t=e.id,i=(e.duration||0)*(e.timescale||0),s=e.width||0,n=e.height||0,r=Math.floor(i/(An+1)),o=Math.floor(i%(An+1));return ie.box(ie.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const i=ie.sdtp(e),s=e.id,n=Math.floor(t/(An+1)),r=Math.floor(t%(An+1));return ie.box(ie.types.traf,ie.box(ie.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),ie.box(ie.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,r>>24,r>>16&255,r>>8&255,r&255])),ie.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,ie.box(ie.types.trak,ie.tkhd(e),ie.mdia(e))}static trex(e){const t=e.id;return ie.box(ie.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],s=i.length,n=12+16*s,r=new Uint8Array(n);let o,u,l,c,h,m;for(t+=8+n,r.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)u=i[o],l=u.duration,c=u.size,h=u.flags,m=u.cts,r.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&61440,h.degradPrio&15,m>>>24&255,m>>>16&255,m>>>8&255,m&255],12+16*o);return ie.box(ie.types.trun,r)}static initSegment(e){ie.types||ie.init();const t=ie.moov(e);return ut(ie.FTYP,t)}static hvc1(e){const t=e.params,i=[e.vps,e.sps,e.pps],s=4,n=new Uint8Array([1,t.general_profile_space<<6|(t.general_tier_flag?32:0)|t.general_profile_idc,t.general_profile_compatibility_flags[0],t.general_profile_compatibility_flags[1],t.general_profile_compatibility_flags[2],t.general_profile_compatibility_flags[3],t.general_constraint_indicator_flags[0],t.general_constraint_indicator_flags[1],t.general_constraint_indicator_flags[2],t.general_constraint_indicator_flags[3],t.general_constraint_indicator_flags[4],t.general_constraint_indicator_flags[5],t.general_level_idc,240|t.min_spatial_segmentation_idc>>8,255&t.min_spatial_segmentation_idc,252|t.parallelismType,252|t.chroma_format_idc,248|t.bit_depth_luma_minus8,248|t.bit_depth_chroma_minus8,0,parseInt(t.frame_rate.fps),s-1|t.temporal_id_nested<<2|t.num_temporal_layers<<3|(t.frame_rate.fixed?64:0),i.length]);let r=n.length;for(let y=0;y<i.length;y+=1){r+=3;for(let b=0;b<i[y].length;b+=1)r+=2+i[y][b].length}const o=new Uint8Array(r);o.set(n,0),r=n.length;const u=i.length-1;for(let y=0;y<i.length;y+=1){o.set(new Uint8Array([32+y|(y===u?128:0),0,i[y].length]),r),r+=3;for(let b=0;b<i[y].length;b+=1)o.set(new Uint8Array([i[y][b].length>>8,i[y][b].length&255]),r),r+=2,o.set(i[y][b],r),r+=i[y][b].length}const l=ie.box(ie.types.hvcC,o),c=e.width,h=e.height,m=e.pixelRatio[0],v=e.pixelRatio[1];return ie.box(ie.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,c>>8&255,c&255,h>>8&255,h&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l,ie.box(ie.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),ie.box(ie.types.pasp,new Uint8Array([m>>24,m>>16&255,m>>8&255,m&255,v>>24,v>>16&255,v>>8&255,v&255])))}}ie.types=void 0,ie.HDLR_TYPES=void 0,ie.STTS=void 0,ie.STSC=void 0,ie.STCO=void 0,ie.STSZ=void 0,ie.VMHD=void 0,ie.SMHD=void 0,ie.STSD=void 0,ie.FTYP=void 0,ie.DINF=void 0;const co=9e4;function ma(a,e,t=1,i=!1){const s=a*e*t;return i?Math.round(s):s}function hu(a,e,t=1,i=!1){return ma(a,e,1/t,i)}function ar(a,e=!1){return ma(a,1e3,1/co,e)}function fu(a,e=1){return ma(a,co,1/e)}function ho(a){const{baseTime:e,timescale:t,trackId:i}=a;return`${e/t} (${e}/${t}) trackId: ${i}`}const mu=10*1e3,gu=1024,pu=1152,vu=1536;let Kn=null,ga=null;function fo(a,e,t,i){return{duration:e,size:t,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:a?2:1,isNonSync:a?0:1}}}class Dr extends Ce{constructor(e,t,i,s){if(super("mp4-remuxer",s),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,Kn===null){const r=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Kn=r?parseInt(r[1]):0}if(ga===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);ga=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){const t=this._initPTS;(!t||!e||e.trackId!==t.trackId||e.baseTime!==t.baseTime||e.timescale!==t.timescale)&&this.log(`Reset initPTS: ${t&&ho(t)} > ${e&&ho(e)}`),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const i=e[0].pts,s=e.reduce((n,r)=>{let o=r.pts,u=o-n;return u<-4294967296&&(t=!0,o=Vs(o,i),u=o-n),u>0?n:o},i);return t&&this.debug("PTS rollover detected"),s}remux(e,t,i,s,n,r,o,u){let l,c,h,m,v,y,b=n,S=n;const I=e.pid>-1,R=t.pid>-1,L=t.samples.length,B=e.samples.length>0,j=o&&L>0||L>1;if((!I||B)&&(!R||j)||this.ISGenerated||o){if(this.ISGenerated){var Z,fe,he,q;const Vt=this.videoTrackConfig;(Vt&&(t.width!==Vt.width||t.height!==Vt.height||((Z=t.pixelRatio)==null?void 0:Z[0])!==((fe=Vt.pixelRatio)==null?void 0:fe[0])||((he=t.pixelRatio)==null?void 0:he[1])!==((q=Vt.pixelRatio)==null?void 0:q[1]))||!Vt&&j||this.nextAudioTs===null&&B)&&this.resetInitSegment()}this.ISGenerated||(h=this.generateIS(e,t,n,r));const Oe=this.isVideoContiguous;let gt=-1,wt;if(j&&(gt=yu(t.samples),!Oe&&this.config.forceKeyFrameOnDiscontinuity))if(y=!0,gt>0){this.warn(`Dropped ${gt} out of ${L} video samples due to a missing keyframe`);const Vt=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(gt),t.dropped+=gt,S+=(t.samples[0].pts-Vt)/t.inputTimeScale,wt=S}else gt===-1&&(this.warn(`No keyframe found out of ${L} video samples`),y=!1);if(this.ISGenerated){if(B&&j){const Vt=this.getVideoStartPts(t.samples),at=(Vs(e.samples[0].pts,Vt)-Vt)/t.inputTimeScale;b+=Math.max(0,at),S+=Math.max(0,-at)}if(B){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),h=this.generateIS(e,t,n,r)),c=this.remuxAudio(e,b,this.isAudioContiguous,r,R||j||u===G.AUDIO?S:void 0),j){const Vt=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),h=this.generateIS(e,t,n,r)),l=this.remuxVideo(t,S,Oe,Vt)}}else j&&(l=this.remuxVideo(t,S,Oe,0));l&&(l.firstKeyFrame=gt,l.independent=gt!==-1,l.firstKeyFramePTS=wt)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(v=mo(i,n,this._initPTS,this._initDTS)),s.samples.length&&(m=go(s,n,this._initPTS))),{audio:c,video:l,initSegment:h,independent:y,text:m,id3:v}}computeInitPts(e,t,i,s){const n=Math.round(i*t);let r=Vs(e,n);if(r<n+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(n-r)/t} ${s}`);r<n+t;)r+=8589934592;return r-n}generateIS(e,t,i,s){const n=e.samples,r=t.samples,o=this.typeSupported,u={},l=this._initPTS;let c=!l||s,h="audio/mp4",m,v,y,b=-1;if(c&&(m=v=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(h="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}u.audio={id:"audio",container:h,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):ie.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(b=e.id,y=e.inputTimeScale,!l||y!==l.timescale?m=v=this.computeInitPts(n[0].pts,y,i,"audio"):c=!1)}if(t.sps&&t.pps&&r.length){if(t.timescale=t.inputTimeScale,u.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:ie.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(b=t.id,y=t.inputTimeScale,!l||y!==l.timescale){const S=this.getVideoStartPts(r),I=Vs(r[0].dts,S),R=this.computeInitPts(I,y,i,"video"),L=this.computeInitPts(S,y,i,"video");v=Math.min(v,R),m=Math.min(m,L)}else c=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(u).length)return this.ISGenerated=!0,c?(l&&this.warn(`Timestamps at playlist time: ${s?"":"~"}${i} ${m/y} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${m/y} (${m}/${y}) trackId: ${b}`),this._initPTS={baseTime:m,timescale:y,trackId:b},this._initDTS={baseTime:v,timescale:y,trackId:b}):m=y=void 0,{tracks:u,initPTS:m,timescale:y,trackId:b}}remuxVideo(e,t,i,s){const n=e.inputTimeScale,r=e.samples,o=[],u=r.length,l=this._initPTS,c=l.baseTime*n/l.timescale;let h=this.nextVideoTs,m=8,v=this.videoSampleDuration,y,b,S=Number.POSITIVE_INFINITY,I=Number.NEGATIVE_INFINITY,R=!1;if(!i||h===null){const ht=c+t*n,ft=r[0].pts-Vs(r[0].dts,r[0].pts);Kn&&h!==null&&Math.abs(ht-ft-(h+c))<15e3?i=!0:h=ht-ft-c}const L=h+c;for(let ht=0;ht<u;ht++){const ft=r[ht];ft.pts=Vs(ft.pts,L),ft.dts=Vs(ft.dts,L),ft.dts<r[ht>0?ht-1:ht].dts&&(R=!0)}R&&r.sort(function(ht,ft){const yi=ht.dts-ft.dts,Ki=ht.pts-ft.pts;return yi||Ki}),y=r[0].dts,b=r[r.length-1].dts;const B=b-y,j=B?Math.round(B/(u-1)):v||e.inputTimeScale/30;if(i){const ht=y-L,ft=ht>j,yi=ht<-1;if((ft||yi)&&(ft?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ar(ht,!0)} ms (${ht}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${ar(-ht,!0)} ms (${ht}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!yi||L>=r[0].pts||Kn)){y=L;const Ki=r[0].pts-ht;if(ft)r[0].dts=y,r[0].pts=Ki;else{let bi=!0;for(let Mi=0;Mi<r.length&&!(r[Mi].dts>Ki&&bi);Mi++){const xs=r[Mi].pts;if(r[Mi].dts-=ht,r[Mi].pts-=ht,Mi<r.length-1){const _s=r[Mi+1].pts,Xs=r[Mi].pts,gn=_s<=Xs,Pn=_s<=xs;bi=gn==Pn}}}this.log(`Video: Initial PTS/DTS adjusted: ${ar(Ki,!0)}/${ar(y,!0)}, delta: ${ar(ht,!0)} ms`)}}y=Math.max(0,y);let be=0,Z=0,fe=y;for(let ht=0;ht<u;ht++){const ft=r[ht],yi=ft.units,Ki=yi.length;let bi=0;for(let Mi=0;Mi<Ki;Mi++)bi+=yi[Mi].data.length;Z+=bi,be+=Ki,ft.length=bi,ft.dts<fe?(ft.dts=fe,fe+=j/4|0||1):fe=ft.dts,S=Math.min(ft.pts,S),I=Math.max(ft.pts,I)}b=r[u-1].dts;const he=Z+4*be+8;let q;try{q=new Uint8Array(he)}catch(ht){this.observer.emit(g.ERROR,g.ERROR,{type:Y.MUX_ERROR,details:A.REMUX_ALLOC_ERROR,fatal:!1,error:ht,bytes:he,reason:`fail allocating video mdat ${he}`});return}const Oe=new DataView(q.buffer);Oe.setUint32(0,he),q.set(ie.types.mdat,4);let gt=!1,wt=Number.POSITIVE_INFINITY,Vt=Number.POSITIVE_INFINITY,kt=Number.NEGATIVE_INFINITY,at=Number.NEGATIVE_INFINITY;for(let ht=0;ht<u;ht++){const ft=r[ht],yi=ft.units;let Ki=0;for(let xs=0,_s=yi.length;xs<_s;xs++){const Xs=yi[xs],gn=Xs.data,Pn=Xs.data.byteLength;Oe.setUint32(m,Pn),m+=4,q.set(gn,m),m+=Pn,Ki+=4+Pn}let bi;if(ht<u-1)v=r[ht+1].dts-ft.dts,bi=r[ht+1].pts-ft.pts;else{const xs=this.config,_s=ht>0?ft.dts-r[ht-1].dts:j;if(bi=ht>0?ft.pts-r[ht-1].pts:j,xs.stretchShortVideoTrack&&this.nextAudioTs!==null){const Xs=Math.floor(xs.maxBufferHole*n),gn=(s?S+s*n:this.nextAudioTs+c)-ft.pts;gn>Xs?(v=gn-_s,v<0?v=_s:gt=!0,this.log(`It is approximately ${gn/90} ms to the next segment; using duration ${v/90} ms for the last video frame.`)):v=_s}else v=_s}const Mi=Math.round(ft.pts-ft.dts);wt=Math.min(wt,v),kt=Math.max(kt,v),Vt=Math.min(Vt,bi),at=Math.max(at,bi),o.push(fo(ft.key,v,Ki,Mi))}if(o.length){if(Kn){if(Kn<70){const ht=o[0].flags;ht.dependsOn=2,ht.isNonSync=0}}else if(ga&&at-Vt<kt-wt&&j/kt<.025&&o[0].cts===0){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let ht=y;for(let ft=0,yi=o.length;ft<yi;ft++){const Ki=ht+o[ft].duration,bi=ht+o[ft].cts;if(ft<yi-1){const Mi=Ki+o[ft+1].cts;o[ft].duration=Mi-bi}else o[ft].duration=ft?o[ft-1].duration:j;o[ft].cts=0,ht=Ki}}}v=gt||!v?j:v;const Ot=b+v;this.nextVideoTs=h=Ot-c,this.videoSampleDuration=v,this.isVideoContiguous=!0;const Jt={data1:ie.moof(e.sequenceNumber++,y,Ie(e,{samples:o})),data2:q,startPTS:(S-c)/n,endPTS:(I+v-c)/n,startDTS:(y-c)/n,endDTS:h/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Jt}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return pu;case"ac3":return vu;default:return gu}}remuxAudio(e,t,i,s,n){const r=e.inputTimeScale,o=e.samplerate?e.samplerate:r,u=r/o,l=this.getSamplesPerFrame(e),c=l*u,h=this._initPTS,m=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],y=n!==void 0;let b=e.samples,S=m?0:8,I=this.nextAudioTs||-1;const R=h.baseTime*r/h.timescale,L=R+t*r;if(this.isAudioContiguous=i=i||b.length&&I>0&&(s&&Math.abs(L-(I+R))<9e3||Math.abs(Vs(b[0].pts,L)-(I+R))<20*c),b.forEach(function(at){at.pts=Vs(at.pts,L)}),!i||I<0){const at=b.length;if(b=b.filter(Ot=>Ot.pts>=0),at!==b.length&&this.warn(`Removed ${b.length-at} of ${at} samples (initPTS ${R} / ${r})`),!b.length)return;n===0?I=0:s&&!y?I=Math.max(0,L-R):I=b[0].pts-R}if(e.segmentCodec==="aac"){const at=this.config.maxAudioFramesDrift;for(let Ot=0,bt=I+R;Ot<b.length;Ot++){const $t=b[Ot],Jt=$t.pts,ht=Jt-bt,ft=Math.abs(1e3*ht/r);if(ht<=-at*c&&y)Ot===0&&(this.warn(`Audio frame @ ${(Jt/r).toFixed(3)}s overlaps marker by ${Math.round(1e3*ht/r)} ms.`),this.nextAudioTs=I=Jt-R,bt=Jt);else if(ht>=at*c&&ft<mu&&y){let yi=Math.round(ht/c);for(bt=Jt-yi*c;bt<0&&yi&&c;)yi--,bt+=c;Ot===0&&(this.nextAudioTs=I=bt-R),this.warn(`Injecting ${yi} audio frames @ ${((bt-R)/r).toFixed(3)}s due to ${Math.round(1e3*ht/r)} ms gap.`);for(let Ki=0;Ki<yi;Ki++){let bi=du.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);bi||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),bi=$t.unit.subarray()),b.splice(Ot,0,{unit:bi,pts:bt}),bt+=c,Ot++}}$t.pts=bt,bt+=c}}let B=null,j=null,be,Z=0,fe=b.length;for(;fe--;)Z+=b[fe].unit.byteLength;for(let at=0,Ot=b.length;at<Ot;at++){const bt=b[at],$t=bt.unit;let Jt=bt.pts;if(j!==null){const ft=v[at-1];ft.duration=Math.round((Jt-j)/u)}else if(i&&e.segmentCodec==="aac"&&(Jt=I+R),B=Jt,Z>0){Z+=S;try{be=new Uint8Array(Z)}catch(ft){this.observer.emit(g.ERROR,g.ERROR,{type:Y.MUX_ERROR,details:A.REMUX_ALLOC_ERROR,fatal:!1,error:ft,bytes:Z,reason:`fail allocating audio mdat ${Z}`});return}m||(new DataView(be.buffer).setUint32(0,Z),be.set(ie.types.mdat,4))}else return;be.set($t,S);const ht=$t.byteLength;S+=ht,v.push(fo(!0,l,ht,0)),j=Jt}const he=v.length;if(!he)return;const q=v[v.length-1];I=j-R,this.nextAudioTs=I+u*q.duration;const Oe=m?new Uint8Array(0):ie.moof(e.sequenceNumber++,B/u,Ie({},e,{samples:v}));e.samples=[];const gt=(B-R)/r,wt=this.nextAudioTs/r,kt={data1:Oe,data2:be,startPTS:gt,endPTS:wt,startDTS:gt,endDTS:wt,type:"audio",hasAudio:!0,hasVideo:!1,nb:he};return this.isAudioContiguous=!0,kt}}function Vs(a,e){let t;if(e===null)return a;for(e<a?t=-8589934592:t=8589934592;Math.abs(a-e)>4294967296;)a+=t;return a}function yu(a){for(let e=0;e<a.length;e++)if(a[e].key)return e;return-1}function mo(a,e,t,i){const s=a.samples.length;if(!s)return;const n=a.inputTimeScale;for(let o=0;o<s;o++){const u=a.samples[o];u.pts=Vs(u.pts-t.baseTime*n/t.timescale,e*n)/n,u.dts=Vs(u.dts-i.baseTime*n/i.timescale,e*n)/n}const r=a.samples;return a.samples=[],{samples:r}}function go(a,e,t){const i=a.samples.length;if(!i)return;const s=a.inputTimeScale;for(let r=0;r<i;r++){const o=a.samples[r];o.pts=Vs(o.pts-t.baseTime*s/t.timescale,e*s)/s}a.samples.sort((r,o)=>r.pts-o.pts);const n=a.samples;return a.samples=[],{samples:n}}class Eu extends Ce{constructor(e,t,i,s){super("passthrough-remuxer",s),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.isVideoContiguous=!1}destroy(){}resetTimeStamp(e){this.lastEndTime=null;const t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,s),this.emitInitSegment=!0}generateInitSegment(e,t){let{audioCodec:i,videoCodec:s}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const{audio:n,video:r}=this.initData=z(e);if(t)Ee(e,t);else{const u=n||r;u!=null&&u.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${u.codec}")!`)}n&&(i=po(n,ke.AUDIO,this)),r&&(s=po(r,ke.VIDEO,this));const o={};n&&r?o.audiovideo={container:"video/mp4",codec:i+","+s,supplemental:r.supplemental,encrypted:r.encrypted,initSegment:e,id:"main"}:n?o.audio={container:"audio/mp4",codec:i,encrypted:n.encrypted,initSegment:e,id:"audio"}:r?o.video={container:"video/mp4",codec:s,supplemental:r.supplemental,encrypted:r.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(e,t,i,s,n,r){var o,u;let{initPTS:l,lastEndTime:c}=this;const h={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};_(c)||(c=this.lastEndTime=n||0);const m=t.samples;if(!m.length)return h;const v={initPTS:void 0,timescale:void 0,trackId:void 0};let y=this.initData;if((o=y)!=null&&o.length||(this.generateInitSegment(m),y=this.initData),!((u=y)!=null&&u.length))return this.warn("Failed to generate initSegment."),h;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);const b=Rt(m,y,this),S=y.audio?b[y.audio.id]:null,I=y.video?b[y.video.id]:null,R=wr(I,1/0),L=wr(S,1/0),B=wr(I,0,!0),j=wr(S,0,!0);let be=n,Z=0;const fe=S&&(!I||!l&&L<R||l&&l.trackId===y.audio.id),he=fe?S:I;if(he){const bt=he.timescale,$t=he.start-n*bt,Jt=fe?y.audio.id:y.video.id;be=he.start/bt,Z=fe?j-L:B-R,(r||!l)&&(_u(l,be,n,Z)||bt!==l.timescale)&&(l&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${n} ${$t/bt} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${be-n} (${$t}/${bt}) trackId: ${Jt}`),l=null,v.initPTS=$t,v.timescale=bt,v.trackId=Jt)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${n}`);l?(v.initPTS=l.baseTime,v.timescale=l.timescale,v.trackId=l.trackId):((!v.timescale||v.trackId===void 0||v.initPTS===void 0)&&(this.warn("Could not set initPTS"),v.initPTS=be,v.timescale=1,v.trackId=-1),this.initPTS=l={baseTime:v.initPTS,timescale:v.timescale,trackId:v.trackId});const q=be-l.baseTime/l.timescale,Oe=q+Z;Z>0?this.lastEndTime=Oe:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const gt=!!y.audio,wt=!!y.video;let Vt="";gt&&(Vt+="audio"),wt&&(Vt+="video");const kt=(y.audio?y.audio.encrypted:!1)||(y.video?y.video.encrypted:!1),at={data1:m,startPTS:q,startDTS:q,endPTS:Oe,endDTS:Oe,type:Vt,hasAudio:gt,hasVideo:wt,nb:1,dropped:0,encrypted:kt};h.audio=gt&&!wt?at:void 0,h.video=wt?at:void 0;const Ot=I==null?void 0:I.sampleCount;if(Ot){const bt=I.keyFrameIndex,$t=bt!==-1;at.nb=Ot,at.dropped=bt===0||this.isVideoContiguous?0:$t?bt:Ot,at.independent=$t,at.firstKeyFrame=bt,$t&&I.keyFrameStart&&(at.firstKeyFramePTS=(I.keyFrameStart-l.baseTime)/l.timescale),this.isVideoContiguous||(h.independent=$t),this.isVideoContiguous||(this.isVideoContiguous=$t),at.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${bt}/${Ot} dropped: ${at.dropped} start: ${at.firstKeyFramePTS||"NA"}`)}return h.initSegment=v,h.id3=mo(i,n,l,l),s.samples.length&&(h.text=go(s,n,l)),h}}function wr(a,e,t=!1){return(a==null?void 0:a.start)!==void 0?(a.start+(t?a.duration:0))/a.timescale:e}function _u(a,e,t,i){if(a===null)return!0;const s=Math.max(i,1),n=e-a.baseTime/a.timescale;return Math.abs(n-t)>s}function po(a,e,t){const i=a.codec;return i&&i.length>4?i:e===ke.AUDIO?i==="ec-3"||i==="ac-3"||i==="alac"?i:i==="fLaC"||i==="Opus"?Ii(i,!1):(t.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(t.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}let _n;try{_n=self.performance.now.bind(self.performance)}catch(a){_n=Date.now}const kr=[{demux:ru,remux:Eu},{demux:xn,remux:Dr},{demux:tu,remux:Dr},{demux:su,remux:Dr}];kr.splice(2,0,{demux:iu,remux:Dr});class vo{constructor(e,t,i,s,n,r){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=e,this.typeSupported=t,this.config=i,this.id=n,this.logger=r}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,s){const n=i.transmuxing;n.executeStart=_n();let r=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:u}=this;s&&(this.currentTransmuxState=s);const{contiguous:l,discontinuity:c,trackSwitch:h,accurateTimeOffset:m,timeOffset:v,initSegmentChange:y}=s||o,{audioCodec:b,videoCodec:S,defaultInitPts:I,duration:R,initSegmentData:L}=u,B=Su(r,t);if(B&&Ds(B.method)){const fe=this.getDecrypter(),he=un(B.method);if(fe.isSync()){let q=fe.softwareDecrypt(r,B.key.buffer,B.iv.buffer,he);if(i.part>-1){const gt=fe.flush();q=gt&&gt.buffer}if(!q)return n.executeEnd=_n(),pa(i);r=new Uint8Array(q)}else return this.asyncResult=!0,this.decryptionPromise=fe.webCryptoDecrypt(r,B.key.buffer,B.iv.buffer,he).then(q=>{const Oe=this.push(q,null,i);return this.decryptionPromise=null,Oe}),this.decryptionPromise}const j=this.needsProbing(c,h);if(j){const fe=this.configureTransmuxer(r);if(fe)return this.logger.warn(`[transmuxer] ${fe.message}`),this.observer.emit(g.ERROR,g.ERROR,{type:Y.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,error:fe,reason:fe.message}),n.executeEnd=_n(),pa(i)}(c||h||y||j)&&this.resetInitSegment(L,b,S,R,t),(c||y||j)&&this.resetInitialTimestamp(I),l||this.resetContiguity();const be=this.transmux(r,B,v,m,i);this.asyncResult=or(be);const Z=this.currentTransmuxState;return Z.contiguous=!0,Z.discontinuity=!1,Z.trackSwitch=!1,n.executeEnd=_n(),be}flush(e){const t=e.transmuxing;t.executeStart=_n();const{decrypter:i,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return this.asyncResult=!0,n.then(()=>this.flush(e));const r=[],{timeOffset:o}=s;if(i){const h=i.flush();h&&r.push(this.push(h.buffer,null,e))}const{demuxer:u,remuxer:l}=this;if(!u||!l){t.executeEnd=_n();const h=[pa(e)];return this.asyncResult?Promise.resolve(h):h}const c=u.flush(o);return or(c)?(this.asyncResult=!0,c.then(h=>(this.flushRemux(r,h,e),r))):(this.flushRemux(r,c,e),this.asyncResult?Promise.resolve(r):r)}flushRemux(e,t,i){const{audioTrack:s,videoTrack:n,id3Track:r,textTrack:o}=t,{accurateTimeOffset:u,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===G.MAIN?"level":"track"} ${i.level}`);const c=this.remuxer.remux(s,n,r,o,l,u,!0,this.id);e.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=_n()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,s,n){const{demuxer:r,remuxer:o}=this;!r||!o||(r.resetInitSegment(e,t,i,s),o.resetInitSegment(e,t,i,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,s,n){let r;return t&&t.method==="SAMPLE-AES"?r=this.transmuxSampleAes(e,t,i,s,n):r=this.transmuxUnencrypted(e,i,s,n),r}transmuxUnencrypted(e,t,i,s){const{audioTrack:n,videoTrack:r,id3Track:o,textTrack:u}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,r,o,u,t,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,i,s,n){return this.demuxer.demuxSampleAes(e,t,i).then(r=>({remuxResult:this.remuxer.remux(r.audioTrack,r.videoTrack,r.id3Track,r.textTrack,i,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:s}=this;let n;for(let h=0,m=kr.length;h<m;h++){var r;if((r=kr[h].demux)!=null&&r.probe(e,this.logger)){n=kr[h];break}}if(!n)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,u=this.remuxer,l=n.remux,c=n.demux;(!u||!(u instanceof l))&&(this.remuxer=new l(i,t,s,this.logger)),(!o||!(o instanceof c))&&(this.demuxer=new c(i,t,s,this.logger),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new cs(this.config)),e}}function Su(a,e){let t=null;return a.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const pa=a=>({remuxResult:{},chunkMeta:a});function or(a){return"then"in a&&a.then instanceof Function}class bu{constructor(e,t,i,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=s,this.defaultInitPts=n||null}}class Tu{constructor(e,t,i,s,n,r){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=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=r}}let yo=0;class Eo{constructor(e,t,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=yo++,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=u=>{const l=u.data,c=this.hls;if(!(!c||!(l!=null&&l.event)||l.instanceNo!==this.instanceNo))switch(l.event){case"init":{var h;const m=(h=this.workerContext)==null?void 0:h.objectURL;m&&self.URL.revokeObjectURL(m);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}case"workerLog":{c.logger[l.data.logType]&&c.logger[l.data.logType](l.data.message);break}default:{l.data=l.data||{},l.data.frag=this.frag,l.data.part=this.part,l.data.id=this.id,c.trigger(l.event,l.data);break}}},this.onWorkerError=u=>{if(!this.hls)return;const l=new Error(`${u.message} (${u.filename}:${u.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:l})};const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const r=(u,l)=>{l=l||{},l.frag=this.frag||void 0,u===g.ERROR&&(l=l,l.parent=this.id,l.part=this.part,this.error=l.error),this.hls.trigger(u,l)};this.observer=new na,this.observer.on(g.FRAG_DECRYPTED,r),this.observer.on(g.ERROR,r);const o=f(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker!="undefined"){const u=this.hls.logger;if(n.workerPath||Rl()){try{n.workerPath?(u.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=Cl(n.workerPath)):(u.log(`injecting Web Worker for "${t}"`),this.workerContext=Ll());const{worker:c}=this.workerContext;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:Q(n)})}catch(c){u.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.terminateWorker(),this.error=null,this.transmuxer=new vo(this.observer,o,n,"",t,e.logger)}return}}this.transmuxer=new vo(this.observer,o,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=yo++;const t=this.hls.config,i=f(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:Q(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),Dl(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(e,t,i,s,n,r,o,u,l,c){var h,m;l.transmuxing.start=self.performance.now();const{instanceNo:v,transmuxer:y}=this,b=r?r.start:n.start,S=n.decryptdata,I=this.frag,R=!(I&&n.cc===I.cc),L=!(I&&l.level===I.level),B=I?l.sn-I.sn:-1,j=this.part?l.part-this.part.index:-1,be=B===0&&l.id>1&&l.id===(I==null?void 0:I.stats.chunkCount),Z=!L&&(B===1||B===0&&(j===1||be&&j<=0)),fe=self.performance.now();(L||B||n.stats.parsing.start===0)&&(n.stats.parsing.start=fe),r&&(j||!Z)&&(r.stats.parsing.start=fe);const he=!(I&&((h=n.initSegment)==null?void 0:h.url)===((m=I.initSegment)==null?void 0:m.url)),q=new Tu(R,Z,u,L,b,he);if(!Z||R||he){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===G.MAIN?"level":"track"}: ${l.level} id: ${l.id}
discontinuity: ${R}
trackSwitch: ${L}
contiguous: ${Z}
accurateTimeOffset: ${u}
timeOffset: ${b}
initSegmentChange: ${he}`);const Oe=new bu(i,s,t,o,c);this.configureTransmuxer(Oe)}if(this.frag=n,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:v,cmd:"demux",data:e,decryptdata:S,chunkMeta:l,state:q},e instanceof ArrayBuffer?[e]:[]);else if(y){const Oe=y.push(e,S,l,q);or(Oe)?Oe.then(gt=>{this.handleTransmuxComplete(gt)}).catch(gt=>{this.transmuxerError(gt,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(Oe)}}flush(e){e.transmuxing.start=self.performance.now();const{instanceNo:t,transmuxer:i}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){const s=i.flush(e);or(s)?s.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")}):this.handleFlushResult(s,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}configureTransmuxer(e){const{instanceNo:t,transmuxer:i}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const _o=100;class xu extends ia{constructor(e,t,i){super(e,t,i,"audio-stream-controller",G.AUDIO),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(g.BUFFER_RESET,this.onBufferReset,this),e.on(g.BUFFER_CREATED,this.onBufferCreated,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(g.FRAG_LOADING,this.onFragLoading,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(g.BUFFER_RESET,this.onBufferReset,this),e.off(g.BUFFER_CREATED,this.onBufferCreated,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(g.FRAG_LOADING,this.onFragLoading,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n,trackId:r}){if(i===G.MAIN){const o=t.cc,u=this.fragCurrent;if(this.initPTS[o]={baseTime:s,timescale:n,trackId:r},this.log(`InitPTS for cc: ${o} found from main: ${s/n} (${s}/${n}) trackId: ${r}`),this.mainAnchor=t,this.state===De.WAITING_INIT_PTS){const l=this.waitingData;(!l&&!this.loadingParts||l&&l.frag.cc!==o)&&this.syncWithAnchor(t,l==null?void 0:l.frag)}else!this.hls.hasEnoughToStart&&u&&u.cc!==o?(u.abortRequests(),this.syncWithAnchor(t,u)):this.state===De.IDLE&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(e,t){var i;const s=((i=this.mainFragLoading)==null?void 0:i.frag)||null;if(t&&(s==null?void 0:s.cc)===t.cc)return;const n=(s||e).cc,r=this.getLevelDetails(),o=this.getLoadPosition(),u=vi(r,n,o);u&&(this.log(`Syncing with main frag at ${u.start} cc ${u.cc}`),this.startFragRequested=!1,this.nextLoadPosition=u.start,this.resetLoadingState(),this.state===De.IDLE&&this.doTickIdle())}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=De.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(_o),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=De.IDLE):this.state=De.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case De.IDLE:this.doTickIdle();break;case De.WAITING_TRACK:{const{levels:e,trackId:t}=this,i=e==null?void 0:e[t],s=i==null?void 0:i.details;if(s&&!this.waitForLive(i)){if(this.waitForCdnTuneIn(s))break;this.state=De.WAITING_INIT_PTS}break}case De.FRAG_LOADING_WAITING_RETRY:{this.checkRetryDate();break}case De.WAITING_INIT_PTS:{const e=this.waitingData;if(e){const{frag:t,part:i,cache:s,complete:n}=e,r=this.mainAnchor;if(this.initPTS[t.cc]!==void 0){this.waitingData=null,this.state=De.FRAG_LOADING;const o=s.flush().buffer,u={frag:t,part:i,payload:o,networkDetails:null};this._handleFragmentLoadProgress(u),n&&super._handleFragmentLoadComplete(u)}else r&&r.cc!==e.frag.cc&&this.syncWithAnchor(r,e.frag)}else this.state=De.IDLE}}this.onTickEnd()}resetLoadingState(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){var e;const{hls:t,levels:i,media:s,trackId:n}=this,r=t.config;if(!this.buffering||!s&&!this.primaryPrefetch&&(this.startFragRequested||!r.startFragPrefetch)||!(i!=null&&i[n]))return;const o=i[n],u=o.details;if(!u||this.waitForLive(o)||this.waitForCdnTuneIn(u)){this.state=De.WAITING_TRACK,this.startFragRequested=!1;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ke.AUDIO,G.AUDIO));const c=this.getFwdBufferInfo(l,G.AUDIO);if(c===null)return;if(!this.switchingTrack&&this._streamEnded(c,u)){t.trigger(g.BUFFER_EOS,{type:"audio"}),this.state=De.ENDED;return}const h=c.len,m=t.maxBufferLength,v=u.fragments,y=v[0].start,b=this.getLoadPosition(),S=this.flushing?b:c.end;if(this.switchingTrack&&s){const L=b;u.PTSKnown&&L<y&&(c.end>y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=y+.05)}if(h>=m&&!this.switchingTrack&&S<v[v.length-1].start)return;let I=this.getNextFragment(S,u);if(I&&this.isLoopLoading(I,S)&&(I=this.getNextFragmentLoopLoading(I,u,c,G.MAIN,m)),!I){this.bufferFlushed=!0;return}let R=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&R&&_e(I)&&!I.endList&&(!u.live||!this.loadingParts&&S<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(R)===xi.OK&&(this.mainFragLoading=R=null),R&&_e(R))){if(I.start>R.end){const B=this.fragmentTracker.getFragAtPos(S,G.MAIN);B&&B.end>R.end&&(R=B,this.mainFragLoading={frag:B,targetBufferTime:null})}if(I.start>R.end)return}this.loadFragment(I,o,S)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new mi(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==De.STOPPED&&(this.setInterval(_o),this.state=De.IDLE,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(e,t){this.mainDetails=t.details;const i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(g.AUDIO_TRACK_LOADED,i))}onAudioTrackLoaded(e,t){var i;const{levels:s}=this,{details:n,id:r,groupId:o,track:u}=t;if(!s){this.warn(`Audio tracks reset while loading track ${r} "${u.name}" of "${o}"`);return}const l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired){this.cachedTrackLoadedData=t,this.state!==De.STOPPED&&(this.state=De.WAITING_TRACK);return}this.cachedTrackLoadedData=null,this.log(`Audio track ${r} "${u.name}" of "${o}" loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const c=s[r];let h=0;if(n.live||(i=c.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(c.details){var m;h=this.alignPlaylists(n,c.details,(m=this.levelLastLoaded)==null?void 0:m.details)}n.alignedSliding||(xr(n,l),n.alignedSliding||Ar(n,l),h=n.fragmentStart)}c.details=n,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(l,h),this.hls.trigger(g.AUDIO_TRACK_UPDATED,{details:n,id:r,groupId:t.groupId}),this.state===De.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=De.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:n}=e,{config:r,trackId:o,levels:u}=this;if(!u){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const l=u[o];if(!l){this.warn("Audio track is undefined on fragment load progress");return}const c=l.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const h=r.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let m=this.transmuxer;m||(m=this.transmuxer=new Eo(this.hls,G.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const v=this.initPTS[i.cc],y=(t=i.initSegment)==null?void 0:t.data;if(v!==void 0){const S=s?s.index:-1,I=S!==-1,R=new Ns(i.level,i.sn,i.stats.chunkCount,n.byteLength,S,I);m.push(n,y,h,"",i,s,c.totalduration,!1,R,v)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);const{cache:b}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new za,complete:!1};b.push(new Uint8Array(n)),this.state!==De.STOPPED&&(this.state=De.WAITING_INIT_PTS)}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(e,t){this.bufferFlushed=this.flushing=!1;const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}onFragLoading(e,t){!this.audioOnly&&t.frag.type===G.MAIN&&_e(t.frag)&&(this.mainFragLoading=t,this.state===De.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i.type!==G.AUDIO){!this.audioOnly&&i.type===G.MAIN&&!i.elementaryStreams.video&&!i.elementaryStreams.audiovideo&&(this.audioOnly=!0,this.mainFragLoading=null);return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(_e(i)){this.fragPrevious=i;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(g.AUDIO_TRACK_SWITCHED,H({},n)))}this.fragBufferedComplete(i,s),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=De.ERROR;return}switch(t.details){case A.FRAG_GAP:case A.FRAG_PARSING_ERROR:case A.FRAG_DECRYPT_ERROR:case A.FRAG_LOAD_ERROR:case A.FRAG_LOAD_TIMEOUT:case A.KEY_LOAD_ERROR:case A.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(G.AUDIO,t);break;case A.AUDIO_TRACK_LOAD_ERROR:case A.AUDIO_TRACK_LOAD_TIMEOUT:case A.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===De.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===te.AUDIO_TRACK&&(this.state=De.IDLE);break;case A.BUFFER_ADD_CODEC_ERROR:case A.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)||this.resetLoadingState();break;case A.BUFFER_FULL_ERROR:if(t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case A.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ke.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ke.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===De.ENDED&&(this.state=De.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,G.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const i="audio",{hls:s}=this,{remuxResult:n,chunkMeta:r}=e,o=this.getCurrentContext(r);if(!o){this.resetWhenMissingContext(r);return}const{frag:u,part:l,level:c}=o,{details:h}=c,{audio:m,text:v,id3:y,initSegment:b}=n;if(this.fragContextChanged(u)||!h){this.fragmentTracker.removeFragment(u);return}if(this.state=De.PARSING,this.switchingTrack&&m&&this.completeAudioSwitch(this.switchingTrack),b!=null&&b.tracks){const S=u.initSegment||u;if(this.unhandledEncryptionError(b,u))return;this._bufferInitSegment(c,b.tracks,S,r),s.trigger(g.FRAG_PARSING_INIT_SEGMENT,{frag:S,id:i,tracks:b.tracks})}if(m){const{startPTS:S,endPTS:I,startDTS:R,endDTS:L}=m;l&&(l.elementaryStreams[ke.AUDIO]={startPTS:S,endPTS:I,startDTS:R,endDTS:L}),u.setElementaryStreamInfo(ke.AUDIO,S,I,R,L),this.bufferFragmentData(m,u,l,r)}if(y!=null&&(t=y.samples)!=null&&t.length){const S=Ie({id:i,frag:u,details:h},y);s.trigger(g.FRAG_PARSING_METADATA,S)}if(v){const S=Ie({id:i,frag:u,details:h},v);s.trigger(g.FRAG_PARSING_USERDATA,S)}}_bufferInitSegment(e,t,i,s){if(this.state!==De.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const n=t.audio;n.id=G.AUDIO;const r=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${r}/${n.codec}]`),r&&r.split(",").length===1&&(n.levelCodec=r),this.hls.trigger(g.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const u={type:"audio",frag:i,part:null,chunkMeta:s,parent:i.type,data:o};this.hls.trigger(g.BUFFER_APPENDING,u)}this.tickImmediate()}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);if(this.switchingTrack||s===xi.NOT_LOADED||s===xi.PARTIAL){var n;if(!_e(e))this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=De.WAITING_INIT_PTS;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&Ar(t.details,r)}else super.loadFragment(e,t,i)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){if(this.media&&this.bufferedTrack){const{name:t,lang:i,assocLang:s,characteristics:n,audioCodec:r,channels:o}=this.bufferedTrack;Kt({name:t,lang:i,assocLang:s,characteristics:n,audioCodec:r,channels:o},e,Nt)||(gi(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(g.AUDIO_TRACK_SWITCHED,H({},e))}}class va extends Ce{constructor(e,t){super(t,e.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,i){const s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let r=0;r<s.length;r++){const o=s[r];let u;try{u=new self.URL(o.URI,t.url).href}catch(l){this.warn(`Could not construct new URL for Rendition Report: ${l}`),u=o.URI||""}if(u===e){n=r;break}else u===e.substring(0,u.length)&&(n=r)}if(n!==-1){const r=s[n],o=parseInt(r["LAST-MSN"])||t.lastPartSn;let u=parseInt(r["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){const c=Math.min(t.age-t.partTarget,t.targetduration);u>=0&&c>t.partTarget&&(u+=1)}const l=i&&di(i);return new Ri(o,u>=0?u:void 0,l)}}}loadPlaylist(e){this.clearTimer()}loadingPlaylist(e,t){this.clearTimer()}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}getUrlWithDirectives(e,t){if(t)try{return t.addDirectives(e)}catch(i){this.warn(`Could not construct new URL with HLS Delivery Directives: ${i}`)}return e}playlistLoaded(e,t,i){const{details:s,stats:n}=t,r=self.performance.now(),o=n.loading.first?Math.max(0,r-n.loading.first):0;s.advancedDateTime=Date.now()-o;const u=this.hls.config.timelineOffset;if(u!==s.appliedTimelineOffset){const c=Math.max(u||0,0);s.appliedTimelineOffset=c,s.fragments.forEach(h=>{h.setStart(h.playlistOffset+c)})}if(s.live||i!=null&&i.live){const c="levelInfo"in t?t.levelInfo:t.track;if(s.reloaded(i),i&&s.fragments.length>0){Jr(i,s,this);const R=s.playlistParsingError;if(R){this.warn(R);const L=this.hls;if(!L.config.ignorePlaylistParsingErrors){var l;const{networkDetails:B}=t;L.trigger(g.ERROR,{type:Y.NETWORK_ERROR,details:A.LEVEL_PARSING_ERROR,fatal:!1,url:s.url,error:R,reason:R.message,level:t.level||void 0,parent:(l=s.fragments[0])==null?void 0:l.type,networkDetails:B,stats:n});return}s.playlistParsingError=null}}s.requestScheduled===-1&&(s.requestScheduled=n.loading.start);const h=this.hls.mainForwardBufferInfo,m=h?h.end-h.len:0,v=(s.edge-m)*1e3,y=Xi(s,v);if(s.requestScheduled+y<r?s.requestScheduled=r:s.requestScheduled+=y,this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),!this.canLoad||!s.live)return;let b,S,I;if(s.canBlockReload&&s.endSN&&s.advanced){const R=this.hls.config.lowLatencyMode,L=s.lastPartSn,B=s.endSN,j=s.lastPartIndex,be=j!==-1,Z=L===B;be?Z?(S=B+1,I=R?0:j):(S=L,I=R?j+1:s.maxPartIndex):S=B+1;const fe=s.age,he=fe+s.ageHeader;let q=Math.min(he-s.partTarget,s.targetduration*1.5);if(q>0){if(he>s.targetduration*3)this.log(`Playlist last advanced ${fe.toFixed(2)}s ago. Omitting segment and part directives.`),S=void 0,I=void 0;else if(i!=null&&i.tuneInGoal&&he-s.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${q} with playlist age: ${s.age}`),q=0;else{const Oe=Math.floor(q/s.targetduration);if(S+=Oe,I!==void 0){const gt=Math.round(q%s.targetduration/s.partTarget);I+=gt}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${fe.toFixed(2)}s goal: ${q} skip sn ${Oe} to part ${I}`)}s.tuneInGoal=q}if(b=this.getDeliveryDirectives(s,t.deliveryDirectives,S,I),R||!Z){s.requestScheduled=r,this.loadingPlaylist(c,b);return}}else(s.canBlockReload||s.canSkipUntil)&&(b=this.getDeliveryDirectives(s,t.deliveryDirectives,S,I));b&&S!==void 0&&s.canBlockReload&&(s.requestScheduled=n.loading.first+Math.max(y-o*2,y/2)),this.scheduleLoading(c,b,s)}else this.clearTimer()}scheduleLoading(e,t,i){const s=i||e.details;if(!s){this.loadingPlaylist(e,t);return}const n=self.performance.now(),r=s.requestScheduled;if(n>=r){this.loadingPlaylist(e,t);return}const o=r-n;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}getDeliveryDirectives(e,t,i,s){let n=di(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,n=mt.No),new Ri(i,s,n)}checkRetry(e){const t=e.details,i=Li(e),s=e.errorAction,{action:n,retryCount:r=0,retryConfig:o}=s||{},u=!!s&&!!o&&(n===Ci.RetryRequest||!s.resolved&&n===Ci.SendAlternateToPenaltyBox);if(u){var l;if(r>=o.maxNumRetry)return!1;if(i&&(l=e.context)!=null&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${r+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const c=ji(o,r);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${r+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,s.resolved=!0}return u}}function So(a,e){if(a.length!==e.length)return!1;for(let t=0;t<a.length;t++)if(!lr(a[t].attrs,e[t].attrs))return!1;return!0}function lr(a,e,t){const i=a["STABLE-RENDITION-ID"];return i&&!t?i===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>a[s]!==e[s])}function ya(a,e){return e.label.toLowerCase()===a.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(a.lang||"").toLowerCase())}class Au extends va{constructor(e){super(e,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(g.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(g.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(g.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:s,details:n}=t,r=this.tracksInGroup[i];if(!r||r.groupId!==s){this.warn(`Audio track with id:${i} and group:${s} not found in active group ${r==null?void 0:r.groupId}`);return}const o=r.details;r.details=t.details,this.log(`Audio track ${i} "${r.name}" lang:${r.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.audioGroups||null,s=this.groupIds;let n=this.currentTrack;if(!i||(s==null?void 0:s.length)!==(i==null?void 0:i.length)||i!=null&&i.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(m=>!i||i.indexOf(m.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(m=>m.default)&&(this.selectDefaultTrack=!1),o.forEach((m,v)=>{m.id=v});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const u=this.hls.config.audioPreference;if(!n&&u){const m=Qe(u,o,Nt);if(m>-1)n=o[m];else{const v=Qe(u,this.tracks);n=this.tracks[v]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i==null?void 0:i.join(",")}`),this.hls.trigger(g.AUDIO_TRACKS_UPDATED,c);const h=this.trackId;if(l!==-1&&h===-1)this.setAudioTrack(l);else if(o.length&&h===-1){var r;const m=new Error(`No audio track selected for current audio group-ID(s): ${(r=this.groupIds)==null?void 0:r.join(",")} track count: ${o.length}`);this.warn(m.message),this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:m})}}}onError(e,t){t.fatal||!t.context||t.context.type===te.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const s=this.currentTrack;if(s&&Kt(e,s,Nt))return s;const n=Qe(e,this.tracksInGroup,Nt);if(n>-1){const r=this.tracksInGroup[n];return this.setAudioTrack(n),r}else if(s){let r=t.loadLevel;r===-1&&(r=t.firstAutoLevel);const o=Zt(e,t.levels,i,r,Nt);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const r=Qe(e,i);if(r>-1)return i[r]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===i&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(g.AUDIO_TRACK_SWITCHING,H({},s)),n))return;const r=this.switchParams(s.url,i==null?void 0:i.details,s.details);this.loadPlaylist(r)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(!(this.selectDefaultTrack&&!s.default)&&(!e||Kt(e,s,Nt)))return i}if(e){const{name:i,lang:s,assocLang:n,characteristics:r,audioCodec:o,channels:u}=e;for(let l=0;l<t.length;l++){const c=t[l];if(Kt({name:i,lang:s,assocLang:n,characteristics:r,audioCodec:o,channels:u},c,Nt))return l}for(let l=0;l<t.length;l++){const c=t[l];if(lr(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){const c=t[l];if(lr(e.attrs,c.attrs,["LANGUAGE"]))return l}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&gi(t.url,this.hls)&&this.scheduleLoading(t,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,n=this.getUrlWithDirectives(e.url,t),r=e.details,o=r==null?void 0:r.age;this.log(`Loading audio-track ${i} "${e.name}" lang:${e.lang} group:${s}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&r.live?" age "+o.toFixed(1)+(r.type?" "+r.type||0:""):""} ${n}`),this.hls.trigger(g.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null,track:e})}}class Iu{constructor(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}destroy(){this.tracks=this.queues=null}append(e,t,i){if(this.queues===null||this.tracks===null)return;const s=this.queues[t];s.push(e),s.length===1&&!i&&this.executeNext(t)}appendBlocker(e){return new Promise(t=>{const i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}prependBlocker(e){return new Promise(t=>{if(this.queues){const i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}removeBlockers(){this.queues!==null&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t;const i=(t=e[0])==null?void 0:t.label;(i==="async-blocker"||i==="async-blocker-prepend")&&(e[0].execute(),e.splice(0,1))})}unblockAudio(e){if(this.queues===null)return;this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio")}executeNext(e){if(this.queues===null||this.tracks===null)return;const t=this.queues[e];if(t.length){const s=t[0];try{s.execute()}catch(n){var i;if(s.onError(n),this.queues===null||this.tracks===null)return;const r=(i=this.tracks[e])==null?void 0:i.buffer;r!=null&&r.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues!==null&&(this.queues[e].shift(),this.executeNext(e))}current(e){var t;return((t=this.queues)==null?void 0:t[e][0])||null}toString(){const{queues:e,tracks:t}=this;return e===null||t===null?"<destroyed>":`
${this.list("video")}
${this.list("audio")}
${this.list("audiovideo")}}`}list(e){var t,i;return(t=this.queues)!=null&&t[e]||(i=this.tracks)!=null&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}listSbInfo(e){var t;const i=(t=this.tracks)==null?void 0:t[e],s=i==null?void 0:i.buffer;return s?`SourceBuffer${s.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}listOps(e){var t;return((t=this.queues)==null?void 0:t[e].map(i=>i.label).join(", "))||""}}const bo=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,To="HlsJsTrackRemovedError";class Ru extends Error{constructor(e){super(e),this.name=To}}class Lu extends Ce{constructor(e,t){super("buffer-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=i=>{var s;this.hls&&((s=this.mediaSource)==null?void 0:s.readyState)==="open"&&this.hls.pauseBuffering()},this._onStartStreaming=i=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=i=>{const{media:s,mediaSource:n}=this;i&&this.log("Media source opened"),!(!s||!n)&&(n.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(g.MEDIA_ATTACHED,{media:s,mediaSource:n}),this.mediaSource!==null&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:i,_objectUrl:s}=this;i!==s&&this.error(`Media element src was set while attaching MediaSource (${s} > ${i})`)},this.hls=e,this.fragmentTracker=t,this.appendSource=yt(vt(e.config.preferManagedMediaSource)),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){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}registerListeners(){const{hls:e}=this;e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.BUFFER_RESET,this.onBufferReset,this),e.on(g.BUFFER_APPENDING,this.onBufferAppending,this),e.on(g.BUFFER_CODECS,this.onBufferCodecs,this),e.on(g.BUFFER_EOS,this.onBufferEos,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.FRAG_PARSED,this.onFragParsed,this),e.on(g.FRAG_CHANGED,this.onFragChanged,this),e.on(g.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.BUFFER_RESET,this.onBufferReset,this),e.off(g.BUFFER_APPENDING,this.onBufferAppending,this),e.off(g.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.BUFFER_EOS,this.onBufferEos,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.FRAG_PARSED,this.onFragParsed,this),e.off(g.FRAG_CHANGED,this.onFragChanged,this),e.off(g.ERROR,this.onError,this)}transferMedia(){const{media:e,mediaSource:t}=this;if(!e)return null;const i={};if(this.operationQueue){const n=this.isUpdating();n||this.operationQueue.removeBlockers();const r=this.isQueued();(n||r)&&this.warn(`Transfering MediaSource with${r?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const s=this.transferData;return!this.sourceBufferCount&&s&&s.mediaSource===t?Ie(i,s.tracks):this.sourceBuffers.forEach(n=>{const[r]=n;r&&(i[r]=Ie({},this.tracks[r]),this.removeBuffer(r)),n[0]=n[1]=null}),{media:e,mediaSource:t,tracks:i}}initTracks(){const e={};this.sourceBuffers=[[null,null],[null,null]],this.tracks=e,this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){var i;let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsTotal=s,this.log(`${s} bufferCodec event(s) expected.`),(i=this.transferData)!=null&&i.mediaSource&&this.sourceBufferCount&&s&&this.bufferCreated()}onMediaAttaching(e,t){const i=this.media=t.media;this.transferData=this.overrides=void 0;const s=vt(this.appendSource);if(s){const n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);const r=this.mediaSource=t.mediaSource||new s;if(this.assignMediaSource(r),n)this._objectUrl=i.src,this.attachTransferred();else{const o=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{i.removeAttribute("src");const u=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||u&&r instanceof u,xo(i),Cu(i,o),i.load()}catch(u){i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(e){var t,i;this.log(`${((t=this.transferData)==null?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${(i=e.constructor)==null?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))}attachTransferred(){const e=this.media,t=this.transferData;if(!t||!e)return;const i=this.tracks,s=t.tracks,n=s?Object.keys(s):null,r=n?n.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(s&&n&&r){if(!this.tracksReady){this.hls.config.startFragPrefetch=!0,this.log("attachTransferred: waiting for SourceBuffer track info");return}if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})
required tracks: ${Q(i,(u,l)=>u==="initSegment"?void 0:l)};
transfer tracks: ${Q(s,(u,l)=>u==="initSegment"?void 0:l)}}`),!Je(s,i)){t.mediaSource=null,t.tracks=void 0;const u=e.currentTime,l=this.details,c=Math.max(u,(l==null?void 0:l.fragments[0].start)||0);if(c-u>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${u} -> ${c}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(s)}"->"${Object.keys(i)}") start time: ${c} currentTime: ${u}`),this.onMediaDetaching(g.MEDIA_DETACHING,{}),this.onMediaAttaching(g.MEDIA_ATTACHING,t),e.currentTime=c;return}this.transferData=void 0,n.forEach(u=>{const l=u,c=s[l];if(c){const h=c.buffer;if(h){const m=this.fragmentTracker,v=c.id;if(m.hasFragments(v)||m.hasParts(v)){const S=Yt.getBuffered(h);m.detectEvictedFragments(l,S,v,null,!0)}const y=Ea(l),b=[l,h];this.sourceBuffers[y]=b,h.updating&&this.operationQueue&&this.operationQueue.prependBlocker(l),this.trackSourceBuffer(l,c)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}get mediaSourceOpenOrEnded(){var e;const t=(e=this.mediaSource)==null?void 0:e.readyState;return t==="open"||t==="ended"}onMediaDetaching(e,t){const i=!!t.transferMedia;this.transferData=this.overrides=void 0;const{media:s,mediaSource:n,_objectUrl:r}=this;if(n){if(this.log(`media source ${i?"transferring":"detaching"}`),i)this.sourceBuffers.forEach(([o])=>{o&&this.removeBuffer(o)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const o=n.readyState==="open";try{const u=n.sourceBuffers;for(let l=u.length;l--;)o&&u[l].abort(),n.removeSourceBuffer(u[l]);o&&n.endOfStream()}catch(u){this.warn(`onMediaDetaching: ${u.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}n.removeEventListener("sourceopen",this._onMediaSourceOpen),n.removeEventListener("sourceended",this._onMediaSourceEnded),n.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(n.removeEventListener("startstreaming",this._onStartStreaming),n.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}s&&(s.removeEventListener("emptied",this._onMediaEmptied),i||(r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(s.removeAttribute("src"),this.appendSource&&xo(s),s.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(g.MEDIA_DETACHED,t)}onBufferReset(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}resetBuffer(e){var t;const i=(t=this.tracks[e])==null?void 0:t.buffer;if(this.removeBuffer(e),i)try{var s;(s=this.mediaSource)!=null&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(n){this.warn(`onBufferReset ${e}`,n)}delete this.tracks[e]}removeBuffer(e){this.removeBufferListeners(e),this.sourceBuffers[Ea(e)]=[null,null];const t=this.tracks[e];t&&(t.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Iu(this.tracks)}onBufferCodecs(e,t){var i;const s=this.tracks,n=Object.keys(t);this.log(`BUFFER_CODECS: "${n}" (current SB count ${this.sourceBufferCount})`);const r="audiovideo"in t&&(s.audio||s.video)||s.audiovideo&&("audio"in t||"video"in t),o=!r&&this.sourceBufferCount&&this.media&&n.some(u=>!s[u]);if(r||o){this.warn(`Unsupported transition between "${Object.keys(s)}" and "${n}" SourceBuffers`);return}n.forEach(u=>{var l,c;const h=t[u],{id:m,codec:v,levelCodec:y,container:b,metadata:S,supplemental:I}=h;let R=s[u];const L=(l=this.transferData)==null||(l=l.tracks)==null?void 0:l[u],B=L!=null&&L.buffer?L:R,j=(B==null?void 0:B.pendingCodec)||(B==null?void 0:B.codec),be=B==null?void 0:B.levelCodec;R||(R=s[u]={buffer:void 0,listeners:[],codec:v,supplemental:I,container:b,levelCodec:y,metadata:S,id:m});const Z=si(j,be),fe=Z==null?void 0:Z.replace(bo,"$1");let he=si(v,y);const q=(c=he)==null?void 0:c.replace(bo,"$1");he&&Z&&fe!==q&&(u.slice(0,5)==="audio"&&(he=Ii(he,this.appendSource)),this.log(`switching codec ${j} to ${he}`),he!==(R.pendingCodec||R.codec)&&(R.pendingCodec=he),R.container=b,this.appendChangeType(u,b,he))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&((i=t.audio)==null?void 0:i.id)==="main"&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((e,t)=>{const i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}appendChangeType(e,t,i){const s=`${t};codecs=${i}`,n={label:`change-type=${s}`,execute:()=>{const r=this.tracks[e];if(r){const o=r.buffer;o!=null&&o.changeType&&(this.log(`changing ${e} sourceBuffer type to ${s}`),o.changeType(s),r.codec=i,r.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:r=>{this.warn(`Failed to change ${e} SourceBuffer type`,r)}};this.append(n,e,this.isPending(this.tracks[e]))}blockAudio(e){var t;const i=e.start,s=i+e.duration*.05;if(((t=this.fragmentTracker.getAppendedFrag(i,G.MAIN))==null?void 0:t.gap)===!0)return;const r={label:"block-audio",execute:()=>{var o;const u=this.tracks.video;(this.lastVideoAppendEnd>s||u!=null&&u.buffer&&Yt.isBuffered(u.buffer,s)||((o=this.fragmentTracker.getAppendedFrag(s,G.MAIN))==null?void 0:o.gap)===!0)&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:o=>{this.warn("Error executing block-audio operation",o)}};this.blockedAudioAppend={op:r,frag:e},this.append(r,"audio",!0)}unblockAudio(){const{blockedAudioAppend:e,operationQueue:t}=this;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}onBufferAppending(e,t){const{tracks:i}=this,{data:s,type:n,parent:r,frag:o,part:u,chunkMeta:l,offset:c}=t,h=l.buffering[n],{sn:m,cc:v}=o,y=self.performance.now();h.start=y;const b=o.stats.buffering,S=u?u.stats.buffering:null;b.start===0&&(b.start=y),S&&S.start===0&&(S.start=y);const I=i.audio;let R=!1;n==="audio"&&(I==null?void 0:I.container)==="audio/mpeg"&&(R=!this.lastMpegAudioChunk||l.id===1||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const L=i.video,B=L==null?void 0:L.buffer;if(B&&m!=="initSegment"){const Z=u||o,fe=this.blockedAudioAppend;if(n==="audio"&&r!=="main"&&!this.blockedAudioAppend&&!(L.ending||L.ended)){const q=Z.start+Z.duration*.05,Oe=B.buffered,gt=this.currentOp("video");!Oe.length&&!gt?this.blockAudio(Z):!gt&&!Yt.isBuffered(B,q)&&this.lastVideoAppendEnd<q&&this.blockAudio(Z)}else if(n==="video"){const he=Z.end;if(fe){const q=fe.frag.start;(he>q||he<this.lastVideoAppendEnd||Yt.isBuffered(B,q))&&this.unblockAudio()}this.lastVideoAppendEnd=he}}const j=(u||o).start,be={label:`append-${n}`,execute:()=>{var Z;h.executeStart=self.performance.now();const fe=(Z=this.tracks[n])==null?void 0:Z.buffer;fe&&(R?this.updateTimestampOffset(fe,j,.1,n,m,v):c!==void 0&&_(c)&&this.updateTimestampOffset(fe,c,1e-6,n,m,v)),this.appendExecutor(s,n)},onStart:()=>{},onComplete:()=>{const Z=self.performance.now();h.executeEnd=h.end=Z,b.first===0&&(b.first=Z),S&&S.first===0&&(S.first=Z);const fe={};this.sourceBuffers.forEach(([he,q])=>{he&&(fe[he]=Yt.getBuffered(q))}),this.appendErrors[n]=0,n==="audio"||n==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(g.BUFFER_APPENDED,{type:n,frag:o,part:u,chunkMeta:l,parent:o.type,timeRanges:fe})},onError:Z=>{var fe;const he={type:Y.MEDIA_ERROR,parent:o.type,details:A.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:u,chunkMeta:l,error:Z,err:Z,fatal:!1},q=(fe=this.media)==null?void 0:fe.error;if(Z.code===DOMException.QUOTA_EXCEEDED_ERR||Z.name=="QuotaExceededError"||"quota"in Z)he.details=A.BUFFER_FULL_ERROR;else if(Z.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!q)he.errorAction=Oi(!0);else if(Z.name===To&&this.sourceBufferCount===0)he.errorAction=Oi(!0);else{const Oe=++this.appendErrors[n];this.warn(`Failed ${Oe}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${q||"no media error"})`),(Oe>=this.hls.config.appendErrorMaxRetry||q)&&(he.fatal=!0)}this.hls.trigger(g.ERROR,he)}};this.log(`queuing "${n}" append sn: ${m}${u?" p: "+u.index:""} of ${o.type===G.MAIN?"level":"track"} ${o.level} cc: ${v}`),this.append(be,n,this.isPending(this.tracks[n]))}getFlushOp(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(g.BUFFER_FLUSHED,{type:e})},onError:s=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,s)}}}onBufferFlushing(e,t){const{type:i,startOffset:s,endOffset:n}=t;i?this.append(this.getFlushOp(i,s,n),i):this.sourceBuffers.forEach(([r])=>{r&&this.append(this.getFlushOp(r,s,n),r)})}onFragParsed(e,t){const{frag:i,part:s}=t,n=[],r=s?s.elementaryStreams:i.elementaryStreams;r[ke.AUDIOVIDEO]?n.push("audiovideo"):(r[ke.AUDIO]&&n.push("audio"),r[ke.VIDEO]&&n.push("video"));const o=()=>{const u=self.performance.now();i.stats.buffering.end=u,s&&(s.stats.buffering.end=u);const l=s?s.stats:i.stats;this.hls.trigger(g.FRAG_BUFFERED,{frag:i,part:s,stats:l,id:i.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(o,n).catch(u=>{this.warn(`Fragment buffered callback ${u}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){const t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}onBufferEos(e,t){var i;this.sourceBuffers.forEach(([r])=>{if(r){const o=this.tracks[r];(!t.type||t.type===r)&&(o.ending=!0,o.ended||(o.ended=!0,this.log(`${r} buffer reached EOS`)))}});const s=((i=this.overrides)==null?void 0:i.endOfStream)!==!1;this.sourceBufferCount>0&&!this.sourceBuffers.some(([r])=>{var o;return r&&!((o=this.tracks[r])!=null&&o.ended)})?s?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),r.endOfStream(),this.hls.trigger(g.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(g.BUFFERED_TO_END,void 0)):t.type==="video"&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([e])=>{if(e!==null){const t=this.tracks[e];t&&(t.ending=!1)}})}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}onError(e,t){if(t.details===A.BUFFER_APPEND_ERROR&&t.frag){var i;const s=(i=t.errorAction)==null?void 0:i.nextAutoLevel;_(s)&&s!==t.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:e,details:t,media:i}=this;if(!i||t===null||!this.sourceBufferCount)return;const s=e.config,n=i.currentTime,r=t.levelTargetDuration,o=t.live&&s.liveBackBufferLength!==null?s.liveBackBufferLength:s.backBufferLength;if(_(o)&&o>=0){const l=Math.max(o,r),c=Math.floor(n/r)*r-l;this.flushBackBuffer(n,r,c)}const u=s.frontBufferFlushThreshold;if(_(u)&&u>0){const l=Math.max(s.maxBufferLength,u),c=Math.max(l,r),h=Math.floor(n/r)*r+c;this.flushFrontBuffer(n,r,h)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([s,n])=>{if(n){const o=Yt.getBuffered(n);if(o.length>0&&i>o.start(0)){var r;this.hls.trigger(g.BACK_BUFFER_REACHED,{bufferEnd:i});const u=this.tracks[s];if((r=this.details)!=null&&r.live)this.hls.trigger(g.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(u!=null&&u.ended){this.log(`Cannot flush ${s} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(g.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:s})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([s,n])=>{if(n){const r=Yt.getBuffered(n),o=r.length;if(o<2)return;const u=r.start(o-1),l=r.end(o-1);if(i>u||e>=u&&e<=l)return;this.hls.trigger(g.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:s})}})}getDurationAndRange(){var e;const{details:t,mediaSource:i}=this;if(!t||!this.media||(i==null?void 0:i.readyState)!=="open")return null;const s=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){const l=Math.max(0,t.fragmentStart),c=Math.max(l,s);return{duration:1/0,start:l,end:c}}return{duration:1/0}}const n=(e=this.overrides)==null?void 0:e.duration;if(n)return _(n)?{duration:n}:null;const r=this.media.duration,o=_(i.duration)?i.duration:0;return s>o&&s>r||!_(r)?{duration:s}:null}updateMediaSource({duration:e,start:t,end:i}){const s=this.mediaSource;!this.media||!s||s.readyState!=="open"||(s.duration!==e&&(_(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),s.duration=e),t!==void 0&&i!==void 0&&(this.log(`MediaSource duration is set to ${s.duration}. Setting seekable range to ${t}-${i}.`),s.setLiveSeekableRange(t,i)))}get tracksReady(){const e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:e,pendingTrackCount:t,tracks:i}=this;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${Q(i)}`),this.tracksReady){var s;const n=(s=this.transferData)==null?void 0:s.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const e={};this.sourceBuffers.forEach(([t,i])=>{if(t){const s=this.tracks[t];e[t]={buffer:i,container:s.container,codec:s.codec,supplemental:s.supplemental,levelCodec:s.levelCodec,id:s.id,metadata:s.metadata}}}),this.hls.trigger(g.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}createSourceBuffers(){const{tracks:e,sourceBuffers:t,mediaSource:i}=this;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(const n in e){const r=n,o=e[r];if(this.isPending(o)){const u=this.getTrackCodec(o,r),l=`${o.container};codecs=${u}`;o.codec=u,this.log(`creating sourceBuffer(${l})${this.currentOp(r)?" Queued":""} ${Q(o)}`);try{const c=i.addSourceBuffer(l),h=Ea(r),m=[r,c];t[h]=m,o.buffer=c}catch(c){var s;this.error(`error while trying to add sourceBuffer: ${c.message}`),this.shiftAndExecuteNext(r),(s=this.operationQueue)==null||s.removeBlockers(),delete this.tracks[r],this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,sourceBufferName:r,mimeType:l,parent:o.id});return}this.trackSourceBuffer(r,o)}}this.bufferCreated()}getTrackCodec(e,t){const i=e.supplemental;let s=e.codec;i&&(t==="video"||t==="audiovideo")&&ui(i,"video")&&(s=Ft(s,i));const n=si(s,e.levelCodec);return n?t.slice(0,5)==="audio"?Ii(n,this.appendSource):n:""}trackSourceBuffer(e,t){const i=t.buffer;if(!i)return;const s=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:s,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(n,r)=>{const o=r.removedRanges;o!=null&&o.length&&this.hls.trigger(g.BUFFER_FLUSHED,{type:n})})}get mediaSrc(){var e,t;const i=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return i==null?void 0:i.src}onSBUpdateStart(e){const t=this.currentOp(e);t&&t.onStart()}onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}onSBUpdateError(e,t){var i;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(i=this.mediaSource)==null?void 0:i.readyState}`);this.error(`${s}`,t),this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const n=this.currentOp(e);n&&n.onError(s)}updateTimestampOffset(e,t,i,s,n,r){const o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${s} SourceBuffer timestampOffset to ${t} (sn: ${n} cc: ${r})`),e.timestampOffset=t)}removeExecutor(e,t,i){const{media:s,mediaSource:n}=this,r=this.tracks[e],o=r==null?void 0:r.buffer;if(!s||!n||!o){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),this.shiftAndExecuteNext(e);return}const u=_(s.duration)?s.duration:1/0,l=_(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(i,u,l);h>c&&(!r.ending||r.ended)?(r.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),o.remove(c,h)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],s=i==null?void 0:i.buffer;if(!s)throw new Ru(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,s.appendBuffer(e)}blockUntilOpen(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}isQueued(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}isPending(e){return!!e&&!e.buffer}blockBuffers(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);const{operationQueue:i}=this,s=t.map(r=>this.appendBlocker(r));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(s).then(r=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(e){e.forEach(t=>{var i;const s=(i=this.tracks[t])==null?void 0:i.buffer;!s||s.updating||this.shiftAndExecuteNext(t)})}append(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}appendBlocker(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}currentOp(e){return this.operationQueue?this.operationQueue.current(e):null}executeNext(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}shiftAndExecuteNext(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}addBufferListener(e,t,i){const s=this.tracks[e];if(!s)return;const n=s.buffer;if(!n)return;const r=i.bind(this,e);s.listeners.push({event:t,listener:r}),n.addEventListener(t,r)}removeBufferListeners(e){const t=this.tracks[e];if(!t)return;const i=t.buffer;i&&(t.listeners.forEach(s=>{i.removeEventListener(s.event,s.listener)}),t.listeners.length=0)}}function xo(a){const e=a.querySelectorAll("source");[].slice.call(e).forEach(t=>{a.removeChild(t)})}function Cu(a,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,a.appendChild(t)}function Ea(a){return a==="audio"?1:0}class _a{constructor(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=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(g.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.BUFFER_CODECS,this.onBufferCodecs,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(g.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&_(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,_a.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(t){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const s=(o,u)=>u?o.width!==u.width||o.height!==u.height:!0;let n=e.length-1;const r=Math.max(t,i);for(let o=0;o<e.length;o+=1){const u=e[o];if((u.width>=r||u.height>=r)&&s(u,e[o+1])){n=o;break}}return n}}const Ms={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Du={HLS:"h"};class hn{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof hn?i:new hn(i))),this.value=e,this.params=t}}const wu="Dict";function ku(a){return Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":typeof a=="object"?JSON.stringify(a):String(a)}function Pu(a,e,t,i){return new Error(`failed to ${a} "${ku(e)}" as ${t}`,{cause:i})}function fn(a,e,t){return Pu("serialize",a,e,t)}class Ao{constructor(e){this.description=e}}const Io="Bare Item",Ou="Boolean";function Mu(a){if(typeof a!="boolean")throw fn(a,Ou);return a?"?1":"?0"}function Fu(a){return btoa(String.fromCharCode(...a))}const Bu="Byte Sequence";function Nu(a){if(ArrayBuffer.isView(a)===!1)throw fn(a,Bu);return`:${Fu(a)}:`}const $u="Integer";function Uu(a){return a<-999999999999999||999999999999999<a}function Ro(a){if(Uu(a))throw fn(a,$u);return a.toString()}function Gu(a){return`@${Ro(a.getTime()/1e3)}`}function Lo(a,e){if(a<0)return-Lo(-a,e);const t=Math.pow(10,e);if(Math.abs(a*t%1-.5)<Number.EPSILON){const s=Math.floor(a*t);return(s%2===0?s:s+1)/t}else return Math.round(a*t)/t}const Ku="Decimal";function Vu(a){const e=Lo(a,3);if(Math.floor(Math.abs(e)).toString().length>12)throw fn(a,Ku);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Hu="String",ju=/[\x00-\x1f\x7f]+/;function zu(a){if(ju.test(a))throw fn(a,Hu);return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Wu(a){return a.description||a.toString().slice(7,-1)}const Zu="Token";function Co(a){const e=Wu(a);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw fn(e,Zu);return e}function Sa(a){switch(typeof a){case"number":if(!_(a))throw fn(a,Io);return Number.isInteger(a)?Ro(a):Vu(a);case"string":return zu(a);case"symbol":return Co(a);case"boolean":return Mu(a);case"object":if(a instanceof Date)return Gu(a);if(a instanceof Uint8Array)return Nu(a);if(a instanceof Ao)return Co(a);default:throw fn(a,Io)}}const Yu="Key";function ba(a){if(/^[a-z*][a-z0-9\-_.*]*$/.test(a)===!1)throw fn(a,Yu);return a}function Ta(a){return a==null?"":Object.entries(a).map(([e,t])=>t===!0?`;${ba(e)}`:`;${ba(e)}=${Sa(t)}`).join("")}function Do(a){return a instanceof hn?`${Sa(a.value)}${Ta(a.params)}`:Sa(a)}function Xu(a){return`(${a.value.map(Do).join(" ")})${Ta(a.params)}`}function qu(a,e={whitespace:!0}){if(typeof a!="object"||a==null)throw fn(a,wu);const t=a instanceof Map?a.entries():Object.entries(a),i=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof hn||(n=new hn(n));let r=ba(s);return n.value===!0?r+=Ta(n.params):(r+="=",Array.isArray(n.value)?r+=Xu(n):r+=Do(n)),r}).join(`,${i}`)}function wo(a,e){return qu(a,e)}const mn="CMCD-Object",ss="CMCD-Request",wn="CMCD-Session",In="CMCD-Status",Qu={br:mn,ab:mn,d:mn,ot:mn,tb:mn,tpb:mn,lb:mn,tab:mn,lab:mn,url:mn,pb:ss,bl:ss,tbl:ss,dl:ss,ltc:ss,mtp:ss,nor:ss,nrr:ss,rc:ss,sn:ss,sta:ss,su:ss,ttfb:ss,ttfbb:ss,ttlb:ss,cmsdd:ss,cmsds:ss,smrt:ss,df:ss,cs:ss,ts:ss,cid:wn,pr:wn,sf:wn,sid:wn,st:wn,v:wn,msd:wn,bs:In,bsd:In,cdn:In,rtp:In,bg:In,pt:In,ec:In,e:In},Ju={REQUEST:ss};function ec(a){return Object.keys(a).reduce((e,t)=>{var i;return(i=a[t])===null||i===void 0||i.forEach(s=>e[s]=t),e},{})}function tc(a,e){const t={};if(!a)return t;const i=Object.keys(a),s=e?ec(e):{};return i.reduce((n,r)=>{var o;const u=Qu[r]||s[r]||Ju.REQUEST,l=(o=n[u])!==null&&o!==void 0?o:n[u]={};return l[r]=a[r],n},t)}function ic(a){return["ot","sf","st","e","sta"].includes(a)}function sc(a){return typeof a=="number"?_(a):a!=null&&a!==""&&a!==!1}const ko="event";function nc(a,e){const t=new URL(a),i=new URL(e);if(t.origin!==i.origin)return a;const s=t.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")+t.search+t.hash}const Pr=a=>Math.round(a),xa=(a,e)=>Array.isArray(a)?a.map(t=>xa(t,e)):a instanceof hn&&typeof a.value=="string"?new hn(xa(a.value,e),a.params):(e.baseUrl&&(a=nc(a,e.baseUrl)),e.version===1?encodeURIComponent(a):a),Or=a=>Pr(a/100)*100,rc={br:Pr,d:Pr,bl:Or,dl:Or,mtp:Or,nor:(a,e)=>{let t=a;return e.version>=2&&(a instanceof hn&&typeof a.value=="string"?t=new hn([a]):typeof a=="string"&&(t=[a])),xa(t,e)},rtp:Or,tb:Pr},Po="request",Oo="response",Aa=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],ac=["e"],oc=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Mr(a){return oc.test(a)}function lc(a){return Aa.includes(a)||ac.includes(a)||Mr(a)}const Mo=["d","dl","nor","ot","rtp","su"];function uc(a){return Aa.includes(a)||Mo.includes(a)||Mr(a)}const cc=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];function dc(a){return Aa.includes(a)||Mo.includes(a)||cc.includes(a)||Mr(a)}const hc=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function fc(a){return hc.includes(a)||Mr(a)}const mc={[Oo]:dc,[ko]:lc,[Po]:uc};function Fo(a,e={}){const t={};if(a==null||typeof a!="object")return t;const i=e.version||a.v||1,s=e.reportingMode||Po,n=i===1?fc:mc[s];let r=Object.keys(a).filter(n);const o=e.filter;typeof o=="function"&&(r=r.filter(o));const u=s===Oo||s===ko;u&&!r.includes("ts")&&r.push("ts"),i>1&&!r.includes("v")&&r.push("v");const l=Ie({},rc,e.formatters),c={version:i,reportingMode:s,baseUrl:e.baseUrl};return r.sort().forEach(h=>{let m=a[h];const v=l[h];if(typeof v=="function"&&(m=v(m,c)),h==="v"){if(i===1)return;m=i}h=="pr"&&m===1||(u&&h==="ts"&&!_(m)&&(m=Date.now()),sc(m)&&(ic(h)&&typeof m=="string"&&(m=new Ao(m)),t[h]=m))}),t}function gc(a,e={}){const t={};if(!a)return t;const i=Fo(a,e),s=tc(i,e==null?void 0:e.customHeaderMap);return Object.entries(s).reduce((n,[r,o])=>{const u=wo(o,{whitespace:!1});return u&&(n[r]=u),n},t)}function pc(a,e,t){return Ie(a,gc(e,t))}const vc="CMCD";function yc(a,e={}){return a?wo(Fo(a,e),{whitespace:!1}):""}function Ec(a,e={}){if(!a)return"";const t=yc(a,e);return encodeURIComponent(t)}function _c(a,e={}){if(!a)return"";const t=Ec(a,e);return`${vc}=${t}`}const Bo=/CMCD=[^&#]+/;function Sc(a,e,t){const i=_c(e,t);if(!i)return a;if(Bo.test(a))return a.replace(Bo,i);const s=a.includes("?")?"&":"?";return`${a}${s}${i}`}class bc{constructor(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=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Ms.MANIFEST,su:!this.initialized})}catch(n){this.hls.logger.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{const{frag:n,part:r}=s,o=this.hls.levels[n.level],u=this.getObjectType(n),l={d:(r||n).duration*1e3,ot:u};(u===Ms.VIDEO||u===Ms.AUDIO||u==Ms.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(u)/1e3,l.bl=this.getBufferLength(u));const c=r?this.getNextPart(r):this.getNextFrag(n);c!=null&&c.url&&c.url!==n.url&&(l.nor=c.url),this.apply(s,l)}catch(n){this.hls.logger.warn("Could not generate segment CMCD data.",n)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||e.sessionId,this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHED,this.onMediaDetached,this),e.on(g.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHED,this.onMediaDetached,this),e.off(g.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,s;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:Du.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ie(t,this.createData());const i=t.ot===Ms.INIT||t.ot===Ms.VIDEO||t.ot===Ms.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((r,o)=>(s.includes(o)&&(r[o]=t[o]),r),{}));const n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),pc(e.headers,t,n)):e.url=Sc(e.url,t,n)}getNextFrag(e){var t;const i=(t=this.hls.levels[e.level])==null?void 0:t.details;if(i){const s=e.sn-i.startSN;return i.fragments[s+1]}}getNextPart(e){var t;const{index:i,fragment:s}=e,n=(t=this.hls.levels[s.level])==null||(t=t.details)==null?void 0:t.partList;if(n){const{sn:r}=s;for(let o=n.length-1;o>=0;o--){const u=n[o];if(u.index===i&&u.fragment.sn===r)return n[o+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Ms.TIMED_TEXT;if(e.sn==="initSegment")return Ms.INIT;if(t==="audio")return Ms.AUDIO;if(t==="main")return this.hls.audioTracks.length?Ms.VIDEO:Ms.MUXED}getTopBandwidth(e){let t=0,i;const s=this.hls;if(e===Ms.AUDIO)i=s.audioTracks;else{const n=s.maxAutoLevel,r=n>-1?n+1:s.levels.length;i=s.levels.slice(0,r)}return i.forEach(n=>{n.bitrate>t&&(t=n.bitrate)}),t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===Ms.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:Yt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,r,o){t(n),this.loader.load(n,r,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,r,o){t(n),this.loader.load(n,r,o)}}}}const Tc=3e5;class xc extends Ce{constructor(e){super("content-steering",e.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((e,t)=>(e.indexOf(t.pathwayId)===-1&&e.push(t.pathwayId),e),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(e){this.updatePathwayPriority(e)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if((i==null?void 0:i.action)===Ci.SendAlternateToPenaltyBox&&i.flags===Di.MoveAllAlternatesMatchingHost){const s=this.levels;let n=this._pathwayPriority,r=this.pathwayId;if(t.context){const{groupId:o,pathwayId:u,type:l}=t.context;o&&s?r=this.getPathwayForGroupId(o,l,r):u&&(r=u)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!n&&s&&(n=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==r),t.details===A.BUFFER_APPEND_ERROR&&!t.fatal?i.resolved=!0:i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${s&&s.length} priorities: ${Q(n)} penalized: ${Q(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this._pathwayPriority=e;let t;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(n=>{s-i[n]>Tc&&delete i[n]});for(let n=0;n<e.length;n++){const r=e[n];if(r in i)continue;if(r===this.pathwayId)return;const o=this.hls.nextLoadLevel,u=this.hls.levels[o];if(t=this.getLevelsForPathway(r),t.length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,Ts(t),this.hls.trigger(g.LEVELS_UPDATED,{levels:t});const l=this.hls.levels[o];u&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==u.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==u.bitrate&&this.log(`Unstable Pathways change from bitrate ${u.bitrate} to ${l.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,i){const s=this.getLevelsForPathway(i).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===te.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===te.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return i}clonePathways(e){const t=this.levels;if(!t)return;const i={},s={};e.forEach(n=>{const{ID:r,"BASE-ID":o,"URI-REPLACEMENT":u}=n;if(t.some(c=>c.pathwayId===r))return;const l=this.getLevelsForPathway(o).map(c=>{const h=new Fi(c.attrs);h["PATHWAY-ID"]=r;const m=h.AUDIO&&`${h.AUDIO}_clone_${r}`,v=h.SUBTITLES&&`${h.SUBTITLES}_clone_${r}`;m&&(i[h.AUDIO]=m,h.AUDIO=m),v&&(s[h.SUBTITLES]=v,h.SUBTITLES=v);const y=$o(c.uri,h["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u),b=new mi({attrs:h,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:y,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let S=1;S<c.audioGroups.length;S++)b.addGroupId("audio",`${c.audioGroups[S]}_clone_${r}`);if(c.subtitleGroups)for(let S=1;S<c.subtitleGroups.length;S++)b.addGroupId("text",`${c.subtitleGroups[S]}_clone_${r}`);return b});t.push(...l),No(this.audioTracks,i,u,r),No(this.subtitleTracks,s,u,r)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let s;try{s=new self.URL(e)}catch(c){this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+c)}const n={responseType:"json",url:s.href},r=t.steeringManifestLoadPolicy.default,o=r.errorRetry||r.timeoutRetry||{},u={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,h,m,v)=>{this.log(`Loaded steering manifest: "${s}"`);const y=c.data;if((y==null?void 0:y.VERSION)!==1){this.log(`Steering VERSION ${y.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=y.TTL;const{"RELOAD-URI":b,"PATHWAY-CLONES":S,"PATHWAY-PRIORITY":I}=y;if(b)try{this.uri=new self.URL(b,s).href}catch(L){this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${b}`);return}this.scheduleRefresh(this.uri||m.url),S&&this.clonePathways(S);const R={steeringManifest:y,url:s.toString()};this.hls.trigger(g.STEERING_MANIFEST_LOADED,R),I&&this.updatePathwayPriority(I)},onError:(c,h,m,v)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${h.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${h.url} no longer available`);return}let y=this.timeToLoad*1e3;if(c.code===429){const b=this.loader;if(typeof(b==null?void 0:b.getResponseHeader)=="function"){const S=b.getResponseHeader("Retry-After");S&&(y=parseFloat(S)*1e3)}this.log(`Steering manifest ${h.url} rate limited`);return}this.scheduleRefresh(this.uri||h.url,y)},onTimeout:(c,h,m)=>{this.log(`Timeout loading steering manifest (${h.url})`),this.scheduleRefresh(this.uri||h.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,u,l)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var i;const s=(i=this.hls)==null?void 0:i.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function No(a,e,t,i){a&&Object.keys(e).forEach(s=>{const n=a.filter(r=>r.groupId===s).map(r=>{const o=Ie({},r);return o.details=void 0,o.attrs=new Fi(o.attrs),o.url=o.attrs.URI=$o(r.url,r.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=i,o});a.push(...n)})}function $o(a,e,t,i){const{HOST:s,PARAMS:n,[t]:r}=i;let o;e&&(o=r==null?void 0:r[e],o&&(a=o));const u=new self.URL(a);return s&&!o&&(u.host=s),n&&Object.keys(n).sort().forEach(l=>{l&&u.searchParams.set(l,n[l])}),u.href}class Vn extends Ce{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Vn.CDMCleanupPromise?[Vn.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:i,initData:s}=t,n=`"${t.type}" event: init data type: "${i}"`;if(this.debug(n),s!==null){if(!this.keyFormatPromise){let r=Object.keys(this.keySystemAccessPromises);r.length||(r=cn(this.config));const o=r.map(Ss).filter(u=>!!u);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(r=>{const o=Zs(r);if(i!=="sinf"||o!==ai.FAIRPLAY){this.log(`Ignoring "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}let u;try{const v=Le(new Uint8Array(s)),y=pn(JSON.parse(v).sinf),b=ot(y);if(!b)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");u=new Uint8Array(b.subarray(8,24))}catch(v){this.warn(`${n} Failed to parse sinf: ${v}`);return}const l=ne(u),{keyIdToKeySessionPromise:c,mediaKeySessions:h}=this;let m=c[l];for(let v=0;v<h.length;v++){const y=h[v],b=y.decryptdata;if(!b.keyId)continue;const S=ne(b.keyId);if(ms(u,b.keyId)||b.uri.replace(/-/g,"").indexOf(l)!==-1){if(m=c[S],!m)continue;if(b.pssh)break;delete c[S],b.pssh=new Uint8Array(s),b.keyId=u,m=c[l]=m.then(()=>this.generateRequestWithPreferredKeySession(y,i,s,"encrypted-event-key-match")),m.catch(I=>this.handleError(I));break}}m||this.handleError(new Error(`Key ID ${l} not encountered in playlist. Key-system sessions ${h.length}.`))}).catch(r=>this.handleError(r))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const 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}registerListeners(){this.hls.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(g.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(g.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(g.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(g.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(g.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(g.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t==null?void 0:t[e];if(s)return s.licenseUrl;if(e===ai.WIDEVINE&&i)return i}getLicenseServerUrlOrThrow(e){const t=this.getLicenseServerUrl(e);if(t===void 0)throw new Error(`no license server URL configured for key-system "${e}"`);return t}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t==null?void 0:t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(r,o,u)=>!!r&&u.indexOf(r)===o,s=t.map(r=>r.audioCodec).filter(i),n=t.map(r=>r.videoCodec).filter(i);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((r,o)=>{const u=l=>{const c=l.shift();this.getMediaKeysPromise(c,s,n).then(h=>r({keySystem:c,mediaKeys:h})).catch(h=>{l.length?u(l):h instanceof Hs?o(h):o(new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_ACCESS,error:h,fatal:!0},h.message))})};u(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return vn===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(e,t)}getMediaKeysPromise(e,t,i){var s;const n=hr(e,t,i,this.config.drmSystemOptions||{});let r=this.keySystemAccessPromises[e],o=(s=r)==null?void 0:s.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${Q(n)}`),o=this.requestMediaKeySystemAccess(e,n);const u=r=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),o.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);const h=u.mediaKeys=l.createMediaKeys().then(m=>(this.log(`Media-keys created for "${e}"`),u.hasMediaKeys=!0,c.then(v=>v?this.setMediaKeysServerCertificate(m,e,v):m)));return h.catch(m=>{this.error(`Failed to create media-keys for "${e}"}: ${m}`)}),h})}return o.then(()=>r.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${ne(e.keyId||[])} keyUri: ${e.uri}`);const s=i.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),s=Fr(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,n,t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}updateKeySession(e,t){const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${ne(e.decryptdata.keyId||[])}
} (data length: ${t.byteLength})`),i.update(t)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>Ss(e)).filter(e=>!!e)}getKeySystemAccess(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:t,mediaKeys:i})=>this.attemptSetMediaKeys(t,i))}selectKeySystem(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:s})=>{const n=Ss(s);n?t(n):i(new Error(`Unable to find format for key-system "${s}"`))}).catch(i)})}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){const t=cn(this.config),i=e.map(Zs).filter(s=>!!s&&t.indexOf(s)!==-1);return this.selectKeySystem(i)}getKeyStatus(e){const{mediaKeySessions:t}=this;for(let i=0;i<t.length;i++){const s=Ac(e,t[i]);if(s)return s}}loadKey(e){const t=e.keyInfo.decryptdata,i=Fr(t),s=this.bannedKeyIds[i];if(s||this.getKeyStatus(t)==="internal-error"){const o=Uo(s||"internal-error",t);return this.handleError(o,e.frag),Promise.reject(o)}const n=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);const r=this.keyIdToKeySessionPromise[i];if(!r){const o=this.getKeySystemForKeyPromise(t).then(({keySystem:u,mediaKeys:l})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(u,l).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:u,mediaKeys:l,decryptdata:t}))))).then(u=>{const l="cenc",c=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(u,l,c,"playlist-key")});return o.catch(u=>this.handleError(u,e.frag)),this.keyIdToKeySessionPromise[i]=o,o}return r.catch(o=>{if(o instanceof Hs){const u=H({},o.data);this.getKeyStatus(t)==="internal-error"&&(u.decryptdata=t);const l=new Hs(u,o.message);this.handleError(l,e.frag)}}),r}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e,t){if(this.hls)if(e instanceof Hs){t&&(e.data.frag=t);const i=e.data.decryptdata;this.error(`${e.message}${i?` (${ne(i.keyId||[])})`:""}`),this.hls.trigger(g.ERROR,e.data)}else this.error(e.message),this.hls.trigger(g.ERROR,{type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}getKeySystemForKeyPromise(e){const t=Fr(e),i=this.keyIdToKeySessionPromise[t];if(!i){const s=Zs(e.keyFormat),n=s?[s]:cn(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=cn(this.config)),e.length===0)throw new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${Q({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((n,r)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return r(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(n).catch(r)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>i.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,i,s){var n;const r=(n=this.config.drmSystems)==null||(n=n[e.keySystem])==null?void 0:n.generateRequest;if(r)try{const y=r.call(this.hls,t,i,e);if(!y)throw new Error("Invalid response from configured generateRequest filter");t=y.initDataType,i=y.initData?y.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(y){if(this.warn(y.message),this.hls&&this.hls.config.debug)throw y}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const o=Fr(e.decryptdata),u=e.decryptdata.uri;this.log(`Generating key-session request for "${s}" keyId: ${o} URI: ${u} (init data type: ${t} length: ${i.byteLength})`);const l=new na,c=e._onmessage=y=>{const b=e.mediaKeysSession;if(!b){l.emit("error",new Error("invalid state"));return}const{messageType:S,message:I}=y;this.log(`"${S}" message event for session "${b.sessionId}" message size: ${I.byteLength}`),S==="license-request"||S==="license-renewal"?this.renewLicense(e,I).catch(R=>{l.eventNames().length?l.emit("error",R):this.handleError(R)}):S==="license-release"?e.keySystem===ai.FAIRPLAY&&this.updateKeySession(e,sn("acknowledged")).then(()=>this.removeSession(e)).catch(R=>this.handleError(R)):this.warn(`unhandled media key message type "${S}"`)},h=(y,b)=>{b.keyStatus=y;let S;y.startsWith("usable")?l.emit("resolved"):y==="internal-error"||y==="output-restricted"||y==="output-downscaled"?S=Uo(y,b.decryptdata):y==="expired"?S=new Error(`key expired (keyId: ${o})`):y==="released"?S=new Error("key released"):y==="status-pending"||this.warn(`unhandled key status change "${y}" (keyId: ${o})`),S&&(l.eventNames().length?l.emit("error",S):this.handleError(S))},m=e._onkeystatuseschange=y=>{if(!e.mediaKeysSession){l.emit("error",new Error("invalid state"));return}const S=this.getKeyStatuses(e);if(!Object.keys(S).some(B=>S[B]!=="status-pending"))return;if(S[o]==="expired"){this.log(`Expired key ${Q(S)} in key-session "${e.mediaKeysSession.sessionId}"`),this.renewKeySession(e);return}let R=S[o];if(R)h(R,e);else{var L;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(L=e.keyStatusTimeouts)[o]||(L[o]=self.setTimeout(()=>{if(!e.mediaKeysSession||!this.mediaKeys)return;const j=this.getKeyStatus(e.decryptdata);if(j&&j!=="status-pending")return this.log(`No status for keyId ${o} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${j} from other session.`),h(j,e);this.log(`key status for ${o} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),R="internal-error",h(R,e)},1e3)),this.log(`No status for keyId ${o} (${Q(S)}).`)}};ws(e.mediaKeysSession,"message",c),ws(e.mediaKeysSession,"keystatuseschange",m);const v=new Promise((y,b)=>{l.on("error",b),l.on("resolved",y)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${o} URI: ${u}`)}).catch(y=>{throw new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_SESSION,error:y,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${y}`)}).then(()=>v).catch(y=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw y}))).then(()=>(l.removeAllListeners(),e))}getKeyStatuses(e){const t={};return e.mediaKeysSession.keyStatuses.forEach((i,s)=>{if(typeof s=="string"&&typeof i=="object"){const o=s;s=i,i=o}const n="buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s);if(e.keySystem===ai.PLAYREADY&&n.length===16){const o=ne(n);t[o]=i,At(n)}const r=ne(n);i==="internal-error"&&(this.bannedKeyIds[r]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${r} key-session "${e.mediaKeysSession.sessionId}"`),t[r]=i}),t}fetchServerCertificate(e){const t=this.config,i=t.loader,s=new i(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((r,o)=>{const u={responseType:"arraybuffer",url:n},l=t.certLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(m,v,y,b)=>{r(m.data)},onError:(m,v,y,b)=>{o(new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:y,response:H({url:u.url,data:void 0},m)},`"${e}" certificate request failed (${n}). Status: ${m.code} (${m.text})`))},onTimeout:(m,v,y)=>{o(new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:y,response:{url:u.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(m,v,y)=>{o(new Error("aborted"))}};s.load(u,c,h)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((s,n)=>{e.setServerCertificate(i).then(r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),s(e)}).catch(r=>{n(new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:r,fatal:!0},r.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(s=>{throw new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:s,fatal:!1},s.message)}))}unpackPlayReadyKeyMessage(e,t){const i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=new DOMParser().parseFromString(i,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let h=0,m=n.length;h<m;h++){var r,o;c=n[h];const v=(r=c.querySelector("name"))==null?void 0:r.textContent,y=(o=c.querySelector("value"))==null?void 0:o.textContent;v&&y&&e.setRequestHeader(v,y)}}const u=s.querySelector("Challenge"),l=u==null?void 0:u.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return sn(atob(l))}setupLicenseXHR(e,t,i,s){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,i,s)}).catch(r=>{if(!i.decryptdata)throw r;return e.open("POST",t,!0),n.call(this.hls,e,t,i,s)}).then(r=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{const r=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${r}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let u=o.response;this.log(`License received ${u instanceof ArrayBuffer?u.byteLength:u}`);const l=this.config.licenseResponseCallback;if(l)try{u=l.call(this.hls,o,r,e)}catch(c){this.error(c)}s(u)}else{const u=i.errorRetry,l=u?u.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)n(new Hs({type:Y.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:r,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${r}). Status: ${o.status} (${o.statusText})`));else{const c=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,r,e,t).then(({xhr:u,licenseChallenge:l})=>{e.keySystem==ai.PLAYREADY&&(l=this.unpackPlayReadyKeyMessage(u,l)),u.send(l)}).catch(n)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,ws(i,"encrypted",this.onMediaEncrypted),ws(i,"waitingforkey",this.onWaitingForKey);const s=this.mediaResolved;s?s():this.mediaKeys=i.mediaKeys}onMediaDetached(){const e=this.media;e&&(Os(e,"encrypted",this.onMediaEncrypted),Os(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var e;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const t=this.mediaResolved;if(t&&t(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const i=this.media,s=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,Us.clearKeyUriToKeyIdMap();const n=s.length;Vn.CDMCleanupPromise=Promise.all(s.map(r=>this.removeSession(r)).concat((i==null||(e=i.setMediaKeys(null))==null?void 0:e.catch(r=>{this.log(`Could not clear media keys: ${r}`),this.hls&&this.hls.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${r}`)})}))||Promise.resolve())).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`),this.hls&&this.hls.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${r}`)})}).then(()=>{n&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i,decryptdata:s}=e;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${ne((s==null?void 0:s.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);const{keyStatusTimeouts:r}=e;r&&Object.keys(r).forEach(l=>self.clearTimeout(r[l]));const{drmSystemOptions:o}=this.config;return(Zr(o)?new Promise((l,c)=>{self.setTimeout(()=>c(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(l).catch(c)}):Promise.resolve()).catch(l=>{this.log(`Could not remove session: ${l}`),this.hls&&this.hls.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${l}`)})}).then(()=>t.close()).catch(l=>{this.log(`Could not close session: ${l}`),this.hls&&this.hls.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${l}`)})})}return Promise.resolve()}}Vn.CDMCleanupPromise=void 0;function Fr(a){if(!a)throw new Error("Could not read keyId of undefined decryptdata");if(a.keyId===null)throw new Error("keyId is null");return ne(a.keyId)}function Ac(a,e){if(a.keyId&&e.mediaKeysSession.keyStatuses.has(a.keyId))return e.mediaKeysSession.keyStatuses.get(a.keyId);if(a.matches(e.decryptdata))return e.keyStatus}class Hs extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}function Uo(a,e){const t=a==="output-restricted",i=t?A.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:A.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Hs({type:Y.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},t?"HDCP level output restricted":`key status changed to "${a}"`)}class Ic{constructor(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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(g.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(g.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(e,t,i){const s=performance.now();if(t){if(this.lastTime){const n=s-this.lastTime,r=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,u=1e3*r/n,l=this.hls;if(l.trigger(g.FPS_DROP,{currentDropped:r,currentDecoded:o,totalDroppedFrames:i}),u>0&&r>l.config.fpsDroppedMonitoringThreshold*o){let c=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=c)&&(c=c-1,l.trigger(g.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:l.currentLevel}),l.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}function Go(a,e){let t;try{t=new Event("addtrack")}catch(i){t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=a,e.dispatchEvent(t)}function Ko(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues&&!a.cues.getCueById(e.id))try{if(a.addCue(e),!a.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){se.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,a.addCue(s)}catch(s){se.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(a.mode=t)}function Hn(a,e){const t=a.mode;if(t==="disabled"&&(a.mode="hidden"),a.cues)for(let i=a.cues.length;i--;)e&&a.cues[i].removeEventListener("enter",e),a.removeCue(a.cues[i]);t==="disabled"&&(a.mode=t)}function Ia(a,e,t,i){const s=a.mode;if(s==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0){const n=Lc(a.cues,e,t);for(let r=0;r<n.length;r++)(!i||i(n[r]))&&a.removeCue(n[r])}s==="disabled"&&(a.mode=s)}function Rc(a,e){if(e<=a[0].startTime)return 0;const t=a.length-1;if(e>a[t].endTime)return-1;let i=0,s=t,n;for(;i<=s;)if(n=Math.floor((s+i)/2),e<a[n].startTime)s=n-1;else if(e>a[n].startTime&&i<t)i=n+1;else return n;return a[i].startTime-e<e-a[s].startTime?i:s}function Lc(a,e,t){const i=[],s=Rc(a,e);if(s>-1)for(let n=s,r=a.length;n<r;n++){const o=a[n];if(o.startTime>=e&&o.endTime<=t)i.push(o);else if(o.startTime>t)return i}return i}function Br(a){const e=[];for(let t=0;t<a.length;t++){const i=a[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(a[t])}return e}class Cc extends va{constructor(e){super(e,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const i=Br(this.media.textTracks);for(let n=0;n<i.length;n++)if(i[n].mode==="hidden")t=i[n];else if(i[n].mode==="showing"){t=i[n];break}const s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(g.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(g.ERROR,this.onError,this)}onMediaAttached(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))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(e,t){const i=this.media;if(!i)return;const s=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,s)return;Br(i.textTracks).forEach(r=>{Hn(r)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,groupId:s,details:n}=t,r=this.tracksInGroup[i];if(!r||r.groupId!==s){this.warn(`Subtitle track with id:${i} and group:${s} not found in active group ${r==null?void 0:r.groupId}`);return}const o=r.details;r.details=t.details,this.log(`Subtitle track ${i} "${r.name}" lang:${r.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const i=t.subtitleGroups||null,s=this.groupIds;let n=this.currentTrack;if(!i||(s==null?void 0:s.length)!==(i==null?void 0:i.length)||i!=null&&i.some(r=>(s==null?void 0:s.indexOf(r))===-1)){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const r=this.tracks.filter(c=>!i||i.indexOf(c.groupId)!==-1);if(r.length)this.selectDefaultTrack&&!r.some(c=>c.default)&&(this.selectDefaultTrack=!1),r.forEach((c,h)=>{c.id=h});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=r;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const c=Qe(o,r);if(c>-1)n=r[c];else{const h=Qe(o,this.tracks);n=this.tracks[h]}}let u=this.findTrackId(n);u===-1&&n&&(u=this.findTrackId(null));const l={subtitleTracks:r};this.log(`Updating subtitle tracks, ${r.length} track(s) found in "${i==null?void 0:i.join(",")}" group-id`),this.hls.trigger(g.SUBTITLE_TRACKS_UPDATED,l),u!==-1&&this.trackId===-1&&this.setSubtitleTrack(u)}}findTrackId(e){const t=this.tracksInGroup,i=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const n=t[s];if(!(i&&!n.default||!i&&!e)&&(!e||Kt(n,e)))return s}if(e){for(let s=0;s<t.length;s++){const n=t[s];if(lr(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const n=t[s];if(lr(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const s=t[i];if(ya(s,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===te.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){if(e.id===-1)return this.setSubtitleTrack(-1),null;const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const i=this.currentTrack;if(i&&Kt(e,i))return i;const s=Qe(e,this.tracksInGroup);if(s>-1){const n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(i)return null;{const n=Qe(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=e.id,s=e.groupId,n=this.getUrlWithDirectives(e.url,t),r=e.details,o=r==null?void 0:r.age;this.log(`Loading subtitle ${i} "${e.name}" lang:${e.lang} group:${s}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${o&&r.live?" age "+o.toFixed(1)+(r.type?" "+r.type||0:""):""} ${n}`),this.hls.trigger(g.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Br(e.textTracks),i=this.currentTrack;let s;if(i&&(s=t.filter(n=>ya(i,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){const n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!_(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.selectDefaultTrack=!1;const i=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(g.SUBTITLE_TRACK_SWITCH,{id:e});return}const n=!!s.details&&!s.details.live;if(e===this.trackId&&s===i&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));const{id:r,groupId:o="",name:u,type:l,url:c}=s;this.hls.trigger(g.SUBTITLE_TRACK_SWITCH,{id:r,groupId:o,name:u,type:l,url:c});const h=this.switchParams(s.url,i==null?void 0:i.details,s.details);this.loadPlaylist(h)}}function Dc(){try{return crypto.randomUUID()}catch(a){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}function ur(a){let e=5381,t=a.length;for(;t;)e=e*33^a.charCodeAt(--t);return(e>>>0).toString()}const jn=.025;let Nr=function(a){return a[a.Point=0]="Point",a[a.Range=1]="Range",a}({});function wc(a,e,t){return`${a.identifier}-${t+1}-${ur(e)}`}class kc{constructor(e,t){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.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}setDateRange(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)}reset(){var e;this.appendInPlaceStarted=!1,(e=this.assetListLoader)==null||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(e){var t;if(e>0&&e>=this.assetList.length)return!0;const i=this.playoutLimit;return e<=0||isNaN(i)?!1:i===0?!0:(((t=this.assetList[e])==null?void 0:t.startOffset)||0)>i}findAssetIndex(e){return this.assetList.indexOf(e)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const e=this.dateRange.startTime;if(this.snapOptions.out){const t=this.dateRange.tagAnchor;if(t)return Ra(e,t)}return e}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(this.startTime===0||this.snapOptions.out)return!0;const e=this.dateRange.tagAnchor;if(e){const t=this.dateRange.startTime,i=Ra(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=_(e)?e:this.duration;return this.cumulativeDuration+t}get resumeTime(){const e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const t=this.resumeAnchor;if(t)return Ra(e,t)}return e}get appendInPlace(){return this.appendInPlaceStarted?!0:this.appendInPlaceDisabled?!1:!!(!this.cue.once&&!this.cue.pre&&this.startIsAligned&&(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<jn))}set appendInPlace(e){if(this.appendInPlaceStarted){this.resetOnResume=!e;return}this.appendInPlaceDisabled=!e}get timelineStart(){return this._timelineStart!==null?this._timelineStart:this.startTime}set timelineStart(e){this._timelineStart=e}get duration(){const e=this.playoutLimit;let t;return this._duration!==null?t=this._duration:this.dateRange.duration?t=this.dateRange.duration:t=this.dateRange.plannedDuration||0,!isNaN(e)&&e<t&&(t=e),t}set duration(e){this._duration=e}get cue(){return this.dateRange.cue}get timelineOccupancy(){return this.dateRange.attr["X-TIMELINE-OCCUPIES"]==="RANGE"?Nr.Range:Nr.Point}get supplementsPrimary(){return this.dateRange.attr["X-TIMELINE-STYLE"]==="PRIMARY"}get contentMayVary(){return this.dateRange.attr["X-CONTENT-MAY-VARY"]!=="NO"}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||this.assetListResponse!==null}toString(){return Pc(this)}}function Ra(a,e){return a-e.start<e.duration/2&&!(Math.abs(a-(e.start+e.duration))<jn)?e.start:e.start+e.duration}function Vo(a,e,t){const i=new self.URL(a,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function La(a,e){for(;(t=a.assetList[++e])!=null&&t.error;)var t;return e}function Pc(a){return`["${a.identifier}" ${a.cue.pre?"<pre>":a.cue.post?"<post>":""}${a.timelineStart.toFixed(2)}-${a.resumeTime.toFixed(2)}]`}function zn(a){const e=a.timelineStart,t=a.duration||0;return`["${a.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class Oc{constructor(e,t,i,s){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(g.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=i,this.assetItem=s;const r=()=>{this.hasDetails=!0};n.once(g.LEVEL_LOADED,r),n.once(g.AUDIO_TRACK_LOADED,r),n.once(g.SUBTITLE_TRACK_LOADED,r),n.on(g.MEDIA_ATTACHING,(o,{media:u})=>{this.removeMediaListeners(),this.mediaAttached=u,this.interstitial.playoutLimit&&(u.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&n.on(g.BUFFER_APPENDED,()=>{const c=this.bufferedEnd;this.reachedPlayout(c)&&(this._bufferedEosTime=c,n.trigger(g.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{let t=this.assetItem.uri;try{t=Vo(t,e.config.primarySessionId||"").href}catch(i){}e.loadSource(t)}}bufferedInPlaceToEnd(e){var t;if(!this.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e)return!1;const i=Math.min(this._bufferedEosTime||1/0,this.duration),s=this.timelineOffset,n=Yt.bufferInfo(e,s,0);return this.getAssetTime(n.end)>=i-.02}reachedPlayout(e){const i=this.interstitial.playoutLimit;return this.startOffset+e>=i}get destroyed(){var e;return!((e=this.hls)!=null&&e.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var e;return((e=this.hls)==null?void 0:e.media)||null}get bufferedEnd(){const e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const t=Yt.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}get currentTime(){const e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}get duration(){const e=this.assetItem.duration;if(!e)return 0;const t=this.interstitial.playoutLimit;if(t){const i=t-this.startOffset;if(i>0&&i<e)return i}return e}get remaining(){const e=this.duration;return e?Math.max(0,e-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var e;return((e=this.hls)==null?void 0:e.config.timelineOffset)||0}set timelineOffset(e){const t=this.timelineOffset;if(e!==t){const i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}getAssetTime(e){const t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}removeMediaListeners(){const e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){if(this.mediaAttached){var e;(e=this.hls)!=null&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){var t;this.loadSource(),(t=this.hls)==null||t.attachMedia(e)}detachMedia(){var e;this.removeMediaListeners(),this.mediaAttached=null,(e=this.hls)==null||e.detachMedia()}resumeBuffering(){var e;(e=this.hls)==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.hls)==null||e.pauseBuffering()}transferMedia(){var e;return this.bufferSnapShot(),((e=this.hls)==null?void 0:e.transferMedia())||null}resetDetails(){const e=this.hls;if(e&&this.hasDetails){e.stopLoad();const t=i=>delete i.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}on(e,t,i){var s;(s=this.hls)==null||s.on(e,t)}once(e,t,i){var s;(s=this.hls)==null||s.once(e,t)}off(e,t,i){var s;(s=this.hls)==null||s.off(e,t)}toString(){var e;return`HlsAssetPlayer: ${zn(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}const Ho=.033;class Mc extends Ce{constructor(e,t){super("interstitials-sched",t),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=e}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}resetErrorsInRange(e,t){return this.events?this.events.reduce((i,s)=>e<=s.startOffset&&t>s.startOffset?(delete s.error,i+1):i,0):0}get duration(){const e=this.items;return e?e[e.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(e){return e&&this.eventMap[e]||null}hasEvent(e){return e in this.eventMap}findItemIndex(e,t){if(e.event)return this.findEventIndex(e.event.identifier);let i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);const s=this.items;if(s)for(s[i]||(t===void 0&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&(n=s[i])!=null&&n.event;){var n;i--}return i}findItemIndexAtTime(e,t){const i=this.items;if(i)for(let s=0;s<i.length;s++){let n=i[s];if(t&&t!=="primary"&&(n=n[t]),e===n.start||e>n.start&&e<n.end)return s}return-1}findJumpRestrictedIndex(e,t){const i=this.items;if(i)for(let s=e;s<=t&&i[s];s++){const n=i[s].event;if(n!=null&&n.restrictions.jump&&!n.appendInPlace)return s}return-1}findEventIndex(e){const t=this.items;if(t)for(let s=t.length;s--;){var i;if(((i=t[s].event)==null?void 0:i.identifier)===e)return s}return-1}findAssetIndex(e,t){const i=e.assetList,s=i.length;if(s>1)for(let n=0;n<s;n++){const r=i[n];if(!r.error){const o=r.timelineStart;if(t===o||t>o&&(t<o+(r.duration||0)||n===s-1))return n}}return 0}get assetIdAtEnd(){var e;const t=(e=this.items)==null||(e=e[this.length-1])==null?void 0:e.event;if(t){const i=t.assetList,s=i[i.length-1];if(s)return s.identifier}return null}parseInterstitialDateRanges(e,t){const i=e.main.details,{dateRanges:s}=i,n=this.events,r=this.parseDateRanges(s,{url:i.url},t),o=Object.keys(s),u=n?n.filter(l=>!o.includes(l.identifier)):[];r.length&&r.sort((l,c)=>{const h=l.cue.pre,m=l.cue.post,v=c.cue.pre,y=c.cue.post;if(h&&!v)return-1;if(v&&!h||m&&!y)return 1;if(y&&!m)return-1;if(!h&&!v&&!m&&!y){const b=l.startTime,S=c.startTime;if(b!==S)return b-S}return l.dateRange.tagOrder-c.dateRange.tagOrder}),this.events=r,u.forEach(l=>{this.removeEvent(l)}),this.updateSchedule(e,u)}updateSchedule(e,t=[],i=!1){const s=this.events||[];if(s.length||t.length||this.length<2){const n=this.items,r=this.parseSchedule(s,e);(i||t.length||(n==null?void 0:n.length)!==r.length||r.some((u,l)=>Math.abs(u.playout.start-n[l].playout.start)>.005||Math.abs(u.playout.end-n[l].playout.end)>.005))&&(this.items=r,this.onScheduleUpdate(t,n))}}parseDateRanges(e,t,i){const s=[],n=Object.keys(e);for(let r=0;r<n.length;r++){const o=n[r],u=e[o];if(u.isInterstitial){let l=this.eventMap[o];l?l.setDateRange(u):(l=new kc(u,t),this.eventMap[o]=l,i===!1&&(l.appendInPlace=i)),s.push(l)}}return s}parseSchedule(e,t){const i=[],s=t.main.details,n=s.live?1/0:s.edge;let r=0;if(e=e.filter(u=>!u.error&&!(u.cue.once&&u.hasPlayed)),e.length){this.resolveOffsets(e,t);let u=0,l=0;if(e.forEach((c,h)=>{const m=c.cue.pre,v=c.cue.post,y=e[h-1]||null,b=c.appendInPlace,S=v?n:c.startOffset,I=c.duration,R=c.timelineOccupancy===Nr.Range?I:0,L=c.resumptionOffset,B=(y==null?void 0:y.startTime)===S,j=S+c.cumulativeDuration;let be=b?j+I:S+L;if(m||!v&&S<=0){const fe=l;l+=R,c.timelineStart=j;const he=r;r+=I,i.push({event:c,start:j,end:be,playout:{start:he,end:r},integrated:{start:fe,end:l}})}else if(S<=n){if(!B){const q=S-u;if(q>Ho){const Oe=u,gt=l;l+=q;const wt=r;r+=q;const Vt={previousEvent:e[h-1]||null,nextEvent:c,start:Oe,end:Oe+q,playout:{start:wt,end:r},integrated:{start:gt,end:l}};i.push(Vt)}else q>0&&y&&(y.cumulativeDuration+=q,i[i.length-1].end=S)}v&&(be=j),c.timelineStart=j;const fe=l;l+=R;const he=r;r+=I,i.push({event:c,start:j,end:be,playout:{start:he,end:r},integrated:{start:fe,end:l}})}else return;const Z=c.resumeTime;v||Z>n?u=n:u=Z}),u<n){var o;const c=u,h=l,m=n-u;l+=m;const v=r;r+=m,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:u,end:c+m,playout:{start:v,end:r},integrated:{start:h,end:l}})}this.setDurations(n,r,l)}else i.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 i}setDurations(e,t,i){this.durations={primary:e,playout:t,integrated:i}}resolveOffsets(e,t){const i=t.main.details,s=i.live?1/0:i.edge;let n=0,r=-1;e.forEach((o,u)=>{const l=o.cue.pre,c=o.cue.post,h=l?0:c?s:o.startTime;this.updateAssetDurations(o),r===h?o.cumulativeDuration=n:(n=0,r=h),!c&&o.snapOptions.in&&(o.resumeAnchor=pi(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1)),!o.appendInPlace&&u+1<e.length&&e[u+1].startTime-e[u].resumeTime<Ho&&(e[u+1].appendInPlace=!1,e[u+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const v=_(o.resumeOffset)?o.resumeOffset:o.duration;n+=v})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,s=e.startTime+e.resumptionOffset;return Math.abs(i-s)>jn?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${s}`),!1):!Object.keys(t).some(r=>{const o=t[r].details,u=o.edge;if(i>=u)return this.log(`"${e.identifier}" resumption ${i} past ${r} playlist end ${u}`),!1;const l=pi(null,o.fragments,i);if(!l)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${r} playlist (${o.fragStart}-${o.fragmentEnd})`),!0;const c=r==="audio"?.175:0;return Math.abs(l.start-i)<jn+c||Math.abs(l.end-i)<jn+c?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${r} fragment bounds (${l.start}-${l.end} sn: ${l.sn} cc: ${l.cc})`),!0)})}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,s=!1,n=!1;for(let r=0;r<e.assetList.length;r++){const o=e.assetList[r],u=t+i;o.startOffset=i,o.timelineStart=u,s||(s=o.duration===null),n||(n=!!o.error);const l=o.error?0:o.duration||0;i+=l}s&&!n?e.duration=Math.max(i,e.duration):e.duration=i}removeEvent(e){e.reset(),delete this.eventMap[e.identifier]}}function nn(a){return`[${a.event?'"'+a.event.identifier+'"':"primary"}: ${a.start.toFixed(2)}-${a.end.toFixed(2)}]`}class Fc{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let s;try{s=Vo(i,this.hls.sessionId,e.baseUrl)}catch(m){const v=this.assignAssetListError(e,A.ASSET_LIST_LOAD_ERROR,m,i);this.hls.trigger(g.ERROR,v);return}t&&s.protocol!=="data:"&&s.searchParams.set("_HLS_start_offset",""+t);const n=this.hls.config,r=n.loader,o=new r(n),u={responseType:"json",url:s.href},l=n.interstitialAssetListLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(m,v,y,b)=>{const S=m.data,I=S==null?void 0:S.ASSETS;if(!Array.isArray(I)){const R=this.assignAssetListError(e,A.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),y.url,v,b);this.hls.trigger(g.ERROR,R);return}e.assetListResponse=S,this.hls.trigger(g.ASSET_LIST_LOADED,{event:e,assetListResponse:S,networkDetails:b})},onError:(m,v,y,b)=>{const S=this.assignAssetListError(e,A.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${m.code} ${m.text} (${v.url})`),v.url,b,y);this.hls.trigger(g.ERROR,S)},onTimeout:(m,v,y)=>{const b=this.assignAssetListError(e,A.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${v.url})`),v.url,m,y);this.hls.trigger(g.ERROR,b)}};return o.load(u,c,h),this.hls.trigger(g.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,s,n,r){return e.error=i,{type:Y.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:s,error:i,networkDetails:r,stats:n}}}function jo(a){var e;a==null||(e=a.play())==null||e.catch(()=>{})}function $r(a,e){return`[${a}] Advancing timeline position to ${e}`}class Bc extends Ce{constructor(e,t){super("interstitials",e.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled||!this.schedule)return;const s=i-this.timelinePos;if(Math.abs(s)<1/7056e5)return;const r=s<=-.01;this.timelinePos=i,this.bufferedPos=i;const o=this.playingItem;if(!o){this.checkBuffer();return}if(r&&this.schedule.resetErrorsInRange(i,i-s)&&this.updateSchedule(!0),this.checkBuffer(),r&&i<o.start||i>=o.end){var u;const v=this.findItemIndex(o);let y=this.schedule.findItemIndexAtTime(i);if(y===-1&&(y=v+(r?-1:1),this.log(`seeked ${r?"back ":""}to position not covered by schedule ${i} (resolving from ${v} to ${y})`)),!this.isInterstitial(o)&&(u=this.media)!=null&&u.paused&&(this.shouldPlay=!1),!r&&y>v){const b=this.schedule.findJumpRestrictedIndex(v+1,y);if(b>v){this.setSchedulePosition(b);return}}this.setSchedulePosition(y);return}const l=this.playingAsset;if(!l){if(this.playingLastItem&&this.isInterstitial(o)){const v=o.event.assetList[0];v&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,v))}return}const c=l.timelineStart,h=l.duration||0;if(r&&i<c||i>=c+h){var m;(m=o.event)!=null&&m.appendInPlace&&(this.clearAssetPlayers(o.event,o),this.flushFrontBuffer(i)),this.setScheduleToAssetAtTime(i,l)}},this.onTimeupdate=()=>{const i=this.currentTime;if(i===void 0||this.playbackDisabled)return;if(i>this.timelinePos)this.timelinePos=i,i>this.bufferedPos&&this.checkBuffer();else return;const s=this.playingItem;if(!s||this.playingLastItem)return;if(i>=s.end){this.timelinePos=s.end;const o=this.findItemIndex(s);this.setSchedulePosition(o+1)}const n=this.playingAsset;if(!n)return;const r=n.timelineStart+(n.duration||0);i>=r&&this.setScheduleToAssetAtTime(i,n)},this.onScheduleUpdate=(i,s)=>{const n=this.schedule;if(!n)return;const r=this.playingItem,o=n.events||[],u=n.items||[],l=n.durations,c=i.map(b=>b.identifier),h=!!(o.length||c.length);(h||s)&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
Schedule: ${u.map(b=>nn(b))} pos: ${this.timelinePos}`),c.length&&this.log(`Removed events ${c}`);let m=null,v=null;r&&(m=this.updateItem(r,this.timelinePos),this.itemsMatch(r,m)?this.playingItem=m:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const y=this.bufferingItem;if(y&&(v=this.updateItem(y,this.bufferedPos),this.itemsMatch(y,v)?this.bufferingItem=v:y.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(y.event,null))),i.forEach(b=>{b.assetList.forEach(S=>{this.clearAssetPlayer(S.identifier,null)})}),this.playerQueue.forEach(b=>{if(b.interstitial.appendInPlace){const S=b.assetItem.timelineStart,I=b.timelineOffset-S;if(I)try{b.timelineOffset=S}catch(R){Math.abs(I)>jn&&this.warn(`${R} ("${b.assetId}" ${b.timelineOffset}->${S})`)}}}),h||s){if(this.hls.trigger(g.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:u.slice(0),durations:l,removedIds:c}),this.isInterstitial(r)&&c.includes(r.event.identifier)){this.warn(`Interstitial "${r.event.identifier}" removed while playing`),this.primaryFallback(r.event);return}r&&this.trimInPlace(m,r),y&&v!==m&&this.trimInPlace(v,y),this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Fc(e),this.schedule=new Mc(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e&&(e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(g.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(g.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(g.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(g.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(g.BUFFER_APPENDED,this.onBufferAppended,this),e.on(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(g.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(g.MEDIA_ENDED,this.onMediaEnded,this),e.on(g.ERROR,this.onError,this),e.on(g.DESTROYING,this.onDestroying,this))}unregisterListeners(){const e=this.hls;e&&(e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(g.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(g.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(g.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(g.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(g.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.BUFFER_APPENDED,this.onBufferAppended,this),e.off(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(g.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(g.MEDIA_ENDED,this.onMediaEnded,this),e.off(g.ERROR,this.onError,this),e.off(g.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var e;(e=this.getBufferingPlayer())==null||e.resumeBuffering()}pauseBuffering(){var e;(e=this.getBufferingPlayer())==null||e.pauseBuffering()}destroy(){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.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){Os(e,"play",this.onPlay),Os(e,"pause",this.onPause),Os(e,"seeking",this.onSeeking),Os(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;ws(i,"seeking",this.onSeeking),ws(i,"timeupdate",this.onTimeupdate),ws(i,"play",this.onPlay),ws(i,"pause",this.onPause)}onMediaAttached(e,t){const i=this.effectivePlayingItem,s=this.detachedData;if(this.detachedData=null,i===null)this.checkStart();else if(!s){this.clearScheduleState();const n=this.findItemIndex(i);this.setSchedulePosition(n)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(e,t){const i=!!t.transferMedia,s=this.media;if(this.media=null,!i&&(s&&this.removeMediaListeners(s),this.detachedData)){const n=this.getBufferingPlayer();n&&(this.log(`Removing schedule state for detachedData and ${n}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=h=>h&&e.getAssetPlayer(h.identifier),s=(h,m,v,y,b)=>{if(h){let S=h[m].start;const I=h.event;if(I){if(m==="playout"||I.timelineOccupancy!==Nr.Point){const R=i(v);(R==null?void 0:R.interstitial)===I&&(S+=R.assetItem.startOffset+R[b])}}else{const R=y==="bufferedPos"?r():e[y];S+=R-h.start}return S}return 0},n=(h,m)=>{var v;if(h!==0&&m!=="primary"&&(v=e.schedule)!=null&&v.length){var y;const b=e.schedule.findItemIndexAtTime(h),S=(y=e.schedule.items)==null?void 0:y[b];if(S){const I=S[m].start-S.start;return h+I}}return h},r=()=>{const h=e.bufferedPos;return h===Number.MAX_VALUE?o("primary"):Math.max(h,0)},o=h=>{var m,v;return(m=e.primaryDetails)!=null&&m.live?e.primaryDetails.edge:((v=e.schedule)==null?void 0:v.durations[h])||0},u=(h,m)=>{var v,y;const b=e.effectivePlayingItem;if(b!=null&&(v=b.event)!=null&&v.restrictions.skip||!e.schedule)return;e.log(`seek to ${h} "${m}"`);const S=e.effectivePlayingItem,I=e.schedule.findItemIndexAtTime(h,m),R=(y=e.schedule.items)==null?void 0:y[I],L=e.getBufferingPlayer(),B=L==null?void 0:L.interstitial,j=B==null?void 0:B.appendInPlace,be=S&&e.itemsMatch(S,R);if(S&&(j||be)){const Z=i(e.playingAsset),fe=(Z==null?void 0:Z.media)||e.primaryMedia;if(fe){const he=m==="primary"?fe.currentTime:s(S,m,e.playingAsset,"timelinePos","currentTime"),q=h-he,Oe=(j?he:fe.currentTime)+q;if(Oe>=0&&(!Z||j||Oe<=Z.duration)){fe.currentTime=Oe;return}}}if(R){let Z=h;if(m!=="primary"){const he=R[m].start,q=h-he;Z=R.start+q}const fe=!e.isInterstitial(R);if((!e.isInterstitial(S)||S.event.appendInPlace)&&(fe||R.event.appendInPlace)){const he=e.media||(j?L==null?void 0:L.media:null);he&&(he.currentTime=Z)}else if(S){const he=e.findItemIndex(S);if(I>he){const Oe=e.schedule.findJumpRestrictedIndex(he+1,I);if(Oe>he){e.setSchedulePosition(Oe);return}}let q=0;if(fe)e.timelinePos=Z,e.checkBuffer();else{const Oe=R.event.assetList,gt=h-(R[m]||R).start;for(let wt=Oe.length;wt--;){const Vt=Oe[wt];if(Vt.duration&&gt>=Vt.startOffset&&gt<Vt.startOffset+Vt.duration){q=wt;break}}}e.setSchedulePosition(I,q)}}},l=()=>{const h=e.effectivePlayingItem;if(e.isInterstitial(h))return h;const m=t();return e.isInterstitial(m)?m:null},c={get bufferedEnd(){const h=t(),m=e.bufferingItem;if(m&&m===h){var v;return s(m,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-m.playout.start||((v=e.bufferingAsset)==null?void 0:v.startOffset)||0}return 0},get currentTime(){const h=l(),m=e.effectivePlayingItem;return m&&m===h?s(m,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-m.playout.start:0},set currentTime(h){const m=l(),v=e.effectivePlayingItem;v&&v===m&&u(h+v.playout.start,"playout")},get duration(){const h=l();return h?h.playout.end-h.playout.start:0},get assetPlayers(){var h;const m=(h=l())==null?void 0:h.event.assetList;return m?m.map(v=>e.getAssetPlayer(v.identifier)):[]},get playingIndex(){var h;const m=(h=l())==null?void 0:h.event;return m&&e.effectivePlayingAsset?m.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return l()}};return this.manager={get events(){var h;return((h=e.schedule)==null||(h=h.events)==null?void 0:h.slice(0))||[]},get schedule(){var h;return((h=e.schedule)==null||(h=h.items)==null?void 0:h.slice(0))||[]},get interstitialPlayer(){return l()?c:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){const h=t();return e.findItemIndex(h)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){const h=e.effectivePlayingItem;return e.findItemIndex(h)},primary:{get bufferedEnd(){return r()},get currentTime(){const h=e.timelinePos;return h>0?h:0},set currentTime(h){u(h,"primary")},get duration(){return o("primary")},get seekableStart(){var h;return((h=e.primaryDetails)==null?void 0:h.fragmentStart)||0}},integrated:{get bufferedEnd(){return s(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return s(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(h){u(h,"integrated")},get duration(){return o("integrated")},get seekableStart(){var h;return n(((h=e.primaryDetails)==null?void 0:h.fragmentStart)||0,"integrated")}},skip:()=>{const h=e.effectivePlayingItem,m=h==null?void 0:h.event;if(m&&!m.restrictions.skip){const v=e.findItemIndex(h);if(m.appendInPlace){const y=h.playout.start+h.event.duration;u(y+.001,"playout")}else e.advanceAfterAssetEnded(m,v,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var e;const t=this.playingItem,i=(e=this.schedule)==null?void 0:e.items;return!this.playbackStarted||!t||!i?!1:this.findItemIndex(t)===i.length-1}get playbackStarted(){return this.effectivePlayingItem!==null}get currentTime(){var e,t;if(this.mediaSelection===null)return;const i=this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&!i.event.appendInPlace)return;let s=this.media;!s&&(e=this.bufferingItem)!=null&&(e=e.event)!=null&&e.appendInPlace&&(s=this.primaryMedia);const n=(t=s)==null?void 0:t.currentTime;if(!(n===void 0||!_(n)))return n}get primaryMedia(){var e;return this.media||((e=this.detachedData)==null?void 0:e.media)||null}isInterstitial(e){return!!(e!=null&&e.event)}retreiveMediaSource(e,t){const i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}transferMediaFromPlayer(e,t){const i=e.interstitial.appendInPlace,s=e.media;if(i&&s===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&s){this.detachedData={media:s};return}const n=e.transferMedia();this.log(`transfer MediaSource from ${e} ${Q(n)}`),this.detachedData=n}else t&&s&&(this.shouldPlay||(this.shouldPlay=!s.paused))}transferMediaTo(e,t){var i,s;if(e.media===t)return;let n=null;const r=this.hls,o=e!==r,u=o&&e.interstitial.appendInPlace,l=(i=this.detachedData)==null?void 0:i.mediaSource;let c;if(r.media)u&&(n=r.transferMedia(),this.detachedData=n),c="Primary";else if(l){const y=this.getBufferingPlayer();y?(n=y.transferMedia(),c=`${y}`):c="detached MediaSource"}else c="detached media";if(!n){if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${Q(n)}`);else if(!this.detachedData||r.media===t){const y=this.playerQueue;y.length>1&&y.forEach(b=>{if(o&&b.interstitial.appendInPlace!==u){const S=b.interstitial;this.clearInterstitial(b.interstitial,null),S.appendInPlace=!1,S.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${S}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const h=n&&"mediaSource"in n&&((s=n.mediaSource)==null?void 0:s.readyState)!=="closed",m=h&&n?n:t;this.log(`${h?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${c} (media.currentTime: ${t.currentTime})`);const v=this.schedule;if(m===n&&v){const y=o&&e.assetId===v.assetIdAtEnd;m.overrides={duration:v.duration,endOfStream:!o||y,cueRemoval:!o}}e.attachMedia(m)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=e==null?void 0:e.events;if(!t||this.playbackDisabled||!this.media)return;this.bufferedPos===-1&&(this.bufferedPos=0);const i=this.timelinePos,s=this.effectivePlayingItem;if(i===-1){const n=this.hls.startPosition;if(this.log($r("checkStart",n)),this.timelinePos=n,t.length&&t[0].cue.pre){const r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(n>=0||!this.primaryLive){const r=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(r);this.setSchedulePosition(o)}}else if(s&&!this.playingItem){const n=e.findItemIndex(s);this.setSchedulePosition(n)}}advanceAssetBuffering(e,t){const i=e.event,s=i.findAssetIndex(t),n=La(i,s);if(!i.isAssetPastPlayoutLimit(n))this.bufferedToEvent(e,n);else if(this.schedule){var r;const o=(r=this.schedule.items)==null?void 0:r[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}advanceAfterAssetEnded(e,t,i){const s=La(e,i);if(e.isAssetPastPlayoutLimit(s)){if(this.schedule){const n=this.schedule.items;if(n){const r=t+1,o=n.length;if(r>=o){this.setSchedulePosition(-1);return}const u=e.resumeTime;this.timelinePos<u&&(this.log($r("advanceAfterAssetEnded",u)),this.timelinePos=u,e.appendInPlace&&this.advanceInPlace(u),this.checkBuffer(this.bufferedPos<u)),this.setSchedulePosition(r)}}}else{if(e.appendInPlace){const n=e.assetList[s];n&&this.advanceInPlace(n.timelineStart)}this.setSchedulePosition(t,s)}}setScheduleToAssetAtTime(e,t){const i=this.schedule;if(!i)return;const s=t.parentIdentifier,n=i.getEvent(s);if(n){const r=i.findEventIndex(s),o=i.findAssetIndex(n,e);this.advanceAfterAssetEnded(n,r,o-1)}}setSchedulePosition(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(!s||this.playbackDisabled)return;const n=e>=0?s[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${n&&nn(n)}) pos: ${this.timelinePos}`);const r=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(r)){const c=r.event,h=this.playingAsset,m=h==null?void 0:h.identifier,v=m?this.getAssetPlayer(m):null;if(v&&m&&(!this.eventItemsMatch(r,n)||t!==void 0&&m!==c.assetList[t].identifier)){var u;const y=c.findAssetIndex(h);if(this.log(`INTERSTITIAL_ASSET_ENDED ${y+1}/${c.assetList.length} ${zn(h)}`),this.endedAsset=h,this.playingAsset=null,this.hls.trigger(g.INTERSTITIAL_ASSET_ENDED,{asset:h,assetListIndex:y,event:c,schedule:s.slice(0),scheduleIndex:e,player:v}),r!==this.playingItem){this.itemsMatch(r,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(c,this.findItemIndex(this.playingItem),y);return}this.retreiveMediaSource(m,n),v.media&&!((u=this.detachedData)!=null&&u.mediaSource)&&v.detachMedia()}if(!this.eventItemsMatch(r,n)&&(this.endedItem=r,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${c} ${nn(r)}`),c.hasPlayed=!0,this.hls.trigger(g.INTERSTITIAL_ENDED,{event:c,schedule:s.slice(0),scheduleIndex:e}),c.cue.once)){var l;this.updateSchedule();const y=(l=this.schedule)==null?void 0:l.items;if(n&&y){const b=this.findItemIndex(n);this.advanceSchedule(b,y,t,r,o)}return}}this.advanceSchedule(e,s,t,r,o)}advanceSchedule(e,t,i,s,n){const r=this.schedule;if(!r)return;const o=t[e]||null,u=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach(c=>{const h=c.interstitial,m=r.findEventIndex(h.identifier);(m<e||m>e+1)&&this.clearInterstitial(h,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);const c=o.event;if(i===void 0){i=r.findAssetIndex(c,this.timelinePos);const y=La(c,i-1);if(c.isAssetPastPlayoutLimit(y)||c.appendInPlace&&this.timelinePos===o.end){this.advanceAfterAssetEnded(c,e,i);return}i=y}const h=this.waitingItem;this.assetsBuffered(o,u)||this.setBufferingItem(o);let m=this.preloadAssets(c,i);if(this.eventItemsMatch(o,h||s)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${nn(o)} ${c.appendInPlace?"append in place":""}`),this.hls.trigger(g.INTERSTITIAL_STARTED,{event:c,schedule:t.slice(0),scheduleIndex:e})),!c.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${c}`);return}if(c.assetListLoader&&(c.assetListLoader.destroy(),c.assetListLoader=void 0),!u){this.log(`Waiting for attachMedia to start Interstitial ${c}`);return}this.waitingItem=this.endedItem=null,this.playingItem=o;const v=c.assetList[i];if(!v){this.advanceAfterAssetEnded(c,e,i||0);return}if(m||(m=this.getAssetPlayer(v.identifier)),m===null||m.destroyed){const y=c.assetList.length;this.warn(`asset ${i+1}/${y} player destroyed ${c}`),m=this.createAssetPlayer(c,v,i),m.loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&c.appendInPlace&&this.isAssetBuffered(v))return;this.startAssetPlayer(m,i,t,e,u),this.shouldPlay&&jo(m.media)}else o?(this.resumePrimary(o,e,s),this.shouldPlay&&jo(this.hls.media)):n&&this.isInterstitial(s)&&(this.endedItem=null,this.playingItem=s,s.event.appendInPlace||this.attachPrimary(r.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e;return(e=this.mediaSelection)==null?void 0:e.main.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var s,n;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${nn(e)}`),!((s=this.detachedData)!=null&&s.mediaSource)){let o=this.timelinePos;(o<e.start||o>=e.end)&&(o=this.getPrimaryResumption(e,t),this.log($r("resumePrimary",o)),this.timelinePos=o),this.attachPrimary(o,e)}if(!i)return;const r=(n=this.schedule)==null?void 0:n.items;r&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${nn(e)}`),this.hls.trigger(g.INTERSTITIALS_PRIMARY_RESUMED,{schedule:r.slice(0),scheduleIndex:t}),this.checkBuffer())}getPrimaryResumption(e,t){const i=e.start;if(this.primaryLive){const s=this.primaryDetails;if(t===0)return this.hls.startPosition;if(s&&(i<s.fragmentStart||i>s.edge))return this.hls.liveSyncPosition||-1}return i}isAssetBuffered(e){const t=this.getAssetPlayer(e.identifier);return t!=null&&t.hls?t.hls.bufferedToEnd:Yt.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}attachPrimary(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const s=this.primaryMedia;if(!s)return;const n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,s),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log($r("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}startLoadingPrimaryAt(e,t){var i;const s=this.hls;!s.loadingEnabled||!s.media||Math.abs((((i=s.mainForwardBufferInfo)==null?void 0:i.start)||s.media.currentTime)-e)>.5?s.startLoad(e,t):s.bufferingEnabled||s.resumeBuffering()}onManifestLoading(){var e;this.stopLoad(),(e=this.schedule)==null||e.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(g.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(g.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1||!this.schedule)return;const i=this.hls.levels[t.level];if(!i.details)return;const s=H(H({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=s,this.schedule.parseInterstitialDateRanges(s,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(e,t){const i=this.hls.audioTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=H(H({},this.altSelection),{},{audio:i});return}const n=H(H({},s),{},{audio:i});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=H(H({},this.altSelection),{},{subtitles:i});return}const n=H(H({},s),{},{subtitles:i});this.mediaSelection=n}onAudioTrackSwitching(e,t){const i=Be(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setAudioOption(t)||s.setAudioOption(i)))}onSubtitleTrackSwitch(e,t){const i=Be(t);this.playerQueue.forEach(({hls:s})=>s&&(s.setSubtitleOption(t)||t.id!==-1&&s.setSubtitleOption(i)))}onBufferCodecs(e,t){const i=t.tracks;i&&(this.requiredTracks=i)}onBufferAppended(e,t){this.checkBuffer()}onBufferFlushed(e,t){const i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){const s=this.timelinePos;this.bufferedPos=s,this.checkBuffer()}}onBufferedToEnd(e){if(!this.schedule)return;const t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(let s=0;s<t.length;s++){const n=t[s];if(n.cue.post){var i;const r=this.schedule.findEventIndex(n.identifier),o=(i=this.schedule.items)==null?void 0:i[r];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(e){const t=this.playingItem;if(!this.playingLastItem&&t){const i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}updateItem(e,t){var i;const s=(i=this.schedule)==null?void 0:i.items;if(e&&s){const n=this.findItemIndex(e,t);return s[n]||null}return null}trimInPlace(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((n,r)=>{e.event.isAssetPastPlayoutLimit(r)&&this.clearAssetPlayer(n.identifier,null)});const i=e.end+.25,s=Yt.bufferInfo(this.primaryMedia,i,0);(s.end>i||(s.nextStart||0)>i)&&(this.log(`trim buffered interstitial ${nn(e)} (was ${nn(t)})`),this.attachPrimary(i,null,!0),this.flushFrontBuffer(i))}}itemsMatch(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}eventItemsMatch(e,t){var i;return!!t&&(e===t||e.event.identifier===((i=t.event)==null?void 0:i.identifier))}findItemIndex(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}updateSchedule(e=!1){var t;const i=this.mediaSelection;i&&((t=this.schedule)==null||t.updateSchedule(i,[],e))}checkBuffer(e){var t;const i=(t=this.schedule)==null?void 0:t.items;if(!i)return;const s=Yt.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=s.len<1),this.updateBufferedPos(s.end,i,e)}updateBufferedPos(e,t,i){const s=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e||!s)return;if(t.length===1&&this.itemsMatch(t[0],n)){this.bufferedPos=e;return}const r=this.playingItem,o=this.findItemIndex(r);let u=s.findItemIndexAtTime(e);if(this.bufferedPos<e){var l;const c=this.findItemIndex(n),h=Math.min(c+1,t.length-1),m=t[h];if((u===-1&&n&&e>=n.end||(l=m.event)!=null&&l.appendInPlace&&e+.01>=m.start)&&(u=h),this.isInterstitial(n)){const v=n.event;if(h-o>1&&v.appendInPlace===!1||v.assetList.length===0&&v.assetListLoader)return}if(this.bufferedPos=e,u>c&&u>o)this.bufferedToItem(m);else{const v=this.primaryDetails;this.primaryLive&&v&&e>v.edge-v.targetduration&&m.start<v.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(m)&&this.preloadAssets(m.event,0)}}else i&&r&&!this.itemsMatch(r,n)&&(u===o?this.bufferedToItem(r):u===o+1&&this.bufferedToItem(t[u]))}assetsBuffered(e,t){return e.event.assetList.length===0?!1:!e.event.assetList.some(s=>{const n=this.getAssetPlayer(s.identifier);return!(n!=null&&n.bufferedInPlaceToEnd(t))})}setBufferingItem(e){const t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){const{items:s,events:n}=i;if(!s||!n)return t;const r=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));const u=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${nn(e)}`+(t?` (${u.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(r){const l=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((c,h)=>{const m=this.getAssetPlayer(c.identifier);m&&(h===l&&m.loadSource(),m.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(l=>l.pauseBuffering());this.hls.trigger(g.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:s.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}bufferedToItem(e,t=0){const i=this.setBufferingItem(e);if(!this.playbackDisabled){if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(i!==null){this.bufferingAsset=null;const s=this.detachedData;s?s.mediaSource?this.attachPrimary(e.start,e,!0):this.preloadPrimary(e):this.preloadPrimary(e)}}}preloadPrimary(e){const t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}bufferedToEvent(e,t){const i=e.event,s=i.assetList.length===0&&!i.assetListLoader,n=i.cue.once;if(s||!n){const r=this.preloadAssets(i,t);if(r!=null&&r.interstitial.appendInPlace){const o=this.primaryMedia;o&&this.bufferAssetPlayer(r,o)}}}preloadAssets(e,t){const i=e.assetUrl,s=e.assetList.length,n=s===0&&!e.assetListLoader,r=e.cue.once;if(n){const u=e.timelineStart;if(e.appendInPlace){var o;const m=this.playingItem;!this.isInterstitial(m)&&(m==null||(o=m.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(u+.25)}let l,c=0;if(!this.playingItem&&this.primaryLive&&(c=this.hls.startPosition,c===-1&&(c=this.hls.liveSyncPosition||0)),c&&!(e.cue.pre||e.cue.post)){const m=c-u;m>0&&(l=Math.round(m*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:s} ${e}${l?` live-start: ${c} start-offset: ${l}`:""}`),i)return this.createAsset(e,0,0,u,e.duration,i);const h=this.assetListLoader.loadAssetList(e,l);h&&(e.assetListLoader=h)}else if(!r&&s){for(let l=t;l<s;l++){const c=e.assetList[l],h=this.getAssetPlayerQueueIndex(c.identifier);(h===-1||this.playerQueue[h].destroyed)&&!c.error&&this.createAssetPlayer(e,c,l)}const u=e.assetList[t];if(u){const l=this.getAssetPlayer(u.identifier);return l&&l.loadSource(),l}}return null}flushFrontBuffer(e){const t=this.requiredTracks;if(!t)return;this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(s=>{this.hls.trigger(g.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:s})})}getAssetPlayerQueueIndex(e){const t=this.playerQueue;for(let i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}getAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}getBufferingPlayer(){const{playerQueue:e,primaryMedia:t}=this;if(t){for(let i=0;i<e.length;i++)if(e[i].media===t)return e[i]}return null}createAsset(e,t,i,s,n,r){const o={parentIdentifier:e.identifier,identifier:wc(e,r,t),duration:n,startOffset:i,timelineStart:s,uri:r};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){const s=this.hls,n=s.userConfig;let r=n.videoPreference;const o=s.loadLevelObj||s.levels[s.currentLevel];(r||o)&&(r=Ie({},r),o.videoCodec&&(r.videoCodec=o.videoCodec),o.videoRange&&(r.allowedVideoRanges=[o.videoRange]));const u=s.audioTracks[s.audioTrack],l=s.subtitleTracks[s.subtitleTrack];let c=0;if(this.primaryLive||e.appendInPlace){const B=this.timelinePos-t.timelineStart;if(B>1){const j=t.duration;j&&B<j&&(c=B)}}const h=t.identifier,m=H(H({},n),{},{maxMaxBufferLength:Math.min(180,s.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:s.sessionId,assetPlayerId:h,abrEwmaDefaultEstimate:s.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:r,audioPreference:u||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(m.timelineOffset=t.timelineStart));const v=m.cmcd;v!=null&&v.sessionId&&v.contentId&&(m.cmcd=Ie({},v,{contentId:ur(t.uri)})),this.getAssetPlayer(h)&&this.warn(`Duplicate date range identifier ${e} and asset ${h}`);const y=new Oc(this.HlsPlayerClass,m,e,t);this.playerQueue.push(y),e.assetList[i]=t;let b=!0;const S=B=>{if(B.live){var j;const fe=new Error(`Interstitials MUST be VOD assets ${e}`),he={fatal:!0,type:Y.OTHER_ERROR,details:A.INTERSTITIAL_ASSET_ITEM_ERROR,error:fe},q=((j=this.schedule)==null?void 0:j.findEventIndex(e.identifier))||-1;this.handleAssetItemError(he,e,q,i,fe.message);return}const be=B.edge-B.fragmentStart,Z=t.duration;(b||Z===null||be>Z)&&(b=!1,this.log(`Interstitial asset "${h}" duration change ${Z} > ${be}`),t.duration=be,this.updateSchedule())};y.on(g.LEVEL_UPDATED,(B,{details:j})=>S(j)),y.on(g.LEVEL_PTS_UPDATED,(B,{details:j})=>S(j)),y.on(g.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const I=(B,j)=>{const be=this.getAssetPlayer(h);if(be&&j.tracks){be.off(g.BUFFER_CODECS,I),be.tracks=j.tracks;const Z=this.primaryMedia;this.bufferingAsset===be.assetItem&&Z&&!be.media&&this.bufferAssetPlayer(be,Z)}};y.on(g.BUFFER_CODECS,I);const R=()=>{var B;const j=this.getAssetPlayer(h);if(this.log(`buffered to end of asset ${j}`),!j||!this.schedule)return;const be=this.schedule.findEventIndex(e.identifier),Z=(B=this.schedule.items)==null?void 0:B[be];this.isInterstitial(Z)&&this.advanceAssetBuffering(Z,t)};y.on(g.BUFFERED_TO_END,R);const L=B=>()=>{if(!this.getAssetPlayer(h)||!this.schedule)return;this.shouldPlay=!0;const be=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,be,B)};return y.once(g.MEDIA_ENDED,L(i)),y.once(g.PLAYOUT_LIMIT_REACHED,L(1/0)),y.on(g.ERROR,(B,j)=>{if(!this.schedule)return;const be=this.getAssetPlayer(h);if(j.details===A.BUFFER_STALLED_ERROR){if(be!=null&&be.appendInPlace){this.handleInPlaceStall(e);return}this.onTimeupdate(),this.checkBuffer(!0);return}this.handleAssetItemError(j,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${j.error} ${e}`)}),y.on(g.DESTROYING,()=>{if(!this.getAssetPlayer(h)||!this.schedule)return;const j=new Error(`Asset player destroyed unexpectedly ${h}`),be={fatal:!0,type:Y.OTHER_ERROR,details:A.INTERSTITIAL_ASSET_ITEM_ERROR,error:j};this.handleAssetItemError(be,e,this.schedule.findEventIndex(e.identifier),i,j.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${zn(t)}`),this.hls.trigger(g.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:y}),y}clearInterstitial(e,t){this.clearAssetPlayers(e,t),e.reset()}clearAssetPlayers(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)})}resetAssetPlayer(e){const t=this.getAssetPlayerQueueIndex(e);if(t!==-1){this.log(`reset asset player "${e}" after error`);const i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){const s=this.playerQueue[i];this.log(`clear ${s} toSegment: ${t&&nn(t)}`),this.transferMediaFromPlayer(s,t),this.playerQueue.splice(i,1),s.destroy()}}emptyPlayerQueue(){let e;for(;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}startAssetPlayer(e,t,i,s,n){const{interstitial:r,assetItem:o,assetId:u}=e,l=r.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!c||c.identifier!==u)&&(c&&(this.clearAssetPlayer(c.identifier,i[s]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${zn(o)}`),this.hls.trigger(g.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:s,player:e})),this.bufferAssetPlayer(e,n)}bufferAssetPlayer(e,t){var i,s;if(!this.schedule)return;const{interstitial:n,assetItem:r}=e,o=this.schedule.findEventIndex(n.identifier),u=(i=this.schedule.items)==null?void 0:i[o];if(!u)return;e.loadSource(),this.setBufferingItem(u),this.bufferingAsset=r;const l=this.getBufferingPlayer();if(l===e)return;const c=n.appendInPlace;if(c&&(l==null?void 0:l.interstitial.appendInPlace)===!1)return;const h=(l==null?void 0:l.tracks)||((s=this.detachedData)==null?void 0:s.tracks)||this.requiredTracks;if(c&&r!==this.playingAsset){if(!e.tracks){this.log(`Waiting for track info before buffering ${e}`);return}if(h&&!Je(h,e.tracks)){const m=new Error(`Asset ${zn(r)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(h)}')`),v={fatal:!0,type:Y.OTHER_ERROR,details:A.INTERSTITIAL_ASSET_ITEM_ERROR,error:m},y=n.findAssetIndex(r);this.handleAssetItemError(v,n,o,y,m.message);return}}this.transferMediaTo(e,t)}handleInPlaceStall(e){const t=this.schedule,i=this.primaryMedia;if(!t||!i)return;const s=i.currentTime,n=t.findAssetIndex(e,s),r=e.assetList[n];if(r){const o=this.getAssetPlayer(r.identifier);if(o){const u=o.currentTime||s-r.timelineStart,l=o.duration-u;if(this.warn(`Stalled at ${u} of ${u+l} in ${o} ${e} (media.currentTime: ${s})`),u&&(l/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){const c=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,c,n)}}}}advanceInPlace(e){const t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}handleAssetItemError(e,t,i,s,n){if(e.details===A.BUFFER_STALLED_ERROR)return;const r=t.assetList[s]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${r&&zn(r)} ${e.error}`),!this.schedule)return;const o=(r==null?void 0:r.identifier)||"",u=this.getAssetPlayerQueueIndex(o),l=this.playerQueue[u]||null,c=this.schedule.items,h=Ie({},e,{fatal:!1,errorAction:Oi(!0),asset:r,assetListIndex:s,event:t,schedule:c,scheduleIndex:i,player:l});if(this.hls.trigger(g.INTERSTITIAL_ASSET_ERROR,h),!e.fatal)return;const m=this.playingAsset,v=this.bufferingAsset,y=new Error(n);if(r&&(this.clearAssetPlayer(o,null),r.error=y),!t.assetList.some(b=>!b.error))t.error=y;else for(let b=s;b<t.assetList.length;b++)this.resetAssetPlayer(t.assetList[b].identifier);this.updateSchedule(!0),t.error?this.primaryFallback(t):m&&m.identifier===o?this.advanceAfterAssetEnded(t,i,s):v&&v.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,v)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem;let s=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${s} playing: ${nn(i)} error: ${e.error}`),s===-1&&(s=this.hls.startPosition);const r=this.updateItem(i,s);this.itemsMatch(i,r)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(s===-1){this.checkStart();return}if(!this.schedule)return;const n=this.schedule.findItemIndexAtTime(s);this.setSchedulePosition(n)}onAssetListLoaded(e,t){var i,s;const n=t.event,r=n.identifier,o=t.assetListResponse.ASSETS;if(!((i=this.schedule)!=null&&i.hasEvent(r)))return;const u=n.timelineStart,l=n.duration;let c=0;o.forEach((b,S)=>{const I=parseFloat(b.DURATION);this.createAsset(n,S,c,u+c,I,b.URI),c+=I}),n.duration=c,this.log(`Loaded asset-list with duration: ${c} (was: ${l}) ${n}`);const h=this.waitingItem,m=(h==null?void 0:h.event.identifier)===r;this.updateSchedule();const v=(s=this.bufferingItem)==null?void 0:s.event;if(m){var y;const b=this.schedule.findEventIndex(r),S=(y=this.schedule.items)==null?void 0:y[b];if(S){if(!this.playingItem&&this.timelinePos>S.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==b){n.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${n}`),this.log(n.error.message),this.updateSchedule(!0),this.primaryFallback(n);return}this.setBufferingItem(S)}this.setSchedulePosition(b)}else if((v==null?void 0:v.identifier)===r){const b=n.assetList[0];if(b){const S=this.getAssetPlayer(b.identifier);if(v.appendInPlace){const I=this.primaryMedia;S&&I&&this.bufferAssetPlayer(S,I)}else S&&S.loadSource()}}}onError(e,t){if(this.schedule)switch(t.details){case A.ASSET_LIST_PARSING_ERROR:case A.ASSET_LIST_LOAD_ERROR:case A.ASSET_LIST_LOAD_TIMEOUT:{const i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break}case A.BUFFER_STALLED_ERROR:{const i=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(i)&&i.event.appendInPlace){this.handleInPlaceStall(i.event);return}this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}const zo=500;class Nc extends ia{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",G.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(g.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(g.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(g.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(g.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=De.IDLE,this.setInterval(zo),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(e,t){this.tracksBuffered=[],super.onMediaDetaching(e,t)}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:s}=t;if(this.fragContextChanged(i)||(_e(i)&&(this.fragPrevious=i),this.state=De.IDLE),!s)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let r;const o=i.start;for(let l=0;l<n.length;l++)if(o>=n[l].start&&o<=n[l].end){r=n[l];break}const u=i.start+i.duration;r?r.end=u:(r={start:o,end:u},n.push(r)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}onBufferFlushing(e,t){const{startOffset:i,endOffset:s}=t;if(i===0&&s!==Number.POSITIVE_INFINITY){const n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(r=>{for(let o=0;o<r.length;){if(r[o].end<=n){r.shift();continue}else if(r[o].start<n)r[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(i,n,G.SUBTITLE)}}onError(e,t){const i=t.frag;(i==null?void 0:i.type)===G.SUBTITLE&&(t.details===A.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==De.STOPPED&&(this.state=De.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&So(this.levels,t)){this.levels=t.map(i=>new mi(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const s=new mi(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,G.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var i;if(this.currentTrackId=t.id,!((i=this.levels)!=null&&i.length)||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.state!==De.STOPPED&&this.setInterval(zo)}onSubtitleTrackLoaded(e,t){var i;const{currentTrackId:s,levels:n}=this,{details:r,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const u=n[o];if(o>=n.length||!u)return;this.log(`Subtitle track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(r.live||(i=u.details)!=null&&i.live){if(r.deltaUpdateFailed)return;const h=this.mainDetails;if(!h){this.startFragRequested=!1;return}const m=h.fragments[0];if(!u.details)r.hasProgramDateTime&&h.hasProgramDateTime?(Ar(r,h),l=r.fragmentStart):m&&(l=m.start,er(r,l));else{var c;l=this.alignPlaylists(r,u.details,(c=this.levelLastLoaded)==null?void 0:c.details),l===0&&m&&(l=m.start,er(r,l))}h&&!this.startFragRequested&&this.setStartPosition(h,l)}u.details=r,this.levelLastLoaded=u,o===s&&(this.hls.trigger(g.SUBTITLE_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===De.IDLE&&(pi(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),u.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&s!=null&&s.key&&s.iv&&Ds(s.method)){const r=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,un(s.method)).catch(o=>{throw n.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const u=performance.now();n.trigger(g.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:r,tdecrypt:u}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=De.IDLE})}}doTick(){if(!this.media){this.state=De.IDLE;return}if(this.state===De.IDLE){const{currentTrackId:e,levels:t}=this,i=t==null?void 0:t[e];if(!i||!t.length||!i.details||this.waitForLive(i))return;const{config:s}=this,n=this.getLoadPosition(),r=Yt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:u}=r,l=i.details,c=this.hls.maxBufferLength+l.levelTargetDuration;if(u>c)return;const h=l.fragments,m=h.length,v=l.edge;let y=null;const b=this.fragPrevious;if(o<v){const R=s.maxFragLookUpTolerance,L=o>v-R?0:R;y=pi(b,h,Math.max(h[0].start,o),L),!y&&b&&b.start<h[0].start&&(y=h[0])}else y=h[m-1];if(y=this.filterReplacedPrimary(y,i.details),!y)return;const S=y.sn-l.startSN,I=h[S-1];if(I&&I.cc===y.cc&&this.fragmentTracker.getState(I)===xi.NOT_LOADED&&(y=I),this.fragmentTracker.getState(y)===xi.NOT_LOADED){const R=this.mapToInitFragWhenRequired(y);R&&this.loadFragment(R,i,o)}}}loadFragment(e,t,i){_e(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new $c(this.tracksBuffered[this.currentTrackId]||[])}}class $c{constructor(e){this.buffered=void 0;const t=(i,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}const Uc={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},Wo=a=>String.fromCharCode(Uc[a]||a),rn=15,Sn=100,Gc={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Kc={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Vc={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Hc={25:2,26:4,29:6,30:8,31:10,27:13,28:15},jc=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class zc{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;se.log(`${this.time} [${e}] ${i}`)}}}const kn=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class Zo{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const s=t[i];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Wc{constructor(){this.uchar=" ",this.penState=new Zo}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class Zc{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Zo,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Sn;t++)this.chars.push(new Wc);this.logger=e}equals(e){for(let t=0;t<Sn;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Sn;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Sn;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Sn&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Sn)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Wo(e);if(this.pos>=Sn){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Sn;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<Sn;i++){const s=this.chars[i].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class Ca{constructor(e){this.rows=[],this.currRow=rn-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<rn;t++)this.rows.push(new Zc(e));this.logger=e}reset(){for(let e=0;e<rn;e++)this.rows[e].clear();this.currRow=rn-1}equals(e){let t=!0;for(let i=0;i<rn;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<rn;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<rn;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+Q(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<rn;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,r=this.lastOutputScreen;if(r){const o=r.rows[n].cueStartTime,u=this.logger.time;if(o!==null&&u!==null&&o<u)for(let l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(r.rows[n+l])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,r=Math.max(n-1,0);i.setCursor(e.indent),e.color=i.chars[r].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+Q(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",s=-1;for(let n=0;n<rn;n++){const r=this.rows[n].getTextString();r&&(s=n+1,e?t.push("Row "+s+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
`)),i}getTextAndFormat(){return this.rows}}class Yo{constructor(e,t,i){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Ca(i),this.nonDisplayedMemory=new Ca(i),this.lastOutputScreen=new Ca(i),this.currRollUpRow=this.displayedMemory.rows[rn-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[rn-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[i]}this.logger.log(2,"MIDROW: "+Q(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t: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.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class Xo{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=Xc(),this.logger=void 0;const s=this.logger=new zc;this.channels=[null,new Yo(e,t,s),new Yo(e+1,i,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let i=0;i<t.length;i+=2){const s=t[i]&127,n=t[i+1]&127;let r=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+kn([t[i],t[i+1]])+"] -> ("+kn([s,n])+")");const u=this.cmdHistory;if(s>=16&&s<=31){if(Yc(s,n,u)){Ur(null,null,u),this.logger.log(3,()=>"Repeated command ("+kn([s,n])+") is dropped");continue}Ur(s,n,this.cmdHistory),r=this.parseCmd(s,n),r||(r=this.parseMidrow(s,n)),r||(r=this.parsePAC(s,n)),r||(r=this.parseBackgroundAttributes(s,n))}else Ur(null,null,u);if(!r&&(o=this.parseChars(s,n),o)){const c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+kn([s,n])+" orig: "+kn([t[i],t[i+1]]))}}parseCmd(e,t){const i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(i||s))return!1;const n=e===20||e===21||e===23?1:2,r=this.channels[n];return e===20||e===21||e===28||e===29?t===32?r.ccRCL():t===33?r.ccBS():t===34?r.ccAOF():t===35?r.ccAON():t===36?r.ccDER():t===37?r.ccRU(2):t===38?r.ccRU(3):t===39?r.ccRU(4):t===40?r.ccFON():t===41?r.ccRDC():t===42?r.ccTR():t===43?r.ccRTD():t===44?r.ccEDM():t===45?r.ccCR():t===46?r.ccENM():t===47&&r.ccEOC():r.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+kn([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;const r=e<=23?1:2;t>=64&&t<=95?i=r===1?Gc[e]:Vc[e]:i=r===1?Kc[e]:Hc[e];const o=this.channels[r];return o?(o.setPAC(this.interpretPAC(i,t)),this.currentChannel=r,!0):!1}interpretPAC(e,t){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(e,t){let i,s=null,n=null;if(e>=25?(i=2,n=e-8):(i=1,n=e),n>=17&&n<=19){let r;n===17?r=t+80:n===18?r=t+112:r=t+144,this.logger.log(2,()=>"Special char '"+Wo(r)+"' in channel "+i),s=[r]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+kn(s).join(",")),s}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(i||s))return!1;let n;const r={};e===16||e===24?(n=Math.floor((t-32)/2),r.background=jc[n],t%2===1&&(r.background=r.background+"_semi")):t===45?r.background="transparent":(r.foreground="black",t===47&&(r.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(r),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}Ur(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Ur(a,e,t){t.a=a,t.b=e}function Yc(a,e,t){return t.a===a&&t.b===e}function Xc(){return{a:null,b:null}}var Da=function(){if(Bi!=null&&Bi.VTTCue)return self.VTTCue;const a=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,u){if(typeof u!="string"||!Array.isArray(o))return!1;const l=u.toLowerCase();return~o.indexOf(l)?l:!1}function i(o){return t(a,o)}function s(o){return t(e,o)}function n(o,...u){let l=1;for(;l<arguments.length;l++){const c=arguments[l];for(const h in c)o[h]=c[h]}return o}function r(o,u,l){const c=this,h={enumerable:!0};c.hasBeenReset=!1;let m="",v=!1,y=o,b=u,S=l,I=null,R="",L=!0,B="auto",j="start",be=50,Z="middle",fe=50,he="middle";Object.defineProperty(c,"id",n({},h,{get:function(){return m},set:function(q){m=""+q}})),Object.defineProperty(c,"pauseOnExit",n({},h,{get:function(){return v},set:function(q){v=!!q}})),Object.defineProperty(c,"startTime",n({},h,{get:function(){return y},set:function(q){if(typeof q!="number")throw new TypeError("Start time must be set to a number.");y=q,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},h,{get:function(){return b},set:function(q){if(typeof q!="number")throw new TypeError("End time must be set to a number.");b=q,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},h,{get:function(){return S},set:function(q){S=""+q,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},h,{get:function(){return I},set:function(q){I=q,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},h,{get:function(){return R},set:function(q){const Oe=i(q);if(Oe===!1)throw new SyntaxError("An invalid or illegal string was specified.");R=Oe,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},h,{get:function(){return L},set:function(q){L=!!q,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},h,{get:function(){return B},set:function(q){if(typeof q!="number"&&q!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");B=q,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},h,{get:function(){return j},set:function(q){const Oe=s(q);if(!Oe)throw new SyntaxError("An invalid or illegal string was specified.");j=Oe,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},h,{get:function(){return be},set:function(q){if(q<0||q>100)throw new Error("Position must be between 0 and 100.");be=q,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},h,{get:function(){return Z},set:function(q){const Oe=s(q);if(!Oe)throw new SyntaxError("An invalid or illegal string was specified.");Z=Oe,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},h,{get:function(){return fe},set:function(q){if(q<0||q>100)throw new Error("Size must be between 0 and 100.");fe=q,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},h,{get:function(){return he},set:function(q){const Oe=s(q);if(!Oe)throw new SyntaxError("An invalid or illegal string was specified.");he=Oe,this.hasBeenReset=!0}})),c.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}();class qc{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function qo(a){function e(i,s,n,r){return(i|0)*3600+(s|0)*60+(n|0)+parseFloat(r||0)}const t=a.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class Qc{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let s=0;s<i.length;++s)if(t===i[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Qo(a,e,t,i){const s=i?a.split(i):[a];for(const n in s){if(typeof s[n]!="string")continue;const r=s[n].split(t);if(r.length!==2)continue;const o=r[0],u=r[1];e(o,u)}}const wa=new Da(0,0,""),Gr=wa.align==="middle"?"middle":"center";function Jc(a,e,t){const i=a;function s(){const o=qo(a);if(o===null)throw new Error("Malformed timestamp: "+i);return a=a.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,u){const l=new Qc;Qo(o,function(m,v){let y;switch(m){case"region":for(let b=t.length-1;b>=0;b--)if(t[b].id===v){l.set(m,t[b].region);break}break;case"vertical":l.alt(m,v,["rl","lr"]);break;case"line":y=v.split(","),l.integer(m,y[0]),l.percent(m,y[0])&&l.set("snapToLines",!1),l.alt(m,y[0],["auto"]),y.length===2&&l.alt("lineAlign",y[1],["start",Gr,"end"]);break;case"position":y=v.split(","),l.percent(m,y[0]),y.length===2&&l.alt("positionAlign",y[1],["start",Gr,"end","line-left","line-right","auto"]);break;case"size":l.percent(m,v);break;case"align":l.alt(m,v,["start",Gr,"end","left","right"]);break}},/:/,/\s/),u.region=l.get("region",null),u.vertical=l.get("vertical","");let c=l.get("line","auto");c==="auto"&&wa.line===-1&&(c=-1),u.line=c,u.lineAlign=l.get("lineAlign","start"),u.snapToLines=l.get("snapToLines",!0),u.size=l.get("size",100),u.align=l.get("align",Gr);let h=l.get("position","auto");h==="auto"&&wa.position===50&&(h=u.align==="start"||u.align==="left"?0:u.align==="end"||u.align==="right"?100:50),u.position=h}function r(){a=a.replace(/^\s+/,"")}if(r(),e.startTime=s(),r(),a.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);a=a.slice(3),r(),e.endTime=s(),r(),n(a,e)}function Jo(a){return a.replace(/<br(?: \/)?>/gi,`
`)}class ed{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new qc,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let n=t.buffer,r=0;for(n=Jo(n);r<n.length&&n[r]!=="\r"&&n[r]!==`
`;)++r;const o=n.slice(0,r);return n[r]==="\r"&&++r,n[r]===`
`&&++r,t.buffer=n.slice(r),o}function s(n){Qo(n,function(r,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=i();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let r=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(r?r=!1:n=i(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Da(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Jc(n,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(r=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
`),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch(n){t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const td=/\r\n|\n\r|\n|\r/g,ka=function(e,t,i=0){return e.slice(i,i+t.length)===t},id=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!_(t)||!_(i)||!_(s)||!_(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*s,t+=60*60*1e3*n,t};function Pa(a,e,t){return ur(a.toString())+ur(e.toString())+ur(t)}const sd=function(e,t,i){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(r=n)!=null&&r.new;){var r;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=i};function nd(a,e,t,i,s,n,r){const o=new ed,u=nt(new Uint8Array(a)).trim().replace(td,`
`).split(`
`),l=[],c=e?fu(e.baseTime,e.timescale):0;let h="00:00.000",m=0,v=0,y,b=!0;o.oncue=function(S){const I=t[i];let R=t.ccOffset;const L=(m-c)/9e4;if(I!=null&&I.new&&(v!==void 0?R=t.ccOffset=I.start:sd(t,i,L)),L){if(!e){y=new Error("Missing initPTS for VTT MPEGTS");return}R=L-t.presentationOffset}const B=S.endTime-S.startTime,j=Vs((S.startTime+R-v)*9e4,s*9e4)/9e4;S.startTime=Math.max(j,0),S.endTime=Math.max(j+B,0);const be=S.text.trim();S.text=decodeURIComponent(encodeURIComponent(be)),S.id||(S.id=Pa(S.startTime,S.endTime,be)),S.endTime>0&&l.push(S)},o.onparsingerror=function(S){y=S},o.onflush=function(){if(y){r(y);return}n(l)},u.forEach(S=>{if(b)if(ka(S,"X-TIMESTAMP-MAP=")){b=!1,S.slice(16).split(",").forEach(I=>{ka(I,"LOCAL:")?h=I.slice(6):ka(I,"MPEGTS:")&&(m=parseInt(I.slice(7)))});try{v=id(h)/1e3}catch(I){y=I}return}else S===""&&(b=!1);o.parse(S+`
`)}),o.flush()}const Oa="stpp.ttml.im1t",el=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,tl=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,rd={left:"start",center:"center",right:"end",start:"start",end:"end"};function il(a,e,t,i){const s=N(new Uint8Array(a),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=s.map(o=>nt(o)),r=hu(e.baseTime,1,e.timescale);try{n.forEach(o=>t(ad(o,r)))}catch(o){i(o)}}function ad(a,e){const s=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(n).reduce((h,m)=>(h[m]=s.getAttribute(`ttp:${m}`)||n[m],h),{}),o=s.getAttribute("xml:space")!=="preserve",u=sl(Ma(s,"styling","style")),l=sl(Ma(s,"layout","region")),c=Ma(s,"body","[begin]");return[].map.call(c,h=>{const m=nl(h,o);if(!m||!h.hasAttribute("begin"))return null;const v=Ba(h.getAttribute("begin"),r),y=Ba(h.getAttribute("dur"),r);let b=Ba(h.getAttribute("end"),r);if(v===null)throw rl(h);if(b===null){if(y===null)throw rl(h);b=v+y}const S=new Da(v-e,b-e,m);S.id=Pa(S.startTime,S.endTime,S.text);const I=l[h.getAttribute("region")],R=u[h.getAttribute("style")],L=od(I,R,u),{textAlign:B}=L;if(B){const j=rd[B];j&&(S.lineAlign=j),S.align=B}return Ie(S,L),S}).filter(h=>h!==null)}function Ma(a,e,t){const i=a.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function sl(a){return a.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function nl(a,e){return[].slice.call(a.childNodes).reduce((t,i,s)=>{var n;return i.nodeName==="br"&&s?t+`
`:(n=i.childNodes)!=null&&n.length?nl(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function od(a,e,t){const i="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],r=a!=null&&a.hasAttribute("style")?a.getAttribute("style"):null;return r&&t.hasOwnProperty(r)&&(s=t[r]),n.reduce((o,u)=>{const l=Fa(e,i,u)||Fa(a,i,u)||Fa(s,i,u);return l&&(o[u]=l),o},{})}function Fa(a,e,t){return a&&a.hasAttributeNS(e,t)?a.getAttributeNS(e,t):null}function rl(a){return new Error(`Could not parse ttml timestamp ${a}`)}function Ba(a,e){if(!a)return null;let t=qo(a);return t===null&&(el.test(a)?t=ld(a,e):tl.test(a)&&(t=ud(a,e))),t}function ld(a,e){const t=el.exec(a),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function ud(a,e){const t=tl.exec(a),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class Kr{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}class cd{constructor(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=ll(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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}},e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(g.FRAG_LOADING,this.onFragLoading,this),e.on(g.FRAG_LOADED,this.onFragLoaded,this),e.on(g.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(g.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(g.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(g.FRAG_LOADING,this.onFragLoading,this),e.off(g.FRAG_LOADED,this.onFragLoaded,this),e.off(g.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(g.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(g.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(g.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Kr(this,"textTrack1"),t=new Kr(this,"textTrack2"),i=new Kr(this,"textTrack3"),s=new Kr(this,"textTrack4");this.cea608Parser1=new Xo(1,e,t),this.cea608Parser2=new Xo(3,i,s)}addCues(e,t,i,s,n){let r=!1;for(let o=n.length;o--;){const u=n[o],l=dd(u[0],u[1],t,i);if(l>=0&&(u[0]=Math.min(u[0],t),u[1]=Math.max(u[1],i),r=!0,l/(i-t)>.5))return}if(r||n.push([t,i]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,i,s)}else{const o=this.Cues.newCue(null,t,i,s);this.hls.trigger(g.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n,trackId:r}){const{unparsedVttFrags:o}=this;i===G.MAIN&&(this.initPTS[t.cc]={baseTime:s,timescale:n,trackId:r}),o.length&&(this.unparsedVttFrags=[],o.forEach(u=>{this.initPTS[u.frag.cc]?this.onFragLoaded(g.FRAG_LOADED,u):this.hls.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:u.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let s=0;s<i.textTracks.length;s++){const n=i.textTracks[s];if(ol(n,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:s}=this,{label:n,languageCode:r}=t[e],o=this.getExistingTrack(n,r);if(o)i[e]=o,Hn(i[e]),Go(i[e],s);else{const u=this.createTextTrack("captions",n,r);u&&(u[e]=!0,i[e]=u)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,s={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(g.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,i){const s=this.media;if(s)return s.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}onMediaDetaching(e,t){const i=!!t.transferMedia;if(this.media=null,i)return;const{captionsTracks:s}=this;Object.keys(s).forEach(n=>{Hn(s[n]),delete s[n]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=ll(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)Hn(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],s=i.some(n=>n.textCodec===Oa);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(So(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const r=this.media,o=r?Br(r.textTracks):null;if(this.tracks.forEach((u,l)=>{let c;if(o){let h=null;for(let m=0;m<o.length;m++)if(o[m]&&ol(o[m],u)){h=o[m],o[m]=null;break}h&&(c=h)}if(c)Hn(c);else{const h=al(u);c=this.createTextTrack(h,u.name,u.lang),c&&(c.mode="disabled")}c&&this.textTracks.push(c)}),o!=null&&o.length){const u=o.filter(l=>l!==null).map(l=>l.label);u.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${u.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const r=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(g.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:r})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const n=`textTrack${s[1]}`,r=this.captionsProperties[n];r&&(r.label=i.name,i.lang&&(r.languageCode=i.lang),r.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===G.MAIN){var i,s;const{cea608Parser1:n,cea608Parser2:r,lastSn:o}=this,{cc:u,sn:l}=t.frag,c=(i=(s=t.part)==null?void 0:s.index)!=null?i:-1;n&&r&&(l!==o+1||l===o&&c!==this.lastPartIndex+1||u!==this.lastCc)&&(n.reset(),r.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=c}}onFragLoaded(e,t){const{frag:i,payload:s}=t;if(i.type===G.SUBTITLE)if(s.byteLength){const n=i.decryptdata,r="stats"in t;if(n==null||!n.encrypted||r){const o=this.tracks[i.level],u=this.vttCCs;u[i.cc]||(u[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===Oa?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;il(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),i.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{i.logger.log(`Failed to parse IMSC1: ${s}`),i.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;const{frag:i,payload:s}=e,{initPTS:n,unparsedVttFrags:r}=this,o=n.length-1;if(!n[i.cc]&&o===-1){r.push(e);return}const u=this.hls,l=(t=i.initSegment)!=null&&t.data?ut(i.initSegment.data,new Uint8Array(s)).buffer:s;nd(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,c=>{this._appendCues(c,i.level),u.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},c=>{const h=c.message==="Missing initPTS for VTT MPEGTS";h?r.push(e):this._fallbackToIMSC1(i,s),u.logger.log(`Failed to parse VTT cue: ${c}`),!(h&&o>i.cc)&&u.trigger(g.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:c})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||il(t,this.initPTS[e.cc],()=>{i.textCodec=Oa,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Ko(s,n))}else{const s=this.tracks[t];if(!s)return;const n=s.default?"default":"subtitles"+t;i.trigger(g.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===G.SUBTITLE&&this.onFragLoaded(g.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:i,samples:s}=t;if(!(i.type===G.MAIN&&this.closedCaptionsForLevel(i)==="NONE"))for(let n=0;n<s.length;n++){const r=s[n].bytes;if(r){this.cea608Parser1||this.initCea608Parsers();const o=this.extractCea608Data(r);this.cea608Parser1.addData(s[n].pts,o[0]),this.cea608Parser2.addData(s[n].pts,o[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:s,type:n}){const{media:r}=this;if(!(!r||r.currentTime<i)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(u=>Ia(o[u],t,i))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(u=>Ia(o[u],t,s))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let s=2;for(let n=0;n<i;n++){const r=e[s++],o=127&e[s++],u=127&e[s++];if(o===0&&u===0)continue;if((4&r)!==0){const c=3&r;(c===0||c===1)&&(t[c].push(o),t[c].push(u))}}return t}}function al(a){return a.characteristics&&/transcribes-spoken-dialog/gi.test(a.characteristics)&&/describes-music-and-sound/gi.test(a.characteristics)?"captions":"subtitles"}function ol(a,e){return!!a&&a.kind===al(e)&&ya(e,a)}function dd(a,e,t,i){return Math.min(e,i)-Math.max(a,t)}function ll(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const hd=/\s/,fd={newCue(a,e,t,i){const s=[];let n,r,o,u,l;const c=self.VTTCue||self.TextTrackCue;for(let m=0;m<i.rows.length;m++)if(n=i.rows[m],o=!0,u=0,l="",!n.isEmpty()){var h;for(let b=0;b<n.chars.length;b++)hd.test(n.chars[b].uchar)&&o?u++:(l+=n.chars[b].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),u>=16?u--:u++;const v=Jo(l.trim()),y=Pa(e,t,v);a!=null&&(h=a.cues)!=null&&h.getCueById(y)||(r=new c(e,t,v),r.id=y,r.line=m+1,r.align="left",r.position=10+Math.min(80,Math.floor(u*8/32)*10),s.push(r))}return a&&s.length&&(s.sort((m,v)=>m.line==="auto"||v.line==="auto"?0:m.line>8&&v.line>8?v.line-m.line:m.line-v.line),s.forEach(m=>Ko(a,m))),s}};function md(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(a){}return!1}const gd=/(\d+)-(\d+)\/(\d+)/;class ul{constructor(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=e.fetchSetup||Ed,this.controller=new self.AbortController,this.stats=new Pe}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const n=pd(e,this.controller.signal),r=e.responseType==="arraybuffer",o=r?"byteLength":"length",{maxTimeToFirstByteMs:u,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=u&&_(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(s,e,this.response))},t.timeout),(or(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(h=>{var m;this.response=this.loader=h;const v=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(s,e,this.response))},l-(v-s.loading.start)),!h.ok){const{status:b,statusText:S}=h;throw new _d(S||"fetch, bad network response",b,h)}s.loading.first=v,s.total=yd(h.headers)||s.total;const y=(m=this.callbacks)==null?void 0:m.onProgress;return y&&_(t.highWaterMark)?this.loadProgressively(h,s,e,t.highWaterMark,y):r?h.arrayBuffer():e.responseType==="json"?h.json():h.text()}).then(h=>{var m,v;const y=this.response;if(!y)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const b=h[o];b&&(s.loaded=s.total=b);const S={url:y.url,data:h,code:y.status},I=(m=this.callbacks)==null?void 0:m.onProgress;I&&!_(t.highWaterMark)&&I(s,e,h,y),(v=this.callbacks)==null||v.onSuccess(S,s,e,y)}).catch(h=>{var m;if(self.clearTimeout(this.requestTimeout),s.aborted)return;const v=h&&h.code||0,y=h?h.message:null;(m=this.callbacks)==null||m.onError({code:v,text:y},e,h?h.details:null,s)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,s=0,n){const r=new za,o=e.body.getReader(),u=()=>o.read().then(l=>{if(l.done)return r.dataLength&&n(t,i,r.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));const c=l.value,h=c.length;return t.loaded+=h,h<s||r.dataLength?(r.push(c),r.dataLength>=s&&n(t,i,r.flush().buffer,e)):n(t,i,c.buffer,e),u()}).catch(()=>Promise.reject());return u()}}function pd(a,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ie({},a.headers))};return a.rangeEnd&&t.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),t}function vd(a){const e=gd.exec(a);if(e)return parseInt(e[2])-parseInt(e[1])+1}function yd(a){const e=a.get("Content-Range");if(e){const i=vd(e);if(_(i))return i}const t=a.get("Content-Length");if(t)return parseInt(t)}function Ed(a,e){return new self.Request(a.url,e)}class _d extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const Sd=/^age:\s*[\d.]+\s*$/im;class cl{constructor(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=e&&e.xhrSetup||null,this.stats=new Pe,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){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=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==i||this.stats.aborted))return n(i,t.url)}).catch(r=>{if(!(this.loader!==i||this.stats.aborted))return i.open("GET",t.url,!0),n(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(r=>{var o;(o=this.callbacks)==null||o.onError({code:i.status,text:r.message},t,i,s)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:r}=i.loadPolicy;if(s)for(const o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=n&&_(n)?n:r,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const s=t.readyState,n=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const l=t.status,c=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){const y=c!=null?c:t.response;if(y!=null){var r,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const b=t.responseType==="arraybuffer"?y.byteLength:y.length;i.loaded=i.total=b,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const S=(r=this.callbacks)==null?void 0:r.onProgress;S&&S(i,e,y,t);const I={url:t.responseURL,data:y,code:l};(o=this.callbacks)==null||o.onSuccess(I,i,e,t);return}}const h=n.loadPolicy.errorRetry,m=i.retry,v={url:e.url,data:void 0,code:l};if(Ji(h,m,!1,v))this.retry(h);else{var u;se.error(`${l} while loading ${e.url}`),(u=this.callbacks)==null||u.onError({code:l,text:t.statusText},e,t,i)}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Ji(e,t,!0))this.retry(e);else{var i;se.warn(`timeout while loading ${(i=this.context)==null?void 0:i.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=ji(e,i.retry),i.retry++,se.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Sd.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const bd={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Td=H(H({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,startOnSegmentBoundary:!1,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",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,ignorePlaylistParsingErrors:!1,loader:cl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Si,bufferController:Lu,capLevelController:_a,errorController:fs,fpsController:Ic,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:vn,requireKeySystemAccessOnStart:!1,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,preserveManualLevelOnError:!1,certLoadPolicy:{default:bd},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},xd()),{},{subtitleStreamController:Nc,subtitleTrackController:Cc,timelineController:cd,audioStreamController:xu,audioTrackController:Au,emeController:Vn,cmcdController:bc,contentSteeringController:xc,interstitialsController:Bc});function xd(){return{cueHandler:fd,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Ad(a,e,t){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=Na(a),s=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(r=>{const o=`${r==="level"?"playlist":r}LoadPolicy`,u=e[o]===void 0,l=[];n.forEach(c=>{const h=`${r}Loading${c}`,m=e[h];if(m!==void 0&&u){l.push(h);const v=i[o].default;switch(e[o]={default:v},c){case"TimeOut":v.maxLoadTimeMs=m,v.maxTimeToFirstByteMs=m;break;case"MaxRetry":v.errorRetry.maxNumRetry=m,v.timeoutRetry.maxNumRetry=m;break;case"RetryDelay":v.errorRetry.retryDelayMs=m,v.timeoutRetry.retryDelayMs=m;break;case"MaxRetryTimeout":v.errorRetry.maxRetryDelayMs=m,v.timeoutRetry.maxRetryDelayMs=m;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${Q(e[o])}`)}),H(H({},i),e)}function Na(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(Na):Object.keys(a).reduce((e,t)=>(e[t]=Na(a[t]),e),{}):a}function Id(a,e){const t=a.loader;t!==ul&&t!==cl?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1):md()&&(a.loader=ul,a.progressive=!0,a.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Vr=2,Rd=.1,Ld=.05,Cd=100;class Dd extends js{constructor(e,t){super("gap-controller",e.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var i;(i=this.media)!=null&&i.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{if(this.hls){var i;this.ended=((i=this.media)==null?void 0:i.currentTime)||1,this.hls.trigger(g.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(e,t){this.setInterval(Cd),this.mediaSource=t.mediaSource;const i=this.media=t.media;ws(i,"playing",this.onMediaPlaying),ws(i,"waiting",this.onMediaWaiting),ws(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(Os(i,"playing",this.onMediaPlaying),Os(i,"waiting",this.onMediaWaiting),Os(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(e,t){this.buffered=t.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var e;if(!((e=this.media)!=null&&e.readyState)||!this.hasBuffered)return;const t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}poll(e,t){var i,s;const n=(i=this.hls)==null?void 0:i.config;if(!n)return;const r=this.media;if(!r)return;const{seeking:o}=r,u=this.seeking&&!o,l=!this.seeking&&o,c=r.paused&&!o||r.ended||r.playbackRate===0;if(this.seeking=o,e!==t){t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(l||u){u&&this.stallResolved(e);return}if(c){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&r.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(g.MEDIA_ENDED,{stalled:!1}));return}if(!Yt.getBuffered(r).length){this.nudgeRetry=0;return}const h=Yt.bufferInfo(r,e,0),m=h.nextStart||0,v=this.fragmentTracker;if(o&&v&&this.hls){const be=dl(this.hls.inFlightFragments,e),Z=h.len>Vr,fe=!m||be||m-e>Vr&&!v.getPartialFragment(e);if(Z||fe)return;this.moved=!1}const y=(s=this.hls)==null?void 0:s.latestLevelDetails;if(!this.moved&&this.stalled!==null&&v){if(!(h.len>0)&&!m)return;const Z=Math.max(m,h.start||0)-e,he=!!(y!=null&&y.live)?y.targetduration*2:Vr,q=Hr(e,v);if(Z>0&&(Z<=he||q)){r.paused||this._trySkipBufferHole(q);return}}const b=n.detectStallWithCurrentTimeMs,S=self.performance.now(),I=this.waiting;let R=this.stalled;if(R===null)if(I>0&&S-I<b)R=this.stalled=I;else{this.stalled=S;return}const L=S-R;if(!o&&(L>=b||I)&&this.hls){var B;if(((B=this.mediaSource)==null?void 0:B.readyState)==="ended"&&!(y!=null&&y.live)&&Math.abs(e-((y==null?void 0:y.edge)||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(g.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(h),!this.media||!this.hls)return}const j=Yt.bufferInfo(r,e,n.maxBufferHole);this._tryFixBufferStall(j,L,e)}stallResolved(e){const t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){const i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(g.STALL_RESOLVED,{})}}nudgeOnVideoHole(e,t){var i;const s=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&(i=this.buffered.audio)!=null&&i.length&&s&&s.length>1&&e>s.end(0)){const n=Yt.bufferedInfo(Yt.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){const r=Yt.timeRangesToArray(s),o=Yt.bufferedInfo(r,t,0).bufferedIndex;if(o>-1&&o<r.length-1){const u=Yt.bufferedInfo(r,e,0).bufferedIndex,l=r[o].end,c=r[o+1].start;if((u===-1||u>o)&&c-l<1&&e-l<2){const h=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${c} buffered index: ${u}`);this.warn(h.message),this.media.currentTime+=1e-6;let m=Hr(e,this.fragmentTracker);m&&"fragment"in m?m=m.fragment:m||(m=void 0);const v=Yt.bufferInfo(this.media,e,0);this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:m,buffer:v.len,bufferInfo:v})}}}}}_tryFixBufferStall(e,t,i){var s,n;const{fragmentTracker:r,media:o}=this,u=(s=this.hls)==null?void 0:s.config;if(!o||!r||!u)return;const l=(n=this.hls)==null?void 0:n.latestLevelDetails,c=Hr(i,r);if((c||l!=null&&l.live&&i<l.fragmentStart)&&(this._trySkipBufferHole(c)||!this.media))return;const h=e.buffered,m=this.adjacentTraversal(e,i);(h&&h.length>1&&e.len>u.maxBufferHole||e.nextStart&&(e.nextStart-i<u.maxBufferHole||m))&&(t>u.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}adjacentTraversal(e,t){const i=this.fragmentTracker,s=e.nextStart;if(i&&s){const n=i.getFragAtPos(t,G.MAIN),r=i.getFragAtPos(s,G.MAIN);if(n&&r)return r.sn-n.sn<2}return!1}_reportStall(e){const{hls:t,media:i,stallReported:s,stalled:n}=this;if(!s&&n!==null&&i&&t){this.stallReported=!0;const r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${Q(e)})`);this.warn(r.message),t.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:n}})}}_trySkipBufferHole(e){var t;const{fragmentTracker:i,media:s}=this,n=(t=this.hls)==null?void 0:t.config;if(!s||!i||!n)return 0;const r=s.currentTime,o=Yt.bufferInfo(s,r,0),u=r<o.start?o.start:o.nextStart;if(u&&this.hls){const c=o.len<=n.maxBufferHole,h=o.len>0&&o.len<1&&s.readyState<3,m=u-r;if(m>0&&(c||h)){if(m>n.maxBufferHole){let y=!1;if(r===0){const b=i.getAppendedFrag(0,G.MAIN);b&&u<b.end&&(y=!0)}if(!y&&e){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||dl(this.hls.inFlightFragments,u))return 0;let S=!1,I=e.end;for(;I<u;){const R=Hr(I,i);if(R)I+=R.duration;else{S=!0;break}}if(S)return 0}}const v=Math.max(u+Ld,r+Rd);if(this.warn(`skipping hole, adjusting currentTime from ${r} to ${v}`),this.moved=!0,s.currentTime=v,!(e!=null&&e.gap)){const y=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${v}`),b={type:Y.MEDIA_ERROR,details:A.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?b.part=e:b.frag=e),this.hls.trigger(g.ERROR,b)}return v}}return 0}_tryNudgeBuffer(e){const{hls:t,media:i,nudgeRetry:s}=this,n=t==null?void 0:t.config;if(!i||!n)return 0;const r=i.currentTime;if(this.nudgeRetry++,s<n.nudgeMaxRetry){const o=r+(s+1)*n.nudgeOffset,u=new Error(`Nudging 'currentTime' from ${r} to ${o}`);this.warn(u.message),i.currentTime=o,t.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.BUFFER_NUDGE_ON_STALL,error:u,fatal:!1,buffer:e.len,bufferInfo:e})}else{const o=new Error(`Playhead still not moving while enough data buffered @${r} after ${n.nudgeMaxRetry} nudges`);this.error(o.message),t.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function dl(a,e){const t=hl(a.main);if(t&&t.start<=e)return t;const i=hl(a.audio);return i&&i.start<=e?i:null}function hl(a){if(!a)return null;switch(a.state){case De.IDLE:case De.STOPPED:case De.ENDED:case De.ERROR:return null}return a.frag}function Hr(a,e){return e.getAppendedFrag(a,G.MAIN)||e.getPartialFragment(a)}const wd=.25;function $a(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function Ua(a,e,t,i,s){let n=new a(e,t,"");try{n.value=i,s&&(n.type=s)}catch(r){n=new a(e,t,Q(s?H({type:s},i):i))}return n}const jr=(()=>{const a=$a();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class kd{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(g.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:e}=this;e&&(e.on(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:e}=this;e&&(e.off(g.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(g.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(e,t){var i;this.media=t.media,((i=t.overrides)==null?void 0:i.cueRemoval)===!1&&(this.removeCues=!1)}onMediaAttached(){var e;const t=(e=this.hls)==null?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&Hn(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Go(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:i,enableID3MetadataCues:s}=this.hls.config;if(!i&&!s)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const r=$a();if(r)for(let o=0;o<n.length;o++){const u=n[o].type;if(u===Ks.emsg&&!i||!s)continue;const l=eo(n[o].data),c=n[o].pts;let h=c+n[o].duration;h>jr&&(h=jr),h-c<=0&&(h=c+wd);for(let v=0;v<l.length;v++){const y=l[v];if(!to(y)){this.updateId3CueEnds(c,u);const b=Ua(r,c,h,y,u);b&&this.id3Track.addCue(b)}}}}updateId3CueEnds(e,t){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let n=s.length;n--;){const r=s[n];r.type===t&&r.startTime<e&&r.endTime===jr&&(r.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:s}){const{id3Track:n,hls:r}=this;if(!r)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:u}}=r;if(n&&(o||u)){let l;s==="audio"?l=c=>c.type===Ks.audioId3&&u:s==="video"?l=c=>c.type===Ks.emsg&&o:l=c=>c.type===Ks.audioId3&&u||c.type===Ks.emsg&&o,Ia(n,t,i,l)}}onLevelUpdated(e,{details:t}){this.updateDateRangeCues(t,!0)}onLevelPtsUpdated(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}updateDateRangeCues(e,t){if(!this.hls||!this.media)return;const{assetPlayerId:i,timelineOffset:s,enableDateRangeMetadataCues:n,interstitialsController:r}=this.hls.config;if(!n)return;const o=$a();if(i&&s&&!r){const{fragmentStart:b,fragmentEnd:S}=e;let I=this.assetCue;I?(I.startTime=b,I.endTime=S):o&&(I=this.assetCue=Ua(o,b,S,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),I&&(I.id=i,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(I),I.addEventListener("enter",this.onEventCueEnter)))}if(!e.hasProgramDateTime)return;const{id3Track:u}=this,{dateRanges:l}=e,c=Object.keys(l);let h=this.dateRangeCuesAppended;if(u&&t){var m;if((m=u.cues)!=null&&m.length){const b=Object.keys(h).filter(S=>!c.includes(S));for(let S=b.length;S--;){var v;const I=b[S],R=(v=h[I])==null?void 0:v.cues;delete h[I],R&&Object.keys(R).forEach(L=>{const B=R[L];if(B){B.removeEventListener("enter",this.onEventCueEnter);try{u.removeCue(B)}catch(j){}}})}}else h=this.dateRangeCuesAppended={}}const y=e.fragments[e.fragments.length-1];if(!(c.length===0||!_(y==null?void 0:y.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let b=0;b<c.length;b++){const S=c[b],I=l[S],R=I.startTime,L=h[S],B=(L==null?void 0:L.cues)||{};let j=(L==null?void 0:L.durationKnown)||!1,be=jr;const{duration:Z,endDate:fe}=I;if(fe&&Z!==null)be=R+Z,j=!0;else if(I.endOnNext&&!j){const q=c.reduce((Oe,gt)=>{if(gt!==I.id){const wt=l[gt];if(wt.class===I.class&&wt.startDate>I.startDate&&(!Oe||I.startDate<Oe.startDate))return wt}return Oe},null);q&&(be=q.startTime,j=!0)}const he=Object.keys(I.attr);for(let q=0;q<he.length;q++){const Oe=he[q];if(!Cs(Oe))continue;const gt=B[Oe];if(gt)j&&!(L!=null&&L.durationKnown)?gt.endTime=be:Math.abs(gt.startTime-R)>.01&&(gt.startTime=R,gt.endTime=be);else if(o){let wt=I.attr[Oe];tn(Oe)&&(wt=ee(wt));const kt=Ua(o,R,be,{key:Oe,data:wt},Ks.dateRange);kt&&(kt.id=S,this.id3Track.addCue(kt),B[Oe]=kt,r&&(Oe==="X-ASSET-LIST"||Oe==="X-ASSET-URL")&&kt.addEventListener("enter",this.onEventCueEnter))}}h[S]={cues:B,dateRange:I,durationKnown:j}}}}}class Pd{constructor(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=()=>{const{media:t}=this,i=this.levelDetails;if(!t||!i)return;this.currentTime=t.currentTime;const s=this.computeLatency();if(s===null)return;this._latency=s;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:r}=this.config;if(!n||r===1||!i.live)return;const o=this.targetLatency;if(o===null)return;const u=s-o,l=Math.min(this.maxLatency,o+i.targetduration);if(u<l&&u>.05&&this.forwardBufferLength>1){const h=Math.min(2,Math.max(1,r)),m=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20,v=Math.min(h,Math.max(1,m));this.changeMediaPlaybackRate(t,v)}else t.playbackRate!==1&&t.playbackRate!==0&&this.changeMediaPlaybackRate(t,1)},this.hls=e,this.config=e.config,this.registerListeners()}get levelDetails(){var e;return((e=this.hls)==null?void 0:e.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:e}=this;if(e.liveMaxLatencyDuration!==void 0)return e.liveMaxLatencyDuration;const t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const e=this.levelDetails;if(e===null||this.hls===null)return null;const{holdBack:t,partHoldBack:i,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:r,lowLatencyMode:o}=this.config,u=this.hls.userConfig;let l=o&&i||t;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||l===0)&&(l=n!==void 0?n:r*s);const c=s;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)}set targetLatency(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency;if(e===null||t===null)return null;const i=this.levelDetails;if(i===null)return null;const s=i.edge,n=e-t-this.edgeStalled,r=s-i.totalduration,o=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(r,n),o)}get drift(){const e=this.levelDetails;return e===null?1:e.drift}get edgeStalled(){const e=this.levelDetails;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e}=this,t=this.levelDetails;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:e}=this;e&&(e.on(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(g.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.ERROR,this.onError,this))}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(e,t){var i;t.details===A.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&(i=this.levelDetails)!=null&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(e,t){var i,s;e.playbackRate!==t&&((i=this.hls)==null||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${(s=this.targetLatency)==null?void 0:s.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}estimateLiveEdge(){const e=this.levelDetails;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}class Od extends va{constructor(e,t){super(e,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=this.hls.config.preferManagedMediaSource,s=[],n={},r={};let o=!1,u=!1,l=!1;t.levels.forEach(c=>{const h=c.attrs;let{audioCodec:m,videoCodec:v}=c;m&&(c.audioCodec=m=Ii(m,i)||void 0),v&&(v=c.videoCodec=Fe(v));const{width:y,height:b,unknownCodecs:S}=c,I=(S==null?void 0:S.length)||0;if(o||(o=!!(y&&b)),u||(u=!!v),l||(l=!!m),I||m&&!this.isAudioSupported(m)||v&&!this.isVideoSupported(v)){this.log(`Some or all CODECS not supported "${h.CODECS}"`);return}const{CODECS:R,"FRAME-RATE":L,"HDCP-LEVEL":B,"PATHWAY-ID":j,RESOLUTION:be,"VIDEO-RANGE":Z}=h,he=`${`${j||"."}-`}${c.bitrate}-${be}-${L}-${R}-${Z}-${B}`;if(n[he])if(n[he].uri!==c.url&&!c.attrs["PATHWAY-ID"]){const q=r[he]+=1;c.attrs["PATHWAY-ID"]=new Array(q+1).join(".");const Oe=this.createLevel(c);n[he]=Oe,s.push(Oe)}else n[he].addGroupId("audio",h.AUDIO),n[he].addGroupId("text",h.SUBTITLES);else{const q=this.createLevel(c);n[he]=q,r[he]=1,s.push(q)}}),this.filterAndSortMediaOptions(s,t,o,u,l)}createLevel(e){const t=new mi(e),i=e.supplemental;if(i!=null&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){const s=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(s.message),t.supportedResult=U(s,[])}return t}isAudioSupported(e){return ui(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return ui(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,s,n){var r;let o=[],u=[],l=e;const c=((r=t.stats)==null?void 0:r.parsing)||{};if((i||s)&&n&&(l=l.filter(({videoCodec:R,videoRange:L,width:B,height:j})=>(!!R||!!(B&&j))&&Ct(L))),l.length===0){Promise.resolve().then(()=>{if(this.hls){let R="no level with compatible codecs found in manifest",L=R;t.levels.length&&(L=`one or more CODECS in variant not supported: ${Q(t.levels.map(j=>j.attrs.CODECS).filter((j,be,Z)=>Z.indexOf(j)===be))}`,this.warn(L),R+=` (${L})`);const B=new Error(R);this.hls.trigger(g.ERROR,{type:Y.MEDIA_ERROR,details:A.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:B,reason:L})}}),c.end=performance.now();return}t.audioTracks&&(o=t.audioTracks.filter(R=>!R.audioCodec||this.isAudioSupported(R.audioCodec)),fl(o)),t.subtitles&&(u=t.subtitles,fl(u));const h=l.slice(0);l.sort((R,L)=>{if(R.attrs["HDCP-LEVEL"]!==L.attrs["HDCP-LEVEL"])return(R.attrs["HDCP-LEVEL"]||"")>(L.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&R.height!==L.height)return R.height-L.height;if(R.frameRate!==L.frameRate)return R.frameRate-L.frameRate;if(R.videoRange!==L.videoRange)return Ne.indexOf(R.videoRange)-Ne.indexOf(L.videoRange);if(R.videoCodec!==L.videoCodec){const B=St(R.videoCodec),j=St(L.videoCodec);if(B!==j)return j-B}if(R.uri===L.uri&&R.codecSet!==L.codecSet){const B=ti(R.codecSet),j=ti(L.codecSet);if(B!==j)return j-B}return R.averageBitrate!==L.averageBitrate?R.averageBitrate-L.averageBitrate:0});let m=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==h.length)){for(let R=0;R<h.length;R++)if(h[R].pathwayId===l[0].pathwayId){m=h[R];break}}this._levels=l;for(let R=0;R<l.length;R++)if(l[R]===m){var v;this._firstLevel=R;const L=m.bitrate,B=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${L}`),((v=this.hls.userConfig)==null?void 0:v.abrEwmaDefaultEstimate)===void 0){const j=Math.min(L,this.hls.config.abrEwmaDefaultEstimateMax);j>B&&B===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=j)}break}const y=n&&!s,b=this.hls.config,S=!!(b.audioStreamController&&b.audioTrackController),I={levels:l,audioTracks:o,subtitleTracks:u,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:S&&!y&&o.some(R=>!!R.url)};c.end=performance.now(),this.hls.trigger(g.MANIFEST_PARSED,I)}get levels(){return this._levels.length===0?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const c=new Error("invalid level idx"),h=e<0;if(this.hls.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.LEVEL_SWITCH_ERROR,level:e,fatal:h,error:c,reason:c.message}),h)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,r=t[e],o=r.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=r,i===e&&s&&n===o)return;this.log(`Switching to level ${e} (${r.height?r.height+"p ":""}${r.videoRange?r.videoRange+" ":""}${r.codecSet?r.codecSet+" ":""}@${r.bitrate})${o?" with Pathway "+o:""} from level ${i}${n?" with Pathway "+n:""}`);const u={level:e,attrs:r.attrs,details:r.details,bitrate:r.bitrate,averageBitrate:r.averageBitrate,maxBitrate:r.maxBitrate,realBitrate:r.realBitrate,width:r.width,height:r.height,codecSet:r.codecSet,audioCodec:r.audioCodec,videoCodec:r.videoCodec,audioGroups:r.audioGroups,subtitleGroups:r.subtitleGroups,loaded:r.loaded,loadError:r.loadError,fragmentError:r.fragmentError,name:r.name,id:r.id,uri:r.uri,url:r.url,urlId:0,audioGroupIds:r.audioGroupIds,textGroupIds:r.textGroupIds};this.hls.trigger(g.LEVEL_SWITCHING,u);const l=r.details;if(!l||l.live){const c=this.switchParams(r.uri,s==null?void 0:s.details,l);this.loadPlaylist(c)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(e){if(this.steering){const t=this.steering.pathways(),i=e.filter(s=>t.indexOf(s)!==-1);if(e.length<1){this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);return}this.steering.pathwayPriority=i}}onError(e,t){t.fatal||!t.context||t.context.type===te.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===G.MAIN){const i=t.elementaryStreams;if(!Object.keys(i).some(n=>!!i[n]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var i;const{level:s,details:n}=t,r=t.levelInfo;if(!r){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}if(r===this.currentLevel||t.withoutMultiVariant){r.fragmentError===0&&(r.loadError=0);let u=r.details;u===t.details&&u.advanced&&(u=void 0),this.playlistLoaded(s,t,u)}else(i=t.deliveryDirectives)!=null&&i.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}loadingPlaylist(e,t){super.loadingPlaylist(e,t);const i=this.getUrlWithDirectives(e.uri,t),s=this.currentLevelIndex,n=e.attrs["PATHWAY-ID"],r=e.details,o=r==null?void 0:r.age;this.log(`Loading level index ${s}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""}${n?" Pathway "+n:""}${o&&r.live?" age "+o.toFixed(1)+(r.type?" "+r.type||0:""):""} ${i}`),this.hls.trigger(g.LEVEL_LOADING,{url:i,level:s,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;if(this._levels.length===1)return;const i=this._levels.filter((n,r)=>r!==e?!0:(this.steering&&this.steering.removeLevel(n),n===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,n.details&&n.details.fragments.forEach(o=>o.level=-1)),!1));Ts(i),this._levels=i,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const s=i.length-1;this._firstLevel=Math.min(this._firstLevel,s),this._startLevel&&(this._startLevel=Math.min(this._startLevel,s)),this.hls.trigger(g.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(g.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function fl(a){const e={};a.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function ml(){return self.SourceBuffer||self.WebKitSourceBuffer}function gl(){if(!vt())return!1;const e=ml();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Md(){if(!gl())return!1;const a=vt();return typeof(a==null?void 0:a.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>a.isTypeSupported(Lt(e,"video")))||["mp4a.40.2","fLaC"].some(e=>a.isTypeSupported(Lt(e,"audio"))))}function Fd(){var a;const e=ml();return typeof(e==null||(a=e.prototype)==null?void 0:a.changeType)=="function"}const Bd=100;class Nd extends ia{constructor(e,t,i){super(e,t,i,"stream-controller",G.MAIN),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const s=this.media,n=s?s.currentTime:null;if(n===null||!_(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;const r=this.getFwdBufferInfoAtPos(s,n,G.MAIN,0);if(r===null||r.len===0){this.warn(`Main forward buffer length at ${n} on "seeked" event ${r?r.len:"empty"})`);return}this.tick()},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:e}=this;e.on(g.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.LEVEL_LOADED,this.onLevelLoaded,this),e.on(g.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(g.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(g.BUFFER_CREATED,this.onBufferCreated,this),e.on(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(g.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(g.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.LEVEL_LOADED,this.onLevelLoaded,this),e.off(g.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(g.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(g.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(g.BUFFER_CREATED,this.onBufferCreated,this),e.off(g.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(g.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(e,t){if(this.levels){const{lastCurrentTime:i,hls:s}=this;if(this.stopLoad(),this.setInterval(Bd),this.level=-1,!this.startFragRequested){let n=s.startLevel;n===-1&&(s.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=s.firstAutoLevel),s.nextLoadLevel=n,this.level=s.loadLevel,this._hasEnoughToStart=!!t}i>0&&e===-1&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=De.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=De.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case De.WAITING_LEVEL:{const{levels:e,level:t}=this,i=e==null?void 0:e[t],s=i==null?void 0:i.details;if(s&&(!s.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(s))break;this.state=De.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=De.IDLE;break}break}case De.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate();break}this.state===De.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var e;super.onTickEnd(),(e=this.media)!=null&&e.readyState&&this.media.seeking===!1&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:s}=this;if(t===null||!s&&!this.primaryPrefetch&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=this.buffering?e.nextLoadLevel:e.loadLevel;if(!(i!=null&&i[n]))return;const r=i[n],o=this.getMainFwdBufferInfo();if(o===null)return;const u=this.getLevelDetails();if(u&&this._streamEnded(o,u)){const b={};this.altAudio===2&&(b.type="video"),this.hls.trigger(g.BUFFER_EOS,b),this.state=De.ENDED;return}if(!this.buffering)return;e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const l=r.details;if(!l||this.state===De.WAITING_LEVEL||this.waitForLive(r)){this.level=n,this.state=De.WAITING_LEVEL,this.startFragRequested=!1;return}const c=o.len,h=this.getMaxBufferLength(r.maxBitrate);if(c>=h)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const m=this.backtrackFragment?this.backtrackFragment.start:o.end;let v=this.getNextFragment(m,l);if(this.couldBacktrack&&!this.fragPrevious&&v&&_e(v)&&this.fragmentTracker.getState(v)!==xi.OK){var y;const S=((y=this.backtrackFragment)!=null?y:v).sn-l.startSN,I=l.fragments[S-1];I&&v.cc===I.cc&&(v=I,this.fragmentTracker.removeFragment(I))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(v&&this.isLoopLoading(v,m)){if(!v.gap){const S=this.audioOnly&&!this.altAudio?ke.AUDIO:ke.VIDEO,I=(S===ke.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;I&&this.afterBufferFlushed(I,S,G.MAIN)}v=this.getNextFragmentLoopLoading(v,l,o,G.MAIN,h)}v&&(v.initSegment&&!v.initSegment.data&&!this.bitrateTest&&(v=v.initSegment),this.loadFragment(v,r,m))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);s===xi.NOT_LOADED||s===xi.PARTIAL?_e(e)?this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):super.loadFragment(e,t,i):this._loadInitSegment(e,t):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,G.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,u=e[o],l=this.fragLastKbps;l&&this.fragCurrent?i=this.fragCurrent.duration*u.maxBitrate/(1e3*l)+1:i=0}else i=0;const r=this.getBufferedFrag(t.currentTime+i);if(r){const o=this.followingBufferedFrag(r);if(o){this.abortCurrentFrag();const u=o.maxStartPTS?o.maxStartPTS:o.start,l=o.duration,c=Math.max(r.end,u+Math.min(Math.max(l-this.config.maxFragLookUpTolerance,l*(this.couldBacktrack?.5:.125)),l*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case De.KEY_LOADING:case De.FRAG_LOADING:case De.FRAG_LOADING_WAITING_RETRY:case De.PARSING:case De.PARSED:this.state=De.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio===2?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.media;ws(i,"playing",this.onMediaPlaying),ws(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(Os(i,"playing",this.onMediaPlaying),Os(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(e,t),!t.transferMedia&&(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(g.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(e,t){let i=!1,s=!1;for(let n=0;n<t.levels.length;n++){const r=t.levels[n].audioCodec;r&&(i=i||r.indexOf("mp4a.40.2")!==-1,s=s||r.indexOf("mp4a.40.5")!==-1)}this.audioCodecSwitch=i&&s&&!Fd(),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}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==De.IDLE)return;const s=t.levelInfo;(!s.details||s.details.live&&(this.levelLastLoaded!==s||s.details.expired)||this.waitForCdnTuneIn(s.details))&&(this.state=De.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:s,startFragRequested:n}=this,r=t.level,o=t.details,u=o.totalduration;if(!s){this.warn(`Levels were reset while loading level ${r}`);return}this.log(`Level ${r} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${u}`);const l=t.levelInfo,c=this.fragCurrent;c&&(this.state===De.FRAG_LOADING||this.state===De.FRAG_LOADING_WAITING_RETRY)&&c.level!==t.level&&c.loader&&this.abortCurrentFrag();let h=0;if(o.live||(i=l.details)!=null&&i.live){var m;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;h=this.alignPlaylists(o,l.details,(m=this.levelLastLoaded)==null?void 0:m.details)}if(l.details=o,this.levelLastLoaded=l,n||this.setStartPosition(o,h),this.hls.trigger(g.LEVEL_UPDATED,{details:o,level:r}),this.state===De.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=De.IDLE}n&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,n=this.getLoadPosition(),r=e.fragmentStart,o=e.edge,u=n>=r-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&i.duration>s&&(n<s||!u)){const c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!u&&i.readyState<4||n<o-c)&&(this._hasEnoughToStart||(this.nextLoadPosition=s),i.readyState))if(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),this.config.liveSyncMode==="buffered"){var l;const h=Yt.bufferInfo(i,s,0);if(!((l=h.buffered)!=null&&l.length)){i.currentTime=s;return}if(h.start<=n){i.currentTime=s;return}const{nextStart:v}=Yt.bufferedInfo(h.buffered,n,0);v&&(i.currentTime=v)}else i.currentTime=s}}_handleFragmentLoadProgress(e){var t;const i=e.frag,{part:s,payload:n}=e,{levels:r}=this;if(!r){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const o=r[i.level];if(!o){this.warn(`Level ${i.level} not found on progress`);return}const u=o.details;if(!u){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const l=o.videoCodec,c=u.PTSKnown||!u.live,h=(t=i.initSegment)==null?void 0:t.data,m=this._getAudioCodec(o),v=this.transmuxer=this.transmuxer||new Eo(this.hls,G.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),y=s?s.index:-1,b=y!==-1,S=new Ns(i.level,i.sn,i.stats.chunkCount,n.byteLength,y,b),I=this.initPTS[i.cc];v.push(n,h,m,l,i,s,u.totalduration,c,S,I)}onAudioTrackSwitching(e,t){const i=this.hls,s=this.altAudio!==0;if(gi(t.url,i))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;const r=this.fragCurrent;r&&(this.log("Switching to main audio track, cancel main fragment load"),r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(s){this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(g.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(g.AUDIO_TRACK_SWITCHED,t)}),i.trigger(g.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(g.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=gi(t.url,this.hls);if(i){const s=this.videoBuffer;s&&this.mediaBuffer!==s&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=s)}this.altAudio=i?2:0,this.tick()}onBufferCreated(e,t){const i=t.tracks;let s,n,r=!1;for(const o in i){const u=i[o];if(u.id==="main"){if(n=o,s=u,o==="video"){const l=i[o];l&&(this.videoBuffer=l.buffer)}}else r=!0}r&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:s}=t,n=i.type===G.MAIN;if(n){if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===De.PARSED&&(this.state=De.IDLE);return}const o=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),_e(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}const r=this.media;r&&(!this._hasEnoughToStart&&Yt.getBuffered(r).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),n&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(e,t){var i;if(t.fatal){this.state=De.ERROR;return}switch(t.details){case A.FRAG_GAP:case A.FRAG_PARSING_ERROR:case A.FRAG_DECRYPT_ERROR:case A.FRAG_LOAD_ERROR:case A.FRAG_LOAD_TIMEOUT:case A.KEY_LOAD_ERROR:case A.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(G.MAIN,t);break;case A.LEVEL_LOAD_ERROR:case A.LEVEL_LOAD_TIMEOUT:case A.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===De.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===te.LEVEL&&(this.state=De.IDLE);break;case A.BUFFER_ADD_CODEC_ERROR:case A.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case A.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case A.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=De.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ke.AUDIO||!this.altAudio){const i=(t===ke.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,G.MAIN),this.tick())}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,this.level===-1&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const s=this.timelineOffset;s&&i&&(i+=s);const n=this.getLevelDetails(),r=Yt.getBuffered(e),o=r.length?r.start(0):0,u=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||u>0&&(u<l||this.loadingParts&&u<2*((n==null?void 0:n.partTarget)||0)))&&(this.log(`adjusting start position by ${u} to match buffer start`),i+=u,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:s}=this,n=i==null?void 0:i.frag;if(!n||this.fragContextChanged(n))return;t.fragmentError=0,this.state=De.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const r=n.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),s.trigger(g.FRAG_LOADED,i),n.bitrateTest=!1}).catch(i=>{this.state===De.STOPPED||this.state===De.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}_handleTransmuxComplete(e){const t=this.playlistType,{hls:i}=this,{remuxResult:s,chunkMeta:n}=e,r=this.getCurrentContext(n);if(!r){this.resetWhenMissingContext(n);return}const{frag:o,part:u,level:l}=r,{video:c,text:h,id3:m,initSegment:v}=s,{details:y}=l,b=this.altAudio?void 0:s.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}if(this.state=De.PARSING,v){const S=v.tracks;if(S){const B=o.initSegment||o;if(this.unhandledEncryptionError(v,o))return;this._bufferInitSegment(l,S,B,n),i.trigger(g.FRAG_PARSING_INIT_SEGMENT,{frag:B,id:t,tracks:S})}const I=v.initPTS,R=v.timescale,L=this.initPTS[o.cc];if(_(I)&&(!L||L.baseTime!==I||L.timescale!==R)){const B=v.trackId;this.initPTS[o.cc]={baseTime:I,timescale:R,trackId:B},i.trigger(g.INIT_PTS_FOUND,{frag:o,id:t,initPTS:I,timescale:R,trackId:B})}}if(c&&y){b&&c.type==="audiovideo"&&this.logMuxedErr(o);const S=y.fragments[o.sn-1-y.startSN],I=o.sn===y.startSN,R=!S||o.cc>S.cc;if(s.independent!==!1){const{startPTS:L,endPTS:B,startDTS:j,endDTS:be}=c;if(u)u.elementaryStreams[c.type]={startPTS:L,endPTS:B,startDTS:j,endDTS:be};else if(c.firstKeyFrame&&c.independent&&n.id===1&&!R&&(this.couldBacktrack=!0),c.dropped&&c.independent){const Z=this.getMainFwdBufferInfo(),fe=(Z?Z.end:this.getLoadPosition())+this.config.maxBufferHole,he=c.firstKeyFramePTS?c.firstKeyFramePTS:L;if(!I&&fe<he-this.config.maxBufferHole&&!R){this.backtrack(o);return}else R&&(o.gap=!0);o.setElementaryStreamInfo(c.type,o.start,B,o.start,be,!0)}else I&&L-(y.appliedTimelineOffset||0)>Vr&&(o.gap=!0);o.setElementaryStreamInfo(c.type,L,B,j,be),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,u,n,I||R)}else if(I||R)o.gap=!0;else{this.backtrack(o);return}}if(b){const{startPTS:S,endPTS:I,startDTS:R,endDTS:L}=b;u&&(u.elementaryStreams[ke.AUDIO]={startPTS:S,endPTS:I,startDTS:R,endDTS:L}),o.setElementaryStreamInfo(ke.AUDIO,S,I,R,L),this.bufferFragmentData(b,o,u,n)}if(y&&m!=null&&m.samples.length){const S={id:t,frag:o,details:y,samples:m.samples};i.trigger(g.FRAG_PARSING_METADATA,S)}if(y&&h){const S={id:t,frag:o,details:y,samples:h.samples};i.trigger(g.FRAG_PARSING_USERDATA,S)}}logMuxedErr(e){this.warn(`${_e(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}_bufferInitSegment(e,t,i,s){if(this.state!==De.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));const{audio:n,video:r,audiovideo:o}=t;if(n){const l=e.audioCodec;let c=si(n.codec,l);c==="mp4a"&&(c="mp4a.40.5");const h=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){c&&(c.indexOf("mp4a.40.5")!==-1?c="mp4a.40.2":c="mp4a.40.5");const m=n.metadata;m&&"channelCount"in m&&(m.channelCount||1)!==1&&h.indexOf("firefox")===-1&&(c="mp4a.40.5")}c&&c.indexOf("mp4a.40.5")!==-1&&h.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log(`Android: force audio codec to ${c}`)),l&&l!==c&&this.log(`Swapping manifest audio codec "${l}" for "${c}"`),n.levelCodec=c,n.id=G.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${c||""}/${l||""}/${n.codec}]`),delete t.audiovideo}if(r){r.levelCodec=e.videoCodec,r.id=G.MAIN;const l=r.codec;if((l==null?void 0:l.length)===4)switch(l){case"hvc1":case"hev1":r.codec="hvc1.1.6.L120.90";break;case"av01":r.codec="av01.0.04M.08";break;case"avc1":r.codec="avc1.42e01e";break}this.log(`Init video buffer, container:${r.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l}]${r.codec!==l?" parsed-corrected="+r.codec:""}${r.supplemental?" supplemental="+r.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);const u=Object.keys(t);if(u.length){if(this.hls.trigger(g.BUFFER_CODECS,t),!this.hls)return;u.forEach(l=>{const h=t[l].initSegment;h!=null&&h.byteLength&&this.hls.trigger(g.BUFFER_APPENDING,{type:l,data:h,frag:i,part:null,chunkMeta:s,parent:i.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const e=this.mediaBuffer&&this.altAudio===2?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,G.MAIN)}get maxBufferLength(){const{levels:e,level:t}=this,i=e==null?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}backtrack(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=De.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(Yt.isBuffered(e,i)?t=this.getAppendedFrag(i):Yt.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(g.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(g.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){var e;if(this.fragPlaying)return this.fragPlaying;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;return _(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(_(t)){const i=this.getLevelDetails(),s=this.currentFrag||(i?pi(null,i.fragments,t):null);if(s){const n=s.programDateTime;if(n!==null){const r=n+(t-s.start)*1e3;return new Date(r)}}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class $d extends Ce{constructor(e,t){super("key-loader",t),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyIdToKeyInfo){const s=this.keyIdToKeyInfo[i].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyIdToKeyInfo){const t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(e,t=A.KEY_LOAD_ERROR,i,s,n){return new hs({type:Y.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:s})}loadClear(e,t,i){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(let s=0,n=t.length;s<n;s++){const r=t[s];if(e.cc<=r.cc&&(!_e(e)||!_e(r)||e.sn<r.sn)||!i&&s==n-1)return this.emeController.selectKeySystemFormat(r).then(o=>{if(!this.emeController)return;r.setKeyFormat(o);const u=Zs(o);if(u)return this.emeController.getKeySystemAccess([u])})}if(this.config.requireKeySystemAccessOnStart){const s=cn(this.config);if(s.length)return this.emeController.getKeySystemAccess(s)}}return null}load(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,s;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const l=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,A.KEY_LOAD_ERROR,l))}const r=n.uri;if(!r)return Promise.reject(this.createKeyLoadError(e,A.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${r}"`)));const o=Ga(n);let u=this.keyIdToKeyInfo[o];if((i=u)!=null&&i.decryptdata.key)return n.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(this.emeController&&(s=u)!=null&&s.keyLoadPromise)switch(this.emeController.getKeyStatus(u.decryptdata)){case"usable":case"usable-in-future":return u.keyLoadPromise.then(c=>{const{keyInfo:h}=c;return n.key=h.decryptdata.key,{frag:e,keyInfo:h}})}switch(this.log(`${this.keyIdToKeyInfo[o]?"Rel":"L"}oading${n.keyId?" keyId: "+ne(n.keyId):""} URI: ${n.uri} from ${e.type} ${e.level}`),u=this.keyIdToKeyInfo[o]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,A.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var s;if(!e.decryptdata.keyId&&(s=t.initSegment)!=null&&s.data){const r=xe(t.initSegment.data);if(r.length){let o=r[0];o.some(u=>u!==0)?(this.log(`Using keyId found in init segment ${ne(o)}`),Us.setKeyIdForUri(e.decryptdata.uri,o)):(o=Us.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${ne(o)}`)),e.decryptdata.keyId=o}}if(!e.decryptdata.keyId&&!_e(t))return Promise.resolve(i);const n=this.emeController.loadKey(i);return(e.keyLoadPromise=n.then(r=>(e.mediaKeySessionContext=r,i))).catch(r=>{throw e.keyLoadPromise=null,"data"in r&&(r.data.frag=t),r})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,s=i.loader,n=new s(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((r,o)=>{const u={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,c={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(m,v,y,b)=>{const{frag:S,keyInfo:I}=y,R=Ga(I.decryptdata);if(!S.decryptdata||I!==this.keyIdToKeyInfo[R])return o(this.createKeyLoadError(S,A.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),b));I.decryptdata.key=S.decryptdata.key=new Uint8Array(m.data),S.keyLoader=null,I.loader=null,r({frag:S,keyInfo:I})},onError:(m,v,y,b)=>{this.resetLoader(v),o(this.createKeyLoadError(t,A.KEY_LOAD_ERROR,new Error(`HTTP Error ${m.code} loading key ${m.text}`),y,H({url:u.url,data:void 0},m)))},onTimeout:(m,v,y)=>{this.resetLoader(v),o(this.createKeyLoadError(t,A.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),y))},onAbort:(m,v,y)=>{this.resetLoader(v),o(this.createKeyLoadError(t,A.INTERNAL_ABORTED,new Error("key loading aborted"),y))}};n.load(u,c,h)})}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null);const r=Ga(i.decryptdata)||s;delete this.keyIdToKeyInfo[r],n&&n.destroy()}}function Ga(a){if(a.keyFormat!==fi.FAIRPLAY){const e=a.keyId;if(e)return ne(e)}return a.uri}function pl(a){const{type:e}=a;switch(e){case te.AUDIO_TRACK:return G.AUDIO;case te.SUBTITLE_TRACK:return G.SUBTITLE;default:return G.MAIN}}function Ka(a,e){let t=a.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class Ud{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(g.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(g.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(g.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(g.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(g.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(g.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,s=t.loader,n=i||s,r=new n(t);return this.loaders[e.type]=r,r}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:te.MANIFEST,url:i,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(e,t){const{id:i,level:s,pathwayId:n,url:r,deliveryDirectives:o,levelInfo:u}=t;this.load({id:i,level:s,pathwayId:n,responseType:"text",type:te.LEVEL,url:r,deliveryDirectives:o,levelOrTrack:u})}onAudioTrackLoading(e,t){const{id:i,groupId:s,url:n,deliveryDirectives:r,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:te.AUDIO_TRACK,url:n,deliveryDirectives:r,levelOrTrack:o})}onSubtitleTrackLoading(e,t){const{id:i,groupId:s,url:n,deliveryDirectives:r,track:o}=t;this.load({id:i,groupId:s,level:null,responseType:"text",type:te.SUBTITLE_TRACK,url:n,deliveryDirectives:r,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[te.LEVEL];if(i){const s=i.context;s&&!t.levels.some(n=>n===s.levelOrTrack)&&(i.abort(),delete this.loaders[te.LEVEL])}}load(e){var t;const i=this.hls.config;let s=this.getInternalLoader(e);if(s){const l=this.hls.logger,c=s.context;if(c&&c.levelOrTrack===e.levelOrTrack&&(c.url===e.url||c.deliveryDirectives&&!e.deliveryDirectives)){c.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${c.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===te.MANIFEST?n=i.manifestLoadPolicy.default:n=Ie({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),_((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===te.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===te.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===te.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){const c=l.partTarget,h=l.targetduration;if(c&&h){const m=Math.max(c*3,h*.8)*1e3;n=Ie({},n,{maxTimeToFirstByteMs:Math.min(m,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(m,n.maxTimeToFirstByteMs)})}}}const r=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:r.maxNumRetry||0,retryDelay:r.retryDelayMs||0,maxRetryDelay:r.maxRetryDelayMs||0},u={onSuccess:(l,c,h,m)=>{const v=this.getInternalLoader(h);this.resetInternalLoader(h.type);const y=l.data;c.parsing.start=performance.now(),Gs.isMediaPlaylist(y)||h.type!==te.MANIFEST?this.handleTrackOrLevelPlaylist(l,c,h,m||null,v):this.handleMasterPlaylist(l,c,h,m)},onError:(l,c,h,m)=>{this.handleNetworkError(c,h,!1,l,m)},onTimeout:(l,c,h)=>{this.handleNetworkError(c,h,!0,void 0,l)}};s.load(e,o,u)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:e,startPosition:t},forceStartLoad:i}=this.hls;(e||i)&&(this.hls.logger.log(`${e?"auto":"force"} startLoad with configured startPosition ${t}`),this.hls.startLoad(t))}handleMasterPlaylist(e,t,i,s){const n=this.hls,r=e.data,o=Ka(e,i),u=Gs.parseMasterPlaylist(r,o);if(u.playlistParsingError){t.parsing.end=performance.now(),this.handleManifestParsingError(e,i,u.playlistParsingError,s,t);return}const{contentSteering:l,levels:c,sessionData:h,sessionKeys:m,startTimeOffset:v,variableList:y}=u;this.variableList=y,c.forEach(R=>{const{unknownCodecs:L}=R;if(L){const{preferManagedMediaSource:B}=this.hls.config;let{audioCodec:j,videoCodec:be}=R;for(let Z=L.length;Z--;){const fe=L[Z];ui(fe,"audio",B)?(R.audioCodec=j=j?`${j},${fe}`:fe,Ut.audio[j.substring(0,4)]=2,L.splice(Z,1)):ui(fe,"video",B)&&(R.videoCodec=be=be?`${be},${fe}`:fe,Ut.video[be.substring(0,4)]=2,L.splice(Z,1))}}});const{AUDIO:b=[],SUBTITLES:S,"CLOSED-CAPTIONS":I}=Gs.parseMasterPlaylistMedia(r,o,u);b.length&&!b.some(L=>!L.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),b.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Fi({}),bitrate:0,url:""})),n.trigger(g.MANIFEST_LOADED,{levels:c,audioTracks:b,subtitles:S,captions:I,contentSteering:l,url:o,stats:t,networkDetails:s,sessionData:h,sessionKeys:m,startTimeOffset:v,variableList:y})}handleTrackOrLevelPlaylist(e,t,i,s,n){const r=this.hls,{id:o,level:u,type:l}=i,c=Ka(e,i),h=_(u)?u:_(o)?o:0,m=pl(i),v=Gs.parseLevelPlaylist(e.data,c,h,m,0,this.variableList);if(l===te.MANIFEST){const y={attrs:new Fi({}),bitrate:0,details:v,name:"",url:c};v.requestScheduled=t.loading.start+Xi(v,0),r.trigger(g.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:c,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=v,this.handlePlaylistLoaded(v,e,t,i,s,n)}handleManifestParsingError(e,t,i,s,n){this.hls.trigger(g.ERROR,{type:Y.NETWORK_ERROR,details:A.MANIFEST_PARSING_ERROR,fatal:t.type===te.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,i=!1,s,n){let r=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===te.LEVEL?r+=`: ${e.level} id: ${e.id}`:(e.type===te.AUDIO_TRACK||e.type===te.SUBTITLE_TRACK)&&(r+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(r);this.hls.logger.warn(`[playlist-loader]: ${r}`);let u=A.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case te.MANIFEST:u=i?A.MANIFEST_LOAD_TIMEOUT:A.MANIFEST_LOAD_ERROR,l=!0;break;case te.LEVEL:u=i?A.LEVEL_LOAD_TIMEOUT:A.LEVEL_LOAD_ERROR,l=!1;break;case te.AUDIO_TRACK:u=i?A.AUDIO_TRACK_LOAD_TIMEOUT:A.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case te.SUBTITLE_TRACK:u=i?A.SUBTITLE_TRACK_LOAD_TIMEOUT:A.SUBTITLE_LOAD_ERROR,l=!1;break}c&&this.resetInternalLoader(e.type);const h={type:Y.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(s){const m=(t==null?void 0:t.url)||e.url;h.response=H({url:m,data:void 0},s)}this.hls.trigger(g.ERROR,h)}handlePlaylistLoaded(e,t,i,s,n,r){const o=this.hls,{type:u,level:l,levelOrTrack:c,id:h,groupId:m,deliveryDirectives:v}=s,y=Ka(t,s),b=pl(s);let S=typeof s.level=="number"&&b===G.MAIN?l:void 0;const I=e.playlistParsingError;if(I){if(this.hls.logger.warn(`${I} ${e.url}`),!o.config.ignorePlaylistParsingErrors){o.trigger(g.ERROR,{type:Y.NETWORK_ERROR,details:A.LEVEL_PARSING_ERROR,fatal:!1,url:y,error:I,reason:I.message,response:t,context:s,level:S,parent:b,networkDetails:n,stats:i});return}e.playlistParsingError=null}if(!e.fragments.length){const R=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(g.ERROR,{type:Y.NETWORK_ERROR,details:A.LEVEL_EMPTY_ERROR,fatal:!1,url:y,error:R,reason:R.message,response:t,context:s,level:S,parent:b,networkDetails:n,stats:i});return}switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),u){case te.MANIFEST:case te.LEVEL:if(S){if(!c)S=0;else if(c!==o.levels[S]){const R=o.levels.indexOf(c);R>-1&&(S=R)}}o.trigger(g.LEVEL_LOADED,{details:e,levelInfo:c||o.levels[0],level:S||0,id:h||0,stats:i,networkDetails:n,deliveryDirectives:v,withoutMultiVariant:u===te.MANIFEST});break;case te.AUDIO_TRACK:o.trigger(g.AUDIO_TRACK_LOADED,{details:e,track:c,id:h||0,groupId:m||"",stats:i,networkDetails:n,deliveryDirectives:v});break;case te.SUBTITLE_TRACK:o.trigger(g.SUBTITLE_TRACK_LOADED,{details:e,track:c,id:h||0,groupId:m||"",stats:i,networkDetails:n,deliveryDirectives:v});break}}}class Rn{static get version(){return sr}static isMSESupported(){return gl()}static isSupported(){return Md()}static getMediaSource(){return vt()}static get Events(){return g}static get MetadataSchema(){return Ks}static get ErrorTypes(){return Y}static get ErrorDetails(){return A}static get DefaultConfig(){return Rn.defaultConfig?Rn.defaultConfig:Td}static set DefaultConfig(e){Rn.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new na,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=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;const t=this.logger=Xe(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=Ad(Rn.DefaultConfig,e,t);this.userConfig=e,i.progressive&&Id(i,t);const{abrController:s,bufferController:n,capLevelController:r,errorController:o,fpsController:u}=i,l=new o(this),c=this.abrController=new s(this),h=new ks(this),m=i.interstitialsController,v=m?this.interstitialsController=new m(this,Rn):null,y=this.bufferController=new n(this,h),b=this.capLevelController=new r(this),S=new u(this),I=new Ud(this),R=i.contentSteeringController,L=R?new R(this):null,B=this.levelController=new Od(this,L),j=new kd(this),be=new $d(this.config,this.logger),Z=this.streamController=new Nd(this,h,be),fe=this.gapController=new Dd(this,h);b.setStreamController(Z),S.setStreamController(Z);const he=[I,B,Z];v&&he.splice(1,0,v),L&&he.splice(1,0,L),this.networkControllers=he;const q=[c,y,fe,b,S,j,h];this.audioTrackController=this.createController(i.audioTrackController,he);const Oe=i.audioStreamController;Oe&&he.push(this.audioStreamController=new Oe(this,h,be)),this.subtitleTrackController=this.createController(i.subtitleTrackController,he);const gt=i.subtitleStreamController;gt&&he.push(this.subtititleStreamController=new gt(this,h,be)),this.createController(i.timelineController,q),be.emeController=this.emeController=this.createController(i.emeController,q),this.cmcdController=this.createController(i.cmcdController,q),this.latencyController=this.createController(Pd,q),this.coreComponents=q,he.push(l);const wt=l.onErrorOut;typeof wt=="function"&&this.on(g.ERROR,wt,l),this.on(g.MANIFEST_LOADED,I.onManifestLoaded,I)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,s){this._emitter.off(e,t,i,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;const s=e===g.ERROR;this.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.INTERNAL_EXCEPTION,fatal:s,event:e,error:i}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){this.logger.log("destroy"),this.trigger(g.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){if(!e||"media"in e&&!e.media){const n=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(g.ERROR,{type:Y.OTHER_ERROR,details:A.ATTACH_MEDIA_ERROR,fatal:!0,error:n});return}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const t="media"in e,i=t?e.media:e,s=t?e:{media:i};this._media=i,this.trigger(g.MEDIA_ATTACHING,s)}detachMedia(){this.logger.log("detachMedia"),this.trigger(g.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(g.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,s=this._url=ve.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${s}`),t&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(g.MANIFEST_LOADING,{url:e})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),!(!this.started||!this.networkControllers));i++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!(this.started||!this.networkControllers));e++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}get inFlightFragments(){const e={[G.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[G.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[G.SUBTITLE]=this.subtititleStreamController.inFlightFrag),e}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const e=this._media,t=e==null?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}removeLevel(e){this.levelController.removeLevel(e)}get sessionId(){let e=this._sessionId;return e||(e=this._sessionId=Dc()),e}get levels(){const e=this.levelController.levels;return e||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){this.logger.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get abrEwmaDefaultEstimate(){const{bwEstimator:e}=this.abrController;return e?e.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){He(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let s=0;s<i;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,i)for(let n=s;n--;){const r=e[n].attrs["HDCP-LEVEL"];if(r&&r<=i)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(e){var t;return((t=this.audioTrackController)==null?void 0:t.setAudioOption(e))||null}setSubtitleOption(e){var t;return((t=this.subtitleTrackController)==null?void 0:t.setSubtitleOption(e))||null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(e){this.latencyController.targetLatency=e}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(e){this.levelController.pathwayPriority=e}get bufferedToEnd(){var e;return!!((e=this.bufferController)!=null&&e.bufferedToEnd)}get interstitialsManager(){var e;return((e=this.interstitialsController)==null?void 0:e.interstitialsManager)||null}getMediaDecodingInfo(e,t=this.allAudioTracks){const i=ue(t);return $e(e,i,navigator.mediaCapabilities)}}Rn.defaultConfig=void 0}}]);
}());