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.
83 lines
828 KiB
83 lines
828 KiB
!(function(){var Wo=Math.pow;(self.webpackChunk=self.webpackChunk||[]).push([[4928],{18785:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return H}});var S=R(72308),B=R(59301),fe={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"},z=fe,A=R(7657),m=function(Ae,Pe){return B.createElement(A.Z,(0,S.Z)({},Ae,{ref:Pe,icon:z}))},oe=B.forwardRef(m),H=oe},33853:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return H}});var S=R(72308),B=R(59301),fe={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"},z=fe,A=R(7657),m=function(Ae,Pe){return B.createElement(A.Z,(0,S.Z)({},Ae,{ref:Pe,icon:z}))},oe=B.forwardRef(m),H=oe},38819:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return H}});var S=R(72308),B=R(59301),fe={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"}}]},name:"right",theme:"outlined"},z=fe,A=R(7657),m=function(Ae,Pe){return B.createElement(A.Z,(0,S.Z)({},Ae,{ref:Pe,icon:z}))},oe=B.forwardRef(m),H=oe},35593:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return Ht}});var S=R(77321),B=R(52487),fe=R(74416),z=R(43403),A=R(92310),m=R.n(A),oe=R(29301),H=R(76846),me=R(96452),Ae=R(6089),Pe=R(80402),ce=R(34280),I=R(49658),j=R(59301),ct=R(72308),Re=R(77900),De=R(8654);function K(k){var C=k.prefixCls,x=k.align,D=k.arrow,$=k.arrowPos,ae=D||{},w=ae.className,V=ae.content,W=$.x,O=W===void 0?0:W,le=$.y,Le=le===void 0?0:le,We=j.useRef();if(!x||!x.points)return null;var Je={position:"absolute"};if(x.autoArrow!==!1){var ft=x.points[0],nt=x.points[1],st=ft[0],tt=ft[1],It=nt[0],Ot=nt[1];st===It||!["t","b"].includes(st)?Je.top=Le:st==="t"?Je.top=0:Je.bottom=0,tt===Ot||!["l","r"].includes(tt)?Je.left=O:tt==="l"?Je.left=0:Je.right=0}return j.createElement("div",{ref:We,className:m()("".concat(C,"-arrow"),w),style:Je},V)}function P(k){var C=k.prefixCls,x=k.open,D=k.zIndex,$=k.mask,ae=k.motion;return $?j.createElement(Re.default,(0,ct.Z)({},ae,{motionAppear:!0,visible:x,removeOnLeave:!0}),function(w){var V=w.className;return j.createElement("div",{style:{zIndex:D},className:m()("".concat(C,"-mask"),V)})}):null}var F=j.memo(function(k){var C=k.children;return C},function(k,C){return C.cache}),Y=F,X=j.forwardRef(function(k,C){var x=k.popup,D=k.className,$=k.prefixCls,ae=k.style,w=k.target,V=k.onVisibleChanged,W=k.open,O=k.keepDom,le=k.fresh,Le=k.onClick,We=k.mask,Je=k.arrow,ft=k.arrowPos,nt=k.align,st=k.motion,tt=k.maskMotion,It=k.forceRender,Ot=k.getPopupContainer,ge=k.autoDestroy,ei=k.portal,ti=k.zIndex,hi=k.onMouseEnter,Xt=k.onMouseLeave,Ti=k.onPointerEnter,gi=k.ready,Si=k.offsetX,ii=k.offsetY,Mi=k.offsetR,Qt=k.offsetB,ut=k.onAlign,_t=k.onPrepare,si=k.stretch,At=k.targetWidth,bi=k.targetHeight,li=typeof x=="function"?x():x,_i=W||O,pi=(Ot==null?void 0:Ot.length)>0,ri=j.useState(!Ot||!pi),ci=(0,B.Z)(ri,2),as=ci[0],Ge=ci[1];if((0,ce.Z)(function(){!as&&pi&&w&&Ge(!0)},[as,pi,w]),!as)return null;var c="auto",f={left:"-1000vw",top:"-1000vh",right:c,bottom:c};if(gi||!W){var p,E=nt.points,T=nt.dynamicInset||((p=nt._experimental)===null||p===void 0?void 0:p.dynamicInset),G=T&&E[0][1]==="r",J=T&&E[0][0]==="b";G?(f.right=Mi,f.left=c):(f.left=Si,f.right=c),J?(f.bottom=Qt,f.top=c):(f.top=ii,f.bottom=c)}var Ye={};return si&&(si.includes("height")&&bi?Ye.height=bi:si.includes("minHeight")&&bi&&(Ye.minHeight=bi),si.includes("width")&&At?Ye.width=At:si.includes("minWidth")&&At&&(Ye.minWidth=At)),W||(Ye.pointerEvents="none"),j.createElement(ei,{open:It||_i,getContainer:Ot&&function(){return Ot(w)},autoDestroy:ge},j.createElement(P,{prefixCls:$,open:W,zIndex:ti,mask:We,motion:tt}),j.createElement(oe.Z,{onResize:ut,disabled:!W},function(Ve){return j.createElement(Re.default,(0,ct.Z)({motionAppear:!0,motionEnter:!0,motionLeave:!0,removeOnLeave:!1,forceRender:It,leavedClassName:"".concat($,"-hidden")},st,{onAppearPrepare:_t,onEnterPrepare:_t,visible:W,onVisibleChanged:function(Rt){var Pt;st==null||(Pt=st.onVisibleChanged)===null||Pt===void 0||Pt.call(st,Rt),V(Rt)}}),function(ht,Rt){var Pt=ht.className,Ne=ht.style,Ct=m()($,Pt,D);return j.createElement("div",{ref:(0,De.sQ)(Ve,C,Rt),className:Ct,style:(0,S.Z)((0,S.Z)((0,S.Z)((0,S.Z)({"--arrow-x":"".concat(ft.x||0,"px"),"--arrow-y":"".concat(ft.y||0,"px")},f),Ye),Ne),{},{boxSizing:"border-box",zIndex:ti},ae),onMouseEnter:hi,onMouseLeave:Xt,onPointerEnter:Ti,onClick:Le},Je&&j.createElement(K,{prefixCls:$,arrow:Je,arrowPos:ft,align:nt}),j.createElement(Y,{cache:!W&&!le},li))})}))}),de=X,ve=j.forwardRef(function(k,C){var x=k.children,D=k.getTriggerDOMNode,$=(0,De.Yr)(x),ae=j.useCallback(function(V){(0,De.mH)(C,D?D(V):V)},[D]),w=(0,De.x1)(ae,x.ref);return $?j.cloneElement(x,{ref:w}):x}),Z=ve,Oe=j.createContext(null),He=Oe;function Qe(k){return k?Array.isArray(k)?k:[k]:[]}function xe(k,C,x,D){return j.useMemo(function(){var $=Qe(x!=null?x:C),ae=Qe(D!=null?D:C),w=new Set($),V=new Set(ae);return k&&(w.has("hover")&&(w.delete("hover"),w.add("click")),V.has("hover")&&(V.delete("hover"),V.add("click"))),[w,V]},[k,C,x,D])}var ee=R(29194);function Q(){var k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],x=arguments.length>2?arguments[2]:void 0;return x?k[0]===C[0]:k[0]===C[0]&&k[1]===C[1]}function ie(k,C,x,D){for(var $=x.points,ae=Object.keys(k),w=0;w<ae.length;w+=1){var V,W=ae[w];if(Q((V=k[W])===null||V===void 0?void 0:V.points,$,D))return"".concat(C,"-placement-").concat(W)}return""}function N(k,C,x,D){return C||(x?{motionName:"".concat(k,"-").concat(x)}:D?{motionName:D}:null)}function we(k){return k.ownerDocument.defaultView}function je(k){for(var C=[],x=k==null?void 0:k.parentElement,D=["hidden","scroll","clip","auto"];x;){var $=we(x).getComputedStyle(x),ae=$.overflowX,w=$.overflowY,V=$.overflow;[ae,w,V].some(function(W){return D.includes(W)})&&C.push(x),x=x.parentElement}return C}function Ee(k){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;return Number.isNaN(k)?C:k}function _e(k){return Ee(parseFloat(k),0)}function Me(k,C){var x=(0,S.Z)({},k);return(C||[]).forEach(function(D){if(!(D instanceof HTMLBodyElement||D instanceof HTMLHtmlElement)){var $=we(D).getComputedStyle(D),ae=$.overflow,w=$.overflowClipMargin,V=$.borderTopWidth,W=$.borderBottomWidth,O=$.borderLeftWidth,le=$.borderRightWidth,Le=D.getBoundingClientRect(),We=D.offsetHeight,Je=D.clientHeight,ft=D.offsetWidth,nt=D.clientWidth,st=_e(V),tt=_e(W),It=_e(O),Ot=_e(le),ge=Ee(Math.round(Le.width/ft*1e3)/1e3),ei=Ee(Math.round(Le.height/We*1e3)/1e3),ti=(ft-nt-It-Ot)*ge,hi=(We-Je-st-tt)*ei,Xt=st*ei,Ti=tt*ei,gi=It*ge,Si=Ot*ge,ii=0,Mi=0;if(ae==="clip"){var Qt=_e(w);ii=Qt*ge,Mi=Qt*ei}var ut=Le.x+gi-ii,_t=Le.y+Xt-Mi,si=ut+Le.width+2*ii-gi-Si-ti,At=_t+Le.height+2*Mi-Xt-Ti-hi;x.left=Math.max(x.left,ut),x.top=Math.max(x.top,_t),x.right=Math.min(x.right,si),x.bottom=Math.min(x.bottom,At)}}),x}function Be(k){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,x="".concat(C),D=x.match(/^(.*)\%$/);return D?k*(parseFloat(D[1])/100):parseFloat(x)}function Fe(k,C){var x=C||[],D=(0,B.Z)(x,2),$=D[0],ae=D[1];return[Be(k.width,$),Be(k.height,ae)]}function Ze(){var k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return[k[0],k[1]]}function ot(k,C){var x=C[0],D=C[1],$,ae;return x==="t"?ae=k.y:x==="b"?ae=k.y+k.height:ae=k.y+k.height/2,D==="l"?$=k.x:D==="r"?$=k.x+k.width:$=k.x+k.width/2,{x:$,y:ae}}function mt(k,C){var x={t:"b",b:"t",l:"r",r:"l"};return k.map(function(D,$){return $===C?x[D]||"c":D}).join("")}function Et(k,C,x,D,$,ae,w){var V=j.useState({ready:!1,offsetX:0,offsetY:0,offsetR:0,offsetB:0,arrowX:0,arrowY:0,scaleX:1,scaleY:1,align:$[D]||{}}),W=(0,B.Z)(V,2),O=W[0],le=W[1],Le=j.useRef(0),We=j.useMemo(function(){return C?je(C):[]},[C]),Je=j.useRef({}),ft=function(){Je.current={}};k||ft();var nt=(0,Ae.Z)(function(){if(C&&x&&k){let ts=function(ji,vs){var ys=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ct,us=li.x+ji,Qi=li.y+vs,yi=us+p,rs=Qi+f,zs=Math.max(us,ys.left),en=Math.max(Qi,ys.top),tn=Math.min(yi,ys.right),Fs=Math.min(rs,ys.bottom);return Math.max(0,(tn-zs)*(Fs-en))},xs=function(){Zi=li.y+Tt,Bi=Zi+f,ni=li.x+Bt,is=ni+p};var It,Ot,ge=C,ei=ge.ownerDocument,ti=we(ge),hi=ti.getComputedStyle(ge),Xt=hi.width,Ti=hi.height,gi=hi.position,Si=ge.style.left,ii=ge.style.top,Mi=ge.style.right,Qt=ge.style.bottom,ut=ge.style.overflow,_t=(0,S.Z)((0,S.Z)({},$[D]),ae),si=ei.createElement("div");(It=ge.parentElement)===null||It===void 0||It.appendChild(si),si.style.left="".concat(ge.offsetLeft,"px"),si.style.top="".concat(ge.offsetTop,"px"),si.style.position=gi,si.style.height="".concat(ge.offsetHeight,"px"),si.style.width="".concat(ge.offsetWidth,"px"),ge.style.left="0",ge.style.top="0",ge.style.right="auto",ge.style.bottom="auto",ge.style.overflow="hidden";var At;if(Array.isArray(x))At={x:x[0],y:x[1],width:0,height:0};else{var bi=x.getBoundingClientRect();At={x:bi.x,y:bi.y,width:bi.width,height:bi.height}}var li=ge.getBoundingClientRect(),_i=ei.documentElement,pi=_i.clientWidth,ri=_i.clientHeight,ci=_i.scrollWidth,as=_i.scrollHeight,Ge=_i.scrollTop,c=_i.scrollLeft,f=li.height,p=li.width,E=At.height,T=At.width,G={left:0,top:0,right:pi,bottom:ri},J={left:-c,top:-Ge,right:ci-c,bottom:as-Ge},Ye=_t.htmlRegion,Ve="visible",ht="visibleFirst";Ye!=="scroll"&&Ye!==ht&&(Ye=Ve);var Rt=Ye===ht,Pt=Me(J,We),Ne=Me(G,We),Ct=Ye===Ve?Ne:Pt,at=Rt?Ne:Ct;ge.style.left="auto",ge.style.top="auto",ge.style.right="0",ge.style.bottom="0";var Ke=ge.getBoundingClientRect();ge.style.left=Si,ge.style.top=ii,ge.style.right=Mi,ge.style.bottom=Qt,ge.style.overflow=ut,(Ot=ge.parentElement)===null||Ot===void 0||Ot.removeChild(si);var et=Ee(Math.round(p/parseFloat(Xt)*1e3)/1e3),vt=Ee(Math.round(f/parseFloat(Ti)*1e3)/1e3);if(et===0||vt===0||(0,H.Sh)(x)&&!(0,ee.Z)(x))return;var Lt=_t.offset,Ut=_t.targetOffset,qt=Fe(li,Lt),ki=(0,B.Z)(qt,2),rt=ki[0],lt=ki[1],q=Fe(At,Ut),se=(0,B.Z)(q,2),pe=se[0],Ce=se[1];At.x-=pe,At.y-=Ce;var Se=_t.points||[],Ue=(0,B.Z)(Se,2),ke=Ue[0],xt=Ue[1],Mt=Ze(xt),pt=Ze(ke),jt=ot(At,Mt),kt=ot(li,pt),ai=(0,S.Z)({},_t),Bt=jt.x-kt.x+rt,Tt=jt.y-kt.y+lt,Ai=ts(Bt,Tt),Ri=ts(Bt,Tt,Ne),Oi=ot(At,["t","l"]),xi=ot(li,["t","l"]),ui=ot(At,["b","r"]),di=ot(li,["b","r"]),oi=_t.overflow||{},Ii=oi.adjustX,Vi=oi.adjustY,Ci=oi.shiftX,Li=oi.shiftY,fi=function(vs){return typeof vs=="boolean"?vs:vs>=0},Zi,Bi,ni,is;xs();var qi=fi(Vi),Ji=pt[0]===Mt[0];if(qi&&pt[0]==="t"&&(Bi>at.bottom||Je.current.bt)){var Fi=Tt;Ji?Fi-=f-E:Fi=Oi.y-di.y-lt;var ss=ts(Bt,Fi),fs=ts(Bt,Fi,Ne);ss>Ai||ss===Ai&&(!Rt||fs>=Ri)?(Je.current.bt=!0,Tt=Fi,lt=-lt,ai.points=[mt(pt,0),mt(Mt,0)]):Je.current.bt=!1}if(qi&&pt[0]==="b"&&(Zi<at.top||Je.current.tb)){var Ni=Tt;Ji?Ni+=f-E:Ni=ui.y-xi.y-lt;var Rs=ts(Bt,Ni),ks=ts(Bt,Ni,Ne);Rs>Ai||Rs===Ai&&(!Rt||ks>=Ri)?(Je.current.tb=!0,Tt=Ni,lt=-lt,ai.points=[mt(pt,0),mt(Mt,0)]):Je.current.tb=!1}var _s=fi(Ii),gs=pt[1]===Mt[1];if(_s&&pt[1]==="l"&&(is>at.right||Je.current.rl)){var cs=Bt;gs?cs-=p-T:cs=Oi.x-di.x-rt;var ns=ts(cs,Tt),ls=ts(cs,Tt,Ne);ns>Ai||ns===Ai&&(!Rt||ls>=Ri)?(Je.current.rl=!0,Bt=cs,rt=-rt,ai.points=[mt(pt,1),mt(Mt,1)]):Je.current.rl=!1}if(_s&&pt[1]==="r"&&(ni<at.left||Je.current.lr)){var ms=Bt;gs?ms+=p-T:ms=ui.x-xi.x-rt;var Ls=ts(ms,Tt),Yi=ts(ms,Tt,Ne);Ls>Ai||Ls===Ai&&(!Rt||Yi>=Ri)?(Je.current.lr=!0,Bt=ms,rt=-rt,ai.points=[mt(pt,1),mt(Mt,1)]):Je.current.lr=!1}xs();var Gi=Ci===!0?0:Ci;typeof Gi=="number"&&(ni<Ne.left&&(Bt-=ni-Ne.left-rt,At.x+T<Ne.left+Gi&&(Bt+=At.x-Ne.left+T-Gi)),is>Ne.right&&(Bt-=is-Ne.right-rt,At.x>Ne.right-Gi&&(Bt+=At.x-Ne.right+Gi)));var es=Li===!0?0:Li;typeof es=="number"&&(Zi<Ne.top&&(Tt-=Zi-Ne.top-lt,At.y+E<Ne.top+es&&(Tt+=At.y-Ne.top+E-es)),Bi>Ne.bottom&&(Tt-=Bi-Ne.bottom-lt,At.y>Ne.bottom-es&&(Tt+=At.y-Ne.bottom+es)));var os=li.x+Bt,Is=os+p,Ft=li.y+Tt,Ss=Ft+f,Cs=At.x,bs=Cs+T,Vs=At.y,Ks=Vs+E,Qs=Math.max(os,Cs),Ps=Math.min(Is,bs),vi=(Qs+Ps)/2,an=vi-os,Hs=Math.max(Ft,Vs),js=Math.min(Ss,Ks),Js=(Hs+js)/2,Ms=Js-Ft;w==null||w(C,ai);var Bs=Ke.right-li.x-(Bt+li.width),ps=Ke.bottom-li.y-(Tt+li.height);le({ready:!0,offsetX:Bt/et,offsetY:Tt/vt,offsetR:Bs/et,offsetB:ps/vt,arrowX:an/et,arrowY:Ms/vt,scaleX:et,scaleY:vt,align:ai})}}),st=function(){Le.current+=1;var Ot=Le.current;Promise.resolve().then(function(){Le.current===Ot&&nt()})},tt=function(){le(function(Ot){return(0,S.Z)((0,S.Z)({},Ot),{},{ready:!1})})};return(0,ce.Z)(tt,[D]),(0,ce.Z)(function(){k||tt()},[k]),[O.ready,O.offsetX,O.offsetY,O.offsetR,O.offsetB,O.arrowX,O.arrowY,O.scaleX,O.scaleY,O.align,st]}var wt=R(80702);function Gt(k,C,x,D,$){(0,ce.Z)(function(){if(k&&C&&x){let Le=function(){D(),$()};var ae=C,w=x,V=je(ae),W=je(w),O=we(w),le=new Set([O].concat((0,wt.Z)(V),(0,wt.Z)(W)));return le.forEach(function(We){We.addEventListener("scroll",Le,{passive:!0})}),O.addEventListener("resize",Le,{passive:!0}),D(),function(){le.forEach(function(We){We.removeEventListener("scroll",Le),O.removeEventListener("resize",Le)})}}},[k,C,x])}var gt=R(48736),bt=R(16089);function $e(k,C,x,D,$,ae,w,V){var W=j.useRef(k),O=j.useRef(!1);W.current!==k&&(O.current=!0,W.current=k),j.useEffect(function(){var le=(0,bt.Z)(function(){O.current=!1});return function(){bt.Z.cancel(le)}},[k]),j.useEffect(function(){if(C&&D&&(!$||ae)){var le=function(){var gi=!1,Si=function(Qt){var ut=Qt.target;gi=w(ut)},ii=function(Qt){var ut=Qt.target;!O.current&&W.current&&!gi&&!w(ut)&&V(!1)};return[Si,ii]},Le=le(),We=(0,B.Z)(Le,2),Je=We[0],ft=We[1],nt=le(),st=(0,B.Z)(nt,2),tt=st[0],It=st[1],Ot=we(D);Ot.addEventListener("mousedown",Je,!0),Ot.addEventListener("click",ft,!0),Ot.addEventListener("contextmenu",ft,!0);var ge=(0,me.A)(x);if(ge&&(ge.addEventListener("mousedown",tt,!0),ge.addEventListener("click",It,!0),ge.addEventListener("contextmenu",It,!0)),0)var ei,ti,hi,Xt;return function(){Ot.removeEventListener("mousedown",Je,!0),Ot.removeEventListener("click",ft,!0),Ot.removeEventListener("contextmenu",ft,!0),ge&&(ge.removeEventListener("mousedown",tt,!0),ge.removeEventListener("click",It,!0),ge.removeEventListener("contextmenu",It,!0))}}},[C,x,D,$,ae])}var Vt=["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 Zt(){var k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z.Z,C=j.forwardRef(function(x,D){var $=x.prefixCls,ae=$===void 0?"rc-trigger-popup":$,w=x.children,V=x.action,W=V===void 0?"hover":V,O=x.showAction,le=x.hideAction,Le=x.popupVisible,We=x.defaultPopupVisible,Je=x.onPopupVisibleChange,ft=x.afterPopupVisibleChange,nt=x.mouseEnterDelay,st=x.mouseLeaveDelay,tt=st===void 0?.1:st,It=x.focusDelay,Ot=x.blurDelay,ge=x.mask,ei=x.maskClosable,ti=ei===void 0?!0:ei,hi=x.getPopupContainer,Xt=x.forceRender,Ti=x.autoDestroy,gi=x.destroyPopupOnHide,Si=x.popup,ii=x.popupClassName,Mi=x.popupStyle,Qt=x.popupPlacement,ut=x.builtinPlacements,_t=ut===void 0?{}:ut,si=x.popupAlign,At=x.zIndex,bi=x.stretch,li=x.getPopupClassNameFromAlign,_i=x.fresh,pi=x.alignPoint,ri=x.onPopupClick,ci=x.onPopupAlign,as=x.arrow,Ge=x.popupMotion,c=x.maskMotion,f=x.popupTransitionName,p=x.popupAnimation,E=x.maskTransitionName,T=x.maskAnimation,G=x.className,J=x.getTriggerDOMNode,Ye=(0,fe.Z)(x,Vt),Ve=Ti||gi||!1,ht=j.useState(!1),Rt=(0,B.Z)(ht,2),Pt=Rt[0],Ne=Rt[1];(0,ce.Z)(function(){Ne((0,I.Z)())},[]);var Ct=j.useRef({}),at=j.useContext(He),Ke=j.useMemo(function(){return{registerSubPopup:function(Kt,zi){Ct.current[Kt]=zi,at==null||at.registerSubPopup(Kt,zi)}}},[at]),et=(0,Pe.Z)(),vt=j.useState(null),Lt=(0,B.Z)(vt,2),Ut=Lt[0],qt=Lt[1],ki=(0,Ae.Z)(function(yt){(0,H.Sh)(yt)&&Ut!==yt&&qt(yt),at==null||at.registerSubPopup(et,yt)}),rt=j.useState(null),lt=(0,B.Z)(rt,2),q=lt[0],se=lt[1],pe=j.useRef(null),Ce=(0,Ae.Z)(function(yt){(0,H.Sh)(yt)&&q!==yt&&(se(yt),pe.current=yt)}),Se=j.Children.only(w),Ue=(Se==null?void 0:Se.props)||{},ke={},xt=(0,Ae.Z)(function(yt){var Kt,zi,Xi=q;return(Xi==null?void 0:Xi.contains(yt))||((Kt=(0,me.A)(Xi))===null||Kt===void 0?void 0:Kt.host)===yt||yt===Xi||(Ut==null?void 0:Ut.contains(yt))||((zi=(0,me.A)(Ut))===null||zi===void 0?void 0:zi.host)===yt||yt===Ut||Object.values(Ct.current).some(function(Di){return(Di==null?void 0:Di.contains(yt))||yt===Di})}),Mt=N(ae,Ge,p,f),pt=N(ae,c,T,E),jt=j.useState(We||!1),kt=(0,B.Z)(jt,2),ai=kt[0],Bt=kt[1],Tt=Le!=null?Le:ai,Ai=(0,Ae.Z)(function(yt){Le===void 0&&Bt(yt)});(0,ce.Z)(function(){Bt(Le||!1)},[Le]);var Ri=j.useRef(Tt);Ri.current=Tt;var Oi=j.useRef([]);Oi.current=[];var xi=(0,Ae.Z)(function(yt){var Kt;Ai(yt),((Kt=Oi.current[Oi.current.length-1])!==null&&Kt!==void 0?Kt:Tt)!==yt&&(Oi.current.push(yt),Je==null||Je(yt))}),ui=j.useRef(),di=function(){clearTimeout(ui.current)},oi=function(Kt){var zi=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;di(),zi===0?xi(Kt):ui.current=setTimeout(function(){xi(Kt)},zi*1e3)};j.useEffect(function(){return di},[]);var Ii=j.useState(!1),Vi=(0,B.Z)(Ii,2),Ci=Vi[0],Li=Vi[1];(0,ce.Z)(function(yt){(!yt||Tt)&&Li(!0)},[Tt]);var fi=j.useState(null),Zi=(0,B.Z)(fi,2),Bi=Zi[0],ni=Zi[1],is=j.useState([0,0]),qi=(0,B.Z)(is,2),Ji=qi[0],Fi=qi[1],ss=function(Kt){Fi([Kt.clientX,Kt.clientY])},fs=Et(Tt,Ut,pi?Ji:q,Qt,_t,si,ci),Ni=(0,B.Z)(fs,11),Rs=Ni[0],ks=Ni[1],_s=Ni[2],gs=Ni[3],cs=Ni[4],ns=Ni[5],ls=Ni[6],ms=Ni[7],Ls=Ni[8],Yi=Ni[9],Gi=Ni[10],es=xe(Pt,W,O,le),os=(0,B.Z)(es,2),Is=os[0],Ft=os[1],Ss=Is.has("click"),Cs=Ft.has("click")||Ft.has("contextMenu"),bs=(0,Ae.Z)(function(){Ci||Gi()}),Vs=function(){Ri.current&&pi&&Cs&&oi(!1)};Gt(Tt,q,Ut,bs,Vs),(0,ce.Z)(function(){bs()},[Ji,Qt]),(0,ce.Z)(function(){Tt&&!(_t!=null&&_t[Qt])&&bs()},[JSON.stringify(si)]);var Ks=j.useMemo(function(){var yt=ie(_t,ae,Yi,pi);return m()(yt,li==null?void 0:li(Yi))},[Yi,li,_t,ae,pi]);j.useImperativeHandle(D,function(){return{nativeElement:pe.current,forceAlign:bs}});var Qs=j.useState(0),Ps=(0,B.Z)(Qs,2),vi=Ps[0],an=Ps[1],Hs=j.useState(0),js=(0,B.Z)(Hs,2),Js=js[0],Ms=js[1],Bs=function(){if(bi&&q){var Kt=q.getBoundingClientRect();an(Kt.width),Ms(Kt.height)}},ps=function(){Bs(),bs()},ts=function(Kt){Li(!1),Gi(),ft==null||ft(Kt)},xs=function(){return new Promise(function(Kt){Bs(),ni(function(){return Kt})})};(0,ce.Z)(function(){Bi&&(Gi(),Bi(),ni(null))},[Bi]);function ji(yt,Kt,zi,Xi){ke[yt]=function(Di){var Ws;Xi==null||Xi(Di),oi(Kt,zi);for(var Zs=arguments.length,En=new Array(Zs>1?Zs-1:0),on=1;on<Zs;on++)En[on-1]=arguments[on];(Ws=Ue[yt])===null||Ws===void 0||Ws.call.apply(Ws,[Ue,Di].concat(En))}}(Ss||Cs)&&(ke.onClick=function(yt){var Kt;Ri.current&&Cs?oi(!1):!Ri.current&&Ss&&(ss(yt),oi(!0));for(var zi=arguments.length,Xi=new Array(zi>1?zi-1:0),Di=1;Di<zi;Di++)Xi[Di-1]=arguments[Di];(Kt=Ue.onClick)===null||Kt===void 0||Kt.call.apply(Kt,[Ue,yt].concat(Xi))}),$e(Tt,Cs,q,Ut,ge,ti,xt,oi);var vs=Is.has("hover"),ys=Ft.has("hover"),us,Qi;vs&&(ji("onMouseEnter",!0,nt,function(yt){ss(yt)}),ji("onPointerEnter",!0,nt,function(yt){ss(yt)}),us=function(Kt){(Tt||Ci)&&Ut!==null&&Ut!==void 0&&Ut.contains(Kt.target)&&oi(!0,nt)},pi&&(ke.onMouseMove=function(yt){var Kt;(Kt=Ue.onMouseMove)===null||Kt===void 0||Kt.call(Ue,yt)})),ys&&(ji("onMouseLeave",!1,tt),ji("onPointerLeave",!1,tt),Qi=function(){oi(!1,tt)}),Is.has("focus")&&ji("onFocus",!0,It),Ft.has("focus")&&ji("onBlur",!1,Ot),Is.has("contextMenu")&&(ke.onContextMenu=function(yt){var Kt;Ri.current&&Ft.has("contextMenu")?oi(!1):(ss(yt),oi(!0)),yt.preventDefault();for(var zi=arguments.length,Xi=new Array(zi>1?zi-1:0),Di=1;Di<zi;Di++)Xi[Di-1]=arguments[Di];(Kt=Ue.onContextMenu)===null||Kt===void 0||Kt.call.apply(Kt,[Ue,yt].concat(Xi))}),G&&(ke.className=m()(Ue.className,G));var yi=(0,S.Z)((0,S.Z)({},Ue),ke),rs={},zs=["onContextMenu","onClick","onMouseDown","onTouchStart","onMouseEnter","onMouseLeave","onFocus","onBlur"];zs.forEach(function(yt){Ye[yt]&&(rs[yt]=function(){for(var Kt,zi=arguments.length,Xi=new Array(zi),Di=0;Di<zi;Di++)Xi[Di]=arguments[Di];(Kt=yi[yt])===null||Kt===void 0||Kt.call.apply(Kt,[yi].concat(Xi)),Ye[yt].apply(Ye,Xi)})});var en=j.cloneElement(Se,(0,S.Z)((0,S.Z)({},yi),rs)),tn={x:ns,y:ls},Fs=as?(0,S.Z)({},as!==!0?as:{}):null;return j.createElement(j.Fragment,null,j.createElement(oe.Z,{disabled:!Tt,ref:Ce,onResize:ps},j.createElement(Z,{getTriggerDOMNode:J},en)),j.createElement(He.Provider,{value:Ke},j.createElement(de,{portal:k,ref:ki,prefixCls:ae,popup:Si,className:m()(ii,Ks),style:Mi,target:q,onMouseEnter:us,onMouseLeave:Qi,onPointerEnter:us,zIndex:At,open:Tt,keepDom:Ci,fresh:_i,onClick:ri,mask:ge,motion:Mt,maskMotion:pt,onVisibleChanged:ts,onPrepare:xs,forceRender:Xt,autoDestroy:Ve,getPopupContainer:hi,align:Yi,arrow:Fs,arrowPos:tn,ready:Rs,offsetX:ks,offsetY:_s,offsetR:gs,offsetB:cs,onAlign:bs,stretch:bi,targetWidth:vi/ms,targetHeight:Js/Ls})))});return C}var Ht=Zt(z.Z)},71839:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return ct}});var S=R(59301),B=R(8591),fe=R(38854),z=R(29382),A=R(65157),m=R(24065),oe=R(56102),H=R(4901),me={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"},Ae=(Re,De,K)=>new Promise((P,F)=>{var Y=ve=>{try{de(K.next(ve))}catch(Z){F(Z)}},X=ve=>{try{de(K.throw(ve))}catch(Z){F(Z)}},de=ve=>ve.done?P(ve.value):Promise.resolve(ve.value).then(Y,X);de((K=K.apply(Re,De)).next())});function Pe(Re){if(isNaN(Re))return{minutes:"00",seconds:"00"};const De=new Date(Re*1e3).toISOString().substr(11,8);return{hour:De.substr(0,2),minutes:De.substr(3,2),seconds:De.substr(6,2)}}Object.defineProperty(HTMLMediaElement.prototype,"playing",{get:function(){return this.currentTime>0&&!this.paused&&!this.ended&&this.readyState>2}});function ce(Re,De){return Re-De}function I(Re){Re.sort(ce);let De=0;for(let K=0;K<Re.length-1;K++){let P=Math.abs(Re[K+1]-Re[K]);P<21&&(De+=P)}return De}const j=/(android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini)/i;var ct=(0,S.forwardRef)(({allow_skip:Re,src:De,toLog:K,videoId:P,logWatchHistory:F,courseId:Y=null,startTime:X,handlePause:de=()=>{},handlePlay:ve=()=>{},handlePlayEnded:Z=()=>{},autoPlay:Oe=!1,onPlayEnded:He=()=>{},isShowWaterMark:Qe=!0},xe)=>{var ee;De=De==null?void 0:De.replace("http://","https://");const ie=((ee=De==null?void 0:De.split("."))==null?void 0:ee.pop())==="flv",N=(0,S.useRef)(),we=(0,S.useRef)(),je=(0,S.useRef)(),Ee=(0,S.useRef)(),_e=(0,S.useRef)(),Me=(0,S.useRef)(),Be=(0,S.useRef)(),Fe=(0,S.useRef)(),Ze=(0,S.useRef)(),ot=(0,S.useRef)(),mt=(0,S.useRef)(),Et=(0,S.useRef)(),wt=(0,S.useRef)(),Gt=(0,S.useRef)(),gt=navigator.userAgent.toLowerCase().match(j),bt=gt?gt[0]:"pc",$e=(0,S.useRef)(!1),Vt=(0,m.eY)();let Zt=0,Ht=0,k=0,C=null,x=!1,D=20,$=1,ae=!1,w=!1,V=[];(0,S.useImperativeHandle)(xe,()=>({getLastUpdatedTime:()=>N.current.currentTime,getDuration:()=>N.current.duration})),B.ZP.config({maxCount:1,getContainer:()=>je.current});const W=(0,S.useCallback)((nt,st=!1)=>{let tt={point:N.current.currentTime};C?(tt.log_id=C,tt.watch_duration=I(V),tt.total_duration=Ht):(Y?(tt.video_id=parseInt(P,10),tt.course_id=Y):tt.video_id=P,tt.duration=Zt,tt.device=bt),st&&(tt.ed="1");function It(){return Ae(this,null,function*(){ae=!0,C=yield F==null?void 0:F(tt),ae=!1,nt&&nt()})}It()},[P,Y]);(0,S.useEffect)(()=>{N.current&&(Ee.current.style.display="none",_e.current.style.display="block"),B.ZP.destroy();let nt=null;return z.Z.isSupported&&ie&&De&&(De==null?void 0:De.indexOf(".m3u8"))<0?(nt=z.Z.createPlayer({type:"flv",volume:.8,cors:!0,url:De,muted:!1}),N.current&&(nt.attachMediaElement(N.current),nt.load())):N.current.setAttribute("src",De),le(),()=>{nt&&(nt.unload(),nt.pause(),nt.destroy(),nt=null)}},[N,ie,De]);function O(){N.current.paused?(Ee.current.style.display="none",_e.current.style.display="block"):(Ee.current.style.display="block",_e.current.style.display="none")}function le(){mt.current.style.display="none",wt.current.style.display="none",Et.current.style.display="none",N.current.muted||N.current.volume===0?mt.current.style.display="block":N.current.volume>0&&N.current.volume<=.5?wt.current.style.display="block":Et.current.style.display="block"}(0,S.useEffect)(()=>{const nt=document.getElementById("play"),st=document.querySelectorAll(".playback-icons use");function tt(){ve(),X&&!$e.current&&(N.current.currentTime=X),$e.current=!0,V.push(N.current.currentTime),x||(x=!0,K&&W())}function It(){return Ae(this,null,function*(){O(),V.push(N.current.currentTime),K&&W(()=>{C=null,k=0,x=!1,ae=!1,w=!1,V=[],Ht=0,$=1},!0),He()})}function Ot(){Me.current.value=Math.round(N.current.currentTime),Be.current.value=Math.round(N.current.currentTime)}function ge(){const ut=Pe(Math.round(N.current.currentTime));Ze.current.innerText=`${ut.hour>0?ut.hour+":":""}${ut.minutes}:${ut.seconds}`,Ze.current.setAttribute("datetime",`${ut.hour>0?" "+ut.hour+" ":""}${ut.minutes}m ${ut.seconds}s`)}function ei(){var ut,_t,si,At,bi,li,_i;const pi=Math.round((ut=N.current)==null?void 0:ut.duration);(si=(_t=Me.current)==null?void 0:_t.setAttribute)==null||si.call(_t,"max",pi),(bi=(At=Be.current)==null?void 0:At.setAttribute)==null||bi.call(At,"max",pi);const ri=Pe(pi);Fe.current&&(Fe.current.innerText=`${ri.hour>0?ri.hour+":":""}${ri.minutes}:${ri.seconds}`,(_i=(li=Fe.current).setAttribute)==null||_i.call(li,"datetime",`${ri.hour>0?" "+ri.hour+" ":""}${ri.minutes}m ${ri.seconds}s`))}function ti(){try{const ut=Math.round(N.current.duration);Me.current.setAttribute("max",ut),Be.current.setAttribute("max",ut);const _t=Pe(ut);Fe.current.innerText=`${_t.hour>0?_t.hour+":":""}${_t.minutes}:${_t.seconds}`,Fe.current.setAttribute("datetime",`${_t.hour>0?" "+_t.hour+" ":""}${_t.minutes}m ${_t.seconds}s`),Ot(),ge();const{width:si,height:At,x:bi,y:li}=we.current.getBoundingClientRect();if(bi<0||li<0||!si)return;if(!w){let _i=N.current.currentTime,pi=_i-k;Math.abs(pi)<10?(Ht+=Math.abs(pi),k=_i,ae||Ht-$*D>=0&&($++,V.push(k),K&&W())):(k=_i,K&&W())}}catch(ut){console.log(ut)}}function hi(){w=!0}function Xt(){N.current.playing&&V.push(N.current.currentTime,k),k=N.current.currentTime,w=!1}function Ti(){Zt=N.current.duration,Zt<=20&&(D=Zt/3),N.current.addEventListener("play",tt)}function gi(ut){ut.preventDefault(),(0,H.vp)()?(N.current.style.width="100%",N.current.style.height="100%"):N.current.style.cssText=""}function Si(){de()}function ii(ut){if(!Re){B.ZP.warning("\u8BE5\u89C6\u9891\u7981\u6B62\u5FEB\u8FDB/\u540E\u9000\u64AD\u653E");return}const _t=ut.target.dataset.seek?ut.target.dataset.seek:ut.target.value;N.current.currentTime=_t,Be.current.value=_t,Me.current.value=_t}function Mi(ut){const _t=Math.round(ut.offsetX/ut.target.clientWidth*parseInt(ut.target.getAttribute("max"),10));Me.current.setAttribute("data-seek",_t);const si=Pe(_t);ot.current.textContent=`${si.hour>0?si.hour+":":""}${si.minutes}:${si.seconds}`;const At=N.current.getBoundingClientRect();ot.current.style.left=`${ut.pageX-At.left}px`}function Qt(ut){switch(ut.code){case"Space":ut.preventDefault(),Je();break;case"ArrowRight":if(ut.preventDefault(),!Re){B.ZP.warning("\u8BE5\u89C6\u9891\u7981\u6B62\u5FEB\u8FDB/\u540E\u9000\u64AD\u653E");break}if(N.current.currentTime>=N.current.duration)break;N.current.currentTime=parseInt(N.current.currentTime)+5,Ot();break;case"ArrowLeft":if(ut.preventDefault(),!Re){B.ZP.warning("\u8BE5\u89C6\u9891\u7981\u6B62\u5FEB\u8FDB/\u540E\u9000\u64AD\u653E");break}if(N.current.currentTime===0)break;N.current.currentTime=parseInt(N.current.currentTime)-5,Ot();break;case"ArrowUp":ut.preventDefault(),N.current.volume<1&&(N.current.volume=(parseInt(N.current.volume*10)+1)/10);break;case"ArrowDown":ut.preventDefault(),N.current.volume>0&&(N.current.volume=(parseInt(N.current.volume*10)-1)/10);break}}return je.current.addEventListener((0,H.gH)(),gi),N.current.addEventListener("canplay",Ti),N.current.addEventListener("ended",It),N.current.addEventListener("seeking",hi),N.current.addEventListener("seeked",Xt),N.current.addEventListener("loadedmetadata",ei),Me.current.addEventListener("mousemove",Mi),Me.current.addEventListener("input",ii),N.current.addEventListener("timeupdate",ti),N.current.addEventListener("pause",Si),N.current.addEventListener("volumechange",le),document.addEventListener("keydown",Qt),()=>{var ut,_t,si,At,bi,li,_i,pi,ri,ci,as,Ge;(ut=N.current)==null||ut.removeEventListener("canplay",Ti),(_t=N.current)==null||_t.removeEventListener("play",tt),(si=N.current)==null||si.removeEventListener("ended",It),(At=N.current)==null||At.removeEventListener("seeking",hi),(bi=N.current)==null||bi.removeEventListener("seeked",Xt),(li=Me.current)==null||li.removeEventListener("mousemove",Mi),(_i=Me.current)==null||_i.removeEventListener("input",ii),(pi=N.current)==null||pi.removeEventListener("timeupdate",ti),(ri=N.current)==null||ri.removeEventListener("pause",Si),(ci=N.current)==null||ci.removeEventListener("loadedmetadata",ei),(as=N.current)==null||as.removeEventListener("volumechange",le),document.removeEventListener("keydown",Qt),(Ge=N.current)!=null&&Ge.playing&&(V.push(k,N.current.currentTime),K&&W())}},[N,De]),(0,S.useEffect)(()=>{if(N.current.onended=()=>{Z(N)},N.current.oncontextmenu=()=>!1,(De==null?void 0:De.indexOf(".m3u8"))>-1){if(N.current.canPlayType("application/vnd.apple.mpegurl"))N.current.src=De;else if(A.ZP.isSupported()){var nt=new A.ZP;nt.loadSource(De),nt.attachMedia(N.current)}}},[De]);const[Le,We]=(0,S.useState)(1),Je=()=>{N.current.paused||N.current.ended?N.current.play():N.current.pause(),O()};function ft(){N.current.muted=!N.current.muted,N.current.muted?(Gt.current.setAttribute("data-volume",volume.value),Gt.current.value=0):Gt.current.value=Gt.current.dataset.volume}return S.createElement("div",{style:{position:"relative"},ref:je},S.createElement("div",{ref:we,className:`${me.watermark} animated_alternate animate__animated_10s animate__infinite animate__stepstart ${me.animate__loop}`},Qe&&Vt?Vt.login:" "),S.createElement("div",{className:me.container},S.createElement("div",{className:me["video-container"],id:"video-container"},S.createElement("div",{className:me["playback-animation"],id:"playback-animation"},S.createElement("svg",{className:me["playback-icons"]},S.createElement("use",{className:"hidden",href:"#play-icon"}),S.createElement("use",{href:"#pause"}))),S.createElement("video",{className:me.video,id:"video",preload:"auto",disablePictureInPicture:!0,ref:N,autoPlay:Oe}),S.createElement("div",{className:`${me["video-controls"]} `,id:"video-controls"},S.createElement("div",{className:me["bottom-controls"]},S.createElement("div",{className:me["left-controls"]},S.createElement("button",{"data-title":"\u64AD\u653E/\u6682\u505C",id:"play",onClick:Je},S.createElement("svg",{className:me["playback-icons"]},S.createElement("use",{ref:_e,href:"#play-icon"}),S.createElement("use",{ref:Ee,style:{display:"none"},href:"#pause"}))),S.createElement("div",{className:me.time},S.createElement("time",{id:"time-elapsed",ref:Ze},"00:00"),S.createElement("span",null," / "),S.createElement("time",{id:"duration",ref:Fe},"00:00"))),S.createElement("div",{className:me["right-controls"]},Re&&S.createElement(fe.Z,{placement:"top",overlayClassName:me.rateOverlay,getPopupContainer:nt=>nt.parentNode,menu:{items:[{key:"1",label:S.createElement("span",{onClick:()=>{We(1),N.current.playbackRate=1}},"1.0x")},{key:"2",label:S.createElement("span",{onClick:()=>{We(1.5),N.current.playbackRate=1.5}},"1.5x")},{key:"3",label:S.createElement("span",{onClick:()=>{We(2),N.current.playbackRate=2}},"2.0x")}]}},S.createElement("div",{className:`${me.controlText} mr5`},"\u500D\u901F")),S.createElement(oe.CopyToClipboard,{text:De,onCopy:()=>B.ZP.success("\u590D\u5236\u6210\u529F")},S.createElement("button",{"data-title":"\u590D\u5236\u94FE\u63A5"},S.createElement("i",{className:"icon-lianjie2 iconfont",style:{fontSize:"12px",color:"white"}}))),S.createElement("div",{className:me["volume-controls"]},S.createElement("button",{"data-title":"\u5F00\u542F/\u5173\u95ED\u58F0\u97F3",className:me["volume-button"],id:"volume-button",onClick:ft},S.createElement("i",{ref:mt,className:"icon-a-bianzu8 iconfont",style:{fontSize:"14px",color:"white"}}),S.createElement("i",{ref:wt,className:"icon-shengyinkaibeifen iconfont",style:{fontSize:"14px",color:"white"}}),S.createElement("i",{ref:Et,className:"icon-shengyinkai iconfont",style:{fontSize:"14px",color:"white"}})),S.createElement("input",{className:me.volume,id:"volume",value:"1","data-mute":"0.5",type:"range",max:"1",min:"0",step:"0.01",ref:Gt,style:{display:"none"},onClick:le})),S.createElement("button",{"data-title":"\u5168\u5C4F/\u9000\u51FA\u5168\u5C4F",className:me["fullscreen-button"],onClick:()=>{(0,H.vp)()?(0,H.BU)():(0,H.Dj)(je.current)}},S.createElement("i",{className:"icon-fangda1 iconfont",style:{fontSize:"12px",color:"white"}})))),S.createElement("div",{className:me["video-progress"]},S.createElement("progress",{ref:Be,value:"0",min:"0"}),S.createElement("input",{className:me.seek,ref:Me,value:"0",min:"0",type:"range",step:"1"}),S.createElement("div",{className:me["seek-tooltip"],ref:ot,id:"seek-tooltip"},"00:00"))))),S.createElement("svg",{style:{display:"none"}},S.createElement("defs",null,S.createElement("symbol",{id:"pause",viewBox:"0 0 24 24"},S.createElement("path",{d:"M14.016 5.016h3.984v13.969h-3.984v-13.969zM6 18.984v-13.969h3.984v13.969h-3.984z"})),S.createElement("symbol",{id:"play-icon",viewBox:"0 0 24 24"},S.createElement("path",{d:"M8.016 5.016l10.969 6.984-10.969 6.984v-13.969z"})),S.createElement("symbol",{id:"volume-high",viewBox:"0 0 24 24"},S.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"})),S.createElement("symbol",{id:"volume-low",viewBox:"0 0 24 24"},S.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"})),S.createElement("symbol",{id:"volume-mute",viewBox:"0 0 24 24"},S.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"})),S.createElement("symbol",{id:"fullscreen",viewBox:"0 0 24 24"},S.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"})),S.createElement("symbol",{id:"fullscreen-exit",viewBox:"0 0 24 24"},S.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"})),S.createElement("symbol",{id:"pip",viewBox:"0 0 24 24"},S.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"})))))})},66676:function(Wt,ze,R){"use strict";R.r(ze),R.d(ze,{default:function(){return De}});var S=R(59301),B=R(89070),fe=R(61621),z=R(43418),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"},m=R(24065);const oe={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(K=>(K.parent=Number(K.parent),K.key=Number(K.key),K)),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(K=>(K.parent=Number(K.parent),K.key=Number(K.key),K)),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(K=>(K.parent=Number(K.parent),K.key=Number(K.key),K))};var H=R(62202),me=R(71839),Ae=Object.defineProperty,Pe=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,j=(K,P,F)=>P in K?Ae(K,P,{enumerable:!0,configurable:!0,writable:!0,value:F}):K[P]=F,ct=(K,P)=>{for(var F in P||(P={}))ce.call(P,F)&&j(K,F,P[F]);if(Pe)for(var F of Pe(P))I.call(P,F)&&j(K,F,P[F]);return K};const Re=({classroomList:K,loading:P,dispatch:F})=>{const[Y]=(0,B.useSearchParams)(),[X]=(0,S.useState)(ct({},(0,B.useParams)())),[de,ve]=(0,S.useState)("init"),[Z,Oe]=(0,S.useState)(""),He=(0,S.useRef)();(0,S.useEffect)(()=>{const ie=Y.get("tabId");ie&&(ve(ie),X.status=ie)},[X.categoryId,Y.get("tabId")]);const Qe=ie=>{ve(ie.key)},xe=[{name:"\u521D\u59CB\u5B66\u4E60",id:"init"},{name:"\u590D\u4E60\u5B66\u4E60",id:"review"},{name:"\u8003\u524D\u5B66\u4E60",id:"before"}],ee=ie=>{ie.data.type==="playVideo"&&Oe(ie.data.url)};(0,S.useEffect)(()=>{de&&Q(),window.addEventListener("message",ee)},[de]);const Q=()=>{var ie;(ie=He.current.contentWindow)==null||ie.postMessage({data:oe[de]},"*")};return S.createElement("section",null,S.createElement(H.Z,{isLoading:P["classroomList/getClassroomAttendancesList"],tabDataSource:xe,isAdmin:(0,m.GJ)(),onTabMenuClick:Qe,defaultSelectedKeys:[de]}),S.createElement("section",null,S.createElement(fe.Z,{loading:P["classroomList/getClassroomAttendancesList"],active:!0,avatar:{size:40},paragraph:{rows:5},className:"mt30"},S.createElement("iframe",{src:"/knowledgegraph/parseTree.html",onLoad:Q,className:A.iframe,ref:He}))),S.createElement(z.default,{open:!!Z,onCancel:()=>Oe(""),width:800,footer:null,bodyStyle:{padding:0},centered:!0,destroyOnClose:!0},S.createElement(me.Z,{src:Z,autoPlay:!0,toLog:!1})))};var De=(0,B.connect)(({classroomList:K,loading:P,globalSetting:F})=>({classroomList:K,globalSetting:F,loading:P.effects}))(Re)},62202:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return ce}});var S=R(59301),B=R(95237),fe=R(43604),z=R(20834),A=R(38854),m=R(8591),oe=R(6848),H={tabMenuContainer:"tabMenuContainer___uf5IP",control:"control___GheLs",iconH:"iconH___Wzw_r",selectBtn:"selectBtn___mfEnI",selectBtn1:"selectBtn1___rJF8S"},me=R(89070),Ae=R(24065),ce=({isLoading:I,addText:j,tabDataSource:ct,isAdmin:Re,dispatch:De,classroomList:K,type:P,isExercise:F,defaultSelectedKeys:Y,onTabMenuClick:X,getDropdownMenu:de,showControlButton:ve,buttonText:Z,buttonIcon:Oe="icon-tianjiadaohang",extraNode:He,user:Qe,onButtonClick:xe,isModelUser:ee,menuItemWidth:Q=125})=>{var ie,N,we,je,Ee;const _e=(0,me.useParams)();return S.createElement("div",{className:H.tabMenuContainer},S.createElement(B.Z,null,S.createElement(fe.Z,{flex:"1"},S.createElement(z.default,{onSelect:Me=>I?{}:X(Me),mode:"horizontal",selectedKeys:Y},ct.map(Me=>S.createElement(z.default.Item,{style:{width:Q},key:typeof Me.index=="number"?Me.index:Me.id},S.createElement("span",{className:"c-grey-666"},Me.name),Me.total!==void 0&&Re&&S.createElement("span",{className:"c-grey-999 ml20"},Me.total||0))))),Re&&F&&S.createElement("i",{className:"iconfont icon-shezhi8",style:{display:"flex",alignItems:"center",cursor:"pointer"},onClick:()=>{De({type:"classroomList/setActionTabs",payload:{key:"\u5728\u7EBF\u8003\u8BD5\u8BBE\u7F6E"}})}}),Re&&S.createElement(fe.Z,{className:"mr20 gutter-row",style:{display:"flex",alignItems:"center",color:"#0152d9",paddingBottom:3}},F&&S.createElement(A.Z,{className:"mr15",placement:"bottom",arrow:!0,dropdownRender:()=>S.createElement(z.default,null,S.createElement(z.default.Item,{key:1,onClick:()=>{var Me;if((0,Ae.Rm)()&&!((Me=K.AssistantObject.exercise)!=null&&Me.can_download)){m.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}De({type:"classroomList/setActionTabs",payload:{key:"\u5BFC\u51FA\u6210\u7EE9",type:P,exportType:"exercise",category_id:_e.categoryId}})}},"\u5B66\u751F\u6210\u7EE9"),S.createElement(z.default.Item,{key:3,onClick:()=>{var Me;if((0,Ae.Rm)()&&!((Me=K.AssistantObject.exercise)!=null&&Me.can_download)){m.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}me.history.push(`/classrooms/${_e==null?void 0:_e.coursesId}/exportlist/exercise_score,export_exercise_users`)}},"\u5386\u53F2\u5BFC\u51FA"))},S.createElement("div",{className:"c-blue font16 ml20 current",style:{marginTop:2}},S.createElement("span",{style:{color:"#666666",cursor:"pointer"}},S.createElement("i",{className:"iconfont icon-xiazai6"})))),S.createElement("div",{className:H.control},S.createElement("div",{className:H.extra},He),ve&&(Z=="\u6DFB\u52A0\u76F4\u64AD"?S.createElement(A.Z,{menu:{items:(N=(ie=[{label:S.createElement("div",{onClick:()=>{xe("\u5916\u94FE")}},"\u5916\u94FE\u76F4\u64AD"),key:"1",show:!0},ee&&{label:S.createElement("div",{onClick:()=>{xe("\u5934\u6B4C")}},"\u5934\u6B4C\u76F4\u64AD"),key:"2",show:!0}])==null?void 0:ie.filter(Me=>Me==null?void 0:Me.show))==null?void 0:N.map(Me=>({label:Me==null?void 0:Me.label,key:Me==null?void 0:Me.key}))}},S.createElement("span",{className:H.selectBtn},S.createElement("span",null,S.createElement("i",{className:`iconfont ${Oe}`})),S.createElement("span",null,Z))):S.createElement("span",{onClick:xe,style:{cursor:"pointer"},className:H.selectBtn},S.createElement("span",null,S.createElement("i",{className:`iconfont ${Oe}`})),S.createElement("span",null,Z))),!!de&&S.createElement(A.Z,{disabled:((we=Qe==null?void 0:Qe.userInfo)==null?void 0:we.user_status)===2,className:"ml10",dropdownRender:de},S.createElement("span",{className:((je=Qe==null?void 0:Qe.userInfo)==null?void 0:je.user_status)===2?H.selectBtn1:H.selectBtn},S.createElement("span",null,S.createElement("i",{className:"iconfont icon-tianjiadaohang"})),S.createElement(oe.Z,{title:((Ee=Qe==null?void 0:Qe.userInfo)==null?void 0:Ee.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"},S.createElement("span",null,j||"\u521B\u5EFA\u8BD5\u5377"))))))))}},4901:function(Wt,ze,R){"use strict";R.d(ze,{BU:function(){return B},Dj:function(){return S},gH:function(){return fe},vp:function(){return z}});function S(A){try{A.mozRequestFullScreen?A.mozRequestFullScreen():A.webkitRequestFullScreen&&A.webkitRequestFullScreen()}catch(m){console.log(m,":e")}}function B(){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 fe=()=>{if(document.webkitExitFullscreen)return"webkitfullscreenchange";if(document.exitFullscreen)return"fullscreenchange";if(document.msExitFullscreen)return"msfullscreenchange";if(document.mozCancelFullScreen)return"mozfullscreenchange"};function z(){var A=window.top.document.fullscreenElement||window.top.document.mozFullscreenElement||window.top.document.webkitFullscreenElement,m=document.fullscreenEnabled||document.mozFullscreenEnabled||document.webkitFullscreenEnabled;return console.log("fullscreenElement",A),window.isFullScreen?window.isFullScreen:A!=null}},29382:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return as}});class S{static install(){Object.setPrototypeOf=Object.setPrototypeOf||function(c,f){return c.__proto__=f,c},Object.assign=Object.assign||function(c){if(c==null)throw new TypeError("Cannot convert undefined or null to object");let f=Object(c);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"&&R(3867).polyfill()}}S.install();var B=S,fe=R(86204),z=R.n(fe);class A{static e(c,f){(!c||A.FORCE_GLOBAL_TAG)&&(c=A.GLOBAL_TAG);let p=`[${c}] > ${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(c,f){(!c||A.FORCE_GLOBAL_TAG)&&(c=A.GLOBAL_TAG);let p=`[${c}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","info",p),A.ENABLE_INFO&&(console.info?console.info(p):console.log(p))}static w(c,f){(!c||A.FORCE_GLOBAL_TAG)&&(c=A.GLOBAL_TAG);let p=`[${c}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","warn",p),A.ENABLE_WARN&&(console.warn?console.warn(p):console.log(p))}static d(c,f){(!c||A.FORCE_GLOBAL_TAG)&&(c=A.GLOBAL_TAG);let p=`[${c}] > ${f}`;A.ENABLE_CALLBACK&&A.emitter.emit("log","debug",p),A.ENABLE_DEBUG&&(console.debug?console.debug(p):console.log(p))}static v(c,f){(!c||A.FORCE_GLOBAL_TAG)&&(c=A.GLOBAL_TAG);let p=`[${c}] > ${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(z());var m=A;class oe{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(c){this._firstCheckpoint===0?(this._firstCheckpoint=this._now(),this._lastCheckpoint=this._firstCheckpoint,this._intervalBytes+=c,this._totalBytes+=c):this._now()-this._lastCheckpoint<1e3?(this._intervalBytes+=c,this._totalBytes+=c):(this._lastSecondBytes=this._intervalBytes,this._intervalBytes=c,this._totalBytes+=c,this._lastCheckpoint=this._now())}get currentKBps(){this.addBytes(0);let c=(this._now()-this._lastCheckpoint)/1e3;return c==0&&(c=1),this._intervalBytes/c/1024}get lastSecondKBps(){return this.addBytes(0),this._lastSecondBytes!==0?this._lastSecondBytes/1024:this._now()-this._lastCheckpoint>=500?this.currentKBps:0}get averageKBps(){let c=(this._now()-this._firstCheckpoint)/1e3;return this._totalBytes/c/1024}}var H=oe;class me{constructor(c){this._message=c}get name(){return"RuntimeException"}get message(){return this._message}toString(){return this.name+": "+this.message}}class Ae extends me{constructor(c){super(c)}get name(){return"IllegalStateException"}}class Pe extends me{constructor(c){super(c)}get name(){return"InvalidArgumentException"}}class ce extends me{constructor(c){super(c)}get name(){return"NotImplementedException"}}const I={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},j={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"};class ct{constructor(c){this._type=c||"undefined",this._status=I.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}destroy(){this._status=I.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}isWorking(){return this._status===I.kConnecting||this._status===I.kBuffering}get type(){return this._type}get status(){return this._status}get needStashBuffer(){return this._needStash}get onContentLengthKnown(){return this._onContentLengthKnown}set onContentLengthKnown(c){this._onContentLengthKnown=c}get onURLRedirect(){return this._onURLRedirect}set onURLRedirect(c){this._onURLRedirect=c}get onDataArrival(){return this._onDataArrival}set onDataArrival(c){this._onDataArrival=c}get onError(){return this._onError}set onError(c){this._onError=c}get onComplete(){return this._onComplete}set onComplete(c){this._onComplete=c}open(c,f){throw new ce("Unimplemented abstract function!")}abort(){throw new ce("Unimplemented abstract function!")}}let Re={};function De(){let Ge=self.navigator.userAgent.toLowerCase(),c=/(edge)\/([\w.]+)/.exec(Ge)||/(opr)[\/]([\w.]+)/.exec(Ge)||/(chrome)[ \/]([\w.]+)/.exec(Ge)||/(iemobile)[\/]([\w.]+)/.exec(Ge)||/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(Ge)||/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(Ge)||/(webkit)[ \/]([\w.]+)/.exec(Ge)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(Ge)||/(msie) ([\w.]+)/.exec(Ge)||Ge.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(Ge)||Ge.indexOf("compatible")<0&&/(firefox)[ \/]([\w.]+)/.exec(Ge)||[],f=/(ipad)/.exec(Ge)||/(ipod)/.exec(Ge)||/(windows phone)/.exec(Ge)||/(iphone)/.exec(Ge)||/(kindle)/.exec(Ge)||/(android)/.exec(Ge)||/(windows)/.exec(Ge)||/(mac)/.exec(Ge)||/(linux)/.exec(Ge)||/(cros)/.exec(Ge)||[],p={browser:c[5]||c[3]||c[1]||"",version:c[2]||c[4]||"0",majorVersion:c[4]||c[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 Re)Re.hasOwnProperty(T)&&delete Re[T];Object.assign(Re,E)}De();var K=Re;class P extends ct{static isSupported(){try{let c=K.msedge&&K.version.minor>=15048,f=K.msedge?c:!0;return self.fetch&&self.ReadableStream&&f}catch(c){return!1}}constructor(c,f){super("fetch-stream-loader"),this.TAG="FetchStreamLoader",this._seekHandler=c,this._config=f,this._needStash=!0,this._requestAbort=!1,this._contentLength=null,this._receivedLength=0}destroy(){this.isWorking()&&this.abort(),super.destroy()}open(c,f){this._dataSource=c,this._range=f;let p=c.url;this._config.reuseRedirectedURL&&c.redirectedURL!=null&&(p=c.redirectedURL);let E=this._seekHandler.getConfig(p,f),T=new self.Headers;if(typeof E.headers=="object"){let J=E.headers;for(let Ye in J)J.hasOwnProperty(Ye)&&T.append(Ye,J[Ye])}let G={method:"GET",headers:T,mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if(typeof this._config.headers=="object")for(let J in this._config.headers)T.append(J,this._config.headers[J]);c.cors===!1&&(G.mode="same-origin"),c.withCredentials&&(G.credentials="include"),c.referrerPolicy&&(G.referrerPolicy=c.referrerPolicy),this._status=I.kConnecting,self.fetch(E.url,G).then(J=>{if(this._requestAbort){this._requestAbort=!1,this._status=I.kIdle;return}if(J.ok&&J.status>=200&&J.status<=299){if(J.url!==E.url&&this._onURLRedirect){let Ve=this._seekHandler.removeURLParameters(J.url);this._onURLRedirect(Ve)}let Ye=J.headers.get("Content-Length");return Ye!=null&&(this._contentLength=parseInt(Ye),this._contentLength!==0&&this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength)),this._pump.call(this,J.body.getReader())}else if(this._status=I.kError,this._onError)this._onError(j.HTTP_STATUS_CODE_INVALID,{code:J.status,msg:J.statusText});else throw new me("FetchStreamLoader: Http code invalid, "+J.status+" "+J.statusText)}).catch(J=>{if(this._status=I.kError,this._onError)this._onError(j.EXCEPTION,{code:-1,msg:J.message});else throw J})}abort(){this._requestAbort=!0}_pump(c){return c.read().then(f=>{if(f.done)if(this._contentLength!==null&&this._receivedLength<this._contentLength){this._status=I.kError;let p=j.EARLY_EOF,E={code:-1,msg:"Fetch stream meet Early-EOF"};if(this._onError)this._onError(p,E);else throw new me(E.msg)}else this._status=I.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=I.kComplete,c.cancel();this._status=I.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(c)}}).catch(f=>{if(f.code===11&&K.msedge)return;this._status=I.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=j.EARLY_EOF,E={code:f.code,msg:"Fetch stream meet Early-EOF"}):(p=j.EXCEPTION,E={code:f.code,msg:f.message}),this._onError)this._onError(p,E);else throw new me(E.msg)})}}var F=P;class Y extends ct{static isSupported(){try{let c=new XMLHttpRequest;return c.open("GET","https://example.com",!0),c.responseType="moz-chunked-arraybuffer",c.responseType==="moz-chunked-arraybuffer"}catch(c){return m.w("MozChunkedLoader",c.message),!1}}constructor(c,f){super("xhr-moz-chunked-loader"),this.TAG="MozChunkedLoader",this._seekHandler=c,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(c,f){this._dataSource=c,this._range=f;let p=c.url;this._config.reuseRedirectedURL&&c.redirectedURL!=null&&(p=c.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),c.withCredentials&&(T.withCredentials=!0),typeof E.headers=="object"){let G=E.headers;for(let J in G)G.hasOwnProperty(J)&&T.setRequestHeader(J,G[J])}if(typeof this._config.headers=="object"){let G=this._config.headers;for(let J in G)G.hasOwnProperty(J)&&T.setRequestHeader(J,G[J])}this._status=I.kConnecting,T.send()}abort(){this._requestAbort=!0,this._xhr&&this._xhr.abort(),this._status=I.kComplete}_onReadyStateChange(c){let f=c.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=I.kError,this._onError)this._onError(j.HTTP_STATUS_CODE_INVALID,{code:f.status,msg:f.statusText});else throw new me("MozChunkedLoader: Http code invalid, "+f.status+" "+f.statusText);else this._status=I.kBuffering}}_onProgress(c){if(this._status===I.kError)return;this._contentLength===null&&c.total!==null&&c.total!==0&&(this._contentLength=c.total,this._onContentLengthKnown&&this._onContentLengthKnown(this._contentLength));let f=c.target.response,p=this._range.from+this._receivedLength;this._receivedLength+=f.byteLength,this._onDataArrival&&this._onDataArrival(f,p,this._receivedLength)}_onLoadEnd(c){if(this._requestAbort===!0){this._requestAbort=!1;return}else if(this._status===I.kError)return;this._status=I.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1)}_onXhrError(c){this._status=I.kError;let f=0,p=null;if(this._contentLength&&c.loaded<this._contentLength?(f=j.EARLY_EOF,p={code:-1,msg:"Moz-Chunked stream meet Early-Eof"}):(f=j.EXCEPTION,p={code:-1,msg:c.constructor.name+" "+c.type}),this._onError)this._onError(f,p);else throw new me(p.msg)}}var X=Y;class de extends null{static isSupported(){try{if(typeof self.MSStream=="undefined"||typeof self.MSStreamReader=="undefined")return!1;let c=new XMLHttpRequest;return c.open("GET","https://example.com",!0),c.responseType="ms-stream",c.responseType==="ms-stream"}catch(c){return Log.w("MSStreamLoader",c.message),!1}}constructor(c,f){super("xhr-msstream-loader"),this.TAG="MSStreamLoader",this._seekHandler=c,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(c,f){this._internalOpen(c,f,!1)}_internalOpen(c,f,p){this._dataSource=c,p?this._currentRange=f:this._totalRange=f;let E=c.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?E=this._currentRedirectedURL:c.redirectedURL!=null&&(E=c.redirectedURL));let T=this._seekHandler.getConfig(E,f);this._currentRequestURL=T.url;let G=this._reader=new self.MSStreamReader;G.onprogress=this._msrOnProgress.bind(this),G.onload=this._msrOnLoad.bind(this),G.onerror=this._msrOnError.bind(this);let J=this._xhr=new XMLHttpRequest;if(J.open("GET",T.url,!0),J.responseType="ms-stream",J.onreadystatechange=this._xhrOnReadyStateChange.bind(this),J.onerror=this._xhrOnError.bind(this),c.withCredentials&&(J.withCredentials=!0),typeof T.headers=="object"){let Ye=T.headers;for(let Ve in Ye)Ye.hasOwnProperty(Ve)&&J.setRequestHeader(Ve,Ye[Ve])}if(typeof this._config.headers=="object"){let Ye=this._config.headers;for(let Ve in Ye)Ye.hasOwnProperty(Ve)&&J.setRequestHeader(Ve,Ye[Ve])}this._isReconnecting?this._isReconnecting=!1:this._status=LoaderStatus.kConnecting,J.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(c){let f=c.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(c){this._status=LoaderStatus.kError;let f=LoaderErrors.EXCEPTION,p={code:-1,msg:c.constructor.name+" "+c.type};if(this._onError)this._onError(f,p);else throw new RuntimeException(p.msg)}_msrOnProgress(c){let p=c.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 c={from:this._totalRange.from+this._receivedLength,to:-1};this._internalOpen(this._dataSource,c,!0)}}_msrOnLoad(c){this._status=LoaderStatus.kComplete,this._onComplete&&this._onComplete(this._totalRange.from,this._totalRange.from+this._receivedLength-1)}_msrOnError(c){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:c.constructor.name+" "+c.type}),this._onError)this._onError(f,p);else throw new RuntimeException(p.msg)}}var ve=null;class Z extends ct{static isSupported(){try{let c=new XMLHttpRequest;return c.open("GET","https://example.com",!0),c.responseType="arraybuffer",c.responseType==="arraybuffer"}catch(c){return m.w("RangeLoader",c.message),!1}}constructor(c,f){super("xhr-range-loader"),this.TAG="RangeLoader",this._seekHandler=c,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 H,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(c,f){this._dataSource=c,this._range=f,this._status=I.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 c=this._currentChunkSizeKB*1024,f=this._range.from+this._receivedLength,p=f+c;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(c,f){this._lastTimeLoaded=0;let p=c.url;this._config.reuseRedirectedURL&&(this._currentRedirectedURL!=null?p=this._currentRedirectedURL:c.redirectedURL!=null&&(p=c.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),c.withCredentials&&(T.withCredentials=!0),typeof E.headers=="object"){let G=E.headers;for(let J in G)G.hasOwnProperty(J)&&T.setRequestHeader(J,G[J])}if(typeof this._config.headers=="object"){let G=this._config.headers;for(let J in G)G.hasOwnProperty(J)&&T.setRequestHeader(J,G[J])}T.send()}abort(){this._requestAbort=!0,this._internalAbort(),this._status=I.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(c){let f=c.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=I.kBuffering}else if(this._status=I.kError,this._onError)this._onError(j.HTTP_STATUS_CODE_INVALID,{code:f.status,msg:f.statusText});else throw new me("RangeLoader: Http code invalid, "+f.status+" "+f.statusText)}}_onProgress(c){if(this._status===I.kError)return;if(this._contentLength===null){let p=!1;if(this._waitForTotalLength){this._waitForTotalLength=!1,this._totalLengthReceived=!0,p=!0;let E=c.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=c.loaded-this._lastTimeLoaded;this._lastTimeLoaded=c.loaded,this._speedSampler.addBytes(f)}_normalizeSpeed(c){let f=this._chunkSizeKBList,p=f.length-1,E=0,T=0,G=p;if(c<f[0])return f[0];for(;T<=G;){if(E=T+Math.floor((G-T)/2),E===p||c>=f[E]&&c<f[E+1])return f[E];f[E]<c?T=E+1:G=E-1}}_onLoad(c){if(this._status===I.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 G=this._normalizeSpeed(f);this._currentSpeedNormalized!==G&&(this._currentSpeedNormalized=G,this._currentChunkSizeKB=G)}let p=c.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=I.kComplete,this._onComplete&&this._onComplete(this._range.from,this._range.from+this._receivedLength-1))}_onXhrError(c){this._status=I.kError;let f=0,p=null;if(this._contentLength&&this._receivedLength>0&&this._receivedLength<this._contentLength?(f=j.EARLY_EOF,p={code:-1,msg:"RangeLoader meet Early-Eof"}):(f=j.EXCEPTION,p={code:-1,msg:c.constructor.name+" "+c.type}),this._onError)this._onError(f,p);else throw new me(p.msg)}}var Oe=Z;class He extends ct{static isSupported(){try{return typeof self.WebSocket!="undefined"}catch(c){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(c){try{let f=this._ws=new self.WebSocket(c.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=I.kConnecting}catch(f){this._status=I.kError;let p={code:f.code,msg:f.message};if(this._onError)this._onError(j.EXCEPTION,p);else throw new me(p.msg)}}abort(){let c=this._ws;c&&(c.readyState===0||c.readyState===1)&&(this._requestAbort=!0,c.close()),this._ws=null,this._status=I.kComplete}_onWebSocketOpen(c){this._status=I.kBuffering}_onWebSocketClose(c){if(this._requestAbort===!0){this._requestAbort=!1;return}this._status=I.kComplete,this._onComplete&&this._onComplete(0,this._receivedLength-1)}_onWebSocketMessage(c){if(c.data instanceof ArrayBuffer)this._dispatchArrayBuffer(c.data);else if(c.data instanceof Blob){let f=new FileReader;f.onload=()=>{this._dispatchArrayBuffer(f.result)},f.readAsArrayBuffer(c.data)}else{this._status=I.kError;let f={code:-1,msg:"Unsupported WebSocket message type: "+c.data.constructor.name};if(this._onError)this._onError(j.EXCEPTION,f);else throw new me(f.msg)}}_dispatchArrayBuffer(c){let f=c,p=this._receivedLength;this._receivedLength+=f.byteLength,this._onDataArrival&&this._onDataArrival(f,p,this._receivedLength)}_onWebSocketError(c){this._status=I.kError;let f={code:c.code,msg:c.message};if(this._onError)this._onError(j.EXCEPTION,f);else throw new me(f.msg)}}var Qe=He;class xe{constructor(c){this._zeroStart=c||!1}getConfig(c,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:c,headers:p}}removeURLParameters(c){return c}}var ee=xe;class Q{constructor(c,f){this._startName=c,this._endName=f}getConfig(c,f){let p=c;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(c){let f=c.split("?")[0],p,E=c.indexOf("?");E!==-1&&(p=c.substring(E+1));let T="";if(p!=null&&p.length>0){let G=p.split("&");for(let J=0;J<G.length;J++){let Ye=G[J].split("="),Ve=J>0;Ye[0]!==this._startName&&Ye[0]!==this._endName&&(Ve&&(T+="&"),T+=G[J])}}return T.length===0?f:f+"?"+T}}var ie=Q;class N{constructor(c,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=c,this._isWebSocketURL=/wss?:\/\/(.+?)/.test(c.url),this._refTotalLength=c.filesize?c.filesize:null,this._totalLength=this._refTotalLength,this._fullRequestFlag=!1,this._currentRange=null,this._redirectedURL=null,this._speedNormalized=0,this._speedSampler=new H,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(c){this._extraData=c}get onDataArrival(){return this._onDataArrival}set onDataArrival(c){this._onDataArrival=c}get onSeeked(){return this._onSeeked}set onSeeked(c){this._onSeeked=c}get onError(){return this._onError}set onError(c){this._onError=c}get onComplete(){return this._onComplete}set onComplete(c){this._onComplete=c}get onRedirect(){return this._onRedirect}set onRedirect(c){this._onRedirect=c}get onRecoveredEarlyEof(){return this._onRecoveredEarlyEof}set onRecoveredEarlyEof(c){this._onRecoveredEarlyEof=c}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===Oe?this._loader.currentSpeed:this._speedSampler.lastSecondKBps}get loaderType(){return this._loader.type}_selectSeekHandler(){let c=this._config;if(c.seekType==="range")this._seekHandler=new ee(this._config.rangeLoadZeroStart);else if(c.seekType==="param"){let f=c.seekParamStart||"bstart",p=c.seekParamEnd||"bend";this._seekHandler=new ie(f,p)}else if(c.seekType==="custom"){if(typeof c.customSeekHandler!="function")throw new Pe("Custom seekType specified in config but invalid customSeekHandler!");this._seekHandler=new c.customSeekHandler}else throw new Pe(`Invalid seekType in config: ${c.seekType}`)}_selectLoader(){if(this._config.customLoader!=null)this._loaderClass=this._config.customLoader;else if(this._isWebSocketURL)this._loaderClass=Qe;else if(F.isSupported())this._loaderClass=F;else if(X.isSupported())this._loaderClass=X;else if(Oe.isSupported())this._loaderClass=Oe;else throw new me("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(c){this._currentRange={from:0,to:-1},c&&(this._currentRange.from=c),this._speedSampler.reset(),c||(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 c=this._resumeFrom;this._resumeFrom=0,this._internalSeek(c,!0)}}seek(c){this._paused=!1,this._stashUsed=0,this._stashByteStart=0,this._internalSeek(c,!0)}_internalSeek(c,f){this._loader.isWorking()&&this._loader.abort(),this._flushStashBuffer(f),this._loader.destroy(),this._loader=null;let p={from:c,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(c){if(!c||typeof c!="string"||c.length===0)throw new Pe("Url must be a non-empty string!");this._dataSource.url=c}_expandBuffer(c){let f=this._stashSize;for(;f+1024*1024*1<c;)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(c){let f=this._speedNormalizeList,p=f.length-1,E=0,T=0,G=p;if(c<f[0])return f[0];for(;T<=G;){if(E=T+Math.floor((G-T)/2),E===p||c>=f[E]&&c<f[E+1])return f[E];f[E]<c?T=E+1:G=E-1}}_adjustStashSize(c){let f=0;this._config.isLive||c<512?f=c:c>=512&&c<=1024?f=Math.floor(c*1.5):f=c*2,f>8192&&(f=8192);let p=f*1024+1024*1024*1;this._bufferSize<p&&this._expandBuffer(p),this._stashSize=f*1024}_dispatchChunks(c,f){return this._currentRange.to=f+c.byteLength-1,this._onDataArrival(c,f)}_onURLRedirect(c){this._redirectedURL=c,this._onRedirect&&this._onRedirect(c)}_onContentLengthKnown(c){c&&this._fullRequestFlag&&(this._totalLength=c,this._fullRequestFlag=!1)}_onLoaderChunkArrival(c,f,p){if(!this._onDataArrival)throw new Ae("IOController: No existing consumer (onDataArrival) callback!");if(this._paused)return;this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,this._onRecoveredEarlyEof&&this._onRecoveredEarlyEof()),this._speedSampler.addBytes(c.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+c.byteLength<=this._stashSize)new Uint8Array(this._stashBuffer,0,this._stashSize).set(new Uint8Array(c),this._stashUsed),this._stashUsed+=c.byteLength;else{let T=new Uint8Array(this._stashBuffer,0,this._bufferSize);if(this._stashUsed>0){let G=this._stashBuffer.slice(0,this._stashUsed),J=this._dispatchChunks(G,this._stashByteStart);if(J<G.byteLength){if(J>0){let Ye=new Uint8Array(G,J);T.set(Ye,0),this._stashUsed=Ye.byteLength,this._stashByteStart+=J}}else this._stashUsed=0,this._stashByteStart+=J;this._stashUsed+c.byteLength>this._bufferSize&&(this._expandBuffer(this._stashUsed+c.byteLength),T=new Uint8Array(this._stashBuffer,0,this._bufferSize)),T.set(new Uint8Array(c),this._stashUsed),this._stashUsed+=c.byteLength}else{let G=this._dispatchChunks(c,f);if(G<c.byteLength){let J=c.byteLength-G;J>this._bufferSize&&(this._expandBuffer(J),T=new Uint8Array(this._stashBuffer,0,this._bufferSize)),T.set(new Uint8Array(c,G),0),this._stashUsed+=J,this._stashByteStart=f+G}}}else if(this._stashUsed===0){let T=this._dispatchChunks(c,f);if(T<c.byteLength){let G=c.byteLength-T;G>this._bufferSize&&this._expandBuffer(G),new Uint8Array(this._stashBuffer,0,this._bufferSize).set(new Uint8Array(c,T),0),this._stashUsed+=G,this._stashByteStart=f+T}}else{this._stashUsed+c.byteLength>this._bufferSize&&this._expandBuffer(this._stashUsed+c.byteLength);let T=new Uint8Array(this._stashBuffer,0,this._bufferSize);T.set(new Uint8Array(c),this._stashUsed),this._stashUsed+=c.byteLength;let G=this._dispatchChunks(this._stashBuffer.slice(0,this._stashUsed),this._stashByteStart);if(G<this._stashUsed&&G>0){let J=new Uint8Array(this._stashBuffer,G);T.set(J,0)}this._stashUsed-=G,this._stashByteStart+=G}}_flushStashBuffer(c){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(c)m.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),G=new Uint8Array(f,p);T.set(G,0),this._stashUsed=G.byteLength,this._stashByteStart+=p}return 0}return this._stashUsed=0,this._stashByteStart=0,E}return 0}_onLoaderComplete(c,f){this._flushStashBuffer(!0),this._onComplete&&this._onComplete(this._extraData)}_onLoaderError(c,f){switch(m.e(this.TAG,`Loader error, code = ${f.code}, msg = ${f.msg}`),this._flushStashBuffer(!1),this._isEarlyEofReconnecting&&(this._isEarlyEofReconnecting=!1,c=j.UNRECOVERABLE_EARLY_EOF),c){case j.EARLY_EOF:{if(!this._config.isLive&&this._totalLength){let p=this._currentRange.to+1;p<this._totalLength&&(m.w(this.TAG,"Connection lost, trying reconnect..."),this._isEarlyEofReconnecting=!0,this._internalSeek(p,!1));return}c=j.UNRECOVERABLE_EARLY_EOF;break}case j.UNRECOVERABLE_EARLY_EOF:case j.CONNECTING_TIMEOUT:case j.HTTP_STATUS_CODE_INVALID:case j.EXCEPTION:break}if(this._onError)this._onError(c,f);else throw new me("IOException: "+f.msg)}}var we=N;const je={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 Ee(){return Object.assign({},je)}class _e{static supportMSEH264Playback(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}static supportNetworkStreamIO(){let c=new we({},Ee()),f=c.loaderType;return c.destroy(),f=="fetch-stream-loader"||f=="xhr-moz-chunked-loader"}static getNetworkLoaderTypeName(){let c=new we({},Ee()),f=c.loaderType;return c.destroy(),f}static supportNativeMediaPlayback(c){_e.videoElement==null&&(_e.videoElement=window.document.createElement("video"));let f=_e.videoElement.canPlayType(c);return f==="probably"||f=="maybe"}static getFeatureList(){let c={mseFlvPlayback:!1,mseLiveFlvPlayback:!1,networkStreamIO:!1,networkLoaderName:"",nativeMP4H264Playback:!1,nativeWebmVP8Playback:!1,nativeWebmVP9Playback:!1};return c.mseFlvPlayback=_e.supportMSEH264Playback(),c.networkStreamIO=_e.supportNetworkStreamIO(),c.networkLoaderName=_e.getNetworkLoaderTypeName(),c.mseLiveFlvPlayback=c.mseFlvPlayback&&c.networkStreamIO,c.nativeMP4H264Playback=_e.supportNativeMediaPlayback('video/mp4; codecs="avc1.42001E, mp4a.40.2"'),c.nativeWebmVP8Playback=_e.supportNativeMediaPlayback('video/webm; codecs="vp8.0, vorbis"'),c.nativeWebmVP9Playback=_e.supportNativeMediaPlayback('video/webm; codecs="vp9"'),c}}var Me=_e,Fe={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 Ze{static get forceGlobalTag(){return m.FORCE_GLOBAL_TAG}static set forceGlobalTag(c){m.FORCE_GLOBAL_TAG=c,Ze._notifyChange()}static get globalTag(){return m.GLOBAL_TAG}static set globalTag(c){m.GLOBAL_TAG=c,Ze._notifyChange()}static get enableAll(){return m.ENABLE_VERBOSE&&m.ENABLE_DEBUG&&m.ENABLE_INFO&&m.ENABLE_WARN&&m.ENABLE_ERROR}static set enableAll(c){m.ENABLE_VERBOSE=c,m.ENABLE_DEBUG=c,m.ENABLE_INFO=c,m.ENABLE_WARN=c,m.ENABLE_ERROR=c,Ze._notifyChange()}static get enableDebug(){return m.ENABLE_DEBUG}static set enableDebug(c){m.ENABLE_DEBUG=c,Ze._notifyChange()}static get enableVerbose(){return m.ENABLE_VERBOSE}static set enableVerbose(c){m.ENABLE_VERBOSE=c,Ze._notifyChange()}static get enableInfo(){return m.ENABLE_INFO}static set enableInfo(c){m.ENABLE_INFO=c,Ze._notifyChange()}static get enableWarn(){return m.ENABLE_WARN}static set enableWarn(c){m.ENABLE_WARN=c,Ze._notifyChange()}static get enableError(){return m.ENABLE_ERROR}static set enableError(c){m.ENABLE_ERROR=c,Ze._notifyChange()}static getConfig(){return{globalTag:m.GLOBAL_TAG,forceGlobalTag:m.FORCE_GLOBAL_TAG,enableVerbose:m.ENABLE_VERBOSE,enableDebug:m.ENABLE_DEBUG,enableInfo:m.ENABLE_INFO,enableWarn:m.ENABLE_WARN,enableError:m.ENABLE_ERROR,enableCallback:m.ENABLE_CALLBACK}}static applyConfig(c){m.GLOBAL_TAG=c.globalTag,m.FORCE_GLOBAL_TAG=c.forceGlobalTag,m.ENABLE_VERBOSE=c.enableVerbose,m.ENABLE_DEBUG=c.enableDebug,m.ENABLE_INFO=c.enableInfo,m.ENABLE_WARN=c.enableWarn,m.ENABLE_ERROR=c.enableError,m.ENABLE_CALLBACK=c.enableCallback}static _notifyChange(){let c=Ze.emitter;if(c.listenerCount("change")>0){let f=Ze.getConfig();c.emit("change",f)}}static registerListener(c){Ze.emitter.addListener("change",c)}static removeListener(c){Ze.emitter.removeListener("change",c)}static addLogListener(c){m.emitter.addListener("log",c),m.emitter.listenerCount("log")>0&&(m.ENABLE_CALLBACK=!0,Ze._notifyChange())}static removeLogListener(c){m.emitter.removeListener("log",c),m.emitter.listenerCount("log")===0&&(m.ENABLE_CALLBACK=!1,Ze._notifyChange())}}Ze.emitter=new(z());var ot=Ze;class mt{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 c=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&&c&&f}isSeekable(){return this.hasKeyframesIndex===!0}getNearestKeyframe(c){if(this.keyframesIndex==null)return null;let f=this.keyframesIndex,p=this._search(f.times,c);return{index:p,milliseconds:f.times[p],fileposition:f.filepositions[p]}}_search(c,f){let p=0,E=c.length-1,T=0,G=0,J=E;for(f<c[0]&&(p=0,G=J+1);G<=J;)if(T=G+Math.floor((J-G)/2),T===E||f>=c[T]&&f<c[T+1]){p=T;break}else c[T]<f?G=T+1:J=T-1;return p}}var Et=mt;function wt(Ge,c,f){let p=Ge;if(c+f<p.length){for(;f--;)if((p[++c]&192)!==128)return!1;return!0}else return!1}function Gt(Ge){let c=[],f=Ge,p=0,E=Ge.length;for(;p<E;){if(f[p]<128){c.push(String.fromCharCode(f[p])),++p;continue}else if(!(f[p]<192)){if(f[p]<224){if(wt(f,p,1)){let T=(f[p]&31)<<6|f[p+1]&63;if(T>=128){c.push(String.fromCharCode(T&65535)),p+=2;continue}}}else if(f[p]<240){if(wt(f,p,2)){let T=(f[p]&15)<<12|(f[p+1]&63)<<6|f[p+2]&63;if(T>=2048&&(T&63488)!==55296){c.push(String.fromCharCode(T&65535)),p+=3;continue}}}else if(f[p]<248&&wt(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,c.push(String.fromCharCode(T>>>10|55296)),c.push(String.fromCharCode(T&1023|56320)),p+=4;continue}}}c.push("\uFFFD"),++p}return c.join("")}var gt=Gt;let bt=function(){let Ge=new ArrayBuffer(2);return new DataView(Ge).setInt16(0,256,!0),new Int16Array(Ge)[0]===256}();class $e{static parseScriptData(c,f,p){let E={};try{let T=$e.parseValue(c,f,p),G=$e.parseValue(c,f+T.size,p-T.size);E[T.data]=G.data}catch(T){m.e("AMF",T.toString())}return E}static parseObject(c,f,p){if(p<3)throw new Ae("Data not enough when parse ScriptDataObject");let E=$e.parseString(c,f,p),T=$e.parseValue(c,f+E.size,p-E.size),G=T.objectEnd;return{data:{name:E.data,value:T.data},size:E.size+T.size,objectEnd:G}}static parseVariable(c,f,p){return $e.parseObject(c,f,p)}static parseString(c,f,p){if(p<2)throw new Ae("Data not enough when parse String");let T=new DataView(c,f,p).getUint16(0,!bt),G;return T>0?G=gt(new Uint8Array(c,f+2,T)):G="",{data:G,size:2+T}}static parseLongString(c,f,p){if(p<4)throw new Ae("Data not enough when parse LongString");let T=new DataView(c,f,p).getUint32(0,!bt),G;return T>0?G=gt(new Uint8Array(c,f+4,T)):G="",{data:G,size:4+T}}static parseDate(c,f,p){if(p<10)throw new Ae("Data size invalid when parse Date");let E=new DataView(c,f,p),T=E.getFloat64(0,!bt),G=E.getInt16(8,!bt);return T+=G*60*1e3,{data:new Date(T),size:10}}static parseValue(c,f,p){if(p<1)throw new Ae("Data not enough when parse Value");let E=new DataView(c,f,p),T=1,G=E.getUint8(0),J,Ye=!1;try{switch(G){case 0:J=E.getFloat64(1,!bt),T+=8;break;case 1:{J=!!E.getUint8(1),T+=1;break}case 2:{let Ve=$e.parseString(c,f+1,p-1);J=Ve.data,T+=Ve.size;break}case 3:{J={};let Ve=0;for((E.getUint32(p-4,!bt)&16777215)===9&&(Ve=3);T<p-4;){let ht=$e.parseObject(c,f+T,p-T-Ve);if(ht.objectEnd)break;J[ht.data.name]=ht.data.value,T+=ht.size}T<=p-3&&(E.getUint32(T-1,!bt)&16777215)===9&&(T+=3);break}case 8:{J={},T+=4;let Ve=0;for((E.getUint32(p-4,!bt)&16777215)===9&&(Ve=3);T<p-8;){let ht=$e.parseVariable(c,f+T,p-T-Ve);if(ht.objectEnd)break;J[ht.data.name]=ht.data.value,T+=ht.size}T<=p-3&&(E.getUint32(T-1,!bt)&16777215)===9&&(T+=3);break}case 9:J=void 0,T=1,Ye=!0;break;case 10:{J=[];let Ve=E.getUint32(1,!bt);T+=4;for(let ht=0;ht<Ve;ht++){let Rt=$e.parseValue(c,f+T,p-T);J.push(Rt.data),T+=Rt.size}break}case 11:{let Ve=$e.parseDate(c,f+1,p-1);J=Ve.data,T+=Ve.size;break}case 12:{let Ve=$e.parseString(c,f+1,p-1);J=Ve.data,T+=Ve.size;break}default:T=p,m.w("AMF","Unsupported AMF value type "+G)}}catch(Ve){m.e("AMF",Ve.toString())}return{data:J,size:T,objectEnd:Ye}}}var Vt=$e;class Zt{constructor(c){this.TAG="ExpGolomb",this._buffer=c,this._buffer_index=0,this._total_bytes=c.byteLength,this._total_bits=c.byteLength*8,this._current_word=0,this._current_word_bits_left=0}destroy(){this._buffer=null}_fillCurrentWord(){let c=this._total_bytes-this._buffer_index;if(c<=0)throw new Ae("ExpGolomb: _fillCurrentWord() but no bytes available");let f=Math.min(4,c),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(c){if(c>32)throw new Pe("ExpGolomb: readBits() bits exceeded max 32bits!");if(c<=this._current_word_bits_left){let G=this._current_word>>>32-c;return this._current_word<<=c,this._current_word_bits_left-=c,G}let f=this._current_word_bits_left?this._current_word:0;f=f>>>32-this._current_word_bits_left;let p=c-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 c;for(c=0;c<this._current_word_bits_left;c++)if(this._current_word&2147483648>>>c)return this._current_word<<=c,this._current_word_bits_left-=c,c;return this._fillCurrentWord(),c+this._skipLeadingZero()}readUEG(){let c=this._skipLeadingZero();return this.readBits(c+1)-1}readSEG(){let c=this.readUEG();return c&1?c+1>>>1:-1*(c>>>1)}}var Ht=Zt;class k{static _ebsp2rbsp(c){let f=c,p=f.byteLength,E=new Uint8Array(p),T=0;for(let G=0;G<p;G++)G>=2&&f[G]===3&&f[G-1]===0&&f[G-2]===0||(E[T]=f[G],T++);return new Uint8Array(E.buffer,0,T)}static parseSPS(c){let f=k._ebsp2rbsp(c),p=new Ht(f);p.readByte();let E=p.readByte();p.readByte();let T=p.readByte();p.readUEG();let G=k.getProfileString(E),J=k.getLevelString(T),Ye=1,Ve=420,ht=[0,420,422,444],Rt=8;if((E===100||E===110||E===122||E===244||E===44||E===83||E===86||E===118||E===128||E===138||E===144)&&(Ye=p.readUEG(),Ye===3&&p.readBits(1),Ye<=3&&(Ve=ht[Ye]),Rt=p.readUEG()+8,p.readUEG(),p.readBits(1),p.readBool())){let jt=Ye!==3?8:12;for(let kt=0;kt<jt;kt++)p.readBool()&&(kt<6?k._skipScalingList(p,16):k._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 jt=p.readUEG();for(let kt=0;kt<jt;kt++)p.readSEG()}let Ne=p.readUEG();p.readBits(1);let Ct=p.readUEG(),at=p.readUEG(),Ke=p.readBits(1);Ke===0&&p.readBits(1),p.readBits(1);let et=0,vt=0,Lt=0,Ut=0;p.readBool()&&(et=p.readUEG(),vt=p.readUEG(),Lt=p.readUEG(),Ut=p.readUEG());let ki=1,rt=1,lt=0,q=!0,se=0,pe=0;if(p.readBool()){if(p.readBool()){let jt=p.readByte(),kt=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],ai=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];jt>0&&jt<16?(ki=kt[jt-1],rt=ai[jt-1]):jt===255&&(ki=p.readByte()<<8|p.readByte(),rt=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 jt=p.readBits(32),kt=p.readBits(32);q=p.readBool(),se=kt,pe=jt*2,lt=se/pe}}let Se=1;(ki!==1||rt!==1)&&(Se=ki/rt);let Ue=0,ke=0;if(Ye===0)Ue=1,ke=2-Ke;else{let jt=Ye===3?1:2,kt=Ye===1?2:1;Ue=jt,ke=kt*(2-Ke)}let xt=(Ct+1)*16,Mt=(2-Ke)*((at+1)*16);xt-=(et+vt)*Ue,Mt-=(Lt+Ut)*ke;let pt=Math.ceil(xt*Se);return p.destroy(),p=null,{profile_string:G,level_string:J,bit_depth:Rt,ref_frames:Ne,chroma_format:Ve,chroma_format_string:k.getChromaFormatString(Ve),frame_rate:{fixed:q,fps:lt,fps_den:pe,fps_num:se},sar_ratio:{width:ki,height:rt},codec_size:{width:xt,height:Mt},present_size:{width:pt,height:Mt}}}static _skipScalingList(c,f){let p=8,E=8,T=0;for(let G=0;G<f;G++)E!==0&&(T=c.readSEG(),E=(p+T+256)%256),p=E===0?p:E}static getProfileString(c){switch(c){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(c){return(c/10).toFixed(1)}static getChromaFormatString(c){switch(c){case 420:return"4:2:0";case 422:return"4:2:2";case 444:return"4:4:4";default:return"Unknown"}}}var C=k,D={OK:"OK",FORMAT_ERROR:"FormatError",FORMAT_UNSUPPORTED:"FormatUnsupported",CODEC_UNSUPPORTED:"CodecUnsupported"};function $(Ge){return Ge>>>8&255|(Ge&255)<<8}function ae(Ge){return(Ge&4278190080)>>>24|(Ge&16711680)>>>8|(Ge&65280)<<8|(Ge&255)<<24}function w(Ge,c){return Ge[c]<<24|Ge[c+1]<<16|Ge[c+2]<<8|Ge[c+3]}class V{constructor(c,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=c.dataOffset,this._firstParse=!0,this._dispatch=!1,this._hasAudio=c.hasAudioTrack,this._hasVideo=c.hasVideoTrack,this._hasAudioFlagOverrided=!1,this._hasVideoFlagOverrided=!1,this._audioInitialMetadataDispatched=!1,this._videoInitialMetadataDispatched=!1,this._mediaInfo=new Et,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(c){let f=new Uint8Array(c),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,G=w(f,5);return G<9?p:{match:!0,consumed:G,dataOffset:G,hasAudioTrack:E,hasVideoTrack:T}}bindDataSource(c){return c.onDataArrival=this.parseChunks.bind(this),this}get onTrackMetadata(){return this._onTrackMetadata}set onTrackMetadata(c){this._onTrackMetadata=c}get onMediaInfo(){return this._onMediaInfo}set onMediaInfo(c){this._onMediaInfo=c}get onMetaDataArrived(){return this._onMetaDataArrived}set onMetaDataArrived(c){this._onMetaDataArrived=c}get onScriptDataArrived(){return this._onScriptDataArrived}set onScriptDataArrived(c){this._onScriptDataArrived=c}get onError(){return this._onError}set onError(c){this._onError=c}get onDataAvailable(){return this._onDataAvailable}set onDataAvailable(c){this._onDataAvailable=c}get timestampBase(){return this._timestampBase}set timestampBase(c){this._timestampBase=c}get overridedDuration(){return this._duration}set overridedDuration(c){this._durationOverrided=!0,this._duration=c,this._mediaInfo.duration=c}set overridedHasAudio(c){this._hasAudioFlagOverrided=!0,this._hasAudio=c,this._mediaInfo.hasAudio=c}set overridedHasVideo(c){this._hasVideoFlagOverrided=!0,this._hasVideo=c,this._mediaInfo.hasVideo=c}resetMediaInfo(){this._mediaInfo=new Et}_isInitialMetadataDispatched(){return this._hasAudio&&this._hasVideo?this._audioInitialMetadataDispatched&&this._videoInitialMetadataDispatched:this._hasAudio&&!this._hasVideo?this._audioInitialMetadataDispatched:!this._hasAudio&&this._hasVideo?this._videoInitialMetadataDispatched:!1}parseChunks(c,f){if(!this._onError||!this._onMediaInfo||!this._onTrackMetadata||!this._onDataAvailable)throw new Ae("Flv: onError & onMediaInfo & onTrackMetadata & onDataAvailable callback must be specified");let p=0,E=this._littleEndian;if(f===0)if(c.byteLength>13)p=V.probe(c).dataOffset;else return 0;for(this._firstParse&&(this._firstParse=!1,f+p!==this._dataOffset&&m.w(this.TAG,"First time parsing but chunk byteStart invalid!"),new DataView(c,p).getUint32(0,!E)!==0&&m.w(this.TAG,"PrevTagSize0 !== 0 !!!"),p+=4);p<c.byteLength;){this._dispatch=!0;let T=new DataView(c,p);if(p+11+4>c.byteLength)break;let G=T.getUint8(0),J=T.getUint32(0,!E)&16777215;if(p+11+J+4>c.byteLength)break;if(G!==8&&G!==9&&G!==18){m.w(this.TAG,`Unsupported tag type ${G}, skipped`),p+=11+J+4;continue}let Ye=T.getUint8(4),Ve=T.getUint8(5),ht=T.getUint8(6),Rt=T.getUint8(7),Pt=ht|Ve<<8|Ye<<16|Rt<<24;(T.getUint32(7,!E)&16777215)!==0&&m.w(this.TAG,"Meet tag which has StreamID != 0!");let Ct=p+11;switch(G){case 8:this._parseAudioData(c,Ct,J,Pt);break;case 9:this._parseVideoData(c,Ct,J,Pt,f+p);break;case 18:this._parseScriptData(c,Ct,J);break}let at=T.getUint32(11+J,!E);at!==11+J&&m.w(this.TAG,`Invalid PrevTagSize ${at}`),p+=11+J+4}return this._isInitialMetadataDispatched()&&this._dispatch&&(this._audioTrack.length||this._videoTrack.length)&&this._onDataAvailable(this._audioTrack,this._videoTrack),p}_parseScriptData(c,f,p){let E=Vt.parseScriptData(c,f,p);if(E.hasOwnProperty("onMetaData")){if(E.onMetaData==null||typeof E.onMetaData!="object"){m.w(this.TAG,"Invalid onMetaData structure!");return}this._metadata&&m.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 G=Math.floor(T.duration*this._timescale);this._duration=G,this._mediaInfo.duration=G}}else this._mediaInfo.duration=0;if(typeof T.framerate=="number"){let G=Math.floor(T.framerate*1e3);if(G>0){let J=G/1e3;this._referenceFrameRate.fixed=!0,this._referenceFrameRate.fps=J,this._referenceFrameRate.fps_num=G,this._referenceFrameRate.fps_den=1e3,this._mediaInfo.fps=J}}if(typeof T.keyframes=="object"){this._mediaInfo.hasKeyframesIndex=!0;let G=T.keyframes;this._mediaInfo.keyframesIndex=this._parseKeyframesIndex(G),T.keyframes=null}else this._mediaInfo.hasKeyframesIndex=!1;this._dispatch=!1,this._mediaInfo.metadata=T,m.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(c){let f=[],p=[];for(let E=1;E<c.times.length;E++){let T=this._timestampBase+Math.floor(c.times[E]*1e3);f.push(T),p.push(c.filepositions[E])}return{times:f,filepositions:p}}_parseAudioData(c,f,p,E){if(p<=1){m.w(this.TAG,"Flv: Invalid audio packet, missing SoundData payload!");return}if(this._hasAudioFlagOverrided===!0&&this._hasAudio===!1)return;let T=this._littleEndian,J=new DataView(c,f,p).getUint8(0),Ye=J>>>4;if(Ye!==2&&Ye!==10){this._onError(D.CODEC_UNSUPPORTED,"Flv: Unsupported audio codec idx: "+Ye);return}let Ve=0,ht=(J&12)>>>2;if(ht>=0&&ht<=4)Ve=this._flvSoundRateTable[ht];else{this._onError(D.FORMAT_ERROR,"Flv: Invalid audio sample rate idx: "+ht);return}let Rt=(J&2)>>>1,Pt=J&1,Ne=this._audioMetadata,Ct=this._audioTrack;if(Ne||(this._hasAudio===!1&&this._hasAudioFlagOverrided===!1&&(this._hasAudio=!0,this._mediaInfo.hasAudio=!0),Ne=this._audioMetadata={},Ne.type="audio",Ne.id=Ct.id,Ne.timescale=this._timescale,Ne.duration=this._duration,Ne.audioSampleRate=Ve,Ne.channelCount=Pt===0?1:2),Ye===10){let at=this._parseAACAudioData(c,f+1,p-1);if(at==null)return;if(at.packetType===0){Ne.config&&m.w(this.TAG,"Found another AudioSpecificConfig!");let Ke=at.data;Ne.audioSampleRate=Ke.samplingRate,Ne.channelCount=Ke.channelCount,Ne.codec=Ke.codec,Ne.originalCodec=Ke.originalCodec,Ne.config=Ke.config,Ne.refSampleDuration=1024/Ne.audioSampleRate*Ne.timescale,m.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",Ne);let et=this._mediaInfo;et.audioCodec=Ne.originalCodec,et.audioSampleRate=Ne.audioSampleRate,et.audioChannelCount=Ne.channelCount,et.hasVideo?et.videoCodec!=null&&(et.mimeType='video/x-flv; codecs="'+et.videoCodec+","+et.audioCodec+'"'):et.mimeType='video/x-flv; codecs="'+et.audioCodec+'"',et.isComplete()&&this._onMediaInfo(et)}else if(at.packetType===1){let Ke=this._timestampBase+E,et={unit:at.data,length:at.data.byteLength,dts:Ke,pts:Ke};Ct.samples.push(et),Ct.length+=at.data.length}else m.e(this.TAG,`Flv: Unsupported AAC data type ${at.packetType}`)}else if(Ye===2){if(!Ne.codec){let vt=this._parseMP3AudioData(c,f+1,p-1,!0);if(vt==null)return;Ne.audioSampleRate=vt.samplingRate,Ne.channelCount=vt.channelCount,Ne.codec=vt.codec,Ne.originalCodec=vt.originalCodec,Ne.refSampleDuration=1152/Ne.audioSampleRate*Ne.timescale,m.v(this.TAG,"Parsed MPEG Audio Frame Header"),this._audioInitialMetadataDispatched=!0,this._onTrackMetadata("audio",Ne);let Lt=this._mediaInfo;Lt.audioCodec=Ne.codec,Lt.audioSampleRate=Ne.audioSampleRate,Lt.audioChannelCount=Ne.channelCount,Lt.audioDataRate=vt.bitRate,Lt.hasVideo?Lt.videoCodec!=null&&(Lt.mimeType='video/x-flv; codecs="'+Lt.videoCodec+","+Lt.audioCodec+'"'):Lt.mimeType='video/x-flv; codecs="'+Lt.audioCodec+'"',Lt.isComplete()&&this._onMediaInfo(Lt)}let at=this._parseMP3AudioData(c,f+1,p-1,!1);if(at==null)return;let Ke=this._timestampBase+E,et={unit:at,length:at.byteLength,dts:Ke,pts:Ke};Ct.samples.push(et),Ct.length+=at.length}}_parseAACAudioData(c,f,p){if(p<=1){m.w(this.TAG,"Flv: Invalid AAC packet, missing AACPacketType or/and Data!");return}let E={},T=new Uint8Array(c,f,p);return E.packetType=T[0],T[0]===0?E.data=this._parseAACAudioSpecificConfig(c,f+1,p-1):E.data=T.subarray(1),E}_parseAACAudioSpecificConfig(c,f,p){let E=new Uint8Array(c,f,p),T=null,G=0,J=0,Ye=null,Ve=0,ht=null;if(G=J=E[0]>>>3,Ve=(E[0]&7)<<1|E[1]>>>7,Ve<0||Ve>=this._mpegSamplingRates.length){this._onError(D.FORMAT_ERROR,"Flv: AAC invalid sampling frequency index!");return}let Rt=this._mpegSamplingRates[Ve],Pt=(E[1]&120)>>>3;if(Pt<0||Pt>=8){this._onError(D.FORMAT_ERROR,"Flv: AAC invalid channel configuration");return}G===5&&(ht=(E[1]&7)<<1|E[2]>>>7,Ye=(E[2]&124)>>>2);let Ne=self.navigator.userAgent.toLowerCase();return Ne.indexOf("firefox")!==-1?Ve>=6?(G=5,T=new Array(4),ht=Ve-3):(G=2,T=new Array(2),ht=Ve):Ne.indexOf("android")!==-1?(G=2,T=new Array(2),ht=Ve):(G=5,ht=Ve,T=new Array(4),Ve>=6?ht=Ve-3:Pt===1&&(G=2,T=new Array(2),ht=Ve)),T[0]=G<<3,T[0]|=(Ve&15)>>>1,T[1]=(Ve&15)<<7,T[1]|=(Pt&15)<<3,G===5&&(T[1]|=(ht&15)>>>1,T[2]=(ht&1)<<7,T[2]|=8,T[3]=0),{config:T,samplingRate:Rt,channelCount:Pt,codec:"mp4a.40."+G,originalCodec:"mp4a.40."+J}}_parseMP3AudioData(c,f,p,E){if(p<4){m.w(this.TAG,"Flv: Invalid MP3 packet, header missing!");return}let T=this._littleEndian,G=new Uint8Array(c,f,p),J=null;if(E){if(G[0]!==255)return;let Ye=G[1]>>>3&3,Ve=(G[1]&6)>>1,ht=(G[2]&240)>>>4,Rt=(G[2]&12)>>>2,Ne=(G[3]>>>6&3)!==3?2:1,Ct=0,at=0,Ke=34,et="mp3";switch(Ye){case 0:Ct=this._mpegAudioV25SampleRateTable[Rt];break;case 2:Ct=this._mpegAudioV20SampleRateTable[Rt];break;case 3:Ct=this._mpegAudioV10SampleRateTable[Rt];break}switch(Ve){case 1:Ke=34,ht<this._mpegAudioL3BitRateTable.length&&(at=this._mpegAudioL3BitRateTable[ht]);break;case 2:Ke=33,ht<this._mpegAudioL2BitRateTable.length&&(at=this._mpegAudioL2BitRateTable[ht]);break;case 3:Ke=32,ht<this._mpegAudioL1BitRateTable.length&&(at=this._mpegAudioL1BitRateTable[ht]);break}J={bitRate:at,samplingRate:Ct,channelCount:Ne,codec:et,originalCodec:et}}else J=G;return J}_parseVideoData(c,f,p,E,T){if(p<=1){m.w(this.TAG,"Flv: Invalid video packet, missing VideoData payload!");return}if(this._hasVideoFlagOverrided===!0&&this._hasVideo===!1)return;let G=new Uint8Array(c,f,p)[0],J=(G&240)>>>4,Ye=G&15;if(Ye!==7){this._onError(D.CODEC_UNSUPPORTED,`Flv: Unsupported codec in video frame: ${Ye}`);return}this._parseAVCVideoPacket(c,f+1,p-1,E,T,J)}_parseAVCVideoPacket(c,f,p,E,T,G){if(p<4){m.w(this.TAG,"Flv: Invalid AVC packet, missing AVCPacketType or/and CompositionTime");return}let J=this._littleEndian,Ye=new DataView(c,f,p),Ve=Ye.getUint8(0),Rt=(Ye.getUint32(0,!J)&16777215)<<8>>8;if(Ve===0)this._parseAVCDecoderConfigurationRecord(c,f+4,p-4);else if(Ve===1)this._parseAVCVideoData(c,f+4,p-4,E,T,G,Rt);else if(Ve!==2){this._onError(D.FORMAT_ERROR,`Flv: Invalid video packet type ${Ve}`);return}}_parseAVCDecoderConfigurationRecord(c,f,p){if(p<7){m.w(this.TAG,"Flv: Invalid AVCDecoderConfigurationRecord, lack of data!");return}let E=this._videoMetadata,T=this._videoTrack,G=this._littleEndian,J=new DataView(c,f,p);E?typeof E.avcc!="undefined"&&m.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 Ye=J.getUint8(0),Ve=J.getUint8(1),ht=J.getUint8(2),Rt=J.getUint8(3);if(Ye!==1||Ve===0){this._onError(D.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord");return}if(this._naluLengthSize=(J.getUint8(4)&3)+1,this._naluLengthSize!==3&&this._naluLengthSize!==4){this._onError(D.FORMAT_ERROR,`Flv: Strange NaluLengthSizeMinusOne: ${this._naluLengthSize-1}`);return}let Pt=J.getUint8(5)&31;if(Pt===0){this._onError(D.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No SPS");return}else Pt>1&&m.w(this.TAG,`Flv: Strange AVCDecoderConfigurationRecord: SPS Count = ${Pt}`);let Ne=6;for(let at=0;at<Pt;at++){let Ke=J.getUint16(Ne,!G);if(Ne+=2,Ke===0)continue;let et=new Uint8Array(c,f+Ne,Ke);Ne+=Ke;let vt=C.parseSPS(et);if(at!==0)continue;E.codecWidth=vt.codec_size.width,E.codecHeight=vt.codec_size.height,E.presentWidth=vt.present_size.width,E.presentHeight=vt.present_size.height,E.profile=vt.profile_string,E.level=vt.level_string,E.bitDepth=vt.bit_depth,E.chromaFormat=vt.chroma_format,E.sarRatio=vt.sar_ratio,E.frameRate=vt.frame_rate,(vt.frame_rate.fixed===!1||vt.frame_rate.fps_num===0||vt.frame_rate.fps_den===0)&&(E.frameRate=this._referenceFrameRate);let Lt=E.frameRate.fps_den,Ut=E.frameRate.fps_num;E.refSampleDuration=E.timescale*(Lt/Ut);let qt=et.subarray(1,4),ki="avc1.";for(let lt=0;lt<3;lt++){let q=qt[lt].toString(16);q.length<2&&(q="0"+q),ki+=q}E.codec=ki;let rt=this._mediaInfo;rt.width=E.codecWidth,rt.height=E.codecHeight,rt.fps=E.frameRate.fps,rt.profile=E.profile,rt.level=E.level,rt.refFrames=vt.ref_frames,rt.chromaFormat=vt.chroma_format_string,rt.sarNum=E.sarRatio.width,rt.sarDen=E.sarRatio.height,rt.videoCodec=ki,rt.hasAudio?rt.audioCodec!=null&&(rt.mimeType='video/x-flv; codecs="'+rt.videoCodec+","+rt.audioCodec+'"'):rt.mimeType='video/x-flv; codecs="'+rt.videoCodec+'"',rt.isComplete()&&this._onMediaInfo(rt)}let Ct=J.getUint8(Ne);if(Ct===0){this._onError(D.FORMAT_ERROR,"Flv: Invalid AVCDecoderConfigurationRecord: No PPS");return}else Ct>1&&m.w(this.TAG,`Flv: Strange AVCDecoderConfigurationRecord: PPS Count = ${Ct}`);Ne++;for(let at=0;at<Ct;at++){let Ke=J.getUint16(Ne,!G);Ne+=2,Ke!==0&&(Ne+=Ke)}E.avcc=new Uint8Array(p),E.avcc.set(new Uint8Array(c,f,p),0),m.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(c,f,p,E,T,G,J){let Ye=this._littleEndian,Ve=new DataView(c,f,p),ht=[],Rt=0,Pt=0;const Ne=this._naluLengthSize;let Ct=this._timestampBase+E,at=G===1;for(;Pt<p;){if(Pt+4>=p){m.w(this.TAG,`Malformed Nalu near timestamp ${Ct}, offset = ${Pt}, dataSize = ${p}`);break}let Ke=Ve.getUint32(Pt,!Ye);if(Ne===3&&(Ke>>>=8),Ke>p-Ne){m.w(this.TAG,`Malformed Nalus near timestamp ${Ct}, NaluSize > DataSize!`);return}let et=Ve.getUint8(Pt+Ne)&31;et===5&&(at=!0);let vt=new Uint8Array(c,f+Pt,Ne+Ke),Lt={type:et,data:vt};ht.push(Lt),Rt+=vt.byteLength,Pt+=Ne+Ke}if(ht.length){let Ke=this._videoTrack,et={units:ht,length:Rt,isKeyframe:at,dts:Ct,cts:J,pts:Ct+J};at&&(et.fileposition=T),Ke.samples.push(et),Ke.length+=Rt}}}var W=V;class O{static init(){O.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 O.types)O.types.hasOwnProperty(f)&&(O.types[f]=[f.charCodeAt(0),f.charCodeAt(1),f.charCodeAt(2),f.charCodeAt(3)]);let c=O.constants={};c.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),c.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),c.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),c.STSC=c.STCO=c.STTS,c.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),c.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]),c.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]),c.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),c.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),c.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}static box(c){let f=8,p=null,E=Array.prototype.slice.call(arguments,1),T=E.length;for(let J=0;J<T;J++)f+=E[J].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(c,4);let G=8;for(let J=0;J<T;J++)p.set(E[J],G),G+=E[J].byteLength;return p}static generateInitSegment(c){let f=O.box(O.types.ftyp,O.constants.FTYP),p=O.moov(c),E=new Uint8Array(f.byteLength+p.byteLength);return E.set(f,0),E.set(p,f.byteLength),E}static moov(c){let f=O.mvhd(c.timescale,c.duration),p=O.trak(c),E=O.mvex(c);return O.box(O.types.moov,f,p,E)}static mvhd(c,f){return O.box(O.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,c>>>24&255,c>>>16&255,c>>>8&255,c&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(c){return O.box(O.types.trak,O.tkhd(c),O.mdia(c))}static tkhd(c){let f=c.id,p=c.duration,E=c.presentWidth,T=c.presentHeight;return O.box(O.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(c){return O.box(O.types.mdia,O.mdhd(c),O.hdlr(c),O.minf(c))}static mdhd(c){let f=c.timescale,p=c.duration;return O.box(O.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(c){let f=null;return c.type==="audio"?f=O.constants.HDLR_AUDIO:f=O.constants.HDLR_VIDEO,O.box(O.types.hdlr,f)}static minf(c){let f=null;return c.type==="audio"?f=O.box(O.types.smhd,O.constants.SMHD):f=O.box(O.types.vmhd,O.constants.VMHD),O.box(O.types.minf,f,O.dinf(),O.stbl(c))}static dinf(){return O.box(O.types.dinf,O.box(O.types.dref,O.constants.DREF))}static stbl(c){return O.box(O.types.stbl,O.stsd(c),O.box(O.types.stts,O.constants.STTS),O.box(O.types.stsc,O.constants.STSC),O.box(O.types.stsz,O.constants.STSZ),O.box(O.types.stco,O.constants.STCO))}static stsd(c){return c.type==="audio"?c.codec==="mp3"?O.box(O.types.stsd,O.constants.STSD_PREFIX,O.mp3(c)):O.box(O.types.stsd,O.constants.STSD_PREFIX,O.mp4a(c)):O.box(O.types.stsd,O.constants.STSD_PREFIX,O.avc1(c))}static mp3(c){let f=c.channelCount,p=c.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 O.box(O.types[".mp3"],E)}static mp4a(c){let f=c.channelCount,p=c.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 O.box(O.types.mp4a,E,O.esds(c))}static esds(c){let f=c.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 O.box(O.types.esds,E)}static avc1(c){let f=c.avcc,p=c.codecWidth,E=c.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 O.box(O.types.avc1,T,O.box(O.types.avcC,f))}static mvex(c){return O.box(O.types.mvex,O.trex(c))}static trex(c){let f=c.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 O.box(O.types.trex,p)}static moof(c,f){return O.box(O.types.moof,O.mfhd(c.sequenceNumber),O.traf(c,f))}static mfhd(c){let f=new Uint8Array([0,0,0,0,c>>>24&255,c>>>16&255,c>>>8&255,c&255]);return O.box(O.types.mfhd,f)}static traf(c,f){let p=c.id,E=O.box(O.types.tfhd,new Uint8Array([0,0,0,0,p>>>24&255,p>>>16&255,p>>>8&255,p&255])),T=O.box(O.types.tfdt,new Uint8Array([0,0,0,0,f>>>24&255,f>>>16&255,f>>>8&255,f&255])),G=O.sdtp(c),J=O.trun(c,G.byteLength+16+16+8+16+8+8);return O.box(O.types.traf,E,T,J,G)}static sdtp(c){let f=c.samples||[],p=f.length,E=new Uint8Array(4+p);for(let T=0;T<p;T++){let G=f[T].flags;E[T+4]=G.isLeading<<6|G.dependsOn<<4|G.isDependedOn<<2|G.hasRedundancy}return O.box(O.types.sdtp,E)}static trun(c,f){let p=c.samples||[],E=p.length,T=12+16*E,G=new Uint8Array(T);f+=8+T,G.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 J=0;J<E;J++){let Ye=p[J].duration,Ve=p[J].size,ht=p[J].flags,Rt=p[J].cts;G.set([Ye>>>24&255,Ye>>>16&255,Ye>>>8&255,Ye&255,Ve>>>24&255,Ve>>>16&255,Ve>>>8&255,Ve&255,ht.isLeading<<2|ht.dependsOn,ht.isDependedOn<<6|ht.hasRedundancy<<4|ht.isNonSync,0,0,Rt>>>24&255,Rt>>>16&255,Rt>>>8&255,Rt&255],12+16*J)}return O.box(O.types.trun,G)}static mdat(c){return O.box(O.types.mdat,c)}}O.init();var le=O;class Le{static getSilentFrame(c,f){if(c==="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 We=Le;class Je{constructor(c,f,p,E,T){this.dts=c,this.pts=f,this.duration=p,this.originalDts=E,this.isSyncPoint=T,this.fileposition=null}}class ft{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(c){c.isSyncPoint=!0,this.syncPoints.push(c)}}class nt{constructor(){this._list=[]}clear(){this._list=[]}appendArray(c){let f=this._list;c.length!==0&&(f.length>0&&c[0].originalDts<f[f.length-1].originalDts&&this.clear(),Array.prototype.push.apply(f,c))}getLastSyncPointBeforeDts(c){if(this._list.length==0)return null;let f=this._list,p=0,E=f.length-1,T=0,G=0,J=E;for(c<f[0].dts&&(p=0,G=J+1);G<=J;)if(T=G+Math.floor((J-G)/2),T===E||c>=f[T].dts&&c<f[T+1].dts){p=T;break}else f[T].dts<c?G=T+1:J=T-1;return this._list[p]}}class st{constructor(c){this._type=c,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(c){let f=this._list;if(f.length===0)return-2;let p=f.length-1,E=0,T=0,G=p,J=0;if(c<f[0].originalBeginDts)return J=-1,J;for(;T<=G;)if(E=T+Math.floor((G-T)/2),E===p||c>f[E].lastSample.originalDts&&c<f[E+1].originalBeginDts){J=E;break}else f[E].originalBeginDts<c?T=E+1:G=E-1;return J}_searchNearestSegmentAfter(c){return this._searchNearestSegmentBefore(c)+1}append(c){let f=this._list,p=c,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(c){let f=this._searchNearestSegmentBefore(c);return f>=0?this._list[f]:null}getLastSampleBefore(c){let f=this.getLastSegmentBefore(c);return f!=null?f.lastSample:null}getLastSyncPointBefore(c){let f=this._searchNearestSegmentBefore(c),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 tt{constructor(c){this.TAG="MP4Remuxer",this._config=c,this._isLive=c.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 st("audio"),this._videoSegmentInfoList=new st("video"),this._onInitSegment=null,this._onMediaSegment=null,this._forceFirstIDR=!!(K.chrome&&(K.version.major<50||K.version.major===50&&K.version.build<2661)),this._fillSilentAfterSeek=K.msedge||K.msie,this._mp3UseMpegAudio=!K.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(c){return c.onDataAvailable=this.remux.bind(this),c.onTrackMetadata=this._onTrackMetadataReceived.bind(this),this}get onInitSegment(){return this._onInitSegment}set onInitSegment(c){this._onInitSegment=c}get onMediaSegment(){return this._onMediaSegment}set onMediaSegment(c){this._onMediaSegment=c}insertDiscontinuity(){this._audioNextDts=this._videoNextDts=void 0}seek(c){this._audioStashedLastSample=null,this._videoStashedLastSample=null,this._videoSegmentInfoList.clear(),this._audioSegmentInfoList.clear()}remux(c,f){if(!this._onMediaSegment)throw new Ae("MP4Remuxer: onMediaSegment callback must be specificed!");this._dtsBaseInited||this._calculateDtsBase(c,f),this._remuxVideo(f),this._remuxAudio(c)}_onTrackMetadataReceived(c,f){let p=null,E="mp4",T=f.codec;if(c==="audio")this._audioMeta=f,f.codec==="mp3"&&this._mp3UseMpegAudio?(E="mpeg",T="",p=new Uint8Array):p=le.generateInitSegment(f);else if(c==="video")this._videoMeta=f,p=le.generateInitSegment(f);else return;if(!this._onInitSegment)throw new Ae("MP4Remuxer: onInitSegment callback must be specified!");this._onInitSegment(c,{type:c,data:p.buffer,codec:T,container:`${c}/${E}`,mediaDuration:f.duration})}_calculateDtsBase(c,f){this._dtsBaseInited||(c.samples&&c.samples.length&&(this._audioDtsBase=c.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 c=this._videoStashedLastSample,f=this._audioStashedLastSample,p={type:"video",id:1,sequenceNumber:0,samples:[],length:0};c!=null&&(p.samples.push(c),p.length=c.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(c,f){if(this._audioMeta==null)return;let p=c,E=p.samples,T,G=-1,J=-1,Ye=-1,Ve=this._audioMeta.refSampleDuration,ht=this._audioMeta.codec==="mp3"&&this._mp3UseMpegAudio,Rt=this._dtsBaseInited&&this._audioNextDts===void 0,Pt=!1;if(!E||E.length===0||E.length===1&&!f)return;let Ne=0,Ct=null,at=0;ht?(Ne=0,at=p.length):(Ne=8,at=8+p.length);let Ke=null;if(E.length>1&&(Ke=E.pop(),at-=Ke.length),this._audioStashedLastSample!=null){let rt=this._audioStashedLastSample;this._audioStashedLastSample=null,E.unshift(rt),at+=rt.length}Ke!=null&&(this._audioStashedLastSample=Ke);let et=E[0].dts-this._dtsBase;if(this._audioNextDts)T=et-this._audioNextDts;else if(this._audioSegmentInfoList.isEmpty())T=0,this._fillSilentAfterSeek&&!this._videoSegmentInfoList.isEmpty()&&this._audioMeta.originalCodec!=="mp3"&&(Pt=!0);else{let rt=this._audioSegmentInfoList.getLastSampleBefore(et);if(rt!=null){let lt=et-(rt.originalDts+rt.duration);lt<=3&&(lt=0);let q=rt.dts+rt.duration+lt;T=et-q}else T=0}if(Pt){let rt=et-T,lt=this._videoSegmentInfoList.getLastSegmentBefore(et);if(lt!=null&<.beginDts<rt){let q=We.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);if(q){let se=lt.beginDts,pe=rt-lt.beginDts;m.v(this.TAG,`InsertPrefixSilentAudio: dts: ${se}, duration: ${pe}`),E.unshift({unit:q,dts:se,pts:se}),at+=q.byteLength}}else Pt=!1}let vt=[];for(let rt=0;rt<E.length;rt++){let lt=E[rt],q=lt.unit,se=lt.dts-this._dtsBase,pe=se-T;G===-1&&(G=pe);let Ce=0;rt!==E.length-1?Ce=E[rt+1].dts-this._dtsBase-T-pe:Ke!=null?Ce=Ke.dts-this._dtsBase-T-pe:vt.length>=1?Ce=vt[vt.length-1].duration:Ce=Math.floor(Ve);let Se=!1,Ue=null;if(Ce>Ve*1.5&&this._audioMeta.codec!=="mp3"&&this._fillAudioTimestampGap&&!K.safari){Se=!0;let ke=Math.abs(Ce-Ve),xt=Math.ceil(ke/Ve),Mt=pe+Ve;m.w(this.TAG,`Large audio timestamp gap detected, may cause AV sync to drift. Silent frames will be generated to avoid unsync.
|
|
dts: ${pe+Ce} ms, expected: ${pe+Math.round(Ve)} ms, delta: ${Math.round(ke)} ms, generate: ${xt} frames`);let pt=We.getSilentFrame(this._audioMeta.originalCodec,this._audioMeta.channelCount);pt==null&&(m.w(this.TAG,`Unable to generate silent frame for ${this._audioMeta.originalCodec} with ${this._audioMeta.channelCount} channels, repeat last frame`),pt=q),Ue=[];for(let kt=0;kt<xt;kt++){let ai=Math.round(Mt);if(Ue.length>0){let Tt=Ue[Ue.length-1];Tt.duration=ai-Tt.dts}let Bt={dts:ai,pts:ai,cts:0,unit:pt,size:pt.byteLength,duration:0,originalDts:se,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}};Ue.push(Bt),at+=Bt.size,Mt+=Ve}let jt=Ue[Ue.length-1];jt.duration=pe+Ce-jt.dts,Ce=Math.round(Ve)}vt.push({dts:pe,pts:pe,cts:0,unit:lt.unit,size:lt.unit.byteLength,duration:Ce,originalDts:se,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0}}),Se&&vt.push.apply(vt,Ue)}ht?Ct=new Uint8Array(at):(Ct=new Uint8Array(at),Ct[0]=at>>>24&255,Ct[1]=at>>>16&255,Ct[2]=at>>>8&255,Ct[3]=at&255,Ct.set(le.types.mdat,4));for(let rt=0;rt<vt.length;rt++){let lt=vt[rt].unit;Ct.set(lt,Ne),Ne+=lt.byteLength}let Lt=vt[vt.length-1];J=Lt.dts+Lt.duration,this._audioNextDts=J;let Ut=new ft;Ut.beginDts=G,Ut.endDts=J,Ut.beginPts=G,Ut.endPts=J,Ut.originalBeginDts=vt[0].originalDts,Ut.originalEndDts=Lt.originalDts+Lt.duration,Ut.firstSample=new Je(vt[0].dts,vt[0].pts,vt[0].duration,vt[0].originalDts,!1),Ut.lastSample=new Je(Lt.dts,Lt.pts,Lt.duration,Lt.originalDts,!1),this._isLive||this._audioSegmentInfoList.append(Ut),p.samples=vt,p.sequenceNumber++;let qt=null;ht?qt=new Uint8Array:qt=le.moof(p,G),p.samples=[],p.length=0;let ki={type:"audio",data:this._mergeBoxes(qt,Ct).buffer,sampleCount:vt.length,info:Ut};ht&&Rt&&(ki.timestampOffset=G),this._onMediaSegment("audio",ki)}_remuxVideo(c,f){if(this._videoMeta==null)return;let p=c,E=p.samples,T,G=-1,J=-1,Ye=-1,Ve=-1;if(!E||E.length===0||E.length===1&&!f)return;let ht=8,Rt=null,Pt=8+c.length,Ne=null;if(E.length>1&&(Ne=E.pop(),Pt-=Ne.length),this._videoStashedLastSample!=null){let Lt=this._videoStashedLastSample;this._videoStashedLastSample=null,E.unshift(Lt),Pt+=Lt.length}Ne!=null&&(this._videoStashedLastSample=Ne);let Ct=E[0].dts-this._dtsBase;if(this._videoNextDts)T=Ct-this._videoNextDts;else if(this._videoSegmentInfoList.isEmpty())T=0;else{let Lt=this._videoSegmentInfoList.getLastSampleBefore(Ct);if(Lt!=null){let Ut=Ct-(Lt.originalDts+Lt.duration);Ut<=3&&(Ut=0);let qt=Lt.dts+Lt.duration+Ut;T=Ct-qt}else T=0}let at=new ft,Ke=[];for(let Lt=0;Lt<E.length;Lt++){let Ut=E[Lt],qt=Ut.dts-this._dtsBase,ki=Ut.isKeyframe,rt=qt-T,lt=Ut.cts,q=rt+lt;G===-1&&(G=rt,Ye=q);let se=0;if(Lt!==E.length-1?se=E[Lt+1].dts-this._dtsBase-T-rt:Ne!=null?se=Ne.dts-this._dtsBase-T-rt:Ke.length>=1?se=Ke[Ke.length-1].duration:se=Math.floor(this._videoMeta.refSampleDuration),ki){let pe=new Je(rt,q,se,Ut.dts,!0);pe.fileposition=Ut.fileposition,at.appendSyncPoint(pe)}Ke.push({dts:rt,pts:q,cts:lt,units:Ut.units,size:Ut.length,isKeyframe:ki,duration:se,originalDts:qt,flags:{isLeading:0,dependsOn:ki?2:1,isDependedOn:ki?1:0,hasRedundancy:0,isNonSync:ki?0:1}})}Rt=new Uint8Array(Pt),Rt[0]=Pt>>>24&255,Rt[1]=Pt>>>16&255,Rt[2]=Pt>>>8&255,Rt[3]=Pt&255,Rt.set(le.types.mdat,4);for(let Lt=0;Lt<Ke.length;Lt++){let Ut=Ke[Lt].units;for(;Ut.length;){let ki=Ut.shift().data;Rt.set(ki,ht),ht+=ki.byteLength}}let et=Ke[Ke.length-1];if(J=et.dts+et.duration,Ve=et.pts+et.duration,this._videoNextDts=J,at.beginDts=G,at.endDts=J,at.beginPts=Ye,at.endPts=Ve,at.originalBeginDts=Ke[0].originalDts,at.originalEndDts=et.originalDts+et.duration,at.firstSample=new Je(Ke[0].dts,Ke[0].pts,Ke[0].duration,Ke[0].originalDts,Ke[0].isKeyframe),at.lastSample=new Je(et.dts,et.pts,et.duration,et.originalDts,et.isKeyframe),this._isLive||this._videoSegmentInfoList.append(at),p.samples=Ke,p.sequenceNumber++,this._forceFirstIDR){let Lt=Ke[0].flags;Lt.dependsOn=2,Lt.isNonSync=0}let vt=le.moof(p,G);p.samples=[],p.length=0,this._onMediaSegment("video",{type:"video",data:this._mergeBoxes(vt,Rt).buffer,sampleCount:Ke.length,info:at})}_mergeBoxes(c,f){let p=new Uint8Array(c.byteLength+f.byteLength);return p.set(c,0),p.set(f,c.byteLength),p}}var It=tt,ge={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 ei{constructor(c,f){this.TAG="TransmuxingController",this._emitter=new(z()),this._config=f,c.segments||(c.segments=[{duration:c.duration,filesize:c.filesize,url:c.url}]),typeof c.cors!="boolean"&&(c.cors=!0),typeof c.withCredentials!="boolean"&&(c.withCredentials=!1),this._mediaDataSource=c,this._currentSegmentIndex=0;let p=0;this._mediaDataSource.segments.forEach(E=>{E.timestampBase=p,p+=E.duration,E.cors=c.cors,E.withCredentials=c.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(c,f){this._emitter.addListener(c,f)}off(c,f){this._emitter.removeListener(c,f)}start(){this._loadSegment(0),this._enableStatisticsReporter()}_loadSegment(c,f){this._currentSegmentIndex=c;let p=this._mediaDataSource.segments[c],E=this._ioctl=new we(p,this._config,c);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(c){if(this._mediaInfo==null||!this._mediaInfo.isSeekable())return;let f=this._searchSegmentIndexContains(c);if(f===this._currentSegmentIndex){let p=this._mediaInfo.segments[f];if(p==null)this._pendingSeekTime=c;else{let E=p.getNearestKeyframe(c);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=c,this._internalAbort(),this._remuxer.seek(),this._remuxer.insertDiscontinuity(),this._loadSegment(f);else{let E=p.getNearestKeyframe(c);this._internalAbort(),this._remuxer.seek(c),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(c){let f=this._mediaDataSource.segments,p=f.length-1;for(let E=0;E<f.length;E++)if(c<f[E].timestampBase){p=E-1;break}return p}_onInitChunkArrival(c,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(c,f);else if((p=W.probe(c)).match){this._demuxer=new W(p,this._config),this._remuxer||(this._remuxer=new It(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(c,f)}else p=null,m.e(this.TAG,"Non-FLV, Unsupported media type!"),Promise.resolve().then(()=>{this._internalAbort()}),this._emitter.emit(ge.DEMUX_ERROR,D.FORMAT_UNSUPPORTED,"Non-FLV, Unsupported media type"),E=0;return E}_onMediaInfo(c){this._mediaInfo==null&&(this._mediaInfo=Object.assign({},c),this._mediaInfo.keyframesIndex=null,this._mediaInfo.segments=[],this._mediaInfo.segmentCount=this._mediaDataSource.segments.length,Object.setPrototypeOf(this._mediaInfo,Et.prototype));let f=Object.assign({},c);Object.setPrototypeOf(f,Et.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(c){this._emitter.emit(ge.METADATA_ARRIVED,c)}_onScriptDataArrived(c){this._emitter.emit(ge.SCRIPTDATA_ARRIVED,c)}_onIOSeeked(){this._remuxer.insertDiscontinuity()}_onIOComplete(c){let p=c+1;p<this._mediaDataSource.segments.length?(this._internalAbort(),this._remuxer.flushStashedSamples(),this._loadSegment(p)):(this._remuxer.flushStashedSamples(),this._emitter.emit(ge.LOADING_COMPLETE),this._disableStatisticsReporter())}_onIORedirect(c){let f=this._ioctl.extraData;this._mediaDataSource.segments[f].redirectedURL=c}_onIORecoveredEarlyEof(){this._emitter.emit(ge.RECOVERED_EARLY_EOF)}_onIOException(c,f){m.e(this.TAG,`IOException: type = ${c}, code = ${f.code}, msg = ${f.msg}`),this._emitter.emit(ge.IO_ERROR,c,f),this._disableStatisticsReporter()}_onDemuxException(c,f){m.e(this.TAG,`DemuxException: type = ${c}, info = ${f}`),this._emitter.emit(ge.DEMUX_ERROR,c,f)}_onRemuxerInitSegmentArrival(c,f){this._emitter.emit(ge.INIT_SEGMENT,c,f)}_onRemuxerMediaSegmentArrival(c,f){if(this._pendingSeekTime==null&&(this._emitter.emit(ge.MEDIA_SEGMENT,c,f),this._pendingResolveSeekPoint!=null&&c==="video")){let p=f.info.syncPoints,E=this._pendingResolveSeekPoint;this._pendingResolveSeekPoint=null,K.safari&&p.length>0&&p[0].originalDts===E&&(E=p[0].pts),this._emitter.emit(ge.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(c){let f=this._mediaInfo.segments[c],p=Object.assign({},f);p.duration=this._mediaInfo.duration,p.segmentCount=this._mediaInfo.segmentCount,delete p.segments,delete p.keyframesIndex,this._emitter.emit(ge.MEDIA_INFO,p)}_reportStatisticsInfo(){let c={};c.url=this._ioctl.currentURL,c.hasRedirect=this._ioctl.hasRedirect,c.hasRedirect&&(c.redirectedURL=this._ioctl.currentRedirectedURL),c.speed=this._ioctl.currentSpeed,c.loaderType=this._ioctl.loaderType,c.currentSegmentIndex=this._currentSegmentIndex,c.totalSegmentCount=this._mediaDataSource.segments.length,this._emitter.emit(ge.STATISTICS_INFO,c)}}var ti=ei,Xt=function(Ge){let c="TransmuxingWorker",f=null,p=at.bind(this);B.install(),Ge.addEventListener("message",function(Ke){switch(Ke.data.cmd){case"init":f=new ti(Ke.data.param[0],Ke.data.param[1]),f.on(ge.IO_ERROR,Pt.bind(this)),f.on(ge.DEMUX_ERROR,Ne.bind(this)),f.on(ge.INIT_SEGMENT,E.bind(this)),f.on(ge.MEDIA_SEGMENT,T.bind(this)),f.on(ge.LOADING_COMPLETE,G.bind(this)),f.on(ge.RECOVERED_EARLY_EOF,J.bind(this)),f.on(ge.MEDIA_INFO,Ye.bind(this)),f.on(ge.METADATA_ARRIVED,Ve.bind(this)),f.on(ge.SCRIPTDATA_ARRIVED,ht.bind(this)),f.on(ge.STATISTICS_INFO,Rt.bind(this)),f.on(ge.RECOMMEND_SEEKPOINT,Ct.bind(this));break;case"destroy":f&&(f.destroy(),f=null),Ge.postMessage({msg:"destroyed"});break;case"start":f.start();break;case"stop":f.stop();break;case"seek":f.seek(Ke.data.param);break;case"pause":f.pause();break;case"resume":f.resume();break;case"logging_config":{let et=Ke.data.param;ot.applyConfig(et),et.enableCallback===!0?ot.addLogListener(p):ot.removeLogListener(p);break}}});function E(Ke,et){let vt={msg:ge.INIT_SEGMENT,data:{type:Ke,data:et}};Ge.postMessage(vt,[et.data])}function T(Ke,et){let vt={msg:ge.MEDIA_SEGMENT,data:{type:Ke,data:et}};Ge.postMessage(vt,[et.data])}function G(){let Ke={msg:ge.LOADING_COMPLETE};Ge.postMessage(Ke)}function J(){let Ke={msg:ge.RECOVERED_EARLY_EOF};Ge.postMessage(Ke)}function Ye(Ke){let et={msg:ge.MEDIA_INFO,data:Ke};Ge.postMessage(et)}function Ve(Ke){let et={msg:ge.METADATA_ARRIVED,data:Ke};Ge.postMessage(et)}function ht(Ke){let et={msg:ge.SCRIPTDATA_ARRIVED,data:Ke};Ge.postMessage(et)}function Rt(Ke){let et={msg:ge.STATISTICS_INFO,data:Ke};Ge.postMessage(et)}function Pt(Ke,et){Ge.postMessage({msg:ge.IO_ERROR,data:{type:Ke,info:et}})}function Ne(Ke,et){Ge.postMessage({msg:ge.DEMUX_ERROR,data:{type:Ke,info:et}})}function Ct(Ke){Ge.postMessage({msg:ge.RECOMMEND_SEEKPOINT,data:Ke})}function at(Ke,et){Ge.postMessage({msg:"logcat_callback",data:{type:Ke,logcat:et}})}};class Ti{constructor(c,f){if(this.TAG="Transmuxer",this._emitter=new(z()),f.enableWorker&&typeof Worker!="undefined")try{let p=R(82059);this._worker=p(Xt),this._workerDestroying=!1,this._worker.addEventListener("message",this._onWorkerMessage.bind(this)),this._worker.postMessage({cmd:"init",param:[c,f]}),this.e={onLoggingConfigChanged:this._onLoggingConfigChanged.bind(this)},ot.registerListener(this.e.onLoggingConfigChanged),this._worker.postMessage({cmd:"logging_config",param:ot.getConfig()})}catch(p){m.e(this.TAG,"Error while initialize transmuxing worker, fallback to inline transmuxing"),this._worker=null,this._controller=new ti(c,f)}else this._controller=new ti(c,f);if(this._controller){let p=this._controller;p.on(ge.IO_ERROR,this._onIOError.bind(this)),p.on(ge.DEMUX_ERROR,this._onDemuxError.bind(this)),p.on(ge.INIT_SEGMENT,this._onInitSegment.bind(this)),p.on(ge.MEDIA_SEGMENT,this._onMediaSegment.bind(this)),p.on(ge.LOADING_COMPLETE,this._onLoadingComplete.bind(this)),p.on(ge.RECOVERED_EARLY_EOF,this._onRecoveredEarlyEof.bind(this)),p.on(ge.MEDIA_INFO,this._onMediaInfo.bind(this)),p.on(ge.METADATA_ARRIVED,this._onMetaDataArrived.bind(this)),p.on(ge.SCRIPTDATA_ARRIVED,this._onScriptDataArrived.bind(this)),p.on(ge.STATISTICS_INFO,this._onStatisticsInfo.bind(this)),p.on(ge.RECOMMEND_SEEKPOINT,this._onRecommendSeekpoint.bind(this))}}destroy(){this._worker?this._workerDestroying||(this._workerDestroying=!0,this._worker.postMessage({cmd:"destroy"}),ot.removeListener(this.e.onLoggingConfigChanged),this.e=null):(this._controller.destroy(),this._controller=null),this._emitter.removeAllListeners(),this._emitter=null}on(c,f){this._emitter.addListener(c,f)}off(c,f){this._emitter.removeListener(c,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(c){this._worker?this._worker.postMessage({cmd:"seek",param:c}):this._controller.seek(c)}pause(){this._worker?this._worker.postMessage({cmd:"pause"}):this._controller.pause()}resume(){this._worker?this._worker.postMessage({cmd:"resume"}):this._controller.resume()}_onInitSegment(c,f){Promise.resolve().then(()=>{this._emitter.emit(ge.INIT_SEGMENT,c,f)})}_onMediaSegment(c,f){Promise.resolve().then(()=>{this._emitter.emit(ge.MEDIA_SEGMENT,c,f)})}_onLoadingComplete(){Promise.resolve().then(()=>{this._emitter.emit(ge.LOADING_COMPLETE)})}_onRecoveredEarlyEof(){Promise.resolve().then(()=>{this._emitter.emit(ge.RECOVERED_EARLY_EOF)})}_onMediaInfo(c){Promise.resolve().then(()=>{this._emitter.emit(ge.MEDIA_INFO,c)})}_onMetaDataArrived(c){Promise.resolve().then(()=>{this._emitter.emit(ge.METADATA_ARRIVED,c)})}_onScriptDataArrived(c){Promise.resolve().then(()=>{this._emitter.emit(ge.SCRIPTDATA_ARRIVED,c)})}_onStatisticsInfo(c){Promise.resolve().then(()=>{this._emitter.emit(ge.STATISTICS_INFO,c)})}_onIOError(c,f){Promise.resolve().then(()=>{this._emitter.emit(ge.IO_ERROR,c,f)})}_onDemuxError(c,f){Promise.resolve().then(()=>{this._emitter.emit(ge.DEMUX_ERROR,c,f)})}_onRecommendSeekpoint(c){Promise.resolve().then(()=>{this._emitter.emit(ge.RECOMMEND_SEEKPOINT,c)})}_onLoggingConfigChanged(c){this._worker&&this._worker.postMessage({cmd:"logging_config",param:c})}_onWorkerMessage(c){let f=c.data,p=f.data;if(f.msg==="destroyed"||this._workerDestroying){this._workerDestroying=!1,this._worker.terminate(),this._worker=null;return}switch(f.msg){case ge.INIT_SEGMENT:case ge.MEDIA_SEGMENT:this._emitter.emit(f.msg,p.type,p.data);break;case ge.LOADING_COMPLETE:case ge.RECOVERED_EARLY_EOF:this._emitter.emit(f.msg);break;case ge.MEDIA_INFO:Object.setPrototypeOf(p,Et.prototype),this._emitter.emit(f.msg,p);break;case ge.METADATA_ARRIVED:case ge.SCRIPTDATA_ARRIVED:case ge.STATISTICS_INFO:this._emitter.emit(f.msg,p);break;case ge.IO_ERROR:case ge.DEMUX_ERROR:this._emitter.emit(f.msg,p.type,p.info);break;case ge.RECOMMEND_SEEKPOINT:this._emitter.emit(f.msg,p);break;case"logcat_callback":m.emitter.emit("log",p.type,p.logcat);break;default:break}}}var gi=Ti,ii={ERROR:"error",SOURCE_OPEN:"source_open",UPDATE_END:"update_end",BUFFER_FULL:"buffer_full"};class Mi{constructor(c){this.TAG="MSEController",this._config=c,this._emitter=new(z()),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 nt}destroy(){(this._mediaElement||this._mediaSource)&&this.detachMediaElement(),this.e=null,this._emitter.removeAllListeners(),this._emitter=null}on(c,f){this._emitter.addListener(c,f)}off(c,f){this._emitter.removeListener(c,f)}attachMediaElement(c){if(this._mediaSource)throw new Ae("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=c,this._mediaSourceObjectURL=window.URL.createObjectURL(this._mediaSource),c.src=this._mediaSourceObjectURL}detachMediaElement(){if(this._mediaSource){let c=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(c.readyState!=="closed"){try{c.removeSourceBuffer(E)}catch(T){m.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(c.readyState==="open")try{c.endOfStream()}catch(f){m.e(this.TAG,f.message)}c.removeEventListener("sourceopen",this.e.onSourceOpen),c.removeEventListener("sourceended",this.e.onSourceEnded),c.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(c,f){if(!this._mediaSource||this._mediaSource.readyState!=="open"){this._pendingSourceBufferInit.push(c),this._pendingSegments[c.type].push(c);return}let p=c,E=`${p.container}`;p.codec&&p.codec.length>0&&(E+=`;codecs=${p.codec}`);let T=!1;if(m.v(this.TAG,"Received Initialization Segment, mimeType: "+E),this._lastInitSegments[p.type]=p,E!==this._mimeTypes[p.type]){if(this._mimeTypes[p.type])m.v(this.TAG,`Notice: ${p.type} mimeType changed, origin: ${this._mimeTypes[p.type]}, target: ${E}`);else{T=!0;try{let G=this._sourceBuffers[p.type]=this._mediaSource.addSourceBuffer(E);G.addEventListener("error",this.e.onSourceBufferError),G.addEventListener("updateend",this.e.onSourceBufferUpdateEnd)}catch(G){m.e(this.TAG,G.message),this._emitter.emit(ii.ERROR,{code:G.code,msg:G.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(),K.safari&&p.container==="audio/mpeg"&&p.mediaDuration>0&&(this._requireSetMediaDuration=!0,this._pendingMediaDuration=p.mediaDuration/1e3,this._updateMediaSourceDuration())}appendMediaSegment(c){let f=c;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(c){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){m.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 G=p.buffered.start(T),J=p.buffered.end(T);this._pendingRemoveRanges[f].push({start:G,end:J})}if(p.updating||this._doRemoveRanges(),K.safari){let T=this._lastInitSegments[f];T&&(this._pendingSegments[f].push(T),p.updating||this._doAppendSegments())}}}}endOfStream(){let c=this._mediaSource,f=this._sourceBuffers;if(!c||c.readyState!=="open"){c&&c.readyState==="closed"&&this._hasPendingSegments()&&(this._hasPendingEos=!0);return}f.video&&f.video.updating||f.audio&&f.audio.updating?this._hasPendingEos=!0:(this._hasPendingEos=!1,c.endOfStream())}getNearestKeyframe(c){return this._idrList.getLastSyncPointBeforeDts(c)}_needCleanupSourceBuffer(){if(!this._config.autoCleanupSourceBuffer)return!1;let c=this._mediaElement.currentTime;for(let f in this._sourceBuffers){let p=this._sourceBuffers[f];if(p){let E=p.buffered;if(E.length>=1&&c-E.start(0)>=this._config.autoCleanupMaxBackwardDuration)return!0}}return!1}_doCleanupSourceBuffer(){let c=this._mediaElement.currentTime;for(let f in this._sourceBuffers){let p=this._sourceBuffers[f];if(p){let E=p.buffered,T=!1;for(let G=0;G<E.length;G++){let J=E.start(G),Ye=E.end(G);if(J<=c&&c<Ye+3){if(c-J>=this._config.autoCleanupMaxBackwardDuration){T=!0;let Ve=c-this._config.autoCleanupMinBackwardDuration;this._pendingRemoveRanges[f].push({start:J,end:Ve})}}else Ye<c&&(T=!0,this._pendingRemoveRanges[f].push({start:J,end:Ye}))}T&&!p.updating&&this._doRemoveRanges()}}}_updateMediaSourceDuration(){let c=this._sourceBuffers;if(this._mediaElement.readyState===0||this._mediaSource.readyState!=="open"||c.video&&c.video.updating||c.audio&&c.audio.updating)return;let f=this._mediaSource.duration,p=this._pendingMediaDuration;p>0&&(isNaN(f)||p>f)&&(m.v(this.TAG,`Update MediaSource duration from ${f} to ${p}`),this._mediaSource.duration=p),this._requireSetMediaDuration=!1,this._pendingMediaDuration=0}_doRemoveRanges(){for(let c in this._pendingRemoveRanges){if(!this._sourceBuffers[c]||this._sourceBuffers[c].updating)continue;let f=this._sourceBuffers[c],p=this._pendingRemoveRanges[c];for(;p.length&&!f.updating;){let E=p.shift();f.remove(E.start,E.end)}}}_doAppendSegments(){let c=this._pendingSegments;for(let f in c)if(!(!this._sourceBuffers[f]||this._sourceBuffers[f].updating)&&c[f].length>0){let p=c[f].shift();if(p.timestampOffset){let E=this._sourceBuffers[f].timestampOffset,T=p.timestampOffset/1e3;Math.abs(E-T)>.1&&(m.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(ii.BUFFER_FULL),this._isBufferFull=!0):(m.e(this.TAG,E.message),this._emitter.emit(ii.ERROR,{code:E.code,msg:E.message}))}}}_onSourceOpen(){if(m.v(this.TAG,"MediaSource onSourceOpen"),this._mediaSource.removeEventListener("sourceopen",this.e.onSourceOpen),this._pendingSourceBufferInit.length>0){let c=this._pendingSourceBufferInit;for(;c.length;){let f=c.shift();this.appendInitSegment(f,!0)}}this._hasPendingSegments()&&this._doAppendSegments(),this._emitter.emit(ii.SOURCE_OPEN)}_onSourceEnded(){m.v(this.TAG,"MediaSource onSourceEnded")}_onSourceClose(){m.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 c=this._pendingSegments;return c.video.length>0||c.audio.length>0}_hasPendingRemoveRanges(){let c=this._pendingRemoveRanges;return c.video.length>0||c.audio.length>0}_onSourceBufferUpdateEnd(){this._requireSetMediaDuration?this._updateMediaSourceDuration():this._hasPendingRemoveRanges()?this._doRemoveRanges():this._hasPendingSegments()?this._doAppendSegments():this._hasPendingEos&&this.endOfStream(),this._emitter.emit(ii.UPDATE_END)}_onSourceBufferError(c){m.e(this.TAG,`SourceBuffer Error: ${c}`)}}var Qt=Mi;const ut={NETWORK_ERROR:"NetworkError",MEDIA_ERROR:"MediaError",OTHER_ERROR:"OtherError"},_t={NETWORK_EXCEPTION:j.EXCEPTION,NETWORK_STATUS_CODE_INVALID:j.HTTP_STATUS_CODE_INVALID,NETWORK_TIMEOUT:j.CONNECTING_TIMEOUT,NETWORK_UNRECOVERABLE_EARLY_EOF:j.UNRECOVERABLE_EARLY_EOF,MEDIA_MSE_ERROR:"MediaMSEError",MEDIA_FORMAT_ERROR:D.FORMAT_ERROR,MEDIA_FORMAT_UNSUPPORTED:D.FORMAT_UNSUPPORTED,MEDIA_CODEC_UNSUPPORTED:D.CODEC_UNSUPPORTED};class si{constructor(c,f){if(this.TAG="FlvPlayer",this._type="FlvPlayer",this._emitter=new(z()),this._config=Ee(),typeof f=="object"&&Object.assign(this._config,f),c.type.toLowerCase()!=="flv")throw new Pe("FlvPlayer requires an flv MediaDataSource input!");c.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=c,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=K.chrome&&(K.version.major<50||K.version.major===50&&K.version.build<2661);this._alwaysSeekKeyframe=!!(p||K.msedge||K.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(c,f){c===Fe.MEDIA_INFO?this._mediaInfo!=null&&Promise.resolve().then(()=>{this._emitter.emit(Fe.MEDIA_INFO,this.mediaInfo)}):c===Fe.STATISTICS_INFO&&this._statisticsInfo!=null&&Promise.resolve().then(()=>{this._emitter.emit(Fe.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(c,f)}off(c,f){this._emitter.removeListener(c,f)}attachMediaElement(c){if(this._mediaElement=c,c.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),c.addEventListener("seeking",this.e.onvSeeking),c.addEventListener("canplay",this.e.onvCanPlay),c.addEventListener("stalled",this.e.onvStalled),c.addEventListener("progress",this.e.onvProgress),this._msectl=new Qt(this._config),this._msectl.on(ii.UPDATE_END,this._onmseUpdateEnd.bind(this)),this._msectl.on(ii.BUFFER_FULL,this._onmseBufferFull.bind(this)),this._msectl.on(ii.SOURCE_OPEN,()=>{this._mseSourceOpened=!0,this._hasPendingLoad&&(this._hasPendingLoad=!1,this.load())}),this._msectl.on(ii.ERROR,f=>{this._emitter.emit(Fe.ERROR,ut.MEDIA_ERROR,_t.MEDIA_MSE_ERROR,f)}),this._msectl.attachMediaElement(c),this._pendingSeekTime!=null)try{c.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 Ae("HTMLMediaElement must be attached before load()!");if(this._transmuxer)throw new Ae("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 gi(this._mediaDataSource,this._config),this._transmuxer.on(ge.INIT_SEGMENT,(c,f)=>{this._msectl.appendInitSegment(f)}),this._transmuxer.on(ge.MEDIA_SEGMENT,(c,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&&(m.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}}),this._transmuxer.on(ge.LOADING_COMPLETE,()=>{this._msectl.endOfStream(),this._emitter.emit(Fe.LOADING_COMPLETE)}),this._transmuxer.on(ge.RECOVERED_EARLY_EOF,()=>{this._emitter.emit(Fe.RECOVERED_EARLY_EOF)}),this._transmuxer.on(ge.IO_ERROR,(c,f)=>{this._emitter.emit(Fe.ERROR,ut.NETWORK_ERROR,c,f)}),this._transmuxer.on(ge.DEMUX_ERROR,(c,f)=>{this._emitter.emit(Fe.ERROR,ut.MEDIA_ERROR,c,{code:-1,msg:f})}),this._transmuxer.on(ge.MEDIA_INFO,c=>{this._mediaInfo=c,this._emitter.emit(Fe.MEDIA_INFO,Object.assign({},c))}),this._transmuxer.on(ge.METADATA_ARRIVED,c=>{this._emitter.emit(Fe.METADATA_ARRIVED,c)}),this._transmuxer.on(ge.SCRIPTDATA_ARRIVED,c=>{this._emitter.emit(Fe.SCRIPTDATA_ARRIVED,c)}),this._transmuxer.on(ge.STATISTICS_INFO,c=>{this._statisticsInfo=this._fillStatisticsInfo(c),this._emitter.emit(Fe.STATISTICS_INFO,Object.assign({},this._statisticsInfo))}),this._transmuxer.on(ge.RECOMMEND_SEEKPOINT,c=>{this._mediaElement&&!this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=c/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(c){this._mediaElement.volume=c}get muted(){return this._mediaElement.muted}set muted(c){this._mediaElement.muted=c}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(c){this._mediaElement?this._internalSeek(c):this._pendingSeekTime=c}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(c){if(c.playerType=this._type,!(this._mediaElement instanceof HTMLVideoElement))return c;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&&(c.decodedFrames=p,c.droppedFrames=E),c}_onmseUpdateEnd(){if(!this._config.lazyLoad||this._config.isLive)return;let c=this._mediaElement.buffered,f=this._mediaElement.currentTime,p=0,E=0;for(let T=0;T<c.length;T++){let G=c.start(T),J=c.end(T);if(G<=f&&f<J){p=G,E=J;break}}E>=f+this._config.lazyLoadMaxDuration&&this._progressChecker==null&&(m.v(this.TAG,"Maximum buffering duration exceeded, suspend transmuxing task"),this._suspendTransmuxer())}_onmseBufferFull(){m.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 c=this._mediaElement.currentTime,f=this._mediaElement.buffered,p=!1;for(let E=0;E<f.length;E++){let T=f.start(E),G=f.end(E);if(c>=T&&c<G){c>=G-this._config.lazyLoadRecoverDuration&&(p=!0);break}}p&&(window.clearInterval(this._progressChecker),this._progressChecker=null,p&&(m.v(this.TAG,"Continue loading from paused position"),this._transmuxer.resume()))}_isTimepointBuffered(c){let f=this._mediaElement.buffered;for(let p=0;p<f.length;p++){let E=f.start(p),T=f.end(p);if(c>=E&&c<T)return!0}return!1}_internalSeek(c){let f=this._isTimepointBuffered(c),p=!1,E=0;if(c<1&&this._mediaElement.buffered.length>0){let T=this._mediaElement.buffered.start(0);(T<1&&c<T||K.safari)&&(p=!0,E=K.safari?.1:T)}if(p)this._requestSetTime=!0,this._mediaElement.currentTime=E;else if(f){if(!this._alwaysSeekKeyframe)this._requestSetTime=!0,this._mediaElement.currentTime=c;else{let T=this._msectl.getNearestKeyframe(Math.floor(c*1e3));this._requestSetTime=!0,T!=null?this._mediaElement.currentTime=T.dts/1e3:this._mediaElement.currentTime=c}this._progressChecker!=null&&this._checkProgressAndResume()}else this._progressChecker!=null&&(window.clearInterval(this._progressChecker),this._progressChecker=null),this._msectl.seek(c),this._transmuxer.seek(Math.floor(c*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=c)}_checkAndApplyUnbufferedSeekpoint(){if(this._seekpointRecord)if(this._seekpointRecord.recordTime<=this._now()-100){let c=this._mediaElement.currentTime;this._seekpointRecord=null,this._isTimepointBuffered(c)||(this._progressChecker!=null&&(window.clearTimeout(this._progressChecker),this._progressChecker=null),this._msectl.seek(c),this._transmuxer.seek(Math.floor(c*1e3)),this._config.accurateSeek&&(this._requestSetTime=!0,this._mediaElement.currentTime=c))}else window.setTimeout(this._checkAndApplyUnbufferedSeekpoint.bind(this),50)}_checkAndResumeStuckPlayback(c){let f=this._mediaElement;if(c||!this._receivedCanPlay||f.readyState<2){let p=f.buffered;p.length>0&&f.currentTime<p.start(0)&&(m.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(c){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null)}_onvSeeking(c){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||K.safari){this._requestSetTime=!0,this._mediaElement.currentTime=K.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(c){this._receivedCanPlay=!0,this._mediaElement.removeEventListener("canplay",this.e.onvCanPlay)}_onvStalled(c){this._checkAndResumeStuckPlayback(!0)}_onvProgress(c){this._checkAndResumeStuckPlayback()}}var At=si;class bi{constructor(c,f){if(this.TAG="NativePlayer",this._type="NativePlayer",this._emitter=new(z()),this._config=Ee(),typeof f=="object"&&Object.assign(this._config,f),c.type.toLowerCase()==="flv")throw new Pe("NativePlayer does't support flv MediaDataSource input!");if(c.hasOwnProperty("segments"))throw new Pe(`NativePlayer(${c.type}) doesn't support multipart playback!`);this.e={onvLoadedMetadata:this._onvLoadedMetadata.bind(this)},this._pendingSeekTime=null,this._statisticsReporter=null,this._mediaDataSource=c,this._mediaElement=null}destroy(){this._mediaElement&&(this.unload(),this.detachMediaElement()),this.e=null,this._mediaDataSource=null,this._emitter.removeAllListeners(),this._emitter=null}on(c,f){c===Fe.MEDIA_INFO?this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(()=>{this._emitter.emit(Fe.MEDIA_INFO,this.mediaInfo)}):c===Fe.STATISTICS_INFO&&this._mediaElement!=null&&this._mediaElement.readyState!==0&&Promise.resolve().then(()=>{this._emitter.emit(Fe.STATISTICS_INFO,this.statisticsInfo)}),this._emitter.addListener(c,f)}off(c,f){this._emitter.removeListener(c,f)}attachMediaElement(c){if(this._mediaElement=c,c.addEventListener("loadedmetadata",this.e.onvLoadedMetadata),this._pendingSeekTime!=null)try{c.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 Ae("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(c){this._mediaElement.volume=c}get muted(){return this._mediaElement.muted}set muted(c){this._mediaElement.muted=c}get currentTime(){return this._mediaElement?this._mediaElement.currentTime:0}set currentTime(c){this._mediaElement?this._mediaElement.currentTime=c:this._pendingSeekTime=c}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 c={playerType:this._type,url:this._mediaDataSource.url};if(!(this._mediaElement instanceof HTMLVideoElement))return c;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&&(c.decodedFrames=p,c.droppedFrames=E),c}_onvLoadedMetadata(c){this._pendingSeekTime!=null&&(this._mediaElement.currentTime=this._pendingSeekTime,this._pendingSeekTime=null),this._emitter.emit(Fe.MEDIA_INFO,this.mediaInfo)}_reportStatisticsInfo(){this._emitter.emit(Fe.STATISTICS_INFO,this.statisticsInfo)}}var li=bi;B.install();function _i(Ge,c){let f=Ge;if(f==null||typeof f!="object")throw new Pe("MediaDataSource must be an javascript object!");if(!f.hasOwnProperty("type"))throw new Pe("MediaDataSource must has type field to indicate video file type!");switch(f.type){case"flv":return new At(f,c);default:return new li(f,c)}}function pi(){return Me.supportMSEH264Playback()}function ri(){return Me.getFeatureList()}let ci={};ci.createPlayer=_i,ci.isSupported=pi,ci.getFeatureList=ri,ci.BaseLoader=ct,ci.LoaderStatus=I,ci.LoaderErrors=j,ci.Events=Fe,ci.ErrorTypes=ut,ci.ErrorDetails=_t,ci.FlvPlayer=At,ci.NativePlayer=li,ci.LoggingControl=ot,Object.defineProperty(ci,"version",{enumerable:!0,get:function(){return"__VERSION__"}});var as=ci},36785:function(Wt,ze,R){"use strict";R.d(ze,{o2:function(){return A},yT:function(){return m}});var S=R(80702),B=R(33166);const fe=B.i.map(oe=>`${oe}-inverse`),z=["success","processing","error","default","warning"];function A(oe){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0)?[].concat((0,S.Z)(fe),(0,S.Z)(B.i)).includes(oe):B.i.includes(oe)}function m(oe){return z.includes(oe)}},79676:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return m}});var S=R(19447);function B(oe,H,me,Ae){if(Ae===!1)return{adjustX:!1,adjustY:!1};const Pe=Ae&&typeof Ae=="object"?Ae:{},ce={};switch(oe){case"top":case"bottom":ce.shiftX=H.dropdownArrowOffset*2+me;break;case"left":case"right":ce.shiftY=H.dropdownArrowOffsetVertical*2+me;break}const I=Object.assign(Object.assign({},ce),Pe);return I.shiftX||(I.adjustX=!0),I.shiftY||(I.adjustY=!0),I}const fe={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"]}},z={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 m(oe){const{arrowWidth:H,autoAdjustOverflow:me,arrowPointAtCenter:Ae,offset:Pe,borderRadius:ce,visibleFirst:I}=oe,j=H/2,ct={};return Object.keys(fe).forEach(Re=>{const De=Ae&&z[Re]||fe[Re],K=Object.assign(Object.assign({},De),{offset:[0,0]});switch(ct[Re]=K,A.has(Re)&&(K.autoArrow=!1),Re){case"top":case"topLeft":case"topRight":K.offset[1]=-j-Pe;break;case"bottom":case"bottomLeft":case"bottomRight":K.offset[1]=j+Pe;break;case"left":case"leftTop":case"leftBottom":K.offset[0]=-j-Pe;break;case"right":case"rightTop":case"rightBottom":K.offset[0]=j+Pe;break}const P=(0,S.fS)({contentRadius:ce,limitVerticalRadius:!0});if(Ae)switch(Re){case"topLeft":case"bottomLeft":K.offset[0]=-P.dropdownArrowOffset-j;break;case"topRight":case"bottomRight":K.offset[0]=P.dropdownArrowOffset+j;break;case"leftTop":case"rightTop":K.offset[1]=-P.dropdownArrowOffset-j;break;case"leftBottom":case"rightBottom":K.offset[1]=P.dropdownArrowOffset+j;break}K.overflow=B(Re,P,H,me),I&&(K.htmlRegion="visibleFirst")}),ct}},91857:function(Wt,ze,R){"use strict";var S=R(59301),B=R(38819),fe=R(92310),z=R.n(fe),A=R(31561),m=R(70425),oe=R(18929),H=R(2738),me=R(79676),Ae=R(53487),Pe=R(92343),ce=R(36355),I=R(20834),j=R(40875),ct=R(88088),Re=R(47211);const De=null,K=X=>{const{menu:de,arrow:ve,prefixCls:Z,children:Oe,trigger:He,disabled:Qe,dropdownRender:xe,getPopupContainer:ee,overlayClassName:Q,rootClassName:ie,open:N,onOpenChange:we,visible:je,onVisibleChange:Ee,mouseEnterDelay:_e=.15,mouseLeaveDelay:Me=.1,autoAdjustOverflow:Be=!0,placement:Fe="",overlay:Ze,transitionName:ot}=X,{getPopupContainer:mt,getPrefixCls:Et,direction:wt}=S.useContext(ce.E_),Gt=S.useMemo(()=>{const le=Et();return ot!==void 0?ot:Fe.includes("top")?`${le}-slide-down`:`${le}-slide-up`},[Et,Fe,ot]),gt=S.useMemo(()=>Fe?Fe.includes("Center")?Fe.slice(0,Fe.indexOf("Center")):Fe:wt==="rtl"?"bottomRight":"bottomLeft",[Fe,wt]),bt=Et("dropdown",Z),[$e,Vt]=(0,Re.Z)(bt),[,Zt]=(0,ct.Z)(),Ht=S.Children.only(Oe),k=(0,Pe.Tm)(Ht,{className:z()(`${bt}-trigger`,{[`${bt}-rtl`]:wt==="rtl"},Ht.props.className),disabled:Qe}),C=Qe?[]:He;let x;C&&C.includes("contextMenu")&&(x=!0);const[D,$]=(0,oe.Z)(!1,{value:N!=null?N:je}),ae=(0,m.useEvent)(le=>{we==null||we(le),Ee==null||Ee(le),$(le)}),w=z()(Q,ie,Vt,{[`${bt}-rtl`]:wt==="rtl"}),V=(0,me.Z)({arrowPointAtCenter:typeof ve=="object"&&ve.pointAtCenter,autoAdjustOverflow:Be,offset:Zt.marginXXS,arrowWidth:ve?Zt.sizePopupArrow:0,borderRadius:Zt.borderRadius}),W=S.useCallback(()=>{$(!1)},[]),O=()=>{let le;return de!=null&&de.items?le=S.createElement(I.default,Object.assign({},de)):typeof Ze=="function"?le=Ze():le=Ze,xe&&(le=xe(le)),le=S.Children.only(typeof le=="string"?S.createElement("span",null,le):le),S.createElement(j.J,{prefixCls:`${bt}-menu`,expandIcon:S.createElement("span",{className:`${bt}-menu-submenu-arrow`},S.createElement(B.Z,{className:`${bt}-menu-submenu-arrow-icon`})),mode:"vertical",selectable:!1,onClick:W,validator:Le=>{let{mode:We}=Le}},le)};return $e(S.createElement(A.Z,Object.assign({alignPoint:x},(0,H.Z)(X,["rootClassName"]),{mouseEnterDelay:_e,mouseLeaveDelay:Me,visible:D,builtinPlacements:V,arrow:!!ve,overlayClassName:w,prefixCls:bt,getPopupContainer:ee||mt,transitionName:Gt,trigger:C,overlay:O,placement:gt,onVisibleChange:ae}),k))};function P(X){return Object.assign(Object.assign({},X),{align:{overflow:{adjustX:!1,adjustY:!1}}})}const F=(0,Ae.Z)(K,"dropdown",X=>X,P),Y=X=>S.createElement(F,Object.assign({},X),S.createElement("span",null));K._InternalPanelDoNotUseOrYouWillBeFired=Y,ze.Z=K},38854:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return ct}});var S=R(91857),B=R(92310),fe=R.n(B),z=R(59301),A=R(18785),m=R(3113),oe=R(36355),H=R(81327),me=R(33234),Ae=R(47211),Pe=function(Re,De){var K={};for(var P in Re)Object.prototype.hasOwnProperty.call(Re,P)&&De.indexOf(P)<0&&(K[P]=Re[P]);if(Re!=null&&typeof Object.getOwnPropertySymbols=="function")for(var F=0,P=Object.getOwnPropertySymbols(Re);F<P.length;F++)De.indexOf(P[F])<0&&Object.prototype.propertyIsEnumerable.call(Re,P[F])&&(K[P[F]]=Re[P[F]]);return K};const ce=Re=>{const{getPopupContainer:De,getPrefixCls:K,direction:P}=z.useContext(oe.E_),{prefixCls:F,type:Y="default",danger:X,disabled:de,loading:ve,onClick:Z,htmlType:Oe,children:He,className:Qe,menu:xe,arrow:ee,autoFocus:Q,overlay:ie,trigger:N,align:we,open:je,onOpenChange:Ee,placement:_e,getPopupContainer:Me,href:Be,icon:Fe=z.createElement(A.Z,null),title:Ze,buttonsRender:ot=O=>O,mouseEnterDelay:mt,mouseLeaveDelay:Et,overlayClassName:wt,overlayStyle:Gt,destroyPopupOnHide:gt,dropdownRender:bt}=Re,$e=Pe(Re,["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"]),Vt=K("dropdown",F),Zt=`${Vt}-button`,[Ht,k]=(0,Ae.Z)(Vt),C={menu:xe,arrow:ee,autoFocus:Q,align:we,disabled:de,trigger:de?[]:N,onOpenChange:Ee,getPopupContainer:Me||De,mouseEnterDelay:mt,mouseLeaveDelay:Et,overlayClassName:wt,overlayStyle:Gt,destroyPopupOnHide:gt,dropdownRender:bt},{compactSize:x,compactItemClassnames:D}=(0,me.ri)(Vt,P),$=fe()(Zt,D,Qe,k);"overlay"in Re&&(C.overlay=ie),"open"in Re&&(C.open=je),"placement"in Re?C.placement=_e:C.placement=P==="rtl"?"bottomLeft":"bottomRight";const ae=z.createElement(m.ZP,{type:Y,danger:X,disabled:de,loading:ve,onClick:Z,htmlType:Oe,href:Be,title:Ze},He),w=z.createElement(m.ZP,{type:Y,danger:X,icon:Fe}),[V,W]=ot([ae,w]);return Ht(z.createElement(H.Z.Compact,Object.assign({className:$,size:x,block:!0},$e),V,z.createElement(S.Z,Object.assign({},C),W)))};ce.__ANT_BUTTON=!0;var I=ce;const j=S.Z;j.Button=I;var ct=j},47211:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return Pe}});var S=R(17313),B=R(13826),fe=R(92899),z=R(29878),A=R(19447),m=R(83116),oe=R(37613),me=ce=>{const{componentCls:I,menuCls:j,colorError:ct,colorTextLightSolid:Re}=ce,De=`${j}-item`;return{[`${I}, ${I}-menu-submenu`]:{[`${j} ${De}`]:{[`&${De}-danger:not(${De}-disabled)`]:{color:ct,"&:hover":{color:Re,backgroundColor:ct}}}}}};const Ae=ce=>{const{componentCls:I,menuCls:j,zIndexPopup:ct,dropdownArrowDistance:Re,sizePopupArrow:De,antCls:K,iconCls:P,motionDurationMid:F,dropdownPaddingVertical:Y,fontSize:X,dropdownEdgeChildPadding:de,colorTextDisabled:ve,fontSizeIcon:Z,controlPaddingHorizontal:Oe,colorBgElevated:He}=ce;return[{[I]:Object.assign(Object.assign({},(0,S.Wf)(ce)),{position:"absolute",top:-9999,left:{_skip_check_:!0,value:-9999},zIndex:ct,display:"block","&::before":{position:"absolute",insetBlock:-Re+De/2,zIndex:-9999,opacity:1e-4,content:'""'},[`&-trigger${K}-btn`]:{[`& > ${P}-down, & > ${K}-btn-icon > ${P}-down`]:{fontSize:Z}},[`${I}-wrap`]:{position:"relative",[`${K}-btn > ${P}-down`]:{fontSize:Z},[`${P}-down::before`]:{transition:`transform ${F}`}},[`${I}-wrap-open`]:{[`${P}-down::before`]:{transform:"rotate(180deg)"}},"\n &-hidden,\n &-menu-hidden,\n &-menu-submenu-hidden\n ":{display:"none"},[`&${K}-slide-down-enter${K}-slide-down-enter-active${I}-placement-bottomLeft,
|
|
&${K}-slide-down-appear${K}-slide-down-appear-active${I}-placement-bottomLeft,
|
|
&${K}-slide-down-enter${K}-slide-down-enter-active${I}-placement-bottom,
|
|
&${K}-slide-down-appear${K}-slide-down-appear-active${I}-placement-bottom,
|
|
&${K}-slide-down-enter${K}-slide-down-enter-active${I}-placement-bottomRight,
|
|
&${K}-slide-down-appear${K}-slide-down-appear-active${I}-placement-bottomRight`]:{animationName:B.fJ},[`&${K}-slide-up-enter${K}-slide-up-enter-active${I}-placement-topLeft,
|
|
&${K}-slide-up-appear${K}-slide-up-appear-active${I}-placement-topLeft,
|
|
&${K}-slide-up-enter${K}-slide-up-enter-active${I}-placement-top,
|
|
&${K}-slide-up-appear${K}-slide-up-appear-active${I}-placement-top,
|
|
&${K}-slide-up-enter${K}-slide-up-enter-active${I}-placement-topRight,
|
|
&${K}-slide-up-appear${K}-slide-up-appear-active${I}-placement-topRight`]:{animationName:B.Qt},[`&${K}-slide-down-leave${K}-slide-down-leave-active${I}-placement-bottomLeft,
|
|
&${K}-slide-down-leave${K}-slide-down-leave-active${I}-placement-bottom,
|
|
&${K}-slide-down-leave${K}-slide-down-leave-active${I}-placement-bottomRight`]:{animationName:B.Uw},[`&${K}-slide-up-leave${K}-slide-up-leave-active${I}-placement-topLeft,
|
|
&${K}-slide-up-leave${K}-slide-up-leave-active${I}-placement-top,
|
|
&${K}-slide-up-leave${K}-slide-up-leave-active${I}-placement-topRight`]:{animationName:B.ly}})},(0,A.ZP)(ce,{colorBg:He,limitVerticalRadius:!0,arrowPlacement:{top:!0,bottom:!0}}),{[`${I} ${j}`]:{position:"relative",margin:0},[`${j}-submenu-popup`]:{position:"absolute",zIndex:ct,background:"transparent",boxShadow:"none",transformOrigin:"0 0","ul, li":{listStyle:"none",margin:0}},[`${I}, ${I}-menu-submenu`]:{[j]:Object.assign(Object.assign({padding:de,listStyleType:"none",backgroundColor:He,backgroundClip:"padding-box",borderRadius:ce.borderRadiusLG,outline:"none",boxShadow:ce.boxShadowSecondary},(0,S.Qy)(ce)),{[`${j}-item-group-title`]:{padding:`${Y}px ${Oe}px`,color:ce.colorTextDescription,transition:`all ${F}`},[`${j}-item`]:{position:"relative",display:"flex",alignItems:"center"},[`${j}-item-icon`]:{minWidth:X,marginInlineEnd:ce.marginXS,fontSize:ce.fontSizeSM},[`${j}-title-content`]:{flex:"auto","> a":{color:"inherit",transition:`all ${F}`,"&:hover":{color:"inherit"},"&::after":{position:"absolute",inset:0,content:'""'}}},[`${j}-item, ${j}-submenu-title`]:Object.assign(Object.assign({clear:"both",margin:0,padding:`${Y}px ${Oe}px`,color:ce.colorText,fontWeight:"normal",fontSize:X,lineHeight:ce.lineHeight,cursor:"pointer",transition:`all ${F}`,borderRadius:ce.borderRadiusSM,"&:hover, &-active":{backgroundColor:ce.controlItemBgHover}},(0,S.Qy)(ce)),{"&-selected":{color:ce.colorPrimary,backgroundColor:ce.controlItemBgActive,"&:hover, &-active":{backgroundColor:ce.controlItemBgActiveHover}},"&-disabled":{color:ve,cursor:"not-allowed","&:hover":{color:ve,backgroundColor:He,cursor:"not-allowed"},a:{pointerEvents:"none"}},"&-divider":{height:1,margin:`${ce.marginXXS}px 0`,overflow:"hidden",lineHeight:0,backgroundColor:ce.colorSplit},[`${I}-menu-submenu-expand-icon`]:{position:"absolute",insetInlineEnd:ce.paddingXS,[`${I}-menu-submenu-arrow-icon`]:{marginInlineEnd:"0 !important",color:ce.colorTextDescription,fontSize:Z,fontStyle:"normal"}}}),[`${j}-item-group-list`]:{margin:`0 ${ce.marginXS}px`,padding:0,listStyle:"none"},[`${j}-submenu-title`]:{paddingInlineEnd:Oe+ce.fontSizeSM},[`${j}-submenu-vertical`]:{position:"relative"},[`${j}-submenu${j}-submenu-disabled ${I}-menu-submenu-title`]:{[`&, ${I}-menu-submenu-arrow-icon`]:{color:ve,backgroundColor:He,cursor:"not-allowed"}},[`${j}-submenu-selected ${I}-menu-submenu-title`]:{color:ce.colorPrimary}})}},[(0,B.oN)(ce,"slide-up"),(0,B.oN)(ce,"slide-down"),(0,fe.Fm)(ce,"move-up"),(0,fe.Fm)(ce,"move-down"),(0,z._y)(ce,"zoom-big")]]};var Pe=(0,m.Z)("Dropdown",(ce,I)=>{let{rootPrefixCls:j}=I;const{marginXXS:ct,sizePopupArrow:Re,controlHeight:De,fontSize:K,lineHeight:P,paddingXXS:F,componentCls:Y,borderRadiusLG:X}=ce,de=(De-K*P)/2,{dropdownArrowOffset:ve}=(0,A.fS)({contentRadius:X}),Z=(0,oe.TS)(ce,{menuCls:`${Y}-menu`,rootPrefixCls:j,dropdownArrowDistance:Re/2+ct,dropdownArrowOffset:ve,dropdownPaddingVertical:de,dropdownEdgeChildPadding:F});return[Ae(Z),me(Z)]},ce=>({zIndexPopup:ce.zIndexPopupBase+50}))},45818:function(Wt,ze,R){"use strict";R.d(ze,{D:function(){return F},Z:function(){return de}});var S=R(72308),B=R(59301),fe={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"},z=fe,A=R(7657),m=function(Z,Oe){return B.createElement(A.Z,(0,S.Z)({},Z,{ref:Oe,icon:z}))},oe=B.forwardRef(m),H=oe,me=R(33853),Ae=R(38819),Pe=R(92310),ce=R.n(Pe),I=R(2738),ct=ve=>!isNaN(parseFloat(ve))&&isFinite(ve),Re=R(36355),De=R(84966),K=function(ve,Z){var Oe={};for(var He in ve)Object.prototype.hasOwnProperty.call(ve,He)&&Z.indexOf(He)<0&&(Oe[He]=ve[He]);if(ve!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Qe=0,He=Object.getOwnPropertySymbols(ve);Qe<He.length;Qe++)Z.indexOf(He[Qe])<0&&Object.prototype.propertyIsEnumerable.call(ve,He[Qe])&&(Oe[He[Qe]]=ve[He[Qe]]);return Oe};const P={xs:"479.98px",sm:"575.98px",md:"767.98px",lg:"991.98px",xl:"1199.98px",xxl:"1599.98px"},F=B.createContext({}),Y=(()=>{let ve=0;return function(){let Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return ve+=1,`${Z}${ve}`}})();var de=B.forwardRef((ve,Z)=>{const{prefixCls:Oe,className:He,trigger:Qe,children:xe,defaultCollapsed:ee=!1,theme:Q="dark",style:ie={},collapsible:N=!1,reverseArrow:we=!1,width:je=200,collapsedWidth:Ee=80,zeroWidthTriggerStyle:_e,breakpoint:Me,onCollapse:Be,onBreakpoint:Fe}=ve,Ze=K(ve,["prefixCls","className","trigger","children","defaultCollapsed","theme","style","collapsible","reverseArrow","width","collapsedWidth","zeroWidthTriggerStyle","breakpoint","onCollapse","onBreakpoint"]),{siderHook:ot}=(0,B.useContext)(De.Gs),[mt,Et]=(0,B.useState)("collapsed"in ve?ve.collapsed:ee),[wt,Gt]=(0,B.useState)(!1);(0,B.useEffect)(()=>{"collapsed"in ve&&Et(ve.collapsed)},[ve.collapsed]);const gt=(k,C)=>{"collapsed"in ve||Et(k),Be==null||Be(k,C)},bt=(0,B.useRef)();bt.current=k=>{Gt(k.matches),Fe==null||Fe(k.matches),mt!==k.matches&>(k.matches,"responsive")},(0,B.useEffect)(()=>{function k(x){return bt.current(x)}let C;if(typeof window!="undefined"){const{matchMedia:x}=window;if(x&&Me&&Me in P){C=x(`(max-width: ${P[Me]})`);try{C.addEventListener("change",k)}catch(D){C.addListener(k)}k(C)}}return()=>{try{C==null||C.removeEventListener("change",k)}catch(x){C==null||C.removeListener(k)}}},[Me]),(0,B.useEffect)(()=>{const k=Y("ant-sider-");return ot.addSider(k),()=>ot.removeSider(k)},[]);const $e=()=>{gt(!mt,"clickTrigger")},{getPrefixCls:Vt}=(0,B.useContext)(Re.E_),Zt=()=>{const k=Vt("layout-sider",Oe),C=(0,I.Z)(Ze,["collapsed"]),x=mt?Ee:je,D=ct(x)?`${x}px`:String(x),$=parseFloat(String(Ee||0))===0?B.createElement("span",{onClick:$e,className:ce()(`${k}-zero-width-trigger`,`${k}-zero-width-trigger-${we?"right":"left"}`),style:_e},Qe||B.createElement(H,null)):null,V={expanded:we?B.createElement(Ae.Z,null):B.createElement(me.Z,null),collapsed:we?B.createElement(me.Z,null):B.createElement(Ae.Z,null)}[mt?"collapsed":"expanded"],W=Qe!==null?$||B.createElement("div",{className:`${k}-trigger`,onClick:$e,style:{width:D}},Qe||V):null,O=Object.assign(Object.assign({},ie),{flex:`0 0 ${D}`,maxWidth:D,minWidth:D,width:D}),le=ce()(k,`${k}-${Q}`,{[`${k}-collapsed`]:!!mt,[`${k}-has-trigger`]:N&&Qe!==null&&!$,[`${k}-below`]:!!wt,[`${k}-zero-width`]:parseFloat(D)===0},He);return B.createElement("aside",Object.assign({className:le},C,{style:O,ref:Z}),B.createElement("div",{className:`${k}-children`},xe),N||wt&&$?W:null)},Ht=B.useMemo(()=>({siderCollapsed:mt}),[mt]);return B.createElement(F.Provider,{value:Ht},Zt())})},84966:function(Wt,ze,R){"use strict";R.d(ze,{VY:function(){return F},$_:function(){return P},h4:function(){return K},Gs:function(){return I},ZP:function(){return Y}});var S=R(80702),B=R(92310),fe=R.n(B),z=R(2738),A=R(59301),m=R(36355),oe=R(83116),me=X=>{const{componentCls:de,bodyBg:ve,lightSiderBg:Z,lightTriggerBg:Oe,lightTriggerColor:He}=X;return{[`${de}-sider-light`]:{background:Z,[`${de}-sider-trigger`]:{color:He,background:Oe},[`${de}-sider-zero-width-trigger`]:{color:He,background:Oe,border:`1px solid ${ve}`,borderInlineStart:0}}}};const Ae=X=>{const{antCls:de,componentCls:ve,colorText:Z,triggerColor:Oe,footerBg:He,triggerBg:Qe,headerHeight:xe,headerPadding:ee,headerColor:Q,footerPadding:ie,triggerHeight:N,zeroTriggerHeight:we,zeroTriggerWidth:je,motionDurationMid:Ee,motionDurationSlow:_e,fontSize:Me,borderRadius:Be,bodyBg:Fe,headerBg:Ze,siderBg:ot}=X;return{[ve]:Object.assign(Object.assign({display:"flex",flex:"auto",flexDirection:"column",minHeight:0,background:Fe,"&, *":{boxSizing:"border-box"},[`&${ve}-has-sider`]:{flexDirection:"row",[`> ${ve}, > ${ve}-content`]:{width:0}},[`${ve}-header, &${ve}-footer`]:{flex:"0 0 auto"},[`${ve}-sider`]:{position:"relative",minWidth:0,background:ot,transition:`all ${Ee}, background 0s`,"&-children":{height:"100%",marginTop:-.1,paddingTop:.1,[`${de}-menu${de}-menu-inline-collapsed`]:{width:"auto"}},"&-has-trigger":{paddingBottom:N},"&-right":{order:1},"&-trigger":{position:"fixed",bottom:0,zIndex:1,height:N,color:Oe,lineHeight:`${N}px`,textAlign:"center",background:Qe,cursor:"pointer",transition:`all ${Ee}`},"&-zero-width":{"> *":{overflow:"hidden"},"&-trigger":{position:"absolute",top:xe,insetInlineEnd:-je,zIndex:1,width:je,height:we,color:Oe,fontSize:X.fontSizeXL,display:"flex",alignItems:"center",justifyContent:"center",background:ot,borderStartStartRadius:0,borderStartEndRadius:Be,borderEndEndRadius:Be,borderEndStartRadius:0,cursor:"pointer",transition:`background ${_e} ease`,"&::after":{position:"absolute",inset:0,background:"transparent",transition:`all ${_e}`,content:'""'},"&:hover::after":{background:"rgba(255, 255, 255, 0.2)"},"&-right":{insetInlineStart:-je,borderStartStartRadius:Be,borderStartEndRadius:0,borderEndEndRadius:0,borderEndStartRadius:Be}}}}},me(X)),{"&-rtl":{direction:"rtl"}}),[`${ve}-header`]:{height:xe,padding:ee,color:Q,lineHeight:`${xe}px`,background:Ze,[`${de}-menu`]:{lineHeight:"inherit"}},[`${ve}-footer`]:{padding:ie,color:Z,fontSize:Me,background:He},[`${ve}-content`]:{flex:"auto",minHeight:0}}};var Pe=(0,oe.Z)("Layout",X=>[Ae(X)],X=>{const{colorBgLayout:de,controlHeight:ve,controlHeightLG:Z,colorText:Oe,controlHeightSM:He,marginXXS:Qe,colorTextLightSolid:xe,colorBgContainer:ee}=X,Q=Z*1.25;return{colorBgHeader:"#001529",colorBgBody:de,colorBgTrigger:"#002140",bodyBg:de,headerBg:"#001529",headerHeight:ve*2,headerPadding:`0 ${Q}px`,headerColor:Oe,footerPadding:`${He}px ${Q}px`,footerBg:de,siderBg:"#001529",triggerHeight:Z+Qe*2,triggerBg:"#002140",triggerColor:xe,zeroTriggerWidth:Z,zeroTriggerHeight:Z,lightSiderBg:ee,lightTriggerBg:ee,lightTriggerColor:Oe}},{deprecatedTokens:[["colorBgBody","bodyBg"],["colorBgHeader","headerBg"],["colorBgTrigger","triggerBg"]]}),ce=function(X,de){var ve={};for(var Z in X)Object.prototype.hasOwnProperty.call(X,Z)&&de.indexOf(Z)<0&&(ve[Z]=X[Z]);if(X!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Oe=0,Z=Object.getOwnPropertySymbols(X);Oe<Z.length;Oe++)de.indexOf(Z[Oe])<0&&Object.prototype.propertyIsEnumerable.call(X,Z[Oe])&&(ve[Z[Oe]]=X[Z[Oe]]);return ve};const I=A.createContext({siderHook:{addSider:()=>null,removeSider:()=>null}});function j(X){let{suffixCls:de,tagName:ve,displayName:Z}=X;return Oe=>A.forwardRef((Qe,xe)=>A.createElement(Oe,Object.assign({ref:xe,suffixCls:de,tagName:ve},Qe)))}const ct=A.forwardRef((X,de)=>{const{prefixCls:ve,suffixCls:Z,className:Oe,tagName:He}=X,Qe=ce(X,["prefixCls","suffixCls","className","tagName"]),{getPrefixCls:xe}=A.useContext(m.E_),ee=xe("layout",ve),[Q,ie]=Pe(ee),N=Z?`${ee}-${Z}`:ee;return Q(A.createElement(He,Object.assign({className:fe()(ve||N,Oe,ie),ref:de},Qe)))}),Re=A.forwardRef((X,de)=>{const{direction:ve}=A.useContext(m.E_),[Z,Oe]=A.useState([]),{prefixCls:He,className:Qe,rootClassName:xe,children:ee,hasSider:Q,tagName:ie,style:N}=X,we=ce(X,["prefixCls","className","rootClassName","children","hasSider","tagName","style"]),je=(0,z.Z)(we,["suffixCls"]),{getPrefixCls:Ee,layout:_e}=A.useContext(m.E_),Me=Ee("layout",He),[Be,Fe]=Pe(Me),Ze=fe()(Me,{[`${Me}-has-sider`]:typeof Q=="boolean"?Q:Z.length>0,[`${Me}-rtl`]:ve==="rtl"},_e==null?void 0:_e.className,Qe,xe,Fe),ot=A.useMemo(()=>({siderHook:{addSider:mt=>{Oe(Et=>[].concat((0,S.Z)(Et),[mt]))},removeSider:mt=>{Oe(Et=>Et.filter(wt=>wt!==mt))}}}),[]);return Be(A.createElement(I.Provider,{value:ot},A.createElement(ie,Object.assign({ref:de,className:Ze,style:Object.assign(Object.assign({},_e==null?void 0:_e.style),N)},je),ee)))}),De=j({tagName:"div",displayName:"Layout"})(Re),K=j({suffixCls:"header",tagName:"header",displayName:"Header"})(ct),P=j({suffixCls:"footer",tagName:"footer",displayName:"Footer"})(ct),F=j({suffixCls:"content",tagName:"main",displayName:"Content"})(ct);var Y=De},40875:function(Wt,ze,R){"use strict";R.d(ze,{J:function(){return m}});var S=R(59301),B=R(33234),fe=R(70425),z=function(oe,H){var me={};for(var Ae in oe)Object.prototype.hasOwnProperty.call(oe,Ae)&&H.indexOf(Ae)<0&&(me[Ae]=oe[Ae]);if(oe!=null&&typeof Object.getOwnPropertySymbols=="function")for(var Pe=0,Ae=Object.getOwnPropertySymbols(oe);Pe<Ae.length;Pe++)H.indexOf(Ae[Pe])<0&&Object.prototype.propertyIsEnumerable.call(oe,Ae[Pe])&&(me[Ae[Pe]]=oe[Ae[Pe]]);return me};const A=S.createContext(null),m=S.forwardRef((oe,H)=>{const{children:me}=oe,Ae=z(oe,["children"]),Pe=S.useContext(A),ce=S.useMemo(()=>Object.assign(Object.assign({},Pe),Ae),[Pe,Ae.prefixCls,Ae.mode,Ae.selectable]);return S.createElement(A.Provider,{value:ce},S.createElement(B.BR,null,(0,fe.supportNodeRef)(me)?S.cloneElement(me,{ref:H}):me))});ze.Z=A},20834:function(Wt,ze,R){"use strict";R.d(ze,{default:function(){return Ht}});var S=R(15285),B=R(59301),fe=R(45818),z=R(92310),A=R.n(z),m=R(36355),oe=function(k,C){var x={};for(var D in k)Object.prototype.hasOwnProperty.call(k,D)&&C.indexOf(D)<0&&(x[D]=k[D]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var $=0,D=Object.getOwnPropertySymbols(k);$<D.length;$++)C.indexOf(D[$])<0&&Object.prototype.propertyIsEnumerable.call(k,D[$])&&(x[D[$]]=k[D[$]]);return x},me=k=>{const{prefixCls:C,className:x,dashed:D}=k,$=oe(k,["prefixCls","className","dashed"]),{getPrefixCls:ae}=B.useContext(m.E_),w=ae("menu",C),V=A()({[`${w}-item-divider-dashed`]:!!D},x);return B.createElement(S.iz,Object.assign({className:V},$))},Ae=R(11592),Pe=R(2738),ce=R(6848),I=R(92343),ct=(0,B.createContext)({prefixCls:"",firstLevel:!0,inlineCollapsed:!1}),De=k=>{var C;const{className:x,children:D,icon:$,title:ae,danger:w}=k,{prefixCls:V,firstLevel:W,direction:O,disableMenuItemTitleTooltip:le,inlineCollapsed:Le}=B.useContext(ct),We=It=>{const Ot=B.createElement("span",{className:`${V}-title-content`},D);return(!$||(0,I.l$)(D)&&D.type==="span")&&D&&It&&W&&typeof D=="string"?B.createElement("div",{className:`${V}-inline-collapsed-noicon`},D.charAt(0)):Ot},{siderCollapsed:Je}=B.useContext(fe.D);let ft=ae;typeof ae=="undefined"?ft=W?D:"":ae===!1&&(ft="");const nt={title:ft};!Je&&!Le&&(nt.title=null,nt.open=!1);const st=(0,Ae.Z)(D).length;let tt=B.createElement(S.ck,Object.assign({},(0,Pe.Z)(k,["title","icon","danger"]),{className:A()({[`${V}-item-danger`]:w,[`${V}-item-only-child`]:($?st+1:st)===1},x),title:typeof ae=="string"?ae:void 0}),(0,I.Tm)($,{className:A()((0,I.l$)($)?(C=$.props)===null||C===void 0?void 0:C.className:"",`${V}-item-icon`)}),We(Le));return le||(tt=B.createElement(ce.Z,Object.assign({},nt,{placement:O==="rtl"?"left":"right",overlayClassName:`${V}-inline-collapsed-tooltip`}),tt)),tt},P=k=>{var C;const{popupClassName:x,icon:D,title:$,theme:ae}=k,w=B.useContext(ct),{prefixCls:V,inlineCollapsed:W,theme:O}=w,le=(0,S.Xl)();let Le;if(!D)Le=W&&!le.length&&$&&typeof $=="string"?B.createElement("div",{className:`${V}-inline-collapsed-noicon`},$.charAt(0)):B.createElement("span",{className:`${V}-title-content`},$);else{const Je=(0,I.l$)($)&&$.type==="span";Le=B.createElement(B.Fragment,null,(0,I.Tm)(D,{className:A()((0,I.l$)(D)?(C=D.props)===null||C===void 0?void 0:C.className:"",`${V}-item-icon`)}),Je?$:B.createElement("span",{className:`${V}-title-content`},$))}const We=B.useMemo(()=>Object.assign(Object.assign({},w),{firstLevel:!1}),[w]);return B.createElement(ct.Provider,{value:We},B.createElement(S.Wd,Object.assign({},(0,Pe.Z)(k,["icon"]),{title:Le,popupClassName:A()(V,x,`${V}-${ae||O}`)})))},F=R(18785),Y=R(70425),X=R(62892),de=R(40875),ve=function(k,C){var x={};for(var D in k)Object.prototype.hasOwnProperty.call(k,D)&&C.indexOf(D)<0&&(x[D]=k[D]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var $=0,D=Object.getOwnPropertySymbols(k);$<D.length;$++)C.indexOf(D[$])<0&&Object.prototype.propertyIsEnumerable.call(k,D[$])&&(x[D[$]]=k[D[$]]);return x};function Z(k){return(k||[]).map((C,x)=>{if(C&&typeof C=="object"){const D=C,{label:$,children:ae,key:w,type:V}=D,W=ve(D,["label","children","key","type"]),O=w!=null?w:`tmp-${x}`;return ae||V==="group"?V==="group"?B.createElement(S.BW,Object.assign({key:O},W,{title:$}),Z(ae)):B.createElement(P,Object.assign({key:O},W,{title:$}),Z(ae)):V==="divider"?B.createElement(me,Object.assign({key:O},W)):B.createElement(De,Object.assign({key:O},W),$)}return null}).filter(C=>C)}function Oe(k){return B.useMemo(()=>k&&Z(k),[k])}var He=R(64993),Qe=R(17313),xe=R(8378),ee=R(13826),Q=R(29878),ie=R(83116),N=R(37613),je=k=>{const{componentCls:C,motionDurationSlow:x,horizontalLineHeight:D,colorSplit:$,lineWidth:ae,lineType:w,itemPaddingInline:V}=k;return{[`${C}-horizontal`]:{lineHeight:D,border:0,borderBottom:`${ae}px ${w} ${$}`,boxShadow:"none","&::after":{display:"block",clear:"both",height:0,content:'"\\20"'},[`${C}-item, ${C}-submenu`]:{position:"relative",display:"inline-block",verticalAlign:"bottom",paddingInline:V},[`> ${C}-item:hover,
|
|
> ${C}-item-active,
|
|
> ${C}-submenu ${C}-submenu-title:hover`]:{backgroundColor:"transparent"},[`${C}-item, ${C}-submenu-title`]:{transition:[`border-color ${x}`,`background ${x}`].join(",")},[`${C}-submenu-arrow`]:{display:"none"}}}},_e=k=>{let{componentCls:C,menuArrowOffset:x}=k;return{[`${C}-rtl`]:{direction:"rtl"},[`${C}-submenu-rtl`]:{transformOrigin:"100% 0"},[`${C}-rtl${C}-vertical,
|
|
${C}-submenu-rtl ${C}-vertical`]:{[`${C}-submenu-arrow`]:{"&::before":{transform:`rotate(-45deg) translateY(-${x})`},"&::after":{transform:`rotate(45deg) translateY(${x})`}}}}};const Me=k=>Object.assign({},(0,Qe.oN)(k));var Fe=(k,C)=>{const{componentCls:x,itemColor:D,itemSelectedColor:$,groupTitleColor:ae,itemBg:w,subMenuItemBg:V,itemSelectedBg:W,activeBarHeight:O,activeBarWidth:le,activeBarBorderWidth:Le,motionDurationSlow:We,motionEaseInOut:Je,motionEaseOut:ft,itemPaddingInline:nt,motionDurationMid:st,itemHoverColor:tt,lineType:It,colorSplit:Ot,itemDisabledColor:ge,dangerItemColor:ei,dangerItemHoverColor:ti,dangerItemSelectedColor:hi,dangerItemActiveBg:Xt,dangerItemSelectedBg:Ti,itemHoverBg:gi,itemActiveBg:Si,menuSubMenuBg:ii,horizontalItemSelectedColor:Mi,horizontalItemSelectedBg:Qt,horizontalItemBorderRadius:ut,horizontalItemHoverBg:_t,popupBg:si}=k;return{[`${x}-${C}, ${x}-${C} > ${x}`]:{color:D,background:w,[`&${x}-root:focus-visible`]:Object.assign({},Me(k)),[`${x}-item-group-title`]:{color:ae},[`${x}-submenu-selected`]:{[`> ${x}-submenu-title`]:{color:$}},[`${x}-item-disabled, ${x}-submenu-disabled`]:{color:`${ge} !important`},[`${x}-item:not(${x}-item-selected):not(${x}-submenu-selected)`]:{[`&:hover, > ${x}-submenu-title:hover`]:{color:tt}},[`&:not(${x}-horizontal)`]:{[`${x}-item:not(${x}-item-selected)`]:{"&:hover":{backgroundColor:gi},"&:active":{backgroundColor:Si}},[`${x}-submenu-title`]:{"&:hover":{backgroundColor:gi},"&:active":{backgroundColor:Si}}},[`${x}-item-danger`]:{color:ei,[`&${x}-item:hover`]:{[`&:not(${x}-item-selected):not(${x}-submenu-selected)`]:{color:ti}},[`&${x}-item:active`]:{background:Xt}},[`${x}-item a`]:{"&, &:hover":{color:"inherit"}},[`${x}-item-selected`]:{color:$,[`&${x}-item-danger`]:{color:hi},"a, a:hover":{color:"inherit"}},[`& ${x}-item-selected`]:{backgroundColor:W,[`&${x}-item-danger`]:{backgroundColor:Ti}},[`${x}-item, ${x}-submenu-title`]:{[`&:not(${x}-item-disabled):focus-visible`]:Object.assign({},Me(k))},[`&${x}-submenu > ${x}`]:{backgroundColor:ii},[`&${x}-popup > ${x}`]:{backgroundColor:si},[`&${x}-horizontal`]:Object.assign(Object.assign({},C==="dark"?{borderBottom:0}:{}),{[`> ${x}-item, > ${x}-submenu`]:{top:Le,marginTop:-Le,marginBottom:0,borderRadius:ut,"&::after":{position:"absolute",insetInline:nt,bottom:0,borderBottom:`${O}px solid transparent`,transition:`border-color ${We} ${Je}`,content:'""'},"&:hover, &-active, &-open":{background:_t,"&::after":{borderBottomWidth:O,borderBottomColor:Mi}},"&-selected":{color:Mi,backgroundColor:Qt,"&:hover":{backgroundColor:Qt},"&::after":{borderBottomWidth:O,borderBottomColor:Mi}}}}),[`&${x}-root`]:{[`&${x}-inline, &${x}-vertical`]:{borderInlineEnd:`${Le}px ${It} ${Ot}`}},[`&${x}-inline`]:{[`${x}-sub${x}-inline`]:{background:V},[`${x}-item, ${x}-submenu-title`]:Le&&le?{width:`calc(100% + ${Le}px)`}:{},[`${x}-item`]:{position:"relative","&::after":{position:"absolute",insetBlock:0,insetInlineEnd:0,borderInlineEnd:`${le}px solid ${$}`,transform:"scaleY(0.0001)",opacity:0,transition:[`transform ${st} ${ft}`,`opacity ${st} ${ft}`].join(","),content:'""'},[`&${x}-item-danger`]:{"&::after":{borderInlineEndColor:hi}}},[`${x}-selected, ${x}-item-selected`]:{"&::after":{transform:"scaleY(1)",opacity:1,transition:[`transform ${st} ${Je}`,`opacity ${st} ${Je}`].join(",")}}}}}};const Ze=k=>{const{componentCls:C,itemHeight:x,itemMarginInline:D,padding:$,menuArrowSize:ae,marginXS:w,itemMarginBlock:V}=k,W=$+ae+w;return{[`${C}-item`]:{position:"relative",overflow:"hidden"},[`${C}-item, ${C}-submenu-title`]:{height:x,lineHeight:`${x}px`,paddingInline:$,overflow:"hidden",textOverflow:"ellipsis",marginInline:D,marginBlock:V,width:`calc(100% - ${D*2}px)`},[`> ${C}-item,
|
|
> ${C}-submenu > ${C}-submenu-title`]:{height:x,lineHeight:`${x}px`},[`${C}-item-group-list ${C}-submenu-title,
|
|
${C}-submenu-title`]:{paddingInlineEnd:W}}};var mt=k=>{const{componentCls:C,iconCls:x,itemHeight:D,colorTextLightSolid:$,dropdownWidth:ae,controlHeightLG:w,motionDurationMid:V,motionEaseOut:W,paddingXL:O,itemMarginInline:le,fontSizeLG:Le,motionDurationSlow:We,paddingXS:Je,boxShadowSecondary:ft,collapsedWidth:nt,collapsedIconSize:st}=k,tt={height:D,lineHeight:`${D}px`,listStylePosition:"inside",listStyleType:"disc"};return[{[C]:{"&-inline, &-vertical":Object.assign({[`&${C}-root`]:{boxShadow:"none"}},Ze(k))},[`${C}-submenu-popup`]:{[`${C}-vertical`]:Object.assign(Object.assign({},Ze(k)),{boxShadow:ft})}},{[`${C}-submenu-popup ${C}-vertical${C}-sub`]:{minWidth:ae,maxHeight:`calc(100vh - ${w*2.5}px)`,padding:"0",overflow:"hidden",borderInlineEnd:0,"&:not([class*='-active'])":{overflowX:"hidden",overflowY:"auto"}}},{[`${C}-inline`]:{width:"100%",[`&${C}-root`]:{[`${C}-item, ${C}-submenu-title`]:{display:"flex",alignItems:"center",transition:[`border-color ${We}`,`background ${We}`,`padding ${V} ${W}`].join(","),[`> ${C}-title-content`]:{flex:"auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},"> *":{flex:"none"}}},[`${C}-sub${C}-inline`]:{padding:0,border:0,borderRadius:0,boxShadow:"none",[`& > ${C}-submenu > ${C}-submenu-title`]:tt,[`& ${C}-item-group-title`]:{paddingInlineStart:O}},[`${C}-item`]:tt}},{[`${C}-inline-collapsed`]:{width:nt,[`&${C}-root`]:{[`${C}-item, ${C}-submenu ${C}-submenu-title`]:{[`> ${C}-inline-collapsed-noicon`]:{fontSize:Le,textAlign:"center"}}},[`> ${C}-item,
|
|
> ${C}-item-group > ${C}-item-group-list > ${C}-item,
|
|
> ${C}-item-group > ${C}-item-group-list > ${C}-submenu > ${C}-submenu-title,
|
|
> ${C}-submenu > ${C}-submenu-title`]:{insetInlineStart:0,paddingInline:`calc(50% - ${Le/2}px - ${le}px)`,textOverflow:"clip",[`
|
|
${C}-submenu-arrow,
|
|
${C}-submenu-expand-icon
|
|
`]:{opacity:0},[`${C}-item-icon, ${x}`]:{margin:0,fontSize:st,lineHeight:`${D}px`,"+ span":{display:"inline-block",opacity:0}}},[`${C}-item-icon, ${x}`]:{display:"inline-block"},"&-tooltip":{pointerEvents:"none",[`${C}-item-icon, ${x}`]:{display:"none"},"a, a:hover":{color:$}},[`${C}-item-group-title`]:Object.assign(Object.assign({},Qe.vS),{paddingInline:Je})}}]};const Et=k=>{const{componentCls:C,motionDurationSlow:x,motionDurationMid:D,motionEaseInOut:$,motionEaseOut:ae,iconCls:w,iconSize:V,iconMarginInlineEnd:W}=k;return{[`${C}-item, ${C}-submenu-title`]:{position:"relative",display:"block",margin:0,whiteSpace:"nowrap",cursor:"pointer",transition:[`border-color ${x}`,`background ${x}`,`padding ${x} ${$}`].join(","),[`${C}-item-icon, ${w}`]:{minWidth:V,fontSize:V,transition:[`font-size ${D} ${ae}`,`margin ${x} ${$}`,`color ${x}`].join(","),"+ span":{marginInlineStart:W,opacity:1,transition:[`opacity ${x} ${$}`,`margin ${x}`,`color ${x}`].join(",")}},[`${C}-item-icon`]:Object.assign({},(0,Qe.Ro)()),[`&${C}-item-only-child`]:{[`> ${w}, > ${C}-item-icon`]:{marginInlineEnd:0}}},[`${C}-item-disabled, ${C}-submenu-disabled`]:{background:"none !important",cursor:"not-allowed","&::after":{borderColor:"transparent !important"},a:{color:"inherit !important"},[`> ${C}-submenu-title`]:{color:"inherit !important",cursor:"not-allowed"}}}},wt=k=>{const{componentCls:C,motionDurationSlow:x,motionEaseInOut:D,borderRadius:$,menuArrowSize:ae,menuArrowOffset:w}=k;return{[`${C}-submenu`]:{"&-expand-icon, &-arrow":{position:"absolute",top:"50%",insetInlineEnd:k.margin,width:ae,color:"currentcolor",transform:"translateY(-50%)",transition:`transform ${x} ${D}, opacity ${x}`},"&-arrow":{"&::before, &::after":{position:"absolute",width:ae*.6,height:ae*.15,backgroundColor:"currentcolor",borderRadius:$,transition:[`background ${x} ${D}`,`transform ${x} ${D}`,`top ${x} ${D}`,`color ${x} ${D}`].join(","),content:'""'},"&::before":{transform:`rotate(45deg) translateY(-${w})`},"&::after":{transform:`rotate(-45deg) translateY(${w})`}}}}},Gt=k=>{const{antCls:C,componentCls:x,fontSize:D,motionDurationSlow:$,motionDurationMid:ae,motionEaseInOut:w,paddingXS:V,padding:W,colorSplit:O,lineWidth:le,zIndexPopup:Le,borderRadiusLG:We,subMenuItemBorderRadius:Je,menuArrowSize:ft,menuArrowOffset:nt,lineType:st,menuPanelMaskInset:tt,groupTitleLineHeight:It,groupTitleFontSize:Ot}=k;return[{"":{[`${x}`]:Object.assign(Object.assign({},(0,Qe.dF)()),{"&-hidden":{display:"none"}})},[`${x}-submenu-hidden`]:{display:"none"}},{[x]:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},(0,Qe.Wf)(k)),(0,Qe.dF)()),{marginBottom:0,paddingInlineStart:0,fontSize:D,lineHeight:0,listStyle:"none",outline:"none",transition:`width ${$} cubic-bezier(0.2, 0, 0, 1) 0s`,"ul, ol":{margin:0,padding:0,listStyle:"none"},"&-overflow":{display:"flex",[`${x}-item`]:{flex:"none"}},[`${x}-item, ${x}-submenu, ${x}-submenu-title`]:{borderRadius:k.itemBorderRadius},[`${x}-item-group-title`]:{padding:`${V}px ${W}px`,fontSize:Ot,lineHeight:It,transition:`all ${$}`},[`&-horizontal ${x}-submenu`]:{transition:[`border-color ${$} ${w}`,`background ${$} ${w}`].join(",")},[`${x}-submenu, ${x}-submenu-inline`]:{transition:[`border-color ${$} ${w}`,`background ${$} ${w}`,`padding ${ae} ${w}`].join(",")},[`${x}-submenu ${x}-sub`]:{cursor:"initial",transition:[`background ${$} ${w}`,`padding ${$} ${w}`].join(",")},[`${x}-title-content`]:{transition:`color ${$}`},[`${x}-item a`]:{"&::before":{position:"absolute",inset:0,backgroundColor:"transparent",content:'""'}},[`${x}-item-divider`]:{overflow:"hidden",lineHeight:0,borderColor:O,borderStyle:st,borderWidth:0,borderTopWidth:le,marginBlock:le,padding:0,"&-dashed":{borderStyle:"dashed"}}}),Et(k)),{[`${x}-item-group`]:{[`${x}-item-group-list`]:{margin:0,padding:0,[`${x}-item, ${x}-submenu-title`]:{paddingInline:`${D*2}px ${W}px`}}},"&-submenu":{"&-popup":{position:"absolute",zIndex:Le,borderRadius:We,boxShadow:"none",transformOrigin:"0 0",[`&${x}-submenu`]:{background:"transparent"},"&::before":{position:"absolute",inset:`${tt}px 0 0`,zIndex:-1,width:"100%",height:"100%",opacity:0,content:'""'}},"&-placement-rightTop::before":{top:0,insetInlineStart:tt},"\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:k.paddingXS},"\n &-placement-rightTop,\n &-placement-rightBottom\n ":{paddingInlineStart:k.paddingXS},"\n &-placement-topRight,\n &-placement-topLeft\n ":{paddingBottom:k.paddingXS},"\n &-placement-bottomRight,\n &-placement-bottomLeft\n ":{paddingTop:k.paddingXS},[`> ${x}`]:Object.assign(Object.assign(Object.assign({borderRadius:We},Et(k)),wt(k)),{[`${x}-item, ${x}-submenu > ${x}-submenu-title`]:{borderRadius:Je},[`${x}-submenu-title::after`]:{transition:`transform ${$} ${w}`}})}}),wt(k)),{[`&-inline-collapsed ${x}-submenu-arrow,
|
|
&-inline ${x}-submenu-arrow`]:{"&::before":{transform:`rotate(-45deg) translateX(${nt})`},"&::after":{transform:`rotate(45deg) translateX(-${nt})`}},[`${x}-submenu-open${x}-submenu-inline > ${x}-submenu-title > ${x}-submenu-arrow`]:{transform:`translateY(-${ft*.2}px)`,"&::after":{transform:`rotate(-45deg) translateX(-${nt})`},"&::before":{transform:`rotate(45deg) translateX(${nt})`}}})},{[`${C}-layout-header`]:{[x]:{lineHeight:"inherit"}}}]};var gt=(k,C)=>(0,ie.Z)("Menu",D=>{if(C===!1)return[];const{colorBgElevated:$,colorPrimary:ae,colorTextLightSolid:w,controlHeightLG:V,fontSize:W,darkItemColor:O,darkDangerItemColor:le,darkItemBg:Le,darkSubMenuItemBg:We,darkItemSelectedColor:Je,darkItemSelectedBg:ft,darkDangerItemSelectedBg:nt,darkItemHoverBg:st,darkGroupTitleColor:tt,darkItemHoverColor:It,darkItemDisabledColor:Ot,darkDangerItemHoverColor:ge,darkDangerItemSelectedColor:ei,darkDangerItemActiveBg:ti}=D,hi=W/7*5,Xt=(0,N.TS)(D,{menuArrowSize:hi,menuHorizontalHeight:V*1.15,menuArrowOffset:`${hi*.25}px`,menuPanelMaskInset:-7,menuSubMenuBg:$}),Ti=(0,N.TS)(Xt,{itemColor:O,itemHoverColor:It,groupTitleColor:tt,itemSelectedColor:Je,itemBg:Le,popupBg:Le,subMenuItemBg:We,itemActiveBg:"transparent",itemSelectedBg:ft,activeBarHeight:0,activeBarBorderWidth:0,itemHoverBg:st,itemDisabledColor:Ot,dangerItemColor:le,dangerItemHoverColor:ge,dangerItemSelectedColor:ei,dangerItemActiveBg:ti,dangerItemSelectedBg:nt,menuSubMenuBg:We,horizontalItemSelectedColor:w,horizontalItemSelectedBg:ae});return[Gt(Xt),je(Xt),mt(Xt),Fe(Xt,"light"),Fe(Ti,"dark"),_e(Xt),(0,xe.Z)(Xt),(0,ee.oN)(Xt,"slide-up"),(0,ee.oN)(Xt,"slide-down"),(0,Q._y)(Xt,"zoom-big")]},D=>{const{colorPrimary:$,colorError:ae,colorTextDisabled:w,colorErrorBg:V,colorText:W,colorTextDescription:O,colorBgContainer:le,colorFillAlter:Le,colorFillContent:We,lineWidth:Je,lineWidthBold:ft,controlItemBgActive:nt,colorBgTextHover:st,controlHeightLG:tt,lineHeight:It,colorBgElevated:Ot,marginXXS:ge,padding:ei,fontSize:ti,controlHeightSM:hi,fontSizeLG:Xt,colorTextLightSolid:Ti,colorErrorHover:gi}=D,Si=new He.C(Ti).setAlpha(.65).toRgbString();return{dropdownWidth:160,zIndexPopup:D.zIndexPopupBase+50,radiusItem:D.borderRadiusLG,itemBorderRadius:D.borderRadiusLG,radiusSubMenuItem:D.borderRadiusSM,subMenuItemBorderRadius:D.borderRadiusSM,colorItemText:W,itemColor:W,colorItemTextHover:W,itemHoverColor:W,colorItemTextHoverHorizontal:$,horizontalItemHoverColor:$,colorGroupTitle:O,groupTitleColor:O,colorItemTextSelected:$,itemSelectedColor:$,colorItemTextSelectedHorizontal:$,horizontalItemSelectedColor:$,colorItemBg:le,itemBg:le,colorItemBgHover:st,itemHoverBg:st,colorItemBgActive:We,itemActiveBg:nt,colorSubItemBg:Le,subMenuItemBg:Le,colorItemBgSelected:nt,itemSelectedBg:nt,colorItemBgSelectedHorizontal:"transparent",horizontalItemSelectedBg:"transparent",colorActiveBarWidth:0,activeBarWidth:0,colorActiveBarHeight:ft,activeBarHeight:ft,colorActiveBarBorderSize:Je,activeBarBorderWidth:Je,colorItemTextDisabled:w,itemDisabledColor:w,colorDangerItemText:ae,dangerItemColor:ae,colorDangerItemTextHover:ae,dangerItemHoverColor:ae,colorDangerItemTextSelected:ae,dangerItemSelectedColor:ae,colorDangerItemBgActive:V,dangerItemActiveBg:V,colorDangerItemBgSelected:V,dangerItemSelectedBg:V,itemMarginInline:D.marginXXS,horizontalItemBorderRadius:0,horizontalItemHoverBg:"transparent",itemHeight:tt,groupTitleLineHeight:It,collapsedWidth:tt*2,popupBg:Ot,itemMarginBlock:ge,itemPaddingInline:ei,horizontalLineHeight:`${tt*1.15}px`,iconSize:ti,iconMarginInlineEnd:hi-ti,collapsedIconSize:Xt,groupTitleFontSize:ti,darkItemDisabledColor:new He.C(Ti).setAlpha(.25).toRgbString(),darkItemColor:Si,darkDangerItemColor:ae,darkItemBg:"#001529",darkSubMenuItemBg:"#000c17",darkItemSelectedColor:Ti,darkItemSelectedBg:$,darkDangerItemSelectedBg:ae,darkItemHoverBg:"transparent",darkGroupTitleColor:Si,darkItemHoverColor:Ti,darkDangerItemHoverColor:gi,darkDangerItemSelectedColor:Ti,darkDangerItemActiveBg:ae}},{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"]]})(k),bt=function(k,C){var x={};for(var D in k)Object.prototype.hasOwnProperty.call(k,D)&&C.indexOf(D)<0&&(x[D]=k[D]);if(k!=null&&typeof Object.getOwnPropertySymbols=="function")for(var $=0,D=Object.getOwnPropertySymbols(k);$<D.length;$++)C.indexOf(D[$])<0&&Object.prototype.propertyIsEnumerable.call(k,D[$])&&(x[D[$]]=k[D[$]]);return x},Vt=(0,B.forwardRef)((k,C)=>{var x,D;const $=B.useContext(de.Z),ae=$||{},{getPrefixCls:w,getPopupContainer:V,direction:W,menu:O}=B.useContext(m.E_),le=w(),{prefixCls:Le,className:We,style:Je,theme:ft="light",expandIcon:nt,_internalDisableMenuItemTitleTooltip:st,inlineCollapsed:tt,siderCollapsed:It,items:Ot,children:ge,rootClassName:ei,mode:ti,selectable:hi,onClick:Xt,overflowedIndicatorPopupClassName:Ti}=k,gi=bt(k,["prefixCls","className","style","theme","expandIcon","_internalDisableMenuItemTitleTooltip","inlineCollapsed","siderCollapsed","items","children","rootClassName","mode","selectable","onClick","overflowedIndicatorPopupClassName"]),Si=(0,Pe.Z)(gi,["collapsedWidth"]),ii=Oe(Ot)||ge;(x=ae.validator)===null||x===void 0||x.call(ae,{mode:ti});const Mi=(0,Y.useEvent)(function(){var ci;Xt==null||Xt.apply(void 0,arguments),(ci=ae.onClick)===null||ci===void 0||ci.call(ae)}),Qt=ae.mode||ti,ut=hi!=null?hi:ae.selectable,_t=B.useMemo(()=>It!==void 0?It:tt,[tt,It]),si={horizontal:{motionName:`${le}-slide-up`},inline:(0,X.Z)(le),other:{motionName:`${le}-zoom-big`}},At=w("menu",Le||ae.prefixCls),[bi,li]=gt(At,!$),_i=A()(`${At}-${ft}`,O==null?void 0:O.className,We);let pi;if(typeof nt=="function")pi=nt;else if(nt===null||nt===!1)pi=null;else if(ae.expandIcon===null||ae.expandIcon===!1)pi=null;else{const ci=nt!=null?nt:ae.expandIcon;pi=(0,I.Tm)(ci,{className:A()(`${At}-submenu-expand-icon`,(0,I.l$)(ci)?(D=ci.props)===null||D===void 0?void 0:D.className:"")})}const ri=B.useMemo(()=>({prefixCls:At,inlineCollapsed:_t||!1,direction:W,firstLevel:!0,theme:ft,mode:Qt,disableMenuItemTitleTooltip:st}),[At,_t,W,st,ft]);return bi(B.createElement(de.Z.Provider,{value:null},B.createElement(ct.Provider,{value:ri},B.createElement(S.ZP,Object.assign({getPopupContainer:V,overflowedIndicator:B.createElement(F.Z,null),overflowedIndicatorPopupClassName:A()(At,`${At}-${ft}`,Ti),mode:Qt,selectable:ut,onClick:Mi},Si,{inlineCollapsed:_t,style:Object.assign(Object.assign({},O==null?void 0:O.style),Je),className:_i,prefixCls:At,direction:W,defaultMotions:si,expandIcon:pi,ref:C,rootClassName:A()(ei,li)}),ii))))});const Zt=(0,B.forwardRef)((k,C)=>{const x=(0,B.useRef)(null),D=B.useContext(fe.D);return(0,B.useImperativeHandle)(C,()=>({menu:x.current,focus:$=>{var ae;(ae=x.current)===null||ae===void 0||ae.focus($)}})),B.createElement(Vt,Object.assign({ref:x},k,D))});Zt.Item=De,Zt.SubMenu=P,Zt.Divider=me,Zt.ItemGroup=S.BW;var Ht=Zt},61621:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return C}});var S=R(92310),B=R.n(S),fe=R(59301),z=R(36355),A=R(2738),oe=x=>{const{prefixCls:D,className:$,style:ae,size:w,shape:V}=x,W=B()({[`${D}-lg`]:w==="large",[`${D}-sm`]:w==="small"}),O=B()({[`${D}-circle`]:V==="circle",[`${D}-square`]:V==="square",[`${D}-round`]:V==="round"}),le=fe.useMemo(()=>typeof w=="number"?{width:w,height:w,lineHeight:`${w}px`}:{},[w]);return fe.createElement("span",{className:B()(D,W,O,$),style:Object.assign(Object.assign({},le),ae)})},H=R(93083),me=R(83116),Ae=R(37613);const Pe=new H.Keyframes("ant-skeleton-loading",{"0%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0 50%"}}),ce=x=>({height:x,lineHeight:`${x}px`}),I=x=>Object.assign({width:x},ce(x)),j=x=>({background:x.skeletonLoadingBackground,backgroundSize:"400% 100%",animationName:Pe,animationDuration:x.skeletonLoadingMotionDuration,animationTimingFunction:"ease",animationIterationCount:"infinite"}),ct=x=>Object.assign({width:x*5,minWidth:x*5},ce(x)),Re=x=>{const{skeletonAvatarCls:D,gradientFromColor:$,controlHeight:ae,controlHeightLG:w,controlHeightSM:V}=x;return{[`${D}`]:Object.assign({display:"inline-block",verticalAlign:"top",background:$},I(ae)),[`${D}${D}-circle`]:{borderRadius:"50%"},[`${D}${D}-lg`]:Object.assign({},I(w)),[`${D}${D}-sm`]:Object.assign({},I(V))}},De=x=>{const{controlHeight:D,borderRadiusSM:$,skeletonInputCls:ae,controlHeightLG:w,controlHeightSM:V,gradientFromColor:W}=x;return{[`${ae}`]:Object.assign({display:"inline-block",verticalAlign:"top",background:W,borderRadius:$},ct(D)),[`${ae}-lg`]:Object.assign({},ct(w)),[`${ae}-sm`]:Object.assign({},ct(V))}},K=x=>Object.assign({width:x},ce(x)),P=x=>{const{skeletonImageCls:D,imageSizeBase:$,gradientFromColor:ae,borderRadiusSM:w}=x;return{[`${D}`]:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"center",verticalAlign:"top",background:ae,borderRadius:w},K($*2)),{[`${D}-path`]:{fill:"#bfbfbf"},[`${D}-svg`]:Object.assign(Object.assign({},K($)),{maxWidth:$*4,maxHeight:$*4}),[`${D}-svg${D}-svg-circle`]:{borderRadius:"50%"}}),[`${D}${D}-circle`]:{borderRadius:"50%"}}},F=(x,D,$)=>{const{skeletonButtonCls:ae}=x;return{[`${$}${ae}-circle`]:{width:D,minWidth:D,borderRadius:"50%"},[`${$}${ae}-round`]:{borderRadius:D}}},Y=x=>Object.assign({width:x*2,minWidth:x*2},ce(x)),X=x=>{const{borderRadiusSM:D,skeletonButtonCls:$,controlHeight:ae,controlHeightLG:w,controlHeightSM:V,gradientFromColor:W}=x;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[`${$}`]:Object.assign({display:"inline-block",verticalAlign:"top",background:W,borderRadius:D,width:ae*2,minWidth:ae*2},Y(ae))},F(x,ae,$)),{[`${$}-lg`]:Object.assign({},Y(w))}),F(x,w,`${$}-lg`)),{[`${$}-sm`]:Object.assign({},Y(V))}),F(x,V,`${$}-sm`))},de=x=>{const{componentCls:D,skeletonAvatarCls:$,skeletonTitleCls:ae,skeletonParagraphCls:w,skeletonButtonCls:V,skeletonInputCls:W,skeletonImageCls:O,controlHeight:le,controlHeightLG:Le,controlHeightSM:We,gradientFromColor:Je,padding:ft,marginSM:nt,borderRadius:st,titleHeight:tt,blockRadius:It,paragraphLiHeight:Ot,controlHeightXS:ge,paragraphMarginTop:ei}=x;return{[`${D}`]:{display:"table",width:"100%",[`${D}-header`]:{display:"table-cell",paddingInlineEnd:ft,verticalAlign:"top",[`${$}`]:Object.assign({display:"inline-block",verticalAlign:"top",background:Je},I(le)),[`${$}-circle`]:{borderRadius:"50%"},[`${$}-lg`]:Object.assign({},I(Le)),[`${$}-sm`]:Object.assign({},I(We))},[`${D}-content`]:{display:"table-cell",width:"100%",verticalAlign:"top",[`${ae}`]:{width:"100%",height:tt,background:Je,borderRadius:It,[`+ ${w}`]:{marginBlockStart:We}},[`${w}`]:{padding:0,"> li":{width:"100%",height:Ot,listStyle:"none",background:Je,borderRadius:It,"+ li":{marginBlockStart:ge}}},[`${w}> li:last-child:not(:first-child):not(:nth-child(2))`]:{width:"61%"}},[`&-round ${D}-content`]:{[`${ae}, ${w} > li`]:{borderRadius:st}}},[`${D}-with-avatar ${D}-content`]:{[`${ae}`]:{marginBlockStart:nt,[`+ ${w}`]:{marginBlockStart:ei}}},[`${D}${D}-element`]:Object.assign(Object.assign(Object.assign(Object.assign({display:"inline-block",width:"auto"},X(x)),Re(x)),De(x)),P(x)),[`${D}${D}-block`]:{width:"100%",[`${V}`]:{width:"100%"},[`${W}`]:{width:"100%"}},[`${D}${D}-active`]:{[`
|
|
${ae},
|
|
${w} > li,
|
|
${$},
|
|
${V},
|
|
${W},
|
|
${O}
|
|
`]:Object.assign({},j(x))}}};var ve=(0,me.Z)("Skeleton",x=>{const{componentCls:D}=x,$=(0,Ae.TS)(x,{skeletonAvatarCls:`${D}-avatar`,skeletonTitleCls:`${D}-title`,skeletonParagraphCls:`${D}-paragraph`,skeletonButtonCls:`${D}-button`,skeletonInputCls:`${D}-input`,skeletonImageCls:`${D}-image`,imageSizeBase:x.controlHeight*1.5,borderRadius:100,skeletonLoadingBackground:`linear-gradient(90deg, ${x.gradientFromColor} 25%, ${x.gradientToColor} 37%, ${x.gradientFromColor} 63%)`,skeletonLoadingMotionDuration:"1.4s"});return[de($)]},x=>{const{colorFillContent:D,colorFill:$}=x,ae=D,w=$;return{color:ae,colorGradientEnd:w,gradientFromColor:ae,gradientToColor:w,titleHeight:x.controlHeight/2,blockRadius:x.borderRadiusSM,paragraphMarginTop:x.marginLG+x.marginXXS,paragraphLiHeight:x.controlHeight/2}},{deprecatedTokens:[["color","gradientFromColor"],["colorGradientEnd","gradientToColor"]]}),Oe=x=>{const{prefixCls:D,className:$,rootClassName:ae,active:w,shape:V="circle",size:W="default"}=x,{getPrefixCls:O}=fe.useContext(z.E_),le=O("skeleton",D),[Le,We]=ve(le),Je=(0,A.Z)(x,["prefixCls","className"]),ft=B()(le,`${le}-element`,{[`${le}-active`]:w},$,ae,We);return Le(fe.createElement("div",{className:ft},fe.createElement(oe,Object.assign({prefixCls:`${le}-avatar`,shape:V,size:W},Je))))},Qe=x=>{const{prefixCls:D,className:$,rootClassName:ae,active:w,block:V=!1,size:W="default"}=x,{getPrefixCls:O}=fe.useContext(z.E_),le=O("skeleton",D),[Le,We]=ve(le),Je=(0,A.Z)(x,["prefixCls"]),ft=B()(le,`${le}-element`,{[`${le}-active`]:w,[`${le}-block`]:V},$,ae,We);return Le(fe.createElement("div",{className:ft},fe.createElement(oe,Object.assign({prefixCls:`${le}-button`,size:W},Je))))};const xe="M365.714286 329.142857q0 45.714286-32.036571 77.677714t-77.677714 32.036571-77.677714-32.036571-32.036571-77.677714 32.036571-77.677714 77.677714-32.036571 77.677714 32.036571 32.036571 77.677714zM950.857143 548.571429l0 256-804.571429 0 0-109.714286 182.857143-182.857143 91.428571 91.428571 292.571429-292.571429zM1005.714286 146.285714l-914.285714 0q-7.460571 0-12.873143 5.412571t-5.412571 12.873143l0 694.857143q0 7.460571 5.412571 12.873143t12.873143 5.412571l914.285714 0q7.460571 0 12.873143-5.412571t5.412571-12.873143l0-694.857143q0-7.460571-5.412571-12.873143t-12.873143-5.412571zM1097.142857 164.571429l0 694.857143q0 37.741714-26.843429 64.585143t-64.585143 26.843429l-914.285714 0q-37.741714 0-64.585143-26.843429t-26.843429-64.585143l0-694.857143q0-37.741714 26.843429-64.585143t64.585143-26.843429l914.285714 0q37.741714 0 64.585143 26.843429t26.843429 64.585143z";var Q=x=>{const{prefixCls:D,className:$,rootClassName:ae,style:w,active:V}=x,{getPrefixCls:W}=fe.useContext(z.E_),O=W("skeleton",D),[le,Le]=ve(O),We=B()(O,`${O}-element`,{[`${O}-active`]:V},$,ae,Le);return le(fe.createElement("div",{className:We},fe.createElement("div",{className:B()(`${O}-image`,$),style:w},fe.createElement("svg",{viewBox:"0 0 1098 1024",xmlns:"http://www.w3.org/2000/svg",className:`${O}-image-svg`},fe.createElement("path",{d:xe,className:`${O}-image-path`})))))},N=x=>{const{prefixCls:D,className:$,rootClassName:ae,active:w,block:V,size:W="default"}=x,{getPrefixCls:O}=fe.useContext(z.E_),le=O("skeleton",D),[Le,We]=ve(le),Je=(0,A.Z)(x,["prefixCls"]),ft=B()(le,`${le}-element`,{[`${le}-active`]:w,[`${le}-block`]:V},$,ae,We);return Le(fe.createElement("div",{className:ft},fe.createElement(oe,Object.assign({prefixCls:`${le}-input`,size:W},Je))))},we=R(72308),je={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M888 792H200V168c0-4.4-3.6-8-8-8h-56c-4.4 0-8 3.6-8 8v688c0 4.4 3.6 8 8 8h752c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM288 604a64 64 0 10128 0 64 64 0 10-128 0zm118-224a48 48 0 1096 0 48 48 0 10-96 0zm158 228a96 96 0 10192 0 96 96 0 10-192 0zm148-314a56 56 0 10112 0 56 56 0 10-112 0z"}}]},name:"dot-chart",theme:"outlined"},Ee=je,_e=R(7657),Me=function(D,$){return fe.createElement(_e.Z,(0,we.Z)({},D,{ref:$,icon:Ee}))},Be=fe.forwardRef(Me),Fe=Be,ot=x=>{const{prefixCls:D,className:$,rootClassName:ae,style:w,active:V,children:W}=x,{getPrefixCls:O}=fe.useContext(z.E_),le=O("skeleton",D),[Le,We]=ve(le),Je=B()(le,`${le}-element`,{[`${le}-active`]:V},We,$,ae),ft=W!=null?W:fe.createElement(Fe,null);return Le(fe.createElement("div",{className:Je},fe.createElement("div",{className:B()(`${le}-image`,$),style:w},ft)))},mt=R(80702),wt=x=>{const D=O=>{const{width:le,rows:Le=2}=x;if(Array.isArray(le))return le[O];if(Le-1===O)return le},{prefixCls:$,className:ae,style:w,rows:V}=x,W=(0,mt.Z)(Array(V)).map((O,le)=>fe.createElement("li",{key:le,style:{width:D(le)}}));return fe.createElement("ul",{className:B()($,ae),style:w},W)},gt=x=>{let{prefixCls:D,className:$,width:ae,style:w}=x;return fe.createElement("h3",{className:B()(D,$),style:Object.assign({width:ae},w)})};function bt(x){return x&&typeof x=="object"?x:{}}function $e(x,D){return x&&!D?{size:"large",shape:"square"}:{size:"large",shape:"circle"}}function Vt(x,D){return!x&&D?{width:"38%"}:x&&D?{width:"50%"}:{}}function Zt(x,D){const $={};return(!x||!D)&&($.width="61%"),!x&&D?$.rows=3:$.rows=2,$}const Ht=x=>{const{prefixCls:D,loading:$,className:ae,rootClassName:w,style:V,children:W,avatar:O=!1,title:le=!0,paragraph:Le=!0,active:We,round:Je}=x,{getPrefixCls:ft,direction:nt,skeleton:st}=fe.useContext(z.E_),tt=ft("skeleton",D),[It,Ot]=ve(tt);if($||!("loading"in x)){const ge=!!O,ei=!!le,ti=!!Le;let hi;if(ge){const gi=Object.assign(Object.assign({prefixCls:`${tt}-avatar`},$e(ei,ti)),bt(O));hi=fe.createElement("div",{className:`${tt}-header`},fe.createElement(oe,Object.assign({},gi)))}let Xt;if(ei||ti){let gi;if(ei){const ii=Object.assign(Object.assign({prefixCls:`${tt}-title`},Vt(ge,ti)),bt(le));gi=fe.createElement(gt,Object.assign({},ii))}let Si;if(ti){const ii=Object.assign(Object.assign({prefixCls:`${tt}-paragraph`},Zt(ge,ei)),bt(Le));Si=fe.createElement(wt,Object.assign({},ii))}Xt=fe.createElement("div",{className:`${tt}-content`},gi,Si)}const Ti=B()(tt,{[`${tt}-with-avatar`]:ge,[`${tt}-active`]:We,[`${tt}-rtl`]:nt==="rtl",[`${tt}-round`]:Je},st==null?void 0:st.className,ae,w,Ot);return It(fe.createElement("div",{className:Ti,style:Object.assign(Object.assign({},st==null?void 0:st.style),V)},hi,Xt))}return typeof W!="undefined"?W:null};Ht.Button=Qe,Ht.Avatar=Oe,Ht.Input=N,Ht.Image=Q,Ht.Node=ot;var k=Ht,C=k},81327:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return De}});var S=R(59301),B=R(92310),fe=R.n(B),z=R(11592),A=R(36355),m=R(33234);const oe=S.createContext({latestIndex:0}),H=oe.Provider;var Ae=K=>{let{className:P,index:F,children:Y,split:X,style:de}=K;const{latestIndex:ve}=S.useContext(oe);return Y==null?null:S.createElement(S.Fragment,null,S.createElement("div",{className:P,style:de},Y),F<ve&&X&&S.createElement("span",{className:`${P}-split`},X))},Pe=R(2856);function ce(K){return["small","middle","large"].includes(K)}function I(K){return K?typeof K=="number"&&!Number.isNaN(K):!1}var j=function(K,P){var F={};for(var Y in K)Object.prototype.hasOwnProperty.call(K,Y)&&P.indexOf(Y)<0&&(F[Y]=K[Y]);if(K!=null&&typeof Object.getOwnPropertySymbols=="function")for(var X=0,Y=Object.getOwnPropertySymbols(K);X<Y.length;X++)P.indexOf(Y[X])<0&&Object.prototype.propertyIsEnumerable.call(K,Y[X])&&(F[Y[X]]=K[Y[X]]);return F};const Re=S.forwardRef((K,P)=>{var F,Y;const{getPrefixCls:X,space:de,direction:ve}=S.useContext(A.E_),{size:Z=(de==null?void 0:de.size)||"small",align:Oe,className:He,rootClassName:Qe,children:xe,direction:ee="horizontal",prefixCls:Q,split:ie,style:N,wrap:we=!1,classNames:je,styles:Ee}=K,_e=j(K,["size","align","className","rootClassName","children","direction","prefixCls","split","style","wrap","classNames","styles"]),[Me,Be]=Array.isArray(Z)?Z:[Z,Z],Fe=ce(Be),Ze=ce(Me),ot=I(Be),mt=I(Me),Et=(0,z.Z)(xe,{keepEmpty:!0}),wt=Oe===void 0&&ee==="horizontal"?"center":Oe,Gt=X("space",Q),[gt,bt]=(0,Pe.Z)(Gt),$e=fe()(Gt,de==null?void 0:de.className,bt,`${Gt}-${ee}`,{[`${Gt}-rtl`]:ve==="rtl",[`${Gt}-align-${wt}`]:wt,[`${Gt}-gap-row-${Be}`]:Fe,[`${Gt}-gap-col-${Me}`]:Ze},He,Qe),Vt=fe()(`${Gt}-item`,(F=je==null?void 0:je.item)!==null&&F!==void 0?F:(Y=de==null?void 0:de.classNames)===null||Y===void 0?void 0:Y.item);let Zt=0;const Ht=Et.map((x,D)=>{var $,ae;x!=null&&(Zt=D);const w=x&&x.key||`${Vt}-${D}`;return S.createElement(Ae,{className:Vt,key:w,index:D,split:ie,style:($=Ee==null?void 0:Ee.item)!==null&&$!==void 0?$:(ae=de==null?void 0:de.styles)===null||ae===void 0?void 0:ae.item},x)}),k=S.useMemo(()=>({latestIndex:Zt}),[Zt]);if(Et.length===0)return null;const C={};return we&&(C.flexWrap="wrap"),!Ze&&mt&&(C.columnGap=Me),!Fe&&ot&&(C.rowGap=Be),gt(S.createElement("div",Object.assign({ref:P,className:$e,style:Object.assign(Object.assign(Object.assign({},C),de==null?void 0:de.style),N)},_e),S.createElement(H,{value:k},Ht)))});Re.Compact=m.ZP;var De=Re},8378:function(Wt,ze){"use strict";const R=S=>({[S.componentCls]:{[`${S.antCls}-motion-collapse-legacy`]:{overflow:"hidden","&-active":{transition:`height ${S.motionDurationMid} ${S.motionEaseInOut},
|
|
opacity ${S.motionDurationMid} ${S.motionEaseInOut} !important`}},[`${S.antCls}-motion-collapse`]:{overflow:"hidden",transition:`height ${S.motionDurationMid} ${S.motionEaseInOut},
|
|
opacity ${S.motionDurationMid} ${S.motionEaseInOut} !important`}}});ze.Z=R},92899:function(Wt,ze,R){"use strict";R.d(ze,{Fm:function(){return ce}});var S=R(93083),B=R(95406);const fe=new S.Keyframes("antMoveDownIn",{"0%":{transform:"translate3d(0, 100%, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),z=new S.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 S.Keyframes("antMoveLeftIn",{"0%":{transform:"translate3d(-100%, 0, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),m=new S.Keyframes("antMoveLeftOut",{"0%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1},"100%":{transform:"translate3d(-100%, 0, 0)",transformOrigin:"0 0",opacity:0}}),oe=new S.Keyframes("antMoveRightIn",{"0%":{transform:"translate3d(100%, 0, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),H=new S.Keyframes("antMoveRightOut",{"0%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1},"100%":{transform:"translate3d(100%, 0, 0)",transformOrigin:"0 0",opacity:0}}),me=new S.Keyframes("antMoveUpIn",{"0%":{transform:"translate3d(0, -100%, 0)",transformOrigin:"0 0",opacity:0},"100%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1}}),Ae=new S.Keyframes("antMoveUpOut",{"0%":{transform:"translate3d(0, 0, 0)",transformOrigin:"0 0",opacity:1},"100%":{transform:"translate3d(0, -100%, 0)",transformOrigin:"0 0",opacity:0}}),Pe={"move-up":{inKeyframes:me,outKeyframes:Ae},"move-down":{inKeyframes:fe,outKeyframes:z},"move-left":{inKeyframes:A,outKeyframes:m},"move-right":{inKeyframes:oe,outKeyframes:H}},ce=(I,j)=>{const{antCls:ct}=I,Re=`${ct}-${j}`,{inKeyframes:De,outKeyframes:K}=Pe[j];return[(0,B.R)(Re,De,K,I.motionDurationMid),{[`
|
|
${Re}-enter,
|
|
${Re}-appear
|
|
`]:{opacity:0,animationTimingFunction:I.motionEaseOutCirc},[`${Re}-leave`]:{animationTimingFunction:I.motionEaseInOutCirc}}]}},13826:function(Wt,ze,R){"use strict";R.d(ze,{Qt:function(){return A},Uw:function(){return z},fJ:function(){return fe},ly:function(){return m},oN:function(){return ce}});var S=R(93083),B=R(95406);const fe=new S.Keyframes("antSlideUpIn",{"0%":{transform:"scaleY(0.8)",transformOrigin:"0% 0%",opacity:0},"100%":{transform:"scaleY(1)",transformOrigin:"0% 0%",opacity:1}}),z=new S.Keyframes("antSlideUpOut",{"0%":{transform:"scaleY(1)",transformOrigin:"0% 0%",opacity:1},"100%":{transform:"scaleY(0.8)",transformOrigin:"0% 0%",opacity:0}}),A=new S.Keyframes("antSlideDownIn",{"0%":{transform:"scaleY(0.8)",transformOrigin:"100% 100%",opacity:0},"100%":{transform:"scaleY(1)",transformOrigin:"100% 100%",opacity:1}}),m=new S.Keyframes("antSlideDownOut",{"0%":{transform:"scaleY(1)",transformOrigin:"100% 100%",opacity:1},"100%":{transform:"scaleY(0.8)",transformOrigin:"100% 100%",opacity:0}}),oe=new S.Keyframes("antSlideLeftIn",{"0%":{transform:"scaleX(0.8)",transformOrigin:"0% 0%",opacity:0},"100%":{transform:"scaleX(1)",transformOrigin:"0% 0%",opacity:1}}),H=new S.Keyframes("antSlideLeftOut",{"0%":{transform:"scaleX(1)",transformOrigin:"0% 0%",opacity:1},"100%":{transform:"scaleX(0.8)",transformOrigin:"0% 0%",opacity:0}}),me=new S.Keyframes("antSlideRightIn",{"0%":{transform:"scaleX(0.8)",transformOrigin:"100% 0%",opacity:0},"100%":{transform:"scaleX(1)",transformOrigin:"100% 0%",opacity:1}}),Ae=new S.Keyframes("antSlideRightOut",{"0%":{transform:"scaleX(1)",transformOrigin:"100% 0%",opacity:1},"100%":{transform:"scaleX(0.8)",transformOrigin:"100% 0%",opacity:0}}),Pe={"slide-up":{inKeyframes:fe,outKeyframes:z},"slide-down":{inKeyframes:A,outKeyframes:m},"slide-left":{inKeyframes:oe,outKeyframes:H},"slide-right":{inKeyframes:me,outKeyframes:Ae}},ce=(I,j)=>{const{antCls:ct}=I,Re=`${ct}-${j}`,{inKeyframes:De,outKeyframes:K}=Pe[j];return[(0,B.R)(Re,De,K,I.motionDurationMid),{[`
|
|
${Re}-enter,
|
|
${Re}-appear
|
|
`]:{transform:"scale(0)",transformOrigin:"0% 0%",opacity:0,animationTimingFunction:I.motionEaseOutQuint,"&-prepare":{transform:"scale(1)"}},[`${Re}-leave`]:{animationTimingFunction:I.motionEaseInQuint}}]}},19447:function(Wt,ze,R){"use strict";R.d(ze,{ZP:function(){return A},fS:function(){return fe},qN:function(){return B}});var S=R(47585);const B=8;function fe(m){const oe=B,{contentRadius:H,limitVerticalRadius:me}=m,Ae=H>12?H+2:12;return{dropdownArrowOffset:Ae,dropdownArrowOffsetVertical:me?oe:Ae}}function z(m,oe){return m?oe:{}}function A(m,oe){const{componentCls:H,sizePopupArrow:me,borderRadiusXS:Ae,borderRadiusOuter:Pe,boxShadowPopoverArrow:ce}=m,{colorBg:I,contentRadius:j=m.borderRadiusLG,limitVerticalRadius:ct,arrowDistance:Re=0,arrowPlacement:De={left:!0,right:!0,top:!0,bottom:!0}}=oe,{dropdownArrowOffsetVertical:K,dropdownArrowOffset:P}=fe({contentRadius:j,limitVerticalRadius:ct});return{[H]:Object.assign(Object.assign(Object.assign(Object.assign({[`${H}-arrow`]:[Object.assign(Object.assign({position:"absolute",zIndex:1,display:"block"},(0,S.r)(me,Ae,Pe,I,ce)),{"&:before":{background:I}})]},z(!!De.top,{[[`&-placement-top ${H}-arrow`,`&-placement-topLeft ${H}-arrow`,`&-placement-topRight ${H}-arrow`].join(",")]:{bottom:Re,transform:"translateY(100%) rotate(180deg)"},[`&-placement-top ${H}-arrow`]:{left:{_skip_check_:!0,value:"50%"},transform:"translateX(-50%) translateY(100%) rotate(180deg)"},[`&-placement-topLeft ${H}-arrow`]:{left:{_skip_check_:!0,value:P}},[`&-placement-topRight ${H}-arrow`]:{right:{_skip_check_:!0,value:P}}})),z(!!De.bottom,{[[`&-placement-bottom ${H}-arrow`,`&-placement-bottomLeft ${H}-arrow`,`&-placement-bottomRight ${H}-arrow`].join(",")]:{top:Re,transform:"translateY(-100%)"},[`&-placement-bottom ${H}-arrow`]:{left:{_skip_check_:!0,value:"50%"},transform:"translateX(-50%) translateY(-100%)"},[`&-placement-bottomLeft ${H}-arrow`]:{left:{_skip_check_:!0,value:P}},[`&-placement-bottomRight ${H}-arrow`]:{right:{_skip_check_:!0,value:P}}})),z(!!De.left,{[[`&-placement-left ${H}-arrow`,`&-placement-leftTop ${H}-arrow`,`&-placement-leftBottom ${H}-arrow`].join(",")]:{right:{_skip_check_:!0,value:Re},transform:"translateX(100%) rotate(90deg)"},[`&-placement-left ${H}-arrow`]:{top:{_skip_check_:!0,value:"50%"},transform:"translateY(-50%) translateX(100%) rotate(90deg)"},[`&-placement-leftTop ${H}-arrow`]:{top:K},[`&-placement-leftBottom ${H}-arrow`]:{bottom:K}})),z(!!De.right,{[[`&-placement-right ${H}-arrow`,`&-placement-rightTop ${H}-arrow`,`&-placement-rightBottom ${H}-arrow`].join(",")]:{left:{_skip_check_:!0,value:Re},transform:"translateX(-100%) rotate(-90deg)"},[`&-placement-right ${H}-arrow`]:{top:{_skip_check_:!0,value:"50%"},transform:"translateY(-50%) translateX(-100%) rotate(-90deg)"},[`&-placement-rightTop ${H}-arrow`]:{top:K},[`&-placement-rightBottom ${H}-arrow`]:{bottom:K}}))}}},47585:function(Wt,ze,R){"use strict";R.d(ze,{r:function(){return S}});const S=(B,fe,z,A,m)=>{const oe=B/2,H=0,me=oe,Ae=z*1/Math.sqrt(2),Pe=oe-z*(1-1/Math.sqrt(2)),ce=oe-fe*(1/Math.sqrt(2)),I=z*(Math.sqrt(2)-1)+fe*(1/Math.sqrt(2)),j=2*oe-ce,ct=I,Re=2*oe-Ae,De=Pe,K=2*oe-H,P=me,F=oe*Math.sqrt(2)+z*(Math.sqrt(2)-2),Y=z*(Math.sqrt(2)-1);return{pointerEvents:"none",width:B,height:B,overflow:"hidden","&::before":{position:"absolute",bottom:0,insetInlineStart:0,width:B,height:B/2,background:A,clipPath:{_multi_value_:!0,value:[`polygon(${Y}px 100%, 50% ${Y}px, ${2*oe-Y}px 100%, ${Y}px 100%)`,`path('M ${H} ${me} A ${z} ${z} 0 0 0 ${Ae} ${Pe} L ${ce} ${I} A ${fe} ${fe} 0 0 1 ${j} ${ct} L ${Re} ${De} A ${z} ${z} 0 0 0 ${K} ${P} Z')`]},content:'""'},"&::after":{content:'""',position:"absolute",width:F,height:F,bottom:0,insetInline:0,margin:"auto",borderRadius:{_skip_check_:!0,value:`0 0 ${fe}px 0`},transform:"translateY(50%) rotate(-135deg)",boxShadow:m,zIndex:0,background:"transparent"}}}},33166:function(Wt,ze,R){"use strict";R.d(ze,{i:function(){return S}});const S=["blue","purple","cyan","green","magenta","pink","red","orange","yellow","volcano","geekblue","lime","gold"]},45157:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return B}});var S=R(33166);function B(fe,z){return S.i.reduce((A,m)=>{const oe=fe[`${m}1`],H=fe[`${m}3`],me=fe[`${m}6`],Ae=fe[`${m}7`];return Object.assign(Object.assign({},A),z(m,{lightColor:oe,lightBorderColor:H,darkColor:me,textColor:Ae}))},{})}},6848:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return Qe}});var S=R(59301),B=R(92310),fe=R.n(B),z=R(55477),A=R(18929),m=R(62892),oe=R(79676),H=R(92343),me=R(36355),Ae=R(33234),Pe=R(88088),ce=R(17313),I=R(29878),j=R(19447),ct=R(45157),Re=R(37613),De=R(83116);const K=xe=>{const{componentCls:ee,tooltipMaxWidth:Q,tooltipColor:ie,tooltipBg:N,tooltipBorderRadius:we,zIndexPopup:je,controlHeight:Ee,boxShadowSecondary:_e,paddingSM:Me,paddingXS:Be,tooltipRadiusOuter:Fe}=xe;return[{[ee]:Object.assign(Object.assign(Object.assign(Object.assign({},(0,ce.Wf)(xe)),{position:"absolute",zIndex:je,display:"block",width:"max-content",maxWidth:Q,visibility:"visible",transformOrigin:"var(--arrow-x, 50%) var(--arrow-y, 50%)","&-hidden":{display:"none"},"--antd-arrow-background-color":N,[`${ee}-inner`]:{minWidth:Ee,minHeight:Ee,padding:`${Me/2}px ${Be}px`,color:ie,textAlign:"start",textDecoration:"none",wordWrap:"break-word",backgroundColor:N,borderRadius:we,boxShadow:_e,boxSizing:"border-box"},[["&-placement-left","&-placement-leftTop","&-placement-leftBottom","&-placement-right","&-placement-rightTop","&-placement-rightBottom"].join(",")]:{[`${ee}-inner`]:{borderRadius:Math.min(we,j.qN)}},[`${ee}-content`]:{position:"relative"}}),(0,ct.Z)(xe,(Ze,ot)=>{let{darkColor:mt}=ot;return{[`&${ee}-${Ze}`]:{[`${ee}-inner`]:{backgroundColor:mt},[`${ee}-arrow`]:{"--antd-arrow-background-color":mt}}}})),{"&-rtl":{direction:"rtl"}})},(0,j.ZP)((0,Re.TS)(xe,{borderRadiusOuter:Fe}),{colorBg:"var(--antd-arrow-background-color)",contentRadius:we,limitVerticalRadius:!0}),{[`${ee}-pure`]:{position:"relative",maxWidth:"none",margin:xe.sizePopupArrow}}]};var P=(xe,ee)=>(0,De.Z)("Tooltip",ie=>{if(ee===!1)return[];const{borderRadius:N,colorTextLightSolid:we,colorBgDefault:je,borderRadiusOuter:Ee}=ie,_e=(0,Re.TS)(ie,{tooltipMaxWidth:250,tooltipColor:we,tooltipBorderRadius:N,tooltipBg:je,tooltipRadiusOuter:Ee>4?4:Ee});return[K(_e),(0,I._y)(ie,"zoom-big-fast")]},ie=>{let{zIndexPopupBase:N,colorBgSpotlight:we}=ie;return{zIndexPopup:N+70,colorBgDefault:we}},{resetStyle:!1})(xe),F=R(36785);function Y(xe,ee){const Q=(0,F.o2)(ee),ie=fe()({[`${xe}-${ee}`]:ee&&Q}),N={},we={};return ee&&!Q&&(N.background=ee,we["--antd-arrow-background-color"]=ee),{className:ie,overlayStyle:N,arrowStyle:we}}var de=xe=>{const{prefixCls:ee,className:Q,placement:ie="top",title:N,color:we,overlayInnerStyle:je}=xe,{getPrefixCls:Ee}=S.useContext(me.E_),_e=Ee("tooltip",ee),[Me,Be]=P(_e,!0),Fe=Y(_e,we),Ze=Fe.arrowStyle,ot=Object.assign(Object.assign({},je),Fe.overlayStyle),mt=fe()(Be,_e,`${_e}-pure`,`${_e}-placement-${ie}`,Q,Fe.className);return Me(S.createElement("div",{className:mt,style:Ze},S.createElement("div",{className:`${_e}-arrow`}),S.createElement(z.G,Object.assign({},xe,{className:Be,prefixCls:_e,overlayInnerStyle:ot}),N)))},ve=function(xe,ee){var Q={};for(var ie in xe)Object.prototype.hasOwnProperty.call(xe,ie)&&ee.indexOf(ie)<0&&(Q[ie]=xe[ie]);if(xe!=null&&typeof Object.getOwnPropertySymbols=="function")for(var N=0,ie=Object.getOwnPropertySymbols(xe);N<ie.length;N++)ee.indexOf(ie[N])<0&&Object.prototype.propertyIsEnumerable.call(xe,ie[N])&&(Q[ie[N]]=xe[ie[N]]);return Q};const Z=(xe,ee)=>{const Q={},ie=Object.assign({},xe);return ee.forEach(N=>{xe&&N in xe&&(Q[N]=xe[N],delete ie[N])}),{picked:Q,omitted:ie}};function Oe(xe,ee){const Q=xe.type;if((Q.__ANT_BUTTON===!0||xe.type==="button")&&xe.props.disabled||Q.__ANT_SWITCH===!0&&(xe.props.disabled||xe.props.loading)||Q.__ANT_RADIO===!0&&xe.props.disabled){const{picked:ie,omitted:N}=Z(xe.props.style,["position","left","right","top","bottom","float","display","zIndex"]),we=Object.assign(Object.assign({display:"inline-block"},ie),{cursor:"not-allowed",width:xe.props.block?"100%":void 0}),je=Object.assign(Object.assign({},N),{pointerEvents:"none"}),Ee=(0,H.Tm)(xe,{style:je,className:null});return S.createElement("span",{style:we,className:fe()(xe.props.className,`${ee}-disabled-compatible-wrapper`)},Ee)}return xe}const He=S.forwardRef((xe,ee)=>{var Q,ie;const{prefixCls:N,openClassName:we,getTooltipContainer:je,overlayClassName:Ee,color:_e,overlayInnerStyle:Me,children:Be,afterOpenChange:Fe,afterVisibleChange:Ze,destroyTooltipOnHide:ot,arrow:mt=!0,title:Et,overlay:wt,builtinPlacements:Gt,arrowPointAtCenter:gt=!1,autoAdjustOverflow:bt=!0}=xe,$e=!!mt,[,Vt]=(0,Pe.Z)(),{getPopupContainer:Zt,getPrefixCls:Ht,direction:k}=S.useContext(me.E_),C=S.useRef(null),x=()=>{var Qt;(Qt=C.current)===null||Qt===void 0||Qt.forceAlign()};S.useImperativeHandle(ee,()=>({forceAlign:x,forcePopupAlign:()=>{x()}}));const[D,$]=(0,A.Z)(!1,{value:(Q=xe.open)!==null&&Q!==void 0?Q:xe.visible,defaultValue:(ie=xe.defaultOpen)!==null&&ie!==void 0?ie:xe.defaultVisible}),ae=!Et&&!wt&&Et!==0,w=Qt=>{var ut,_t;$(ae?!1:Qt),ae||((ut=xe.onOpenChange)===null||ut===void 0||ut.call(xe,Qt),(_t=xe.onVisibleChange)===null||_t===void 0||_t.call(xe,Qt))},V=S.useMemo(()=>{var Qt,ut;let _t=gt;return typeof mt=="object"&&(_t=(ut=(Qt=mt.pointAtCenter)!==null&&Qt!==void 0?Qt:mt.arrowPointAtCenter)!==null&&ut!==void 0?ut:gt),Gt||(0,oe.Z)({arrowPointAtCenter:_t,autoAdjustOverflow:bt,arrowWidth:$e?Vt.sizePopupArrow:0,borderRadius:Vt.borderRadius,offset:Vt.marginXXS,visibleFirst:!0})},[gt,mt,Gt,Vt]),W=S.useMemo(()=>Et===0?Et:wt||Et||"",[wt,Et]),O=S.createElement(Ae.BR,null,typeof W=="function"?W():W),{getPopupContainer:le,placement:Le="top",mouseEnterDelay:We=.1,mouseLeaveDelay:Je=.1,overlayStyle:ft,rootClassName:nt}=xe,st=ve(xe,["getPopupContainer","placement","mouseEnterDelay","mouseLeaveDelay","overlayStyle","rootClassName"]),tt=Ht("tooltip",N),It=Ht(),Ot=xe["data-popover-inject"];let ge=D;!("open"in xe)&&!("visible"in xe)&&ae&&(ge=!1);const ei=Oe((0,H.l$)(Be)&&!(0,H.M2)(Be)?Be:S.createElement("span",null,Be),tt),ti=ei.props,hi=!ti.className||typeof ti.className=="string"?fe()(ti.className,we||`${tt}-open`):ti.className,[Xt,Ti]=P(tt,!Ot),gi=Y(tt,_e),Si=gi.arrowStyle,ii=Object.assign(Object.assign({},Me),gi.overlayStyle),Mi=fe()(Ee,{[`${tt}-rtl`]:k==="rtl"},gi.className,nt,Ti);return Xt(S.createElement(z.Z,Object.assign({},st,{showArrow:$e,placement:Le,mouseEnterDelay:We,mouseLeaveDelay:Je,prefixCls:tt,overlayClassName:Mi,overlayStyle:Object.assign(Object.assign({},Si),ft),getTooltipContainer:le||je||Zt,ref:C,builtinPlacements:V,overlay:O,visible:ge,onVisibleChange:w,afterVisibleChange:Fe!=null?Fe:Ze,overlayInnerStyle:ii,arrowContent:S.createElement("span",{className:`${tt}-arrow-content`}),motion:{motionName:(0,m.m)(It,"zoom-big-fast",xe.transitionName),motionDeadline:1e3},destroyTooltipOnHide:!!ot}),ge?(0,H.Tm)(ei,{className:hi}):ei))});He._InternalPanelDoNotUseOrYouWillBeFired=de;var Qe=He},25769:function(Wt,ze,R){"use strict";var S=R(98040),B={"text/plain":"Text","text/html":"Url",default:"Text"},fe="Copy to clipboard: #{key}, Enter";function z(m){var oe=(/mac os x/i.test(navigator.userAgent)?"\u2318":"Ctrl")+"+C";return m.replace(/#{\s*key\s*}/g,oe)}function A(m,oe){var H,me,Ae,Pe,ce,I,j=!1;oe||(oe={}),H=oe.debug||!1;try{Ae=S(),Pe=document.createRange(),ce=document.getSelection(),I=document.createElement("span"),I.textContent=m,I.ariaHidden="true",I.style.all="unset",I.style.position="fixed",I.style.top=0,I.style.clip="rect(0, 0, 0, 0)",I.style.whiteSpace="pre",I.style.webkitUserSelect="text",I.style.MozUserSelect="text",I.style.msUserSelect="text",I.style.userSelect="text",I.addEventListener("copy",function(Re){if(Re.stopPropagation(),oe.format)if(Re.preventDefault(),typeof Re.clipboardData=="undefined"){H&&console.warn("unable to use e.clipboardData"),H&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var De=B[oe.format]||B.default;window.clipboardData.setData(De,m)}else Re.clipboardData.clearData(),Re.clipboardData.setData(oe.format,m);oe.onCopy&&(Re.preventDefault(),oe.onCopy(Re.clipboardData))}),document.body.appendChild(I),Pe.selectNodeContents(I),ce.addRange(Pe);var ct=document.execCommand("copy");if(!ct)throw new Error("copy command was unsuccessful");j=!0}catch(Re){H&&console.error("unable to copy using execCommand: ",Re),H&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(oe.format||"text",m),oe.onCopy&&oe.onCopy(window.clipboardData),j=!0}catch(De){H&&console.error("unable to copy using clipboardData: ",De),H&&console.error("falling back to prompt"),me=z("message"in oe?oe.message:fe),window.prompt(me,m)}}finally{ce&&(typeof ce.removeRange=="function"?ce.removeRange(Pe):ce.removeAllRanges()),I&&document.body.removeChild(I),Ae()}return j}Wt.exports=A},3867:function(Wt,ze,R){var S=R(97671);(function(B,fe){Wt.exports=fe()})(this,function(){"use strict";function B(w){var V=typeof w;return w!==null&&(V==="object"||V==="function")}function fe(w){return typeof w=="function"}var z=void 0;Array.isArray?z=Array.isArray:z=function(w){return Object.prototype.toString.call(w)==="[object Array]"};var A=z,m=0,oe=void 0,H=void 0,me=function(V,W){X[m]=V,X[m+1]=W,m+=2,m===2&&(H?H(de):Z())};function Ae(w){H=w}function Pe(w){me=w}var ce=typeof window!="undefined"?window:void 0,I=ce||{},j=I.MutationObserver||I.WebKitMutationObserver,ct=typeof self=="undefined"&&typeof S!="undefined"&&{}.toString.call(S)==="[object process]",Re=typeof Uint8ClampedArray!="undefined"&&typeof importScripts!="undefined"&&typeof MessageChannel!="undefined";function De(){return function(){return S.nextTick(de)}}function K(){return typeof oe!="undefined"?function(){oe(de)}:Y()}function P(){var w=0,V=new j(de),W=document.createTextNode("");return V.observe(W,{characterData:!0}),function(){W.data=w=++w%2}}function F(){var w=new MessageChannel;return w.port1.onmessage=de,function(){return w.port2.postMessage(0)}}function Y(){var w=setTimeout;return function(){return w(de,1)}}var X=new Array(1e3);function de(){for(var w=0;w<m;w+=2){var V=X[w],W=X[w+1];V(W),X[w]=void 0,X[w+1]=void 0}m=0}function ve(){try{var w=Function("return this")().require("vertx");return oe=w.runOnLoop||w.runOnContext,K()}catch(V){return Y()}}var Z=void 0;ct?Z=De():j?Z=P():Re?Z=F():ce===void 0?Z=ve():Z=Y();function Oe(w,V){var W=this,O=new this.constructor(xe);O[Qe]===void 0&&$e(O);var le=W._state;if(le){var Le=arguments[le-1];me(function(){return wt(le,O,Le,W._result)})}else mt(W,O,w,V);return O}function He(w){var V=this;if(w&&typeof w=="object"&&w.constructor===V)return w;var W=new V(xe);return Be(W,w),W}var Qe=Math.random().toString(36).substring(2);function xe(){}var ee=void 0,Q=1,ie=2;function N(){return new TypeError("You cannot resolve a promise with itself")}function we(){return new TypeError("A promises callback cannot return that same promise.")}function je(w,V,W,O){try{w.call(V,W,O)}catch(le){return le}}function Ee(w,V,W){me(function(O){var le=!1,Le=je(W,V,function(We){le||(le=!0,V!==We?Be(O,We):Ze(O,We))},function(We){le||(le=!0,ot(O,We))},"Settle: "+(O._label||" unknown promise"));!le&&Le&&(le=!0,ot(O,Le))},w)}function _e(w,V){V._state===Q?Ze(w,V._result):V._state===ie?ot(w,V._result):mt(V,void 0,function(W){return Be(w,W)},function(W){return ot(w,W)})}function Me(w,V,W){V.constructor===w.constructor&&W===Oe&&V.constructor.resolve===He?_e(w,V):W===void 0?Ze(w,V):fe(W)?Ee(w,V,W):Ze(w,V)}function Be(w,V){if(w===V)ot(w,N());else if(B(V)){var W=void 0;try{W=V.then}catch(O){ot(w,O);return}Me(w,V,W)}else Ze(w,V)}function Fe(w){w._onerror&&w._onerror(w._result),Et(w)}function Ze(w,V){w._state===ee&&(w._result=V,w._state=Q,w._subscribers.length!==0&&me(Et,w))}function ot(w,V){w._state===ee&&(w._state=ie,w._result=V,me(Fe,w))}function mt(w,V,W,O){var le=w._subscribers,Le=le.length;w._onerror=null,le[Le]=V,le[Le+Q]=W,le[Le+ie]=O,Le===0&&w._state&&me(Et,w)}function Et(w){var V=w._subscribers,W=w._state;if(V.length!==0){for(var O=void 0,le=void 0,Le=w._result,We=0;We<V.length;We+=3)O=V[We],le=V[We+W],O?wt(W,O,le,Le):le(Le);w._subscribers.length=0}}function wt(w,V,W,O){var le=fe(W),Le=void 0,We=void 0,Je=!0;if(le){try{Le=W(O)}catch(ft){Je=!1,We=ft}if(V===Le){ot(V,we());return}}else Le=O;V._state!==ee||(le&&Je?Be(V,Le):Je===!1?ot(V,We):w===Q?Ze(V,Le):w===ie&&ot(V,Le))}function Gt(w,V){try{V(function(O){Be(w,O)},function(O){ot(w,O)})}catch(W){ot(w,W)}}var gt=0;function bt(){return gt++}function $e(w){w[Qe]=gt++,w._state=void 0,w._result=void 0,w._subscribers=[]}function Vt(){return new Error("Array Methods must be provided an Array")}var Zt=function(){function w(V,W){this._instanceConstructor=V,this.promise=new V(xe),this.promise[Qe]||$e(this.promise),A(W)?(this.length=W.length,this._remaining=W.length,this._result=new Array(this.length),this.length===0?Ze(this.promise,this._result):(this.length=this.length||0,this._enumerate(W),this._remaining===0&&Ze(this.promise,this._result))):ot(this.promise,Vt())}return w.prototype._enumerate=function(W){for(var O=0;this._state===ee&&O<W.length;O++)this._eachEntry(W[O],O)},w.prototype._eachEntry=function(W,O){var le=this._instanceConstructor,Le=le.resolve;if(Le===He){var We=void 0,Je=void 0,ft=!1;try{We=W.then}catch(st){ft=!0,Je=st}if(We===Oe&&W._state!==ee)this._settledAt(W._state,O,W._result);else if(typeof We!="function")this._remaining--,this._result[O]=W;else if(le===$){var nt=new le(xe);ft?ot(nt,Je):Me(nt,W,We),this._willSettleAt(nt,O)}else this._willSettleAt(new le(function(st){return st(W)}),O)}else this._willSettleAt(Le(W),O)},w.prototype._settledAt=function(W,O,le){var Le=this.promise;Le._state===ee&&(this._remaining--,W===ie?ot(Le,le):this._result[O]=le),this._remaining===0&&Ze(Le,this._result)},w.prototype._willSettleAt=function(W,O){var le=this;mt(W,void 0,function(Le){return le._settledAt(Q,O,Le)},function(Le){return le._settledAt(ie,O,Le)})},w}();function Ht(w){return new Zt(this,w).promise}function k(w){var V=this;return A(w)?new V(function(W,O){for(var le=w.length,Le=0;Le<le;Le++)V.resolve(w[Le]).then(W,O)}):new V(function(W,O){return O(new TypeError("You must pass an array to race."))})}function C(w){var V=this,W=new V(xe);return ot(W,w),W}function x(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function D(){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(V){this[Qe]=bt(),this._result=this._state=void 0,this._subscribers=[],xe!==V&&(typeof V!="function"&&x(),this instanceof w?Gt(this,V):D())}return w.prototype.catch=function(W){return this.then(null,W)},w.prototype.finally=function(W){var O=this,le=O.constructor;return fe(W)?O.then(function(Le){return le.resolve(W()).then(function(){return Le})},function(Le){return le.resolve(W()).then(function(){throw Le})}):O.then(W,W)},w}();$.prototype.then=Oe,$.all=Ht,$.race=k,$.resolve=He,$.reject=C,$._setScheduler=Ae,$._setAsap=Pe,$._asap=me;function ae(){var w=void 0;if(typeof R.g!="undefined")w=R.g;else if(typeof self!="undefined")w=self;else try{w=Function("return this")()}catch(O){throw new Error("polyfill failed because global object is unavailable in this environment")}var V=w.Promise;if(V){var W=null;try{W=Object.prototype.toString.call(V.resolve())}catch(O){}if(W==="[object Promise]"&&!V.cast)return}w.Promise=$}return $.polyfill=ae,$.Promise=$,$})},86204:function(Wt){"use strict";var ze=typeof Reflect=="object"?Reflect:null,R=ze&&typeof ze.apply=="function"?ze.apply:function(F,Y,X){return Function.prototype.apply.call(F,Y,X)},S;ze&&typeof ze.ownKeys=="function"?S=ze.ownKeys:Object.getOwnPropertySymbols?S=function(F){return Object.getOwnPropertyNames(F).concat(Object.getOwnPropertySymbols(F))}:S=function(F){return Object.getOwnPropertyNames(F)};function B(P){console&&console.warn&&console.warn(P)}var fe=Number.isNaN||function(F){return F!==F};function z(){z.init.call(this)}Wt.exports=z,Wt.exports.once=Re,z.EventEmitter=z,z.prototype._events=void 0,z.prototype._eventsCount=0,z.prototype._maxListeners=void 0;var A=10;function m(P){if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P)}Object.defineProperty(z,"defaultMaxListeners",{enumerable:!0,get:function(){return A},set:function(P){if(typeof P!="number"||P<0||fe(P))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+P+".");A=P}}),z.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},z.prototype.setMaxListeners=function(F){if(typeof F!="number"||F<0||fe(F))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+F+".");return this._maxListeners=F,this};function oe(P){return P._maxListeners===void 0?z.defaultMaxListeners:P._maxListeners}z.prototype.getMaxListeners=function(){return oe(this)},z.prototype.emit=function(F){for(var Y=[],X=1;X<arguments.length;X++)Y.push(arguments[X]);var de=F==="error",ve=this._events;if(ve!==void 0)de=de&&ve.error===void 0;else if(!de)return!1;if(de){var Z;if(Y.length>0&&(Z=Y[0]),Z instanceof Error)throw Z;var Oe=new Error("Unhandled error."+(Z?" ("+Z.message+")":""));throw Oe.context=Z,Oe}var He=ve[F];if(He===void 0)return!1;if(typeof He=="function")R(He,this,Y);else for(var Qe=He.length,xe=I(He,Qe),X=0;X<Qe;++X)R(xe[X],this,Y);return!0};function H(P,F,Y,X){var de,ve,Z;if(m(Y),ve=P._events,ve===void 0?(ve=P._events=Object.create(null),P._eventsCount=0):(ve.newListener!==void 0&&(P.emit("newListener",F,Y.listener?Y.listener:Y),ve=P._events),Z=ve[F]),Z===void 0)Z=ve[F]=Y,++P._eventsCount;else if(typeof Z=="function"?Z=ve[F]=X?[Y,Z]:[Z,Y]:X?Z.unshift(Y):Z.push(Y),de=oe(P),de>0&&Z.length>de&&!Z.warned){Z.warned=!0;var Oe=new Error("Possible EventEmitter memory leak detected. "+Z.length+" "+String(F)+" listeners added. Use emitter.setMaxListeners() to increase limit");Oe.name="MaxListenersExceededWarning",Oe.emitter=P,Oe.type=F,Oe.count=Z.length,B(Oe)}return P}z.prototype.addListener=function(F,Y){return H(this,F,Y,!1)},z.prototype.on=z.prototype.addListener,z.prototype.prependListener=function(F,Y){return H(this,F,Y,!0)};function me(){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 Ae(P,F,Y){var X={fired:!1,wrapFn:void 0,target:P,type:F,listener:Y},de=me.bind(X);return de.listener=Y,X.wrapFn=de,de}z.prototype.once=function(F,Y){return m(Y),this.on(F,Ae(this,F,Y)),this},z.prototype.prependOnceListener=function(F,Y){return m(Y),this.prependListener(F,Ae(this,F,Y)),this},z.prototype.removeListener=function(F,Y){var X,de,ve,Z,Oe;if(m(Y),de=this._events,de===void 0)return this;if(X=de[F],X===void 0)return this;if(X===Y||X.listener===Y)--this._eventsCount===0?this._events=Object.create(null):(delete de[F],de.removeListener&&this.emit("removeListener",F,X.listener||Y));else if(typeof X!="function"){for(ve=-1,Z=X.length-1;Z>=0;Z--)if(X[Z]===Y||X[Z].listener===Y){Oe=X[Z].listener,ve=Z;break}if(ve<0)return this;ve===0?X.shift():j(X,ve),X.length===1&&(de[F]=X[0]),de.removeListener!==void 0&&this.emit("removeListener",F,Oe||Y)}return this},z.prototype.off=z.prototype.removeListener,z.prototype.removeAllListeners=function(F){var Y,X,de;if(X=this._events,X===void 0)return this;if(X.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):X[F]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete X[F]),this;if(arguments.length===0){var ve=Object.keys(X),Z;for(de=0;de<ve.length;++de)Z=ve[de],Z!=="removeListener"&&this.removeAllListeners(Z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(Y=X[F],typeof Y=="function")this.removeListener(F,Y);else if(Y!==void 0)for(de=Y.length-1;de>=0;de--)this.removeListener(F,Y[de]);return this};function Pe(P,F,Y){var X=P._events;if(X===void 0)return[];var de=X[F];return de===void 0?[]:typeof de=="function"?Y?[de.listener||de]:[de]:Y?ct(de):I(de,de.length)}z.prototype.listeners=function(F){return Pe(this,F,!0)},z.prototype.rawListeners=function(F){return Pe(this,F,!1)},z.listenerCount=function(P,F){return typeof P.listenerCount=="function"?P.listenerCount(F):ce.call(P,F)},z.prototype.listenerCount=ce;function ce(P){var F=this._events;if(F!==void 0){var Y=F[P];if(typeof Y=="function")return 1;if(Y!==void 0)return Y.length}return 0}z.prototype.eventNames=function(){return this._eventsCount>0?S(this._events):[]};function I(P,F){for(var Y=new Array(F),X=0;X<F;++X)Y[X]=P[X];return Y}function j(P,F){for(;F+1<P.length;F++)P[F]=P[F+1];P.pop()}function ct(P){for(var F=new Array(P.length),Y=0;Y<F.length;++Y)F[Y]=P[Y].listener||P[Y];return F}function Re(P,F){return new Promise(function(Y,X){function de(Z){P.removeListener(F,ve),X(Z)}function ve(){typeof P.removeListener=="function"&&P.removeListener("error",de),Y([].slice.call(arguments))}K(P,F,ve,{once:!0}),F!=="error"&&De(P,de,{once:!0})})}function De(P,F,Y){typeof P.on=="function"&&K(P,"error",F,Y)}function K(P,F,Y,X){if(typeof P.on=="function")X.once?P.once(F,Y):P.on(F,Y);else if(typeof P.addEventListener=="function")P.addEventListener(F,function de(ve){X.once&&P.removeEventListener(F,de),Y(ve)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof P)}},31561:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return ve}});var S=R(72308),B=R(49618),fe=R(52487),z=R(74416),A=R(35593),m=R(92310),oe=R.n(m),H=R(8654),me=R(59301),Ae=R(10228),Pe=R(16089),ce=Ae.Z.ESC,I=Ae.Z.TAB;function j(Z){var Oe=Z.visible,He=Z.triggerRef,Qe=Z.onVisibleChange,xe=Z.autoFocus,ee=Z.overlayRef,Q=me.useRef(!1),ie=function(){if(Oe){var Ee,_e;(Ee=He.current)===null||Ee===void 0||(_e=Ee.focus)===null||_e===void 0||_e.call(Ee),Qe==null||Qe(!1)}},N=function(){var Ee;return(Ee=ee.current)!==null&&Ee!==void 0&&Ee.focus?(ee.current.focus(),Q.current=!0,!0):!1},we=function(Ee){switch(Ee.keyCode){case ce:ie();break;case I:{var _e=!1;Q.current||(_e=N()),_e?Ee.preventDefault():ie();break}}};me.useEffect(function(){return Oe?(window.addEventListener("keydown",we),xe&&(0,Pe.Z)(N,3),function(){window.removeEventListener("keydown",we),Q.current=!1}):function(){Q.current=!1}},[Oe])}var ct=(0,me.forwardRef)(function(Z,Oe){var He=Z.overlay,Qe=Z.arrow,xe=Z.prefixCls,ee=(0,me.useMemo)(function(){var ie;return typeof He=="function"?ie=He():ie=He,ie},[He]),Q=(0,H.sQ)(Oe,ee==null?void 0:ee.ref);return me.createElement(me.Fragment,null,Qe&&me.createElement("div",{className:"".concat(xe,"-arrow")}),me.cloneElement(ee,{ref:(0,H.Yr)(ee)?Q:void 0}))}),Re=ct,De={adjustX:1,adjustY:1},K=[0,0],P={topLeft:{points:["bl","tl"],overflow:De,offset:[0,-4],targetOffset:K},top:{points:["bc","tc"],overflow:De,offset:[0,-4],targetOffset:K},topRight:{points:["br","tr"],overflow:De,offset:[0,-4],targetOffset:K},bottomLeft:{points:["tl","bl"],overflow:De,offset:[0,4],targetOffset:K},bottom:{points:["tc","bc"],overflow:De,offset:[0,4],targetOffset:K},bottomRight:{points:["tr","br"],overflow:De,offset:[0,4],targetOffset:K}},F=P,Y=["arrow","prefixCls","transitionName","animation","align","placement","placements","getPopupContainer","showAction","hideAction","overlayClassName","overlayStyle","visible","trigger","autoFocus","overlay","children","onVisibleChange"];function X(Z,Oe){var He,Qe=Z.arrow,xe=Qe===void 0?!1:Qe,ee=Z.prefixCls,Q=ee===void 0?"rc-dropdown":ee,ie=Z.transitionName,N=Z.animation,we=Z.align,je=Z.placement,Ee=je===void 0?"bottomLeft":je,_e=Z.placements,Me=_e===void 0?F:_e,Be=Z.getPopupContainer,Fe=Z.showAction,Ze=Z.hideAction,ot=Z.overlayClassName,mt=Z.overlayStyle,Et=Z.visible,wt=Z.trigger,Gt=wt===void 0?["hover"]:wt,gt=Z.autoFocus,bt=Z.overlay,$e=Z.children,Vt=Z.onVisibleChange,Zt=(0,z.Z)(Z,Y),Ht=me.useState(),k=(0,fe.Z)(Ht,2),C=k[0],x=k[1],D="visible"in Z?Et:C,$=me.useRef(null),ae=me.useRef(null),w=me.useRef(null);me.useImperativeHandle(Oe,function(){return $.current});var V=function(st){x(st),Vt==null||Vt(st)};j({visible:D,triggerRef:w,onVisibleChange:V,autoFocus:gt,overlayRef:ae});var W=function(st){var tt=Z.onOverlayClick;x(!1),tt&&tt(st)},O=function(){return me.createElement(Re,{ref:ae,overlay:bt,prefixCls:Q,arrow:xe})},le=function(){return typeof bt=="function"?O:O()},Le=function(){var st=Z.minOverlayWidthMatchTrigger,tt=Z.alignPoint;return"minOverlayWidthMatchTrigger"in Z?st:!tt},We=function(){var st=Z.openClassName;return st!==void 0?st:"".concat(Q,"-open")},Je=me.cloneElement($e,{className:oe()((He=$e.props)===null||He===void 0?void 0:He.className,D&&We()),ref:(0,H.Yr)($e)?(0,H.sQ)(w,$e.ref):void 0}),ft=Ze;return!ft&&Gt.indexOf("contextMenu")!==-1&&(ft=["click"]),me.createElement(A.Z,(0,S.Z)({builtinPlacements:Me},Zt,{prefixCls:Q,ref:$,popupClassName:oe()(ot,(0,B.Z)({},"".concat(Q,"-show-arrow"),xe)),popupStyle:mt,action:Gt,showAction:Fe,hideAction:ft,popupPlacement:Ee,popupAlign:we,popupTransitionName:ie,popupAnimation:N,popupVisible:D,stretch:Le()?"minWidth":"",popup:le(),onPopupVisibleChange:V,onPopupClick:W,getPopupContainer:Be}),Je)}var de=me.forwardRef(X),ve=de},15285:function(Wt,ze,R){"use strict";R.d(ze,{iz:function(){return at},ck:function(){return ut},BW:function(){return Ct},sN:function(){return ut},Wd:function(){return Ve},ZP:function(){return lt},Xl:function(){return He}});var S=R(72308),B=R(49618),fe=R(77321),z=R(80702),A=R(52487),m=R(74416),oe=R(92310),H=R.n(oe),me=R(11780),Ae=R(18929),Pe=R(13697),ce=R(48736),I=R(59301),j=R(4676),ct=I.createContext(null);function Re(q,se){return q===void 0?null:"".concat(q,"-").concat(se)}function De(q){var se=I.useContext(ct);return Re(se,q)}var K=R(80547),P=["children","locked"],F=I.createContext(null);function Y(q,se){var pe=(0,fe.Z)({},q);return Object.keys(se).forEach(function(Ce){var Se=se[Ce];Se!==void 0&&(pe[Ce]=Se)}),pe}function X(q){var se=q.children,pe=q.locked,Ce=(0,m.Z)(q,P),Se=I.useContext(F),Ue=(0,K.Z)(function(){return Y(Se,Ce)},[Se,Ce],function(ke,xt){return!pe&&(ke[0]!==xt[0]||!(0,Pe.Z)(ke[1],xt[1],!0))});return I.createElement(F.Provider,{value:Ue},se)}var de=[],ve=I.createContext(null);function Z(){return I.useContext(ve)}var Oe=I.createContext(de);function He(q){var se=I.useContext(Oe);return I.useMemo(function(){return q!==void 0?[].concat((0,z.Z)(se),[q]):se},[se,q])}var Qe=I.createContext(null),xe=I.createContext({}),ee=xe,Q=R(29194);function ie(q){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if((0,Q.Z)(q)){var pe=q.nodeName.toLowerCase(),Ce=["input","select","textarea","button"].includes(pe)||q.isContentEditable||pe==="a"&&!!q.getAttribute("href"),Se=q.getAttribute("tabindex"),Ue=Number(Se),ke=null;return Se&&!Number.isNaN(Ue)?ke=Ue:Ce&&ke===null&&(ke=0),Ce&&q.disabled&&(ke=null),ke!==null&&(ke>=0||se&&ke<0)}return!1}function N(q){var se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,pe=(0,z.Z)(q.querySelectorAll("*")).filter(function(Ce){return ie(Ce,se)});return ie(q,se)&&pe.unshift(q),pe}var we=null;function je(){we=document.activeElement}function Ee(){we=null}function _e(){if(we)try{we.focus()}catch(q){}}function Me(q,se){if(se.keyCode===9){var pe=N(q),Ce=pe[se.shiftKey?0:pe.length-1],Se=Ce===document.activeElement||q===document.activeElement;if(Se){var Ue=pe[se.shiftKey?pe.length-1:0];Ue.focus(),se.preventDefault()}}}var Be=R(10228),Fe=R(16089),Ze=Be.Z.LEFT,ot=Be.Z.RIGHT,mt=Be.Z.UP,Et=Be.Z.DOWN,wt=Be.Z.ENTER,Gt=Be.Z.ESC,gt=Be.Z.HOME,bt=Be.Z.END,$e=[mt,Et,Ze,ot];function Vt(q,se,pe,Ce){var Se,Ue,ke,xt,Mt="prev",pt="next",jt="children",kt="parent";if(q==="inline"&&Ce===wt)return{inlineTrigger:!0};var ai=(Se={},(0,B.Z)(Se,mt,Mt),(0,B.Z)(Se,Et,pt),Se),Bt=(Ue={},(0,B.Z)(Ue,Ze,pe?pt:Mt),(0,B.Z)(Ue,ot,pe?Mt:pt),(0,B.Z)(Ue,Et,jt),(0,B.Z)(Ue,wt,jt),Ue),Tt=(ke={},(0,B.Z)(ke,mt,Mt),(0,B.Z)(ke,Et,pt),(0,B.Z)(ke,wt,jt),(0,B.Z)(ke,Gt,kt),(0,B.Z)(ke,Ze,pe?jt:kt),(0,B.Z)(ke,ot,pe?kt:jt),ke),Ai={inline:ai,horizontal:Bt,vertical:Tt,inlineSub:ai,horizontalSub:Tt,verticalSub:Tt},Ri=(xt=Ai["".concat(q).concat(se?"":"Sub")])===null||xt===void 0?void 0:xt[Ce];switch(Ri){case Mt:return{offset:-1,sibling:!0};case pt:return{offset:1,sibling:!0};case kt:return{offset:-1,sibling:!1};case jt:return{offset:1,sibling:!1};default:return null}}function Zt(q){for(var se=q;se;){if(se.getAttribute("data-menu-list"))return se;se=se.parentElement}return null}function Ht(q,se){for(var pe=q||document.activeElement;pe;){if(se.has(pe))return pe;pe=pe.parentElement}return null}function k(q,se){var pe=N(q,!0);return pe.filter(function(Ce){return se.has(Ce)})}function C(q,se,pe){var Ce=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(!q)return null;var Se=k(q,se),Ue=Se.length,ke=Se.findIndex(function(xt){return pe===xt});return Ce<0?ke===-1?ke=Ue-1:ke-=1:Ce>0&&(ke+=1),ke=(ke+Ue)%Ue,Se[ke]}var x=function(se,pe){var Ce=new Set,Se=new Map,Ue=new Map;return se.forEach(function(ke){var xt=document.querySelector("[data-menu-id='".concat(Re(pe,ke),"']"));xt&&(Ce.add(xt),Ue.set(xt,ke),Se.set(ke,xt))}),{elements:Ce,key2element:Se,element2key:Ue}};function D(q,se,pe,Ce,Se,Ue,ke,xt,Mt,pt){var jt=I.useRef(),kt=I.useRef();kt.current=se;var ai=function(){Fe.Z.cancel(jt.current)};return I.useEffect(function(){return function(){ai()}},[]),function(Bt){var Tt=Bt.which;if([].concat($e,[wt,Gt,gt,bt]).includes(Tt)){var Ai=Ue(),Ri=x(Ai,Ce),Oi=Ri,xi=Oi.elements,ui=Oi.key2element,di=Oi.element2key,oi=ui.get(se),Ii=Ht(oi,xi),Vi=di.get(Ii),Ci=Vt(q,ke(Vi,!0).length===1,pe,Tt);if(!Ci&&Tt!==gt&&Tt!==bt)return;($e.includes(Tt)||[gt,bt].includes(Tt))&&Bt.preventDefault();var Li=function(Fi){if(Fi){var ss=Fi,fs=Fi.querySelector("a");fs!=null&&fs.getAttribute("href")&&(ss=fs);var Ni=di.get(Fi);xt(Ni),ai(),jt.current=(0,Fe.Z)(function(){kt.current===Ni&&ss.focus()})}};if([gt,bt].includes(Tt)||Ci.sibling||!Ii){var fi;!Ii||q==="inline"?fi=Se.current:fi=Zt(Ii);var Zi,Bi=k(fi,xi);Tt===gt?Zi=Bi[0]:Tt===bt?Zi=Bi[Bi.length-1]:Zi=C(fi,xi,Ii,Ci.offset),Li(Zi)}else if(Ci.inlineTrigger)Mt(Vi);else if(Ci.offset>0)Mt(Vi,!0),ai(),jt.current=(0,Fe.Z)(function(){Ri=x(Ai,Ce);var Ji=Ii.getAttribute("aria-controls"),Fi=document.getElementById(Ji),ss=C(Fi,Ri.elements);Li(ss)},5);else if(Ci.offset<0){var ni=ke(Vi,!0),is=ni[ni.length-2],qi=ui.get(is);Mt(is,!1),Li(qi)}}pt==null||pt(Bt)}}function $(q){Promise.resolve().then(q)}var ae="__RC_UTIL_PATH_SPLIT__",w=function(se){return se.join(ae)},V=function(se){return se.split(ae)},W="rc-menu-more";function O(){var q=I.useState({}),se=(0,A.Z)(q,2),pe=se[1],Ce=(0,I.useRef)(new Map),Se=(0,I.useRef)(new Map),Ue=I.useState([]),ke=(0,A.Z)(Ue,2),xt=ke[0],Mt=ke[1],pt=(0,I.useRef)(0),jt=(0,I.useRef)(!1),kt=function(){jt.current||pe({})},ai=(0,I.useCallback)(function(ui,di){var oi=w(di);Se.current.set(oi,ui),Ce.current.set(ui,oi),pt.current+=1;var Ii=pt.current;$(function(){Ii===pt.current&&kt()})},[]),Bt=(0,I.useCallback)(function(ui,di){var oi=w(di);Se.current.delete(oi),Ce.current.delete(ui)},[]),Tt=(0,I.useCallback)(function(ui){Mt(ui)},[]),Ai=(0,I.useCallback)(function(ui,di){var oi=Ce.current.get(ui)||"",Ii=V(oi);return di&&xt.includes(Ii[0])&&Ii.unshift(W),Ii},[xt]),Ri=(0,I.useCallback)(function(ui,di){return ui.some(function(oi){var Ii=Ai(oi,!0);return Ii.includes(di)})},[Ai]),Oi=function(){var di=(0,z.Z)(Ce.current.keys());return xt.length&&di.push(W),di},xi=(0,I.useCallback)(function(ui){var di="".concat(Ce.current.get(ui)).concat(ae),oi=new Set;return(0,z.Z)(Se.current.keys()).forEach(function(Ii){Ii.startsWith(di)&&oi.add(Se.current.get(Ii))}),oi},[]);return I.useEffect(function(){return function(){jt.current=!0}},[]),{registerPath:ai,unregisterPath:Bt,refreshOverflowKeys:Tt,isSubPathKey:Ri,getKeyPath:Ai,getKeys:Oi,getSubPathKeys:xi}}function le(q){var se=I.useRef(q);se.current=q;var pe=I.useCallback(function(){for(var Ce,Se=arguments.length,Ue=new Array(Se),ke=0;ke<Se;ke++)Ue[ke]=arguments[ke];return(Ce=se.current)===null||Ce===void 0?void 0:Ce.call.apply(Ce,[se].concat(Ue))},[]);return q?pe:void 0}var Le=Math.random().toFixed(5).toString().slice(2),We=0;function Je(q){var se=(0,Ae.Z)(q,{value:q}),pe=(0,A.Z)(se,2),Ce=pe[0],Se=pe[1];return I.useEffect(function(){We+=1;var Ue="".concat(Le,"-").concat(We);Se("rc-menu-uuid-".concat(Ue))},[]),Ce}var ft=R(96949),nt=R(55090),st=R(77205),tt=R(38793),It=R(2738),Ot=R(8654);function ge(q,se,pe,Ce){var Se=I.useContext(F),Ue=Se.activeKey,ke=Se.onActive,xt=Se.onInactive,Mt={active:Ue===q};return se||(Mt.onMouseEnter=function(pt){pe==null||pe({key:q,domEvent:pt}),ke(q)},Mt.onMouseLeave=function(pt){Ce==null||Ce({key:q,domEvent:pt}),xt(q)}),Mt}function ei(q){var se=I.useContext(F),pe=se.mode,Ce=se.rtl,Se=se.inlineIndent;if(pe!=="inline")return null;var Ue=q;return Ce?{paddingRight:Ue*Se}:{paddingLeft:Ue*Se}}function ti(q){var se=q.icon,pe=q.props,Ce=q.children,Se;return se===null||se===!1?null:(typeof se=="function"?Se=I.createElement(se,(0,fe.Z)({},pe)):typeof se!="boolean"&&(Se=se),Se||Ce||null)}var hi=["item"];function Xt(q){var se=q.item,pe=(0,m.Z)(q,hi);return Object.defineProperty(pe,"item",{get:function(){return(0,ce.ZP)(!1,"`info.item` is deprecated since we will move to function component that not provides React Node instance in future."),se}}),pe}var Ti=["title","attribute","elementRef"],gi=["style","className","eventKey","warnKey","disabled","itemIcon","children","role","onMouseEnter","onMouseLeave","onClick","onKeyDown","onFocus"],Si=["active"],ii=function(q){(0,st.Z)(pe,q);var se=(0,tt.Z)(pe);function pe(){return(0,ft.Z)(this,pe),se.apply(this,arguments)}return(0,nt.Z)(pe,[{key:"render",value:function(){var Se=this.props,Ue=Se.title,ke=Se.attribute,xt=Se.elementRef,Mt=(0,m.Z)(Se,Ti),pt=(0,It.Z)(Mt,["eventKey","popupClassName","popupOffset","onTitleClick"]);return(0,ce.ZP)(!ke,"`attribute` of Menu.Item is deprecated. Please pass attribute directly."),I.createElement(me.Z.Item,(0,S.Z)({},ke,{title:typeof Ue=="string"?Ue:void 0},pt,{ref:xt}))}}]),pe}(I.Component),Mi=I.forwardRef(function(q,se){var pe,Ce=q.style,Se=q.className,Ue=q.eventKey,ke=q.warnKey,xt=q.disabled,Mt=q.itemIcon,pt=q.children,jt=q.role,kt=q.onMouseEnter,ai=q.onMouseLeave,Bt=q.onClick,Tt=q.onKeyDown,Ai=q.onFocus,Ri=(0,m.Z)(q,gi),Oi=De(Ue),xi=I.useContext(F),ui=xi.prefixCls,di=xi.onItemClick,oi=xi.disabled,Ii=xi.overflowDisabled,Vi=xi.itemIcon,Ci=xi.selectedKeys,Li=xi.onActive,fi=I.useContext(ee),Zi=fi._internalRenderMenuItem,Bi="".concat(ui,"-item"),ni=I.useRef(),is=I.useRef(),qi=oi||xt,Ji=(0,Ot.x1)(se,is),Fi=He(Ue),ss=function(Gi){return{key:Ue,keyPath:(0,z.Z)(Fi).reverse(),item:ni.current,domEvent:Gi}},fs=Mt||Vi,Ni=ge(Ue,qi,kt,ai),Rs=Ni.active,ks=(0,m.Z)(Ni,Si),_s=Ci.includes(Ue),gs=ei(Fi.length),cs=function(Gi){if(!qi){var es=ss(Gi);Bt==null||Bt(Xt(es)),di(es)}},ns=function(Gi){if(Tt==null||Tt(Gi),Gi.which===Be.Z.ENTER){var es=ss(Gi);Bt==null||Bt(Xt(es)),di(es)}},ls=function(Gi){Li(Ue),Ai==null||Ai(Gi)},ms={};q.role==="option"&&(ms["aria-selected"]=_s);var Ls=I.createElement(ii,(0,S.Z)({ref:ni,elementRef:Ji,role:jt===null?"none":jt||"menuitem",tabIndex:xt?null:-1,"data-menu-id":Ii&&Oi?null:Oi},Ri,ks,ms,{component:"li","aria-disabled":xt,style:(0,fe.Z)((0,fe.Z)({},gs),Ce),className:H()(Bi,(pe={},(0,B.Z)(pe,"".concat(Bi,"-active"),Rs),(0,B.Z)(pe,"".concat(Bi,"-selected"),_s),(0,B.Z)(pe,"".concat(Bi,"-disabled"),qi),pe),Se),onClick:cs,onKeyDown:ns,onFocus:ls}),pt,I.createElement(ti,{props:(0,fe.Z)((0,fe.Z)({},q),{},{isSelected:_s}),icon:fs}));return Zi&&(Ls=Zi(Ls,q,{selected:_s})),Ls});function Qt(q,se){var pe=q.eventKey,Ce=Z(),Se=He(pe);return I.useEffect(function(){if(Ce)return Ce.registerPath(pe,Se),function(){Ce.unregisterPath(pe,Se)}},[Se]),Ce?null:I.createElement(Mi,(0,S.Z)({},q,{ref:se}))}var ut=I.forwardRef(Qt),_t=["className","children"],si=function(se,pe){var Ce=se.className,Se=se.children,Ue=(0,m.Z)(se,_t),ke=I.useContext(F),xt=ke.prefixCls,Mt=ke.mode,pt=ke.rtl;return I.createElement("ul",(0,S.Z)({className:H()(xt,pt&&"".concat(xt,"-rtl"),"".concat(xt,"-sub"),"".concat(xt,"-").concat(Mt==="inline"?"inline":"vertical"),Ce),role:"menu"},Ue,{"data-menu-list":!0,ref:pe}),Se)},At=I.forwardRef(si);At.displayName="SubMenuList";var bi=At,li=R(11592);function _i(q,se){return(0,li.Z)(q).map(function(pe,Ce){if(I.isValidElement(pe)){var Se,Ue,ke=pe.key,xt=(Se=(Ue=pe.props)===null||Ue===void 0?void 0:Ue.eventKey)!==null&&Se!==void 0?Se:ke,Mt=xt==null;Mt&&(xt="tmp_key-".concat([].concat((0,z.Z)(se),[Ce]).join("-")));var pt={key:xt,eventKey:xt};return I.cloneElement(pe,pt)}return pe})}var pi=R(35593),ri={adjustX:1,adjustY:1},ci={topLeft:{points:["bl","tl"],overflow:ri},topRight:{points:["br","tr"],overflow:ri},bottomLeft:{points:["tl","bl"],overflow:ri},bottomRight:{points:["tr","br"],overflow:ri},leftTop:{points:["tr","tl"],overflow:ri},leftBottom:{points:["br","bl"],overflow:ri},rightTop:{points:["tl","tr"],overflow:ri},rightBottom:{points:["bl","br"],overflow:ri}},as={topLeft:{points:["bl","tl"],overflow:ri},topRight:{points:["br","tr"],overflow:ri},bottomLeft:{points:["tl","bl"],overflow:ri},bottomRight:{points:["tr","br"],overflow:ri},rightTop:{points:["tr","tl"],overflow:ri},rightBottom:{points:["br","bl"],overflow:ri},leftTop:{points:["tl","tr"],overflow:ri},leftBottom:{points:["bl","br"],overflow:ri}},Ge=null;function c(q,se,pe){if(se)return se;if(pe)return pe[q]||pe.other}var f={horizontal:"bottomLeft",vertical:"rightTop","vertical-left":"rightTop","vertical-right":"leftTop"};function p(q){var se=q.prefixCls,pe=q.visible,Ce=q.children,Se=q.popup,Ue=q.popupStyle,ke=q.popupClassName,xt=q.popupOffset,Mt=q.disabled,pt=q.mode,jt=q.onVisibleChange,kt=I.useContext(F),ai=kt.getPopupContainer,Bt=kt.rtl,Tt=kt.subMenuOpenDelay,Ai=kt.subMenuCloseDelay,Ri=kt.builtinPlacements,Oi=kt.triggerSubMenuAction,xi=kt.forceSubMenuRender,ui=kt.rootClassName,di=kt.motion,oi=kt.defaultMotions,Ii=I.useState(!1),Vi=(0,A.Z)(Ii,2),Ci=Vi[0],Li=Vi[1],fi=Bt?(0,fe.Z)((0,fe.Z)({},as),Ri):(0,fe.Z)((0,fe.Z)({},ci),Ri),Zi=f[pt],Bi=c(pt,di,oi),ni=I.useRef(Bi);pt!=="inline"&&(ni.current=Bi);var is=(0,fe.Z)((0,fe.Z)({},ni.current),{},{leavedClassName:"".concat(se,"-hidden"),removeOnLeave:!1,motionAppear:!0}),qi=I.useRef();return I.useEffect(function(){return qi.current=(0,Fe.Z)(function(){Li(pe)}),function(){Fe.Z.cancel(qi.current)}},[pe]),I.createElement(pi.Z,{prefixCls:se,popupClassName:H()("".concat(se,"-popup"),(0,B.Z)({},"".concat(se,"-rtl"),Bt),ke,ui),stretch:pt==="horizontal"?"minWidth":null,getPopupContainer:ai,builtinPlacements:fi,popupPlacement:Zi,popupVisible:Ci,popup:Se,popupStyle:Ue,popupAlign:xt&&{offset:xt},action:Mt?[]:[Oi],mouseEnterDelay:Tt,mouseLeaveDelay:Ai,onPopupVisibleChange:jt,forceRender:xi,popupMotion:is,fresh:!0},Ce)}var E=R(77900);function T(q){var se=q.id,pe=q.open,Ce=q.keyPath,Se=q.children,Ue="inline",ke=I.useContext(F),xt=ke.prefixCls,Mt=ke.forceSubMenuRender,pt=ke.motion,jt=ke.defaultMotions,kt=ke.mode,ai=I.useRef(!1);ai.current=kt===Ue;var Bt=I.useState(!ai.current),Tt=(0,A.Z)(Bt,2),Ai=Tt[0],Ri=Tt[1],Oi=ai.current?pe:!1;I.useEffect(function(){ai.current&&Ri(!1)},[kt]);var xi=(0,fe.Z)({},c(Ue,pt,jt));Ce.length>1&&(xi.motionAppear=!1);var ui=xi.onVisibleChanged;return xi.onVisibleChanged=function(di){return!ai.current&&!di&&Ri(!0),ui==null?void 0:ui(di)},Ai?null:I.createElement(X,{mode:Ue,locked:!ai.current},I.createElement(E.default,(0,S.Z)({visible:Oi},xi,{forceRender:Mt,removeOnLeave:!1,leavedClassName:"".concat(xt,"-hidden")}),function(di){var oi=di.className,Ii=di.style;return I.createElement(bi,{id:se,className:oi,style:Ii},Se)}))}var G=["style","className","title","eventKey","warnKey","disabled","internalPopupClose","children","itemIcon","expandIcon","popupClassName","popupOffset","popupStyle","onClick","onMouseEnter","onMouseLeave","onTitleClick","onTitleMouseEnter","onTitleMouseLeave"],J=["active"],Ye=function(se){var pe,Ce=se.style,Se=se.className,Ue=se.title,ke=se.eventKey,xt=se.warnKey,Mt=se.disabled,pt=se.internalPopupClose,jt=se.children,kt=se.itemIcon,ai=se.expandIcon,Bt=se.popupClassName,Tt=se.popupOffset,Ai=se.popupStyle,Ri=se.onClick,Oi=se.onMouseEnter,xi=se.onMouseLeave,ui=se.onTitleClick,di=se.onTitleMouseEnter,oi=se.onTitleMouseLeave,Ii=(0,m.Z)(se,G),Vi=De(ke),Ci=I.useContext(F),Li=Ci.prefixCls,fi=Ci.mode,Zi=Ci.openKeys,Bi=Ci.disabled,ni=Ci.overflowDisabled,is=Ci.activeKey,qi=Ci.selectedKeys,Ji=Ci.itemIcon,Fi=Ci.expandIcon,ss=Ci.onItemClick,fs=Ci.onOpenChange,Ni=Ci.onActive,Rs=I.useContext(ee),ks=Rs._internalRenderSubMenuItem,_s=I.useContext(Qe),gs=_s.isSubPathKey,cs=He(),ns="".concat(Li,"-submenu"),ls=Bi||Mt,ms=I.useRef(),Ls=I.useRef(),Yi=kt!=null?kt:Ji,Gi=ai!=null?ai:Fi,es=Zi.includes(ke),os=!ni&&es,Is=gs(qi,ke),Ft=ge(ke,ls,di,oi),Ss=Ft.active,Cs=(0,m.Z)(Ft,J),bs=I.useState(!1),Vs=(0,A.Z)(bs,2),Ks=Vs[0],Qs=Vs[1],Ps=function(Qi){ls||Qs(Qi)},vi=function(Qi){Ps(!0),Oi==null||Oi({key:ke,domEvent:Qi})},an=function(Qi){Ps(!1),xi==null||xi({key:ke,domEvent:Qi})},Hs=I.useMemo(function(){return Ss||(fi!=="inline"?Ks||gs([is],ke):!1)},[fi,Ss,is,Ks,ke,gs]),js=ei(cs.length),Js=function(Qi){ls||(ui==null||ui({key:ke,domEvent:Qi}),fi==="inline"&&fs(ke,!es))},Ms=le(function(us){Ri==null||Ri(Xt(us)),ss(us)}),Bs=function(Qi){fi!=="inline"&&fs(ke,Qi)},ps=function(){Ni(ke)},ts=Vi&&"".concat(Vi,"-popup"),xs=I.createElement("div",(0,S.Z)({role:"menuitem",style:js,className:"".concat(ns,"-title"),tabIndex:ls?null:-1,ref:ms,title:typeof Ue=="string"?Ue:null,"data-menu-id":ni&&Vi?null:Vi,"aria-expanded":os,"aria-haspopup":!0,"aria-controls":ts,"aria-disabled":ls,onClick:Js,onFocus:ps},Cs),Ue,I.createElement(ti,{icon:fi!=="horizontal"?Gi:void 0,props:(0,fe.Z)((0,fe.Z)({},se),{},{isOpen:os,isSubMenu:!0})},I.createElement("i",{className:"".concat(ns,"-arrow")}))),ji=I.useRef(fi);if(fi!=="inline"&&cs.length>1?ji.current="vertical":ji.current=fi,!ni){var vs=ji.current;xs=I.createElement(p,{mode:vs,prefixCls:ns,visible:!pt&&os&&fi!=="inline",popupClassName:Bt,popupOffset:Tt,popupStyle:Ai,popup:I.createElement(X,{mode:vs==="horizontal"?"vertical":vs},I.createElement(bi,{id:ts,ref:Ls},jt)),disabled:ls,onVisibleChange:Bs},xs)}var ys=I.createElement(me.Z.Item,(0,S.Z)({role:"none"},Ii,{component:"li",style:Ce,className:H()(ns,"".concat(ns,"-").concat(fi),Se,(pe={},(0,B.Z)(pe,"".concat(ns,"-open"),os),(0,B.Z)(pe,"".concat(ns,"-active"),Hs),(0,B.Z)(pe,"".concat(ns,"-selected"),Is),(0,B.Z)(pe,"".concat(ns,"-disabled"),ls),pe)),onMouseEnter:vi,onMouseLeave:an}),xs,!ni&&I.createElement(T,{id:ts,open:os,keyPath:cs},jt));return ks&&(ys=ks(ys,se,{selected:Is,active:Hs,open:os,disabled:ls})),I.createElement(X,{onItemClick:Ms,mode:fi==="horizontal"?"vertical":fi,itemIcon:Yi,expandIcon:Gi},ys)};function Ve(q){var se=q.eventKey,pe=q.children,Ce=He(se),Se=_i(pe,Ce),Ue=Z();I.useEffect(function(){if(Ue)return Ue.registerPath(se,Ce),function(){Ue.unregisterPath(se,Ce)}},[Ce]);var ke;return Ue?ke=Se:ke=I.createElement(Ye,q,Se),I.createElement(Oe.Provider,{value:Ce},ke)}var ht=R(62853),Rt=["className","title","eventKey","children"],Pt=["children"],Ne=function(se){var pe=se.className,Ce=se.title,Se=se.eventKey,Ue=se.children,ke=(0,m.Z)(se,Rt),xt=I.useContext(F),Mt=xt.prefixCls,pt="".concat(Mt,"-item-group");return I.createElement("li",(0,S.Z)({role:"presentation"},ke,{onClick:function(kt){return kt.stopPropagation()},className:H()(pt,pe)}),I.createElement("div",{role:"presentation",className:"".concat(pt,"-title"),title:typeof Ce=="string"?Ce:void 0},Ce),I.createElement("ul",{role:"group",className:"".concat(pt,"-list")},Ue))};function Ct(q){var se=q.children,pe=(0,m.Z)(q,Pt),Ce=He(pe.eventKey),Se=_i(se,Ce),Ue=Z();return Ue?Se:I.createElement(Ne,(0,It.Z)(pe,["warnKey"]),Se)}function at(q){var se=q.className,pe=q.style,Ce=I.useContext(F),Se=Ce.prefixCls,Ue=Z();return Ue?null:I.createElement("li",{role:"separator",className:H()("".concat(Se,"-item-divider"),se),style:pe})}var Ke=["label","children","key","type"];function et(q){return(q||[]).map(function(se,pe){if(se&&(0,ht.Z)(se)==="object"){var Ce=se,Se=Ce.label,Ue=Ce.children,ke=Ce.key,xt=Ce.type,Mt=(0,m.Z)(Ce,Ke),pt=ke!=null?ke:"tmp-".concat(pe);return Ue||xt==="group"?xt==="group"?I.createElement(Ct,(0,S.Z)({key:pt},Mt,{title:Se}),et(Ue)):I.createElement(Ve,(0,S.Z)({key:pt},Mt,{title:Se}),et(Ue)):xt==="divider"?I.createElement(at,(0,S.Z)({key:pt},Mt)):I.createElement(ut,(0,S.Z)({key:pt},Mt),Se)}return null}).filter(function(se){return se})}function vt(q,se,pe){var Ce=q;return se&&(Ce=et(se)),_i(Ce,pe)}var Lt=["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"],Ut=[],qt=I.forwardRef(function(q,se){var pe,Ce,Se=q,Ue=Se.prefixCls,ke=Ue===void 0?"rc-menu":Ue,xt=Se.rootClassName,Mt=Se.style,pt=Se.className,jt=Se.tabIndex,kt=jt===void 0?0:jt,ai=Se.items,Bt=Se.children,Tt=Se.direction,Ai=Se.id,Ri=Se.mode,Oi=Ri===void 0?"vertical":Ri,xi=Se.inlineCollapsed,ui=Se.disabled,di=Se.disabledOverflow,oi=Se.subMenuOpenDelay,Ii=oi===void 0?.1:oi,Vi=Se.subMenuCloseDelay,Ci=Vi===void 0?.1:Vi,Li=Se.forceSubMenuRender,fi=Se.defaultOpenKeys,Zi=Se.openKeys,Bi=Se.activeKey,ni=Se.defaultActiveFirst,is=Se.selectable,qi=is===void 0?!0:is,Ji=Se.multiple,Fi=Ji===void 0?!1:Ji,ss=Se.defaultSelectedKeys,fs=Se.selectedKeys,Ni=Se.onSelect,Rs=Se.onDeselect,ks=Se.inlineIndent,_s=ks===void 0?24:ks,gs=Se.motion,cs=Se.defaultMotions,ns=Se.triggerSubMenuAction,ls=ns===void 0?"hover":ns,ms=Se.builtinPlacements,Ls=Se.itemIcon,Yi=Se.expandIcon,Gi=Se.overflowedIndicator,es=Gi===void 0?"...":Gi,os=Se.overflowedIndicatorPopupClassName,Is=Se.getPopupContainer,Ft=Se.onClick,Ss=Se.onOpenChange,Cs=Se.onKeyDown,bs=Se.openAnimation,Vs=Se.openTransitionName,Ks=Se._internalRenderMenuItem,Qs=Se._internalRenderSubMenuItem,Ps=(0,m.Z)(Se,Lt),vi=I.useMemo(function(){return vt(Bt,ai,Ut)},[Bt,ai]),an=I.useState(!1),Hs=(0,A.Z)(an,2),js=Hs[0],Js=Hs[1],Ms=I.useRef(),Bs=Je(Ai),ps=Tt==="rtl",ts=(0,Ae.Z)(fi,{value:Zi,postState:function($i){return $i||Ut}}),xs=(0,A.Z)(ts,2),ji=xs[0],vs=xs[1],ys=function($i){var Ki=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;function ds(){vs($i),Ss==null||Ss($i)}Ki?(0,j.flushSync)(ds):ds()},us=I.useState(ji),Qi=(0,A.Z)(us,2),yi=Qi[0],rs=Qi[1],zs=I.useRef(!1),en=I.useMemo(function(){return(Oi==="inline"||Oi==="vertical")&&xi?["vertical",xi]:[Oi,!1]},[Oi,xi]),tn=(0,A.Z)(en,2),Fs=tn[0],yt=tn[1],Kt=Fs==="inline",zi=I.useState(Fs),Xi=(0,A.Z)(zi,2),Di=Xi[0],Ws=Xi[1],Zs=I.useState(yt),En=(0,A.Z)(Zs,2),on=En[0],nr=En[1];I.useEffect(function(){Ws(Fs),nr(yt),zs.current&&(Kt?vs(yi):ys(Ut))},[Fs,yt]);var wr=I.useState(0),Rn=(0,A.Z)(wr,2),Ln=Rn[0],Ns=Rn[1],In=Ln>=vi.length-1||Di!=="horizontal"||di;I.useEffect(function(){Kt&&rs(ji)},[ji]),I.useEffect(function(){return zs.current=!0,function(){zs.current=!1}},[]);var ln=O(),Un=ln.registerPath,Gn=ln.unregisterPath,rr=ln.refreshOverflowKeys,Vn=ln.isSubPathKey,kr=ln.getKeyPath,Cn=ln.getKeys,ar=ln.getSubPathKeys,or=I.useMemo(function(){return{registerPath:Un,unregisterPath:Gn}},[Un,Gn]),Ys=I.useMemo(function(){return{isSubPathKey:Vn}},[Vn]);I.useEffect(function(){rr(In?Ut:vi.slice(Ln+1).map(function(Wi){return Wi.key}))},[Ln,In]);var lr=(0,Ae.Z)(Bi||ni&&((pe=vi[0])===null||pe===void 0?void 0:pe.key),{value:Bi}),Dn=(0,A.Z)(lr,2),fn=Dn[0],Kn=Dn[1],Or=le(function(Wi){Kn(Wi)}),Pr=le(function(){Kn(void 0)});(0,I.useImperativeHandle)(se,function(){return{list:Ms.current,focus:function($i){var Ki,ds=Cn(),Ts=x(ds,Bs),Ie=Ts.elements,bn=Ts.key2element,fr=Ts.element2key,Wn=k(Ms.current,Ie),mr=fn!=null?fn:Wn[0]?fr.get(Wn[0]):(Ki=vi.find(function(Nr){return!Nr.props.disabled}))===null||Ki===void 0?void 0:Ki.key,un=bn.get(mr);if(mr&&un){var wn;un==null||(wn=un.focus)===null||wn===void 0||wn.call(un,$i)}}}});var Mr=(0,Ae.Z)(ss||[],{value:fs,postState:function($i){return Array.isArray($i)?$i:$i==null?Ut:[$i]}}),Hn=(0,A.Z)(Mr,2),_n=Hn[0],jn=Hn[1],ur=function($i){if(qi){var Ki=$i.key,ds=_n.includes(Ki),Ts;Fi?ds?Ts=_n.filter(function(bn){return bn!==Ki}):Ts=[].concat((0,z.Z)(_n),[Ki]):Ts=[Ki],jn(Ts);var Ie=(0,fe.Z)((0,fe.Z)({},$i),{},{selectedKeys:Ts});ds?Rs==null||Rs(Ie):Ni==null||Ni(Ie)}!Fi&&ji.length&&Di!=="inline"&&ys(Ut)},Br=le(function(Wi){Ft==null||Ft(Xt(Wi)),ur(Wi)}),zn=le(function(Wi,$i){var Ki=ji.filter(function(Ts){return Ts!==Wi});if($i)Ki.push(Wi);else if(Di!=="inline"){var ds=ar(Wi);Ki=Ki.filter(function(Ts){return!ds.has(Ts)})}(0,Pe.Z)(ji,Ki,!0)||ys(Ki,!0)}),cr=function($i,Ki){var ds=Ki!=null?Ki:!ji.includes($i);zn($i,ds)},dr=D(Di,fn,ps,Bs,Ms,Cn,kr,Kn,cr,Cs);I.useEffect(function(){Js(!0)},[]);var Sn=I.useMemo(function(){return{_internalRenderMenuItem:Ks,_internalRenderSubMenuItem:Qs}},[Ks,Qs]),Fr=Di!=="horizontal"||di?vi:vi.map(function(Wi,$i){return I.createElement(X,{key:Wi.key,overflowDisabled:$i>Ln},Wi)}),hr=I.createElement(me.Z,(0,S.Z)({id:Ai,ref:Ms,prefixCls:"".concat(ke,"-overflow"),component:"ul",itemComponent:ut,className:H()(ke,"".concat(ke,"-root"),"".concat(ke,"-").concat(Di),pt,(Ce={},(0,B.Z)(Ce,"".concat(ke,"-inline-collapsed"),on),(0,B.Z)(Ce,"".concat(ke,"-rtl"),ps),Ce),xt),dir:Tt,style:Mt,role:"menu",tabIndex:kt,data:Fr,renderRawItem:function($i){return $i},renderRawRest:function($i){var Ki=$i.length,ds=Ki?vi.slice(-Ki):null;return I.createElement(Ve,{eventKey:W,title:es,disabled:In,internalPopupClose:Ki===0,popupClassName:os},ds)},maxCount:Di!=="horizontal"||di?me.Z.INVALIDATE:me.Z.RESPONSIVE,ssr:"full","data-menu-list":!0,onVisibleChange:function($i){Ns($i)},onKeyDown:dr},Ps));return I.createElement(ee.Provider,{value:Sn},I.createElement(ct.Provider,{value:Bs},I.createElement(X,{prefixCls:ke,rootClassName:xt,mode:Di,openKeys:ji,rtl:ps,disabled:ui,motion:js?gs:null,defaultMotions:js?cs:null,activeKey:fn,onActive:Or,onInactive:Pr,selectedKeys:_n,inlineIndent:_s,subMenuOpenDelay:Ii,subMenuCloseDelay:Ci,forceSubMenuRender:Li,builtinPlacements:ms,triggerSubMenuAction:ls,getPopupContainer:Is,itemIcon:Ls,expandIcon:Yi,onItemClick:Br,onOpenChange:zn},I.createElement(Qe.Provider,{value:Ys},hr),I.createElement("div",{style:{display:"none"},"aria-hidden":!0},I.createElement(ve.Provider,{value:or},vi)))))}),ki=qt,rt=ki;rt.Item=ut,rt.SubMenu=Ve,rt.ItemGroup=Ct,rt.Divider=at;var lt=rt},11780:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return je}});var S=R(72308),B=R(77321),fe=R(52487),z=R(74416),A=R(59301),m=R(92310),oe=R.n(m),H=R(29301),me=R(34280),Ae=["prefixCls","invalidate","item","renderItem","responsive","responsiveDisabled","registerSize","itemKey","className","style","children","display","order","component"],Pe=void 0;function ce(Ee,_e){var Me=Ee.prefixCls,Be=Ee.invalidate,Fe=Ee.item,Ze=Ee.renderItem,ot=Ee.responsive,mt=Ee.responsiveDisabled,Et=Ee.registerSize,wt=Ee.itemKey,Gt=Ee.className,gt=Ee.style,bt=Ee.children,$e=Ee.display,Vt=Ee.order,Zt=Ee.component,Ht=Zt===void 0?"div":Zt,k=(0,z.Z)(Ee,Ae),C=ot&&!$e;function x(V){Et(wt,V)}A.useEffect(function(){return function(){x(null)}},[]);var D=Ze&&Fe!==Pe?Ze(Fe,{index:Vt}):bt,$;Be||($={opacity:C?0:1,height:C?0:Pe,overflowY:C?"hidden":Pe,order:ot?Vt:Pe,pointerEvents:C?"none":Pe,position:C?"absolute":Pe});var ae={};C&&(ae["aria-hidden"]=!0);var w=A.createElement(Ht,(0,S.Z)({className:oe()(!Be&&Me,Gt),style:(0,B.Z)((0,B.Z)({},$),gt)},ae,k,{ref:_e}),D);return ot&&(w=A.createElement(H.Z,{onResize:function(W){var O=W.offsetWidth;x(O)},disabled:mt},w)),w}var I=A.forwardRef(ce);I.displayName="Item";var j=I,ct=R(6089),Re=R(4676),De=R(16089);function K(Ee){if(typeof MessageChannel=="undefined")(0,De.Z)(Ee);else{var _e=new MessageChannel;_e.port1.onmessage=function(){return Ee()},_e.port2.postMessage(void 0)}}function P(){var Ee=A.useRef(null),_e=function(Be){Ee.current||(Ee.current=[],K(function(){(0,Re.unstable_batchedUpdates)(function(){Ee.current.forEach(function(Fe){Fe()}),Ee.current=null})})),Ee.current.push(Be)};return _e}function F(Ee,_e){var Me=A.useState(_e),Be=(0,fe.Z)(Me,2),Fe=Be[0],Ze=Be[1],ot=(0,ct.Z)(function(mt){Ee(function(){Ze(mt)})});return[Fe,ot]}var Y=A.createContext(null),X=["component"],de=["className"],ve=["className"],Z=function(_e,Me){var Be=A.useContext(Y);if(!Be){var Fe=_e.component,Ze=Fe===void 0?"div":Fe,ot=(0,z.Z)(_e,X);return A.createElement(Ze,(0,S.Z)({},ot,{ref:Me}))}var mt=Be.className,Et=(0,z.Z)(Be,de),wt=_e.className,Gt=(0,z.Z)(_e,ve);return A.createElement(Y.Provider,{value:null},A.createElement(j,(0,S.Z)({ref:Me,className:oe()(mt,wt)},Et,Gt)))},Oe=A.forwardRef(Z);Oe.displayName="RawItem";var He=Oe,Qe=["prefixCls","data","renderItem","renderRawItem","itemKey","itemWidth","ssr","style","className","maxCount","renderRest","renderRawRest","suffix","component","itemComponent","onVisibleChange"],xe="responsive",ee="invalidate";function Q(Ee){return"+ ".concat(Ee.length," ...")}function ie(Ee,_e){var Me=Ee.prefixCls,Be=Me===void 0?"rc-overflow":Me,Fe=Ee.data,Ze=Fe===void 0?[]:Fe,ot=Ee.renderItem,mt=Ee.renderRawItem,Et=Ee.itemKey,wt=Ee.itemWidth,Gt=wt===void 0?10:wt,gt=Ee.ssr,bt=Ee.style,$e=Ee.className,Vt=Ee.maxCount,Zt=Ee.renderRest,Ht=Ee.renderRawRest,k=Ee.suffix,C=Ee.component,x=C===void 0?"div":C,D=Ee.itemComponent,$=Ee.onVisibleChange,ae=(0,z.Z)(Ee,Qe),w=gt==="full",V=P(),W=F(V,null),O=(0,fe.Z)(W,2),le=O[0],Le=O[1],We=le||0,Je=F(V,new Map),ft=(0,fe.Z)(Je,2),nt=ft[0],st=ft[1],tt=F(V,0),It=(0,fe.Z)(tt,2),Ot=It[0],ge=It[1],ei=F(V,0),ti=(0,fe.Z)(ei,2),hi=ti[0],Xt=ti[1],Ti=F(V,0),gi=(0,fe.Z)(Ti,2),Si=gi[0],ii=gi[1],Mi=(0,A.useState)(null),Qt=(0,fe.Z)(Mi,2),ut=Qt[0],_t=Qt[1],si=(0,A.useState)(null),At=(0,fe.Z)(si,2),bi=At[0],li=At[1],_i=A.useMemo(function(){return bi===null&&w?Number.MAX_SAFE_INTEGER:bi||0},[bi,le]),pi=(0,A.useState)(!1),ri=(0,fe.Z)(pi,2),ci=ri[0],as=ri[1],Ge="".concat(Be,"-item"),c=Math.max(Ot,hi),f=Vt===xe,p=Ze.length&&f,E=Vt===ee,T=p||typeof Vt=="number"&&Ze.length>Vt,G=(0,A.useMemo)(function(){var lt=Ze;return p?le===null&&w?lt=Ze:lt=Ze.slice(0,Math.min(Ze.length,We/Gt)):typeof Vt=="number"&&(lt=Ze.slice(0,Vt)),lt},[Ze,Gt,le,Vt,p]),J=(0,A.useMemo)(function(){return p?Ze.slice(_i+1):Ze.slice(G.length)},[Ze,G,p,_i]),Ye=(0,A.useCallback)(function(lt,q){var se;return typeof Et=="function"?Et(lt):(se=Et&&(lt==null?void 0:lt[Et]))!==null&&se!==void 0?se:q},[Et]),Ve=(0,A.useCallback)(ot||function(lt){return lt},[ot]);function ht(lt,q,se){bi===lt&&(q===void 0||q===ut)||(li(lt),se||(as(lt<Ze.length-1),$==null||$(lt)),q!==void 0&&_t(q))}function Rt(lt,q){Le(q.clientWidth)}function Pt(lt,q){st(function(se){var pe=new Map(se);return q===null?pe.delete(lt):pe.set(lt,q),pe})}function Ne(lt,q){Xt(q),ge(hi)}function Ct(lt,q){ii(q)}function at(lt){return nt.get(Ye(G[lt],lt))}(0,me.Z)(function(){if(We&&typeof c=="number"&&G){var lt=Si,q=G.length,se=q-1;if(!q){ht(0,null);return}for(var pe=0;pe<q;pe+=1){var Ce=at(pe);if(w&&(Ce=Ce||0),Ce===void 0){ht(pe-1,void 0,!0);break}if(lt+=Ce,se===0&<<=We||pe===se-1&<+at(se)<=We){ht(se,null);break}else if(lt+c>We){ht(pe-1,lt-Ce-Si+hi);break}}k&&at(0)+Si>We&&_t(null)}},[We,nt,hi,Si,Ye,G]);var Ke=ci&&!!J.length,et={};ut!==null&&p&&(et={position:"absolute",left:ut,top:0});var vt={prefixCls:Ge,responsive:p,component:D,invalidate:E},Lt=mt?function(lt,q){var se=Ye(lt,q);return A.createElement(Y.Provider,{key:se,value:(0,B.Z)((0,B.Z)({},vt),{},{order:q,item:lt,itemKey:se,registerSize:Pt,display:q<=_i})},mt(lt,q))}:function(lt,q){var se=Ye(lt,q);return A.createElement(j,(0,S.Z)({},vt,{order:q,key:se,item:lt,renderItem:Ve,itemKey:se,registerSize:Pt,display:q<=_i}))},Ut={order:Ke?_i:Number.MAX_SAFE_INTEGER,className:"".concat(Ge,"-rest"),registerSize:Ne,display:Ke},qt=Zt||Q,ki=Ht?A.createElement(Y.Provider,{value:(0,B.Z)((0,B.Z)({},vt),Ut)},Ht(J)):A.createElement(j,(0,S.Z)({},vt,Ut),typeof qt=="function"?qt(J):qt),rt=A.createElement(x,(0,S.Z)({className:oe()(!E&&Be,$e),style:bt,ref:_e},ae),G.map(Lt),T?ki:null,k&&A.createElement(j,(0,S.Z)({},vt,{responsive:f,responsiveDisabled:!p,order:_i,className:"".concat(Ge,"-suffix"),registerSize:Ct,display:!0,style:et}),k));return f?A.createElement(H.Z,{onResize:Rt,disabled:!p},rt):rt}var N=A.forwardRef(ie);N.displayName="Overflow",N.Item=He,N.RESPONSIVE=xe,N.INVALIDATE=ee;var we=N,je=we},29301:function(Wt,ze,R){"use strict";R.d(ze,{Z:function(){return ee}});var S=R(72308),B=R(59301),fe=R(11592),z=R(48736),A=R(77321),m=R(62853),oe=R(76846),H=R(8654),me=B.createContext(null);function Ae(Q){var ie=Q.children,N=Q.onBatchResize,we=B.useRef(0),je=B.useRef([]),Ee=B.useContext(me),_e=B.useCallback(function(Me,Be,Fe){we.current+=1;var Ze=we.current;je.current.push({size:Me,element:Be,data:Fe}),Promise.resolve().then(function(){Ze===we.current&&(N==null||N(je.current),je.current=[])}),Ee==null||Ee(Me,Be,Fe)},[N,Ee]);return B.createElement(me.Provider,{value:_e},ie)}var Pe=R(76374),ce=new Map;function I(Q){Q.forEach(function(ie){var N,we=ie.target;(N=ce.get(we))===null||N===void 0||N.forEach(function(je){return je(we)})})}var j=new Pe.Z(I),ct=null,Re=null;function De(Q,ie){ce.has(Q)||(ce.set(Q,new Set),j.observe(Q)),ce.get(Q).add(ie)}function K(Q,ie){ce.has(Q)&&(ce.get(Q).delete(ie),ce.get(Q).size||(j.unobserve(Q),ce.delete(Q)))}var P=R(96949),F=R(55090),Y=R(77205),X=R(38793),de=function(Q){(0,Y.Z)(N,Q);var ie=(0,X.Z)(N);function N(){return(0,P.Z)(this,N),ie.apply(this,arguments)}return(0,F.Z)(N,[{key:"render",value:function(){return this.props.children}}]),N}(B.Component);function ve(Q,ie){var N=Q.children,we=Q.disabled,je=B.useRef(null),Ee=B.useRef(null),_e=B.useContext(me),Me=typeof N=="function",Be=Me?N(je):N,Fe=B.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),Ze=!Me&&B.isValidElement(Be)&&(0,H.Yr)(Be),ot=Ze?(0,H.C4)(Be):null,mt=(0,H.x1)(ot,je),Et=function(){var bt;return(0,oe.ZP)(je.current)||(je.current&&(0,m.Z)(je.current)==="object"?(0,oe.ZP)((bt=je.current)===null||bt===void 0?void 0:bt.nativeElement):null)||(0,oe.ZP)(Ee.current)};B.useImperativeHandle(ie,function(){return Et()});var wt=B.useRef(Q);wt.current=Q;var Gt=B.useCallback(function(gt){var bt=wt.current,$e=bt.onResize,Vt=bt.data,Zt=gt.getBoundingClientRect(),Ht=Zt.width,k=Zt.height,C=gt.offsetWidth,x=gt.offsetHeight,D=Math.floor(Ht),$=Math.floor(k);if(Fe.current.width!==D||Fe.current.height!==$||Fe.current.offsetWidth!==C||Fe.current.offsetHeight!==x){var ae={width:D,height:$,offsetWidth:C,offsetHeight:x};Fe.current=ae;var w=C===Math.round(Ht)?Ht:C,V=x===Math.round(k)?k:x,W=(0,A.Z)((0,A.Z)({},ae),{},{offsetWidth:w,offsetHeight:V});_e==null||_e(W,gt,Vt),$e&&Promise.resolve().then(function(){$e(W,gt)})}},[]);return B.useEffect(function(){var gt=Et();return gt&&!we&&De(gt,Gt),function(){return K(gt,Gt)}},[je.current,we]),B.createElement(de,{ref:Ee},Ze?B.cloneElement(Be,{ref:mt}):Be)}var Z=B.forwardRef(ve),Oe=Z,He="rc-observer-key";function Qe(Q,ie){var N=Q.children,we=typeof N=="function"?[N]:(0,fe.Z)(N);return we.map(function(je,Ee){var _e=(je==null?void 0:je.key)||"".concat(He,"-").concat(Ee);return B.createElement(Oe,(0,S.Z)({},Q,{key:_e,ref:Ee===0?ie:void 0}),je)})}var xe=B.forwardRef(Qe);xe.Collection=Ae;var ee=xe},55477:function(Wt,ze,R){"use strict";R.d(ze,{G:function(){return I},Z:function(){return De}});var S=R(72308),B=R(77321),fe=R(74416),z=R(35593),A=R(59301),m={shiftX:64,adjustY:1},oe={adjustX:1,shiftY:!0},H=[0,0],me={left:{points:["cr","cl"],overflow:oe,offset:[-4,0],targetOffset:H},right:{points:["cl","cr"],overflow:oe,offset:[4,0],targetOffset:H},top:{points:["bc","tc"],overflow:m,offset:[0,-4],targetOffset:H},bottom:{points:["tc","bc"],overflow:m,offset:[0,4],targetOffset:H},topLeft:{points:["bl","tl"],overflow:m,offset:[0,-4],targetOffset:H},leftTop:{points:["tr","tl"],overflow:oe,offset:[-4,0],targetOffset:H},topRight:{points:["br","tr"],overflow:m,offset:[0,-4],targetOffset:H},rightTop:{points:["tl","tr"],overflow:oe,offset:[4,0],targetOffset:H},bottomRight:{points:["tr","br"],overflow:m,offset:[0,4],targetOffset:H},rightBottom:{points:["bl","br"],overflow:oe,offset:[4,0],targetOffset:H},bottomLeft:{points:["tl","bl"],overflow:m,offset:[0,4],targetOffset:H},leftBottom:{points:["br","bl"],overflow:oe,offset:[-4,0],targetOffset:H}},Ae=null,Pe=R(92310),ce=R.n(Pe);function I(K){var P=K.children,F=K.prefixCls,Y=K.id,X=K.overlayInnerStyle,de=K.className,ve=K.style;return A.createElement("div",{className:ce()("".concat(F,"-content"),de),style:ve},A.createElement("div",{className:"".concat(F,"-inner"),id:Y,role:"tooltip",style:X},typeof P=="function"?P():P))}var j=["overlayClassName","trigger","mouseEnterDelay","mouseLeaveDelay","overlayStyle","prefixCls","children","onVisibleChange","afterVisibleChange","transitionName","animation","motion","placement","align","destroyTooltipOnHide","defaultVisible","getTooltipContainer","overlayInnerStyle","arrowContent","overlay","id","showArrow"],ct=function(P,F){var Y=P.overlayClassName,X=P.trigger,de=X===void 0?["hover"]:X,ve=P.mouseEnterDelay,Z=ve===void 0?0:ve,Oe=P.mouseLeaveDelay,He=Oe===void 0?.1:Oe,Qe=P.overlayStyle,xe=P.prefixCls,ee=xe===void 0?"rc-tooltip":xe,Q=P.children,ie=P.onVisibleChange,N=P.afterVisibleChange,we=P.transitionName,je=P.animation,Ee=P.motion,_e=P.placement,Me=_e===void 0?"right":_e,Be=P.align,Fe=Be===void 0?{}:Be,Ze=P.destroyTooltipOnHide,ot=Ze===void 0?!1:Ze,mt=P.defaultVisible,Et=P.getTooltipContainer,wt=P.overlayInnerStyle,Gt=P.arrowContent,gt=P.overlay,bt=P.id,$e=P.showArrow,Vt=$e===void 0?!0:$e,Zt=(0,fe.Z)(P,j),Ht=(0,A.useRef)(null);(0,A.useImperativeHandle)(F,function(){return Ht.current});var k=(0,B.Z)({},Zt);"visible"in P&&(k.popupVisible=P.visible);var C=function(){return A.createElement(I,{key:"content",prefixCls:ee,id:bt,overlayInnerStyle:wt},gt)};return A.createElement(z.Z,(0,S.Z)({popupClassName:Y,prefixCls:ee,popup:C,action:de,builtinPlacements:me,popupPlacement:Me,ref:Ht,popupAlign:Fe,getPopupContainer:Et,onPopupVisibleChange:ie,afterPopupVisibleChange:N,popupTransitionName:we,popupAnimation:je,popupMotion:Ee,defaultPopupVisible:mt,autoDestroy:ot,mouseLeaveDelay:He,popupStyle:Qe,mouseEnterDelay:Z,arrow:Vt},k),Q)},Re=(0,A.forwardRef)(ct),De=Re},49658:function(Wt,ze){"use strict";ze.Z=function(){if(typeof navigator=="undefined"||typeof window=="undefined")return!1;var R=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(R)||/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(R==null?void 0:R.substr(0,4))}},83145:function(Wt,ze,R){"use strict";Object.defineProperty(ze,"__esModule",{value:!0}),ze.CopyToClipboard=void 0;var S=fe(R(59301)),B=fe(R(25769));function fe(P){return P&&P.__esModule?P:{default:P}}function z(P){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?z=function(Y){return typeof Y}:z=function(Y){return Y&&typeof Symbol=="function"&&Y.constructor===Symbol&&Y!==Symbol.prototype?"symbol":typeof Y},z(P)}function A(P,F){var Y=Object.keys(P);if(Object.getOwnPropertySymbols){var X=Object.getOwnPropertySymbols(P);F&&(X=X.filter(function(de){return Object.getOwnPropertyDescriptor(P,de).enumerable})),Y.push.apply(Y,X)}return Y}function m(P){for(var F=1;F<arguments.length;F++){var Y=arguments[F]!=null?arguments[F]:{};F%2?A(Y,!0).forEach(function(X){De(P,X,Y[X])}):Object.getOwnPropertyDescriptors?Object.defineProperties(P,Object.getOwnPropertyDescriptors(Y)):A(Y).forEach(function(X){Object.defineProperty(P,X,Object.getOwnPropertyDescriptor(Y,X))})}return P}function oe(P,F){if(P==null)return{};var Y=H(P,F),X,de;if(Object.getOwnPropertySymbols){var ve=Object.getOwnPropertySymbols(P);for(de=0;de<ve.length;de++)X=ve[de],!(F.indexOf(X)>=0)&&Object.prototype.propertyIsEnumerable.call(P,X)&&(Y[X]=P[X])}return Y}function H(P,F){if(P==null)return{};var Y={},X=Object.keys(P),de,ve;for(ve=0;ve<X.length;ve++)de=X[ve],!(F.indexOf(de)>=0)&&(Y[de]=P[de]);return Y}function me(P,F){if(!(P instanceof F))throw new TypeError("Cannot call a class as a function")}function Ae(P,F){for(var Y=0;Y<F.length;Y++){var X=F[Y];X.enumerable=X.enumerable||!1,X.configurable=!0,"value"in X&&(X.writable=!0),Object.defineProperty(P,X.key,X)}}function Pe(P,F,Y){return F&&Ae(P.prototype,F),Y&&Ae(P,Y),P}function ce(P,F){return F&&(z(F)==="object"||typeof F=="function")?F:j(P)}function I(P){return I=Object.setPrototypeOf?Object.getPrototypeOf:function(Y){return Y.__proto__||Object.getPrototypeOf(Y)},I(P)}function j(P){if(P===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return P}function ct(P,F){if(typeof F!="function"&&F!==null)throw new TypeError("Super expression must either be null or a function");P.prototype=Object.create(F&&F.prototype,{constructor:{value:P,writable:!0,configurable:!0}}),F&&Re(P,F)}function Re(P,F){return Re=Object.setPrototypeOf||function(X,de){return X.__proto__=de,X},Re(P,F)}function De(P,F,Y){return F in P?Object.defineProperty(P,F,{value:Y,enumerable:!0,configurable:!0,writable:!0}):P[F]=Y,P}var K=function(P){ct(F,P);function F(){var Y,X;me(this,F);for(var de=arguments.length,ve=new Array(de),Z=0;Z<de;Z++)ve[Z]=arguments[Z];return X=ce(this,(Y=I(F)).call.apply(Y,[this].concat(ve))),De(j(X),"onClick",function(Oe){var He=X.props,Qe=He.text,xe=He.onCopy,ee=He.children,Q=He.options,ie=S.default.Children.only(ee),N=(0,B.default)(Qe,Q);xe&&xe(Qe,N),ie&&ie.props&&typeof ie.props.onClick=="function"&&ie.props.onClick(Oe)}),X}return Pe(F,[{key:"render",value:function(){var X=this.props,de=X.text,ve=X.onCopy,Z=X.options,Oe=X.children,He=oe(X,["text","onCopy","options","children"]),Qe=S.default.Children.only(Oe);return S.default.cloneElement(Qe,m({},He,{onClick:this.onClick}))}}]),F}(S.default.PureComponent);ze.CopyToClipboard=K,De(K,"defaultProps",{onCopy:void 0,options:void 0})},56102:function(Wt,ze,R){"use strict";var S=R(83145),B=S.CopyToClipboard;B.CopyToClipboard=B,Wt.exports=B},76374:function(Wt,ze,R){"use strict";var S=function(){if(typeof Map!="undefined")return Map;function ee(Q,ie){var N=-1;return Q.some(function(we,je){return we[0]===ie?(N=je,!0):!1}),N}return function(){function Q(){this.__entries__=[]}return Object.defineProperty(Q.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),Q.prototype.get=function(ie){var N=ee(this.__entries__,ie),we=this.__entries__[N];return we&&we[1]},Q.prototype.set=function(ie,N){var we=ee(this.__entries__,ie);~we?this.__entries__[we][1]=N:this.__entries__.push([ie,N])},Q.prototype.delete=function(ie){var N=this.__entries__,we=ee(N,ie);~we&&N.splice(we,1)},Q.prototype.has=function(ie){return!!~ee(this.__entries__,ie)},Q.prototype.clear=function(){this.__entries__.splice(0)},Q.prototype.forEach=function(ie,N){N===void 0&&(N=null);for(var we=0,je=this.__entries__;we<je.length;we++){var Ee=je[we];ie.call(N,Ee[1],Ee[0])}},Q}()}(),B=typeof window!="undefined"&&typeof document!="undefined"&&window.document===document,fe=function(){return typeof R.g!="undefined"&&R.g.Math===Math?R.g:typeof self!="undefined"&&self.Math===Math?self:typeof window!="undefined"&&window.Math===Math?window:Function("return this")()}(),z=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(fe):function(ee){return setTimeout(function(){return ee(Date.now())},1e3/60)}}(),A=2;function m(ee,Q){var ie=!1,N=!1,we=0;function je(){ie&&(ie=!1,ee()),N&&_e()}function Ee(){z(je)}function _e(){var Me=Date.now();if(ie){if(Me-we<A)return;N=!0}else ie=!0,N=!1,setTimeout(Ee,Q);we=Me}return _e}var oe=20,H=["top","right","bottom","left","width","height","size","weight"],me=typeof MutationObserver!="undefined",Ae=function(){function ee(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=m(this.refresh.bind(this),oe)}return ee.prototype.addObserver=function(Q){~this.observers_.indexOf(Q)||this.observers_.push(Q),this.connected_||this.connect_()},ee.prototype.removeObserver=function(Q){var ie=this.observers_,N=ie.indexOf(Q);~N&&ie.splice(N,1),!ie.length&&this.connected_&&this.disconnect_()},ee.prototype.refresh=function(){var Q=this.updateObservers_();Q&&this.refresh()},ee.prototype.updateObservers_=function(){var Q=this.observers_.filter(function(ie){return ie.gatherActive(),ie.hasActive()});return Q.forEach(function(ie){return ie.broadcastActive()}),Q.length>0},ee.prototype.connect_=function(){!B||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),me?(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)},ee.prototype.disconnect_=function(){!B||!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)},ee.prototype.onTransitionEnd_=function(Q){var ie=Q.propertyName,N=ie===void 0?"":ie,we=H.some(function(je){return!!~N.indexOf(je)});we&&this.refresh()},ee.getInstance=function(){return this.instance_||(this.instance_=new ee),this.instance_},ee.instance_=null,ee}(),Pe=function(ee,Q){for(var ie=0,N=Object.keys(Q);ie<N.length;ie++){var we=N[ie];Object.defineProperty(ee,we,{value:Q[we],enumerable:!1,writable:!1,configurable:!0})}return ee},ce=function(ee){var Q=ee&&ee.ownerDocument&&ee.ownerDocument.defaultView;return Q||fe},I=de(0,0,0,0);function j(ee){return parseFloat(ee)||0}function ct(ee){for(var Q=[],ie=1;ie<arguments.length;ie++)Q[ie-1]=arguments[ie];return Q.reduce(function(N,we){var je=ee["border-"+we+"-width"];return N+j(je)},0)}function Re(ee){for(var Q=["top","right","bottom","left"],ie={},N=0,we=Q;N<we.length;N++){var je=we[N],Ee=ee["padding-"+je];ie[je]=j(Ee)}return ie}function De(ee){var Q=ee.getBBox();return de(0,0,Q.width,Q.height)}function K(ee){var Q=ee.clientWidth,ie=ee.clientHeight;if(!Q&&!ie)return I;var N=ce(ee).getComputedStyle(ee),we=Re(N),je=we.left+we.right,Ee=we.top+we.bottom,_e=j(N.width),Me=j(N.height);if(N.boxSizing==="border-box"&&(Math.round(_e+je)!==Q&&(_e-=ct(N,"left","right")+je),Math.round(Me+Ee)!==ie&&(Me-=ct(N,"top","bottom")+Ee)),!F(ee)){var Be=Math.round(_e+je)-Q,Fe=Math.round(Me+Ee)-ie;Math.abs(Be)!==1&&(_e-=Be),Math.abs(Fe)!==1&&(Me-=Fe)}return de(we.left,we.top,_e,Me)}var P=function(){return typeof SVGGraphicsElement!="undefined"?function(ee){return ee instanceof ce(ee).SVGGraphicsElement}:function(ee){return ee instanceof ce(ee).SVGElement&&typeof ee.getBBox=="function"}}();function F(ee){return ee===ce(ee).document.documentElement}function Y(ee){return B?P(ee)?De(ee):K(ee):I}function X(ee){var Q=ee.x,ie=ee.y,N=ee.width,we=ee.height,je=typeof DOMRectReadOnly!="undefined"?DOMRectReadOnly:Object,Ee=Object.create(je.prototype);return Pe(Ee,{x:Q,y:ie,width:N,height:we,top:ie,right:Q+N,bottom:we+ie,left:Q}),Ee}function de(ee,Q,ie,N){return{x:ee,y:Q,width:ie,height:N}}var ve=function(){function ee(Q){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=de(0,0,0,0),this.target=Q}return ee.prototype.isActive=function(){var Q=Y(this.target);return this.contentRect_=Q,Q.width!==this.broadcastWidth||Q.height!==this.broadcastHeight},ee.prototype.broadcastRect=function(){var Q=this.contentRect_;return this.broadcastWidth=Q.width,this.broadcastHeight=Q.height,Q},ee}(),Z=function(){function ee(Q,ie){var N=X(ie);Pe(this,{target:Q,contentRect:N})}return ee}(),Oe=function(){function ee(Q,ie,N){if(this.activeObservations_=[],this.observations_=new S,typeof Q!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=Q,this.controller_=ie,this.callbackCtx_=N}return ee.prototype.observe=function(Q){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(Q instanceof ce(Q).Element))throw new TypeError('parameter 1 is not of type "Element".');var ie=this.observations_;ie.has(Q)||(ie.set(Q,new ve(Q)),this.controller_.addObserver(this),this.controller_.refresh())}},ee.prototype.unobserve=function(Q){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element=="undefined"||!(Element instanceof Object))){if(!(Q instanceof ce(Q).Element))throw new TypeError('parameter 1 is not of type "Element".');var ie=this.observations_;ie.has(Q)&&(ie.delete(Q),ie.size||this.controller_.removeObserver(this))}},ee.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},ee.prototype.gatherActive=function(){var Q=this;this.clearActive(),this.observations_.forEach(function(ie){ie.isActive()&&Q.activeObservations_.push(ie)})},ee.prototype.broadcastActive=function(){if(this.hasActive()){var Q=this.callbackCtx_,ie=this.activeObservations_.map(function(N){return new Z(N.target,N.broadcastRect())});this.callback_.call(Q,ie,Q),this.clearActive()}},ee.prototype.clearActive=function(){this.activeObservations_.splice(0)},ee.prototype.hasActive=function(){return this.activeObservations_.length>0},ee}(),He=typeof WeakMap!="undefined"?new WeakMap:new S,Qe=function(){function ee(Q){if(!(this instanceof ee))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var ie=Ae.getInstance(),N=new Oe(Q,ie,this);He.set(this,N)}return ee}();["observe","unobserve","disconnect"].forEach(function(ee){Qe.prototype[ee]=function(){var Q;return(Q=He.get(this))[ee].apply(Q,arguments)}});var xe=function(){return typeof fe.ResizeObserver!="undefined"?fe.ResizeObserver:Qe}();ze.Z=xe},98040:function(Wt){Wt.exports=function(){var ze=document.getSelection();if(!ze.rangeCount)return function(){};for(var R=document.activeElement,S=[],B=0;B<ze.rangeCount;B++)S.push(ze.getRangeAt(B));switch(R.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":R.blur();break;default:R=null;break}return ze.removeAllRanges(),function(){ze.type==="Caret"&&ze.removeAllRanges(),ze.rangeCount||S.forEach(function(fe){ze.addRange(fe)}),R&&R.focus()}}},82059:function(Wt){var ze=arguments[3],R=arguments[4],S=arguments[5],B=JSON.stringify;Wt.exports=function(fe,z){for(var A,m=Object.keys(S),oe=0,H=m.length;oe<H;oe++){var me=m[oe],Ae=S[me].exports;if(Ae===fe||Ae&&Ae.default===fe){A=me;break}}if(!A){A=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var Pe={},oe=0,H=m.length;oe<H;oe++){var me=m[oe];Pe[me]=me}R[A]=["function(require,module,exports){"+fe+"(self); }",Pe]}var ce=Math.floor(Math.pow(16,8)*Math.random()).toString(16),I={};I[A]=A,R[ce]=["function(require,module,exports){var f = require("+B(A)+");(f.default ? f.default : f)(self);}",I];var j={};ct(ce);function ct(Y){j[Y]=!0;for(var X in R[Y][1]){var de=R[Y][1][X];j[de]||ct(de)}}var Re="("+ze+")({"+Object.keys(j).map(function(Y){return B(Y)+":["+R[Y][0]+","+B(R[Y][1])+"]"}).join(",")+"},{},["+B(ce)+"])",De=window.URL||window.webkitURL||window.mozURL||window.msURL,K=new Blob([Re],{type:"text/javascript"});if(z&&z.bare)return K;var P=De.createObjectURL(K),F=new Worker(P);return F.objectURL=P,F}},65157:function(Wt,ze,R){"use strict";R.d(ze,{ZP:function(){return vn}});const S=Number.isFinite||function(a){return typeof a=="number"&&isFinite(a)},B=Number.isSafeInteger||function(a){return typeof a=="number"&&Math.abs(a)<=fe},fe=Number.MAX_SAFE_INTEGER||9007199254740991;let z=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}({}),m=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 oe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},H={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};class me{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 Ae{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 me(e),this.fast_=new me(t),this.defaultTTFB_=s,this.ttfb_=new me(e)}update(e,t){const{slow_:i,fast_:s,ttfb_:n}=this;i.halfLife!==e&&(this.slow_=new me(e,i.getEstimate(),i.getTotalWeight())),s.halfLife!==t&&(this.fast_=new me(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new me(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 Pe(a,e,t){return(e=Re(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function ce(){return ce=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},ce.apply(null,arguments)}function I(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 j(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?I(Object(t),!0).forEach(function(i){Pe(a,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):I(Object(t)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(t,i))})}return a}function ct(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 Re(a){var e=ct(a,"string");return typeof e=="symbol"?e:e+""}class De{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=K,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 K=function(){},P={trace:K,debug:K,log:K,warn:K,info:K,error:K};function F(){return ce({},P)}function Y(a,e){const t=self.console[a];return t?t.bind(self.console,`${e?"["+e+"] ":""}[${a}] >`):K}function X(a,e,t){return e[a]?e[a].bind(e):Y(a,t)}const de=F();function ve(a,e,t){const i=F();if(typeof console=="object"&&a===!0||typeof a=="object"){const s=["debug","log","info","warn","error"];s.forEach(n=>{i[n]=X(n,a,t)});try{i.log(`Debug logs enabled for "${e}" in hls.js version 1.6.0`)}catch(n){return F()}s.forEach(n=>{de[n]=X(n,a)})}else ce(de,i);return i}const Z=de;function Oe(a=!0){return typeof self=="undefined"?void 0:(a||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function He(a){return typeof self!="undefined"&&a===self.ManagedMediaSource}function Qe(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 xe(a,e=!1){if(typeof TextDecoder!="undefined"){const l=new TextDecoder("utf-8").decode(a);if(e){const d=l.indexOf("\0");return d!==-1?l.substring(0,d):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}const ee={hexDump:function(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 Q(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var ie={exports:{}},N;function we(){return N||(N=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,d){if(d=d||{},u=u.trim(),l=l.trim(),!l){if(!d.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 g=o.parseURL(l);if(!g)throw new Error("Error trying to parse relative URL.");if(g.scheme)return d.alwaysNormalize?(g.path=o.normalizePath(g.path),o.buildURLFromParts(g)):l;var y=o.parseURL(u);if(!y)throw new Error("Error trying to parse base URL.");if(!y.netLoc&&y.path&&y.path[0]!=="/"){var v=s.exec(y.path);y.netLoc=v[1],y.path=v[2]}y.netLoc&&!y.path&&(y.path="/");var _={scheme:y.scheme,netLoc:g.netLoc,path:null,params:g.params,query:g.query,fragment:g.fragment};if(!g.netLoc&&(_.netLoc=y.netLoc,g.path[0]!=="/"))if(!g.path)_.path=y.path,g.params||(_.params=y.params,g.query||(_.query=y.query));else{var b=y.path,L=b.substring(0,b.lastIndexOf("/")+1)+g.path;_.path=o.normalizePath(L)}return _.path===null&&(_.path=d.alwaysNormalize?o.normalizePath(g.path):g.path),o.buildURLFromParts(_)},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})()}(ie)),ie.exports}var je=we();class Ee{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 _e={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Me{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,mt(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={[_e.AUDIO]:null,[_e.VIDEO]:null,[_e.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 Ee),this._stats}set stats(e){this._stats=e}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=je.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[_e.AUDIO]=null,e[_e.VIDEO]=null,e[_e.AUDIOVIDEO]=null}}function Be(a){return a.sn!=="initSegment"}class Fe extends Me{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){const e=this.byteRange[0],t=this.byteRange[1];if(S(e)&&S(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(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null)return null;const e=S(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){const t=Object.keys(this.levelkeys),i=t.length;if(i>1||i===1&&this.levelkeys[t[0]].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(!S(e)){this._programDateTime=this.rawProgramDateTime=null;return}this._programDateTime=e}get ref(){return Be(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){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}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 Ze extends Me{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 ot(a,e){const t=Object.getPrototypeOf(a);if(t){const i=Object.getOwnPropertyDescriptor(t,e);return i||ot(t,e)}}function mt(a,e){const t=ot(a,e);t&&(t.enumerable=!0,Object.defineProperty(a,e,t))}const Et=Math.pow(2,32)-1,wt=[].push,Gt={video:1,audio:2,id3:3,text:4};function gt(a){return String.fromCharCode.apply(null,a)}function bt(a,e){const t=a[e]<<8|a[e+1];return t<0?65536+t:t}function $e(a,e){const t=Zt(a,e);return t<0?4294967296+t:t}function Vt(a,e){let t=$e(a,e);return t*=Math.pow(2,32),t+=$e(a,e+4),t}function Zt(a,e){return a[e]<<24|a[e+1]<<16|a[e+2]<<8|a[e+3]}function Ht(a,e,t){a[e]=t>>24,a[e+1]=t>>16&255,a[e+2]=t>>8&255,a[e+3]=t&255}function k(a){const e=a.byteLength;for(let t=0;t<e;){const i=$e(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 C(a,e){const t=[];if(!e.length)return t;const i=a.byteLength;for(let s=0;s<i;){const n=$e(a,s),r=gt(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=C(a.subarray(s+8,o),e.slice(1));u.length&&wt.apply(t,u)}s=o}return t}function x(a){const e=[],t=a[0];let i=8;const s=$e(a,i);i+=4;let n=0,r=0;t===0?(n=$e(a,i),r=$e(a,i+4),i+=8):(n=Vt(a,i),r=Vt(a,i+8),i+=16),i+=2;let o=a.length+r;const u=bt(a,i);i+=2;for(let l=0;l<u;l++){let d=i;const h=$e(a,d);d+=4;const g=h&2147483647;if((h&2147483648)>>>31===1)return Z.warn("SIDX has hierarchical references (not supported)"),null;const v=$e(a,d);d+=4,e.push({referenceSize:g,subsegmentDuration:v,info:{duration:v/s,start:o,end:o+g-1}}),o+=g,d+=4,i=d}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:u,references:e}}function D(a){const e=[],t=C(a,["moov","trak"]);for(let s=0;s<t.length;s++){const n=t[s],r=C(n,["tkhd"])[0];if(r){let o=r[0];const u=$e(r,o===0?12:20),l=C(n,["mdia","mdhd"])[0];if(l){o=l[0];const d=$e(l,o===0?12:20),h=C(n,["mdia","hdlr"])[0];if(h){const g=gt(h.subarray(8,12)),y={soun:_e.AUDIO,vide:_e.VIDEO}[g],v=C(n,["mdia","minf","stbl","stsd"])[0],_=$(v);y?(e[u]={timescale:d,type:y,stsd:_},e[y]=j({timescale:d,id:u},_)):e[u]={timescale:d,type:g,stsd:_}}}}}return C(a,["moov","mvex","trex"]).forEach(s=>{const n=$e(s,4),r=e[n];r&&(r.default={duration:$e(s,12),flags:$e(s,20)})}),e}function $(a){const e=a.subarray(8),t=e.subarray(86),i=gt(e.subarray(4,8));let s=i,n;const r=i==="enca"||i==="encv";if(r){const l=C(e,[i])[0].subarray(i==="enca"?28:78);C(l,["sinf"]).forEach(h=>{const g=C(h,["schm"])[0];if(g){const y=gt(g.subarray(4,8));if(y==="cbcs"||y==="cenc"){const v=C(h,["frma"])[0];v&&(s=gt(v))}}})}const o=s;switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const u=C(t,["avcC"])[0];s+="."+V(u[1])+V(u[2])+V(u[3]),n=ae(o==="avc1"?"dva1":"dvav",t);break}case"mp4a":{const u=C(e,[i])[0],l=C(u.subarray(28),["esds"])[0];if(l&&l.length>7){let d=4;if(l[d++]!==3)break;d=w(l,d),d+=2;const h=l[d++];if(h&128&&(d+=2),h&64&&(d+=l[d++]),l[d++]!==4)break;d=w(l,d);const g=l[d++];if(g===64)s+="."+V(g);else break;if(d+=12,l[d++]!==5)break;d=w(l,d);const y=l[d++];let v=(y&248)>>3;v===31&&(v+=1+((y&7)<<3)+((l[d]&224)>>5)),s+="."+v}break}case"hvc1":case"hev1":{const u=C(t,["hvcC"]);if(u){const l=u[0],d=l[1],h=["","A","B","C"][d>>6],g=d&31,y=$e(l,2),v=(d&32)>>5?"H":"L",_=l[12],b=l.subarray(6,12);s+="."+h+g,s+="."+y.toString(16).toUpperCase(),s+="."+v+_;let L="";for(let U=b.length;U--;){const M=b[U];(M||L)&&(L="."+M.toString(16).toUpperCase()+L)}s+=L}n=ae(o=="hev1"?"dvhe":"dvh1",t);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":{s=ae(s,t)||s;break}case"vp09":{const u=C(t,["vpcC"])[0],l=u[4],d=u[5],h=u[6]>>4&15;s+="."+W(l)+"."+W(d)+"."+W(h);break}case"av01":{const u=C(t,["av1C"])[0],l=u[1]>>>5,d=u[1]&31,h=u[2]>>>7?"H":"M",g=(u[2]&64)>>6,y=(u[2]&32)>>5,v=l===2&&g?y?12:10:g?10:8,_=(u[2]&16)>>4,b=(u[2]&8)>>3,L=(u[2]&4)>>2,U=u[2]&3;s+="."+l+"."+W(d)+h+"."+W(v)+"."+_+"."+b+L+U+"."+W(1)+"."+W(1)+"."+W(1)+"."+0,n=ae("dav1",t);break}}return{codec:s,encrypted:r,supplemental:n}}function ae(a,e){const t=C(e,["dvvC"]),i=t.length?t[0]:C(e,["dvcC"])[0];if(i){const s=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return a+"."+W(s)+"."+W(n)}}function w(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 W(a){return(a<10?"0":"")+a}function O(a,e){if(!a||!e)return a;const t=e.keyId;return t&&e.isCommonEncryption&&C(a,["moov","trak"]).forEach(s=>{const r=C(s,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=C(r,["enca"]);const u=o.length>0;u||(o=C(r,["encv"])),o.forEach(l=>{const d=u?l.subarray(28):l.subarray(78);C(d,["sinf"]).forEach(g=>{const y=le(g);if(y){const v=y.subarray(8,24);v.some(_=>_!==0)||(Z.log(`[eme] Patching keyId in 'enc${u?"a":"v"}>sinf>>tenc' box: ${ee.hexDump(v)} -> ${ee.hexDump(t)}`),y.set(t,8))}})})}),a}function le(a){const e=C(a,["schm"])[0];if(e){const t=gt(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return C(a,["schi","tenc"])[0]}return null}function Le(a,e){return C(e,["moof","traf"]).reduce((t,i)=>{const s=C(i,["tfdt"])[0],n=s[0],r=C(i,["tfhd"]).reduce((o,u)=>{const l=$e(u,4),d=a[l];if(d){let h=$e(s,4);if(n===1){if(h===Et)return Z.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;h*=Et+1,h+=$e(s,8)}const g=d.timescale||9e4,y=h/g;if(S(y)&&(o===null||y<o))return y}return o},null);return r!==null&&S(r)&&(t===null||r<t)?r:t},null)}function We(a,e){let t=0,i=0,s=0;const n=C(a,["moof","traf"]);for(let r=0;r<n.length;r++){const o=n[r],u=C(o,["tfhd"])[0],l=$e(u,4),d=e[l];if(!d)continue;const h=d.default,g=$e(u,0)|(h==null?void 0:h.flags);let y=h==null?void 0:h.duration;g&8&&(g&2?y=$e(u,12):y=$e(u,8));const v=d.timescale||9e4,_=C(o,["trun"]);for(let b=0;b<_.length;b++){if(t=Je(_[b]),!t&&y){const L=$e(_[b],4);t=y*L}d.type===_e.VIDEO?i+=t/v:d.type===_e.AUDIO&&(s+=t/v)}}if(i===0&&s===0){let r=1/0,o=0,u=0;const l=C(a,["sidx"]);for(let d=0;d<l.length;d++){const h=x(l[d]);if(h!=null&&h.references){r=Math.min(r,h.earliestPresentationTime/h.timescale);const g=h.references.reduce((y,v)=>y+v.info.duration||0,0);o=Math.max(o,g+h.earliestPresentationTime/h.timescale),u=o-r}}if(u&&S(u))return u}return i||s}function Je(a){const e=$e(a,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0;const s=$e(a,4);for(let n=0;n<s;n++){if(e&256){const r=$e(a,t);i+=r,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function ft(a,e,t){C(e,["moof","traf"]).forEach(i=>{C(i,["tfhd"]).forEach(s=>{const n=$e(s,4),r=a[n];if(!r)return;const o=r.timescale||9e4;C(i,["tfdt"]).forEach(u=>{const l=u[0],d=t*o;if(d){let h=$e(u,4);if(l===0)h-=d,h=Math.max(h,0),Ht(u,4,h);else{h*=Math.pow(2,32),h+=$e(u,8),h-=d,h=Math.max(h,0);const g=Math.floor(h/(Et+1)),y=Math.floor(h%(Et+1));Ht(u,4,g),Ht(u,8,y)}}})})})}function nt(a){const e={valid:null,remainder:null},t=C(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 st(a,e){const t=new Uint8Array(a.length+e.length);return t.set(a),t.set(e,a.length),t}function tt(a,e){const t=[],i=e.samples,s=e.timescale,n=e.id;let r=!1;return C(i,["moof"]).map(u=>{const l=u.byteOffset-8;C(u,["traf"]).map(h=>{const g=C(h,["tfdt"]).map(y=>{const v=y[0];let _=$e(y,4);return v===1&&(_*=Math.pow(2,32),_+=$e(y,8)),_/s})[0];return g!==void 0&&(a=g),C(h,["tfhd"]).map(y=>{const v=$e(y,4),_=$e(y,0)&16777215,b=(_&1)!==0,L=(_&2)!==0,U=(_&8)!==0;let M=0;const te=(_&16)!==0;let ne=0;const be=(_&32)!==0;let re=8;v===n&&(b&&(re+=8),L&&(re+=4),U&&(M=$e(y,re),re+=4),te&&(ne=$e(y,re),re+=4),be&&(re+=4),e.type==="video"&&(r=It(e.codec)),C(h,["trun"]).map(ye=>{const Te=ye[0],ue=$e(ye,0)&16777215,Xe=(ue&1)!==0;let dt=0;const Ei=(ue&4)!==0,zt=(ue&256)!==0;let Nt=0;const St=(ue&512)!==0;let $t=0;const Dt=(ue&1024)!==0,qe=(ue&2048)!==0;let it=0;const Jt=$e(ye,4);let Yt=8;Xe&&(dt=$e(ye,Yt),Yt+=4),Ei&&(Yt+=4);let mi=dt+l;for(let wi=0;wi<Jt;wi++){if(zt?(Nt=$e(ye,Yt),Yt+=4):Nt=M,St?($t=$e(ye,Yt),Yt+=4):$t=ne,Dt&&(Yt+=4),qe&&(Te===0?it=$e(ye,Yt):it=Zt(ye,Yt),Yt+=4),e.type===_e.VIDEO){let Ui=0;for(;Ui<$t;){const Hi=$e(i,mi);if(mi+=4,Ot(r,i[mi])){const As=i.subarray(mi,mi+Hi);ge(As,r?2:1,a+it/s,t)}mi+=Hi,Ui+=Hi+4}}a+=Nt/s}}))})})}),t}function It(a){if(!a)return!1;const e=a.substring(0,4);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Ot(a,e){if(a){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function ge(a,e,t,i){const s=ei(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 d=n;if(o<l)n+=o;else if(o>l){Z.error(`Malformed SEI payload. ${o} is too small, only ${l} bytes left to parse.`);break}if(r===4){if(s[d++]===181){const g=bt(s,d);if(d+=2,g===49){const y=$e(s,d);if(d+=4,y===1195456820){const v=s[d++];if(v===3){const _=s[d++],b=31&_,L=64&_,U=L?2+b*3:0,M=new Uint8Array(U);if(L){M[0]=_;for(let te=1;te<U;te++)M[te]=s[d++]}i.push({type:v,payloadType:r,pts:t,bytes:M})}}}}}else if(r===5&&o>16){const h=[];for(let v=0;v<16;v++){const _=s[d++].toString(16);h.push(_.length==1?"0"+_:_),(v===3||v===5||v===7||v===9)&&h.push("-")}const g=o-16,y=new Uint8Array(g);for(let v=0;v<g;v++)y[v]=s[d++];i.push({payloadType:r,pts:t,uuid:h.join(""),userData:xe(y),userDataBytes:y})}}}function ei(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 ti(a){const e=a[0];let t="",i="",s=0,n=0,r=0,o=0,u=0,l=0;if(e===0){for(;gt(a.subarray(l,l+1))!=="\0";)t+=gt(a.subarray(l,l+1)),l+=1;for(t+=gt(a.subarray(l,l+1)),l+=1;gt(a.subarray(l,l+1))!=="\0";)i+=gt(a.subarray(l,l+1)),l+=1;i+=gt(a.subarray(l,l+1)),l+=1,s=$e(a,12),n=$e(a,16),o=$e(a,20),u=$e(a,24),l=28}else if(e===1){l+=4,s=$e(a,l),l+=4;const h=$e(a,l);l+=4;const g=$e(a,l);for(l+=4,r=Wo(2,32)*h+g,B(r)||(r=Number.MAX_SAFE_INTEGER,Z.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=$e(a,l),l+=4,u=$e(a,l),l+=4;gt(a.subarray(l,l+1))!=="\0";)t+=gt(a.subarray(l,l+1)),l+=1;for(t+=gt(a.subarray(l,l+1)),l+=1;gt(a.subarray(l,l+1))!=="\0";)i+=gt(a.subarray(l,l+1)),l+=1;i+=gt(a.subarray(l,l+1)),l+=1}const d=a.subarray(l,a.byteLength);return{schemeIdUri:t,value:i,timeScale:s,presentationTime:r,presentationTimeDelta:n,eventDuration:o,id:u,payload:d}}function hi(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 Xt(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&&t.byteLength>0&&new DataView(r.buffer).setUint32(0,t.byteLength,!1),hi([112,115,115,104],new Uint8Array([i,0,0,0]),a,n,s,r,t||new Uint8Array)}function Ti(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=gi(s);e.push(n),i+=n.size}}return e}function gi(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=ee.hexDump(new Uint8Array(r,t+12,16)),u=a.getUint32(28);let l=null,d=null;if(n===0){if(e-32<u||u<22)return{offset:t,size:e};d=new Uint8Array(r,t+32,u)}else if(n===1){if(!u||i<t+32+u*16+16)return{offset:t,size:e};l=[];for(let h=0;h<u;h++)l.push(new Uint8Array(r,t+32+h*16,16))}return{version:n,systemId:o,kids:l,data:d,offset:t,size:e}}const Si=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),ii={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 Mi(a,e){const t=ii[e];return!!t&&!!t[a.slice(0,4)]}function Qt(a,e,t=!0){return!a.split(",").some(i=>!ut(i,e,t))}function ut(a,e,t=!0){var i;const s=Oe(t);return(i=s==null?void 0:s.isTypeSupported(_t(a,e)))!=null?i:!1}function _t(a,e){return`${e}/mp4;codecs=${a}`}function si(a){if(a){const e=a.substring(0,4);return ii.video[e]}return 2}function At(a){const e=Si();return a.split(",").reduce((t,i)=>{const n=e&&It(i)?9:ii.video[i];return n?(n*2+t)/(t?3:2):(ii.audio[i]+t)/(t?2:1)},0)}const bi={};function li(a,e=!0){if(bi[a])return bi[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(ut(t[s],"audio",e))return bi[a]=t[s],t[s];if(t[s]==="mp3"&&(i=Oe(e))!=null&&i.isTypeSupported("audio/mpeg"))return""}return a}const _i=/flac|opus|mp4a\.40\.34/i;function pi(a,e=!0){return a.replace(_i,t=>li(t.toLowerCase(),e))}function ri(a,e){const t=[];if(a){const i=a.split(",");for(let s=0;s<i.length;s++)Mi(i[s],"video")||t.push(i[s])}return e&&t.push(e),t.join(",")}function ci(a,e){if(a&&(a.length>4||["ac-3","ec-3","alac","fLaC","Opus"].indexOf(a)!==-1))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 as(a){const e=a.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");if(i.length>2){let s=i.shift()+".";s+=parseInt(i.shift()).toString(16),s+=("000"+parseInt(i.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}function Ge(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 c(a){const e=Oe(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 f(a){return a.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const p={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function E(a,e){return{supported:!1,configurations:e,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:a}}const T={};function G(a,e,t,i,s,n){const r=a.audioCodec?a.audioGroups:null,o=n==null?void 0:n.audioCodec,u=n==null?void 0:n.channels,l=u?parseInt(u):o?1/0:2;let d=null;if(r!=null&&r.length)try{r.length===1&&r[0]?d=e.groups[r[0]].channels:d=r.reduce((h,g)=>{if(g){const y=e.groups[g];if(!y)throw new Error(`Audio track group ${g} not found`);Object.keys(y.channels).forEach(v=>{h[v]=(h[v]||0)+y.channels[v]})}return h},{2:0})}catch(h){return!0}return a.videoCodec!==void 0&&(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))||!!d&&S(l)&&Object.keys(d).some(h=>parseInt(h)>l)}function J(a,e,t){const i=a.videoCodec,s=a.audioCodec;if(!i&&!s||!t)return Promise.resolve(p);const n=[];if(i){const r={width:a.width,height:a.height,bitrate:Math.ceil(Math.max(a.bitrate*.9,a.averageBitrate)),framerate:a.frameRate||30},o=a.videoRange;o!=="SDR"&&(r.transferFunction=o.toLowerCase());const u=i.split(","),l=navigator.userAgent;if(u.some(d=>It(d))&&Si())return Promise.resolve(E(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (${l})`),n));n.push.apply(n,u.map(d=>({type:"media-source",video:j(j({},r),{},{contentType:_t(Ge(d),"video")})})))}return s&&a.audioGroups&&a.audioGroups.forEach(r=>{var o;r&&((o=e.groups[r])==null||o.tracks.forEach(u=>{if(u.groupId===r){const l=u.channels||"",d=parseFloat(l);S(d)&&d>2&&n.push.apply(n,s.split(",").map(h=>({type:"media-source",audio:{contentType:_t(h,"audio"),channels:""+d}})))}}))}),Promise.all(n.map(r=>{const o=Ye(r);return T[o]||(T[o]=t.decodingInfo(r))})).then(r=>({supported:!r.some(o=>!o.supported),configurations:n,decodingInfoResults:r})).catch(r=>({supported:!1,configurations:n,decodingInfoResults:[],error:r}))}function Ye(a){const{audio:e,video:t}=a,i=t||e;if(i){const s=f(i.contentType);if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}const Ve=["NONE","TYPE-0","TYPE-1",null];function ht(a){return Ve.indexOf(a)>-1}const Rt=["SDR","PQ","HLG"];function Pt(a){return!!a&&Rt.indexOf(a)>-1}var Ne={No:"",Yes:"YES",v2:"v2"};function Ct(a){const{canSkipUntil:e,canSkipDateRanges:t,age:i}=a,s=i<e/2;return e&&s?t?Ne.v2:Ne.Yes:Ne.No}class at{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 Ke{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 et(this._audioGroups,e)}hasSubtitleGroup(e){return et(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 et(a,e){return!e||!a?!1:a.indexOf(e)!==-1}function vt(){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 Lt(a,e){let t=!1,i=[];if(a&&(t=a!=="SDR",i=[a]),e){i=e.allowedVideoRanges||Rt.slice(0);const s=i.join("")!=="SDR"&&!e.videoCodec;t=e.preferHDR!==void 0?e.preferHDR:s&&vt(),t||(i=["SDR"])}return{preferHDR:t,allowedVideoRanges:i}}const Ut=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}},qt=(a,e)=>JSON.stringify(a,Ut(e));function ki(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 d=!1,h=!1,g=1/0,y=1/0,v=1/0,_=1/0,b=0,L=[];const{preferHDR:U,allowedVideoRanges:M}=Lt(e,s);for(let ye=n.length;ye--;){const Te=a[n[ye]];d||(d=Te.channels[2]>0),g=Math.min(g,Te.minHeight),y=Math.min(y,Te.minFramerate),v=Math.min(v,Te.minBitrate),M.filter(Xe=>Te.videoRanges[Xe]>0).length>0&&(h=!0)}g=S(g)?g:0,y=S(y)?y:0;const te=Math.max(1080,g),ne=Math.max(30,y);v=S(v)?v:t,t=Math.max(v,t),h||(e=void 0);const be=n.length>1;return{codecSet:n.reduce((ye,Te)=>{const ue=a[Te];if(Te===ye)return ye;if(L=h?M.filter(Xe=>ue.videoRanges[Xe]>0):[],be){if(ue.minBitrate>t)return rt(Te,`min bitrate of ${ue.minBitrate} > current estimate of ${t}`),ye;if(!ue.hasDefaultAudio)return rt(Te,"no renditions with default or auto-select sound found"),ye;if(o&&Te.indexOf(o.substring(0,4))%5!==0)return rt(Te,`audio codec preference "${o}" not found`),ye;if(r&&!l){if(!ue.channels[r])return rt(Te,`no renditions with ${r} channel sound found (channels options: ${Object.keys(ue.channels)})`),ye}else if((!o||l)&&d&&ue.channels[2]===0)return rt(Te,"no renditions with stereo sound found"),ye;if(ue.minHeight>te)return rt(Te,`min resolution of ${ue.minHeight} > maximum of ${te}`),ye;if(ue.minFramerate>ne)return rt(Te,`min framerate of ${ue.minFramerate} > maximum of ${ne}`),ye;if(!L.some(Xe=>ue.videoRanges[Xe]>0))return rt(Te,`no variants with VIDEO-RANGE of ${qt(L)} found`),ye;if(u&&Te.indexOf(u.substring(0,4))%5!==0)return rt(Te,`video codec preference "${u}" not found`),ye;if(ue.maxScore<b)return rt(Te,`max score of ${ue.maxScore} < selected max of ${b}`),ye}return ye&&(At(Te)>=At(ye)||ue.fragmentError>a[ye].fragmentError)?ye:(_=ue.minIndex,b=ue.maxScore,Te)},void 0),videoRanges:L,preferHDR:U,minFramerate:y,minBitrate:v,minIndex:_}}function rt(a,e){Z.log(`[abr] start candidates with "${a}" ignored because ${e}`)}function lt(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 q(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(d=>{if(!d)return;const h=e.groups[d];h&&(u.hasDefaultAudio=u.hasDefaultAudio||e.hasDefaultAudio?h.hasDefault:h.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(h.channels).forEach(g=>{u.channels[g]=(u.channels[g]||0)+h.channels[g]}))}),s},{})}function se(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 pe(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(Ce(a,s,t))return i}return-1}function Ce(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||Se(n,e.lang))&&(n===void 0||e.assocLang===r)&&(o===void 0||e.default===o)&&(u===void 0||e.forced===u)&&(!("characteristics"in a)||Ue(a.characteristics||"",e.characteristics))&&(t===void 0||t(a,e))}function Se(a,e="--"){return a.length===e.length?a===e:a.startsWith(e)||e.startsWith(a)}function Ue(a,e=""){const t=a.split(","),i=e.split(",");return t.length===i.length&&!t.some(s=>i.indexOf(s)===-1)}function ke(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 xt(a,e,t,i,s){const n=e[i],o=e.reduce((g,y,v)=>{const _=y.uri;return(g[_]||(g[_]=[])).push(v),g},{})[n.uri];o.length>1&&(i=Math.max.apply(Math,o));const u=n.videoRange,l=n.frameRate,d=n.codecSet.substring(0,4),h=Mt(e,i,g=>{if(g.videoRange!==u||g.frameRate!==l||g.codecSet.substring(0,4)!==d)return!1;const y=g.audioGroups,v=t.filter(_=>!y||y.indexOf(_.groupId)!==-1);return pe(a,v,s)>-1});return h>-1?h:Mt(e,i,g=>{const y=g.audioGroups,v=t.filter(_=>!y||y.indexOf(_.groupId)!==-1);return pe(a,v,s)>-1})}function Mt(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 pt(a,e){var t;return!!a&&a!==((t=e.loadLevelObj)==null?void 0:t.uri)}class jt extends De{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.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(),d=n?n.stats:s.stats,h=n?n.duration:s.duration,g=l-d.loading.start,y=r.minAutoLevel,v=s.level,_=this._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||v<=y){this.clearTimer(),this._nextAutoLevel=-1;return}if(!o)return;const b=_>-1&&_!==v,L=!!t||b;if(!L&&(u.paused||!u.playbackRate||!u.readyState))return;const U=r.mainForwardBufferInfo;if(!L&&U===null)return;const M=this.bwEstimator.getEstimateTTFB(),te=Math.abs(u.playbackRate);if(g<=Math.max(M,1e3*(h/(te*2))))return;const ne=U?U.len/te:0,be=d.loading.first?d.loading.first-d.loading.start:-1,re=d.loaded&&be>-1,ye=this.getBwEstimate(),Te=r.levels,ue=Te[v],Xe=Math.max(d.loaded,Math.round(h*(s.bitrate||ue.averageBitrate)/8));let dt=re?g-be:g;dt<1&&re&&(dt=Math.min(g,d.loaded*8/ye));const Ei=re?d.loaded*1e3/dt:0,zt=M/1e3,Nt=Ei?(Xe-d.loaded)/Ei:Xe*8/ye+zt;if(Nt<=ne)return;const St=Ei?Ei*8:ye,$t=((i=(t==null?void 0:t.details)||this.hls.latestLevelDetails)==null?void 0:i.live)===!0,Dt=this.hls.config.abrBandWidthUpFactor;let qe=Number.POSITIVE_INFINITY,it;for(it=v-1;it>y;it--){const wi=Te[it].maxBitrate,Ui=!Te[it].details||$t;if(qe=this.getTimeToLoadFrag(zt,St,h*wi,Ui),qe<Math.min(ne,h+zt))break}if(qe>=Nt||qe>h*10)return;re?this.bwEstimator.sample(g-Math.min(M,be),d.loaded):this.bwEstimator.sampleTTFB(g);const Jt=Te[it].maxBitrate;this.getBwEstimate()*Dt>Jt&&this.resetEstimator(Jt);const Yt=this.findBestLevel(Jt,y,it,0,ne,1,1);Yt>-1&&(it=Yt),this.warn(`Fragment ${s.sn}${n?" part "+n.index:""} of level ${v} is loading too slowly;
|
|
Fragment duration: ${s.duration.toFixed(3)}
|
|
Time to underbuffer: ${ne.toFixed(3)} s
|
|
Estimated load time for current fragment: ${Nt.toFixed(3)} s
|
|
Estimated load time for down switch fragment: ${qe.toFixed(3)} s
|
|
TTFB estimate: ${be|0} ms
|
|
Current BW estimate: ${S(ye)?ye|0:"Unknown"} bps
|
|
New BW estimate: ${this.getBwEstimate()|0} bps
|
|
Switching to level ${it} @ ${Jt|0} bps`),r.nextLoadLevel=r.nextAutoLevel=it,this.clearTimer();const mi=()=>{if(this.clearTimer(),this.fragCurrent===s&&this.hls.loadLevel===it&&it>0){const wi=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${it>0?"and switching down":""}
|
|
Fragment duration: ${s.duration.toFixed(3)} s
|
|
Time to underbuffer: ${wi.toFixed(3)} s`),s.abortRequests(),this.fragCurrent=this.partCurrent=null,it>y){let Ui=this.findBestLevel(this.hls.levels[y].bitrate,y,it,0,wi,1,1);Ui===-1&&(Ui=y),this.hls.nextLoadLevel=this.hls.nextAutoLevel=Ui,this.resetEstimator(this.hls.levels[Ui].bitrate)}}};b||Nt>qe*2?mi():this.timer=self.setInterval(mi,qe*1e3),r.trigger(m.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:n,stats:d})},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 Ae(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.FRAG_LOADING,this.onFragLoading,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.FRAG_LOADING,this.onFragLoading,this),e.off(m.FRAG_LOADED,this.onFragLoaded,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(m.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,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;S(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===H.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(m.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!==H.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 d=n.abrBandWidthFactor,h=n.abrBandWidthUpFactor;if(l){const b=this.findBestLevel(u,r,s,l,0,d,h);if(b>=0)return this.rebufferNotice=-1,b}let g=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){const b=this.bitrateTestDelay;b&&(g=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-b,this.info(`bitrate test took ${Math.round(1e3*b)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),d=h=1)}const y=this.findBestLevel(u,r,s,l,g,d,h);if(this.rebufferNotice!==y&&(this.rebufferNotice=y,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${y}`)),y>-1)return y;const v=i.levels[r],_=i.loadLevelObj;return _&&(v==null?void 0:v.bitrate)<_.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,d=this.lastLoadedFragLevel,h=d===-1?this.hls.firstLevel:d,{fragCurrent:g,partCurrent:y}=this,{levels:v,allAudioTracks:_,loadLevel:b,config:L}=this.hls;if(v.length===1)return 0;const U=v[h],M=!!((u=this.hls.latestLevelDetails)!=null&&u.live),te=b===-1||d===-1;let ne,be="SDR",re=(U==null?void 0:U.frameRate)||0;const{audioPreference:ye,videoPreference:Te}=L,ue=this.audioTracksByGroup||(this.audioTracksByGroup=lt(_));let Xe=-1;if(te){if(this.firstSelection!==-1)return this.firstSelection;const St=this.codecTiers||(this.codecTiers=q(v,ue,t,i)),$t=ki(St,be,e,ye,Te),{codecSet:Dt,videoRanges:qe,minFramerate:it,minBitrate:Jt,minIndex:Yt,preferHDR:mi}=$t;Xe=Yt,ne=Dt,be=mi?qe[qe.length-1]:qe[0],re=it,e=Math.max(e,Jt),this.log(`picked start tier ${qt($t)}`)}else ne=U==null?void 0:U.codecSet,be=U==null?void 0:U.videoRange;const dt=y?y.duration:g?g.duration:0,Ei=this.bwEstimator.getEstimateTTFB()/1e3,zt=[];for(let St=i;St>=t;St--){var Nt;const $t=v[St],Dt=St>h;if(!$t)continue;if(L.useMediaCapabilities&&!$t.supportedResult&&!$t.supportedPromise){const Ui=navigator.mediaCapabilities;typeof(Ui==null?void 0:Ui.decodingInfo)=="function"&&(G($t,ue,be,re,e,ye)||It($t.videoCodec))?($t.supportedPromise=J($t,ue,Ui),$t.supportedPromise.then(Hi=>{if(!this.hls)return;$t.supportedResult=Hi;const As=this.hls.levels,ws=As.indexOf($t);Hi.error?this.warn(`MediaCapabilities decodingInfo error: "${Hi.error}" for level ${ws} ${qt(Hi)}`):Hi.supported||(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${ws} ${qt(Hi)}`),ws>-1&&As.length>1&&(this.log(`Removing unsupported level ${ws}`),this.hls.removeLevel(ws),this.hls.loadLevel===-1&&(this.hls.nextLoadLevel=0)))})):$t.supportedResult=p}if((ne&&$t.codecSet!==ne||be&&$t.videoRange!==be||Dt&&re>$t.frameRate||!Dt&&re>0&&re<$t.frameRate||$t.supportedResult&&!((Nt=$t.supportedResult.decodingInfoResults)!=null&&Nt[0].smooth))&&(!te||St!==Xe)){zt.push(St);continue}const qe=$t.details,it=(y?qe==null?void 0:qe.partTarget:qe==null?void 0:qe.averagetargetduration)||dt;let Jt;Dt?Jt=o*e:Jt=r*e;const Yt=dt&&s>=dt*2&&n===0?$t.averageBitrate:$t.maxBitrate,mi=this.getTimeToLoadFrag(Ei,Jt,Yt*it,qe===void 0);if(Jt>=Yt&&(St===d||$t.loadError===0&&$t.fragmentError===0)&&(mi<=Ei||!S(mi)||M&&!this.bitrateTestDelay||mi<l)){const Ui=this.forcedAutoLevel;return St!==b&&(Ui===-1||Ui!==b)&&(zt.length&&this.trace(`Skipped level(s) ${zt.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${v[zt[0]].codecs}" ${v[zt[0]].videoRange}; not compatible with "${ne}" ${be}`),this.info(`switch candidate:${h}->${St} adjustedbw(${Math.round(Jt)})-bitrate=${Math.round(Jt-Yt)} ttfb:${Ei.toFixed(1)} avgDuration:${it.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${mi.toFixed(1)} firstSelection:${te} codecSet:${$t.codecSet} videoRange:${$t.videoRange} hls.loadLevel:${b}`)),te&&(this.firstSelection=St),St}}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 kt={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 ai(a,e,t){if(e===null||!Array.isArray(a)||!a.length||!S(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;t=t||0;for(let n=0;n<a.length;++n){const r=a[n];if(Ri(e,t,r))return r}return null}function Bt(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)&&Ai(t,i,n)===0||Tt(n,a,Math.min(s,i))))return n;const r=kt.search(e,Ai.bind(null,t,i));return r&&(r!==a||!n)?r:n}function Tt(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 Ai(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 Ri(a,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>a}function Oi(a,e){return kt.search(a,t=>t.cc<e?1:t.cc>e?-1:0)}function xi(a,e,t){if(a&&a.startCC<=e&&a.endCC>=e){const i=t.start,s=t.end;let n=a.fragments;if(!t.relurl){const{fragmentHint:r}=a;r&&(n=n.concat(r))}return kt.search(n,r=>r.cc<e||r.end<=i?1:r.cc>e||r.start>=s?-1:0)}return null}function ui(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 di(a,e){const t=ui(e);return a.default[`${t?"timeout":"error"}Retry`]}function oi(a,e){const t=a.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*a.retryDelayMs,a.maxRetryDelayMs)}function Ii(a){return j(j({},a),{errorRetry:null,timeoutRetry:null})}function Vi(a,e,t,i){if(!a)return!1;const s=i==null?void 0:i.code,n=e<a.maxNumRetry&&(Ci(s)||!!t);return a.shouldRetry?a.shouldRetry(a,e,t,i,n):n}function Ci(a){return a===0&&navigator.onLine===!1||!!a&&(a<400||a>499)}var Li={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},fi={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class Zi extends De{constructor(e){super("error-controller",e.logger),this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.hls=e,this.registerListeners()}registerListeners(){const e=this.hls;e.on(m.ERROR,this.onError,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(m.ERROR,this.onError,this),e.off(m.ERROR,this.onErrorOut,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===H.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}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=Bi();return}case A.FRAG_GAP:case A.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Li.SendAlternateToPenaltyBox;return}case A.LEVEL_EMPTY_ERROR:case A.LEVEL_PARSING_ERROR:{var r,o;const l=t.parent===H.MAIN?t.level:s.loadLevel;t.details===A.LEVEL_EMPTY_ERROR&&((r=t.context)!=null&&(o=r.levelDetails)!=null&&o.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,l))}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 l=s.loadLevelObj;if(l&&(n.type===oe.AUDIO_TRACK&&l.hasAudioGroup(n.groupId)||n.type===oe.SUBTITLE_TRACK&&l.hasSubtitleGroup(n.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.loadLevel),t.errorAction.action=Li.SendAlternateToPenaltyBox,t.errorAction.flags=fi.MoveAllAlternatesMatchingHost;return}}return;case A.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const l=s.loadLevelObj,d=l==null?void 0:l.attrs["HDCP-LEVEL"];d?t.errorAction={action:Li.SendAlternateToPenaltyBox,flags:fi.MoveAllAlternatesMatchingHDCP,hdcpLevel:d}:this.keySystemError(t)}return;case A.BUFFER_ADD_CODEC_ERROR:case A.REMUX_ALLOC_ERROR:case A.BUFFER_APPEND_ERROR:if(!t.errorAction){var u;t.errorAction=this.getLevelSwitchAction(t,(u=t.level)!=null?u: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=Bi();return}t.type===z.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const i=this.hls,s=di(i.config.playlistLoadPolicy,e),n=this.playlistError++;if(Vi(s,n,ui(e),e.response))return{action:Li.RetryRequest,flags:fi.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=di(e.details.startsWith("key")?r:n,e),u=t.levels.reduce((d,h)=>d+h.fragmentError,0);if(s&&(e.details!==A.FRAG_GAP&&s.fragmentError++,Vi(o,u,ui(e),e.response)))return{action:Li.RetryRequest,flags:fi.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 d=-1;const{levels:h,loadLevel:g,minAutoLevel:y,maxAutoLevel:v}=i;i.autoLevelEnabled||(i.loadLevel=-1);const _=(n=e.frag)==null?void 0:n.type,L=(_===H.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),M=e.sourceBufferName==="video"&&(l===A.BUFFER_ADD_CODEC_ERROR||l===A.BUFFER_APPEND_ERROR)&&h.some(({codecSet:be,audioCodec:re})=>s.codecSet!==be&&s.audioCodec===re),{type:te,groupId:ne}=(r=e.context)!=null?r:{};for(let be=h.length;be--;){const re=(be+g)%h.length;if(re!==g&&re>=y&&re<=v&&h[re].loadError===0){var o,u;const ye=h[re];if(l===A.FRAG_GAP&&_===H.MAIN&&e.frag){const Te=h[re].details;if(Te){const ue=Bt(e.frag,Te.fragments,e.frag.start);if(ue!=null&&ue.gap)continue}}else{if(te===oe.AUDIO_TRACK&&ye.hasAudioGroup(ne)||te===oe.SUBTITLE_TRACK&&ye.hasSubtitleGroup(ne))continue;if(_===H.AUDIO&&(o=s.audioGroups)!=null&&o.some(Te=>ye.hasAudioGroup(Te))||_===H.SUBTITLE&&(u=s.subtitleGroups)!=null&&u.some(Te=>ye.hasSubtitleGroup(Te))||L&&s.audioCodec===ye.audioCodec||!L&&s.audioCodec!==ye.audioCodec||M&&s.codecSet===ye.codecSet)continue}d=re;break}}if(d>-1&&i.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:Li.SendAlternateToPenaltyBox,flags:fi.None,nextAutoLevel:d}}return{action:Li.SendAlternateToPenaltyBox,flags:fi.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Li.DoNothing:break;case Li.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 Li.RetryRequest:break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:s,hdcpLevel:n,nextAutoLevel:r}=i;switch(s){case fi.None:this.switchLevel(e,r);break;case fi.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Ve[Ve.indexOf(n)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,r)}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=f(e.mimeType),s=this.hls.levels;for(let n=s.length;n--;)s[n][`${e.sourceBufferName}Codec`]===i&&this.hls.removeLevel(n)}}}function Bi(a){const e={action:Li.DoNothing,flags:fi.None};return a&&(e.resolved=!0),e}var ni={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class is{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.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.BUFFER_APPENDED,this.onBufferAppended,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.BUFFER_APPENDED,this.onBufferAppended,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),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;const r=n.end;if(n.start<=e&&r!==null&&e<=r)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(d=>{const h=!this.isTimeBuffered(d.startPTS,d.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=Ji(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],d=r||u.partial===!0;n.range[o]=this.getBufferedTimes(i,e.part,d,l)}),n.loaded=null,Object.keys(n.range).length?(n.buffered=!0,(n.body.endList=i.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),qi(n)||this.removeParts(i.sn-1,i.type)):this.removeFragment(n.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){const i=Ji(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,s.buffered=!0)}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 d=0;d<s.length;d++){const h=s.start(d)-this.bufferPadding,g=s.end(d)+this.bufferPadding;if(l>=h&&u<=g){n.time.push({startPTS:Math.max(r,s.start(d)),endPTS:Math.min(o,s.end(d))});break}else if(r<g&&o>h){const y=Math.max(r,s.start(d)),v=Math.min(o,s.end(d));v>y&&(n.partial=!0,n.time.push({startPTS:y,endPTS:v}))}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 d=u[l];d&&qi(d)&&(s=d.body.start-o,n=d.body.end+o,e>=s&&e<=n&&(i=Math.min(e-s,n-e),r<=i&&(t=d.body,r=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||qi(t))}getState(e){const t=Ji(e),i=this.fragments[t];return i?i.buffered?qi(i)?ni.PARTIAL:ni.OK:ni.APPENDING:ni.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=Ji(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=Ji(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=Ji(e);e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const s=e.sn;this.activePartLists[e.type]=i.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){var e,t;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const i=(e=this.hls)==null||(t=e.latestLevelDetails)==null?void 0:t.partList;i&&i.forEach(s=>s.clearElementaryStreamInfo())}}function qi(a){var e,t,i;return a.buffered&&(a.body.gap||((e=a.range.video)==null?void 0:e.partial)||((t=a.range.audio)==null?void 0:t.partial)||((i=a.range.audiovideo)==null?void 0:i.partial))}function Ji(a){return`${a.type}_${a.level}_${a.sn}`}var Fi={cbc:0,ctr:1};class ss{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 Fi.cbc:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Fi.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 Ni{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],d=u[1],h=u[2],g=u[3],y=new Uint32Array(256);let v=0,_=0,b=0;for(b=0;b<256;b++)b<128?y[b]=b<<1:y[b]=b<<1^283;for(b=0;b<256;b++){let L=_^_<<1^_<<2^_<<3^_<<4;L=L>>>8^L&255^99,e[v]=L,t[L]=v;const U=y[v],M=y[U],te=y[M];let ne=y[L]*257^L*16843008;s[v]=ne<<24|ne>>>8,n[v]=ne<<16|ne>>>16,r[v]=ne<<8|ne>>>24,o[v]=ne,ne=te*16843009^M*65537^U*257^v*16843008,l[L]=ne<<24|ne>>>8,d[L]=ne<<16|ne>>>16,h[L]=ne<<8|ne>>>24,g[L]=ne,v?(v=U^y[y[y[te^U]]],_^=y[y[_]]):v=_=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),d=this.invKeySchedule=new Uint32Array(r),h=this.sBox,g=this.rcon,y=this.invSubMix,v=y[0],_=y[1],b=y[2],L=y[3];let U,M;for(o=0;o<r;o++){if(o<n){U=l[o]=t[o];continue}M=U,o%n===0?(M=M<<8|M>>>24,M=h[M>>>24]<<24|h[M>>>16&255]<<16|h[M>>>8&255]<<8|h[M&255],M^=g[o/n|0]<<24):n>6&&o%n===4&&(M=h[M>>>24]<<24|h[M>>>16&255]<<16|h[M>>>8&255]<<8|h[M&255]),l[o]=U=(l[o-n]^M)>>>0}for(u=0;u<r;u++)o=r-u,u&3?M=l[o]:M=l[o-4],u<4||o<=4?d[u]=M:d[u]=v[h[M>>>24]]^_[h[M>>>16&255]]^b[h[M>>>8&255]]^L[h[M&255]],d[u]=d[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],d=o[2],h=o[3],g=this.uint8ArrayToUint32Array_(i);let y=g[0],v=g[1],_=g[2],b=g[3];const L=new Int32Array(e),U=new Int32Array(L.length);let M,te,ne,be,re,ye,Te,ue,Xe,dt,Ei,zt,Nt,St;const $t=this.networkToHostOrderSwap;for(;t<L.length;){for(Xe=$t(L[t]),dt=$t(L[t+1]),Ei=$t(L[t+2]),zt=$t(L[t+3]),re=Xe^n[0],ye=zt^n[1],Te=Ei^n[2],ue=dt^n[3],Nt=4,St=1;St<s;St++)M=u[re>>>24]^l[ye>>16&255]^d[Te>>8&255]^h[ue&255]^n[Nt],te=u[ye>>>24]^l[Te>>16&255]^d[ue>>8&255]^h[re&255]^n[Nt+1],ne=u[Te>>>24]^l[ue>>16&255]^d[re>>8&255]^h[ye&255]^n[Nt+2],be=u[ue>>>24]^l[re>>16&255]^d[ye>>8&255]^h[Te&255]^n[Nt+3],re=M,ye=te,Te=ne,ue=be,Nt=Nt+4;M=r[re>>>24]<<24^r[ye>>16&255]<<16^r[Te>>8&255]<<8^r[ue&255]^n[Nt],te=r[ye>>>24]<<24^r[Te>>16&255]<<16^r[ue>>8&255]<<8^r[re&255]^n[Nt+1],ne=r[Te>>>24]<<24^r[ue>>16&255]<<16^r[re>>8&255]<<8^r[ye&255]^n[Nt+2],be=r[ue>>>24]<<24^r[re>>16&255]<<16^r[ye>>8&255]<<8^r[Te&255]^n[Nt+3],U[t]=$t(M^y),U[t+1]=$t(be^v),U[t+2]=$t(ne^_),U[t+3]=$t(te^b),y=Xe,v=dt,_=Ei,b=zt,t=t+4}return U.buffer}}class Rs{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=ks(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}function ks(a){switch(a){case Fi.cbc:return"AES-CBC";case Fi.ctr:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${a}`)}}const _s=16;class gs{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!==Fi.cbc||t.byteLength!==16)return Z.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=st(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 Ni),l.expandKey(t);const d=r;return this.currentResult=l.decrypt(u.buffer,0,i),this.currentIV=u.slice(-16).buffer,d||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 Rs(this.subtle,t,s)}return this.fastAesKey.expandKey().then(n=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new ss(this.subtle,new Uint8Array(i),s).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(Z.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%_s;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}logOnce(e){this.logEnabled&&(Z.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const cs=Math.pow(2,17);class ns{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 Yi({type:z.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(v=>v[0]==="GAP")){u(ms(e));return}else e.gap=!1;const l=this.loader=n?new n(s):new r(s),d=ls(e);e.loader=l;const h=Ii(s.fragLoadPolicy.default),g={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:cs};e.stats=l.stats;const y={onSuccess:(v,_,b,L)=>{this.resetLoader(e,l);let U=v.data;b.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(U.slice(0,16)),U=U.slice(16)),o({frag:e,part:null,payload:U,networkDetails:L})},onError:(v,_,b,L)=>{this.resetLoader(e,l),u(new Yi({type:z.NETWORK_ERROR,details:A.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:j({url:i,data:void 0},v),error:new Error(`HTTP Error ${v.code} ${v.text}`),networkDetails:b,stats:L}))},onAbort:(v,_,b)=>{this.resetLoader(e,l),u(new Yi({type:z.NETWORK_ERROR,details:A.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:b,stats:v}))},onTimeout:(v,_,b)=>{this.resetLoader(e,l),u(new Yi({type:z.NETWORK_ERROR,details:A.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:b,stats:v}))}};t&&(y.onProgress=(v,_,b,L)=>t({frag:e,part:null,payload:b,networkDetails:L})),l.load(d,g,y)})}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(ms(e,t));return}const l=this.loader=n?new n(s):new r(s),d=ls(e,t);e.loader=l;const h=Ii(s.fragLoadPolicy.default),g={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:cs};t.stats=l.stats,l.load(d,g,{onSuccess:(y,v,_,b)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const L={frag:e,part:t,payload:y.data,networkDetails:b};i(L),o(L)},onError:(y,v,_,b)=>{this.resetLoader(e,l),u(new Yi({type:z.NETWORK_ERROR,details:A.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:j({url:d.url,data:void 0},y),error:new Error(`HTTP Error ${y.code} ${y.text}`),networkDetails:_,stats:b}))},onAbort:(y,v,_)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),u(new Yi({type:z.NETWORK_ERROR,details:A.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:_,stats:y}))},onTimeout:(y,v,_)=>{this.resetLoader(e,l),u(new Yi({type:z.NETWORK_ERROR,details:A.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${g.timeout}ms`),networkDetails:_,stats:y}))}})})}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 ls(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(s)&&S(n)){var r;let o=s,u=n;if(a.sn==="initSegment"&&Ls((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 ms(a,e){const t=new Error(`GAP ${a.gap?"tag":"attribute"} found`),i={type:z.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 Yi(i)}function Ls(a){return a==="AES-128"||a==="AES-256"}class Yi extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Gi extends De{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 es{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=os(),this.buffering={audio:os(),video:os(),audiovideo:os()},this.level=e,this.sn=t,this.id=i,this.size=s,this.part=n,this.partial=r}}function os(){return{start:0,executeStart:0,executeEnd:0,end:0}}const Is={length:0,start:()=>0,end:()=>0};class Ft{static isBuffered(e,t){if(e){const i=Ft.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=Ft.getBuffered(e);return Ft.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=Ft.bufferedRanges(e);if(s.length)return Ft.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((d,h)=>d.start-h.start||h.end-d.end);let s=-1,n=[];if(i)for(let d=0;d<e.length;d++){t>=e[d].start&&t<=e[d].end&&(s=d);const h=n.length;if(h){const g=n[h-1].end;e[d].start-g<i?e[d].end>g&&(n[h-1].end=e[d].end):n.push(e[d])}else n.push(e[d])}else n=e;let r=0,o,u=t,l=t;for(let d=0;d<n.length;d++){const h=n[d].start,g=n[d].end;if(s===-1&&t>=h&&t<=g&&(s=d),t+i>=h&&t<g)u=h,l=g,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||Is}catch(t){return Z.log("failed to get media.buffered",t),Is}}}const Ss=/\{\$([a-zA-Z0-9-_]+)\}/g;function Cs(a){return Ss.test(a)}function bs(a,e){if(a.variableList!==null||a.hasVariableRefs){const t=a.variableList;return e.replace(Ss,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 Vs(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 Ks(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 Qs=/^(\d+)x(\d+)$/,Ps=/(.+?)=(".*?"|.*?)(?:,|$)/g;class vi{constructor(e,t){typeof e=="string"&&(e=vi.parseAttrList(e,t)),ce(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=Qs.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(Ps.lastIndex=0;(i=Ps.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=bs(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":Z.warn(`${e}: attribute ${r} is missing quotes`)}s[r]=o}return s}}const an="com.apple.hls.interstitial";function Hs(a){return a!=="ID"&&a!=="CLASS"&&a!=="CUE"&&a!=="START-DATE"&&a!=="DURATION"&&a!=="END-DATE"&&a!=="END-ON-NEXT"}function js(a){return a==="SCTE35-OUT"||a==="SCTE35-IN"||a==="SCTE35-CMD"}class Js{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]){Z.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=ce(new vi({}),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"]);S(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?(Z.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(S(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===an}get isValid(){return!!this.id&&!this._badValueForSameId&&S(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 Ms=10;class Bs{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}get hasProgramDateTime(){return this.fragments.length?S(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Ms}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(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){var e;return(e=this.fragments)!=null&&e.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 ps(a){return a==="AES-128"||a==="AES-256"||a==="AES-256-CTR"}function ts(a){switch(a){case"AES-128":case"AES-256":return Fi.cbc;case"AES-256-CTR":return Fi.ctr;default:throw new Error(`invalid full segment method ${a}`)}}function xs(a){return Uint8Array.from(atob(a),e=>e.charCodeAt(0))}function ji(a){return Uint8Array.from(unescape(encodeURIComponent(a)),e=>e.charCodeAt(0))}function vs(a){const e=ji(a).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function ys(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 us(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=xs(r)):t=vs(r)}}return t}const Qi=typeof self!="undefined"?self:void 0;var yi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},rs={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 rs.FAIRPLAY:return yi.FAIRPLAY;case rs.PLAYREADY:return yi.PLAYREADY;case rs.WIDEVINE:return yi.WIDEVINE;case rs.CLEARKEY:return yi.CLEARKEY}}var en={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function tn(a){if(a===en.WIDEVINE)return yi.WIDEVINE;if(a===en.PLAYREADY)return yi.PLAYREADY;if(a===en.CENC||a===en.CLEARKEY)return yi.CLEARKEY}function Fs(a){switch(a){case yi.FAIRPLAY:return rs.FAIRPLAY;case yi.PLAYREADY:return rs.PLAYREADY;case yi.WIDEVINE:return rs.WIDEVINE;case yi.CLEARKEY:return rs.CLEARKEY}}function yt(a){const{drmSystems:e,widevineLicenseUrl:t}=a,i=e?[yi.FAIRPLAY,yi.WIDEVINE,yi.PLAYREADY,yi.CLEARKEY].filter(s=>!!e[s]):[];return!i[yi.WIDEVINE]&&t&&i.push(yi.WIDEVINE),i}const Kt=function(a){return Qi!=null&&(a=Qi.navigator)!=null&&a.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function zi(a,e,t,i){let s;switch(a){case yi.FAIRPLAY:s=["cenc","sinf"];break;case yi.WIDEVINE:case yi.PLAYREADY:s=["cenc"];break;case yi.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${a}`)}return Xi(s,e,t,i)}function Xi(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 Di(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=xs(o).subarray(0,16);return ys(u),u}}return null}let Ws={};class Zs{static clearKeyUriToKeyIdMap(){Ws={}}constructor(e,t,i,s=[1],n=null){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&&!ps(e)}isSupported(){if(this.method){if(ps(this.method)||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case rs.FAIRPLAY:case rs.WIDEVINE:case rs.PLAYREADY:case rs.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(ps(this.method)&&this.uri&&!this.iv){typeof e!="number"&&(Z.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const i=En(e);return new Zs(this.method,this.uri,"identity",this.keyFormatVersions,i)}const t=us(this.uri);if(t)switch(this.keyFormat){case rs.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case rs.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Xt(i,null,t),this.keyId=Di(t);break}default:{let i=t.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Ws[this.uri];if(!i){const s=Object.keys(Ws).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),Ws[this.uri]=i}this.keyId=i}return this}}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 on=/#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,nr=/#EXT-X-MEDIA:(.*)/g,wr=/^#EXT(?:INF|-X-TARGETDURATION):/m,Rn=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Ln=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 Ns{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 je.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return wr.test(e)}static parseMasterPlaylist(e,t){const i=Cs(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},n=[];on.lastIndex=0;let r;for(;(r=on.exec(e))!=null;)if(r[1]){var o;const l=new vi(r[1],s),d=bs(s,r[2]),h={attrs:l,bitrate:l.decimalInteger("BANDWIDTH")||l.decimalInteger("AVERAGE-BANDWIDTH"),name:l.NAME,url:Ns.resolve(d,t)},g=l.decimalResolution("RESOLUTION");g&&(h.width=g.width,h.height=g.height),rr(l.CODECS,h);const y=l["SUPPLEMENTAL-CODECS"];y&&(h.supplemental={},rr(y,h.supplemental)),(o=h.unknownCodecs)!=null&&o.length||n.push(h),s.levels.push(h)}else if(r[3]){const l=r[3],d=r[4];switch(l){case"SESSION-DATA":{const h=new vi(d,s),g=h["DATA-ID"];g&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[g]=h);break}case"SESSION-KEY":{const h=Un(d,t,s);h.encrypted&&h.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(h)):Z.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${d}"`);break}case"DEFINE":{{const h=new vi(d,s);Vs(s,h,t)}break}case"CONTENT-STEERING":{const h=new vi(d,s);s.contentSteering={uri:Ns.resolve(h["SERVER-URI"],t),pathwayId:h["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Gn(d);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(nr.lastIndex=0;(s=nr.exec(e))!==null;){const l=new vi(s[1],i),d=l.TYPE;if(d){const h=o[d],g=n[d]||[];n[d]=g;const y=l.LANGUAGE,v=l["ASSOC-LANGUAGE"],_=l.CHANNELS,b=l.CHARACTERISTICS,L=l["INSTREAM-ID"],U={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||y||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:y,url:l.URI?Ns.resolve(l.URI,t):""};if(v&&(U.assocLang=v),_&&(U.channels=_),b&&(U.characteristics=b),L&&(U.instreamId=L),h!=null&&h.length){const M=Ns.findGroup(h,U.groupId)||h[0];Vn(U,M,"audioCodec"),Vn(U,M,"textCodec")}g.push(U)}}return n}static parseLevelPlaylist(e,t,i,s,n,r){var o;const u={url:t},l=new Bs(t),d=l.fragments,h=[];let g=null,y=0,v=0,_=0,b=0,L=0,U=null,M=new Fe(s,u),te,ne,be,re=-1,ye=!1,Te=null,ue;if(Rn.lastIndex=0,l.m3u8=e,l.hasVariableRefs=Cs(e),((o=Rn.exec(e))==null?void 0:o[0])!=="#EXTM3U")return l.playlistParsingError=new Error("Missing format identifier #EXTM3U"),l;for(;(te=Rn.exec(e))!==null;){ye&&(ye=!1,M=new Fe(s,u),M.playlistOffset=_,M.start=_,M.sn=y,M.cc=b,L&&(M.bitrate=L),M.level=i,g&&(M.initSegment=g,g.rawProgramDateTime&&(M.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),Te&&(M.setByteRange(Te),Te=null)));const zt=te[1];if(zt){M.duration=parseFloat(zt);const Nt=(" "+te[2]).slice(1);M.title=Nt||null,M.tagList.push(Nt?["INF",zt,Nt]:["INF",zt])}else if(te[3]){if(S(M.duration)){M.playlistOffset=_,M.start=_,be&&or(M,be,l),M.sn=y,M.level=i,M.cc=b,d.push(M);const Nt=(" "+te[3]).slice(1);M.relurl=bs(l,Nt),Cn(M,U,h),U=M,_+=M.duration,y++,v=0,ye=!0}}else{if(te=te[0].match(Ln),!te){Z.warn("No matches on slow regex match for level playlist!");continue}for(ne=1;ne<te.length&&te[ne]===void 0;ne++);const Nt=(" "+te[ne]).slice(1),St=(" "+te[ne+1]).slice(1),$t=te[ne+2]?(" "+te[ne+2]).slice(1):null;switch(Nt){case"BYTERANGE":U?M.setByteRange(St,U):M.setByteRange(St);break;case"PROGRAM-DATE-TIME":M.rawProgramDateTime=St,M.tagList.push(["PROGRAM-DATE-TIME",St]),re===-1&&(re=d.length);break;case"PLAYLIST-TYPE":l.type&&Ys(l,Nt,te),l.type=St.toUpperCase();break;case"MEDIA-SEQUENCE":l.startSN!==0?Ys(l,Nt,te):d.length>0&&lr(l,Nt,te),y=l.startSN=parseInt(St);break;case"SKIP":{l.skippedSegments&&Ys(l,Nt,te);const Dt=new vi(St,l),qe=Dt.decimalInteger("SKIPPED-SEGMENTS");if(S(qe)){l.skippedSegments+=qe;for(let Jt=qe;Jt--;)d.push(null);y+=qe}const it=Dt.enumeratedString("RECENTLY-REMOVED-DATERANGES");it&&(l.recentlyRemovedDateranges=(l.recentlyRemovedDateranges||[]).concat(it.split(" ")));break}case"TARGETDURATION":l.targetduration!==0&&Ys(l,Nt,te),l.targetduration=Math.max(parseInt(St),1);break;case"VERSION":l.version!==null&&Ys(l,Nt,te),l.version=parseInt(St);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":l.live||Ys(l,Nt,te),l.live=!1;break;case"#":(St||$t)&&M.tagList.push($t?[St,$t]:[St]);break;case"DISCONTINUITY":b++,M.tagList.push(["DIS"]);break;case"GAP":M.gap=!0,M.tagList.push([Nt]);break;case"BITRATE":M.tagList.push([Nt,St]),L=parseInt(St)*1e3,S(L)?M.bitrate=L:L=0;break;case"DATERANGE":{const Dt=new vi(St,l),qe=new Js(Dt,l.dateRanges[Dt.ID],l.dateRangeTagCount);l.dateRangeTagCount++,qe.isValid||l.skippedSegments?l.dateRanges[qe.id]=qe:Z.warn(`Ignoring invalid DATERANGE tag: "${St}"`),M.tagList.push(["EXT-X-DATERANGE",St]);break}case"DEFINE":{{const Dt=new vi(St,l);"IMPORT"in Dt?Ks(l,Dt,r):Vs(l,Dt,t)}break}case"DISCONTINUITY-SEQUENCE":l.startCC!==0?Ys(l,Nt,te):d.length>0&&lr(l,Nt,te),l.startCC=b=parseInt(St);break;case"KEY":{const Dt=Un(St,t,l);if(Dt.isSupported()){if(Dt.method==="NONE"){be=void 0;break}be||(be={}),be[Dt.keyFormat]&&(be=ce({},be)),be[Dt.keyFormat]=Dt}else Z.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${St}"`);break}case"START":l.startTimeOffset=Gn(St);break;case"MAP":{const Dt=new vi(St,l);if(M.duration){const qe=new Fe(s,u);ar(qe,Dt,i,be),g=qe,M.initSegment=g,g.rawProgramDateTime&&!M.rawProgramDateTime&&(M.rawProgramDateTime=g.rawProgramDateTime)}else{const qe=M.byteRangeEndOffset;if(qe){const it=M.byteRangeStartOffset;Te=`${qe-it}@${it}`}else Te=null;ar(M,Dt,i,be),g=M,ye=!0}g.cc=b;break}case"SERVER-CONTROL":{ue&&Ys(l,Nt,te),ue=new vi(St),l.canBlockReload=ue.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=ue.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&ue.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=ue.optionalFloat("PART-HOLD-BACK",0),l.holdBack=ue.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{l.partTarget&&Ys(l,Nt,te);const Dt=new vi(St);l.partTarget=Dt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let Dt=l.partList;Dt||(Dt=l.partList=[]);const qe=v>0?Dt[Dt.length-1]:void 0,it=v++,Jt=new vi(St,l),Yt=new Ze(Jt,M,u,it,qe);Dt.push(Yt),M.duration+=Yt.duration;break}case"PRELOAD-HINT":{const Dt=new vi(St,l);l.preloadHint=Dt;break}case"RENDITION-REPORT":{const Dt=new vi(St,l);l.renditionReports=l.renditionReports||[],l.renditionReports.push(Dt);break}default:Z.warn(`line parsed but not handled: ${te}`);break}}}U&&!U.relurl?(d.pop(),_-=U.duration,l.partList&&(l.fragmentHint=U)):l.partList&&(Cn(M,U,h),M.cc=b,l.fragmentHint=M,be&&or(M,be,l)),l.targetduration||(l.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));const Xe=d.length,dt=d[0],Ei=d[Xe-1];if(_+=l.skippedSegments*l.targetduration,_>0&&Xe&&Ei){l.averagetargetduration=_/Xe;const zt=Ei.sn;l.endSN=zt!=="initSegment"?zt:0,l.live||(Ei.endList=!0),dt&&l.startCC===void 0&&(l.startCC=dt.cc),re>0&&(kr(d,re),dt&&h.unshift(dt))}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(_+=l.fragmentHint.duration),l.totalduration=_,h.length&&l.dateRangeTagCount&&dt&&In(h,l),l.endCC=b,l}}function In(a,e){const t=a.length,i=a[t-1],s=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let r=n.length;r--;){const o=e.dateRanges[n[r]],u=o.startDate.getTime();o.tagAnchor=i.ref;for(let l=t;l--;){const d=ln(e,u,a,l,s);if(d!==-1){o.tagAnchor=e.fragments[d].ref;break}}}}function ln(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,d=a.fragments;if(d.length>t.length){const g=(t[i+1]||d[d.length-1]).sn-a.startSN;for(let y=g;y>l;y--){const v=d[y].programDateTime;if(e>=v&&e<v+d[y].duration*1e3)return y}}return l}}}return-1}function Un(a,e,t){var i,s;const n=new vi(a,t),r=(i=n.METHOD)!=null?i:"",o=n.URI,u=n.hexadecimalInteger("IV"),l=n.KEYFORMATVERSIONS,d=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!u&&Z.error(`Invalid IV: ${n.IV}`);const h=o?Ns.resolve(o,e):"",g=(l||"1").split("/").map(Number).filter(Number.isFinite);return new Zs(r,h,d,g,u)}function Gn(a){const t=new vi(a).decimalFloatingPoint("TIME-OFFSET");return S(t)?t:null}function rr(a,e){let t=(a||"").split(/[ ,]+/).filter(i=>i);["video","audio","text"].forEach(i=>{const s=t.filter(n=>Mi(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 Vn(a,e,t){const i=e[t];i&&(a[t]=i)}function kr(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 Cn(a,e,t){a.rawProgramDateTime?t.push(a):e!=null&&e.programDateTime&&(a.programDateTime=e.endProgramDateTime)}function ar(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 or(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 lr(a,e,t){a.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${t[0]})`)}function Dn(a,e){const t=e.startPTS;if(S(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 fn(a,e,t,i,s,n){i-t<=0&&(Z.warn("Fragment should have a positive duration",e),i=t+e.duration,n=s+e.duration);let o=t,u=i;const l=e.startPTS,d=e.endPTS;if(S(l)){const b=Math.abs(l-t);S(e.deltaPTS)?e.deltaPTS=Math.max(b,e.deltaPTS):e.deltaPTS=b,o=Math.max(t,l),t=Math.min(t,l),s=Math.min(s,e.startDTS),u=Math.min(i,d),i=Math.max(i,d),n=Math.max(n,e.endDTS)}const h=t-e.start;e.start!==0&&e.setStart(t),e.setDuration(i-e.start),e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=i,e.minEndPTS=u,e.endDTS=n;const g=e.sn;if(!a||g<a.startSN||g>a.endSN)return 0;let y;const v=g-a.startSN,_=a.fragments;for(_[v]=e,y=v;y>0;y--)Dn(_[y],_[y-1]);for(y=v;y<_.length-1;y++)Dn(_[y],_[y+1]);return a.fragmentHint&&Dn(_[_.length-1],a.fragmentHint),a.PTSKnown=a.alignedSliding=!0,h}function Kn(a,e){if(a===e)return;let t=null;const i=a.fragments;for(let u=i.length-1;u>=0;u--){const l=i[u].initSegment;if(l){t=l;break}}a.fragmentHint&&delete a.fragmentHint.endPTS;let s;Mr(a,e,(u,l,d,h)=>{if(e.skippedSegments&&l.cc!==u.cc){const g=u.cc-l.cc;for(let y=d;y<h.length;y++)h[y].cc+=g}S(u.startPTS)&&S(u.endPTS)&&(l.setStart(l.startPTS=u.startPTS),l.startDTS=u.startDTS,l.maxStartPTS=u.maxStartPTS,l.endPTS=u.endPTS,l.endDTS=u.endDTS,l.minEndPTS=u.minEndPTS,l.setDuration(u.endPTS-u.startPTS),l.duration&&(s=l),e.PTSKnown=e.alignedSliding=!0),u.hasStreams&&(l.elementaryStreams=u.elementaryStreams),l.loader=u.loader,u.hasStats&&(l.stats=u.stats),u.initSegment&&(l.initSegment=u.initSegment,t=u.initSegment)});const n=e.fragments,r=e.fragmentHint?n.concat(e.fragmentHint):n;if(t&&r.forEach(u=>{var l;u&&(!u.initSegment||u.initSegment.relurl===((l=t)==null?void 0:l.relurl))&&(u.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=n.some(u=>!u),e.deltaUpdateFailed){Z.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let u=e.skippedSegments;u--;)n.shift();e.startSN=n[0].sn}else{e.endCC=n[n.length-1].cc,e.canSkipDateRanges&&(e.dateRanges=Or(a.dateRanges,e));const u=a.fragments.filter(l=>l.rawProgramDateTime);if(a.hasProgramDateTime&&!e.hasProgramDateTime)for(let l=1;l<r.length;l++)r[l].programDateTime===null&&Cn(r[l],r[l-1],u);In(u,e)}Pr(a.partList,e.partList,(u,l)=>{l.elementaryStreams=u.elementaryStreams,l.stats=u.stats}),s?fn(e,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):_n(a,e),n.length&&(e.totalduration=e.edge-n[0].start),e.driftStartTime=a.driftStartTime,e.driftStart=a.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const u=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=u),e.driftEndTime=o,e.driftEnd=u}else e.driftEndTime=a.driftEndTime,e.driftEnd=a.driftEnd,e.advancedDateTime=a.advancedDateTime;e.requestScheduled===-1&&(e.requestScheduled=a.requestScheduled)}function Or(a,e){const{dateRanges:t,recentlyRemovedDateranges:i}=e,s=ce({},a);i&&i.forEach(o=>{delete s[o]});const r=Object.keys(s).length;return r&&Object.keys(t).forEach(o=>{const u=s[o],l=new Js(t[o].attr,u);l.isValid?(s[o]=l,u||(l.tagOrder+=r)):Z.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${qt(t[o].attr)}"`)}),s}function Pr(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 Mr(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 d=u[r+l];let h=o[l];if(i&&!h&&d&&(h=e.fragments[l]=d),d&&h){if(t(d,h,l,o),d.url&&d.url!==h.url){e.playlistParsingError=Hn(`media sequence mismatch ${h.sn}:`,a,e,d,h);return}else if(d.cc!==h.cc){e.playlistParsingError=Hn(`discontinuity sequence mismatch (${d.cc}!=${h.cc})`,a,e,d,h);return}}}}function Hn(a,e,t,i,s){return new Error(`${a} ${s.url}
|
|
Playlist starting @${e.startSN}
|
|
${e.m3u8}
|
|
|
|
Playlist starting @${t.startSN}
|
|
${t.m3u8}`)}function _n(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;jn(e,r)}function jn(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 ur(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 Br(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 zn(a,e,t){return a?cr(a.partList,e,t):null}function cr(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 dr(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 Sn(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 Fr(a,e){return!!(a&&e.startCC<a.endCC&&e.endCC>a.startCC)}function hr(a,e){if(a){const t=a.start+e;a.start=a.startPTS=t,a.endPTS=t+a.duration}}function Wi(a,e){const t=e.fragments;for(let i=0,s=t.length;i<s;i++)hr(t[i],a);e.fragmentHint&&hr(e.fragmentHint,a),e.alignedSliding=!0}function $i(a,e){a&&(Ki(e,a),!e.alignedSliding&&a&&ds(e,a),!e.alignedSliding&&a&&!e.skippedSegments&&_n(a,e,!1))}function Ki(a,e){if(!Fr(e,a))return;const t=Math.min(e.endCC,a.endCC),i=Sn(e.fragments,t),s=Sn(a.fragments,t);if(!i||!s)return;Z.log(`Aligning playlist at start of dicontinuity sequence ${t}`);const n=i.start-s.start;Wi(n,a)}function ds(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=Sn(i,r),n=Sn(t,r)),(!s||!n)&&(s=i[Math.floor(i.length/2)],n=Sn(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);Wi(l,a)}const Ts={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}},Ie={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 bn extends Gi{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=Ie.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:d}=this,h=u?u.currentTime:0,g=Ft.bufferInfo(l||u,h,r.maxBufferHole);if(this.log(`media seeking to ${S(h)?h.toFixed(3):h}, state: ${d}`),this.state===Ie.ENDED)this.resetLoadingState();else if(o){const y=r.maxFragLookUpTolerance,v=o.start-y,_=o.start+o.duration+y;if(!g.len||_<g.start||v>g.end){const b=h>_;(h<v||b)&&(b&&o.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),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 v=Math.max(g.end,h),_=this.shouldLoadParts(this.getLevelDetails(),v);_&&(this.log(`LL-Part loading ON after seeking to ${h.toFixed(2)} with buffer @${v.toFixed(2)}`),this.loadingParts=_)}}!this.hls.hasEnoughToStart&&!g.len&&(this.log(`setting startPosition to ${h} because of seek before start`),this.nextLoadPosition=this.startPosition=h),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 ns(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new gs(e.config)}registerListeners(){const{hls:e}=this;e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){if(this.state===Ie.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=Ie.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.nextStart;if(n&&n>s&&n<t.edge||this.media.currentTime<e.start)return!1;const o=t.partList;if(o!=null&&o.length){const l=o[o.length-1];return Ft.isBuffered(this.media,l.start+l.duration/2)}const u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.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;i.removeEventListener("seeking",this.onMediaSeeking),i.removeEventListener("ended",this.onMediaEnded),i.addEventListener("seeking",this.onMediaSeeking),i.addEventListener("ended",this.onMediaEnded);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Ie.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),s.removeEventListener("seeking",this.onMediaSeeking),s.removeEventListener("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=Ie.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===Ie.FRAG_LOADING||!this.fragCurrent&&r===Ie.PARSING)&&(this.fragmentTracker.removeFragment(o),this.state=Ie.IDLE);return}"payload"in n&&(this.log(`Loaded ${o.type} sn: ${o.sn} of ${this.playlistLabel()} ${o.level}`),this.hls.trigger(m.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===Ie.STOPPED||this.state===Ie.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)===ni.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)===ni.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(m.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&&ps(o.method)){const u=self.performance.now();return this.decrypter.decrypt(new Uint8Array(r),o.key.buffer,o.iv.buffer,ts(o.method)).catch(l=>{throw s.trigger(m.ERROR,{type:z.MEDIA_ERROR,details:A.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:n}),l}).then(l=>{const d=self.performance.now();return s.trigger(m.FRAG_DECRYPTED,{frag:n,payload:l,stats:{tstart:u,tdecrypt:d}}),i.payload=l,this.completeInitSegmentLoad(i)})}return this.completeInitSegmentLoad(i)}).catch(i=>{this.state===Ie.STOPPED||this.state===Ie.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!==Ie.STOPPED&&(this.state=Ie.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()}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?Ts.toString(Ft.getBuffered(i)):"(detached)"})`),Be(e)){var s;if(e.type!==H.SUBTITLE){const r=e.elementaryStreams;if(!Object.keys(r).some(o=>!!r[o])){this.state=Ie.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=Ie.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 es(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==null?void 0:t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);let o=null;e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=Ie.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(h=>{if(!this.fragContextChanged(h.frag))return this.hls.trigger(m.KEY_LOADED,h),this.state===Ie.KEY_LOADING&&(this.state=Ie.IDLE),h}),this.hls.trigger(m.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&r.encryptedFragments.length&&this.keyLoader.loadClear(e,r.encryptedFragments);const u=this.fragPrevious;if(Be(e)&&(!u||e.sn!==u.sn)){const h=this.shouldLoadParts(t.details,e.end);h!==this.loadingParts&&(this.log(`LL-Part loading ${h?"ON":"OFF"} loading sn ${u==null?void 0:u.sn}->${e.sn}`),this.loadingParts=h)}if(i=Math.max(e.start,i||0),this.loadingParts&&Be(e)){const h=r.partList;if(h&&s){i>e.end&&r.fragmentHint&&(e=r.fragmentHint);const g=this.getNextPart(h,e,i);if(g>-1){const y=h[g];e=this.fragCurrent=y.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${y.index} (${g}/${h.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=Ie.FRAG_LOADING;let v;return o?v=o.then(_=>!_||this.fragContextChanged(_.frag)?null:this.doFragPartsLoad(e,y,t,s)).catch(_=>this.handleFragLoadError(_)):v=this.doFragPartsLoad(e,y,t,s).catch(_=>this.handleFragLoadError(_)),this.hls.trigger(m.FRAG_LOADING,{frag:e,part:y,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):v}else if(!e.url||this.loadedEndOfParts(h,i))return Promise.resolve(null)}}if(Be(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)}`),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?"["+r.startSN+"-"+r.endSN+"]":""}, target: ${parseFloat(i.toFixed(3))}`),S(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Ie.FRAG_LOADING;const l=this.config.progressive;let d;return l&&o?d=o.then(h=>!h||this.fragContextChanged(h==null?void 0:h.frag)?null:this.fragmentLoader.load(e,s)).catch(h=>this.handleFragLoadError(h)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([h])=>(!l&&h&&s&&s(h),h)).catch(h=>this.handleFragLoadError(h)),this.hls.trigger(m.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,i,s){return new Promise((n,r)=>{var o;const u=[],l=(o=i.details)==null?void 0:o.partList,d=h=>{this.fragmentLoader.loadPart(e,h,s).then(g=>{u[h.index]=g;const y=g.part;this.hls.trigger(m.FRAG_LOADED,g);const v=zn(i.details,e.sn,h.index+1)||cr(l,e.sn,h.index+1);if(v)d(v);else return n({frag:e,part:y,partsLoaded:u})}).catch(r)};d(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===A.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(m.ERROR,t)}else this.hls.trigger(m.ERROR,{type:z.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!==Ie.PARSING){!this.fragCurrent&&this.state!==Ie.STOPPED&&this.state!==Ie.ERROR&&(this.state=Ie.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!=null&&e.partList){var i;const n=e.partList[0],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?zn(u,n,r):null,d=l?l.fragment:Br(u,n,i);return d?(i&&i!==d&&(d.stats=i.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,i,s,n){var r;if(!e||this.state!==Ie.PARSING)return;const{data1:o,data2:u}=e;let l=o;if(o&&u&&(l=st(o,u)),!((r=l)!=null&&r.length))return;const d={type:e.type,frag:t,part:i,chunkMeta:s,parent:t.type,data:l};if(this.hls.trigger(m.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Ft.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,s=Ft.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(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=Ft.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 Ft.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=H.MAIN){var i;const s=(i=this.fragmentTracker)==null?void 0:i.getAppendedFrag(e,t);return s&&"fragment"in s?s.fragment:s}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,i);const g=this.hls.startPosition,y=this.hls.liveSyncPosition,v=u?(g!==-1&&g>=r?g:y)||u.start:e;this.log(`Setting startPosition to ${v} to match start frag at live edge. mainStart: ${g} liveSyncPosition: ${y} frag.start: ${(l=u)==null?void 0:l.start}`),this.startPosition=this.nextLoadPosition=v}}else e<=r&&(u=i[0]);if(!u){const h=this.loadingParts?t.partEnd:t.fragmentEnd;u=this.getFragmentAtPosition(e,h,t)}let d=this.filterReplacedPrimary(u,t);if(!d&&u){const h=u.sn-t.startSN;d=this.filterReplacedPrimary(i[h+1]||null,t)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===ni.OK||i===ni.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(fr(this.hls.config)){var e,t;if((e=this.hls.interstitialsManager)==null||(t=e.playingItem)==null?void 0:t.event)return!0}return!1}filterReplacedPrimary(e,t){if(!e)return e;if(fr(this.hls.config)&&e.type!==H.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!=null&&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 d=l.loaded;d?s=-1:(n||l.independent||r)&&l.fragment===t&&(s=o),n=d}return s}loadedEndOfParts(e,t){const i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){const 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=ai(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=Oi(t,i.cc),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,d=i.partList,h=!!(this.loadingParts&&d!=null&&d.length&&u);h&&u&&!this.bitrateTest&&d[d.length-1].fragment.sn===u.sn&&(r=r.concat(u),o=u.sn);let g;if(e<t){var y;const _=e<this.lastCurrentTime||e>t-l||(y=this.media)!=null&&y.paused||!this.startFragRequested?0:l;g=Bt(n,r,e,_)}else g=r[r.length-1];if(g){const v=g.sn-i.startSN,_=this.fragmentTracker.getState(g);if((_===ni.OK||_===ni.PARTIAL&&g.gap)&&(n=g),n&&g.sn===n.sn&&(!h||d[0].fragment.sn>g.sn||!i.live&&!h)&&n&&g.level===n.level){const L=r[v+1];g.sn<o&&this.fragmentTracker.getState(L)!==ni.OK?g=L:g=null}}return g}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&&S(n);if(r||!o&&!n){$i(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&&S(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&&Be(e)&&e.stats.aborted&&(this.warn(`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!==Ie.FRAG_LOADING_WAITING_RETRY)&&(this.state=Ie.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const v=this.getCurrentContext(t.chunkMeta);v&&(t.frag=v.frag)}const i=t.frag;if(!i||i.type!==e||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const n=t.details===A.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const r=t.errorAction,{action:o,flags:u,retryCount:l=0,retryConfig:d}=r||{},h=!!r&&!!d,g=h&&o===Li.RetryRequest,y=h&&!r.resolved&&u===fi.MoveAllAlternatesMatchingHost;if(!g&&y&&Be(i)&&!i.endList)this.resetFragmentErrors(e),this.treatAsGap(i),r.resolved=!0;else if((g||y)&&l<d.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);const v=oi(d,l);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${v}ms`),r.resolved=!0,this.retryDate=self.performance.now()+v,this.state=Ie.FRAG_LOADING_WAITING_RETRY}else if(d&&r)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==Li.RemoveAlternatePermanently&&(r.resolved=!0);else{this.warn(`${t.details} reached or exceeded max retry (${l})`);return}else o===Li.SendAlternateToPenaltyBox?this.state=Ie.WAITING_LEVEL:this.state=Ie.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===Ie.PARSING||this.state===Ie.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 is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(e){e===H.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Ie.STOPPED&&(this.state=Ie.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const s=Ft.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,i),this.state===Ie.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Ie.STOPPED&&(this.state=Ie.IDLE)}resetStartWhenNotLoaded(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const 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.warn(`The loading context changed while buffering fragment ${e.sn} of ${this.playlistLabel()} ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),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 d=e.elementaryStreams[l];if(d){const h=d.endPTS-d.startPTS;if(h<=0)return this.warn(`Could not parse fragment ${e.sn} ${l} duration reliably (${h})`),u||!1;const g=s?0:fn(n,e,d.startPTS,d.endPTS,d.startDTS,d.endDTS);return this.hls.trigger(m.LEVEL_PTS_UPDATED,{details:n,level:i,drift:g,type:l,frag:e,start:d.startPTS,end:d.endPTS}),!0}return u},!1)){var o;if(i.fragmentError===0&&this.treatAsGap(e,i),((o=this.transmuxer)==null?void 0:o.error)===null){const u=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(u.message),this.hls.trigger(m.ERROR,{type:z.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,error:u,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=Ie.PARSED,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(m.FRAG_PARSED,{frag:e,part:t})}playlistLabel(){return this.playlistType===H.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.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function fr(a){return!!a.interstitialsController&&a.enableInterstitialPlayback!==!1}class Wn{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=mr(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function mr(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 un={exports:{}},wn;function Nr(){return wn||(wn=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,d){this.fn=u,this.context=l,this.once=d||!1}function n(u,l,d,h,g){if(typeof d!="function")throw new TypeError("The listener must be a function");var y=new s(d,h||u,g),v=t?t+l:l;return u._events[v]?u._events[v].fn?u._events[v]=[u._events[v],y]:u._events[v].push(y):(u._events[v]=y,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=[],d,h;if(this._eventsCount===0)return l;for(h in d=this._events)e.call(d,h)&&l.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},o.prototype.listeners=function(l){var d=t?t+l:l,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,y=h.length,v=new Array(y);g<y;g++)v[g]=h[g].fn;return v},o.prototype.listenerCount=function(l){var d=t?t+l:l,h=this._events[d];return h?h.fn?1:h.length:0},o.prototype.emit=function(l,d,h,g,y,v){var _=t?t+l:l;if(!this._events[_])return!1;var b=this._events[_],L=arguments.length,U,M;if(b.fn){switch(b.once&&this.removeListener(l,b.fn,void 0,!0),L){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,d),!0;case 3:return b.fn.call(b.context,d,h),!0;case 4:return b.fn.call(b.context,d,h,g),!0;case 5:return b.fn.call(b.context,d,h,g,y),!0;case 6:return b.fn.call(b.context,d,h,g,y,v),!0}for(M=1,U=new Array(L-1);M<L;M++)U[M-1]=arguments[M];b.fn.apply(b.context,U)}else{var te=b.length,ne;for(M=0;M<te;M++)switch(b[M].once&&this.removeListener(l,b[M].fn,void 0,!0),L){case 1:b[M].fn.call(b[M].context);break;case 2:b[M].fn.call(b[M].context,d);break;case 3:b[M].fn.call(b[M].context,d,h);break;case 4:b[M].fn.call(b[M].context,d,h,g);break;default:if(!U)for(ne=1,U=new Array(L-1);ne<L;ne++)U[ne-1]=arguments[ne];b[M].fn.apply(b[M].context,U)}}return!0},o.prototype.on=function(l,d,h){return n(this,l,d,h,!1)},o.prototype.once=function(l,d,h){return n(this,l,d,h,!0)},o.prototype.removeListener=function(l,d,h,g){var y=t?t+l:l;if(!this._events[y])return this;if(!d)return r(this,y),this;var v=this._events[y];if(v.fn)v.fn===d&&(!g||v.once)&&(!h||v.context===h)&&r(this,y);else{for(var _=0,b=[],L=v.length;_<L;_++)(v[_].fn!==d||g&&!v[_].once||h&&v[_].context!==h)&&b.push(v[_]);b.length?this._events[y]=b.length===1?b[0]:b:r(this,y)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=t?t+l:l,this._events[d]&&r(this,d)):(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}(un)),un.exports}var Zo=Nr(),$r=Q(Zo);const Zn="1.6.0",kn={};function Yo(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Xo(){const a=kn[Zn];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 kn[Zn]=s,s}function qo(a){const e=kn[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 kn[a]=s,s}function Qo(a){const e=kn[a||Zn];if(e&&e.clientCount--===1){const{worker:i,objectURL:s}=e;delete kn[a||Zn],s&&self.URL.revokeObjectURL(s),i.terminate()}}function ba(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 Ur(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 gr(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 Yn(a,e){const t=e;let i=0;for(;Ur(a,e);){i+=10;const s=gr(a,e+6);i+=s,ba(a,e+10)&&(i+=10),e+=i}if(i>0)return a.subarray(t,t+i)}function Jo(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 y=new Error(`invalid ADTS sampling index:${r}`);a.emit(m.ERROR,m.ERROR,{type:z.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!0,error:y,reason:y.message});return}const o=(n>>6&3)+1,u=e[t+3]>>6&3|(n&1)<<2,l="mp4a.40."+o,d=s[r];let h=r;(o===5||o===29)&&(h-=3);const g=[o<<3|(h&14)>>1,(h&1)<<7|u<<3];return Z.log(`manifest codec:${i}, parsed codec:${l}, channels:${u}, rate:${d} (ADTS object type:${o} sampling index:${r})`),{config:g,samplerate:d,channelCount:u,codec:l,parsedCodec:l,manifestCodec:i}}function xa(a,e){return a[e]===255&&(a[e+1]&246)===240}function Ta(a,e){return a[e+1]&1?7:9}function Gr(a,e){return(a[e+3]&3)<<11|a[e+4]<<3|(a[e+5]&224)>>>5}function el(a,e){return e+5<a.length}function pr(a,e){return e+1<a.length&&xa(a,e)}function tl(a,e){return el(a,e)&&xa(a,e)&&Gr(a,e)<=a.length-e}function il(a,e){if(pr(a,e)){const t=Ta(a,e);if(e+t>=a.length)return!1;const i=Gr(a,e);if(i<=t)return!1;const s=e+i;return s===a.length||pr(a,s)}return!1}function Aa(a,e,t,i,s){if(!a.samplerate){const n=Jo(e,t,i,s);if(!n)return;ce(a,n)}}function Ra(a){return 1024*9e4/a}function sl(a,e){const t=Ta(a,e);if(e+t<=a.length){const i=Gr(a,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function La(a,e,t,i,s){const n=Ra(a.samplerate),r=i+s*n,o=sl(e,t);let u;if(o){const{frameLength:h,headerLength:g}=o,y=g+h,v=Math.max(0,t+y-e.length);v?(u=new Uint8Array(y-g),u.set(e.subarray(t+g,e.length),0)):u=e.subarray(t+g,t+y);const _={unit:u,pts:r};return v||a.samples.push(_),{sample:_,length:y,missing:v}}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 nl(a,e){return Ur(a,e)&&gr(a,e+6)+10<=a.length-e}function rl(a){if(a.size<2)return;const e=xe(a.data,!0),t=new Uint8Array(a.data.subarray(e.length+1));return{key:a.type,info:e,data:t.buffer}}function al(a){if(a.size<2)return;if(a.type==="TXXX"){let t=1;const i=xe(a.data.subarray(t),!0);t+=i.length+1;const s=xe(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=xe(a.data.subarray(1));return{key:a.type,info:"",data:e}}function ol(a){if(a.type==="WXXX"){if(a.size<2)return;let t=1;const i=xe(a.data.subarray(t),!0);t+=i.length+1;const s=xe(a.data.subarray(t));return{key:a.type,info:i,data:s}}const e=xe(a.data);return{key:a.type,info:"",data:e}}function ll(a){return btoa(String.fromCharCode(...a))}function Ia(a,e){if(a<0)return-Ia(-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}function ul(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("/")}function cl(){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 dl(a){return a instanceof ArrayBuffer?a:a.byteOffset==0&&a.byteLength==a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer}function Vr(a,e=0,t=1/0){return hl(a,e,t,Uint8Array)}function hl(a,e,t,i){const s=fl(a);let n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);const r=ml(a)?a.byteOffset:0,o=(r+a.byteLength)/n,u=(r+e)/n,l=Math.floor(Math.max(0,Math.min(u,o))),d=Math.floor(Math.min(l+Math.max(t,0),o));return new i(s,l,d-l)}function fl(a){return a instanceof ArrayBuffer?a:a.buffer}function ml(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=xe(Vr(a.data,1,i)),n=a.data[2+i],r=a.data.subarray(3+i).indexOf(0);if(r===-1)return;const o=xe(Vr(a.data,3+i,r));let u;return s==="-->"?u=xe(Vr(a.data,4+i+r)):u=dl(a.data.subarray(4+i+r)),e.mimeType=s,e.pictureType=n,e.description=o,e.data=u,e}function pl(a){return a.type==="PRIV"?rl(a):a.type[0]==="W"?ol(a):a.type==="APIC"?gl(a):al(a)}function vl(a){const e=String.fromCharCode(a[0],a[1],a[2],a[3]),t=gr(a,4),i=10;return{type:e,size:t,data:a.subarray(i,i+t)}}const vr=10,yl=10;function Ca(a){let e=0;const t=[];for(;Ur(a,e);){const i=gr(a,e+6);a[e+5]>>6&1&&(e+=vr),e+=vr;const s=e+i;for(;e+yl<s;){const n=vl(a.subarray(e)),r=pl(n);r&&t.push(r),e+=n.size+vr}ba(a,e)&&(e+=vr)}return t}function Da(a){return a&&a.key==="PRIV"&&a.info==="com.apple.streaming.transportStreamTimestamp"}function El(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 Kr(a){const e=Ca(a);for(let t=0;t<e.length;t++){const i=e[t];if(Da(i))return El(i)}}let Os=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 sn(a="",e=9e4){return{type:a,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Hr{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=st(this.cachedData,e),this.cachedData=null);let i=Yn(e,0),s=i?i.length:0,n;const r=this._audioTrack,o=this._id3Track,u=i?Kr(i):void 0,l=e.length;for((this.basePTS===null||this.frameIndex===0&&S(u))&&(this.basePTS=_l(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:Os.audioId3,duration:Number.POSITIVE_INFINITY});s<l;){if(this.canParse(e,s)){const d=this.appendFrame(r,e,s);d?(this.frameIndex++,this.lastPTS=d.sample.pts,s+=d.length,n=s):s=l}else nl(e,s)?(i=Yn(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Os.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,n=s):s++;if(s===l&&n!==l){const d=e.slice(n);this.cachedData?this.cachedData=st(this.cachedData,d):this.cachedData=d}}return{audioTrack:r,videoTrack:sn(),id3Track:o,textTrack:sn()}}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:sn(),id3Track:this._id3Track,textTrack:sn()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const _l=(a,e,t)=>{if(S(a))return a*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};let yr=null;const Sl=[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],bl=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],xl=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Tl=[0,1,1,4];function wa(a,e,t,i,s){if(t+24>e.length)return;const n=ka(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 ka(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=Sl[u*14+s-1]*1e3,h=bl[(t===3?0:t===2?1:2)*3+n],g=o===3?1:2,y=xl[t][i],v=Tl[i],_=y*8*v,b=Math.floor(y*l/h+r)*v;if(yr===null){const M=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);yr=M?parseInt(M[1]):0}return!!yr&&yr<=87&&i===2&&l>=224e3&&o===0&&(a[e+3]=a[e+3]|128),{sampleRate:h,channelCount:g,frameLength:b,samplesPerFrame:_}}}function jr(a,e){return a[e]===255&&(a[e+1]&224)===224&&(a[e+1]&6)!==0}function Oa(a,e){return e+1<a.length&&jr(a,e)}function Al(a,e){return jr(a,e)&&4<=a.length-e}function Pa(a,e){if(e+1<a.length&&jr(a,e)){const i=ka(a,e);let s=4;i!=null&&i.frameLength&&(s=i.frameLength);const n=e+s;return n===a.length||Oa(a,n)}return!1}class Rl extends Hr{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=Yn(e,0);let s=(i==null?void 0:i.length)||0;if(Pa(e,s))return!1;for(let n=e.length;s<n;s++)if(il(e,s))return t.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return tl(e,t)}appendFrame(e,t,i){Aa(e,this.observer,t,i,e.manifestCodec);const s=La(e,t,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Ma=(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 Ll extends Hr{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=Ba(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=Yn(e,0);if(!t)return!1;const i=t.length;return e[i]===11&&e[i+1]===119&&Kr(t)!==void 0&&Ma(e,i)<16}}function Ba(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,d=[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+d>e.length)return-1;const h=e[t+6]>>5;let g=0;h===2?g+=2:(h&1&&h!==1&&(g+=2),h&4&&(g+=2));const y=(e[t+6]<<8|e[t+7])>>12-g&1,_=[2,1,2,3,3,4,4,5][h]+y,b=e[t+5]>>3,L=e[t+5]&7,U=new Uint8Array([n<<6|b<<1|L>>2,(L&3)<<6|h<<3|y<<2|u>>4,u<<4&224]),M=1536/o*9e4,te=i+s*M,ne=e.subarray(t,t+d);return a.config=U,a.channelCount=_,a.samplerate=o,a.samples.push({unit:ne,pts:te}),d}class Il extends Hr{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=Yn(e,0);let i=(t==null?void 0:t.length)||0;if(t&&e[i]===11&&e[i+1]===119&&Kr(t)!==void 0&&Ma(e,i)<=16)return!1;for(let s=e.length;i<s;i++)if(Pa(e,i))return Z.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Al(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return wa(e,t,i,this.basePTS,this.frameIndex)}}const Cl=/\/emsg[-/]ID3/i;class Dl{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=sn("video",1),r=this.audioTrack=sn("audio",1),o=this.txtTrack=sn("text",1);if(this.id3Track=sn("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const u=D(e);if(u.video){const{id:l,timescale:d,codec:h,supplemental:g}=u.video;n.id=l,n.timescale=o.timescale=d,n.codec=h,n.supplemental=g}if(u.audio){const{id:l,timescale:d,codec:h}=u.audio;r.id=l,r.timescale=d,r.codec=h}o.id=Gt.text,n.sampleDuration=0,n.duration=r.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return k(e)}demux(e,t){this.timeOffset=t;let i=e;const s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=st(this.remainderData,e));const o=nt(i);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=i;const r=this.extractID3Track(s,t);return n.samples=tt(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=tt(e,t),{videoTrack:t,audioTrack:sn(),id3Track:s,textTrack:sn()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const s=C(e.samples,["emsg"]);s&&s.forEach(n=>{const r=ti(n);if(Cl.test(r.schemeIdUri)){const o=Fa(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:Os.emsg,duration:u})}else if(this.config.enableEmsgKLVMetadata&&r.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const o=Fa(r,t);i.samples.push({data:r.payload,len:r.payload.byteLength,dts:o,pts:o,type:Os.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 Fa(a,e){return S(a.presentationTime)?a.presentationTime/a.timeScale:e+a.presentationTimeDelta/a.timeScale}class wl{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new gs(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,Fi.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)})}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=ei(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)})}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 Na{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,d,h,g=-1,y=0;for(n===-1&&(g=0,y=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(d=u-n-1,g>=0){const v={data:t.subarray(g,d),type:y};o.push(v)}else{const v=this.getLastNalUnit(e.samples);v&&(r&&u<=4-r&&v.state&&(v.data=v.data.subarray(0,v.data.byteLength-r)),d>0&&(v.data=st(v.data,t.subarray(0,d)),v.state=0))}u<s?(h=this.getNALuType(t,u),g=u,y=h,n=0):n=-1}else n=0}if(g>=0&&n>=0){const v={data:t.subarray(g,s),type:y,state:n};o.push(v)}if(o.length===0){const v=this.getLastNalUnit(e.samples);v&&(v.data=st(v.data,t))}return e.naluState=n,o}}class Xn{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&&Z.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 $a extends Na{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 d,h;switch(l.type){case 1:{let _=!1;o=!0;const b=l.data;if(u&&b.length>4){const L=this.readSliceType(b);(L===2||L===4||L===7||L===9)&&(_=!0)}if(_){var g;(g=r)!=null&&g.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=_;break}case 5:o=!0,(d=r)!=null&&d.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,ge(l.data,1,i.pts,t.samples);break}case 7:{var y,v;o=!0,u=!0;const _=l.data,b=this.readSPS(_);if(!e.sps||e.width!==b.width||e.height!==b.height||((y=e.pixelRatio)==null?void 0:y[0])!==b.pixelRatio[0]||((v=e.pixelRatio)==null?void 0:v[1])!==b.pixelRatio[1]){e.width=b.width,e.height=b.height,e.pixelRatio=b.pixelRatio,e.sps=[_];const L=_.subarray(1,4);let U="avc1.";for(let M=0;M<3;M++){let te=L[M].toString(16);te.length<2&&(te="0"+te),U+=te}e.codec=U}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 Xn(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 Xn(e);let i=0,s=0,n=0,r=0,o,u,l;const d=t.readUByte.bind(t),h=t.readBits.bind(t),g=t.readUEG.bind(t),y=t.readBoolean.bind(t),v=t.skipBits.bind(t),_=t.skipEG.bind(t),b=t.skipUEG.bind(t),L=this.skipScalingList.bind(this);d();const U=d();if(h(5),v(3),d(),b(),U===100||U===110||U===122||U===244||U===44||U===83||U===86||U===118||U===128){const ye=g();if(ye===3&&v(1),b(),b(),v(1),y())for(u=ye!==3?8:12,l=0;l<u;l++)y()&&(l<6?L(16,t):L(64,t))}b();const M=g();if(M===0)g();else if(M===1)for(v(1),_(),_(),o=g(),l=0;l<o;l++)_();b(),v(1);const te=g(),ne=g(),be=h(1);be===0&&v(1),v(1),y()&&(i=g(),s=g(),n=g(),r=g());let re=[1,1];if(y()&&y())switch(d()){case 1:re=[1,1];break;case 2:re=[12,11];break;case 3:re=[10,11];break;case 4:re=[16,11];break;case 5:re=[40,33];break;case 6:re=[24,11];break;case 7:re=[20,11];break;case 8:re=[32,11];break;case 9:re=[80,33];break;case 10:re=[18,11];break;case 11:re=[15,11];break;case 12:re=[64,33];break;case 13:re=[160,99];break;case 14:re=[4,3];break;case 15:re=[3,2];break;case 16:re=[2,1];break;case 255:{re=[d()<<8|d(),d()<<8|d()];break}}return{width:Math.ceil((te+1)*16-i*2-s*2),height:(2-be)*(ne+1)*16-(be?2:4)*(n+r),pixelRatio:re}}}class Ua extends Na{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 d,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 g;(g=r)!=null&&g.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,(d=r)!=null&&d.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,ge(l.data,2,i.pts,t.samples);break;case 32:o=!0,e.vps||(typeof e.params!="object"&&(e.params={}),e.params=ce(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 y=this.readSPS(l.data);e.width=y.width,e.height=y.height,e.pixelRatio=y.pixelRatio,e.codec=y.codecString,e.sps=[],typeof e.params!="object"&&(e.params={});for(const v in y.params)e.params[v]=y.params[v]}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 y=this.readPPS(l.data);for(const v in y)e.params[v]=y[v]}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 Xn(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 Xn(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(),d=t.readUByte(),h=t.readUByte(),g=t.readUByte(),y=t.readUByte(),v=t.readUByte(),_=t.readUByte(),b=t.readUByte(),L=t.readUByte(),U=[],M=[];for(let Pi=0;Pi<i;Pi++)U.push(t.readBoolean()),M.push(t.readBoolean());if(i>0)for(let Pi=i;Pi<8;Pi++)t.readBits(2);for(let Pi=0;Pi<i;Pi++)U[Pi]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),M[Pi]&&t.readUByte();t.readUEG();const te=t.readUEG();te==3&&t.skipBits(1);const ne=t.readUEG(),be=t.readUEG(),re=t.readBoolean();let ye=0,Te=0,ue=0,Xe=0;re&&(ye+=t.readUEG(),Te+=t.readUEG(),ue+=t.readUEG(),Xe+=t.readUEG());const dt=t.readUEG(),Ei=t.readUEG(),zt=t.readUEG(),Nt=t.readBoolean();for(let Pi=Nt?0:i;Pi<=i;Pi++)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 Es=0;Es<4;Es++)for(let Gs=0;Gs<(Es===3?2:6);Gs++)if(!t.readBoolean())t.readUEG();else{const qs=Math.min(64,1<<4+(Es<<1));Es>1&&t.readEG();for(let $n=0;$n<qs;$n++)t.readEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());const Dt=t.readUEG();let qe=0;for(let Pi=0;Pi<Dt;Pi++){let Es=!1;if(Pi!==0&&(Es=t.readBoolean()),Es){Pi===Dt&&t.readUEG(),t.readBoolean(),t.readUEG();let Gs=0;for(let Tn=0;Tn<=qe;Tn++){const qs=t.readBoolean();let $n=!1;qs||($n=t.readBoolean()),(qs||$n)&&Gs++}qe=Gs}else{const Gs=t.readUEG(),Tn=t.readUEG();qe=Gs+Tn;for(let qs=0;qs<Gs;qs++)t.readUEG(),t.readBoolean();for(let qs=0;qs<Tn;qs++)t.readUEG(),t.readBoolean()}}if(t.readBoolean()){const Pi=t.readUEG();for(let Es=0;Es<Pi;Es++){for(let Gs=0;Gs<zt+4;Gs++)t.readBits(1);t.readBits(1)}}let Jt=0,Yt=1,mi=1,wi=!0,Ui=1,Hi=0;t.readBoolean(),t.readBoolean();let As=!1;if(t.readBoolean()){if(t.readBoolean()){const An=t.readUByte(),Vo=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2],Dr=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1];An>0&&An<16?(Yt=Vo[An-1],mi=Dr[An-1]):An===255&&(Yt=t.readBits(16),mi=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(),As=t.readBoolean(),As&&(ye+=t.readUEG(),Te+=t.readUEG(),ue+=t.readUEG(),Xe+=t.readUEG()),t.readBoolean()&&(Ui=t.readBits(32),Hi=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){const Dr=t.readBoolean(),Ko=t.readBoolean();let ir=!1;(Dr||Ko)&&(ir=t.readBoolean(),ir&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ir&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(let Ho=0;Ho<=i;Ho++){wi=t.readBoolean();const Qc=wi||t.readBoolean();let jo=!1;Qc?t.readEG():jo=t.readBoolean();const zo=jo?1:t.readUEG()+1;if(Dr)for(let sr=0;sr<zo;sr++)t.readUEG(),t.readUEG(),ir&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(Ko)for(let sr=0;sr<zo;sr++)t.readUEG(),t.readUEG(),ir&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),Jt=t.readUEG())}let yn=ne,Go=be;if(re||As){let Pi=1,Es=1;te===1?Pi=Es=2:te==2&&(Pi=2),yn=ne-Pi*Te-Pi*ye,Go=be-Es*Xe-Es*ue}const Xc=s?["A","B","C"][s]:"",qc=o<<24|u<<16|l<<8|d;let _a=0;for(let Pi=0;Pi<32;Pi++)_a=(_a|(qc>>Pi&1)<<31-Pi)>>>0;let Sa=_a.toString(16);return r===1&&Sa==="2"&&(Sa="6"),{codecString:`hvc1.${Xc}${r}.${Sa}.${n?"H":"L"}${L}.B0`,params:{general_tier_flag:n,general_profile_idc:r,general_profile_space:s,general_profile_compatibility_flags:[o,u,l,d],general_constraint_indicator_flags:[h,g,y,v,_,b],general_level_idc:L,bit_depth:dt+8,bit_depth_luma_minus8:dt,bit_depth_chroma_minus8:Ei,min_spatial_segmentation_idc:Jt,chroma_format_idc:te,frame_rate:{fixed:wi,fps:Hi/Ui}},width:yn,height:Go,pixelRatio:[Yt,mi]}}readPPS(e){const t=new Xn(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);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 hs=188;class mn{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=mn.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(hs*5,t-hs)+1,s=0;for(;s<i;){let n=!1,r=-1,o=0;for(let u=s;u<t;u+=hs)if(e[u]===71&&(t-u===hs||e[u+hs]===71)){if(o++,r===-1&&(r=u,r!==0&&(i=Math.min(r+hs*99,e.length-hs)+1)),n||(n=zr(e,u)===0),n&&o>1&&(r===0&&o>2||u+hs>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:Gt[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=mn.createTrack("video"),this._videoTrack.duration=s,this._audioTrack=mn.createTrack("audio",s),this._id3Track=mn.createTrack("id3"),this._txtTrack=mn.createTrack("text"),this._audioTrack.segmentCodec="aac",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 d=r.pid,h=r.pesData,g=o.pid,y=u.pid,v=o.pesData,_=u.pesData,b=null,L=this.pmtParsed,U=this._pmtId,M=e.length;if(this.remainderData&&(e=st(this.remainderData,e),M=e.length,this.remainderData=null),M<hs&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:r,id3Track:u,textTrack:l};const te=Math.max(0,mn.syncOffset(e));M-=(M-te)%hs,M<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,M,e.buffer.byteLength-M));let ne=0;for(let re=te;re<M;re+=hs)if(e[re]===71){const ye=!!(e[re+1]&64),Te=zr(e,re),ue=(e[re+3]&48)>>4;let Xe;if(ue>1){if(Xe=re+5+e[re+4],Xe===re+hs)continue}else Xe=re+4;switch(Te){case d:if(ye){if(h&&(n=On(h,this.logger))){if(this.videoParser===null)switch(r.segmentCodec){case"avc":this.videoParser=new $a;break;case"hevc":this.videoParser=new Ua;break}this.videoParser!==null&&this.videoParser.parsePES(r,l,n,!1)}h={data:[],size:0}}h&&(h.data.push(e.subarray(Xe,re+hs)),h.size+=re+hs-Xe);break;case g:if(ye){if(v&&(n=On(v,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}v={data:[],size:0}}v&&(v.data.push(e.subarray(Xe,re+hs)),v.size+=re+hs-Xe);break;case y:ye&&(_&&(n=On(_,this.logger))&&this.parseID3PES(u,n),_={data:[],size:0}),_&&(_.data.push(e.subarray(Xe,re+hs)),_.size+=re+hs-Xe);break;case 0:ye&&(Xe+=e[Xe]+1),U=this._pmtId=kl(e,Xe);break;case U:{ye&&(Xe+=e[Xe]+1);const dt=Ol(e,Xe,this.typeSupported,i,this.observer,this.logger);d=dt.videoPid,d>0&&(r.pid=d,r.segmentCodec=dt.segmentVideoCodec),g=dt.audioPid,g>0&&(o.pid=g,o.segmentCodec=dt.segmentAudioCodec),y=dt.id3Pid,y>0&&(u.pid=y),b!==null&&!L&&(this.logger.warn(`MPEG-TS PMT found at ${re} after unknown PID '${b}'. Backtracking to sync byte @${te} to parse all TS packets.`),b=null,re=te-188),L=this.pmtParsed=!0;break}case 17:case 8191:break;default:b=Te;break}}else ne++;ne>0&&Wr(this.observer,new Error(`Found ${ne} TS packet/s that do not start with 0x47`),void 0,this.logger),r.pesData=h,o.pesData=v,u.pesData=_;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=On(r,this.logger))){if(this.videoParser===null)switch(i.segmentCodec){case"avc":this.videoParser=new $a;break;case"hevc":this.videoParser=new Ua;break}this.videoParser!==null&&(this.videoParser.parsePES(i,n,l,!0),i.pesData=null)}else i.pesData=r;if(o&&(l=On(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=On(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 wl(this.observer,this.config,t);return this.decrypt(s,n)}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,g=s.sample.unit.byteLength;if(h===-1)n=st(s.sample.unit,n);else{const y=g-h;s.sample.unit.set(n.subarray(0,h),y),e.samples.push(s.sample),i=s.missing}}let r,o;for(r=i,o=n.length;r<o-1&&!pr(n,r);r++);if(r!==i){let h;const g=r<o-1;if(g?h=`AAC PES did not start with ADTS header,offset:${r}`:h="No ADTS header found in AAC PES",Wr(this.observer,new Error(h),g,this.logger),!g)return}Aa(e,this.observer,n,r,this.audioCodec);let u;if(t.pts!==void 0)u=t.pts;else if(s){const h=Ra(e.samplerate);u=s.sample.pts+h}else{this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}let l=0,d;for(;r<o;)if(d=La(e,n,r,u,l),r+=d.length,d.missing){this.aacOverFlow=d;break}else for(l++;r<o-1&&!pr(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(Oa(i,r)){const u=wa(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=Ba(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=ce({},t,{type:this._videoTrack?Os.emsg:Os.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function zr(a,e){return((a[e+1]&31)<<8)+a[e+2]}function kl(a,e){return(a[e+10]&31)<<8|a[e+11]}function Ol(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 d=zr(a,e),h=(a[e+3]&15)<<8|a[e+4];switch(a[e]){case 207:if(!i){Zr("ADTS AAC",n);break}case 15:r.audioPid===-1&&(r.audioPid=d);break;case 21:r.id3Pid===-1&&(r.id3Pid=d);break;case 219:if(!i){Zr("H.264",n);break}case 27:r.videoPid===-1&&(r.videoPid=d);break;case 3:case 4:!t.mpeg&&!t.mp3?n.log("MPEG audio found, not supported in this browser"):r.audioPid===-1&&(r.audioPid=d,r.segmentAudioCodec="mp3");break;case 193:if(!i){Zr("AC-3",n);break}case 129:t.ac3?r.audioPid===-1&&(r.audioPid=d,r.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(r.audioPid===-1&&h>0){let g=e+5,y=h;for(;y>2;){switch(a[g]){case 106:t.ac3!==!0?n.log("AC-3 audio found, not supported in this browser for now"):(r.audioPid=d,r.segmentAudioCodec="ac3");break}const _=a[g+1]+2;g+=_,y-=_}}break;case 194:case 135:return Wr(s,new Error("Unsupported EC-3 in M2TS found"),void 0,n),r;case 36:r.videoPid===-1&&(r.videoPid=d,r.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"));break}e+=h+5}return r}function Wr(a,e,t,i){i.warn(`parsing error: ${e.message}`),a.emit(m.ERROR,m.ERROR,{type:z.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function Zr(a,e){e.log(`${a} with AES-128-CBC encryption found in unencrypted stream`)}function On(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]=st(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 d=i[7];d&192&&(r=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,d&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 g=new Uint8Array(a.size);for(let y=0,v=u.length;y<v;y++){i=u[y];let _=i.byteLength;if(h)if(h>_){h-=_;continue}else i=i.subarray(h),_-=h,h=0;g.set(i,t),t+=_}return s&&(s-=n+3),{data:g,pts:r,dts:o,len:s}}return null}class Pl{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 gn=Math.pow(2,32)-1;class he{static init(){he.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 he.types)he.types.hasOwnProperty(e)&&(he.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]);he.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]);he.STTS=he.STSC=he.STCO=n,he.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),he.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),he.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),he.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]);he.FTYP=he.box(he.types.ftyp,r,u,r,o),he.DINF=he.box(he.types.dinf,he.box(he.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 he.box(he.types.hdlr,he.HDLR_TYPES[e])}static mdat(e){return he.box(he.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(gn+1)),s=Math.floor(t%(gn+1));return he.box(he.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 he.box(he.types.mdia,he.mdhd(e.timescale||0,e.duration||0),he.hdlr(e.type),he.minf(e))}static mfhd(e){return he.box(he.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"?he.box(he.types.minf,he.box(he.types.smhd,he.SMHD),he.DINF,he.stbl(e)):he.box(he.types.minf,he.box(he.types.vmhd,he.VMHD),he.DINF,he.stbl(e))}static moof(e,t,i){return he.box(he.types.moof,he.mfhd(e),he.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=he.trak(e[t]);return he.box.apply(null,[he.types.moov,he.mvhd(e[0].timescale||0,e[0].duration||0)].concat(i).concat(he.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=he.trex(e[t]);return he.box.apply(null,[he.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(gn+1)),s=Math.floor(t%(gn+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 he.box(he.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 he.box(he.types.sdtp,i)}static stbl(e){return he.box(he.types.stbl,he.stsd(e),he.box(he.types.stts,he.STTS),he.box(he.types.stsc,he.STSC),he.box(he.types.stsz,he.STSZ),he.box(he.types.stco,he.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=he.box(he.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,d=e.pixelRatio[0],h=e.pixelRatio[1];return he.box(he.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,he.box(he.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),he.box(he.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,d&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 he.box(he.types.mp4a,he.audioStsd(e),he.box(he.types.esds,he.esds(e)))}static mp3(e){return he.box(he.types[".mp3"],he.audioStsd(e))}static ac3(e){return he.box(he.types["ac-3"],he.audioStsd(e),he.box(he.types.dac3,e.config))}static stsd(e){const{segmentCodec:t}=e;if(e.type==="audio"){if(t==="aac")return he.box(he.types.stsd,he.STSD,he.mp4a(e));if(t==="ac3"&&e.config)return he.box(he.types.stsd,he.STSD,he.ac3(e));if(t==="mp3"&&e.codec==="mp3")return he.box(he.types.stsd,he.STSD,he.mp3(e))}else if(e.pps&&e.sps){if(t==="avc")return he.box(he.types.stsd,he.STSD,he.avc1(e));if(t==="hevc"&&e.vps)return he.box(he.types.stsd,he.STSD,he.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/(gn+1)),o=Math.floor(i%(gn+1));return he.box(he.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=he.sdtp(e),s=e.id,n=Math.floor(t/(gn+1)),r=Math.floor(t%(gn+1));return he.box(he.types.traf,he.box(he.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),he.box(he.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])),he.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,he.box(he.types.trak,he.tkhd(e),he.mdia(e))}static trex(e){const t=e.id;return he.box(he.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,d,h,g;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,d=u.size,h=u.flags,g=u.cts,r.set([l>>>24&255,l>>>16&255,l>>>8&255,l&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,h.degradPrio&61440,h.degradPrio&15,g>>>24&255,g>>>16&255,g>>>8&255,g&255],12+16*o);return he.box(he.types.trun,r)}static initSegment(e){he.types||he.init();const t=he.moov(e);return st(he.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 v=0;v<i.length;v+=1){r+=3;for(let _=0;_<i[v].length;_+=1)r+=2+i[v][_].length}const o=new Uint8Array(r);o.set(n,0),r=n.length;const u=i.length-1;for(let v=0;v<i.length;v+=1){o.set(new Uint8Array([32+v|(v===u?128:0),0,i[v].length]),r),r+=3;for(let _=0;_<i[v].length;_+=1)o.set(new Uint8Array([i[v][_].length>>8,i[v][_].length&255]),r),r+=2,o.set(i[v][_],r),r+=i[v][_].length}const l=he.box(he.types.hvcC,o),d=e.width,h=e.height,g=e.pixelRatio[0],y=e.pixelRatio[1];return he.box(he.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,d>>8&255,d&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,he.box(he.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),he.box(he.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,y>>24,y>>16&255,y>>8&255,y&255])))}}he.types=void 0,he.HDLR_TYPES=void 0,he.STTS=void 0,he.STSC=void 0,he.STCO=void 0,he.STSZ=void 0,he.VMHD=void 0,he.SMHD=void 0,he.STSD=void 0,he.FTYP=void 0,he.DINF=void 0;const Ga=9e4;function Yr(a,e,t=1,i=!1){const s=a*e*t;return i?Math.round(s):s}function Ml(a,e,t=1,i=!1){return Yr(a,e,1/t,i)}function qn(a,e=!1){return Yr(a,1e3,1/Ga,e)}function Bl(a,e=1){return Yr(a,Ga,1/e)}const Fl=10*1e3,Nl=1024,$l=1152,Ul=1536;let Pn=null,Xr=null;function Va(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 Er{constructor(e,t,i,s){if(this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=s,this.ISGenerated=!1,Pn===null){const r=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Pn=r?parseInt(r[1]):0}if(Xr===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);Xr=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.logger.log("[mp4-remuxer]: 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=$s(o,i),u=o-n),u>0?n:o},i);return t&&this.logger.debug("PTS rollover detected"),s}remux(e,t,i,s,n,r,o,u){let l,d,h,g,y,v,_=n,b=n;const L=e.pid>-1,U=t.pid>-1,M=t.samples.length,te=e.samples.length>0,ne=o&&M>0||M>1;if((!L||te)&&(!U||ne)||this.ISGenerated||o){if(this.ISGenerated){var re,ye,Te,ue;const zt=this.videoTrackConfig;(zt&&(t.width!==zt.width||t.height!==zt.height||((re=t.pixelRatio)==null?void 0:re[0])!==((ye=zt.pixelRatio)==null?void 0:ye[0])||((Te=t.pixelRatio)==null?void 0:Te[1])!==((ue=zt.pixelRatio)==null?void 0:ue[1]))||!zt&&ne||this.nextAudioPts===null&&te)&&this.resetInitSegment()}this.ISGenerated||(h=this.generateIS(e,t,n,r));const Xe=this.isVideoContiguous;let dt=-1,Ei;if(ne&&(dt=Gl(t.samples),!Xe&&this.config.forceKeyFrameOnDiscontinuity))if(v=!0,dt>0){this.logger.warn(`[mp4-remuxer]: Dropped ${dt} out of ${M} video samples due to a missing keyframe`);const zt=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(dt),t.dropped+=dt,b+=(t.samples[0].pts-zt)/t.inputTimeScale,Ei=b}else dt===-1&&(this.logger.warn(`[mp4-remuxer]: No keyframe found out of ${M} video samples`),v=!1);if(this.ISGenerated){if(te&&ne){const zt=this.getVideoStartPts(t.samples),St=($s(e.samples[0].pts,zt)-zt)/t.inputTimeScale;_+=Math.max(0,St),b+=Math.max(0,-St)}if(te){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,n,r)),d=this.remuxAudio(e,_,this.isAudioContiguous,r,U||ne||u===H.AUDIO?b:void 0),ne){const zt=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,n,r)),l=this.remuxVideo(t,b,Xe,zt)}}else ne&&(l=this.remuxVideo(t,b,Xe,0));l&&(l.firstKeyFrame=dt,l.independent=dt!==-1,l.firstKeyFramePTS=Ei)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(y=Ka(i,n,this._initPTS,this._initDTS)),s.samples.length&&(g=Ha(s,n,this._initPTS))),{audio:d,video:l,initSegment:h,independent:v,text:g,id3:y}}generateIS(e,t,i,s){const n=e.samples,r=t.samples,o=this.typeSupported,u={},l=this._initPTS;let d=!l||s,h="audio/mp4",g,y,v;if(d&&(g=y=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):he.initSegment([e]),metadata:{channelCount:e.channelCount}},d&&(v=e.inputTimeScale,!l||v!==l.timescale?g=y=n[0].pts-Math.round(v*i):d=!1)}if(t.sps&&t.pps&&r.length){if(t.timescale=t.inputTimeScale,u.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:he.initSegment([t]),metadata:{width:t.width,height:t.height}},d)if(v=t.inputTimeScale,!l||v!==l.timescale){const _=this.getVideoStartPts(r),b=Math.round(v*i);y=Math.min(y,$s(r[0].dts,_)-b),g=Math.min(g,_-b)}else d=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(u).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:g,timescale:v},this._initDTS={baseTime:y,timescale:v}):g=v=void 0,{tracks:u,initPTS:g,timescale:v}}remuxVideo(e,t,i,s){const n=e.inputTimeScale,r=e.samples,o=[],u=r.length,l=this._initPTS;let d=this.nextAvcDts,h=8,g=this.videoSampleDuration,y,v,_=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,L=!1;if(!i||d===null){const qe=t*n,it=r[0].pts-$s(r[0].dts,r[0].pts);Pn&&d!==null&&Math.abs(qe-it-d)<15e3?i=!0:d=qe-it}const U=l.baseTime*n/l.timescale;for(let qe=0;qe<u;qe++){const it=r[qe];it.pts=$s(it.pts-U,d),it.dts=$s(it.dts-U,d),it.dts<r[qe>0?qe-1:qe].dts&&(L=!0)}L&&r.sort(function(qe,it){const Jt=qe.dts-it.dts,Yt=qe.pts-it.pts;return Jt||Yt}),y=r[0].dts,v=r[r.length-1].dts;const M=v-y,te=M?Math.round(M/(u-1)):g||e.inputTimeScale/30;if(i){const qe=y-d,it=qe>te,Jt=qe<-1;if((it||Jt)&&(it?this.logger.warn(`${(e.segmentCodec||"").toUpperCase()}: ${qn(qe,!0)} ms (${qe}dts) hole between fragments detected at ${t.toFixed(3)}`):this.logger.warn(`${(e.segmentCodec||"").toUpperCase()}: ${qn(-qe,!0)} ms (${qe}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!Jt||d>=r[0].pts||Pn)){y=d;const Yt=r[0].pts-qe;if(it)r[0].dts=y,r[0].pts=Yt;else{let mi=!0;for(let wi=0;wi<r.length&&!(r[wi].dts>Yt&&mi);wi++){const Ui=r[wi].pts;if(r[wi].dts-=qe,r[wi].pts-=qe,wi<r.length-1){const Hi=r[wi+1].pts,As=r[wi].pts,ws=Hi<=As,yn=Hi<=Ui;mi=ws==yn}}}this.logger.log(`Video: Initial PTS/DTS adjusted: ${qn(Yt,!0)}/${qn(y,!0)}, delta: ${qn(qe,!0)} ms`)}}y=Math.max(0,y);let ne=0,be=0,re=y;for(let qe=0;qe<u;qe++){const it=r[qe],Jt=it.units,Yt=Jt.length;let mi=0;for(let wi=0;wi<Yt;wi++)mi+=Jt[wi].data.length;be+=mi,ne+=Yt,it.length=mi,it.dts<re?(it.dts=re,re+=te/4|0||1):re=it.dts,_=Math.min(it.pts,_),b=Math.max(it.pts,b)}v=r[u-1].dts;const ye=be+4*ne+8;let Te;try{Te=new Uint8Array(ye)}catch(qe){this.observer.emit(m.ERROR,m.ERROR,{type:z.MUX_ERROR,details:A.REMUX_ALLOC_ERROR,fatal:!1,error:qe,bytes:ye,reason:`fail allocating video mdat ${ye}`});return}const ue=new DataView(Te.buffer);ue.setUint32(0,ye),Te.set(he.types.mdat,4);let Xe=!1,dt=Number.POSITIVE_INFINITY,Ei=Number.POSITIVE_INFINITY,zt=Number.NEGATIVE_INFINITY,Nt=Number.NEGATIVE_INFINITY;for(let qe=0;qe<u;qe++){const it=r[qe],Jt=it.units;let Yt=0;for(let Ui=0,Hi=Jt.length;Ui<Hi;Ui++){const As=Jt[Ui],ws=As.data,yn=As.data.byteLength;ue.setUint32(h,yn),h+=4,Te.set(ws,h),h+=yn,Yt+=4+yn}let mi;if(qe<u-1)g=r[qe+1].dts-it.dts,mi=r[qe+1].pts-it.pts;else{const Ui=this.config,Hi=qe>0?it.dts-r[qe-1].dts:te;if(mi=qe>0?it.pts-r[qe-1].pts:te,Ui.stretchShortVideoTrack&&this.nextAudioPts!==null){const As=Math.floor(Ui.maxBufferHole*n),ws=(s?_+s*n:this.nextAudioPts)-it.pts;ws>As?(g=ws-Hi,g<0?g=Hi:Xe=!0,this.logger.log(`[mp4-remuxer]: It is approximately ${ws/90} ms to the next segment; using duration ${g/90} ms for the last video frame.`)):g=Hi}else g=Hi}const wi=Math.round(it.pts-it.dts);dt=Math.min(dt,g),zt=Math.max(zt,g),Ei=Math.min(Ei,mi),Nt=Math.max(Nt,mi),o.push(Va(it.key,g,Yt,wi))}if(o.length){if(Pn){if(Pn<70){const qe=o[0].flags;qe.dependsOn=2,qe.isNonSync=0}}else if(Xr&&Nt-Ei<zt-dt&&te/zt<.025&&o[0].cts===0){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let qe=y;for(let it=0,Jt=o.length;it<Jt;it++){const Yt=qe+o[it].duration,mi=qe+o[it].cts;if(it<Jt-1){const wi=Yt+o[it+1].cts;o[it].duration=wi-mi}else o[it].duration=it?o[it-1].duration:te;o[it].cts=0,qe=Yt}}}g=Xe||!g?te:g,this.nextAvcDts=d=v+g,this.videoSampleDuration=g,this.isVideoContiguous=!0;const Dt={data1:he.moof(e.sequenceNumber++,y,ce(e,{samples:o})),data2:Te,startPTS:_/n,endPTS:(b+g)/n,startDTS:y/n,endDTS:d/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Dt}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return $l;case"ac3":return Ul;default:return Nl}}remuxAudio(e,t,i,s,n){const r=e.inputTimeScale,o=e.samplerate?e.samplerate:r,u=r/o,l=this.getSamplesPerFrame(e),d=l*u,h=this._initPTS,g=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,y=[],v=n!==void 0;let _=e.samples,b=g?0:8,L=this.nextAudioPts||-1;const U=t*r,M=h.baseTime*r/h.timescale;if(this.isAudioContiguous=i=i||_.length&&L>0&&(s&&Math.abs(U-L)<9e3||Math.abs($s(_[0].pts-M,U)-L)<20*d),_.forEach(function(St){St.pts=$s(St.pts-M,U)}),!i||L<0){if(_=_.filter(St=>St.pts>=0),!_.length)return;n===0?L=0:s&&!v?L=Math.max(0,U):L=_[0].pts}if(e.segmentCodec==="aac"){const St=this.config.maxAudioFramesDrift;for(let $t=0,Dt=L;$t<_.length;$t++){const qe=_[$t],it=qe.pts,Jt=it-Dt,Yt=Math.abs(1e3*Jt/r);if(Jt<=-St*d&&v)$t===0&&(this.logger.warn(`Audio frame @ ${(it/r).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Jt/r)} ms.`),this.nextAudioPts=L=Dt=it);else if(Jt>=St*d&&Yt<Fl&&v){let mi=Math.round(Jt/d);Dt=it-mi*d,Dt<0&&(mi--,Dt+=d),$t===0&&(this.nextAudioPts=L=Dt),this.logger.warn(`[mp4-remuxer]: Injecting ${mi} audio frame @ ${(Dt/r).toFixed(3)}s due to ${Math.round(1e3*Jt/r)} ms gap.`);for(let wi=0;wi<mi;wi++){const Ui=Math.max(Dt,0);let Hi=Pl.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);Hi||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Hi=qe.unit.subarray()),_.splice($t,0,{unit:Hi,pts:Ui}),Dt+=d,$t++}}qe.pts=Dt,Dt+=d}}let te=null,ne=null,be,re=0,ye=_.length;for(;ye--;)re+=_[ye].unit.byteLength;for(let St=0,$t=_.length;St<$t;St++){const Dt=_[St],qe=Dt.unit;let it=Dt.pts;if(ne!==null){const Yt=y[St-1];Yt.duration=Math.round((it-ne)/u)}else if(i&&e.segmentCodec==="aac"&&(it=L),te=it,re>0){re+=b;try{be=new Uint8Array(re)}catch(Yt){this.observer.emit(m.ERROR,m.ERROR,{type:z.MUX_ERROR,details:A.REMUX_ALLOC_ERROR,fatal:!1,error:Yt,bytes:re,reason:`fail allocating audio mdat ${re}`});return}g||(new DataView(be.buffer).setUint32(0,re),be.set(he.types.mdat,4))}else return;be.set(qe,b);const Jt=qe.byteLength;b+=Jt,y.push(Va(!0,l,Jt,0)),ne=it}const Te=y.length;if(!Te)return;const ue=y[y.length-1];this.nextAudioPts=L=ne+u*ue.duration;const Xe=g?new Uint8Array(0):he.moof(e.sequenceNumber++,te/u,ce({},e,{samples:y}));e.samples=[];const dt=te/r,Ei=L/r,Nt={data1:Xe,data2:be,startPTS:dt,endPTS:Ei,startDTS:dt,endDTS:Ei,type:"audio",hasAudio:!0,hasVideo:!1,nb:Te};return this.isAudioContiguous=!0,Nt}}function $s(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 Gl(a){for(let e=0;e<a.length;e++)if(a[e].key)return e;return-1}function Ka(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=$s(u.pts-t.baseTime*n/t.timescale,e*n)/n,u.dts=$s(u.dts-i.baseTime*n/i.timescale,e*n)/n}const r=a.samples;return a.samples=[],{samples:r}}function Ha(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=$s(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 Vl{constructor(e,t,i,s){this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=s}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,s){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(O(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=D(e);s.audio&&(t=ja(s.audio,_e.AUDIO)),s.video&&(i=ja(s.video,_e.VIDEO));const n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+i,supplemental:s.video.supplemental,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:i,supplemental:s.video.supplemental,initSegment:e,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,i,s,n,r){var o,u;let{initPTS:l,lastEndTime:d}=this;const h={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};S(d)||(d=this.lastEndTime=n||0);const g=t.samples;if(!(g!=null&&g.length))return h;const y={initPTS:void 0,timescale:1};let v=this.initData;if((o=v)!=null&&o.length||(this.generateInitSegment(g),v=this.initData),!((u=v)!=null&&u.length))return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(y.tracks=this.initTracks,this.emitInitSegment=!1);const _=We(g,v),b=Le(v,g),L=b===null?n:b;(r||!l)&&(Kl(l,L,n,_)||y.timescale!==l.timescale)&&(y.initPTS=L-n,l&&l.timescale===1&&this.logger.warn(`Adjusting initPTS @${n} from ${l.baseTime/l.timescale} to ${y.initPTS}`),this.initPTS=l={baseTime:y.initPTS,timescale:1});const U=e?L-l.baseTime/l.timescale:d,M=U+_;ft(v,g,l.baseTime/l.timescale),_>0?this.lastEndTime=M:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const te=!!v.audio,ne=!!v.video;let be="";te&&(be+="audio"),ne&&(be+="video");const re={data1:g,startPTS:U,startDTS:U,endPTS:M,endDTS:M,type:be,hasAudio:te,hasVideo:ne,nb:1,dropped:0};return h.audio=re.type==="audio"?re:void 0,h.video=re.type!=="audio"?re:void 0,h.initSegment=y,h.id3=Ka(i,n,l,l),s.samples.length&&(h.text=Ha(s,n,l)),h}}function Kl(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 ja(a,e){const t=a==null?void 0:a.codec;return t&&t.length>4?t:e===_e.AUDIO?t==="ec-3"||t==="ac-3"||t==="alac"?t:t==="fLaC"||t==="Opus"?pi(t,!1):(Z.warn(`Unhandled audio codec "${t}" in mp4 MAP`),t||"mp4a"):(Z.warn(`Unhandled video codec "${t}" in mp4 MAP`),t||"avc1")}let cn;try{cn=self.performance.now.bind(self.performance)}catch(a){cn=Date.now}const _r=[{demux:Dl,remux:Vl},{demux:mn,remux:Er},{demux:Rl,remux:Er},{demux:Il,remux:Er}];_r.splice(2,0,{demux:Ll,remux:Er});class za{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=cn();let r=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:u}=this;s&&(this.currentTransmuxState=s);const{contiguous:l,discontinuity:d,trackSwitch:h,accurateTimeOffset:g,timeOffset:y,initSegmentChange:v}=s||o,{audioCodec:_,videoCodec:b,defaultInitPts:L,duration:U,initSegmentData:M}=u,te=Hl(r,t);if(te&&ps(te.method)){const ye=this.getDecrypter(),Te=ts(te.method);if(ye.isSync()){let ue=ye.softwareDecrypt(r,te.key.buffer,te.iv.buffer,Te);if(i.part>-1){const dt=ye.flush();ue=dt&&dt.buffer}if(!ue)return n.executeEnd=cn(),qr(i);r=new Uint8Array(ue)}else return this.asyncResult=!0,this.decryptionPromise=ye.webCryptoDecrypt(r,te.key.buffer,te.iv.buffer,Te).then(ue=>{const Xe=this.push(ue,null,i);return this.decryptionPromise=null,Xe}),this.decryptionPromise}const ne=this.needsProbing(d,h);if(ne){const ye=this.configureTransmuxer(r);if(ye)return this.logger.warn(`[transmuxer] ${ye.message}`),this.observer.emit(m.ERROR,m.ERROR,{type:z.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,error:ye,reason:ye.message}),n.executeEnd=cn(),qr(i)}(d||h||v||ne)&&this.resetInitSegment(M,_,b,U,t),(d||v||ne)&&this.resetInitialTimestamp(L),l||this.resetContiguity();const be=this.transmux(r,te,y,g,i);this.asyncResult=Qn(be);const re=this.currentTransmuxState;return re.contiguous=!0,re.discontinuity=!1,re.trackSwitch=!1,n.executeEnd=cn(),be}flush(e){const t=e.transmuxing;t.executeStart=cn();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=cn();const h=[qr(e)];return this.asyncResult?Promise.resolve(h):h}const d=u.flush(o);return Qn(d)?(this.asyncResult=!0,d.then(h=>(this.flushRemux(r,h,e),r))):(this.flushRemux(r,d,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===H.MAIN?"level":"track"} ${i.level}`);const d=this.remuxer.remux(s,n,r,o,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=cn()}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,g=_r.length;h<g;h++){var r;if((r=_r[h].demux)!=null&&r.probe(e,this.logger)){n=_r[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,d=n.demux;(!u||!(u instanceof l))&&(this.remuxer=new l(i,t,s,this.logger)),(!o||!(o instanceof d))&&(this.demuxer=new d(i,t,s,this.logger),this.probe=d.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new gs(this.config)),e}}function Hl(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 qr=a=>({remuxResult:{},chunkMeta:a});function Qn(a){return"then"in a&&a.then instanceof Function}class jl{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 zl{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 Wa=0;class Za{constructor(e,t,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Wa++,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,d=this.hls;if(!(!d||!(l!=null&&l.event)||l.instanceNo!==this.instanceNo))switch(l.event){case"init":{var h;const g=(h=this.workerContext)==null?void 0:h.objectURL;g&&self.URL.revokeObjectURL(g);break}case"transmuxComplete":{this.handleTransmuxComplete(l.data);break}case"flush":{this.onFlush(l.data);break}case"workerLog":{d.logger[l.data.logType]&&d.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,d.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(m.ERROR,{type:z.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===m.ERROR&&(l=l,l.parent=this.id,l.part=this.part,this.error=l.error),this.hls.trigger(u,l)};this.observer=new $r,this.observer.on(m.FRAG_DECRYPTED,r),this.observer.on(m.ERROR,r);const o=c(n.preferManagedMediaSource);if(this.useWorker&&typeof Worker!="undefined"){const u=this.hls.logger;if(n.workerPath||Yo()){try{n.workerPath?(u.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=qo(n.workerPath)):(u.log(`injecting Web Worker for "${t}"`),this.workerContext=Xo());const{worker:d}=this.workerContext;d.addEventListener("message",this.onWorkerMessage),d.addEventListener("error",this.onWorkerError),d.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:o,id:t,config:qt(n)})}catch(d){u.warn(`Error setting up "${t}" Web Worker, fallback to inline`,d),this.terminateWorker(),this.error=null,this.transmuxer=new za(this.observer,o,n,"",t,e.logger)}return}}this.transmuxer=new za(this.observer,o,n,"",t,e.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const e=this.instanceNo;this.instanceNo=Wa++;const t=this.hls.config,i=c(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:qt(t)})}}terminateWorker(){if(this.workerContext){const{worker:e}=this.workerContext;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),Qo(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,d){var h,g;l.transmuxing.start=self.performance.now();const{instanceNo:y,transmuxer:v}=this,_=r?r.start:n.start,b=n.decryptdata,L=this.frag,U=!(L&&n.cc===L.cc),M=!(L&&l.level===L.level),te=L?l.sn-L.sn:-1,ne=this.part?l.part-this.part.index:-1,be=te===0&&l.id>1&&l.id===(L==null?void 0:L.stats.chunkCount),re=!M&&(te===1||te===0&&(ne===1||be&&ne<=0)),ye=self.performance.now();(M||te||n.stats.parsing.start===0)&&(n.stats.parsing.start=ye),r&&(ne||!re)&&(r.stats.parsing.start=ye);const Te=!(L&&((h=n.initSegment)==null?void 0:h.url)===((g=L.initSegment)==null?void 0:g.url)),ue=new zl(U,re,u,M,_,Te);if(!re||U||Te){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${n.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===H.MAIN?"level":"track"}: ${l.level} id: ${l.id}
|
|
discontinuity: ${U}
|
|
trackSwitch: ${M}
|
|
contiguous: ${re}
|
|
accurateTimeOffset: ${u}
|
|
timeOffset: ${_}
|
|
initSegmentChange: ${Te}`);const Xe=new jl(i,s,t,o,d);this.configureTransmuxer(Xe)}if(this.frag=n,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:y,cmd:"demux",data:e,decryptdata:b,chunkMeta:l,state:ue},e instanceof ArrayBuffer?[e]:[]);else if(v){const Xe=v.push(e,b,l,ue);Qn(Xe)?Xe.then(dt=>{this.handleTransmuxComplete(dt)}).catch(dt=>{this.transmuxerError(dt,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(Xe)}}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);Qn(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(m.ERROR,{type:z.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 Ya=100;class Wl extends bn{constructor(e,t,i){super(e,t,i,"audio-stream-controller",H.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(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(m.BUFFER_RESET,this.onBufferReset,this),e.on(m.BUFFER_CREATED,this.onBufferCreated,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(m.FRAG_LOADING,this.onFragLoading,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:e}=this;e&&(super.unregisterListeners(),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(m.BUFFER_RESET,this.onBufferReset,this),e.off(m.BUFFER_CREATED,this.onBufferCreated,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(m.FRAG_LOADING,this.onFragLoading,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n}){if(i===H.MAIN){const r=t.cc,o=this.fragCurrent;if(this.initPTS[r]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${r} found from main: ${s}/${n}`),this.mainAnchor=t,this.state===Ie.WAITING_INIT_PTS){const u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==r)&&(this.nextLoadPosition=this.findSyncFrag(t).start),this.tick()}else!this.hls.hasEnoughToStart&&o&&o.cc!==r?(this.startFragRequested=!1,this.nextLoadPosition=this.findSyncFrag(t).start,o.abortRequests(),this.resetLoadingState()):this.state===Ie.IDLE&&this.tick()}}findSyncFrag(e){const t=this.getLevelDetails(),i=e.cc;return xi(t,i,e)||t&&Oi(t.fragments,i)||e}startLoad(e,t){if(!this.levels){this.startPosition=e,this.state=Ie.STOPPED;return}const i=this.lastCurrentTime;this.stopLoad(),this.setInterval(Ya),i>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=Ie.IDLE):this.state=Ie.WAITING_TRACK,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}doTick(){switch(this.state){case Ie.IDLE:this.doTickIdle();break;case Ie.WAITING_TRACK:{const{levels:t,trackId:i}=this,s=t==null?void 0:t[i],n=s==null?void 0:s.details;if(n&&!this.waitForLive(s)){if(this.waitForCdnTuneIn(n))break;this.state=Ie.WAITING_INIT_PTS}break}case Ie.FRAG_LOADING_WAITING_RETRY:{var e;const t=performance.now(),i=this.retryDate;if(!i||t>=i||(e=this.media)!=null&&e.seeking){const{levels:s,trackId:n}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((s==null?void 0:s[n])||null),this.state=Ie.IDLE}break}case Ie.WAITING_INIT_PTS:{const t=this.waitingData;if(t){const{frag:i,part:s,cache:n,complete:r}=t,o=this.mainAnchor;if(this.initPTS[i.cc]!==void 0){this.waitingData=null,this.state=Ie.FRAG_LOADING;const u=n.flush().buffer,l={frag:i,part:s,payload:u,networkDetails:null};this._handleFragmentLoadProgress(l),r&&super._handleFragmentLoadComplete(l)}else o&&o.cc!==t.frag.cc&&(this.log(`Waiting fragment cc (${i.cc}) cancelled because video is at cc ${o.cc}`),this.nextLoadPosition=this.findSyncFrag(o).start,this.clearWaitingFragment())}else this.state=Ie.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.state!==Ie.STOPPED&&(this.state=Ie.IDLE))}resetLoadingState(){this.clearWaitingFragment(),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=Ie.WAITING_TRACK,this.startFragRequested=!1;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,_e.AUDIO,H.AUDIO));const d=this.getFwdBufferInfo(l,H.AUDIO);if(d===null)return;if(!this.switchingTrack&&this._streamEnded(d,u)){t.trigger(m.BUFFER_EOS,{type:"audio"}),this.state=Ie.ENDED;return}const h=d.len,g=t.maxBufferLength,y=u.fragments,v=y[0].start,_=this.getLoadPosition(),b=this.flushing?_:d.end;if(this.switchingTrack&&s){const M=_;u.PTSKnown&&M<v&&(d.end>v||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=v+.05)}if(h>=g&&!this.switchingTrack&&b<y[y.length-1].start)return;let L=this.getNextFragment(b,u);if(L&&this.isLoopLoading(L,b)&&(L=this.getNextFragmentLoopLoading(L,u,d,H.MAIN,g)),!L){this.bufferFlushed=!0;return}let U=((e=this.mainFragLoading)==null?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&U&&Be(L)&&!L.endList&&(!u.live||!this.loadingParts&&b<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(U)===ni.OK&&(this.mainFragLoading=U=null),U&&Be(U))){if(L.start>U.end){const te=this.fragmentTracker.getFragAtPos(b,H.MAIN);te&&te.end>U.end&&(U=te,this.mainFragLoading={frag:te,targetBufferTime:null})}if(L.start>U.end)return}this.loadFragment(L,o,b)}onMediaDetaching(e,t){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(e,t)}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Ke(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!==Ie.STOPPED&&(this.setInterval(Ya),this.state=Ie.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(m.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!==Ie.STOPPED&&(this.state=Ie.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 d=s[r];let h=0;if(n.live||(i=d.details)!=null&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;if(d.details){var g;h=this.alignPlaylists(n,d.details,(g=this.levelLastLoaded)==null?void 0:g.details)}n.alignedSliding||(Ki(n,l),n.alignedSliding||ds(n,l),h=n.fragmentStart)}d.details=n,this.levelLastLoaded=d,this.startFragRequested||this.setStartPosition(l,h),this.hls.trigger(m.AUDIO_TRACK_UPDATED,{details:n,id:r,groupId:t.groupId}),this.state===Ie.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=Ie.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 d=l.details;if(!d){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 g=this.transmuxer;g||(g=this.transmuxer=new Za(this.hls,H.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const y=this.initPTS[i.cc],v=(t=i.initSegment)==null?void 0:t.data;if(y!==void 0){const b=s?s.index:-1,L=b!==-1,U=new es(i.level,i.sn,i.stats.chunkCount,n.byteLength,b,L);g.push(n,v,h,"",i,s,d.totalduration,!1,U,y)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${d.startSN} ,${d.endSN}],track ${o}`);const{cache:_}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new Wn,complete:!1};_.push(new Uint8Array(n)),this.state!==Ie.STOPPED&&(this.state=Ie.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===H.MAIN&&Be(t.frag)&&(this.mainFragLoading=t,this.state===Ie.IDLE&&this.tick())}onFragBuffered(e,t){const{frag:i,part:s}=t;if(i.type!==H.AUDIO){!this.audioOnly&&i.type===H.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(Be(i)){this.fragPrevious=i;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(m.AUDIO_TRACK_SWITCHED,j({},n)))}this.fragBufferedComplete(i,s),this.media&&this.tick()}onError(e,t){var i;if(t.fatal){this.state=Ie.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(H.AUDIO,t);break;case A.AUDIO_TRACK_LOAD_ERROR:case A.AUDIO_TRACK_LOAD_TIMEOUT:case A.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Ie.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===oe.AUDIO_TRACK&&(this.state=Ie.IDLE);break;case A.BUFFER_ADD_CODEC_ERROR:case A.BUFFER_APPEND_ERROR:if(t.parent!=="audio")return;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!==_e.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==_e.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===Ie.ENDED&&(this.state=Ie.IDLE);const i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,H.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:d}=o,{details:h}=d,{audio:g,text:y,id3:v,initSegment:_}=n;if(this.fragContextChanged(u)||!h){this.fragmentTracker.removeFragment(u);return}if(this.state=Ie.PARSING,this.switchingTrack&&g&&this.completeAudioSwitch(this.switchingTrack),_!=null&&_.tracks){const b=u.initSegment||u;this._bufferInitSegment(d,_.tracks,b,r),s.trigger(m.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:i,tracks:_.tracks})}if(g){const{startPTS:b,endPTS:L,startDTS:U,endDTS:M}=g;l&&(l.elementaryStreams[_e.AUDIO]={startPTS:b,endPTS:L,startDTS:U,endDTS:M}),u.setElementaryStreamInfo(_e.AUDIO,b,L,U,M),this.bufferFragmentData(g,u,l,r)}if(v!=null&&(t=v.samples)!=null&&t.length){const b=ce({id:i,frag:u,details:h},v);s.trigger(m.FRAG_PARSING_METADATA,b)}if(y){const b=ce({id:i,frag:u,details:h},y);s.trigger(m.FRAG_PARSING_USERDATA,b)}}_bufferInitSegment(e,t,i,s){if(this.state!==Ie.PARSING||(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,!t.audio))return;const n=t.audio;n.id=H.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(m.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(m.BUFFER_APPENDING,u)}this.tickImmediate()}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);if(this.switchingTrack||s===ni.NOT_LOADED||s===ni.PARTIAL){var n;if(!Be(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=Ie.WAITING_INIT_PTS;const r=this.mainDetails;r&&r.fragmentStart!==t.details.fragmentStart&&ds(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;Ce({name:t,lang:i,assocLang:s,characteristics:n,audioCodec:r,channels:o},e,ke)||(pt(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(m.AUDIO_TRACK_SWITCHED,j({},e))}}class Qr extends De{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==null?void 0:t.lastPartSn);let u=parseInt(r["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const d=Math.min(t.age-t.partTarget,t.targetduration);u>=0&&d>t.partTarget&&(u+=1)}const l=i&&Ct(i);return new at(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 d=Math.max(u||0,0);s.appliedTimelineOffset=d,s.fragments.forEach(h=>{h.start=h.playlistOffset+d})}if(s.live||i!=null&&i.live){const d="levelInfo"in t?t.levelInfo:t.track;if(s.reloaded(i),i&&s.fragments.length>0){Kn(i,s);const U=s.playlistParsingError;if(U){this.warn(U);const M=this.hls;if(!M.config.ignorePlaylistParsingErrors){var l;const{networkDetails:te}=t;M.trigger(m.ERROR,{type:z.NETWORK_ERROR,details:A.LEVEL_PARSING_ERROR,fatal:!1,url:s.url,error:U,reason:U.message,level:t.level||void 0,parent:(l=s.fragments[0])==null?void 0:l.type,networkDetails:te,stats:n});return}s.playlistParsingError=null}}s.requestScheduled===-1&&(s.requestScheduled=n.loading.start);const h=this.hls.mainForwardBufferInfo,g=h?h.end-h.len:0,y=(s.edge-g)*1e3,v=ur(s,y);if(s.requestScheduled+v<r?s.requestScheduled=r:s.requestScheduled+=v,this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),!this.canLoad||!s.live)return;let _,b,L;if(s.canBlockReload&&s.endSN&&s.advanced){const U=this.hls.config.lowLatencyMode,M=s.lastPartSn,te=s.endSN,ne=s.lastPartIndex,be=ne!==-1,re=M===te;be?re?(b=te+1,L=U?0:ne):(b=M,L=U?ne+1:s.maxPartIndex):b=te+1;const ye=s.age,Te=ye+s.ageHeader;let ue=Math.min(Te-s.partTarget,s.targetduration*1.5);if(ue>0){if(Te>s.targetduration*3)this.log(`Playlist last advanced ${ye.toFixed(2)}s ago. Omitting segment and part directives.`),b=void 0,L=void 0;else if(i!=null&&i.tuneInGoal&&Te-s.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${ue} with playlist age: ${s.age}`),ue=0;else{const Xe=Math.floor(ue/s.targetduration);if(b+=Xe,L!==void 0){const dt=Math.round(ue%s.targetduration/s.partTarget);L+=dt}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${ye.toFixed(2)}s goal: ${ue} skip sn ${Xe} to part ${L}`)}s.tuneInGoal=ue}if(_=this.getDeliveryDirectives(s,t.deliveryDirectives,b,L),U||!re){s.requestScheduled=r,this.loadingPlaylist(d,_);return}}else(s.canBlockReload||s.canSkipUntil)&&(_=this.getDeliveryDirectives(s,t.deliveryDirectives,b,L));_&&b!==void 0&&s.canBlockReload&&(s.requestScheduled=n.loading.first+Math.max(v-o*2,v/2)),this.scheduleLoading(d,_,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=Ct(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,s=t.part,n=Ne.No),new at(i,s,n)}checkRetry(e){const t=e.details,i=ui(e),s=e.errorAction,{action:n,retryCount:r=0,retryConfig:o}=s||{},u=!!s&&!!o&&(n===Li.RetryRequest||!s.resolved&&n===Li.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 d=oi(o,r);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),d),this.warn(`Retrying playlist loading ${r+1}/${o.maxNumRetry} after "${t}" in ${d}ms`)}e.levelRetry=!0,s.resolved=!0}return u}}function Xa(a,e){if(a.length!==e.length)return!1;for(let t=0;t<a.length;t++)if(!Jn(a[t].attrs,e[t].attrs))return!1;return!0}function Jn(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 Jr(a,e){return e.label.toLowerCase()===a.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(a.lang||"").toLowerCase())}class Zl extends Qr{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(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVEL_LOADING,this.onLevelLoading,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(m.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(g=>!i||i.indexOf(g.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(g=>g.default)&&(this.selectDefaultTrack=!1),o.forEach((g,y)=>{g.id=y});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const u=this.hls.config.audioPreference;if(!n&&u){const g=pe(u,o,ke);if(g>-1)n=o[g];else{const y=pe(u,this.tracks);n=this.tracks[y]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const d={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${i==null?void 0:i.join(",")}`),this.hls.trigger(m.AUDIO_TRACKS_UPDATED,d);const h=this.trackId;if(l!==-1&&h===-1)this.setAudioTrack(l);else if(o.length&&h===-1){var r;const g=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(g.message),this.hls.trigger(m.ERROR,{type:z.MEDIA_ERROR,details:A.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:g})}}}onError(e,t){t.fatal||!t.context||t.context.type===oe.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&&Ce(e,s,ke))return s;const n=pe(e,this.tracksInGroup,ke);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=xt(e,t.levels,i,r,ke);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const r=pe(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(m.AUDIO_TRACK_SWITCHING,j({},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||Ce(e,s,ke)))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 d=t[l];if(Ce({name:i,lang:s,assocLang:n,characteristics:r,audioCodec:o,channels:u},d,ke))return l}for(let l=0;l<t.length;l++){const d=t[l];if(Jn(e.attrs,d.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return l}for(let l=0;l<t.length;l++){const d=t[l];if(Jn(e.attrs,d.attrs,["LANGUAGE"]))return l}}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;this.shouldLoadPlaylist(t)&&pt(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(m.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null,track:e})}}class Yl{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 qa=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Qa="HlsJsTrackRemovedError";class Xl extends Error{constructor(e){super(e),this.name=Qa}}class ql extends De{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(m.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=He(Oe(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(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.BUFFER_RESET,this.onBufferReset,this),e.on(m.BUFFER_APPENDING,this.onBufferAppending,this),e.on(m.BUFFER_CODECS,this.onBufferCodecs,this),e.on(m.BUFFER_EOS,this.onBufferEos,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m.FRAG_PARSED,this.onFragParsed,this),e.on(m.FRAG_CHANGED,this.onFragChanged,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.BUFFER_RESET,this.onBufferReset,this),e.off(m.BUFFER_APPENDING,this.onBufferAppending,this),e.off(m.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m.BUFFER_EOS,this.onBufferEos,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m.FRAG_PARSED,this.onFragParsed,this),e.off(m.FRAG_CHANGED,this.onFragChanged,this),e.off(m.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?ce(i,s.tracks):this.sourceBuffers.forEach(n=>{const[r]=n;r&&(i[r]=ce({},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,s=Oe(this.appendSource);if(this.transferData=this.overrides=void 0,i&&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,Ja(i),Ql(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=()=>{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: ${qt(i,(u,l)=>u==="initSegment"?void 0:l)};
|
|
transfer tracks: ${qt(s,(u,l)=>u==="initSegment"?void 0:l)}}`),!Qe(s,i)){t.mediaSource=null,t.tracks=void 0;const u=e.currentTime,l=this.details,d=Math.max(u,(l==null?void 0:l.fragments[0].start)||0);if(d-u>1){this.log(`attachTransferred: waiting for playback to reach new tracks start time ${u} -> ${d}`);return}this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(s)}"->"${Object.keys(i)}") start time: ${d} currentTime: ${u}`),this.onMediaDetaching(m.MEDIA_DETACHING,{}),this.onMediaAttaching(m.MEDIA_ATTACHING,t),e.currentTime=d;return}this.transferData=void 0,n.forEach(u=>{const l=u,d=s[l];if(d){const h=d.buffer;if(h){const g=this.fragmentTracker,y=d.id;if(g.hasFragments(y)||g.hasParts(y)){const b=Ft.getBuffered(h);g.detectEvictedFragments(l,b,y,null,!0)}const v=ea(l),_=[l,h];this.sourceBuffers[v]=_,h.updating&&this.operationQueue&&this.operationQueue.prependBlocker(l),this.trackSourceBuffer(l,d)}}}),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&&Ja(s),s.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(m.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 Yl(this.tracks)}onBufferCodecs(e,t){const i=this.tracks,s=Object.keys(t);this.log(`BUFFER_CODECS: "${s}" (current SB count ${this.sourceBufferCount})`);const n="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),r=!n&&this.sourceBufferCount&&this.media&&s.some(o=>!i[o]);if(n||r){this.warn(`Unsupported transition between "${Object.keys(i)}" and "${s}" SourceBuffers`);return}s.forEach(o=>{var u,l,d;const h=t[o],{id:g,codec:y,levelCodec:v,container:_,metadata:b,supplemental:L}=h;let U=i[o];const M=(u=this.transferData)==null||(l=u.tracks)==null?void 0:l[o],te=M!=null&&M.buffer?M:U,ne=(te==null?void 0:te.pendingCodec)||(te==null?void 0:te.codec),be=te==null?void 0:te.levelCodec;U||(U=i[o]={buffer:void 0,listeners:[],codec:y,supplemental:L,container:_,levelCodec:v,metadata:b,id:g});const re=ci(ne,be),ye=re==null?void 0:re.replace(qa,"$1");let Te=ci(y,v);const ue=(d=Te)==null?void 0:d.replace(qa,"$1");Te&&re&&ye!==ue&&(o.slice(0,5)==="audio"&&(Te=pi(Te,this.appendSource)),this.log(`switching codec ${ne} to ${Te}`),Te!==(U.pendingCodec||U.codec)&&(U.pendingCodec=Te),U.container=_,this.appendChangeType(o,_,Te))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),!this.sourceBufferCount&&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,H.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&&Ft.isBuffered(u.buffer,s)||((o=this.fragmentTracker.getAppendedFrag(s,H.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}=t,d=l.buffering[n],h=o.sn,g=self.performance.now();d.start=g;const y=o.stats.buffering,v=u?u.stats.buffering:null;y.start===0&&(y.start=g),v&&v.start===0&&(v.start=g);const _=i.audio;let b=!1;n==="audio"&&(_==null?void 0:_.container)==="audio/mpeg"&&(b=!this.lastMpegAudioChunk||l.id===1||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const L=this.tracks.video,U=L==null?void 0:L.buffer;if(U&&h!=="initSegment"){const ne=u||o,be=this.blockedAudioAppend;if(n==="audio"&&r!=="main"&&!this.blockedAudioAppend){const ye=ne.start+ne.duration*.05,Te=U.buffered,ue=this.currentOp("video");!Te.length&&!ue?this.blockAudio(ne):!ue&&!Ft.isBuffered(U,ye)&&this.lastVideoAppendEnd<ye&&this.blockAudio(ne)}else if(n==="video"){const re=ne.end;if(be){const ye=be.frag.start;(re>ye||re<this.lastVideoAppendEnd||Ft.isBuffered(U,ye))&&this.unblockAudio()}this.lastVideoAppendEnd=re}}const M=(u||o).start,te={label:`append-${n}`,execute:()=>{if(d.executeStart=self.performance.now(),b){const ne=this.tracks[n];if(ne){const be=ne.buffer;if(be){const re=M-be.timestampOffset;Math.abs(re)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${M} (delta: ${re}) sn: ${h})`),be.timestampOffset=M)}}}this.appendExecutor(s,n)},onStart:()=>{},onComplete:()=>{const ne=self.performance.now();d.executeEnd=d.end=ne,y.first===0&&(y.first=ne),v&&v.first===0&&(v.first=ne);const be={};this.sourceBuffers.forEach(([re,ye])=>{re&&(be[re]=Ft.getBuffered(ye))}),this.appendErrors[n]=0,n==="audio"||n==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(m.BUFFER_APPENDED,{type:n,frag:o,part:u,chunkMeta:l,parent:o.type,timeRanges:be})},onError:ne=>{var be;const re={type:z.MEDIA_ERROR,parent:o.type,details:A.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:u,chunkMeta:l,error:ne,err:ne,fatal:!1};if(ne.code===DOMException.QUOTA_EXCEEDED_ERR)re.details=A.BUFFER_FULL_ERROR;else if(ne.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!((be=this.media)!=null&&be.error))re.errorAction=Bi(!0);else if(ne.name===Qa)this.sourceBufferCount===0?re.errorAction=Bi(!0):++this.appendErrors[n];else{const ye=++this.appendErrors[n];this.warn(`Failed ${ye}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer`),ye>=this.hls.config.appendErrorMaxRetry&&(re.fatal=!0)}this.hls.trigger(m.ERROR,re)}};this.append(te,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(m.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[_e.AUDIOVIDEO]?n.push("audiovideo"):(r[_e.AUDIO]&&n.push("audio"),r[_e.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(m.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)}onFragChanged(e,t){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t,i;return e&&(!((t=this.tracks[e])!=null&&t.ended)||((i=this.tracks[e])==null?void 0:i.ending))})}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(m.BUFFERED_TO_END,void 0)})):(this.tracksEnded(),this.hls.trigger(m.BUFFERED_TO_END,void 0)))}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(){const e=this.getDurationAndRange();e&&this.blockUntilOpen(()=>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)&&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(S(o)&&o>=0){const u=Math.max(o,r),l=Math.floor(n/r)*r-u;this.flushBackBuffer(n,r,l)}if(S(s.frontBufferFlushThreshold)&&s.frontBufferFlushThreshold>0){const u=Math.max(s.maxBufferLength,s.frontBufferFlushThreshold),l=Math.max(u,r),d=Math.floor(n/r)*r+l;this.flushFrontBuffer(n,r,d)}}flushBackBuffer(e,t,i){this.sourceBuffers.forEach(([s,n])=>{if(n){const o=Ft.getBuffered(n);if(o.length>0&&i>o.start(0)){var r;this.hls.trigger(m.BACK_BUFFER_REACHED,{bufferEnd:i});const u=this.tracks[s];if((r=this.details)!=null&&r.live)this.hls.trigger(m.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(m.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:s})}}})}flushFrontBuffer(e,t,i){this.sourceBuffers.forEach(([s,n])=>{if(n){const r=Ft.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(m.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&&t.live&&i.setLiveSeekableRange){const l=Math.max(0,t.fragmentStart),d=Math.max(l,s);return{duration:1/0,start:l,end:d}}return{duration:1/0}}const n=(e=this.overrides)==null?void 0:e.duration;if(n)return S(n)?{duration:n}:null;const r=this.media.duration,o=S(i.duration)?i.duration:0;return s>o&&s>r||!S(r)?{duration:s}:null}updateMediaSource({duration:e,start:t,end:i}){const s=this.mediaSource;!this.media||!s||s.readyState!=="open"||(s.duration!==e&&(S(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}) ${qt(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(m.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(m.ERROR,{type:z.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":""} ${qt(o)}`);try{const d=i.addSourceBuffer(l),h=ea(r),g=[r,d];t[h]=g,o.buffer=d}catch(d){var s;this.error(`error while trying to add sourceBuffer: ${d.message}`),this.shiftAndExecuteNext(r),(s=this.operationQueue)==null||s.removeBlockers(),delete this.tracks[r],this.hls.trigger(m.ERROR,{type:z.MEDIA_ERROR,details:A.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,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")&&Qt(i,"video")&&(s=ri(s,i));const n=ci(s,e.levelCodec);return n?t.slice(0,5)==="audio"?pi(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(m.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(m.ERROR,{type:z.MEDIA_ERROR,details:A.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const n=this.currentOp(e);n&&n.onError(s)}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(s.duration)?s.duration:1/0,l=S(n.duration)?n.duration:1/0,d=Math.max(0,t),h=Math.min(i,u,l);h>d&&(!r.ending||r.ended)?(r.ended=!1,this.log(`Removing [${d},${h}] from the ${e} SourceBuffer`),o.remove(d,h)):this.shiftAndExecuteNext(e)}appendExecutor(e,t){const i=this.tracks[t],s=i==null?void 0:i.buffer;if(!s)throw new Xl(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,s.appendBuffer(e)}blockUntilOpen(e){this.isUpdating()||this.isQueued()?this.blockBuffers(e):e()}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){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:i}=this,s=t.map(r=>this.appendBlocker(r));t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(s).then(r=>{i===this.operationQueue&&(e(),this.stepOperationQueue(t))})}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 Ja(a){const e=a.querySelectorAll("source");[].slice.call(e).forEach(t=>{a.removeChild(t)})}function Ql(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 ta{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(m.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.BUFFER_CODECS,this.onBufferCodecs,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(m.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m.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&&S(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,ta.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 Ds={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Jl={HLS:"h"},er={OBJECT:"CMCD-Object",REQUEST:"CMCD-Request",SESSION:"CMCD-Session",STATUS:"CMCD-Status"},eu={[er.OBJECT]:["br","d","ot","tb"],[er.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[er.SESSION]:["cid","pr","sf","sid","st","v"],[er.STATUS]:["bs","rtp"]};class Mn{constructor(e,t){Array.isArray(e)&&(e=e.map(i=>i instanceof Mn?i:new Mn(i))),this.value=e,this.params=t}}const tu="Dict";function iu(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 su(a,e,t,i){return new Error(`failed to ${a} "${iu(e)}" as ${t}`,{cause:i})}function nn(a,e,t){return su("serialize",a,e,t)}class eo{constructor(e){this.description=e}}const to="Bare Item",nu="Boolean";function ru(a){if(typeof a!="boolean")throw nn(a,nu);return a?"?1":"?0"}const au="Byte Sequence";function ou(a){if(ArrayBuffer.isView(a)===!1)throw nn(a,au);return`:${ll(a)}:`}const lu="Integer";function uu(a){return a<-999999999999999||999999999999999<a}function io(a){if(uu(a))throw nn(a,lu);return a.toString()}function cu(a){return`@${io(a.getTime()/1e3)}`}const du="Decimal";function hu(a){const e=Ia(a,3);if(Math.floor(Math.abs(e)).toString().length>12)throw nn(a,du);const t=e.toString();return t.includes(".")?t:`${t}.0`}const fu="String",mu=/[\x00-\x1f\x7f]+/;function gu(a){if(mu.test(a))throw nn(a,fu);return`"${a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function pu(a){return a.description||a.toString().slice(7,-1)}const vu="Token";function so(a){const e=pu(a);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw nn(e,vu);return e}function ia(a){switch(typeof a){case"number":if(!S(a))throw nn(a,to);return Number.isInteger(a)?io(a):hu(a);case"string":return gu(a);case"symbol":return so(a);case"boolean":return ru(a);case"object":if(a instanceof Date)return cu(a);if(a instanceof Uint8Array)return ou(a);if(a instanceof eo)return so(a);default:throw nn(a,to)}}const yu="Key";function sa(a){if(/^[a-z*][a-z0-9\-_.*]*$/.test(a)===!1)throw nn(a,yu);return a}function na(a){return a==null?"":Object.entries(a).map(([e,t])=>t===!0?`;${sa(e)}`:`;${sa(e)}=${ia(t)}`).join("")}function no(a){return a instanceof Mn?`${ia(a.value)}${na(a.params)}`:ia(a)}function Eu(a){return`(${a.value.map(no).join(" ")})${na(a.params)}`}function _u(a,e={whitespace:!0}){if(typeof a!="object")throw nn(a,tu);const t=a instanceof Map?a.entries():Object.entries(a),i=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof Mn||(n=new Mn(n));let r=sa(s);return n.value===!0?r+=na(n.params):(r+="=",Array.isArray(n.value)?r+=Eu(n):r+=no(n)),r}).join(`,${i}`)}function Su(a,e){return _u(a,e)}function bu(a){return a==="ot"||a==="sf"||a==="st"}function xu(a){return typeof a=="number"?S(a):a!=null&&a!==""&&a!==!1}const Sr=a=>Math.round(a),Tu=(a,e)=>(e!=null&&e.baseUrl&&(a=ul(a,e.baseUrl)),encodeURIComponent(a)),br=a=>Sr(a/100)*100,Au={br:Sr,d:Sr,bl:br,dl:br,mtp:br,nor:Tu,rtp:br,tb:Sr};function Ru(a,e){const t={};if(a==null||typeof a!="object")return t;const i=Object.keys(a).sort(),s=ce({},Au,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return i.forEach(r=>{if(n!=null&&n(r))return;let o=a[r];const u=s[r];u&&(o=u(o,e)),!(r==="v"&&o===1)&&(r=="pr"&&o===1||xu(o)&&(bu(r)&&typeof o=="string"&&(o=new eo(o)),t[r]=o))}),t}function ro(a,e={}){return a?Su(Ru(a,e),ce({whitespace:!1},e)):""}function Lu(a,e={}){const t={};if(!a)return t;const i=Object.entries(a),s=Object.entries(eu).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),n=i.reduce((r,o)=>{var u,l;const[d,h]=o,g=((u=s.find(y=>y[1].includes(d)))===null||u===void 0?void 0:u[0])||er.REQUEST;return(l=r[g])!==null&&l!==void 0||(r[g]={}),r[g][d]=h,r},{});return Object.entries(n).reduce((r,[o,u])=>(r[o]=ro(u,e),r),t)}function Iu(a,e,t){return ce(a,Lu(e,t))}const Cu="CMCD";function Du(a,e={}){if(!a)return"";const t=ro(a,e);return`${Cu}=${encodeURIComponent(t)}`}const ao=/CMCD=[^&#]+/;function wu(a,e,t){const i=Du(e,t);if(!i)return a;if(ao.test(a))return a.replace(ao,i);const s=a.includes("?")?"&":"?";return`${a}${s}${i}`}class ku{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:Ds.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===Ds.VIDEO||u===Ds.AUDIO||u==Ds.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(u)/1e3,l.bl=this.getBufferLength(u));const d=r?this.getNextPart(r):this.getNextFrag(n);d!=null&&d.url&&d.url!==n.url&&(l.nor=d.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(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHED,this.onMediaDetached,this),e.on(m.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHED,this.onMediaDetached,this),e.off(m.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:Jl.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ce(t,this.createData());const i=t.ot===Ds.INIT||t.ot===Ds.VIDEO||t.ot===Ds.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={}),Iu(e.headers,t,n)):e.url=wu(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,i;const{index:s,fragment:n}=e,r=(t=this.hls.levels[n.level])==null||(i=t.details)==null?void 0:i.partList;if(r){const{sn:o}=n;for(let u=r.length-1;u>=0;u--){const l=r[u];if(l.index===s&&l.fragment.sn===o)return r[u+1]}}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Ds.TIMED_TEXT;if(e.sn==="initSegment")return Ds.INIT;if(t==="audio")return Ds.AUDIO;if(t==="main")return this.hls.audioTracks.length?Ds.VIDEO:Ds.MUXED}getTopBandwidth(e){let t=0,i;const s=this.hls;if(e===Ds.AUDIO)i=s.audioTracks;else{const n=s.maxAutoLevel,r=n>-1?n+1:s.levels.length;i=s.levels.slice(0,r)}for(const n of i)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.media,i=e===Ds.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:Ft.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 Ou=3e5;class Pu extends De{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(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.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)===Li.SendAlternateToPenaltyBox&&i.flags===fi.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),i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${s&&s.length} priorities: ${qt(n)} penalized: ${qt(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]>Ou&&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,dr(t),this.hls.trigger(m.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===oe.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===oe.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(d=>d.pathwayId===r))return;const l=this.getLevelsForPathway(o).map(d=>{const h=new vi(d.attrs);h["PATHWAY-ID"]=r;const g=h.AUDIO&&`${h.AUDIO}_clone_${r}`,y=h.SUBTITLES&&`${h.SUBTITLES}_clone_${r}`;g&&(i[h.AUDIO]=g,h.AUDIO=g),y&&(s[h.SUBTITLES]=y,h.SUBTITLES=y);const v=lo(d.uri,h["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u),_=new Ke({attrs:h,audioCodec:d.audioCodec,bitrate:d.bitrate,height:d.height,name:d.name,url:v,videoCodec:d.videoCodec,width:d.width});if(d.audioGroups)for(let b=1;b<d.audioGroups.length;b++)_.addGroupId("audio",`${d.audioGroups[b]}_clone_${r}`);if(d.subtitleGroups)for(let b=1;b<d.subtitleGroups.length;b++)_.addGroupId("text",`${d.subtitleGroups[b]}_clone_${r}`);return _});t.push(...l),oo(this.audioTracks,i,u,r),oo(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(d){this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const d=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+d)}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:(d,h,g,y)=>{this.log(`Loaded steering manifest: "${s}"`);const v=d.data;if((v==null?void 0:v.VERSION)!==1){this.log(`Steering VERSION ${v.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=v.TTL;const{"RELOAD-URI":_,"PATHWAY-CLONES":b,"PATHWAY-PRIORITY":L}=v;if(_)try{this.uri=new self.URL(_,s).href}catch(M){this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${_}`);return}this.scheduleRefresh(this.uri||g.url),b&&this.clonePathways(b);const U={steeringManifest:v,url:s.toString()};this.hls.trigger(m.STEERING_MANIFEST_LOADED,U),L&&this.updatePathwayPriority(L)},onError:(d,h,g,y)=>{if(this.log(`Error loading steering manifest: ${d.code} ${d.text} (${h.url})`),this.stopLoad(),d.code===410){this.enabled=!1,this.log(`Steering manifest ${h.url} no longer available`);return}let v=this.timeToLoad*1e3;if(d.code===429){const _=this.loader;if(typeof(_==null?void 0:_.getResponseHeader)=="function"){const b=_.getResponseHeader("Retry-After");b&&(v=parseFloat(b)*1e3)}this.log(`Steering manifest ${h.url} rate limited`);return}this.scheduleRefresh(this.uri||h.url,v)},onTimeout:(d,h,g)=>{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 oo(a,e,t,i){a&&Object.keys(e).forEach(s=>{const n=a.filter(r=>r.groupId===s).map(r=>{const o=ce({},r);return o.details=void 0,o.attrs=new vi(o.attrs),o.url=o.attrs.URI=lo(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 lo(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 Bn extends De{constructor(e){super("eme",e.logger),this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Bn.CDMCleanupPromise?[Bn.CDMCleanupPromise]:[],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=yt(this.config));const o=r.map(Fs).filter(u=>!!u);this.keyFormatPromise=this.getKeyFormatPromise(o)}this.keyFormatPromise.then(r=>{const o=zs(r);let u,l;if(i==="sinf"){if(o!==yi.FAIRPLAY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}const v=gt(new Uint8Array(s));try{const _=xs(JSON.parse(v).sinf),b=le(_);if(!b)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");u=new Uint8Array(b.subarray(8,24)),l=yi.FAIRPLAY}catch(_){this.warn(`${n} Failed to parse sinf: ${_}`);return}}else{if(o!==yi.WIDEVINE&&o!==yi.PLAYREADY){this.warn(`Ignoring unexpected "${t.type}" event with init data type: "${i}" for selected key-system ${o}`);return}const v=Ti(s),_=v.filter(L=>!!L.systemId&&tn(L.systemId)===o);_.length>1&&this.warn(`${n} Using first of ${_.length} pssh found for selected key-system ${o}`);const b=_[0];if(!b){v.length===0||v.some(L=>!L.systemId)?this.warn(`${n} contains incomplete or invalid pssh data`):this.log(`ignoring ${n} for ${v.map(L=>tn(L.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(l=tn(b.systemId),b.version===0&&b.data)if(l===yi.WIDEVINE){const L=b.data.length-22;u=new Uint8Array(b.data.subarray(L,L+16))}else l===yi.PLAYREADY&&(u=Di(b.data))}if(!l||!u)return;const d=ee.hexDump(u),{keyIdToKeySessionPromise:h,mediaKeySessions:g}=this;let y=h[d];for(let v=0;v<g.length;v++){const _=g[v],b=_.decryptdata;if(!b.keyId)continue;const L=ee.hexDump(b.keyId);if(d===L||b.uri.replace(/-/g,"").indexOf(d)!==-1){if(y=h[L],b.pssh)break;delete h[L],b.pssh=new Uint8Array(s),b.keyId=u,y=h[d]=y.then(()=>this.generateRequestWithPreferredKeySession(_,i,s,"encrypted-event-key-match")),y.catch(U=>this.handleError(U));break}}if(!y){if(l!==o){this.log(`Ignoring "${t.type}" event with ${l} init data for selected key-system ${o}`);return}y=h[d]=this.getKeySystemSelectionPromise([l]).then(({keySystem:v,mediaKeys:_})=>{var b;this.throwIfDestroyed();const L=new Zs("ISO-23001-7",d,(b=Fs(v))!=null?b:"");return L.pssh=new Uint8Array(s),L.keyId=u,this.attemptSetMediaKeys(v,_).then(()=>{this.throwIfDestroyed();const U=this.createMediaKeySessionContext({decryptdata:L,keySystem:v,mediaKeys:_});return this.generateRequestWithPreferredKeySession(U,i,s,"encrypted-event-no-match")})}),y.catch(v=>this.handleError(v))}})}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=e,this.config=e.config,this.registerListeners()}destroy(){const e=this.media;this.unregisterListeners(),this.onMediaDetached(),this._clear(e);const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(m.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(m.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(m.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(m.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(m.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===yi.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[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 d=l.shift();this.getMediaKeysPromise(d,s,n).then(h=>r({keySystem:d,mediaKeys:h})).catch(h=>{l.length?u(l):h instanceof Us?o(h):o(new Us({type:z.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 Kt===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){const s=zi(e,t,i,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let r=n==null?void 0:n.keySystemAccess;if(!r){this.log(`Requesting encrypted media "${e}" key-system access with config: ${qt(s)}`),r=this.requestMediaKeySystemAccess(e,s);const o=this.keySystemAccessPromises[e]={keySystemAccess:r};return r.catch(u=>{this.log(`Failed to obtain access to key-system "${e}": ${u}`)}),r.then(u=>{this.log(`Access for key-system "${u.keySystem}" obtained`);const l=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=u.createMediaKeys().then(d=>(this.log(`Media-keys created for "${e}"`),l.then(h=>h?this.setMediaKeysServerCertificate(d,e,h):d))),o.mediaKeys.catch(d=>{this.error(`Failed to create media-keys for "${e}"}: ${d}`)}),o.mediaKeys})}return r.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${ee.hexDump(e.keyId||[])}`);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=this.getKeyIdString(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)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return ee.hexDump(e.keyId)}updateKeySession(e,t){var i;const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${ee.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
|
|
} (data length: ${t&&t.byteLength})`),s.update(t)}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){return new Promise((t,i)=>{const s=yt(this.config),n=e.map(zs).filter(r=>!!r&&s.indexOf(r)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:r})=>{const o=Fs(r);o?t(o):i(new Error(`Unable to find format for key-system "${r}"`))}).catch(i)})}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),s=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[i];return n||(n=this.getKeySystemForKeyPromise(t).then(({keySystem:o,mediaKeys:u})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(o,u).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:o,mediaKeys:u,decryptdata:t}))))),(this.keyIdToKeySessionPromise[i]=n.then(o=>{const u="cenc",l=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(o,u,l,"playlist-key")})).catch(o=>this.handleError(o))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Us?this.hls.trigger(m.ERROR,e.data):this.hls.trigger(m.ERROR,{type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const s=zs(e.keyFormat),n=s?[s]:yt(this.config);return this.attemptKeySystemAccess(n)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=yt(this.config)),e.length===0)throw new Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${qt({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return 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,r;const o=(n=this.config.drmSystems)==null||(r=n[e.keySystem])==null?void 0:r.generateRequest;if(o)try{const v=o.call(this.hls,t,i,e);if(!v)throw new Error("Invalid response from configured generateRequest filter");t=v.initDataType,i=v.initData?v.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(v){var u;if(this.warn(v.message),(u=this.hls)!=null&&u.config.debug)throw v}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const l=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${l} (init data type: ${t} length: ${i?i.byteLength:null})`);const d=new $r,h=e._onmessage=v=>{const _=e.mediaKeysSession;if(!_){d.emit("error",new Error("invalid state"));return}const{messageType:b,message:L}=v;this.log(`"${b}" message event for session "${_.sessionId}" message size: ${L.byteLength}`),b==="license-request"||b==="license-renewal"?this.renewLicense(e,L).catch(U=>{d.eventNames().length?d.emit("error",U):this.handleError(U)}):b==="license-release"?e.keySystem===yi.FAIRPLAY&&(this.updateKeySession(e,ji("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${b}"`)},g=e._onkeystatuseschange=v=>{if(!e.mediaKeysSession){d.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const b=e.keyStatus;d.emit("keyStatus",b),b==="expired"&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",h),e.mediaKeysSession.addEventListener("keystatuseschange",g);const y=new Promise((v,_)=>{d.on("error",_),d.on("keyStatus",b=>{b.startsWith("usable")?v():b==="output-restricted"?_(new Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):b==="internal-error"?_(new Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${b}"`)):b==="expired"?_(new Error("key expired while generating request")):this.warn(`unhandled key status change "${b}"`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var v;this.log(`Request generated for key-session "${(v=e.mediaKeysSession)==null?void 0:v.sessionId}" keyId: ${l}`)}).catch(v=>{throw new Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_SESSION,error:v,fatal:!1},`Error generating key-session request: ${v}`)}).then(()=>y).catch(v=>{throw d.removeAllListeners(),this.removeSession(e),v}).then(()=>(d.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${ee.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${ee.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=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,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(g,y,v,_)=>{r(g.data)},onError:(g,y,v,_)=>{o(new Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:v,response:j({url:u.url,data:void 0},g)},`"${e}" certificate request failed (${n}). Status: ${g.code} (${g.text})`))},onTimeout:(g,y,v)=>{o(new Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:v,response:{url:u.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(g,y,v)=>{o(new Error("aborted"))}};s.load(u,d,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==null?void 0:i.byteLength}) on "${t}"`),s(e)}).catch(r=>{n(new Us({type:z.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 Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},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 d;for(let h=0,g=n.length;h<g;h++){var r,o;d=n[h];const y=(r=d.querySelector("name"))==null?void 0:r.textContent,v=(o=d.querySelector("value"))==null?void 0:o.textContent;y&&v&&e.setRequestHeader(y,v)}}const u=s.querySelector("Challenge"),l=u==null?void 0:u.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return ji(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(d){this.error(d)}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 Us({type:z.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_LICENSE_REQUEST_FAILED,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 d=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${d} 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==yi.PLAYREADY&&(l=this.unpackPlayReadyKeyMessage(u,l)),u.send(l)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,i.removeEventListener("encrypted",this.onMediaEncrypted),i.removeEventListener("waitingforkey",this.onWaitingForKey),i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null)}_clear(e){var t;const i=this.mediaKeySessions;this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Zs.clearKeyUriToKeyIdMap();const s=i.length;Bn.CDMCleanupPromise=Promise.all(i.map(n=>this.removeSession(n)).concat(e==null||(t=e.setMediaKeys(null))==null?void 0:t.catch(n=>{var r;this.log(`Could not clear media keys: ${n}`),(r=this.hls)==null||r.trigger(m.ERROR,{type:z.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${n}`)})}))).then(()=>{s&&(this.log("finished closing key sessions and clearing media keys"),i.length=0)}).catch(n=>{var r;this.log(`Could not close sessions and clear media keys: ${n}`),(r=this.hls)==null||r.trigger(m.ERROR,{type:z.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${n}`)})})}onManifestLoading(){this.keyFormatPromise=null}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}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),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 s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{var r;this.log(`Could not remove session: ${n}`),(r=this.hls)==null||r.trigger(m.ERROR,{type:z.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${n}`)})}).then(()=>t.close()).catch(n=>{var r;this.log(`Could not close session: ${n}`),(r=this.hls)==null||r.trigger(m.ERROR,{type:z.OTHER_ERROR,details:A.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${n}`)})})}}}Bn.CDMCleanupPromise=void 0;class Us 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}}class Mu{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(m.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(m.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(m.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(m.FPS_DROP,{currentDropped:r,currentDecoded:o,totalDroppedFrames:i}),u>0&&r>l.config.fpsDroppedMonitoringThreshold*o){let d=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=d)&&(d=d-1,l.trigger(m.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:l.currentLevel}),l.autoLevelCapping=d,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 uo(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 co(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){Z.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){Z.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(a.mode=t)}function Fn(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 ra(a,e,t,i){const s=a.mode;if(s==="disabled"&&(a.mode="hidden"),a.cues&&a.cues.length>0){const n=Fu(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 Bu(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 Fu(a,e,t){const i=[],s=Bu(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 xr(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 Nu extends Qr{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=xr(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(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(m.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVEL_LOADING,this.onLevelLoading,this),e.off(m.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(m.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;xr(i.textTracks).forEach(r=>{Fn(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(d=>!i||i.indexOf(d.groupId)!==-1);if(r.length)this.selectDefaultTrack&&!r.some(d=>d.default)&&(this.selectDefaultTrack=!1),r.forEach((d,h)=>{d.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 d=pe(o,r);if(d>-1)n=r[d];else{const h=pe(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(m.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||Ce(n,e)))return s}if(e){for(let s=0;s<t.length;s++){const n=t[s];if(Jn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const n=t[s];if(Jn(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(Jr(s,e))return i}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===oe.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&&Ce(e,i))return i;const s=pe(e,this.tracksInGroup);if(s>-1){const n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(i)return null;{const n=pe(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(m.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:s,deliveryDirectives:t||null,track:e})}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=xr(e.textTracks),i=this.currentTrack;let s;if(i&&(s=t.filter(n=>Jr(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||!S(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(m.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:d}=s;this.hls.trigger(m.SUBTITLE_TRACK_SWITCH,{id:r,groupId:o,name:u,type:l,url:d});const h=this.switchParams(s.url,i==null?void 0:i.details,s.details);this.loadPlaylist(h)}}function tr(a){let e=5381,t=a.length;for(;t;)e=e*33^a.charCodeAt(--t);return(e>>>0).toString()}const Nn=.025;let Tr=function(a){return a[a.Point=0]="Point",a[a.Range=1]="Range",a}({});function $u(a,e,t){return`${a.identifier}-${t+1}-${tr(e)}`}class Uu{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){if(e>=this.assetList.length)return!0;const t=this.playoutLimit;return e<=0||isNaN(t)?!1:this.assetList[e].startOffset>t}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 aa(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=aa(t,e);return t-i<.1}return!1}get resumptionOffset(){const e=this.resumeOffset,t=S(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 aa(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)<Nn))}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"?Tr.Range:Tr.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 Gu(this)}}function aa(a,e){return a-e.start<e.duration/2&&!(Math.abs(a-(e.start+e.duration))<Nn)?e.start:e.start+e.duration}function ho(a,e,t){const i=new self.URL(a,t);return i.protocol!=="data:"&&i.searchParams.set("_HLS_primary_id",e),i}function Gu(a){return`["${a.identifier}" ${a.cue.pre?"<pre>":a.cue.post?"<post>":""}${a.timelineStart.toFixed(2)}-${a.resumeTime.toFixed(2)}]`}function oa(a){const e=a.timelineStart,t=a.duration||0;return`["${a.identifier}" ${e.toFixed(2)}-${(e+t).toFixed(2)}]`}class Vu{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=()=>{const l=this.interstitial.playoutLimit,d=this.currentTime;this.startOffset+d>=l&&this.hls.trigger(m.PLAYOUT_LIMIT_REACHED,{})};const n=this.hls=new e(t);this.interstitial=i,this.assetItem=s;let r=s.uri;try{r=ho(r,n.sessionId).href}catch(u){}n.loadSource(r);const o=()=>{this.hasDetails=!0};n.once(m.LEVEL_LOADED,o),n.once(m.AUDIO_TRACK_LOADED,o),n.once(m.SUBTITLE_TRACK_LOADED,o),n.on(m.MEDIA_ATTACHING,(u,{media:l})=>{this.removeMediaListeners(),this.mediaAttached=l,this.interstitial.playoutLimit&&l.addEventListener("timeupdate",this.checkPlayout)})}bufferedInPlaceToEnd(e){var t;if(!this.interstitial.appendInPlace)return!1;if((t=this.hls)!=null&&t.bufferedToEnd)return!0;if(!e||!this._bufferedEosTime)return!1;const i=this.timelineOffset,s=Ft.bufferInfo(e,i,0);return this.getAssetTime(s.end)>=this._bufferedEosTime-.02}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=Ft.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;return e||0}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){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.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(e){this.hls.attachMedia(e)}detachMedia(){this.removeMediaListeners(),this.mediaAttached=null,this.hls.detachMedia()}resumeBuffering(){this.hls.resumeBuffering()}pauseBuffering(){this.hls.pauseBuffering()}transferMedia(){return this.bufferSnapShot(),this.hls.transferMedia()}on(e,t,i){this.hls.on(e,t)}once(e,t,i){this.hls.once(e,t)}off(e,t,i){this.hls.off(e,t)}toString(){var e,t;return`HlsAssetPlayer: ${oa(this.assetItem)} ${(e=this.hls)==null?void 0:e.sessionId} ${(t=this.interstitial)!=null&&t.appendInPlace?"append-in-place":""}`}}const fo=.033;class Ku extends De{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))return n}}return 0}get assetIdAtEnd(){var e,t;const i=(e=this.items)==null||(t=e[this.length-1])==null?void 0:t.event;if(i){const s=i.assetList,n=s[s.length-1];if(n)return n.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,d)=>{const h=l.cue.pre,g=l.cue.post,y=d.cue.pre,v=d.cue.post;if(h&&!y)return-1;if(y&&!h||g&&!v)return 1;if(v&&!g)return-1;if(!h&&!y&&!g&&!v){const _=l.startTime,b=d.startTime;if(_!==b)return _-b}return l.dateRange.tagOrder-d.dateRange.tagOrder}),this.events=r,u.forEach(l=>{this.removeEvent(l)}),this.updateSchedule(e,u)}updateSchedule(e,t=[]){const i=this.events||[];if(i.length||t.length||this.length<2){const s=this.items,n=this.parseSchedule(i,e);(t.length||(s==null?void 0:s.length)!==n.length||n.some((o,u)=>Math.abs(o.playout.start-s[u].playout.start)>.005||Math.abs(o.playout.end-s[u].playout.end)>.005))&&(this.items=n,this.onScheduleUpdate(t,s))}}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 Uu(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((d,h)=>{const g=d.cue.pre,y=d.cue.post,v=e[h-1]||null,_=d.appendInPlace,b=y?n:d.startOffset,L=d.duration,U=d.timelineOccupancy===Tr.Range?L:0,M=d.resumptionOffset,te=(v==null?void 0:v.startTime)===b,ne=b+d.cumulativeDuration;let be=_?ne+L:b+M;if(g||!y&&b<=0){const ye=l;l+=U,d.timelineStart=ne;const Te=r;r+=L,i.push({event:d,start:ne,end:be,playout:{start:Te,end:r},integrated:{start:ye,end:l}})}else if(b<=n){if(!te){const ue=b-u;if(ue>fo){const Xe=u,dt=l;l+=ue;const Ei=r;r+=ue;const zt={previousEvent:e[h-1]||null,nextEvent:d,start:Xe,end:Xe+ue,playout:{start:Ei,end:r},integrated:{start:dt,end:l}};i.push(zt)}else ue>0&&v&&(v.cumulativeDuration+=ue,i[i.length-1].end=b)}y&&(be=ne),d.timelineStart=ne;const ye=l;l+=U;const Te=r;r+=L,i.push({event:d,start:ne,end:be,playout:{start:Te,end:r},integrated:{start:ye,end:l}})}else return;const re=d.resumeTime;y||re>n?u=n:u=re}),u<n){var o;const d=u,h=l,g=n-u;l+=g;const y=r;r+=g,i.push({previousEvent:((o=i[i.length-1])==null?void 0:o.event)||null,nextEvent:null,start:u,end:d+g,playout:{start:y,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,d=o.cue.post,h=l?0:d?s:o.startTime;this.updateAssetDurations(o),r===h?o.cumulativeDuration=n:(n=0,r=h),!d&&o.snapOptions.in&&(o.resumeAnchor=Bt(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<fo&&(e[u+1].appendInPlace=!1,e[u+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const y=S(o.resumeOffset)?o.resumeOffset:o.duration;n+=y})}primaryCanResumeInPlaceAt(e,t){const i=e.resumeTime,s=e.startTime+e.resumptionOffset;return Math.abs(i-s)>Nn?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${s}`),!1):t?!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=Bt(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 d=r==="audio"?.175:0;return Math.abs(l.start-i)<Nn+d||Math.abs(l.end-i)<Nn+d?!1:(this.log(`"${e.identifier}" resumption ${i} not aligned with ${r} fragment bounds (${l.start}-${l.end} sn: ${l.sn} cc: ${l.cc})`),!0)}):(this.log(`"${e.identifier}" resumption ${i} can not be aligned with media (none selected)`),!1)}updateAssetDurations(e){if(!e.assetListLoaded)return;const t=e.timelineStart;let i=0,s=!1,n=!1;e.assetList.forEach((r,o)=>{const u=t+i;r.startOffset=i,r.timelineStart=u,s||(s=r.duration===null),n||(n=!!r.error);const l=r.error?0:r.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 pn(a){return`[${a.event?'"'+a.event.identifier+'"':"primary"}: ${a.start.toFixed(2)}-${a.end.toFixed(2)}]`}class Hu{constructor(e){this.hls=void 0,this.hls=e}destroy(){this.hls=null}loadAssetList(e,t){const i=e.assetListUrl;let s;try{s=ho(i,this.hls.sessionId,e.baseUrl)}catch(g){const y=this.assignAssetListError(e,A.ASSET_LIST_LOAD_ERROR,g,i);this.hls.trigger(m.ERROR,y);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,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(g,y,v,_)=>{const b=g.data,L=b==null?void 0:b.ASSETS;if(!Array.isArray(L)){const U=this.assignAssetListError(e,A.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),v.url,y,_);this.hls.trigger(m.ERROR,U);return}e.assetListResponse=b,this.hls.trigger(m.ASSET_LIST_LOADED,{event:e,assetListResponse:b,networkDetails:_})},onError:(g,y,v,_)=>{const b=this.assignAssetListError(e,A.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${g.code} ${g.text} (${y.url})`),y.url,_,v);this.hls.trigger(m.ERROR,b)},onTimeout:(g,y,v)=>{const _=this.assignAssetListError(e,A.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${y.url})`),y.url,g,v);this.hls.trigger(m.ERROR,_)}};return o.load(u,d,h),this.hls.trigger(m.ASSET_LIST_LOADING,{event:e}),o}assignAssetListError(e,t,i,s,n,r){return e.error=i,{type:z.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:s,error:i,networkDetails:r,stats:n}}}function dn(a,e,t){rn(a,e,t),a.addEventListener(e,t)}function rn(a,e,t){a.removeEventListener(e,t)}function mo(a){a==null||a.play().catch(()=>{})}class ju extends De{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)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(),this.checkBuffer(),r&&i<o.start||i>=o.end){var u;const g=this.schedule.findItemIndexAtTime(this.timelinePos);if(!this.isInterstitial(o)&&(u=this.media)!=null&&u.paused&&(this.shouldPlay=!1),!r){const y=this.findItemIndex(o);if(g>y){const v=this.schedule.findJumpRestrictedIndex(y+1,g);if(v>y){this.setSchedulePosition(v);return}}}this.setSchedulePosition(g);return}const l=this.playingAsset;if(!l){if(this.playingLastItem&&this.isInterstitial(o)){const g=o.event.assetList[0];g&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(i,g))}return}const d=l.timelineStart,h=l.duration||0;(r&&i<d||i>=d+h)&&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,r=this.playingItem,o=n.events||[],u=n.items||[],l=n.durations,d=i.map(y=>y.identifier),h=!!(o.length||d.length);if(h&&this.log(`INTERSTITIALS_UPDATED (${o.length}): ${o}
|
|
Schedule: ${u.map(y=>pn(y))}`),d.length&&this.log(`Removed events ${d}`),this.playerQueue.forEach(y=>{if(y.interstitial.appendInPlace){const v=y.assetItem.timelineStart,_=y.timelineOffset-v;if(_)try{y.timelineOffset=v}catch(b){Math.abs(_)>Nn&&this.warn(`${b} ("${y.assetId}" ${y.timelineOffset}->${v})`)}}}),r){const y=this.updateItem(r,this.timelinePos);this.itemsMatch(r,y)&&(this.playingItem=y,this.waitingItem=this.endedItem=null)}else this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const g=this.bufferingItem;if(g){const y=this.updateItem(g,this.bufferedPos);this.itemsMatch(g,y)?this.bufferingItem=y:g.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(g.event,null))}if(i.forEach(y=>{y.assetList.forEach(v=>{this.clearAssetPlayer(v.identifier,null)})}),h||s){if(this.hls.trigger(m.INTERSTITIALS_UPDATED,{events:o.slice(0),schedule:u.slice(0),durations:l,removedIds:d}),this.isInterstitial(r)&&d.includes(r.event.identifier)){this.warn(`Interstitial "${r.event.identifier}" removed while playing`),this.primaryFallback(r.event);return}this.checkBuffer()}},this.hls=e,this.HlsPlayerClass=t,this.assetListLoader=new Hu(e),this.schedule=new Ku(this.onScheduleUpdate,e.logger),this.registerListeners()}registerListeners(){const e=this.hls;e.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(m.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(m.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(m.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(m.BUFFER_APPENDED,this.onBufferAppended,this),e.on(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(m.MEDIA_ENDED,this.onMediaEnded,this),e.on(m.ERROR,this.onError,this),e.on(m.DESTROYING,this.onDestroying,this)}unregisterListeners(){const e=this.hls;e&&(e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(m.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(m.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(m.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(m.BUFFER_CODECS,this.onBufferCodecs,this),e.off(m.BUFFER_APPENDED,this.onBufferAppended,this),e.off(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(m.MEDIA_ENDED,this.onMediaEnded,this),e.off(m.ERROR,this.onError,this),e.off(m.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.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}removeMediaListeners(e){rn(e,"play",this.onPlay),rn(e,"pause",this.onPause),rn(e,"seeking",this.onSeeking),rn(e,"timeupdate",this.onTimeupdate)}onMediaAttaching(e,t){const i=this.media=t.media;dn(i,"seeking",this.onSeeking),dn(i,"timeupdate",this.onTimeupdate),dn(i,"play",this.onPlay),dn(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.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.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.manager){if(!this.hls)return null;const e=this,t=()=>e.bufferingItem||e.waitingItem,i=h=>h&&e.getAssetPlayer(h.identifier),s=(h,g,y,v,_)=>{if(h){let b=h[g].start;const L=h.event;if(L){if(g==="playout"||L.timelineOccupancy!==Tr.Point){const U=i(y);(U==null?void 0:U.interstitial)===L&&(b+=U.assetItem.startOffset+U[_])}}else{const U=v==="bufferedPos"?r():e[v];b+=U-h.start}return b}return 0},n=(h,g)=>{if(h!==0&&g!=="primary"&&e.schedule.length){var y;const v=e.schedule.findItemIndexAtTime(h),_=(y=e.schedule.items)==null?void 0:y[v];if(_){const b=_[g].start-_.start;return h+b}}return h},r=()=>{const h=e.bufferedPos;return h===Number.MAX_VALUE?o("primary"):Math.max(h,0)},o=h=>{var g;return(g=e.primaryDetails)!=null&&g.live?e.primaryDetails.edge:e.schedule.durations[h]},u=(h,g)=>{var y,v;const _=e.effectivePlayingItem;if(_!=null&&(y=_.event)!=null&&y.restrictions.skip)return;e.log(`seek to ${h} "${g}"`);const b=e.effectivePlayingItem,L=e.schedule.findItemIndexAtTime(h,g),U=(v=e.schedule.items)==null?void 0:v[L],M=e.getBufferingPlayer(),te=M==null?void 0:M.interstitial,ne=te==null?void 0:te.appendInPlace,be=b&&e.itemsMatch(b,U);if(b&&(ne||be)){const ye=i(e.playingAsset),Te=(ye==null?void 0:ye.media)||e.primaryMedia;if(Te){const ue=g==="primary"?Te.currentTime:s(b,g,e.playingAsset,"timelinePos","currentTime"),Xe=h-ue,dt=(ne?ue:Te.currentTime)+Xe;if(dt>=0&&(!ye||ne||dt<=ye.duration)){Te.currentTime=dt;return}}}if(U){let ye=h;if(g!=="primary"){const ue=U[g].start,Xe=h-ue;ye=U.start+Xe}const Te=!e.isInterstitial(U);if((!e.isInterstitial(b)||b.event.appendInPlace)&&(Te||U.event.appendInPlace)){const ue=e.media||(ne?M==null?void 0:M.media:null);ue&&(ue.currentTime=ye)}else if(b){const ue=e.findItemIndex(b);if(L>ue){const dt=e.schedule.findJumpRestrictedIndex(ue+1,L);if(dt>ue){e.setSchedulePosition(dt);return}}let Xe=0;if(Te)e.timelinePos=ye,e.checkBuffer();else{var re;const dt=U==null||(re=U.event)==null?void 0:re.assetList;if(dt){const Ei=h-(U[g]||U).start;for(let zt=dt.length;zt--;){const Nt=dt[zt];if(Nt.duration&&Ei>=Nt.startOffset&&Ei<Nt.startOffset+Nt.duration){Xe=zt;break}}}}e.setSchedulePosition(L,Xe)}}},l=()=>{const h=e.effectivePlayingItem;if(e.isInterstitial(h))return h;const g=t();return e.isInterstitial(g)?g:null},d={get currentTime(){const h=l(),g=e.effectivePlayingItem;return g&&g===h?s(g,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-g.playout.start:0},set currentTime(h){const g=l(),y=e.effectivePlayingItem;y&&y===g&&u(h+y.playout.start,"playout")},get duration(){const h=l();return h?h.playout.end-h.playout.start:0},get assetPlayers(){var h;const g=(h=l())==null?void 0:h.event.assetList;return g?g.map(y=>e.getAssetPlayer(y.identifier)):[]},get playingIndex(){var h;const g=(h=l())==null?void 0:h.event;return g&&e.effectivePlayingAsset?g.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return l()}};this.manager={get events(){var h,g;return((h=e.schedule)==null||(g=h.events)==null?void 0:g.slice(0))||[]},get schedule(){var h,g;return((h=e.schedule)==null||(g=h.items)==null?void 0:g.slice(0))||[]},get interstitialPlayer(){return l()?d: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,g=h==null?void 0:h.event;if(g&&!g.restrictions.skip){const y=e.findItemIndex(h);if(g.appendInPlace){const v=h.playout.start+h.event.duration;u(v+.001,"playout")}else e.advanceAfterAssetEnded(g,y,1/0)}}}}return this.manager}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,i;if(this.mediaSelection===null)return;const s=this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&!s.event.appendInPlace)return;let n=this.media;!n&&(e=this.bufferingItem)!=null&&(t=e.event)!=null&&t.appendInPlace&&(n=this.primaryMedia);const r=(i=n)==null?void 0:i.currentTime;if(!(r===void 0||!S(r)))return r}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} ${qt(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 d;if(r.media)u&&(n=r.transferMedia(),this.detachedData=n),d="Primary";else if(l){const y=this.getBufferingPlayer();y?(n=y.transferMedia(),d=`${y}`):d="detached MediaSource"}else d="detached media";if(!n){if(l)n=this.detachedData,this.log(`using detachedData: MediaSource ${qt(n)}`);else if(!this.detachedData||r.media===t){const y=this.playerQueue;y.length>1&&y.forEach(v=>{if(o&&v.interstitial.appendInPlace!==u){const _=v.interstitial;this.clearInterstitial(v.interstitial,null),_.appendInPlace=!1,_.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${_}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}}const h=n&&"mediaSource"in n&&((s=n.mediaSource)==null?void 0:s.readyState)!=="closed",g=h&&n?n:t;if(this.log(`${h?"transfering MediaSource":"attaching media"} to ${o?e:"Primary"} from ${d}`),g===n){const y=o&&e.assetId===this.schedule.assetIdAtEnd;g.overrides={duration:this.schedule.duration,endOfStream:!o||y,cueRemoval:!o}}e.attachMedia(g)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const e=this.schedule,t=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.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)}}advanceAfterAssetEnded(e,t,i){const s=i+1;if(!e.isAssetPastPlayoutLimit(s)&&!e.assetList[s].error)this.setSchedulePosition(t,s);else{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.timelinePos=u,this.checkBuffer()),this.setSchedulePosition(r)}}}setScheduleToAssetAtTime(e,t){const i=this.schedule,s=t.parentIdentifier,n=i.getEvent(s);if(n){const r=i.findEventIndex(s),o=i.findAssetIndex(n,e);this.setSchedulePosition(r,o)}}setSchedulePosition(e,t){const i=this.schedule.items;if(!i||this.playbackDisabled)return;this.log(`setSchedulePosition ${e}, ${t}`);const s=e>=0?i[e]:null,n=this.playingItem,r=this.playingLastItem;if(this.isInterstitial(n)){var o;const l=n.event,d=this.playingAsset,h=d==null?void 0:d.identifier,g=h?this.getAssetPlayer(h):null;if(g&&h&&(!this.eventItemsMatch(n,s)||t!==void 0&&h!==((o=l.assetList)==null?void 0:o[t].identifier))){var u;const y=l.findAssetIndex(d);this.log(`INTERSTITIAL_ASSET_ENDED ${y+1}/${l.assetList.length} ${oa(d)}`),this.endedAsset=d,this.playingAsset=null,this.hls.trigger(m.INTERSTITIAL_ASSET_ENDED,{asset:d,assetListIndex:y,event:l,schedule:i.slice(0),scheduleIndex:e,player:g}),this.retreiveMediaSource(h,s),g.media&&!((u=this.detachedData)!=null&&u.mediaSource)&&g.detachMedia()}if(!this.eventItemsMatch(n,s)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${l} ${pn(n)}`),l.hasPlayed=!0,this.hls.trigger(m.INTERSTITIAL_ENDED,{event:l,schedule:i.slice(0),scheduleIndex:e}),l.cue.once)){this.updateSchedule();const y=this.schedule.items;if(s&&y){const v=this.schedule.findItemIndex(s);this.advanceSchedule(v,y,t,n,r)}return}}this.advanceSchedule(e,i,t,n,r)}advanceSchedule(e,t,i,s,n){const r=e>=0?t[e]:null,o=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(l=>{const d=l.interstitial,h=this.schedule.findEventIndex(d.identifier);(h<e||h>e+1)&&this.clearInterstitial(d,r)}),this.isInterstitial(r)){this.timelinePos=Math.min(Math.max(this.timelinePos,r.start),r.end);const l=r.event;i===void 0&&(i=this.schedule.findAssetIndex(l,this.timelinePos));const d=this.waitingItem;this.assetsBuffered(r,o)||this.setBufferingItem(r);let h=this.preloadAssets(l,i);if(this.eventItemsMatch(r,d||s)||(this.waitingItem=r,this.log(`INTERSTITIAL_STARTED ${pn(r)} ${l.appendInPlace?"append in place":""}`),this.hls.trigger(m.INTERSTITIAL_STARTED,{event:l,schedule:t.slice(0),scheduleIndex:e})),!l.assetListLoaded){this.log(`Waiting for ASSET-LIST to complete loading ${l}`);return}if(l.assetListLoader&&(l.assetListLoader.destroy(),l.assetListLoader=void 0),!o){this.log(`Waiting for attachMedia to start Interstitial ${l}`);return}this.waitingItem=this.endedItem=null,this.playingItem=r;const g=l.assetList[i];if(!g){const y=t[e+1],v=this.media;y&&v&&!this.isInterstitial(y)&&v.currentTime<y.start&&(v.currentTime=this.timelinePos=y.start),this.advanceAfterAssetEnded(l,e,i||0);return}if(h||(h=this.getAssetPlayer(g.identifier)),h===null||h.destroyed){const y=l.assetList.length;this.warn(`asset ${i+1}/${y} player destroyed ${l}`),h=this.createAssetPlayer(l,g,i)}if(!this.eventItemsMatch(r,this.bufferingItem)&&l.appendInPlace&&this.isAssetBuffered(g))return;this.startAssetPlayer(h,i,t,e,o),this.shouldPlay&&mo(h.media)}else r!==null?(this.resumePrimary(r,e,s),this.shouldPlay&&mo(this.hls.media)):n&&this.isInterstitial(s)&&(this.endedItem=null,this.playingItem=s,s.event.appendInPlace||this.attachPrimary(this.schedule.durations.primary,null))}get playbackDisabled(){return this.hls.config.enableInterstitialPlayback===!1}get primaryDetails(){var e,t;return(e=this.mediaSelection)==null||(t=e.main)==null?void 0:t.details}get primaryLive(){var e;return!!((e=this.primaryDetails)!=null&&e.live)}resumePrimary(e,t,i){var s;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${pn(e)}`),!((s=this.detachedData)!=null&&s.mediaSource)){let r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.timelinePos=r),this.attachPrimary(r,e)}if(!i)return;const n=this.schedule.items;n&&(this.log(`resumed ${pn(e)}`),this.hls.trigger(m.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.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:Ft.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.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(){this.stopLoad(),this.schedule.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(m.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(m.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(e,t){if(t.level===-1)return;const i=this.hls.levels[t.level],s=j(j({},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=j(j({},this.altSelection),{},{audio:i});return}const n=j(j({},s),{},{audio:i});this.mediaSelection=n}onSubtitleTrackUpdated(e,t){const i=this.hls.subtitleTracks[t.id],s=this.mediaSelection;if(!s){this.altSelection=j(j({},this.altSelection),{},{subtitles:i});return}const n=j(j({},s),{},{subtitles:i});this.mediaSelection=n}onAudioTrackSwitching(e,t){const i=se(t);this.playerQueue.forEach(s=>s.hls.setAudioOption(t)||s.hls.setAudioOption(i))}onSubtitleTrackSwitch(e,t){const i=se(t);this.playerQueue.forEach(s=>s.hls.setSubtitleOption(t)||t.id!==-1&&s.hls.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){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){const i=this.schedule.items;if(e&&i){const s=this.findItemIndex(e,t);return i[s]||null}return null}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.findItemIndex(e,t):-1}updateSchedule(){const e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[])}checkBuffer(e){const t=this.schedule.items;if(!t)return;const i=Ft.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,t,e)}updateBufferedPos(e,t,i){const s=this.schedule,n=this.bufferingItem;if(this.bufferedPos>e)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,d;const h=this.findItemIndex(n),g=Math.min(h+1,t.length-1),y=t[g];if((u===-1&&n&&e>=n.end||(l=y.event)!=null&&l.appendInPlace&&e+.01>=y.start)&&(u=g),g-o>1&&(n==null||(d=n.event)==null?void 0:d.appendInPlace)===!1)return;if(this.bufferedPos=e,u>h&&u>o)this.bufferedToItem(y);else{const v=this.primaryDetails;this.primaryLive&&v&&e>v.edge-v.targetduration&&y.start<v.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(y)&&this.preloadAssets(y.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))this.bufferingItem!==e&&(this.bufferingItem=e);else{const{items:s,events:n}=i;if(!s||!n)return t;const r=this.isInterstitial(e),o=this.getBufferingPlayer();if(this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos)),!this.playbackDisabled){const u=o?o.remaining:t?t.end-this.timelinePos:0;this.log(`buffered to boundary ${pn(e)}`+(t?` (${u.toFixed(2)} remaining)`:"")),r?e.event.assetList.forEach(l=>{const d=this.getAssetPlayer(l.identifier);d&&d.resumeBuffering()}):(this.hls.resumeBuffering(),this.playerQueue.forEach(l=>l.pauseBuffering()))}this.hls.trigger(m.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:s.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}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=i.assetList[t],u=this.primaryMedia;o&&u&&this.bufferAssetPlayer(r,u)}}}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 g=this.playingItem;!this.isInterstitial(g)&&(g==null||(o=g.nextEvent)==null?void 0:o.identifier)===e.identifier&&this.flushFrontBuffer(u+.25)}let l,d=0;if(!this.playingItem&&this.primaryLive&&(d=this.hls.startPosition,d===-1&&(d=this.hls.liveSyncPosition||0)),d&&!(e.cue.pre||e.cue.post)){const g=d-u;g>0&&(l=Math.round(g*1e3)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:s} ${e}${l?` live-start: ${d} 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 u=t;u<s;u++){const l=e.assetList[u],d=this.getAssetPlayerQueueIndex(l.identifier);(d===-1||this.playerQueue[d].destroyed)&&!l.error&&this.createAssetPlayer(e,l,u)}return this.getAssetPlayer(e.assetList[t].identifier)}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(m.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:$u(e,r,t),duration:n,startOffset:i,timelineStart:s,uri:r};return this.createAssetPlayer(e,o,t)}createAssetPlayer(e,t,i){this.log(`create HLSAssetPlayer for ${oa(t)}`);const s=this.hls,n=s.userConfig;let r=n.videoPreference;const o=s.loadLevelObj||s.levels[s.currentLevel];(r||o)&&(r=ce({},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 d=0;if(this.primaryLive||e.appendInPlace){const M=this.timelinePos-t.timelineStart;if(M>1){const te=t.duration;te&&M<te&&(d=M)}}const h=t.identifier,g=j(j({},n),{},{autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:s.sessionId,assetPlayerId:h,abrEwmaDefaultEstimate:s.bandwidthEstimate,interstitialsController:void 0,startPosition:d,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:r,audioPreference:u||n.audioPreference,subtitlePreference:l||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(g.timelineOffset=t.timelineStart));const y=g.cmcd;y!=null&&y.sessionId&&y.contentId&&(g.cmcd=ce({},y,{contentId:tr(t.uri)})),this.getAssetPlayer(h)&&this.warn(`Duplicate date range identifier ${e} and asset ${h}`);const v=new Vu(this.HlsPlayerClass,g,e,t);this.playerQueue.push(v),e.assetList[i]=t;const _=M=>{if(M.live){const be=new Error(`Interstitials MUST be VOD assets ${e}`),re={fatal:!0,type:z.OTHER_ERROR,details:A.INTERSTITIAL_ASSET_ITEM_ERROR,error:be};this.handleAssetItemError(re,e,this.schedule.findEventIndex(e.identifier),i,be.message);return}const te=M.edge-M.fragmentStart,ne=t.duration;(ne===null||te>ne)&&(this.log(`Interstitial asset "${h}" duration change ${ne} > ${te}`),t.duration=te,this.updateSchedule())};v.on(m.LEVEL_UPDATED,(M,{details:te})=>_(te)),v.on(m.LEVEL_PTS_UPDATED,(M,{details:te})=>_(te));const b=(M,te)=>{const ne=this.getAssetPlayer(h);if(ne&&te.tracks){ne.off(m.BUFFER_CODECS,b),ne.tracks=te.tracks;const be=this.primaryMedia;this.bufferingAsset===ne.assetItem&&be&&!ne.media&&this.bufferAssetPlayer(ne,be)}};v.on(m.BUFFER_CODECS,b);const L=()=>{var M;const te=this.getAssetPlayer(h);if(this.log(`buffered to end of asset ${te}`),!te)return;const ne=this.schedule.findEventIndex(e.identifier),be=e.findAssetIndex(t),re=be+1,ye=(M=this.schedule.items)==null?void 0:M[ne];if(this.isInterstitial(ye))if(be!==-1&&!e.isAssetPastPlayoutLimit(re)&&!e.assetList[re].error)this.bufferedToItem(ye,re);else{var Te;const ue=(Te=this.schedule.items)==null?void 0:Te[ne+1];ue&&this.bufferedToItem(ue)}};v.on(m.BUFFERED_TO_END,L);const U=M=>()=>{if(!this.getAssetPlayer(h))return;this.shouldPlay=!0;const ne=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,ne,M)};return v.once(m.MEDIA_ENDED,U(i)),v.once(m.PLAYOUT_LIMIT_REACHED,U(1/0)),v.on(m.ERROR,(M,te)=>{const ne=this.getAssetPlayer(h);if(te.details===A.BUFFER_STALLED_ERROR){if(ne!=null&&ne.media){const be=ne.currentTime,re=ne.duration-be;be&&e.appendInPlace&&re/ne.media.playbackRate<.5?(this.log(`Advancing buffer past end of asset ${h} ${e} at ${ne.media.currentTime}`),L()):(this.warn(`Stalled at ${be} of ${be+re} in asset ${h} ${e}`),this.onTimeupdate(),this.checkBuffer(!0))}return}this.handleAssetItemError(te,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${te.error} ${e}`)}),v.on(m.DESTROYING,()=>{if(!this.getAssetPlayer(h))return;const te=new Error(`Asset player destroyed unexpectedly ${h}`),ne={fatal:!0,type:z.OTHER_ERROR,details:A.INTERSTITIAL_ASSET_ITEM_ERROR,error:te};this.handleAssetItemError(ne,e,this.schedule.findEventIndex(e.identifier),i,te.message)}),this.hls.trigger(m.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:v}),v}clearInterstitial(e,t){e.assetList.forEach(i=>{this.clearAssetPlayer(i.identifier,t)}),e.reset()}clearAssetPlayer(e,t){const i=this.getAssetPlayerQueueIndex(e);if(i!==-1){this.log(`clearAssetPlayer "${e}" toSegment: ${t&&pn(t)}`);const s=this.playerQueue[i];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,d=this.playingAsset;this.endedAsset=null,this.playingAsset=o,(!d||d.identifier!==u)&&(d&&(this.clearAssetPlayer(d.identifier,i[s]),delete d.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${l} ${e}`),this.hls.trigger(m.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;const{interstitial:n,assetItem:r,assetId:o}=e,u=this.schedule.findEventIndex(n.identifier),l=(i=this.schedule.items)==null?void 0:i[u];if(!l)return;this.setBufferingItem(l),this.bufferingAsset=r;const d=this.getBufferingPlayer();if(d===e)return;const h=n.appendInPlace;if(h&&(d==null?void 0:d.interstitial.appendInPlace)===!1)return;const g=(d==null?void 0:d.tracks)||((s=this.detachedData)==null?void 0:s.tracks)||this.requiredTracks;if(h&&r!==this.playingAsset){if(!e.tracks)return;if(g&&!Qe(g,e.tracks)){const y=new Error(`Asset "${o}" SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(g)}')`),v={fatal:!0,type:z.OTHER_ERROR,details:A.INTERSTITIAL_ASSET_ITEM_ERROR,error:y},_=n.findAssetIndex(r);this.handleAssetItemError(v,n,u,_,y.message);return}}this.transferMediaTo(e,t)}handleAssetItemError(e,t,i,s,n){if(e.details===A.BUFFER_STALLED_ERROR)return;const r=t.assetList[s]||null;let o=null;if(r){const h=this.getAssetPlayerQueueIndex(r.identifier);o=this.playerQueue[h]||null}const u=this.schedule.items,l=ce({},e,{fatal:!1,errorAction:Bi(!0),asset:r,assetListIndex:s,event:t,schedule:u,scheduleIndex:i,player:o});if(this.warn(`Asset item error: ${e.error}`),this.hls.trigger(m.INTERSTITIAL_ASSET_ERROR,l),!e.fatal)return;const d=new Error(n);r&&(this.playingAsset!==r&&this.clearAssetPlayer(r.identifier,null),r.error=d),t.assetList.some(h=>!h.error)?t.appendInPlace&&(t.error=d):t.error=d,this.primaryFallback(t)}primaryFallback(e){const t=e.timelineStart,i=this.effectivePlayingItem;if(this.updateSchedule(),i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${this.timelinePos} playing: ${i?pn(i):"<none>"} error: ${e.error}`),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t));let s=this.timelinePos;s===-1&&(s=this.hls.startPosition);const n=this.updateItem(i,s);if(this.itemsMatch(i,n))this.clearInterstitial(e,null);else{const r=this.schedule.findItemIndexAtTime(s);this.setSchedulePosition(r)}}else this.checkStart()}onAssetListLoaded(e,t){var i;const s=t.event,n=s.identifier,r=t.assetListResponse.ASSETS;if(!this.schedule.hasEvent(n))return;const o=s.timelineStart,u=s.duration;let l=0;r.forEach((v,_)=>{const b=parseFloat(v.DURATION);this.createAsset(s,_,l,o+l,b,v.URI),l+=b}),s.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${u}) ${s}`);const d=this.waitingItem,h=(d==null?void 0:d.event.identifier)===n;this.updateSchedule();const g=(i=this.bufferingItem)==null?void 0:i.event;if(h){var y;const v=this.schedule.findEventIndex(n),_=(y=this.schedule.items)==null?void 0:y[v];if(_){if(!this.playingItem&&this.timelinePos>_.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==v){s.error=new Error(`Interstitial no longer within playback range ${this.timelinePos} ${s}`),this.primaryFallback(s);return}this.setBufferingItem(_)}this.setSchedulePosition(v)}else if((g==null?void 0:g.identifier)===n&&g.appendInPlace){const v=s.assetList[0],_=this.getAssetPlayer(v.identifier),b=this.primaryMedia;v&&_&&b&&this.bufferAssetPlayer(_,b)}}onError(e,t){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.primaryFallback(i);break}case A.BUFFER_STALLED_ERROR:{this.onTimeupdate(),this.checkBuffer(!0);break}}}}const go=500;class zu extends bn{constructor(e,t,i){super(e,t,i,"subtitle-stream-controller",H.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(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(m.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(m.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(m.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(m.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(e,t){this.stopLoad(),this.state=Ie.IDLE,this.setInterval(go),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(Be(i)&&(this.fragPrevious=i),this.state=Ie.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,H.SUBTITLE)}}onError(e,t){const i=t.frag;(i==null?void 0:i.type)===H.SUBTITLE&&(t.details===A.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Ie.STOPPED&&(this.state=Ie.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Xa(this.levels,t)){this.levels=t.map(i=>new Ke(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const s=new Ke(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,H.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!==Ie.STOPPED&&this.setInterval(go)}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){const h=this.mainDetails;if(r.deltaUpdateFailed||!h)return;const g=h.fragments[0];if(!u.details)r.hasProgramDateTime&&h.hasProgramDateTime?(ds(r,h),l=r.fragmentStart):g&&(l=g.start,jn(r,l));else{var d;l=this.alignPlaylists(r,u.details,(d=this.levelLastLoaded)==null?void 0:d.details),l===0&&g&&(l=g.start,jn(r,l))}}u.details=r,this.levelLastLoaded=u,o===s&&(this.hls.trigger(m.SUBTITLE_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===Ie.IDLE&&(Bt(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&&ps(s.method)){const r=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer,ts(s.method)).catch(o=>{throw n.trigger(m.ERROR,{type:z.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(m.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:r,tdecrypt:u}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=Ie.IDLE})}}doTick(){if(!this.media){this.state=Ie.IDLE;return}if(this.state===Ie.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=Ft.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:u}=r,l=i.details,d=this.hls.maxBufferLength+l.levelTargetDuration;if(u>d)return;const h=l.fragments,g=h.length,y=l.edge;let v=null;const _=this.fragPrevious;if(o<y){const U=s.maxFragLookUpTolerance,M=o>y-U?0:U;v=Bt(_,h,Math.max(h[0].start,o),M),!v&&_&&_.start<h[0].start&&(v=h[0])}else v=h[g-1];if(v=this.filterReplacedPrimary(v,i.details),!v)return;const b=v.sn-l.startSN,L=h[b-1];if(L&&L.cc===v.cc&&this.fragmentTracker.getState(L)===ni.NOT_LOADED&&(v=L),this.fragmentTracker.getState(v)===ni.NOT_LOADED){const U=this.mapToInitFragWhenRequired(v);U&&this.loadFragment(U,i,o)}}}loadFragment(e,t,i){Be(e)?super.loadFragment(e,t,i):this._loadInitSegment(e,t)}get mediaBufferTimeRanges(){return new Wu(this.tracksBuffered[this.currentTrackId]||[])}}class Wu{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 Zu={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},po=a=>String.fromCharCode(Zu[a]||a),Xs=15,hn=100,Yu={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Xu={17:2,18:4,21:6,22:8,23:10,19:13,20:15},qu={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Qu={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ju=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class ec{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;Z.log(`${this.time} [${e}] ${i}`)}}}const xn=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class vo{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 tc{constructor(){this.uchar=" ",this.penState=new vo}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 ic{constructor(e){this.chars=[],this.pos=0,this.currPenState=new vo,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<hn;t++)this.chars.push(new tc);this.logger=e}equals(e){for(let t=0;t<hn;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<hn;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<hn;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>hn&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=hn)}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=po(e);if(this.pos>=hn){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<hn;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<hn;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 la{constructor(e){this.rows=[],this.currRow=Xs-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Xs;t++)this.rows.push(new ic(e));this.logger=e}reset(){for(let e=0;e<Xs;e++)this.rows[e].clear();this.currRow=Xs-1}equals(e){let t=!0;for(let i=0;i<Xs;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<Xs;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Xs;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 = "+qt(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<Xs;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 = "+qt(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<Xs;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 la(i),this.nonDisplayedMemory=new la(i),this.lastOutputScreen=new la(i),this.currRollUpRow=this.displayedMemory.rows[Xs-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[Xs-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: "+qt(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 Eo{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=nc(),this.logger=void 0;const s=this.logger=new ec;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,()=>"["+xn([t[i],t[i+1]])+"] -> ("+xn([s,n])+")");const u=this.cmdHistory;if(s>=16&&s<=31){if(sc(s,n,u)){Ar(null,null,u),this.logger.log(3,()=>"Repeated command ("+xn([s,n])+") is dropped");continue}Ar(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 Ar(null,null,u);if(!r&&(o=this.parseChars(s,n),o)){const d=this.currentChannel;d&&d>0?this.channels[d].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!r&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+xn([s,n])+" orig: "+xn([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 ("+xn([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?Yu[e]:qu[e]:i=r===1?Xu[e]:Qu[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 '"+po(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 = "+xn(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=Ju[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()}Ar(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 Ar(a,e,t){t.a=a,t.b=e}function sc(a,e,t){return t.a===a&&t.b===e}function nc(){return{a:null,b:null}}var ua=function(){if(Qi!=null&&Qi.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 d=arguments[l];for(const h in d)o[h]=d[h]}return o}function r(o,u,l){const d=this,h={enumerable:!0};d.hasBeenReset=!1;let g="",y=!1,v=o,_=u,b=l,L=null,U="",M=!0,te="auto",ne="start",be=50,re="middle",ye=50,Te="middle";Object.defineProperty(d,"id",n({},h,{get:function(){return g},set:function(ue){g=""+ue}})),Object.defineProperty(d,"pauseOnExit",n({},h,{get:function(){return y},set:function(ue){y=!!ue}})),Object.defineProperty(d,"startTime",n({},h,{get:function(){return v},set:function(ue){if(typeof ue!="number")throw new TypeError("Start time must be set to a number.");v=ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",n({},h,{get:function(){return _},set:function(ue){if(typeof ue!="number")throw new TypeError("End time must be set to a number.");_=ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",n({},h,{get:function(){return b},set:function(ue){b=""+ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",n({},h,{get:function(){return L},set:function(ue){L=ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",n({},h,{get:function(){return U},set:function(ue){const Xe=i(ue);if(Xe===!1)throw new SyntaxError("An invalid or illegal string was specified.");U=Xe,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",n({},h,{get:function(){return M},set:function(ue){M=!!ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",n({},h,{get:function(){return te},set:function(ue){if(typeof ue!="number"&&ue!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");te=ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",n({},h,{get:function(){return ne},set:function(ue){const Xe=s(ue);if(!Xe)throw new SyntaxError("An invalid or illegal string was specified.");ne=Xe,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",n({},h,{get:function(){return be},set:function(ue){if(ue<0||ue>100)throw new Error("Position must be between 0 and 100.");be=ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",n({},h,{get:function(){return re},set:function(ue){const Xe=s(ue);if(!Xe)throw new SyntaxError("An invalid or illegal string was specified.");re=Xe,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",n({},h,{get:function(){return ye},set:function(ue){if(ue<0||ue>100)throw new Error("Size must be between 0 and 100.");ye=ue,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",n({},h,{get:function(){return Te},set:function(ue){const Xe=s(ue);if(!Xe)throw new SyntaxError("An invalid or illegal string was specified.");Te=Xe,this.hasBeenReset=!0}})),d.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}();class rc{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function _o(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 ac{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 So(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 ca=new ua(0,0,""),Rr=ca.align==="middle"?"middle":"center";function oc(a,e,t){const i=a;function s(){const o=_o(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 ac;So(o,function(g,y){let v;switch(g){case"region":for(let _=t.length-1;_>=0;_--)if(t[_].id===y){l.set(g,t[_].region);break}break;case"vertical":l.alt(g,y,["rl","lr"]);break;case"line":v=y.split(","),l.integer(g,v[0]),l.percent(g,v[0])&&l.set("snapToLines",!1),l.alt(g,v[0],["auto"]),v.length===2&&l.alt("lineAlign",v[1],["start",Rr,"end"]);break;case"position":v=y.split(","),l.percent(g,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",Rr,"end","line-left","line-right","auto"]);break;case"size":l.percent(g,y);break;case"align":l.alt(g,y,["start",Rr,"end","left","right"]);break}},/:/,/\s/),u.region=l.get("region",null),u.vertical=l.get("vertical","");let d=l.get("line","auto");d==="auto"&&ca.line===-1&&(d=-1),u.line=d,u.lineAlign=l.get("lineAlign","start"),u.snapToLines=l.get("snapToLines",!0),u.size=l.get("size",100),u.align=l.get("align",Rr);let h=l.get("position","auto");h==="auto"&&ca.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 bo(a){return a.replace(/<br(?: \/)?>/gi,`
|
|
`)}class lc{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new rc,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=bo(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){So(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 ua(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{oc(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 uc=/\r\n|\n\r|\n|\r/g,da=function(e,t,i=0){return e.slice(i,i+t.length)===t},cc=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(!S(t)||!S(i)||!S(s)||!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 ha(a,e,t){return tr(a.toString())+tr(e.toString())+tr(t)}const dc=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 hc(a,e,t,i,s,n,r){const o=new lc,u=xe(new Uint8Array(a)).trim().replace(uc,`
|
|
`).split(`
|
|
`),l=[],d=e?Bl(e.baseTime,e.timescale):0;let h="00:00.000",g=0,y=0,v,_=!0;o.oncue=function(b){const L=t[i];let U=t.ccOffset;const M=(g-d)/9e4;if(L!=null&&L.new&&(y!==void 0?U=t.ccOffset=L.start:dc(t,i,M)),M){if(!e){v=new Error("Missing initPTS for VTT MPEGTS");return}U=M-t.presentationOffset}const te=b.endTime-b.startTime,ne=$s((b.startTime+U-y)*9e4,s*9e4)/9e4;b.startTime=Math.max(ne,0),b.endTime=Math.max(ne+te,0);const be=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(be)),b.id||(b.id=ha(b.startTime,b.endTime,be)),b.endTime>0&&l.push(b)},o.onparsingerror=function(b){v=b},o.onflush=function(){if(v){r(v);return}n(l)},u.forEach(b=>{if(_)if(da(b,"X-TIMESTAMP-MAP=")){_=!1,b.slice(16).split(",").forEach(L=>{da(L,"LOCAL:")?h=L.slice(6):da(L,"MPEGTS:")&&(g=parseInt(L.slice(7)))});try{y=cc(h)/1e3}catch(L){v=L}return}else b===""&&(_=!1);o.parse(b+`
|
|
`)}),o.flush()}const fa="stpp.ttml.im1t",xo=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,To=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,fc={left:"start",center:"center",right:"end",start:"start",end:"end"};function Ao(a,e,t,i){const s=C(new Uint8Array(a),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const n=s.map(o=>xe(o)),r=Ml(e.baseTime,1,e.timescale);try{n.forEach(o=>t(mc(o,r)))}catch(o){i(o)}}function mc(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,g)=>(h[g]=s.getAttribute(`ttp:${g}`)||n[g],h),{}),o=s.getAttribute("xml:space")!=="preserve",u=Ro(ma(s,"styling","style")),l=Ro(ma(s,"layout","region")),d=ma(s,"body","[begin]");return[].map.call(d,h=>{const g=Lo(h,o);if(!g||!h.hasAttribute("begin"))return null;const y=pa(h.getAttribute("begin"),r),v=pa(h.getAttribute("dur"),r);let _=pa(h.getAttribute("end"),r);if(y===null)throw Io(h);if(_===null){if(v===null)throw Io(h);_=y+v}const b=new ua(y-e,_-e,g);b.id=ha(b.startTime,b.endTime,b.text);const L=l[h.getAttribute("region")],U=u[h.getAttribute("style")],M=gc(L,U,u),{textAlign:te}=M;if(te){const ne=fc[te];ne&&(b.lineAlign=ne),b.align=te}return ce(b,M),b}).filter(h=>h!==null)}function ma(a,e,t){const i=a.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function Ro(a){return a.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Lo(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?Lo(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function gc(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=ga(e,i,u)||ga(a,i,u)||ga(s,i,u);return l&&(o[u]=l),o},{})}function ga(a,e,t){return a&&a.hasAttributeNS(e,t)?a.getAttributeNS(e,t):null}function Io(a){return new Error(`Could not parse ttml timestamp ${a}`)}function pa(a,e){if(!a)return null;let t=_o(a);return t===null&&(xo.test(a)?t=pc(a,e):To.test(a)&&(t=vc(a,e))),t}function pc(a,e){const t=xo.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 vc(a,e){const t=To.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 Lr{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 yc{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=wo(),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(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(m.FRAG_LOADING,this.onFragLoading,this),e.on(m.FRAG_LOADED,this.onFragLoaded,this),e.on(m.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(m.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(m.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(m.FRAG_LOADING,this.onFragLoading,this),e.off(m.FRAG_LOADED,this.onFragLoaded,this),e.off(m.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(m.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(m.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(m.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const e=new Lr(this,"textTrack1"),t=new Lr(this,"textTrack2"),i=new Lr(this,"textTrack3"),s=new Lr(this,"textTrack4");this.cea608Parser1=new Eo(1,e,t),this.cea608Parser2=new Eo(3,i,s)}addCues(e,t,i,s,n){let r=!1;for(let o=n.length;o--;){const u=n[o],l=Ec(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(m.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:s,timescale:n}){const{unparsedVttFrags:r}=this;i===H.MAIN&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),r.length&&(this.unparsedVttFrags=[],r.forEach(o=>{this.onFragLoaded(m.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:i}=this;if(i)for(let s=0;s<i.textTracks.length;s++){const n=i.textTracks[s];if(Do(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,Fn(i[e]),uo(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(m.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=>{Fn(s[n]),delete s[n]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=wo(),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++)Fn(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],s=i.some(n=>n.textCodec===fa);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Xa(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const r=this.media,o=r?xr(r.textTracks):null;if(this.tracks.forEach((u,l)=>{let d;if(o){let h=null;for(let g=0;g<o.length;g++)if(o[g]&&Do(o[g],u)){h=o[g],o[g]=null;break}h&&(d=h)}if(d)Fn(d);else{const h=Co(u);d=this.createTextTrack(h,u.name,u.lang),d&&(d.mode="disabled")}d&&this.textTracks.push(d)}),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(m.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===H.MAIN){var i,s;const{cea608Parser1:n,cea608Parser2:r,lastSn:o}=this,{cc:u,sn:l}=t.frag,d=(i=(s=t.part)==null?void 0:s.index)!=null?i:-1;n&&r&&(l!==o+1||l===o&&d!==this.lastPartIndex+1||u!==this.lastCc)&&(n.reset(),r.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=d}}onFragLoaded(e,t){const{frag:i,payload:s}=t;if(i.type===H.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===fa?this._parseIMSC1(i,s):this._parseVTTs(t)}}else this.hls.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;Ao(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),i.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{i.logger.log(`Failed to parse IMSC1: ${s}`),i.trigger(m.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?st(i.initSegment.data,new Uint8Array(s)).buffer:s;hc(l,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,d=>{this._appendCues(d,i.level),u.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},d=>{const h=d.message==="Missing initPTS for VTT MPEGTS";h?r.push(e):this._fallbackToIMSC1(i,s),u.logger.log(`Failed to parse VTT cue: ${d}`),!(h&&o>i.cc)&&u.trigger(m.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:d})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||Ao(t,this.initPTS[e.cc],()=>{i.textCodec=fa,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=>co(s,n))}else{const s=this.tracks[t];if(!s)return;const n=s.default?"default":"subtitles"+t;i.trigger(m.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===H.SUBTITLE&&this.onFragLoaded(m.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===H.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=>ra(o[u],t,i))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(u=>ra(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 d=3&r;(d===0||d===1)&&(t[d].push(o),t[d].push(u))}}return t}}function Co(a){return a.characteristics&&/transcribes-spoken-dialog/gi.test(a.characteristics)&&/describes-music-and-sound/gi.test(a.characteristics)?"captions":"subtitles"}function Do(a,e){return!!a&&a.kind===Co(e)&&Jr(e,a)}function Ec(a,e,t,i){return Math.min(e,i)-Math.max(a,t)}function wo(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}const _c=/\s/,Sc={newCue(a,e,t,i){const s=[];let n,r,o,u,l;const d=self.VTTCue||self.TextTrackCue;for(let g=0;g<i.rows.length;g++)if(n=i.rows[g],o=!0,u=0,l="",!n.isEmpty()){var h;for(let _=0;_<n.chars.length;_++)_c.test(n.chars[_].uchar)&&o?u++:(l+=n.chars[_].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),u>=16?u--:u++;const y=bo(l.trim()),v=ha(e,t,y);a!=null&&(h=a.cues)!=null&&h.getCueById(v)||(r=new d(e,t,y),r.id=v,r.line=g+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((g,y)=>g.line==="auto"||y.line==="auto"?0:g.line>8&&y.line>8?y.line-g.line:g.line-y.line),s.forEach(g=>co(a,g))),s}};function bc(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(a){}return!1}const xc=/(\d+)-(\d+)\/(\d+)/;class ko{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||Lc,this.controller=new self.AbortController,this.stats=new Ee}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=Tc(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&&S(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(s,e,this.response))},t.timeout),(Qn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(h=>{var g;this.response=this.loader=h;const y=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-(y-s.loading.start)),!h.ok){const{status:_,statusText:b}=h;throw new Ic(b||"fetch, bad network response",_,h)}s.loading.first=y,s.total=Rc(h.headers)||s.total;const v=(g=this.callbacks)==null?void 0:g.onProgress;return v&&S(t.highWaterMark)?this.loadProgressively(h,s,e,t.highWaterMark,v):r?h.arrayBuffer():e.responseType==="json"?h.json():h.text()}).then(h=>{var g,y;const v=this.response;if(!v)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const _=h[o];_&&(s.loaded=s.total=_);const b={url:v.url,data:h,code:v.status},L=(g=this.callbacks)==null?void 0:g.onProgress;L&&!S(t.highWaterMark)&&L(s,e,h,v),(y=this.callbacks)==null||y.onSuccess(b,s,e,v)}).catch(h=>{var g;if(self.clearTimeout(this.requestTimeout),s.aborted)return;const y=h&&h.code||0,v=h?h.message:null;(g=this.callbacks)==null||g.onError({code:y,text:v},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 Wn,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 d=l.value,h=d.length;return t.loaded+=h,h<s||r.dataLength?(r.push(d),r.dataLength>=s&&n(t,i,r.flush().buffer,e)):n(t,i,d.buffer,e),u()}).catch(()=>Promise.reject());return u()}}function Tc(a,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ce({},a.headers))};return a.rangeEnd&&t.headers.set("Range","bytes="+a.rangeStart+"-"+String(a.rangeEnd-1)),t}function Ac(a){const e=xc.exec(a);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Rc(a){const e=a.get("Content-Range");if(e){const i=Ac(e);if(S(i))return i}const t=a.get("Content-Length");if(t)return parseInt(t)}function Lc(a,e){return new self.Request(a.url,e)}class Ic extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const Cc=/^age:\s*[\d.]+\s*$/im;class Oo{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 Ee,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&&S(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,d=t.responseType==="text"?t.responseText:null;if(l>=200&&l<300){const v=d!=null?d:t.response;if(v!=null){var r,o;i.loading.end=Math.max(self.performance.now(),i.loading.first);const _=t.responseType==="arraybuffer"?v.byteLength:v.length;i.loaded=i.total=_,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);const b=(r=this.callbacks)==null?void 0:r.onProgress;b&&b(i,e,v,t);const L={url:t.responseURL,data:v,code:l};(o=this.callbacks)==null||o.onSuccess(L,i,e,t);return}}const h=n.loadPolicy.errorRetry,g=i.retry,y={url:e.url,data:void 0,code:l};if(Vi(h,g,!1,y))this.retry(h);else{var u;Z.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(Vi(e,t,!0))this.retry(e);else{var i;Z.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=oi(e,i.retry),i.retry++,Z.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&&Cc.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 Dc={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},wc=j(j({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,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:Oo,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:jt,bufferController:ql,capLevelController:ta,errorController:Zi,fpsController:Mu,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:Kt,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,certLoadPolicy:{default:Dc},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},kc()),{},{subtitleStreamController:zu,subtitleTrackController:Nu,timelineController:yc,audioStreamController:Wl,audioTrackController:Zl,emeController:Bn,cmcdController:ku,contentSteeringController:Pu,interstitialsController:ju});function kc(){return{cueHandler:Sc,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 Oc(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=va(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(d=>{const h=`${r}Loading${d}`,g=e[h];if(g!==void 0&&u){l.push(h);const y=i[o].default;switch(e[o]={default:y},d){case"TimeOut":y.maxLoadTimeMs=g,y.maxTimeToFirstByteMs=g;break;case"MaxRetry":y.errorRetry.maxNumRetry=g,y.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":y.errorRetry.retryDelayMs=g,y.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":y.errorRetry.maxRetryDelayMs=g,y.timeoutRetry.maxRetryDelayMs=g;break}}}),l.length&&t.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${qt(e[o])}`)}),j(j({},i),e)}function va(a){return a&&typeof a=="object"?Array.isArray(a)?a.map(va):Object.keys(a).reduce((e,t)=>(e[t]=va(a[t]),e),{}):a}function Pc(a,e){const t=a.loader;t!==ko&&t!==Oo?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),a.progressive=!1):bc()&&(a.loader=ko,a.progressive=!0,a.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}const Ir=2,Mc=.1,Bc=.05,Fc=100;class Nc extends Gi{constructor(e,t){super("gap-controller",e.logger),this.hls=null,this.fragmentTracker=null,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(m.MEDIA_ENDED,{stalled:!1})}},this.hls=e,this.fragmentTracker=t,this.registerListeners()}registerListeners(){const{hls:e}=this;e&&(e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.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(Fc),this.mediaSource=t.mediaSource;const i=this.media=t.media;dn(i,"playing",this.onMediaPlaying),dn(i,"waiting",this.onMediaWaiting),dn(i,"ended",this.onMediaEnded)}onMediaDetaching(e,t){this.clearInterval();const{media:i}=this;i&&(rn(i,"playing",this.onMediaPlaying),rn(i,"waiting",this.onMediaWaiting),rn(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{media:r,stalled:o}=this;if(!r)return;const{seeking:u}=r,l=this.seeking&&!u,d=!this.seeking&&u,h=r.paused&&!u||r.ended||r.playbackRate===0;if(this.seeking=u,e!==t){t&&(this.ended=0),this.moved=!0,u||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!h&&e>t&&this.nudgeOnVideoHole(e,t)),this.waiting===0&&this.stallResolved(e);return}if(d||l){l&&this.stallResolved(e);return}if(h){this.nudgeRetry=0,this.stallResolved(e),!this.ended&&r.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(m.MEDIA_ENDED,{stalled:!1}));return}if(!Ft.getBuffered(r).length){this.nudgeRetry=0;return}const g=Ft.bufferInfo(r,e,0),y=g.nextStart||0,v=this.fragmentTracker;if(u&&v&&this.hls){const be=Po(this.hls.inFlightFragments,e),re=g.len>Ir,ye=!y||be||y-e>Ir&&!v.getPartialFragment(e);if(re||ye)return;this.moved=!1}const _=(s=this.hls)==null?void 0:s.latestLevelDetails;if(!this.moved&&this.stalled!==null&&v){if(!(g.len>0)&&!y)return;const re=Math.max(y,g.start||0)-e,Te=!!(_!=null&&_.live)?_.targetduration*2:Ir,ue=v.getPartialFragment(e);if(re>0&&(re<=Te||ue)){r.paused||this._trySkipBufferHole(ue);return}}const b=n.detectStallWithCurrentTimeMs,L=self.performance.now(),U=this.waiting;if(o===null){U>0&&L-U<b?this.stalled=U:this.stalled=L;return}const M=L-o;if(!u&&(M>=b||U)&&this.hls){var te;if(((te=this.mediaSource)==null?void 0:te.readyState)==="ended"&&!(_!=null&&_.live)&&Math.abs(e-((_==null?void 0:_.edge)||0))<1){if(this.ended)return;this.ended=e||1,this.hls.trigger(m.MEDIA_ENDED,{stalled:!0});return}if(this._reportStall(g),!this.media||!this.hls)return}const ne=Ft.bufferInfo(r,e,n.maxBufferHole);this._tryFixBufferStall(ne,M)}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(m.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=Ft.bufferedInfo(Ft.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){const r=Ft.timeRangesToArray(s),o=Ft.bufferedInfo(r,t,0).bufferedIndex;if(o>-1&&o<r.length-1){const u=Ft.bufferedInfo(r,e,0).bufferedIndex,l=r[o].end,d=r[o+1].start;if((u===-1||u>o)&&d-l<1&&e-l<2){const h=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${l} -> ${d} buffered index: ${u}`);this.warn(h.message),this.media.currentTime+=1e-6;const g=this.fragmentTracker.getPartialFragment(e)||void 0,y=Ft.bufferInfo(this.media,e,0);this.hls.trigger(m.ERROR,{type:z.MEDIA_ERROR,details:A.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:g,buffer:y.len,bufferInfo:y})}}}}}_tryFixBufferStall(e,t){var i,s;const{fragmentTracker:n,media:r}=this,o=(i=this.hls)==null?void 0:i.config;if(!r||!n||!o)return;const u=r.currentTime,l=(s=this.hls)==null?void 0:s.latestLevelDetails,d=n.getPartialFragment(u);if((d||l!=null&&l.live&&u<l.fragmentStart)&&(this._trySkipBufferHole(d)||!this.media))return;const h=e.buffered;(h&&h.length>1&&e.len>o.maxBufferHole||e.nextStart&&e.nextStart-u<o.maxBufferHole)&&(t>o.highBufferWatchdogPeriod*1e3||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}_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 (${qt(e)})`);this.warn(r.message),t.trigger(m.ERROR,{type:z.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=Ft.bufferInfo(s,r,0),u=r<o.start?o.start:o.nextStart;if(u&&this.hls){const d=o.len<=n.maxBufferHole,h=o.len>0&&o.len<1&&s.readyState<3,g=u-r;if(g>0&&(d||h)){if(g>n.maxBufferHole){let v=!1;if(r===0){const _=i.getAppendedFrag(0,H.MAIN);_&&u<_.end&&(v=!0)}if(!v){const _=e||i.getAppendedFrag(r,H.MAIN);if(_){var l;if(!((l=this.hls.loadLevelObj)!=null&&l.details)||Po(this.hls.inFlightFragments,u))return 0;let L=!1,U=_.end;for(;U<u;){const M=i.getPartialFragment(U);if(M)U+=M.duration;else{L=!0;break}}if(L)return 0}}}const y=Math.max(u+Bc,r+Mc);if(this.warn(`skipping hole, adjusting currentTime from ${r} to ${y}`),this.moved=!0,s.currentTime=y,!(e!=null&&e.gap)){const v=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${y}`);this.hls.trigger(m.ERROR,{type:z.MEDIA_ERROR,details:A.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:v,reason:v.message,frag:e||void 0,buffer:o.len,bufferInfo:o})}return y}}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(m.ERROR,{type:z.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(m.ERROR,{type:z.MEDIA_ERROR,details:A.BUFFER_STALLED_ERROR,error:o,fatal:!0,buffer:e.len,bufferInfo:e})}}}function Po(a,e){const t=Mo(a.main);if(t&&t.start<=e)return t;const i=Mo(a.audio);return i&&i.start<=e?i:null}function Mo(a){if(!a)return null;switch(a.state){case Ie.IDLE:case Ie.STOPPED:case Ie.ENDED:case Ie.ERROR:return null}return a.frag}const $c=.25;function ya(){if(typeof self!="undefined")return self.VTTCue||self.TextTrackCue}function Bo(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,qt(s?j({type:s},i):i))}return n}const Cr=(()=>{const a=ya();try{a&&new a(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Uc(a){return Uint8Array.from(a.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Gc{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(m.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.on(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(m.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m.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(){const e=this.hls.latestLevelDetails;e&&this.updateDateRangeCues(e)}onMediaDetaching(e,t){this.media=null,!t.transferMedia&&(this.id3Track&&(this.removeCues&&Fn(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 uo(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const r=ya();if(r)for(let o=0;o<n.length;o++){const u=n[o].type;if(u===Os.emsg&&!i||!s)continue;const l=Ca(n[o].data);if(l){const d=n[o].pts;let h=d+n[o].duration;h>Cr&&(h=Cr),h-d<=0&&(h=d+$c);for(let y=0;y<l.length;y++){const v=l[y];if(!Da(v)){this.updateId3CueEnds(d,u);const _=Bo(r,d,h,v,u);_&&this.id3Track.addCue(_)}}}}}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===Cr&&(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=d=>d.type===Os.audioId3&&u:s==="video"?l=d=>d.type===Os.emsg&&o:l=d=>d.type===Os.audioId3&&u||d.type===Os.emsg&&o,ra(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.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{id3Track:i}=this,{dateRanges:s}=e,n=Object.keys(s);let r=this.dateRangeCuesAppended;if(i&&t){var o;if((o=i.cues)!=null&&o.length){const d=Object.keys(r).filter(h=>!n.includes(h));for(let h=d.length;h--;){const g=d[h],y=r[g].cues;delete r[g],Object.keys(y).forEach(v=>{try{const _=y[v];_.removeEventListener("enter",this.onEventCueEnter),i.removeCue(_)}catch(_){}})}}else r=this.dateRangeCuesAppended={}}const u=e.fragments[e.fragments.length-1];if(n.length===0||!S(u==null?void 0:u.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=ya();for(let d=0;d<n.length;d++){const h=n[d],g=s[h],y=g.startTime,v=r[h],_=(v==null?void 0:v.cues)||{};let b=(v==null?void 0:v.durationKnown)||!1,L=Cr;const{duration:U,endDate:M}=g;if(M&&U!==null)L=y+U,b=!0;else if(g.endOnNext&&!b){const ne=n.reduce((be,re)=>{if(re!==g.id){const ye=s[re];if(ye.class===g.class&&ye.startDate>g.startDate&&(!be||g.startDate<be.startDate))return ye}return be},null);ne&&(L=ne.startTime,b=!0)}const te=Object.keys(g.attr);for(let ne=0;ne<te.length;ne++){const be=te[ne];if(!Hs(be))continue;const re=_[be];if(re)b&&!v.durationKnown?re.endTime=L:Math.abs(re.startTime-y)>.01&&(re.startTime=y,re.endTime=L);else if(l){let ye=g.attr[be];js(be)&&(ye=Uc(ye));const ue=Bo(l,y,L,{key:be,data:ye},Os.dateRange);ue&&(ue.id=h,this.id3Track.addCue(ue),_[be]=ue,this.hls.config.interstitialsController&&(be==="X-ASSET-LIST"||be==="X-ASSET-URL")&&ue.addEventListener("enter",this.onEventCueEnter))}}r[h]={cues:_,dateRange:g,durationKnown:b}}}}class Vc{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)),g=Math.round(2/(1+Math.exp(-.75*u-this.edgeStalled))*20)/20,y=Math.min(h,Math.max(1,g));this.changeMediaPlaybackRate(t,y)}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 d=s;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)}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(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(m.ERROR,this.onError,this))}unregisterListeners(){const{hls:e}=this;e&&(e.off(m.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(m.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(m.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 Kc extends Qr{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(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this),e.on(m.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.FRAG_BUFFERED,this.onFragBuffered,this),e.off(m.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(d=>{var h;const g=d.attrs;let{audioCodec:y,videoCodec:v}=d;y&&(d.audioCodec=y=pi(y,i)||void 0),((h=v)==null?void 0:h.indexOf("avc1"))===0&&(v=d.videoCodec=as(v));const{width:_,height:b,unknownCodecs:L}=d;let U=L?L.length:0;if(L)for(let Xe=U;Xe--;){const dt=L[Xe];this.isAudioSupported(dt)?(d.audioCodec=y=y?`${y},${dt}`:dt,U--,ii.audio[y.substring(0,4)]=2):this.isVideoSupported(dt)&&(d.videoCodec=v=v?`${v},${dt}`:dt,U--,ii.video[v.substring(0,4)]=2)}if(o||(o=!!(_&&b)),u||(u=!!v),l||(l=!!y),U||y&&!this.isAudioSupported(y)||v&&!this.isVideoSupported(v)){this.log(`Some or all CODECS not supported "${g.CODECS}"`);return}const{CODECS:M,"FRAME-RATE":te,"HDCP-LEVEL":ne,"PATHWAY-ID":be,RESOLUTION:re,"VIDEO-RANGE":ye}=g,ue=`${`${be||"."}-`}${d.bitrate}-${re}-${te}-${M}-${ye}-${ne}`;if(n[ue])if(n[ue].uri!==d.url&&!d.attrs["PATHWAY-ID"]){const Xe=r[ue]+=1;d.attrs["PATHWAY-ID"]=new Array(Xe+1).join(".");const dt=this.createLevel(d);n[ue]=dt,s.push(dt)}else n[ue].addGroupId("audio",g.AUDIO),n[ue].addGroupId("text",g.SUBTITLES);else{const Xe=this.createLevel(d);n[ue]=Xe,r[ue]=1,s.push(Xe)}}),this.filterAndSortMediaOptions(s,t,o,u,l)}createLevel(e){const t=new Ke(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=E(s,[])}return t}isAudioSupported(e){return Qt(e,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(e){return Qt(e,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(e,t,i,s,n){let r=[],o=[],u=e;if((i||s)&&n&&(u=u.filter(({videoCodec:v,videoRange:_,width:b,height:L})=>(!!v||!!(b&&L))&&Pt(_))),u.length===0){Promise.resolve().then(()=>{if(this.hls){let v="no level with compatible codecs found in manifest",_=v;t.levels.length&&(_=`one or more CODECS in variant not supported: ${qt(t.levels.map(L=>L.attrs.CODECS).filter((L,U,M)=>M.indexOf(L)===U))}`,this.warn(_),v+=` (${_})`);const b=new Error(v);this.hls.trigger(m.ERROR,{type:z.MEDIA_ERROR,details:A.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:b,reason:_})}});return}t.audioTracks&&(r=t.audioTracks.filter(v=>!v.audioCodec||this.isAudioSupported(v.audioCodec)),Fo(r)),t.subtitles&&(o=t.subtitles,Fo(o));const l=u.slice(0);u.sort((v,_)=>{if(v.attrs["HDCP-LEVEL"]!==_.attrs["HDCP-LEVEL"])return(v.attrs["HDCP-LEVEL"]||"")>(_.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&v.height!==_.height)return v.height-_.height;if(v.frameRate!==_.frameRate)return v.frameRate-_.frameRate;if(v.videoRange!==_.videoRange)return Rt.indexOf(v.videoRange)-Rt.indexOf(_.videoRange);if(v.videoCodec!==_.videoCodec){const b=si(v.videoCodec),L=si(_.videoCodec);if(b!==L)return L-b}if(v.uri===_.uri&&v.codecSet!==_.codecSet){const b=At(v.codecSet),L=At(_.codecSet);if(b!==L)return L-b}return v.averageBitrate!==_.averageBitrate?v.averageBitrate-_.averageBitrate:0});let d=l[0];if(this.steering&&(u=this.steering.filterParsedLevels(u),u.length!==l.length)){for(let v=0;v<l.length;v++)if(l[v].pathwayId===u[0].pathwayId){d=l[v];break}}this._levels=u;for(let v=0;v<u.length;v++)if(u[v]===d){var h;this._firstLevel=v;const _=d.bitrate,b=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${_}`),((h=this.hls.userConfig)==null?void 0:h.abrEwmaDefaultEstimate)===void 0){const L=Math.min(_,this.hls.config.abrEwmaDefaultEstimateMax);L>b&&b===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=L)}break}const g=n&&!s,y={levels:u,audioTracks:r,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!g&&r.some(v=>!!v.url)};this.hls.trigger(m.MANIFEST_PARSED,y)}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 d=new Error("invalid level idx"),h=e<0;if(this.hls.trigger(m.ERROR,{type:z.OTHER_ERROR,details:A.LEVEL_SWITCH_ERROR,level:e,fatal:h,error:d,reason:d.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(m.LEVEL_SWITCHING,u);const l=r.details;if(!l||l.live){const d=this.switchParams(r.uri,s==null?void 0:s.details,l);this.loadPlaylist(d)}}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===oe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===H.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(m.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));dr(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(m.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(m.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function Fo(a){const e={};a.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}function No(){return self.SourceBuffer||self.WebKitSourceBuffer}function $o(){if(!Oe())return!1;const e=No();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function Hc(){if(!$o())return!1;const a=Oe();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(_t(e,"video")))||["mp4a.40.2","fLaC"].some(e=>a.isTypeSupported(_t(e,"audio"))))}function jc(){var a;const e=No();return typeof(e==null||(a=e.prototype)==null?void 0:a.changeType)=="function"}const zc=100;class Wc extends bn{constructor(e,t,i){super(e,t,i,"stream-controller",H.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||!S(n)||(this.log(`Media seeked to ${n.toFixed(3)}`),!this.getBufferedFrag(n)))return;const r=this.getFwdBufferInfoAtPos(s,n,H.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(m.MANIFEST_PARSED,this.onManifestParsed,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.LEVEL_LOADED,this.onLevelLoaded,this),e.on(m.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(m.BUFFER_CREATED,this.onBufferCreated,this),e.on(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(m.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:e}=this;e.off(m.MANIFEST_PARSED,this.onManifestParsed,this),e.off(m.LEVEL_LOADED,this.onLevelLoaded,this),e.off(m.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(m.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(m.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(m.BUFFER_CREATED,this.onBufferCreated,this),e.off(m.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(m.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(m.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(zc),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=Ie.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Ie.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Ie.WAITING_LEVEL:{const{levels:t,level:i}=this,s=t==null?void 0:t[i],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s&&!this.waitForLive(s))){if(this.waitForCdnTuneIn(n))break;this.state=Ie.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Ie.IDLE;break}break}case Ie.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),i=this.retryDate;if(!i||t>=i||(e=this.media)!=null&&e.seeking){const{levels:s,level:n}=this,r=s==null?void 0:s[n];this.resetStartWhenNotLoaded(r||null),this.state=Ie.IDLE}}break}this.state===Ie.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 _={};this.altAudio===2&&(_.type="video"),this.hls.trigger(m.BUFFER_EOS,_),this.state=Ie.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===Ie.WAITING_LEVEL||this.waitForLive(r)){this.level=n,this.state=Ie.WAITING_LEVEL,this.startFragRequested=!1;return}const d=o.len,h=this.getMaxBufferLength(r.maxBitrate);if(d>=h)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const g=this.backtrackFragment?this.backtrackFragment.start:o.end;let y=this.getNextFragment(g,l);if(this.couldBacktrack&&!this.fragPrevious&&y&&Be(y)&&this.fragmentTracker.getState(y)!==ni.OK){var v;const b=((v=this.backtrackFragment)!=null?v:y).sn-l.startSN,L=l.fragments[b-1];L&&y.cc===L.cc&&(y=L,this.fragmentTracker.removeFragment(L))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(y&&this.isLoopLoading(y,g)){if(!y.gap){const b=this.audioOnly&&!this.altAudio?_e.AUDIO:_e.VIDEO,L=(b===_e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;L&&this.afterBufferFlushed(L,b,H.MAIN)}y=this.getNextFragmentLoopLoading(y,l,o,H.MAIN,h)}y&&(y.initSegment&&!y.initSegment.data&&!this.bitrateTest&&(y=y.initSegment),this.loadFragment(y,r,g))}loadFragment(e,t,i){const s=this.fragmentTracker.getState(e);s===ni.NOT_LOADED||s===ni.PARTIAL?Be(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,H.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,d=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(d,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 Ie.KEY_LOADING:case Ie.FRAG_LOADING:case Ie.FRAG_LOADING_WAITING_RETRY:case Ie.PARSING:case Ie.PARSED:this.state=Ie.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;dn(i,"playing",this.onMediaPlaying),dn(i,"seeked",this.onMediaSeeked)}onMediaDetaching(e,t){const{media:i}=this;i&&(rn(i,"playing",this.onMediaPlaying),rn(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(m.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;t.levels.forEach(n=>{const r=n.audioCodec;r&&(i=i||r.indexOf("mp4a.40.2")!==-1,s=s||r.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=i&&s&&!jc(),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!==Ie.IDLE)return;const s=t.levelInfo;(!s.details||s.details.live&&(this.levelLastLoaded!==s||s.details.expired)||this.waitForCdnTuneIn(s.details))&&(this.state=Ie.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,d=this.fragCurrent;d&&(this.state===Ie.FRAG_LOADING||this.state===Ie.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let h=0;if(o.live||(i=l.details)!=null&&i.live){var g;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;h=this.alignPlaylists(o,l.details,(g=this.levelLastLoaded)==null?void 0:g.details)}if(l.details=o,this.levelLastLoaded=l,n||this.setStartPosition(o,h),this.hls.trigger(m.LEVEL_UPDATED,{details:o,level:r}),this.state===Ie.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=Ie.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 l=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!u&&i.readyState<4||n<o-l)&&(this._hasEnoughToStart||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),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,d=u.PTSKnown||!u.live,h=(t=i.initSegment)==null?void 0:t.data,g=this._getAudioCodec(o),y=this.transmuxer=this.transmuxer||new Za(this.hls,H.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),v=s?s.index:-1,_=v!==-1,b=new es(i.level,i.sn,i.stats.chunkCount,n.byteLength,v,_),L=this.initPTS[i.cc];y.push(n,h,g,l,i,s,u.totalduration,d,b,L)}onAudioTrackSwitching(e,t){const i=this.hls,s=this.altAudio===2;if(pt(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.fragmentTracker.removeAllFragments(),i.once(m.BUFFER_FLUSHED,()=>{var r;(r=this.hls)==null||r.trigger(m.AUDIO_TRACK_SWITCHED,t)}),i.trigger(m.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});return}i.trigger(m.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=pt(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===H.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===Ie.PARSED&&(this.state=Ie.IDLE);return}const o=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),Be(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}const r=this.media;r&&(!this._hasEnoughToStart&&Ft.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=Ie.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(H.MAIN,t);break;case A.LEVEL_LOAD_ERROR:case A.LEVEL_LOAD_TIMEOUT:case A.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Ie.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===oe.LEVEL&&(this.state=Ie.IDLE);break;case A.BUFFER_ADD_CODEC_ERROR:case A.BUFFER_APPEND_ERROR:if(t.parent!=="main")return;this.resetLoadingState();break;case A.BUFFER_FULL_ERROR:if(t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case A.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onFragLoadEmergencyAborted(){this.state=Ie.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==_e.AUDIO||!this.altAudio){const i=(t===_e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,H.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=Ft.getBuffered(e),o=r.length?r.start(0):0,u=o-i,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);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=Ie.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(m.FRAG_LOADED,i),n.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const i=this.playlistType,{hls:s}=this,{remuxResult:n,chunkMeta:r}=e,o=this.getCurrentContext(r);if(!o){this.resetWhenMissingContext(r);return}const{frag:u,part:l,level:d}=o,{video:h,text:g,id3:y,initSegment:v}=n,{details:_}=d,b=this.altAudio?void 0:n.audio;if(this.fragContextChanged(u)){this.fragmentTracker.removeFragment(u);return}if(this.state=Ie.PARSING,v){if(v!=null&&v.tracks){const M=u.initSegment||u;this._bufferInitSegment(d,v.tracks,M,r),s.trigger(m.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:i,tracks:v.tracks})}const L=v.initPTS,U=v.timescale;S(L)&&(this.initPTS[u.cc]={baseTime:L,timescale:U},s.trigger(m.INIT_PTS_FOUND,{frag:u,id:i,initPTS:L,timescale:U}))}if(h&&_){const L=_.fragments[u.sn-1-_.startSN],U=u.sn===_.startSN,M=!L||u.cc>L.cc;if(n.independent!==!1){const{startPTS:te,endPTS:ne,startDTS:be,endDTS:re}=h;if(l)l.elementaryStreams[h.type]={startPTS:te,endPTS:ne,startDTS:be,endDTS:re};else if(h.firstKeyFrame&&h.independent&&r.id===1&&!M&&(this.couldBacktrack=!0),h.dropped&&h.independent){const ye=this.getMainFwdBufferInfo(),Te=(ye?ye.end:this.getLoadPosition())+this.config.maxBufferHole,ue=h.firstKeyFramePTS?h.firstKeyFramePTS:te;if(!U&&Te<ue-this.config.maxBufferHole&&!M){this.backtrack(u);return}else M&&(u.gap=!0);u.setElementaryStreamInfo(h.type,u.start,ne,u.start,re,!0)}else U&&te-(_.appliedTimelineOffset||0)>Ir&&(u.gap=!0);u.setElementaryStreamInfo(h.type,te,ne,be,re),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(h,u,l,r,U||M)}else if(U||M)u.gap=!0;else{this.backtrack(u);return}}if(b){const{startPTS:L,endPTS:U,startDTS:M,endDTS:te}=b;l&&(l.elementaryStreams[_e.AUDIO]={startPTS:L,endPTS:U,startDTS:M,endDTS:te}),u.setElementaryStreamInfo(_e.AUDIO,L,U,M,te),this.bufferFragmentData(b,u,l,r)}if(_&&y!=null&&(t=y.samples)!=null&&t.length){const L={id:i,frag:u,details:_,samples:y.samples};s.trigger(m.FRAG_PARSING_METADATA,L)}if(_&&g){const L={id:i,frag:u,details:_,samples:g.samples};s.trigger(m.FRAG_PARSING_USERDATA,L)}}_bufferInitSegment(e,t,i,s){if(this.state!==Ie.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:r,audiovideo:o}=t;if(n){let l=ci(n.codec,e.audioCodec);l==="mp4a"&&(l="mp4a.40.5");const d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const h=n.metadata;h&&"channelCount"in h&&(h.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id=H.MAIN,this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`),delete t.audiovideo}if(r){r.levelCodec=e.videoCodec,r.id=H.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(m.BUFFER_CODECS,t),!this.hls)return;u.forEach(l=>{const h=t[l].initSegment;h!=null&&h.byteLength&&this.hls.trigger(m.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,H.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=Ie.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(Ft.isBuffered(e,i)?t=this.getAppendedFrag(i):Ft.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(m.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(m.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 S(t)?this.getAppendedFrag(t):null}get currentProgramDateTime(){var e;const t=((e=this.media)==null?void 0:e.currentTime)||this.lastCurrentTime;if(S(t)){const i=this.getLevelDetails(),s=this.currentFrag||(i?Bt(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 Zc{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[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.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=A.KEY_LOAD_ERROR,i,s,n){return new Yi({type:z.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=e;for(let n=0;n<t.length;n++){const r=t[n];if(s<=r.cc&&(i==="initSegment"||r.sn==="initSegment"||i<r.sn)){this.emeController.selectKeySystemFormat(r).then(o=>{r.setKeyFormat(o)});break}}}}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");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}"`)));let o=this.keyUriToKeyInfo[r];if((i=o)!=null&&i.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var u;switch((u=o.mediaKeySessionContext)==null?void 0:u.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(l=>(n.key=l.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[r]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(o,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){const s=this.emeController.loadKey(i);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,i))).catch(n=>{throw e.keyLoadPromise=null,n})}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,d={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:(g,y,v,_)=>{const{frag:b,keyInfo:L,url:U}=v;if(!b.decryptdata||L!==this.keyUriToKeyInfo[U])return o(this.createKeyLoadError(b,A.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),_));L.decryptdata.key=b.decryptdata.key=new Uint8Array(g.data),b.keyLoader=null,L.loader=null,r({frag:b,keyInfo:L})},onError:(g,y,v,_)=>{this.resetLoader(y),o(this.createKeyLoadError(t,A.KEY_LOAD_ERROR,new Error(`HTTP Error ${g.code} loading key ${g.text}`),v,j({url:u.url,data:void 0},g)))},onTimeout:(g,y,v)=>{this.resetLoader(y),o(this.createKeyLoadError(t,A.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),v))},onAbort:(g,y,v)=>{this.resetLoader(y),o(this.createKeyLoadError(t,A.INTERNAL_ABORTED,new Error("key loading aborted"),v))}};n.load(u,d,h)})}resetLoader(e){const{frag:t,keyInfo:i,url:s}=e,n=i.loader;t.keyLoader===n&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}}function Uo(a){const{type:e}=a;switch(e){case oe.AUDIO_TRACK:return H.AUDIO;case oe.SUBTITLE_TRACK:return H.SUBTITLE;default:return H.MAIN}}function Ea(a,e){let t=a.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class Yc{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(m.MANIFEST_LOADING,this.onManifestLoading,this),e.on(m.LEVEL_LOADING,this.onLevelLoading,this),e.on(m.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(m.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(m.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:e}=this;e.off(m.MANIFEST_LOADING,this.onManifestLoading,this),e.off(m.LEVEL_LOADING,this.onLevelLoading,this),e.off(m.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(m.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(m.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:oe.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:oe.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:oe.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:oe.SUBTITLE_TRACK,url:n,deliveryDirectives:r,levelOrTrack:o})}onLevelsUpdated(e,t){const i=this.loaders[oe.LEVEL];if(i){const s=i.context;s&&!t.levels.some(n=>n===s.levelOrTrack)&&(i.abort(),delete this.loaders[oe.LEVEL])}}load(e){var t;const i=this.hls.config;let s=this.getInternalLoader(e);if(s){const l=this.hls.logger,d=s.context;if(d&&d.levelOrTrack===e.levelOrTrack&&(d.url===e.url||d.deliveryDirectives&&!e.deliveryDirectives)){d.url===e.url?l.log(`[playlist-loader]: ignore ${e.url} ongoing request`):l.log(`[playlist-loader]: ignore ${e.url} in favor of ${d.url}`);return}l.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===oe.MANIFEST?n=i.manifestLoadPolicy.default:n=ce({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),S((t=e.deliveryDirectives)==null?void 0:t.part)){let l;if(e.type===oe.LEVEL&&e.level!==null?l=this.hls.levels[e.level].details:e.type===oe.AUDIO_TRACK&&e.id!==null?l=this.hls.audioTracks[e.id].details:e.type===oe.SUBTITLE_TRACK&&e.id!==null&&(l=this.hls.subtitleTracks[e.id].details),l){const d=l.partTarget,h=l.targetduration;if(d&&h){const g=Math.max(d*3,h*.8)*1e3;n=ce({},n,{maxTimeToFirstByteMs:Math.min(g,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(g,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,d,h,g)=>{const y=this.getInternalLoader(h);this.resetInternalLoader(h.type);const v=l.data;if(v.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(l,h,new Error("no EXTM3U delimiter"),g||null,d);return}d.parsing.start=performance.now(),Ns.isMediaPlaylist(v)||h.type!==oe.MANIFEST?this.handleTrackOrLevelPlaylist(l,d,h,g||null,y):this.handleMasterPlaylist(l,d,h,g)},onError:(l,d,h,g)=>{this.handleNetworkError(d,h,!1,l,g)},onTimeout:(l,d,h)=>{this.handleNetworkError(d,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=Ea(e,i),u=Ns.parseMasterPlaylist(r,o);if(u.playlistParsingError){this.handleManifestParsingError(e,i,u.playlistParsingError,s,t);return}const{contentSteering:l,levels:d,sessionData:h,sessionKeys:g,startTimeOffset:y,variableList:v}=u;this.variableList=v;const{AUDIO:_=[],SUBTITLES:b,"CLOSED-CAPTIONS":L}=Ns.parseMasterPlaylistMedia(r,o,u);_.length&&!_.some(M=>!M.url)&&d[0].audioCodec&&!d[0].attrs.AUDIO&&(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),_.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new vi({}),bitrate:0,url:""})),n.trigger(m.MANIFEST_LOADED,{levels:d,audioTracks:_,subtitles:b,captions:L,contentSteering:l,url:o,stats:t,networkDetails:s,sessionData:h,sessionKeys:g,startTimeOffset:y,variableList:v})}handleTrackOrLevelPlaylist(e,t,i,s,n){const r=this.hls,{id:o,level:u,type:l}=i,d=Ea(e,i),h=S(u)?u:S(o)?o:0,g=Uo(i),y=Ns.parseLevelPlaylist(e.data,d,h,g,0,this.variableList);if(l===oe.MANIFEST){const v={attrs:new vi({}),bitrate:0,details:y,name:"",url:d};y.requestScheduled=t.loading.start+ur(y,0),r.trigger(m.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:d,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=y,this.handlePlaylistLoaded(y,e,t,i,s,n)}handleManifestParsingError(e,t,i,s,n){this.hls.trigger(m.ERROR,{type:z.NETWORK_ERROR,details:A.MANIFEST_PARSING_ERROR,fatal:t.type===oe.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===oe.LEVEL?r+=`: ${e.level} id: ${e.id}`:(e.type===oe.AUDIO_TRACK||e.type===oe.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 d=this.getInternalLoader(e);switch(e.type){case oe.MANIFEST:u=i?A.MANIFEST_LOAD_TIMEOUT:A.MANIFEST_LOAD_ERROR,l=!0;break;case oe.LEVEL:u=i?A.LEVEL_LOAD_TIMEOUT:A.LEVEL_LOAD_ERROR,l=!1;break;case oe.AUDIO_TRACK:u=i?A.AUDIO_TRACK_LOAD_TIMEOUT:A.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case oe.SUBTITLE_TRACK:u=i?A.SUBTITLE_TRACK_LOAD_TIMEOUT:A.SUBTITLE_LOAD_ERROR,l=!1;break}d&&this.resetInternalLoader(e.type);const h={type:z.NETWORK_ERROR,details:u,fatal:l,url:e.url,loader:d,context:e,error:o,networkDetails:t,stats:n};if(s){const g=(t==null?void 0:t.url)||e.url;h.response=j({url:g,data:void 0},s)}this.hls.trigger(m.ERROR,h)}handlePlaylistLoaded(e,t,i,s,n,r){const o=this.hls,{type:u,level:l,id:d,groupId:h,deliveryDirectives:g}=s,y=Ea(t,s),v=Uo(s),_=typeof s.level=="number"&&v===H.MAIN?l:void 0;if(!e.fragments.length){const L=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(m.ERROR,{type:z.NETWORK_ERROR,details:A.LEVEL_EMPTY_ERROR,fatal:!1,url:y,error:L,reason:L.message,response:t,context:s,level:_,parent:v,networkDetails:n,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const b=e.playlistParsingError;if(b){if(this.hls.logger.warn(b),!o.config.ignorePlaylistParsingErrors){o.trigger(m.ERROR,{type:z.NETWORK_ERROR,details:A.LEVEL_PARSING_ERROR,fatal:!1,url:y,error:b,reason:b.message,response:t,context:s,level:_,parent:v,networkDetails:n,stats:i});return}e.playlistParsingError=null}switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),u){case oe.MANIFEST:case oe.LEVEL:o.trigger(m.LEVEL_LOADED,{details:e,levelInfo:s.levelOrTrack||o.levels[0],level:_||0,id:d||0,stats:i,networkDetails:n,deliveryDirectives:g,withoutMultiVariant:u===oe.MANIFEST});break;case oe.AUDIO_TRACK:o.trigger(m.AUDIO_TRACK_LOADED,{details:e,track:s.levelOrTrack,id:d||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:g});break;case oe.SUBTITLE_TRACK:o.trigger(m.SUBTITLE_TRACK_LOADED,{details:e,track:s.levelOrTrack,id:d||0,groupId:h||"",stats:i,networkDetails:n,deliveryDirectives:g});break}}}class vn{static get version(){return Zn}static isMSESupported(){return $o()}static isSupported(){return Hc()}static getMediaSource(){return Oe()}static get Events(){return m}static get MetadataSchema(){return Os}static get ErrorTypes(){return z}static get ErrorDetails(){return A}static get DefaultConfig(){return vn.defaultConfig?vn.defaultConfig:wc}static set DefaultConfig(e){vn.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 $r,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=ve(e.debug||!1,"Hls instance",e.assetPlayerId),i=this.config=Oc(vn.DefaultConfig,e,t);this.userConfig=e,i.progressive&&Pc(i,t);const{abrController:s,bufferController:n,capLevelController:r,errorController:o,fpsController:u}=i,l=new o(this),d=this.abrController=new s(this),h=new is(this),g=i.interstitialsController,y=g?this.interstitialsController=new g(this,vn):null,v=this.bufferController=new n(this,h),_=this.capLevelController=new r(this),b=new u(this),L=new Yc(this),U=i.contentSteeringController,M=U?new U(this):null,te=this.levelController=new Kc(this,M),ne=new Gc(this),be=new Zc(this.config),re=this.streamController=new Wc(this,h,be),ye=this.gapController=new Nc(this,h);_.setStreamController(re),b.setStreamController(re);const Te=[L,te,re];y&&Te.splice(1,0,y),M&&Te.splice(1,0,M),this.networkControllers=Te;const ue=[d,v,ye,_,b,ne,h];this.audioTrackController=this.createController(i.audioTrackController,Te);const Xe=i.audioStreamController;Xe&&Te.push(this.audioStreamController=new Xe(this,h,be)),this.subtitleTrackController=this.createController(i.subtitleTrackController,Te);const dt=i.subtitleStreamController;dt&&Te.push(this.subtititleStreamController=new dt(this,h,be)),this.createController(i.timelineController,ue),be.emeController=this.emeController=this.createController(i.emeController,ue),this.cmcdController=this.createController(i.cmcdController,ue),this.latencyController=this.createController(Vc,ue),this.coreComponents=ue,Te.push(l);const Ei=l.onErrorOut;typeof Ei=="function"&&this.on(m.ERROR,Ei,l),this.on(m.MANIFEST_LOADED,L.onManifestLoaded,L)}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===m.ERROR;this.trigger(m.ERROR,{type:z.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(m.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(m.ERROR,{type:z.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(m.MEDIA_ATTACHING,s)}detachMedia(){this.logger.log("detachMedia"),this.trigger(m.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const e=this.bufferController.transferMedia();return this.trigger(m.MEDIA_DETACHING,{transferMedia:e}),e}loadSource(e){this.stopLoad();const t=this.media,i=this._url,s=this._url=je.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(m.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={[H.MAIN]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[H.AUDIO]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[H.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=cl()),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){ht(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=lt(t);return J(e,i,navigator.mediaCapabilities)}}vn.defaultConfig=void 0}}]);
|
|
}()); |