import{e as xt,o as $,c as Z,O as Ct,_ as wt,u as j,bf as Pt,be as Ft,R as Tt,d as jt,a as V,M as ht,V as ft,U as et,S as st,bH as ie,r as Dt,Q as ut,$ as qt,Z as Ee,w as ue,j as de,G as ce,L as Jt,T as Xt,a7 as zt,W as te,X as Te,I as Se,K as be,a8 as Ht,n as he,i as Le}from"./@vue.51d7f2d8.js";var Ae=Object.defineProperty,De=Object.defineProperties,ke=Object.getOwnPropertyDescriptors,ne=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable,ae=(N,w,f)=>w in N?Ae(N,w,{enumerable:!0,configurable:!0,writable:!0,value:f}):N[w]=f,ee=(N,w)=>{for(var f in w||(w={}))Re.call(w,f)&&ae(N,f,w[f]);if(ne)for(var f of ne(w))_e.call(w,f)&&ae(N,f,w[f]);return N},re=(N,w)=>De(N,ke(w));function se(N,w,f,_){var T,A=!1,R=0;function I(){T&&clearTimeout(T)}function k(){for(var o=arguments.length,L=new Array(o),m=0;mN?y():w!==!0&&(T=setTimeout(_?d:y,_===void 0?N-E:N)))}return typeof w!="boolean"&&(_=f,f=w,w=void 0),k.cancel=function(){I(),A=!0},k}function oe(N,w,f){return f===void 0?se(N,w,!1):se(N,f,w!==!1)}function Ie(N){return N&&N.__esModule&&Object.prototype.hasOwnProperty.call(N,"default")?N.default:N}var fe={exports:{}};typeof window<"u"&&(fe.exports=function(N){var w={};function f(_){if(w[_])return w[_].exports;var T=w[_]={i:_,l:!1,exports:{}};return N[_].call(T.exports,T,T.exports,f),T.l=!0,T.exports}return f.m=N,f.c=w,f.d=function(_,T,A){f.o(_,T)||Object.defineProperty(_,T,{enumerable:!0,get:A})},f.r=function(_){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(_,"__esModule",{value:!0})},f.t=function(_,T){if(1&T&&(_=f(_)),8&T||4&T&&typeof _=="object"&&_&&_.__esModule)return _;var A=Object.create(null);if(f.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:_}),2&T&&typeof _!="string")for(var R in _)f.d(A,R,function(I){return _[I]}.bind(null,R));return A},f.n=function(_){var T=_&&_.__esModule?function(){return _.default}:function(){return _};return f.d(T,"a",T),T},f.o=function(_,T){return Object.prototype.hasOwnProperty.call(_,T)},f.p="/dist/",f(f.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(N,w,f){var _=Object.prototype.hasOwnProperty,T="~";function A(){}function R(L,m,h){this.fn=L,this.context=m,this.once=h||!1}function I(L,m,h,E,y){if(typeof h!="function")throw new TypeError("The listener must be a function");var d=new R(h,E||L,y),t=T?T+m:m;return L._events[t]?L._events[t].fn?L._events[t]=[L._events[t],d]:L._events[t].push(d):(L._events[t]=d,L._eventsCount++),L}function k(L,m){--L._eventsCount==0?L._events=new A:delete L._events[m]}function o(){this._events=new A,this._eventsCount=0}Object.create&&(A.prototype=Object.create(null),new A().__proto__||(T=!1)),o.prototype.eventNames=function(){var L,m,h=[];if(this._eventsCount===0)return h;for(m in L=this._events)_.call(L,m)&&h.push(T?m.slice(1):m);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(L)):h},o.prototype.listeners=function(L){var m=T?T+L:L,h=this._events[m];if(!h)return[];if(h.fn)return[h.fn];for(var E=0,y=h.length,d=new Array(y);E0},!1)}N.exports=function(o,L){L=L||{};var m={main:f.m},h=L.all?{main:Object.keys(m.main)}:function(a,e){for(var s={main:[e]},u={main:[]},n={main:{}};k(s);)for(var l=Object.keys(s),p=0;p=2*p/v||D<=C)){var x,P=Number.POSITIVE_INFINITY;for(x=t.level-1;x>i&&!((P=p*r[x].maxBitrate/(6.4*b))=D)){var F=this.bwEstimator.getEstimate();o.logger.warn("Fragment "+t.sn+(a?" part "+a.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+x+` Current BW estimate: `+(Object(_.isFiniteNumber)(F)?(F/1024).toFixed(3):"Unknown")+` Kb/s Estimated load time for current fragment: `+D.toFixed(3)+` s Estimated load time for the next fragment: `+P.toFixed(3)+` s Time to underbuffer: `+C.toFixed(3)+" s"),e.nextLoadLevel=x,this.bwEstimator.sample(g,l.loaded),this.clearTimer(),t.loader&&(this.fragCurrent=this.partCurrent=null,t.loader.abort()),e.trigger(A.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:a,stats:l})}}}}}},d.onFragLoaded=function(t,a){var e=a.frag,s=a.part;if(e.type===k.PlaylistLevelType.MAIN&&Object(_.isFiniteNumber)(e.sn)){var u=s?s.stats:e.stats,n=s?s.duration:e.duration;if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var l=this.hls.levels[e.level],p=(l.loaded?l.loaded.bytes:0)+u.loaded,g=(l.loaded?l.loaded.duration:0)+n;l.loaded={bytes:p,duration:g},l.realBitrate=Math.round(8*p/g)}if(e.bitrateTest){var v={stats:u,frag:e,part:s,id:e.type};this.onFragBuffered(A.Events.FRAG_BUFFERED,v),e.bitrateTest=!1}}},d.onFragBuffered=function(t,a){var e=a.frag,s=a.part,u=s?s.stats:e.stats;if(!u.aborted&&e.type===k.PlaylistLevelType.MAIN&&e.sn!=="initSegment"){var n=u.parsing.end-u.loading.start;this.bwEstimator.sample(n,u.loaded),u.bwEstimate=this.bwEstimator.getEstimate(),e.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},d.onError=function(t,a){switch(a.details){case I.ErrorDetails.FRAG_LOAD_ERROR:case I.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},d.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},d.getNextABRAutoLevel=function(){var t=this.fragCurrent,a=this.partCurrent,e=this.hls,s=e.maxAutoLevel,u=e.config,n=e.minAutoLevel,l=e.media,p=a?a.duration:t?t.duration:0,g=l?l.currentTime:0,v=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,r=this.bwEstimator?this.bwEstimator.getEstimate():u.abrEwmaDefaultEstimate,i=(R.BufferHelper.bufferInfo(l,g,u.maxBufferHole).end-g)/v,c=this.findBestLevel(r,n,s,i,u.abrBandWidthFactor,u.abrBandWidthUpFactor);if(c>=0)return c;o.logger.trace((i?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var S=p?Math.min(p,u.maxStarvationDelay):u.maxStarvationDelay,b=u.abrBandWidthFactor,D=u.abrBandWidthUpFactor;if(!i){var O=this.bitrateTestDelay;O&&(S=(p?Math.min(p,u.maxLoadingDelay):u.maxLoadingDelay)-O,o.logger.trace("bitrate test took "+Math.round(1e3*O)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*S)+" ms"),b=D=1)}return c=this.findBestLevel(r,n,s,i+S,b,D),Math.max(c,0)},d.findBestLevel=function(t,a,e,s,u,n){for(var l,p=this.fragCurrent,g=this.partCurrent,v=this.lastLoadedFragLevel,r=this.hls.levels,i=r[v],c=!(i==null||(l=i.details)===null||l===void 0||!l.live),S=i==null?void 0:i.codecSet,b=g?g.duration:p?p.duration:0,D=e;D>=a;D--){var O=r[D];if(O&&(!S||O.codecSet===S)){var C=O.details,x=(g?C==null?void 0:C.partTarget:C==null?void 0:C.averagetargetduration)||b,P=void 0;P=D<=v?u*t:n*t;var F=r[D].maxBitrate,M=F*x/P;if(o.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+D+"/"+Math.round(P)+"/"+F+"/"+x+"/"+s+"/"+M),P>F&&(!M||c&&!this.bitrateTestDelay||M0&&r===-1?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),this.state=T.State.IDLE):(this.loadedmetadata=!1,this.state=T.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},v.doTick=function(){switch(this.state){case T.State.IDLE:this.doTickIdle();break;case T.State.WAITING_TRACK:var r,i=this.levels,c=this.trackId,S=i==null||(r=i[c])===null||r===void 0?void 0:r.details;if(S){if(this.waitForCdnTuneIn(S))break;this.state=T.State.WAITING_INIT_PTS}break;case T.State.FRAG_LOADING_WAITING_RETRY:var b,D=performance.now(),O=this.retryDate;(!O||D>=O||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=T.State.IDLE);break;case T.State.WAITING_INIT_PTS:var C=this.waitingData;if(C){var x=C.frag,P=C.part,F=C.cache,M=C.complete;if(this.initPTS[x.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=T.State.FRAG_LOADING;var B={frag:x,part:P,payload:F.flush(),networkDetails:null};this._handleFragmentLoadProgress(B),M&&n.prototype._handleFragmentLoadComplete.call(this,B)}else if(this.videoTrackCC!==this.waitingVideoCC)a.logger.log("Waiting fragment cc ("+x.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var U=this.getLoadPosition(),G=R.BufferHelper.bufferInfo(this.mediaBuffer,U,this.config.maxBufferHole);Object(y.fragmentWithinToleranceTest)(G.end,this.config.maxFragLookUpTolerance,x)<0&&(a.logger.log("Waiting fragment cc ("+x.cc+") @ "+x.start+" cancelled because another fragment at "+G.end+" is needed"),this.clearWaitingFragment())}}else this.state=T.State.IDLE}this.onTickEnd()},v.clearWaitingFragment=function(){var r=this.waitingData;r&&(this.fragmentTracker.removeFragment(r.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=T.State.IDLE)},v.onTickEnd=function(){var r=this.media;if(r&&r.readyState){var i=(this.mediaBuffer?this.mediaBuffer:r).buffered;!this.loadedmetadata&&i.length&&(this.loadedmetadata=!0),this.lastCurrentTime=r.currentTime}},v.doTickIdle=function(){var r,i,c=this.hls,S=this.levels,b=this.media,D=this.trackId,O=c.config;if(S&&S[D]&&(b||!this.startFragRequested&&O.startFragPrefetch)){var C=S[D].details;if(!C||C.live&&this.levelLastLoaded!==D||this.waitForCdnTuneIn(C))this.state=T.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,L.ElementaryStreamTypes.AUDIO,o.PlaylistLevelType.AUDIO));var x=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,o.PlaylistLevelType.AUDIO);if(x!==null){var P=x.len,F=this.getMaxBufferLength(),M=this.audioSwitch;if(!(P>=F)||M){if(!M&&this._streamEnded(x,C))return c.trigger(A.Events.BUFFER_EOS,{type:"audio"}),void(this.state=T.State.ENDED);var B=C.fragments[0].start,U=x.end;if(M){var G=this.getLoadPosition();U=G,C.PTSKnown&&GB||x.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),b.currentTime=B+.05)}var K=this.getNextFragment(U,C);K?((r=K.decryptdata)===null||r===void 0?void 0:r.keyFormat)!=="identity"||(i=K.decryptdata)!==null&&i!==void 0&&i.key?this.loadFragment(K,C,U):this.loadKey(K,C):this.bufferFlushed=!0}}}}},v.getMaxBufferLength=function(){var r=n.prototype.getMaxBufferLength.call(this),i=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,o.PlaylistLevelType.MAIN);return i===null?r:Math.max(r,i.len)},v.onMediaDetaching=function(){this.videoBuffer=null,n.prototype.onMediaDetaching.call(this)},v.onAudioTracksUpdated=function(r,i){var c=i.audioTracks;this.resetTransmuxer(),this.levels=c.map(function(S){return new k.Level(S)})},v.onAudioTrackSwitching=function(r,i){var c=!!i.url;this.trackId=i.id;var S=this.fragCurrent;S!=null&&S.loader&&S.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),c?this.setInterval(100):this.resetTransmuxer(),c?(this.audioSwitch=!0,this.state=T.State.IDLE):this.state=T.State.STOPPED,this.tick()},v.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},v.onLevelLoaded=function(r,i){this.mainDetails=i.details},v.onAudioTrackLoaded=function(r,i){var c,S=this.levels,b=i.details,D=i.id;if(S){this.log("Track "+D+" loaded ["+b.startSN+","+b.endSN+"],duration:"+b.totalduration);var O=S[D],C=0;if(b.live||(c=O.details)!==null&&c!==void 0&&c.live){var x=this.mainDetails;if(b.fragments[0]||(b.deltaUpdateFailed=!0),b.deltaUpdateFailed||!x)return;!O.details&&b.hasProgramDateTime&&x.hasProgramDateTime?(Object(d.alignPDT)(b,x),C=b.fragments[0].start):C=this.alignPlaylists(b,O.details)}O.details=b,this.levelLastLoaded=D,this.startFragRequested||!this.mainDetails&&b.live||this.setStartPosition(O.details,C),this.state!==T.State.WAITING_TRACK||this.waitForCdnTuneIn(b)||(this.state=T.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+D)},v._handleFragmentLoadProgress=function(r){var i,c=r.frag,S=r.part,b=r.payload,D=this.config,O=this.trackId,C=this.levels;if(C){var x=C[O];console.assert(x,"Audio track is defined on fragment load progress");var P=x.details;console.assert(P,"Audio track details are defined on fragment load progress");var F=D.defaultAudioCodec||x.audioCodec||"mp4a.40.2",M=this.transmuxer;M||(M=this.transmuxer=new h.default(this.hls,o.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var B=this.initPTS[c.cc],U=(i=c.initSegment)===null||i===void 0?void 0:i.data;if(B!==void 0){var G=S?S.index:-1,K=G!==-1,H=new E.ChunkMetadata(c.level,c.sn,c.stats.chunkCount,b.byteLength,G,K);M.push(b,U,F,"",c,S,P.totalduration,!1,H,B)}else a.logger.log("Unknown video PTS for cc "+c.cc+", waiting for video PTS before demuxing audio frag "+c.sn+" of ["+P.startSN+" ,"+P.endSN+"],track "+O),(this.waitingData=this.waitingData||{frag:c,part:S,cache:new m.default,complete:!1}).cache.push(new Uint8Array(b)),this.waitingVideoCC=this.videoTrackCC,this.state=T.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+c.sn+" of level "+c.level+" will not be buffered")},v._handleFragmentLoadComplete=function(r){this.waitingData?this.waitingData.complete=!0:n.prototype._handleFragmentLoadComplete.call(this,r)},v.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},v.onBufferCreated=function(r,i){var c=i.tracks.audio;c&&(this.mediaBuffer=c.buffer),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer)},v.onFragBuffered=function(r,i){var c=i.frag,S=i.part;c.type===o.PlaylistLevelType.AUDIO&&(this.fragContextChanged(c)?this.warn("Fragment "+c.sn+(S?" p: "+S.index:"")+" of level "+c.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(c.sn!=="initSegment"&&(this.fragPrevious=c,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(c,S)))},v.onError=function(r,i){switch(i.details){case t.ErrorDetails.FRAG_LOAD_ERROR:case t.ErrorDetails.FRAG_LOAD_TIMEOUT:case t.ErrorDetails.KEY_LOAD_ERROR:case t.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(o.PlaylistLevelType.AUDIO,i);break;case t.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case t.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==T.State.ERROR&&this.state!==T.State.STOPPED&&(this.state=i.fatal?T.State.ERROR:T.State.IDLE,this.warn(i.details+" while loading frag, switching to "+this.state+" state"));break;case t.ErrorDetails.BUFFER_FULL_ERROR:if(i.parent==="audio"&&(this.state===T.State.PARSING||this.state===T.State.PARSED)){var c=!0,S=this.getFwdBufferInfo(this.mediaBuffer,o.PlaylistLevelType.AUDIO);S&&S.len>.5&&(c=!this.reduceMaxBufferLength(S.len)),c&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},v.onBufferFlushed=function(r,i){i.type===L.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},v._handleTransmuxComplete=function(r){var i,c="audio",S=this.hls,b=r.remuxResult,D=r.chunkMeta,O=this.getCurrentContext(D);if(!O)return this.warn("The loading context changed while buffering fragment "+D.sn+" of level "+D.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(D.level);var C=O.frag,x=O.part,P=b.audio,F=b.text,M=b.id3,B=b.initSegment;if(!this.fragContextChanged(C)){if(this.state=T.State.PARSING,this.audioSwitch&&P&&this.completeAudioSwitch(),B!=null&&B.tracks&&(this._bufferInitSegment(B.tracks,C,D),S.trigger(A.Events.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:c,tracks:B.tracks})),P){var U=P.startPTS,G=P.endPTS,K=P.startDTS,H=P.endDTS;x&&(x.elementaryStreams[L.ElementaryStreamTypes.AUDIO]={startPTS:U,endPTS:G,startDTS:K,endDTS:H}),C.setElementaryStreamInfo(L.ElementaryStreamTypes.AUDIO,U,G,K,H),this.bufferFragmentData(P,C,x,D)}if(M!=null&&(i=M.samples)!==null&&i!==void 0&&i.length){var Y=e({frag:C,id:c},M);S.trigger(A.Events.FRAG_PARSING_METADATA,Y)}if(F){var W=e({frag:C,id:c},F);S.trigger(A.Events.FRAG_PARSING_USERDATA,W)}}},v._bufferInitSegment=function(r,i,c){if(this.state===T.State.PARSING){r.video&&delete r.video;var S=r.audio;if(S){S.levelCodec=S.codec,S.id="audio",this.log("Init audio buffer, container:"+S.container+", codecs[parsed]=["+S.codec+"]"),this.hls.trigger(A.Events.BUFFER_CODECS,r);var b=S.initSegment;if(b!=null&&b.byteLength){var D={type:"audio",frag:i,part:null,chunkMeta:c,parent:i.type,data:b};this.hls.trigger(A.Events.BUFFER_APPENDING,D)}this.tick()}}},v.loadFragment=function(r,i,c){var S=this.fragmentTracker.getState(r);this.fragCurrent=r,(this.audioSwitch||S===I.FragmentState.NOT_LOADED||S===I.FragmentState.PARTIAL)&&(r.sn==="initSegment"?this._loadInitSegment(r):i.live&&!Object(_.isFiniteNumber)(this.initPTS[r.cc])?(this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId),this.state=T.State.WAITING_INIT_PTS):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,r,i,c)))},v.completeAudioSwitch=function(){var r=this.hls,i=this.media,c=this.trackId;i&&(this.log("Switching audio track : flushing all audio"),n.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,r.trigger(A.Events.AUDIO_TRACK_SWITCHED,{id:c})},g}(T.default);w.default=u},"./src/controller/audio-track-controller.ts":function(N,w,f){f.r(w);var _=f("./src/events.ts"),T=f("./src/errors.ts"),A=f("./src/controller/base-playlist-controller.ts"),R=f("./src/types/loader.ts");function I(L,m){for(var h=0;h=e.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var s=e[this.trackId];this.log("Now switching to audio-track index "+a);var u=e[a],n=u.id,l=u.groupId,p=l===void 0?"":l,g=u.name,v=u.type,r=u.url;if(this.trackId=a,this.trackName=g,this.selectDefaultTrack=!1,this.hls.trigger(_.Events.AUDIO_TRACK_SWITCHING,{id:n,groupId:p,name:g,type:v,url:r}),!u.details||u.details.live){var i=this.switchParams(u.url,s==null?void 0:s.details);this.loadPlaylist(i)}}},t.selectInitialTrack=function(){var a=this.tracksInGroup;console.assert(a.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,s=this.findTrackId(e)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(_.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},t.findTrackId=function(a){for(var e=this.tracksInGroup,s=0;sh.partTarget&&(e+=1)}if(Object(_.isFiniteNumber)(a))return new T.HlsUrlParameters(a,Object(_.isFiniteNumber)(e)?e:void 0,T.HlsSkip.No)}}},L.loadPlaylist=function(m){},L.shouldLoadTrack=function(m){return this.canLoad&&m&&!!m.url&&(!m.details||m.details.live)},L.playlistLoaded=function(m,h,E){var y=this,d=h.details,t=h.stats,a=t.loading.end?Math.max(0,self.performance.now()-t.loading.end):0;if(d.advancedDateTime=Date.now()-a,d.live||E!=null&&E.live){if(d.reloaded(E),E&&this.log("live playlist "+m+" "+(d.advanced?"REFRESHED "+d.lastPartSn+"-"+d.lastPartIndex:"MISSED")),E&&d.fragments.length>0&&Object(A.mergeDetails)(E,d),!this.canLoad||!d.live)return;var e,s=void 0,u=void 0;if(d.canBlockReload&&d.endSN&&d.advanced){var n=this.hls.config.lowLatencyMode,l=d.lastPartSn,p=d.endSN,g=d.lastPartIndex,v=l===p;g!==-1?(s=v?p+1:l,u=v?n?0:g:g+1):s=p+1;var r=d.age,i=r+d.ageHeader,c=Math.min(i-d.partTarget,1.5*d.targetduration);if(c>0){if(E&&c>E.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+E.tuneInGoal+" to: "+c+" with playlist age: "+d.age),c=0;else{var S=Math.floor(c/d.targetduration);s+=S,u!==void 0&&(u+=Math.round(c%d.targetduration/d.partTarget)),this.log("CDN Tune-in age: "+d.ageHeader+"s last advanced "+r.toFixed(2)+"s goal: "+c+" skip sn "+S+" to part "+u)}d.tuneInGoal=c}if(e=this.getDeliveryDirectives(d,h.deliveryDirectives,s,u),n||!v)return void this.loadPlaylist(e)}else e=this.getDeliveryDirectives(d,h.deliveryDirectives,s,u);var b=Object(A.computeReloadInterval)(d,t);s!==void 0&&d.canBlockReload&&(b-=d.partTarget||1),this.log("reload live playlist "+m+" in "+Math.round(b)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(e)},b)}else this.clearTimer()},L.getDeliveryDirectives=function(m,h,E,y){var d=Object(T.getSkipValue)(m,E);return h!=null&&h.skip&&m.deltaUpdateFailed&&(E=h.msn,y=h.part,d=T.HlsSkip.No),new T.HlsUrlParameters(E,y,d)},L.retryLoadingOrFail=function(m){var h,E=this,y=this.hls.config,d=this.retryCount-1&&(h=m.context)!==null&&h!==void 0&&h.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+m.details+'"'),this.loadPlaylist();else{var t=Math.min(Math.pow(2,this.retryCount)*y.levelLoadingRetryDelay,y.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return E.loadPlaylist()},t),this.warn("retry playlist loading #"+this.retryCount+" in "+t+' ms after "'+m.details+'"')}else this.warn('cannot recover from error "'+m.details+'"'),this.clearTimer(),m.fatal=!0;return d},o}()},"./src/controller/base-stream-controller.ts":function(N,w,f){f.r(w),f.d(w,"State",function(){return n}),f.d(w,"default",function(){return l});var _=f("./src/polyfills/number.ts"),T=f("./src/task-loop.ts"),A=f("./src/controller/fragment-tracker.ts"),R=f("./src/utils/buffer-helper.ts"),I=f("./src/utils/logger.ts"),k=f("./src/events.ts"),o=f("./src/errors.ts"),L=f("./src/types/transmuxer.ts"),m=f("./src/utils/mp4-tools.ts"),h=f("./src/utils/discontinuities.ts"),E=f("./src/controller/fragment-finders.ts"),y=f("./src/controller/level-helper.ts"),d=f("./src/loader/fragment-loader.ts"),t=f("./src/crypt/decrypter.ts"),a=f("./src/utils/time-ranges.ts"),e=f("./src/types/loader.ts");function s(p,g){for(var v=0;vD.start+D.duration+M;(P0&&P&&P.key&&P.iv&&P.method==="AES-128"){var F=self.performance.now();return D.decrypter.webCryptoDecrypt(new Uint8Array(x),P.key.buffer,P.iv.buffer).then(function(M){var B=self.performance.now();return C.trigger(k.Events.FRAG_DECRYPTED,{frag:b,payload:M,stats:{tstart:F,tdecrypt:B}}),O.payload=M,O})}return O}).then(function(O){var C=D.fragCurrent,x=D.hls,P=D.levels;if(!P)throw new Error("init load aborted, missing levels");var F=P[b.level].details;console.assert(F,"Level details are defined when init segment is loaded");var M=b.stats;D.state=n.IDLE,D.fragLoadError=0,b.data=new Uint8Array(O.payload),M.parsing.start=M.buffering.start=self.performance.now(),M.parsing.end=M.buffering.end=self.performance.now(),O.frag===C&&x.trigger(k.Events.FRAG_BUFFERED,{stats:M,frag:C,part:null,id:b.type}),D.tick()}).catch(function(O){D.warn(O),D.resetFragmentLoading(b)})},S.fragContextChanged=function(b){var D=this.fragCurrent;return!b||!D||b.level!==D.level||b.sn!==D.sn||b.urlId!==D.urlId},S.fragBufferedComplete=function(b,D){var O=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+b.type+" sn: "+b.sn+(D?" part: "+D.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+b.level+" "+a.default.toString(R.BufferHelper.getBuffered(O))),this.state=n.IDLE,this.tick()},S._handleFragmentLoadComplete=function(b){var D=this.transmuxer;if(D){var O=b.frag,C=b.part,x=b.partsLoaded,P=!x||x.length===0||x.some(function(M){return!M}),F=new L.ChunkMetadata(O.level,O.sn,O.stats.chunkCount+1,0,C?C.index:-1,!P);D.flush(F)}},S._handleFragmentLoadProgress=function(b){},S._doFragLoad=function(b,D,O,C){var x=this;if(O===void 0&&(O=null),!this.levels)throw new Error("frag load aborted, missing levels");if(O=Math.max(b.start,O||0),this.config.lowLatencyMode&&D){var P=D.partList;if(P&&C){O>b.end&&D.fragmentHint&&(b=D.fragmentHint);var F=this.getNextPart(P,b,O);if(F>-1){var M=P[F];return this.log("Loading part sn: "+b.sn+" p: "+M.index+" cc: "+b.cc+" of playlist ["+D.startSN+"-"+D.endSN+"] parts [0-"+F+"-"+(P.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(O.toFixed(3))),this.nextLoadPosition=M.start+M.duration,this.state=n.FRAG_LOADING,this.hls.trigger(k.Events.FRAG_LOADING,{frag:b,part:P[F],targetBufferTime:O}),this.doFragPartsLoad(b,P,F,C).catch(function(B){return x.handleFragLoadError(B)})}if(!b.url||this.loadedEndOfParts(P,O))return Promise.resolve(null)}}return this.log("Loading fragment "+b.sn+" cc: "+b.cc+" "+(D?"of ["+D.startSN+"-"+D.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+b.level+", target: "+parseFloat(O.toFixed(3))),Object(_.isFiniteNumber)(b.sn)&&!this.bitrateTest&&(this.nextLoadPosition=b.start+b.duration),this.state=n.FRAG_LOADING,this.hls.trigger(k.Events.FRAG_LOADING,{frag:b,targetBufferTime:O}),this.fragmentLoader.load(b,C).catch(function(B){return x.handleFragLoadError(B)})},S.doFragPartsLoad=function(b,D,O,C){var x=this;return new Promise(function(P,F){var M=[];(function B(U){var G=D[U];x.fragmentLoader.loadPart(b,G,C).then(function(K){M[G.index]=K;var H=K.part;x.hls.trigger(k.Events.FRAG_LOADED,K);var Y=D[U+1];if(!Y||Y.fragment!==b)return P({frag:b,part:H,partsLoaded:M});B(U+1)}).catch(F)})(O)})},S.handleFragLoadError=function(b){var D=b.data;return D&&D.details===o.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(D.frag,D.part):this.hls.trigger(k.Events.ERROR,D),null},S._handleTransmuxerFlush=function(b){var D=this.getCurrentContext(b);if(D&&this.state===n.PARSING){var O=D.frag,C=D.part,x=D.level,P=self.performance.now();O.stats.parsing.end=P,C&&(C.stats.parsing.end=P),this.updateLevelTiming(O,C,x,b.partial)}else this.fragCurrent||(this.state=n.IDLE)},S.getCurrentContext=function(b){var D=this.levels,O=b.level,C=b.sn,x=b.part;if(!D||!D[O])return this.warn("Levels object was unset while buffering fragment "+C+" of level "+O+". The current chunk will not be buffered."),null;var P=D[O],F=x>-1?Object(y.getPartWith)(P,C,x):null,M=F?F.fragment:Object(y.getFragmentWithSN)(P,C,this.fragCurrent);return M?{frag:M,part:F,level:P}:null},S.bufferFragmentData=function(b,D,O,C){if(b&&this.state===n.PARSING){var x=b.data1,P=b.data2,F=x;if(x&&P&&(F=Object(m.appendUint8Array)(x,P)),F&&F.length){var M={type:b.type,frag:D,part:O,chunkMeta:C,parent:D.type,data:F};this.hls.trigger(k.Events.BUFFER_APPENDING,M),b.dropped&&b.independent&&!O&&this.flushBufferGap(D)}}},S.flushBufferGap=function(b){var D=this.media;if(D)if(R.BufferHelper.isBuffered(D,D.currentTime)){var O=D.currentTime,C=R.BufferHelper.bufferInfo(D,O,0),x=b.duration,P=Math.min(2*this.config.maxFragLookUpTolerance,.25*x),F=Math.max(Math.min(b.start-P,C.end-P),O+P);b.start-F>P&&this.flushMainBuffer(F,b.start)}else this.flushMainBuffer(0,b.start)},S.getFwdBufferInfo=function(b,D){var O=this.config,C=this.getLoadPosition();if(!Object(_.isFiniteNumber)(C))return null;var x=R.BufferHelper.bufferInfo(b,C,O.maxBufferHole);if(x.len===0&&x.nextStart!==void 0){var P=this.fragmentTracker.getBufferedFrag(C,D);if(P&&x.nextStart=O&&(D.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+D.maxMaxBufferLength+"s"),!0)},S.getNextFragment=function(b,D){var O,C,x=D.fragments,P=x.length;if(!P)return null;var F,M=this.config,B=x[0].start;if(D.live){var U=M.initialLiveManifestSize;if(P-1&&OO.start&&O.loaded},S.getInitialLiveFragment=function(b,D){var O=this.fragPrevious,C=null;if(O){if(b.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+O.programDateTime),C=Object(E.findFragmentByPDT)(D,O.endProgramDateTime,this.config.maxFragLookUpTolerance)),!C){var x=O.sn+1;if(x>=b.startSN&&x<=b.endSN){var P=D[x-b.startSN];O.cc===P.cc&&(C=P,this.log("Live playlist, switching playlist, load frag with next SN: "+C.sn))}C||(C=Object(E.findFragWithCC)(D,O.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+C.sn)}}else{var F=this.hls.liveSyncPosition;F!==null&&(C=this.getFragmentAtPosition(F,this.bitrateTest?b.fragmentEnd:b.edge,b))}return C},S.getFragmentAtPosition=function(b,D,O){var C,x=this.config,P=this.fragPrevious,F=O.fragments,M=O.endSN,B=O.fragmentHint,U=x.maxFragLookUpTolerance,G=!!(x.lowLatencyMode&&O.partList&&B);if(G&&B&&!this.bitrateTest&&(F=F.concat(B),M=B.sn),bD-U?0:U;C=Object(E.findFragmentByPTS)(P,F,b,K)}else C=F[F.length-1];if(C){var H=C.sn-O.startSN,Y=P&&C.level===P.level,W=F[H+1];if(this.fragmentTracker.getState(C)===A.FragmentState.BACKTRACKED){C=null;for(var q=H;F[q]&&this.fragmentTracker.getState(F[q])===A.FragmentState.BACKTRACKED;)C=P?F[q--]:F[--q];C||(C=W)}else P&&C.sn===P.sn&&!G&&Y&&(C.sn=P-D.maxFragLookUpTolerance&&x<=F;if(C!==null&&O.duration>C&&(x"+b.startSN+" prev-sn: "+(x?x.sn:"na")+" fragments: "+F),G}return M},S.waitForCdnTuneIn=function(b){return b.live&&b.canBlockReload&&b.tuneInGoal>Math.max(b.partHoldBack,3*b.partTarget)},S.setStartPosition=function(b,D){var O=this.startPosition;if(O"+b))}}])&&s(i.prototype,c),r}(T.default)},"./src/controller/buffer-controller.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return E});var _=f("./src/polyfills/number.ts"),T=f("./src/events.ts"),A=f("./src/utils/logger.ts"),R=f("./src/errors.ts"),I=f("./src/utils/buffer-helper.ts"),k=f("./src/utils/mediasource-helper.ts"),o=f("./src/loader/fragment.ts"),L=f("./src/controller/buffer-operation-queue.ts"),m=Object(k.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,E=function(){function y(t){var a=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var e=a.hls,s=a.media,u=a.mediaSource;A.logger.log("[buffer-controller]: Media source opened"),s&&(a.updateMediaElementDuration(),e.trigger(T.Events.MEDIA_ATTACHED,{media:s})),u&&u.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){A.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){A.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var d=y.prototype;return d.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},d.destroy=function(){this.unregisterListeners(),this.details=null},d.registerListeners=function(){var t=this.hls;t.on(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(T.Events.BUFFER_RESET,this.onBufferReset,this),t.on(T.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(T.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(T.Events.BUFFER_EOS,this.onBufferEos,this),t.on(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(T.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(T.Events.FRAG_PARSED,this.onFragParsed,this),t.on(T.Events.FRAG_CHANGED,this.onFragChanged,this)},d.unregisterListeners=function(){var t=this.hls;t.off(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(T.Events.BUFFER_RESET,this.onBufferReset,this),t.off(T.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(T.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(T.Events.BUFFER_EOS,this.onBufferEos,this),t.off(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(T.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(T.Events.FRAG_PARSED,this.onFragParsed,this),t.off(T.Events.FRAG_CHANGED,this.onFragChanged,this)},d._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new L.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},d.onManifestParsed=function(t,a){var e=2;(a.audio&&!a.video||!a.altAudio)&&(e=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e,this.details=null,A.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},d.onMediaAttaching=function(t,a){var e=this.media=a.media;if(e&&m){var s=this.mediaSource=new m;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),e.src=self.URL.createObjectURL(s),this._objectUrl=e.src}},d.onMediaDetaching=function(){var t=this.media,a=this.mediaSource,e=this._objectUrl;if(a){if(A.logger.log("[buffer-controller]: media source detaching"),a.readyState==="open")try{a.endOfStream()}catch(s){A.logger.warn("[buffer-controller]: onMediaDetaching: "+s.message+" while calling endOfStream")}this.onBufferReset(),a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(e&&self.URL.revokeObjectURL(e),t.src===e?(t.removeAttribute("src"),t.load()):A.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(T.Events.MEDIA_DETACHED,void 0)},d.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach(function(a){var e=t.sourceBuffer[a];try{e&&(t.removeBufferListeners(a),t.mediaSource&&t.mediaSource.removeSourceBuffer(e),t.sourceBuffer[a]=void 0)}catch(s){A.logger.warn("[buffer-controller]: Failed to reset the "+a+" buffer",s)}}),this._initSourceBuffer()},d.onBufferCodecs=function(t,a){var e=this,s=this.getSourceBufferTypes().length;Object.keys(a).forEach(function(u){if(s){var n=e.tracks[u];if(n&&typeof n.buffer.changeType=="function"){var l=a[u],p=l.codec,g=l.levelCodec,v=l.container;if((n.levelCodec||n.codec).replace(h,"$1")!==(g||p).replace(h,"$1")){var r=v+";codecs="+(g||p);e.appendChangeType(u,r)}}}else e.pendingTracks[u]=a[u]}),s||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},d.appendChangeType=function(t,a){var e=this,s=this.operationQueue,u={execute:function(){var n=e.sourceBuffer[t];n&&(A.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+a),n.changeType(a)),s.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(n){A.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",n)}};s.append(u,t)},d.onBufferAppending=function(t,a){var e=this,s=this.hls,u=this.operationQueue,n=this.tracks,l=a.data,p=a.type,g=a.frag,v=a.part,r=a.chunkMeta,i=r.buffering[p],c=self.performance.now();i.start=c;var S=g.stats.buffering,b=v?v.stats.buffering:null;S.start===0&&(S.start=c),b&&b.start===0&&(b.start=c);var D=n.audio,O=p==="audio"&&r.id===1&&(D==null?void 0:D.container)==="audio/mpeg",C={execute:function(){if(i.executeStart=self.performance.now(),O){var x=e.sourceBuffer[p];if(x){var P=g.start-x.timestampOffset;Math.abs(P)>=.1&&(A.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+g.start+" (delta: "+P+") sn: "+g.sn+")"),x.timestampOffset=g.start)}}e.appendExecutor(l,p)},onStart:function(){},onComplete:function(){var x=self.performance.now();i.executeEnd=i.end=x,S.first===0&&(S.first=x),b&&b.first===0&&(b.first=x);var P=e.sourceBuffer,F={};for(var M in P)F[M]=I.BufferHelper.getBuffered(P[M]);e.appendError=0,e.hls.trigger(T.Events.BUFFER_APPENDED,{type:p,frag:g,part:v,chunkMeta:r,parent:g.type,timeRanges:F})},onError:function(x){A.logger.error("[buffer-controller]: Error encountered while trying to append to the "+p+" SourceBuffer",x);var P={type:R.ErrorTypes.MEDIA_ERROR,parent:g.type,details:R.ErrorDetails.BUFFER_APPEND_ERROR,err:x,fatal:!1};x.code===DOMException.QUOTA_EXCEEDED_ERR?P.details=R.ErrorDetails.BUFFER_FULL_ERROR:(e.appendError++,P.details=R.ErrorDetails.BUFFER_APPEND_ERROR,e.appendError>s.config.appendErrorMaxRetry&&(A.logger.error("[buffer-controller]: Failed "+s.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),P.fatal=!0)),s.trigger(T.Events.ERROR,P)}};u.append(C,p)},d.onBufferFlushing=function(t,a){var e=this,s=this.operationQueue,u=function(n){return{execute:e.removeExecutor.bind(e,n,a.startOffset,a.endOffset),onStart:function(){},onComplete:function(){e.hls.trigger(T.Events.BUFFER_FLUSHED,{type:n})},onError:function(l){A.logger.warn("[buffer-controller]: Failed to remove from "+n+" SourceBuffer",l)}}};a.type?s.append(u(a.type),a.type):this.getSourceBufferTypes().forEach(function(n){s.append(u(n),n)})},d.onFragParsed=function(t,a){var e=this,s=a.frag,u=a.part,n=[],l=u?u.elementaryStreams:s.elementaryStreams;l[o.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(l[o.ElementaryStreamTypes.AUDIO]&&n.push("audio"),l[o.ElementaryStreamTypes.VIDEO]&&n.push("video")),n.length===0&&A.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+s.type+" level: "+s.level+" sn: "+s.sn),this.blockBuffers(function(){var p=self.performance.now();s.stats.buffering.end=p,u&&(u.stats.buffering.end=p);var g=u?u.stats:s.stats;e.hls.trigger(T.Events.FRAG_BUFFERED,{frag:s,part:u,stats:g,id:s.type})},n)},d.onFragChanged=function(t,a){this.flushBackBuffer()},d.onBufferEos=function(t,a){var e=this;this.getSourceBufferTypes().reduce(function(s,u){var n=e.sourceBuffer[u];return a.type&&a.type!==u||n&&!n.ended&&(n.ended=!0,A.logger.log("[buffer-controller]: "+u+" sourceBuffer now EOS")),s&&!(n&&!n.ended)},!0)&&this.blockBuffers(function(){var s=e.mediaSource;s&&s.readyState==="open"&&s.endOfStream()})},d.onLevelUpdated=function(t,a){var e=a.details;e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},d.flushBackBuffer=function(){var t=this.hls,a=this.details,e=this.media,s=this.sourceBuffer;if(e&&a!==null){var u=this.getSourceBufferTypes();if(u.length){var n=a.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(_.isFiniteNumber)(n)&&!(n<0)){var l=e.currentTime,p=a.levelTargetDuration,g=Math.max(n,p),v=Math.floor(l/p)*p-g;u.forEach(function(r){var i=s[r];if(i){var c=I.BufferHelper.getBuffered(i);c.length>0&&v>c.start(0)&&(t.trigger(T.Events.BACK_BUFFER_REACHED,{bufferEnd:v}),a.live&&t.trigger(T.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:v}),t.trigger(T.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:v,type:r}))}})}}}},d.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var t=this.details,a=this.hls,e=this.media,s=this.mediaSource,u=t.fragments[0].start+t.totalduration,n=e.duration,l=Object(_.isFiniteNumber)(s.duration)?s.duration:0;t.live&&a.config.liveDurationInfinity?(A.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(t)):(u>l&&u>n||!Object(_.isFiniteNumber)(n))&&(A.logger.log("[buffer-controller]: Updating Media Source duration to "+u.toFixed(3)),s.duration=u)}},d.updateSeekableRange=function(t){var a=this.mediaSource,e=t.fragments;if(e.length&&t.live&&a!=null&&a.setLiveSeekableRange){var s=Math.max(0,e[0].start),u=Math.max(s,s+t.totalduration);a.setLiveSeekableRange(s,u)}},d.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,a=this.operationQueue,e=this.pendingTracks,s=Object.keys(e).length;if(s&&!t||s===2){this.createSourceBuffers(e),this.pendingTracks={};var u=this.getSourceBufferTypes();if(u.length===0)return void this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});u.forEach(function(n){a.executeNext(n)})}},d.createSourceBuffers=function(t){var a=this.sourceBuffer,e=this.mediaSource;if(!e)throw Error("createSourceBuffers called when mediaSource was null");var s=0;for(var u in t)if(!a[u]){var n=t[u];if(!n)throw Error("source buffer exists for track "+u+", however track does not");var l=n.levelCodec||n.codec,p=n.container+";codecs="+l;A.logger.log("[buffer-controller]: creating sourceBuffer("+p+")");try{var g=a[u]=e.addSourceBuffer(p),v=u;this.addBufferListener(v,"updatestart",this._onSBUpdateStart),this.addBufferListener(v,"updateend",this._onSBUpdateEnd),this.addBufferListener(v,"error",this._onSBUpdateError),this.tracks[u]={buffer:g,codec:l,container:n.container,levelCodec:n.levelCodec,id:n.id},s++}catch(r){A.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+r.message),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:r,mimeType:p})}}s&&this.hls.trigger(T.Events.BUFFER_CREATED,{tracks:this.tracks})},d._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},d._onSBUpdateEnd=function(t){var a=this.operationQueue;a.current(t).onComplete(),a.shiftAndExecuteNext(t)},d._onSBUpdateError=function(t,a){A.logger.error("[buffer-controller]: "+t+" SourceBuffer error",a),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var e=this.operationQueue.current(t);e&&e.onError(a)},d.removeExecutor=function(t,a,e){var s=this.media,u=this.mediaSource,n=this.operationQueue,l=this.sourceBuffer[t];if(!s||!u||!l)return A.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(t);var p=Object(_.isFiniteNumber)(s.duration)?s.duration:1/0,g=Object(_.isFiniteNumber)(u.duration)?u.duration:1/0,v=Math.max(0,a),r=Math.min(e,p,g);r>v?(A.logger.log("[buffer-controller]: Removing ["+v+","+r+"] from the "+t+" SourceBuffer"),console.assert(!l.updating,t+" sourceBuffer must not be updating"),l.remove(v,r)):n.shiftAndExecuteNext(t)},d.appendExecutor=function(t,a){var e=this.operationQueue,s=this.sourceBuffer[a];if(!s)return A.logger.warn("[buffer-controller]: Attempting to append to the "+a+" SourceBuffer, but it does not exist"),void e.shiftAndExecuteNext(a);s.ended=!1,console.assert(!s.updating,a+" sourceBuffer must not be updating"),s.appendBuffer(t)},d.blockBuffers=function(t,a){var e=this;if(a===void 0&&(a=this.getSourceBufferTypes()),!a.length)return A.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve(t);var s=this.operationQueue,u=a.map(function(n){return s.appendBlocker(n)});Promise.all(u).then(function(){t(),a.forEach(function(n){var l=e.sourceBuffer[n];l&&l.updating||s.shiftAndExecuteNext(n)})})},d.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},d.addBufferListener=function(t,a,e){var s=this.sourceBuffer[t];if(s){var u=e.bind(this,t);this.listeners[t].push({event:a,listener:u}),s.addEventListener(a,u)}},d.removeBufferListeners=function(t){var a=this.sourceBuffer[t];a&&this.listeners[t].forEach(function(e){a.removeEventListener(e.event,e.listener)})},y}()},"./src/controller/buffer-operation-queue.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return T});var _=f("./src/utils/logger.ts"),T=function(){function A(I){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=I}var R=A.prototype;return R.append=function(I,k){var o=this.queues[k];o.push(I),o.length===1&&this.buffers[k]&&this.executeNext(k)},R.insertAbort=function(I,k){this.queues[k].unshift(I),this.executeNext(k)},R.appendBlocker=function(I){var k,o=new Promise(function(m){k=m}),L={execute:k,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(L,I),o},R.executeNext=function(I){var k=this.buffers,o=this.queues,L=k[I],m=o[I];if(m.length){var h=m[0];try{h.execute()}catch(E){_.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),h.onError(E),L&&L.updating||(m.shift(),this.executeNext(I))}}},R.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},R.current=function(I){return this.queues[I][0]},A}()},"./src/controller/cap-level-controller.ts":function(N,w,f){f.r(w);var _=f("./src/events.ts");function T(R,I){for(var k=0;k0&&this.mediaWidth>0){var m=this.hls.levels;if(m.length){var h=this.hls;h.autoLevelCapping=this.getMaxLevel(m.length-1),h.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=h.autoLevelCapping}}},L.getMaxLevel=function(m){var h=this,E=this.hls.levels;if(!E.length)return-1;var y=E.filter(function(d,t){return R.isLevelAllowed(t,h.restrictedLevels)&&t<=m});return this.clientRect=null,R.getMaxLevelByMediaSize(y,this.mediaWidth,this.mediaHeight)},L.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},L.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},L.getDimensions=function(){if(this.clientRect)return this.clientRect;var m=this.media,h={width:0,height:0};if(m){var E=m.getBoundingClientRect();h.width=E.width,h.height=E.height,h.width||h.height||(h.width=E.right-E.left||m.width||0,h.height=E.bottom-E.top||m.height||0)}return this.clientRect=h,h},R.isLevelAllowed=function(m,h){return h===void 0&&(h=[]),h.indexOf(m)===-1},R.getMaxLevelByMediaSize=function(m,h,E){if(!m||!m.length)return-1;for(var y,d,t=m.length-1,a=0;a=h||e.height>=E)&&(y=e,!(d=m[a+1])||y.width!==d.width||y.height!==d.height)){t=a;break}}return t},I=R,o=[{key:"contentScaleFactor",get:function(){var m=1;try{m=self.devicePixelRatio}catch{}return m}}],(k=[{key:"mediaWidth",get:function(){return this.getDimensions().width*R.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*R.contentScaleFactor}}])&&T(I.prototype,k),o&&T(I,o),R}();w.default=A},"./src/controller/eme-controller.ts":function(N,w,f){f.r(w);var _=f("./src/events.ts"),T=f("./src/errors.ts"),A=f("./src/utils/logger.ts"),R=f("./src/utils/mediakeys-helper.ts");function I(o,L){for(var m=0;m3)return void this.hls.trigger(_.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var s=3-this._requestLicenseFailureCount+1;A.logger.warn("Retrying license request, "+s+" attempts left"),this._requestLicense(d,t)}}},h._generateLicenseRequestChallenge=function(E,y){switch(E.mediaKeySystemDomain){case R.KeySystems.WIDEVINE:return y}throw new Error("unsupported key-system: "+E.mediaKeySystemDomain)},h._requestLicense=function(E,y){A.logger.log("Requesting content license for key-system");var d=this._mediaKeysList[0];if(!d)return A.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(_.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var t=this.getLicenseServerUrl(d.mediaKeySystemDomain),a=this._createLicenseXhr(t,E,y);A.logger.log("Sending license request to URL: "+t);var e=this._generateLicenseRequestChallenge(d,E);a.send(e)}catch(s){A.logger.error("Failure requesting DRM license: "+s),this.hls.trigger(_.Events.ERROR,{type:T.ErrorTypes.KEY_SYSTEM_ERROR,details:T.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},h.onMediaAttached=function(E,y){if(this._emeEnabled){var d=y.media;this._media=d,d.addEventListener("encrypted",this._onMediaEncrypted)}},h.onMediaDetached=function(){var E=this._media,y=this._mediaKeysList;E&&(E.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(y.map(function(d){if(d.mediaKeysSession)return d.mediaKeysSession.close().catch(function(){})})).then(function(){return E.setMediaKeys(null)}).catch(function(){}))},h.onManifestParsed=function(E,y){if(this._emeEnabled){var d=y.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),t=y.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(R.KeySystems.WIDEVINE,d,t)}},L=o,(m=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&I(L.prototype,m),o}();w.default=k},"./src/controller/fps-controller.ts":function(N,w,f){f.r(w);var _=f("./src/events.ts"),T=f("./src/utils/logger.ts"),A=function(){function R(k){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=k,this.registerListeners()}var I=R.prototype;return I.setStreamController=function(k){this.streamController=k},I.registerListeners=function(){this.hls.on(_.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},I.unregisterListeners=function(){this.hls.off(_.Events.MEDIA_ATTACHING,this.onMediaAttaching)},I.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},I.onMediaAttaching=function(k,o){var L=this.hls.config;if(L.capLevelOnFPSDrop){var m=o.media instanceof self.HTMLVideoElement?o.media:null;this.media=m,m&&typeof m.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),L.fpsDroppedMonitoringPeriod)}},I.checkFPS=function(k,o,L){var m=performance.now();if(o){if(this.lastTime){var h=m-this.lastTime,E=L-this.lastDroppedFrames,y=o-this.lastDecodedFrames,d=1e3*E/h,t=this.hls;if(t.trigger(_.Events.FPS_DROP,{currentDropped:E,currentDecoded:y,totalDroppedFrames:L}),d>0&&E>t.config.fpsDroppedMonitoringThreshold*y){var a=t.currentLevel;T.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),a>0&&(t.autoLevelCapping===-1||t.autoLevelCapping>=a)&&(a-=1,t.trigger(_.Events.FPS_DROP_LEVEL_CAPPING,{level:a,droppedLevel:t.currentLevel}),t.autoLevelCapping=a,this.streamController.nextLevelSwitch())}}this.lastTime=m,this.lastDroppedFrames=L,this.lastDecodedFrames=o}},I.checkFPSInterval=function(){var k=this.media;if(k)if(this.isVideoPlaybackQualityAvailable){var o=k.getVideoPlaybackQuality();this.checkFPS(k,o.totalVideoFrames,o.droppedVideoFrames)}else this.checkFPS(k,k.webkitDecodedFrameCount,k.webkitDroppedFrameCount)},R}();w.default=A},"./src/controller/fragment-finders.ts":function(N,w,f){f.r(w),f.d(w,"findFragmentByPDT",function(){return A}),f.d(w,"findFragmentByPTS",function(){return R}),f.d(w,"fragmentWithinToleranceTest",function(){return I}),f.d(w,"pdtWithinToleranceTest",function(){return k}),f.d(w,"findFragWithCC",function(){return o});var _=f("./src/polyfills/number.ts"),T=f("./src/utils/binary-search.ts");function A(L,m,h){if(m===null||!Array.isArray(L)||!L.length||!Object(_.isFiniteNumber)(m)||m<(L[0].programDateTime||0)||m>=(L[L.length-1].endProgramDateTime||0))return null;h=h||0;for(var E=0;EL&&h.start?-1:0}function k(L,m,h){var E=1e3*Math.min(m,h.duration+(h.deltaPTS?h.deltaPTS:0));return(h.endProgramDateTime||0)-E>L}function o(L,m){return T.default.search(L,function(h){return h.ccm?-1:0})}},"./src/controller/fragment-tracker.ts":function(N,w,f){f.r(w),f.d(w,"FragmentState",function(){return _}),f.d(w,"FragmentTracker",function(){return I});var _,T,A=f("./src/events.ts"),R=f("./src/types/loader.ts");(T=_||(_={})).NOT_LOADED="NOT_LOADED",T.BACKTRACKED="BACKTRACKED",T.APPENDING="APPENDING",T.PARTIAL="PARTIAL",T.OK="OK";var I=function(){function L(h){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=h,this._registerListeners()}var m=L.prototype;return m._registerListeners=function(){var h=this.hls;h.on(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),h.on(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.on(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m._unregisterListeners=function(){var h=this.hls;h.off(A.Events.BUFFER_APPENDED,this.onBufferAppended,this),h.off(A.Events.FRAG_BUFFERED,this.onFragBuffered,this),h.off(A.Events.FRAG_LOADED,this.onFragLoaded,this)},m.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},m.getAppendedFrag=function(h,E){if(E===R.PlaylistLevelType.MAIN){var y=this.activeFragment,d=this.activeParts;if(!y)return null;if(d)for(var t=d.length;t--;){var a=d[t],e=a?a.end:y.appendedPTS;if(a.start<=h&&e!==void 0&&h<=e)return t>9&&(this.activeParts=d.slice(t-9)),a}else if(y.start<=h&&y.appendedPTS!==void 0&&h<=y.appendedPTS)return y}return this.getBufferedFrag(h,E)},m.getBufferedFrag=function(h,E){for(var y=this.fragments,d=Object.keys(y),t=d.length;t--;){var a=y[d[t]];if((a==null?void 0:a.body.type)===E&&a.buffered){var e=a.body;if(e.start<=h&&h<=e.end)return e}}return null},m.detectEvictedFragments=function(h,E,y){var d=this;Object.keys(this.fragments).forEach(function(t){var a=d.fragments[t];if(a)if(a.buffered){var e=a.range[h];e&&e.time.some(function(s){var u=!d.isTimeBuffered(s.startPTS,s.endPTS,E);return u&&d.removeFragment(a.body),u})}else a.body.type===y&&d.removeFragment(a.body)})},m.detectPartialFragments=function(h){var E=this,y=this.timeRanges,d=h.frag,t=h.part;if(y&&d.sn!=="initSegment"){var a=o(d),e=this.fragments[a];e&&(Object.keys(y).forEach(function(s){var u=d.elementaryStreams[s];if(u){var n=y[s],l=t!==null||u.partial===!0;e.range[s]=E.getBufferedTimes(d,t,l,n)}}),e.backtrack=e.loaded=null,Object.keys(e.range).length?e.buffered=!0:this.removeFragment(e.body))}},m.fragBuffered=function(h){var E=o(h),y=this.fragments[E];y&&(y.backtrack=y.loaded=null,y.buffered=!0)},m.getBufferedTimes=function(h,E,y,d){for(var t={time:[],partial:y},a=E?E.start:h.start,e=E?E.end:h.end,s=h.minEndPTS||e,u=h.maxStartPTS||a,n=0;n=l&&s<=p){t.time.push({startPTS:Math.max(a,d.start(n)),endPTS:Math.min(e,d.end(n))});break}if(al)t.partial=!0,t.time.push({startPTS:Math.max(a,d.start(n)),endPTS:Math.min(e,d.end(n))});else if(e<=l)break}return t},m.getPartialFragment=function(h){var E,y,d,t=null,a=0,e=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(function(u){var n=s[u];n&&k(n)&&(y=n.body.start-e,d=n.body.end+e,h>=y&&h<=d&&(E=Math.min(h-y,d-h),a<=E&&(t=n.body,a=E)))}),t},m.getState=function(h){var E=o(h),y=this.fragments[E];return y?y.buffered?k(y)?_.PARTIAL:_.OK:y.backtrack?_.BACKTRACKED:_.APPENDING:_.NOT_LOADED},m.backtrack=function(h,E){var y=o(h),d=this.fragments[y];if(!d||d.backtrack)return null;var t=d.backtrack=E||d.loaded;return d.loaded=null,t},m.getBacktrackData=function(h){var E=o(h),y=this.fragments[E];if(y){var d,t=y.backtrack;if(t!=null&&(d=t.payload)!==null&&d!==void 0&&d.byteLength)return t;this.removeFragment(h)}return null},m.isTimeBuffered=function(h,E,y){for(var d,t,a=0;a=d&&E<=t)return!0;if(E<=d)return!1}return!1},m.onFragLoaded=function(h,E){var y=E.frag,d=E.part;if(y.sn!=="initSegment"&&!y.bitrateTest&&!d){var t=o(y);this.fragments[t]={body:y,loaded:E,backtrack:null,buffered:!1,range:Object.create(null)}}},m.onBufferAppended=function(h,E){var y=this,d=E.frag,t=E.part,a=E.timeRanges;if(d.type===R.PlaylistLevelType.MAIN)if(this.activeFragment=d,t){var e=this.activeParts;e||(this.activeParts=e=[]),e.push(t)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(s){var u=a[s];if(y.detectEvictedFragments(s,u),!t)for(var n=0;nh&&d.removeFragment(e)}})},m.removeFragment=function(h){var E=o(h);h.stats.loaded=0,h.clearElementaryStreamInfo(),delete this.fragments[E]},m.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},L}();function k(L){var m,h;return L.buffered&&(((m=L.range.video)===null||m===void 0?void 0:m.partial)||((h=L.range.audio)===null||h===void 0?void 0:h.partial))}function o(L){return L.type+"_"+L.level+"_"+L.urlId+"_"+L.sn}},"./src/controller/gap-controller.ts":function(N,w,f){f.r(w),f.d(w,"STALL_MINIMUM_DURATION_MS",function(){return I}),f.d(w,"MAX_START_GAP_JUMP",function(){return k}),f.d(w,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return o}),f.d(w,"SKIP_BUFFER_RANGE_START",function(){return L}),f.d(w,"default",function(){return m});var _=f("./src/utils/buffer-helper.ts"),T=f("./src/errors.ts"),A=f("./src/events.ts"),R=f("./src/utils/logger.ts"),I=250,k=2,o=.1,L=.05,m=function(){function h(y,d,t,a){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=y,this.media=d,this.fragmentTracker=t,this.hls=a}var E=h.prototype;return E.destroy=function(){this.hls=this.fragmentTracker=this.media=null},E.poll=function(y){var d=this.config,t=this.media,a=this.stalled,e=t.currentTime,s=t.seeking,u=this.seeking&&!s,n=!this.seeking&&s;if(this.seeking=s,e===y){if((n||u)&&(this.stalled=null),!t.paused&&!t.ended&&t.playbackRate!==0&&_.BufferHelper.getBuffered(t).length){var l=_.BufferHelper.bufferInfo(t,e,0),p=l.len>0,g=l.nextStart||0;if(p||g){if(s){var v=l.len>k,r=!g||g-e>k&&!this.fragmentTracker.getPartialFragment(e);if(v||r)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var i,c=Math.max(g,l.start||0)-e,S=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,b=!(S==null||(i=S.details)===null||i===void 0)&&i.live?2*S.details.targetduration:k;if(c>0&&c<=b)return void this._trySkipBufferHole(null)}var D=self.performance.now();if(a!==null){var O=D-a;!s&&O>=I&&this._reportStall(l.len);var C=_.BufferHelper.bufferInfo(t,e,d.maxBufferHole);this._tryFixBufferStall(C,O)}else this.stalled=D}}}else if(this.moved=!0,a!==null){if(this.stallReported){var x=self.performance.now()-a;R.logger.warn("playback not stuck anymore @"+e+", after "+Math.round(x)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},E._tryFixBufferStall=function(y,d){var t=this.config,a=this.fragmentTracker,e=this.media.currentTime,s=a.getPartialFragment(e);s&&this._trySkipBufferHole(s)||y.len>t.maxBufferHole&&d>1e3*t.highBufferWatchdogPeriod&&(R.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},E._reportStall=function(y){var d=this.hls,t=this.media;this.stallReported||(this.stallReported=!0,R.logger.warn("Playback stalling at @"+t.currentTime+" due to low buffer (buffer="+y+")"),d.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y}))},E._trySkipBufferHole=function(y){for(var d=this.config,t=this.hls,a=this.media,e=a.currentTime,s=0,u=_.BufferHelper.getBuffered(a),n=0;n=s&&e.05&&this.forwardBufferLength>1){var n=Math.min(2,Math.max(1,a)),l=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20;h.playbackRate=Math.min(n,Math.max(1,l))}else h.playbackRate!==1&&h.playbackRate!==0&&(h.playbackRate=1)}}}}},m.estimateLiveEdge=function(){var h=this.levelDetails;return h===null?null:h.edge+h.age},m.computeLatency=function(){var h=this.estimateLiveEdge();return h===null?null:h-this.currentTime},o=k,(L=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var h=this.config,E=this.levelDetails;return h.liveMaxLatencyDuration!==void 0?h.liveMaxLatencyDuration:E?h.liveMaxLatencyDurationCount*E.targetduration:0}},{key:"targetLatency",get:function(){var h=this.levelDetails;if(h===null)return null;var E=h.holdBack,y=h.partHoldBack,d=h.targetduration,t=this.config,a=t.liveSyncDuration,e=t.liveSyncDurationCount,s=t.lowLatencyMode,u=this.hls.userConfig,n=s&&y||E;(u.liveSyncDuration||u.liveSyncDurationCount||n===0)&&(n=a!==void 0?a:e*d);var l=d;return n+Math.min(1*this.stallCount,l)}},{key:"liveSyncPosition",get:function(){var h=this.estimateLiveEdge(),E=this.targetLatency,y=this.levelDetails;if(h===null||E===null||y===null)return null;var d=y.edge,t=h-E-this.edgeStalled,a=d-y.totalduration,e=d-(this.config.lowLatencyMode&&y.partTarget||y.targetduration);return Math.min(Math.max(a,t),e)}},{key:"drift",get:function(){var h=this.levelDetails;return h===null?1:h.drift}},{key:"edgeStalled",get:function(){var h=this.levelDetails;if(h===null)return 0;var E=3*(this.config.lowLatencyMode&&h.partTarget||h.targetduration);return Math.max(h.age-E,0)}},{key:"forwardBufferLength",get:function(){var h=this.media,E=this.levelDetails;if(!h||!E)return 0;var y=h.buffered.length;return y?h.buffered.end(y-1):E.edge-this.currentTime}}])&&R(o.prototype,L),k}()},"./src/controller/level-controller.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return y});var _=f("./src/types/level.ts"),T=f("./src/events.ts"),A=f("./src/errors.ts"),R=f("./src/utils/codecs.ts"),I=f("./src/controller/level-helper.ts"),k=f("./src/controller/base-playlist-controller.ts"),o=f("./src/types/loader.ts");function L(){return(L=Object.assign||function(d){for(var t=1;t0){g=r[0].bitrate,r.sort(function(F,M){return F.bitrate-M.bitrate}),this._levels=r;for(var C=0;Cthis.hls.config.fragLoadingMaxRetry&&(r=p.frag.level)):r=p.frag.level}break;case A.ErrorDetails.LEVEL_LOAD_ERROR:case A.ErrorDetails.LEVEL_LOAD_TIMEOUT:g&&(g.deliveryDirectives&&(c=!1),r=g.level),i=!0;break;case A.ErrorDetails.REMUX_ALLOC_ERROR:r=p.level,i=!0}r!==void 0&&this.recoverLevel(p,r,i,c)}}},n.recoverLevel=function(l,p,g,v){var r=l.details,i=this._levels[p];if(i.loadError++,g){if(!this.retryLoadingOrFail(l))return void(this.currentLevelIndex=-1);l.levelRetry=!0}if(v){var c=i.url.length;if(c>1&&i.loadError1){var v=(p.urlId+1)%g;this.warn("Switching to redundant URL-id "+v),this._levels.forEach(function(r){r.urlId=v}),this.level=l}},n.onFragLoaded=function(l,p){var g=p.frag;if(g!==void 0&&g.type===o.PlaylistLevelType.MAIN){var v=this._levels[g.level];v!==void 0&&(v.fragmentError=0,v.loadError=0)}},n.onLevelLoaded=function(l,p){var g,v,r=p.level,i=p.details,c=this._levels[r];if(!c)return this.warn("Invalid level index "+r),void((v=p.deliveryDirectives)!==null&&v!==void 0&&v.skip&&(i.deltaUpdateFailed=!0));r===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0,this.retryCount=0),this.playlistLoaded(r,p,c.details)):(g=p.deliveryDirectives)!==null&&g!==void 0&&g.skip&&(i.deltaUpdateFailed=!0)},n.onAudioTrackSwitched=function(l,p){var g=this.hls.levels[this.currentLevelIndex];if(g&&g.audioGroupIds){for(var v=-1,r=this.hls.audioTracks[p.id].groupId,i=0;i0){var v=g.urlId,r=g.url[v];if(l)try{r=l.addDirectives(r)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("Attempt loading level index "+p+(l?" at sn "+l.msn+" part "+l.part:"")+" with URL-id "+v+" "+r),this.clearTimer(),this.hls.trigger(T.Events.LEVEL_LOADING,{url:r,level:p,id:v,deliveryDirectives:l||null})}},n.removeLevel=function(l,p){var g=function(r,i){return i!==p},v=this._levels.filter(function(r,i){return i!==l||r.url.length>1&&p!==void 0&&(r.url=r.url.filter(g),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(g)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(g)),r.urlId=0,!0)}).map(function(r,i){var c=r.details;return c!=null&&c.fragments&&c.fragments.forEach(function(S){S.level=i}),r});this._levels=v,this.hls.trigger(T.Events.LEVELS_UPDATED,{levels:v})},s=e,(u=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(l){var p,g=this._levels;if(g.length!==0&&(this.currentLevelIndex!==l||(p=g[l])===null||p===void 0||!p.details)){if(l<0||l>=g.length){var v=l<0;if(this.hls.trigger(T.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.LEVEL_SWITCH_ERROR,level:l,fatal:v,reason:"invalid level idx"}),v)return;l=Math.min(l,g.length-1)}this.clearTimer();var r=this.currentLevelIndex,i=g[r],c=g[l];this.log("switching to level "+l+" from "+r),this.currentLevelIndex=l;var S=L({},c,{level:l,maxBitrate:c.maxBitrate,uri:c.uri,urlId:c.urlId});delete S._urlId,this.hls.trigger(T.Events.LEVEL_SWITCHING,S);var b=c.details;if(!b||b.live){var D=this.switchParams(c.uri,i==null?void 0:i.details);this.loadPlaylist(D)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(l){this.manualLevelIndex=l,this._startLevel===void 0&&(this._startLevel=l),l!==-1&&(this.level=l)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(l){this._firstLevel=l}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var l=this.hls.config.startLevel;return l!==void 0?l:this._firstLevel}return this._startLevel},set:function(l){this._startLevel=l}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(l){this.level=l,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=l)}}])&&m(s.prototype,u),e}(k.default)},"./src/controller/level-helper.ts":function(N,w,f){f.r(w),f.d(w,"addGroupId",function(){return A}),f.d(w,"assignTrackIdsByGroup",function(){return R}),f.d(w,"updatePTS",function(){return I}),f.d(w,"updateFragPTSDTS",function(){return o}),f.d(w,"mergeDetails",function(){return L}),f.d(w,"mapPartIntersection",function(){return m}),f.d(w,"mapFragmentIntersection",function(){return h}),f.d(w,"adjustSliding",function(){return E}),f.d(w,"addSliding",function(){return y}),f.d(w,"computeReloadInterval",function(){return d}),f.d(w,"getFragmentWithSN",function(){return t}),f.d(w,"getPartWith",function(){return a});var _=f("./src/polyfills/number.ts"),T=f("./src/utils/logger.ts");function A(e,s,u){switch(s){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(u);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(u)}}function R(e){var s={};e.forEach(function(u){var n=u.groupId||"";u.id=s[n]=s[n]||0,s[n]++})}function I(e,s,u){k(e[s],e[u])}function k(e,s){var u=s.startPTS;if(Object(_.isFiniteNumber)(u)){var n,l=0;s.sn>e.sn?(l=u-e.start,n=e):(l=e.start-u,n=s),n.duration!==l&&(n.duration=l)}else s.sn>e.sn?e.cc===s.cc&&e.minEndPTS?s.start=e.start+(e.minEndPTS-e.start):s.start=e.start+e.duration:s.start=Math.max(e.start-s.duration,0)}function o(e,s,u,n,l,p){n-u<=0&&(T.logger.warn("Fragment should have a positive duration",s),n=u+s.duration,p=l+s.duration);var g=u,v=n,r=s.startPTS,i=s.endPTS;if(Object(_.isFiniteNumber)(r)){var c=Math.abs(r-u);Object(_.isFiniteNumber)(s.deltaPTS)?s.deltaPTS=Math.max(c,s.deltaPTS):s.deltaPTS=c,g=Math.max(u,r),u=Math.min(u,r),l=Math.min(l,s.startDTS),v=Math.min(n,i),n=Math.max(n,i),p=Math.max(p,s.endDTS)}s.duration=n-u;var S=u-s.start;s.appendedPTS=n,s.start=s.startPTS=u,s.maxStartPTS=g,s.startDTS=l,s.endPTS=n,s.minEndPTS=v,s.endDTS=p;var b,D=s.sn;if(!e||De.endSN)return 0;var O=D-e.startSN,C=e.fragments;for(C[O]=s,b=O;b>0;b--)k(C[b],C[b-1]);for(b=O;b=0;l--){var p=n[l].initSegment;if(p){u=p;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var g,v=0;if(h(e,s,function(D,O){var C;D.relurl&&(v=D.cc-O.cc),Object(_.isFiniteNumber)(D.startPTS)&&Object(_.isFiniteNumber)(D.endPTS)&&(O.start=O.startPTS=D.startPTS,O.startDTS=D.startDTS,O.appendedPTS=D.appendedPTS,O.maxStartPTS=D.maxStartPTS,O.endPTS=D.endPTS,O.endDTS=D.endDTS,O.minEndPTS=D.minEndPTS,O.duration=D.endPTS-D.startPTS,O.duration&&(g=O),s.PTSKnown=s.alignedSliding=!0),O.elementaryStreams=D.elementaryStreams,O.loader=D.loader,O.stats=D.stats,O.urlId=D.urlId,D.initSegment?(O.initSegment=D.initSegment,u=D.initSegment):O.initSegment&&O.initSegment.relurl!=((C=u)===null||C===void 0?void 0:C.relurl)||(O.initSegment=u)}),s.skippedSegments&&(s.deltaUpdateFailed=s.fragments.some(function(D){return!D}),s.deltaUpdateFailed)){T.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var r=s.skippedSegments;r--;)s.fragments.shift();s.startSN=s.fragments[0].sn,s.startCC=s.fragments[0].cc}var i=s.fragments;if(v){T.logger.warn("discontinuity sliding from playlist, take drift into account");for(var c=0;c=n.length||y(s,n[u].start)}function y(e,s){if(s){for(var u=e.fragments,n=e.skippedSegments;n0&&p<3*n,v=s.loading.end-s.loading.start,r=e.availabilityDelay;if(e.updated===!1)if(g){var i=333*e.misses;u=Math.max(Math.min(l,2*v),i),e.availabilityDelay=(e.availabilityDelay||0)+u}else u=l;else g?(r=Math.min(r||n/2,p),e.availabilityDelay=r,u=r+n-p):u=n-v;return Math.round(u)}function t(e,s,u){if(!e||!e.details)return null;var n=e.details,l=n.fragments[s-n.startSN];return l||((l=n.fragmentHint)&&l.sn===s?l:s0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),r=i),this.state=T.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=T.State.STOPPED},v.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},v.doTick=function(){switch(this.state){case T.State.IDLE:this.doTickIdle();break;case T.State.WAITING_LEVEL:var r,i=this.levels,c=this.level,S=i==null||(r=i[c])===null||r===void 0?void 0:r.details;if(S&&(!S.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(S))break;this.state=T.State.IDLE;break}break;case T.State.FRAG_LOADING_WAITING_RETRY:var b,D=self.performance.now(),O=this.retryDate;(!O||D>=O||(b=this.media)!==null&&b!==void 0&&b.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=T.State.IDLE)}this.onTickEnd()},v.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},v.doTickIdle=function(){var r,i,c=this.hls,S=this.levelLastLoaded,b=this.levels,D=this.media,O=c.config,C=c.nextLoadLevel;if(S!==null&&(D||!this.startFragRequested&&O.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&b&&b[C]){var x=b[C];this.level=c.nextLoadLevel=C;var P=x.details;if(!P||this.state===T.State.WAITING_LEVEL||P.live&&this.levelLastLoaded!==C)this.state=T.State.WAITING_LEVEL;else{var F=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:D,o.PlaylistLevelType.MAIN);if(F!==null&&!(F.len>=this.getMaxBufferLength(x.maxBitrate))){if(this._streamEnded(F,P)){var M={};return this.altAudio&&(M.type="video"),this.hls.trigger(R.Events.BUFFER_EOS,M),void(this.state=T.State.ENDED)}var B=F.end,U=this.getNextFragment(B,P);if(this.couldBacktrack&&!this.fragPrevious&&U&&U.sn!=="initSegment"){var G=U.sn-P.startSN;G>1&&(U=P.fragments[G-1],this.fragmentTracker.removeFragment(U))}if(U&&this.fragmentTracker.getState(U)===k.FragmentState.OK&&this.nextLoadPosition>B){var K=this.audioOnly&&!this.altAudio?L.ElementaryStreamTypes.AUDIO:L.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(D,K,o.PlaylistLevelType.MAIN),U=this.getNextFragment(this.nextLoadPosition,P)}U&&(!U.initSegment||U.initSegment.data||this.bitrateTest||(U=U.initSegment),((r=U.decryptdata)===null||r===void 0?void 0:r.keyFormat)!=="identity"||(i=U.decryptdata)!==null&&i!==void 0&&i.key?this.loadFragment(U,P,B):this.loadKey(U,P))}}}},v.loadFragment=function(r,i,c){var S,b=this.fragmentTracker.getState(r);if(this.fragCurrent=r,b===k.FragmentState.BACKTRACKED){var D=this.fragmentTracker.getBacktrackData(r);if(D)return this._handleFragmentLoadProgress(D),void this._handleFragmentLoadComplete(D);b=k.FragmentState.NOT_LOADED}b===k.FragmentState.NOT_LOADED||b===k.FragmentState.PARTIAL?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(r.bitrateTest=!0,this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,r,i,c)):b===k.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((S=this.media)===null||S===void 0?void 0:S.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},v.getAppendedFrag=function(r){var i=this.fragmentTracker.getAppendedFrag(r,o.PlaylistLevelType.MAIN);return i&&"fragment"in i?i.fragment:i},v.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,o.PlaylistLevelType.MAIN)},v.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},v.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},v.nextLevelSwitch=function(){var r=this.levels,i=this.media;if(i!=null&&i.readyState){var c,S=this.getAppendedFrag(i.currentTime);if(S&&S.start>1&&this.flushMainBuffer(0,S.start-1),!i.paused&&r){var b=r[this.hls.nextLoadLevel],D=this.fragLastKbps;c=D&&this.fragCurrent?this.fragCurrent.duration*b.maxBitrate/(1e3*D)+1:0}else c=0;var O=this.getBufferedFrag(i.currentTime+c);if(O){var C=this.followingBufferedFrag(O);if(C){this.abortCurrentFrag();var x=C.maxStartPTS?C.maxStartPTS:C.start,P=C.duration,F=Math.max(O.end,x+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,.5*P),.75*P));this.flushMainBuffer(F,Number.POSITIVE_INFINITY)}}}},v.abortCurrentFrag=function(){var r=this.fragCurrent;this.fragCurrent=null,r!=null&&r.loader&&r.loader.abort(),this.state===T.State.KEY_LOADING&&(this.state=T.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},v.flushMainBuffer=function(r,i){s.prototype.flushMainBuffer.call(this,r,i,this.altAudio?"video":null)},v.onMediaAttached=function(r,i){s.prototype.onMediaAttached.call(this,r,i);var c=i.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),c.addEventListener("playing",this.onvplaying),c.addEventListener("seeked",this.onvseeked),this.gapController=new E.default(this.config,c,this.fragmentTracker,this.hls)},v.onMediaDetaching=function(){var r=this.media;r&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),s.prototype.onMediaDetaching.call(this)},v.onMediaPlaying=function(){this.tick()},v.onMediaSeeked=function(){var r=this.media,i=r?r.currentTime:null;Object(_.isFiniteNumber)(i)&&this.log("Media seeked to "+i.toFixed(3)),this.tick()},v.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},v.onManifestParsed=function(r,i){var c,S=!1,b=!1;i.levels.forEach(function(D){(c=D.audioCodec)&&(c.indexOf("mp4a.40.2")!==-1&&(S=!0),c.indexOf("mp4a.40.5")!==-1&&(b=!0))}),this.audioCodecSwitch=S&&b&&!Object(A.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=i.levels,this.startFragRequested=!1},v.onLevelLoading=function(r,i){var c=this.levels;if(c&&this.state===T.State.IDLE){var S=c[i.level];(!S.details||S.details.live&&this.levelLastLoaded!==i.level||this.waitForCdnTuneIn(S.details))&&(this.state=T.State.WAITING_LEVEL)}},v.onLevelLoaded=function(r,i){var c,S=this.levels,b=i.level,D=i.details,O=D.totalduration;if(S){this.log("Level "+b+" loaded ["+D.startSN+","+D.endSN+"], cc ["+D.startCC+", "+D.endCC+"] duration:"+O);var C=this.fragCurrent;!C||this.state!==T.State.FRAG_LOADING&&this.state!==T.State.FRAG_LOADING_WAITING_RETRY||C.level!==i.level&&C.loader&&(this.state=T.State.IDLE,C.loader.abort());var x=S[b],P=0;if(D.live||(c=x.details)!==null&&c!==void 0&&c.live){if(D.fragments[0]||(D.deltaUpdateFailed=!0),D.deltaUpdateFailed)return;P=this.alignPlaylists(D,x.details)}if(x.details=D,this.levelLastLoaded=b,this.hls.trigger(R.Events.LEVEL_UPDATED,{details:D,level:b}),this.state===T.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(D))return;this.state=T.State.IDLE}this.startFragRequested?D.live&&this.synchronizeToLiveEdge(D):this.setStartPosition(D,P),this.tick()}else this.warn("Levels were reset while loading level "+b)},v._handleFragmentLoadProgress=function(r){var i,c=r.frag,S=r.part,b=r.payload,D=this.levels;if(D){var O=D[c.level],C=O.details;if(C){var x=O.videoCodec,P=C.PTSKnown||!C.live,F=(i=c.initSegment)===null||i===void 0?void 0:i.data,M=this._getAudioCodec(O),B=this.transmuxer=this.transmuxer||new m.default(this.hls,o.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),U=S?S.index:-1,G=U!==-1,K=new h.ChunkMetadata(c.level,c.sn,c.stats.chunkCount,b.byteLength,U,G),H=this.initPTS[c.cc];B.push(b,F,M,x,c,S,C.totalduration,P,K,H)}else this.warn("Dropping fragment "+c.sn+" of level "+c.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+c.sn+" of level "+c.level+" will not be buffered")},v.onAudioTrackSwitching=function(r,i){var c=this.altAudio,S=!!i.url,b=i.id;if(!S){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var D=this.fragCurrent;D!=null&&D.loader&&(this.log("Switching to main audio track, cancel main fragment load"),D.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var O=this.hls;c&&O.trigger(R.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),O.trigger(R.Events.AUDIO_TRACK_SWITCHED,{id:b})}},v.onAudioTrackSwitched=function(r,i){var c=i.id,S=!!this.hls.audioTracks[c].url;if(S){var b=this.videoBuffer;b&&this.mediaBuffer!==b&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=b)}this.altAudio=S,this.tick()},v.onBufferCreated=function(r,i){var c,S,b=i.tracks,D=!1;for(var O in b){var C=b[O];if(C.id==="main"){if(S=O,c=C,O==="video"){var x=b[O];x&&(this.videoBuffer=x.buffer)}}else D=!0}D&&c?(this.log("Alternate track found, use "+S+".buffered to schedule main fragment loading"),this.mediaBuffer=c.buffer):this.mediaBuffer=this.media},v.onFragBuffered=function(r,i){var c=i.frag,S=i.part;if(!c||c.type===o.PlaylistLevelType.MAIN){if(this.fragContextChanged(c))return this.warn("Fragment "+c.sn+(S?" p: "+S.index:"")+" of level "+c.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===T.State.PARSED&&(this.state=T.State.IDLE));var b=S?S.stats:c.stats;this.fragLastKbps=Math.round(8*b.total/(b.buffering.end-b.loading.first)),c.sn!=="initSegment"&&(this.fragPrevious=c),this.fragBufferedComplete(c,S)}},v.onError=function(r,i){switch(i.details){case y.ErrorDetails.FRAG_LOAD_ERROR:case y.ErrorDetails.FRAG_LOAD_TIMEOUT:case y.ErrorDetails.KEY_LOAD_ERROR:case y.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(o.PlaylistLevelType.MAIN,i);break;case y.ErrorDetails.LEVEL_LOAD_ERROR:case y.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==T.State.ERROR&&(i.fatal?(this.warn(""+i.details),this.state=T.State.ERROR):i.levelRetry||this.state!==T.State.WAITING_LEVEL||(this.state=T.State.IDLE));break;case y.ErrorDetails.BUFFER_FULL_ERROR:if(i.parent==="main"&&(this.state===T.State.PARSING||this.state===T.State.PARSED)){var c=!0,S=this.getFwdBufferInfo(this.media,o.PlaylistLevelType.MAIN);S&&S.len>.5&&(c=!this.reduceMaxBufferLength(S.len)),c&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},v.checkBuffer=function(){var r=this.media,i=this.gapController;if(r&&i&&r.readyState){var c=I.BufferHelper.getBuffered(r);!this.loadedmetadata&&c.length?(this.loadedmetadata=!0,this.seekToStartPos()):i.poll(this.lastCurrentTime),this.lastCurrentTime=r.currentTime}},v.onFragLoadEmergencyAborted=function(){this.state=T.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},v.onBufferFlushed=function(r,i){var c=i.type;if(c!==L.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var S=(c===L.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(S,c,o.PlaylistLevelType.MAIN)}},v.onLevelsUpdated=function(r,i){this.levels=i.levels},v.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},v.seekToStartPos=function(){var r=this.media,i=r.currentTime,c=this.startPosition;if(c>=0&&i0&&b1&&r.seeking===!1){var c=r.currentTime;if(I.BufferHelper.isBuffered(r,c)?i=this.getAppendedFrag(c):I.BufferHelper.isBuffered(r,c+.1)&&(i=this.getAppendedFrag(c+.1)),i){var S=this.fragPlaying,b=i.level;S&&i.sn===S.sn&&S.level===b&&i.urlId===S.urlId||(this.hls.trigger(R.Events.FRAG_CHANGED,{frag:i}),S&&S.level===b||this.hls.trigger(R.Events.LEVEL_SWITCHED,{level:b}),this.fragPlaying=i)}}},p=l,(g=[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentLevel",get:function(){var r=this.media;if(r){var i=this.getAppendedFrag(r.currentTime);if(i)return i.level}return-1}},{key:"nextBufferedFrag",get:function(){var r=this.media;if(r){var i=this.getAppendedFrag(r.currentTime);return this.followingBufferedFrag(i)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&t(p.prototype,g),l}(T.default)},"./src/controller/subtitle-stream-controller.ts":function(N,w,f){f.r(w),f.d(w,"SubtitleStreamController",function(){return d});var _=f("./src/events.ts"),T=f("./src/utils/logger.ts"),A=f("./src/utils/buffer-helper.ts"),R=f("./src/controller/fragment-finders.ts"),I=f("./src/utils/discontinuities.ts"),k=f("./src/controller/level-helper.ts"),o=f("./src/controller/fragment-tracker.ts"),L=f("./src/controller/base-stream-controller.ts"),m=f("./src/types/loader.ts"),h=f("./src/types/level.ts");function E(t,a){for(var e=0;e=i[b].start&&S<=i[b].end){c=i[b];break}var D=v.start+v.duration;c?c.end=D:(c={start:S,end:D},i.push(c)),this.fragmentTracker.fragBuffered(v)}}},l.onBufferFlushing=function(p,g){var v=g.startOffset,r=g.endOffset;if(v===0&&r!==Number.POSITIVE_INFINITY){var i=this.currentTrackId,c=this.levels;if(!c.length||!c[i]||!c[i].details)return;var S=r-c[i].details.targetduration;if(S<=0)return;g.endOffsetSubtitles=Math.max(0,S),this.tracksBuffered.forEach(function(b){for(var D=0;D=S.length||i!==c)&&b){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||(v=b.details)!==null&&v!==void 0&&v.live){var D=this.mainDetails;if(r.deltaUpdateFailed||!D)return;var O=D.fragments[0];b.details?this.alignPlaylists(r,b.details)===0&&O&&Object(k.addSliding)(r,O.start):r.hasProgramDateTime&&D.hasProgramDateTime?Object(I.alignPDT)(r,D):O&&Object(k.addSliding)(r,O.start)}b.details=r,this.levelLastLoaded=i,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===L.State.IDLE&&(Object(R.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),b.details=void 0))}}},l._handleFragmentLoadComplete=function(p){var g=p.frag,v=p.payload,r=g.decryptdata,i=this.hls;if(!this.fragContextChanged(g)&&v&&v.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){var c=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(v),r.key.buffer,r.iv.buffer).then(function(S){var b=performance.now();i.trigger(_.Events.FRAG_DECRYPTED,{frag:g,payload:S,stats:{tstart:c,tdecrypt:b}})})}},l.doTick=function(){if(this.media){if(this.state===L.State.IDLE){var p,g=this.currentTrackId,v=this.levels;if(!v.length||!v[g]||!v[g].details)return;var r=v[g].details,i=r.targetduration,c=this.config,S=this.media,b=A.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,S.currentTime-i,c.maxBufferHole),D=b.end;if(b.len>this.getMaxBufferLength()+i)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var O,C=r.fragments,x=C.length,P=r.edge,F=this.fragPrevious;if(D-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))},a.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),L(this.media.textTracks).forEach(function(e){Object(T.clearCurrentCues)(e)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(e,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(e,s){var u=s.id,n=s.details,l=this.trackId,p=this.tracksInGroup[l];if(p){var g=p.details;p.details=s.details,this.log("subtitle track "+u+" loaded ["+n.startSN+"-"+n.endSN+"]"),u===this.trackId&&(this.retryCount=0,this.playlistLoaded(u,s,g))}else this.warn("Invalid subtitle track id "+u)},a.onLevelLoading=function(e,s){this.switchLevel(s.level)},a.onLevelSwitching=function(e,s){this.switchLevel(s.level)},a.switchLevel=function(e){var s=this.hls.levels[e];if(s!=null&&s.textGroupIds){var u=s.textGroupIds[s.urlId];if(this.groupId!==u){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,l=this.tracks.filter(function(v){return!u||v.groupId===u});this.tracksInGroup=l;var p=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=u;var g={subtitleTracks:l};this.log("Updating subtitle tracks, "+l.length+' track(s) found in "'+u+'" group-id'),this.hls.trigger(_.Events.SUBTITLE_TRACKS_UPDATED,g),p!==-1&&this.setSubtitleTrack(p,n)}}},a.findTrackId=function(e){for(var s=this.tracksInGroup,u=0;u=n.length)){this.clearTimer();var l=n[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,l){var p=l.id,g=l.groupId,v=g===void 0?"":g,r=l.name,i=l.type,c=l.url;this.hls.trigger(_.Events.SUBTITLE_TRACK_SWITCH,{id:p,groupId:v,name:r,type:i,url:c});var S=this.switchParams(l.url,s==null?void 0:s.details);this.loadPlaylist(S)}else this.hls.trigger(_.Events.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,s=L(this.media.textTracks),u=0;u=0&&(i[0]=Math.min(i[0],a),i[1]=Math.max(i[1],e),v=!0,c/(e-a)>.5))return}if(v||u.push([a,e]),this.config.renderTextTracksNatively){var S=this.captionsTracks[t];this.Cues.newCue(S,a,e,s)}else{var b=this.Cues.newCue(null,a,e,s);this.hls.trigger(T.Events.CUES_PARSED,{type:"captions",cues:b,track:t})}},d.onInitPtsFound=function(t,a){var e=this,s=a.frag,u=a.id,n=a.initPTS,l=a.timescale,p=this.unparsedVttFrags;u==="main"&&(this.initPTS[s.cc]=n,this.timescale[s.cc]=l),p.length&&(this.unparsedVttFrags=[],p.forEach(function(g){e.onFragLoaded(T.Events.FRAG_LOADED,g)}))},d.getExistingTrack=function(t){var a=this.media;if(a)for(var e=0;e>>8^255&g^99,k[n]=g,o[g]=n;var v=u[n],r=u[v],i=u[r],c=257*u[g]^16843008*g;m[n]=c<<24|c>>>8,h[n]=c<<16|c>>>16,E[n]=c<<8|c>>>24,y[n]=c,c=16843009*i^65537*r^257*v^16843008*n,t[g]=c<<24|c>>>8,a[g]=c<<16|c>>>16,e[g]=c<<8|c>>>24,s[g]=c,n?(n=v^u[u[u[i^v]]],l^=u[u[l]]):n=l=1}},I.expandKey=function(k){for(var o=this.uint8ArrayToUint32Array_(k),L=!0,m=0;m>>6);var S=(60&s[u+2])>>>2;if(!(S>c.length-1))return g=(1&s[u+2])<<2,g|=(192&s[u+3])>>>6,_.logger.log("manifest codec:"+n+", ADTS type:"+l+", samplingIndex:"+S),/firefox/i.test(r)?S>=6?(l=5,v=new Array(4),p=S-3):(l=2,v=new Array(2),p=S):r.indexOf("android")!==-1?(l=2,v=new Array(2),p=S):(l=5,v=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&S>=6?p=S-3:((n&&n.indexOf("mp4a.40.2")!==-1&&(S>=6&&g===1||/vivaldi/i.test(r))||!n&&g===1)&&(l=2,v=new Array(2)),p=S)),v[0]=l<<3,v[0]|=(14&S)>>1,v[1]|=(1&S)<<7,v[1]|=g<<3,l===5&&(v[1]|=(14&p)>>1,v[2]=(1&p)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:c[S],channelCount:g,codec:"mp4a.40."+l,manifestCodec:i};e.trigger(A.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+S})}function I(e,s){return e[s]===255&&(246&e[s+1])==240}function k(e,s){return 1&e[s+1]?7:9}function o(e,s){return(3&e[s+3])<<11|e[s+4]<<3|(224&e[s+5])>>>5}function L(e,s){return s+5=e.length)return!1;var n=o(e,s);if(n<=u)return!1;var l=s+n;return l===e.length||m(e,l)}return!1}function y(e,s,u,n,l){if(!e.samplerate){var p=R(s,u,n,l);if(!p)return;e.config=p.config,e.samplerate=p.samplerate,e.channelCount=p.channelCount,e.codec=p.codec,e.manifestCodec=p.manifestCodec,_.logger.log("parsed codec:"+e.codec+", rate:"+p.samplerate+", channels:"+p.channelCount)}}function d(e){return 9216e4/e}function t(e,s,u,n,l){var p=k(e,s),g=o(e,s);if((g-=p)>0)return{headerLength:p,frameLength:g,stamp:u+n*l}}function a(e,s,u,n,l){var p=t(s,u,n,l,d(e.samplerate));if(p){var g,v=p.frameLength,r=p.headerLength,i=p.stamp,c=r+v,S=Math.max(0,u+c-s.length);S?(g=new Uint8Array(c-r)).set(s.subarray(u+r,s.length),0):g=s.subarray(u+r,u+c);var b={unit:g,pts:i};return S||e.samples.push(b),{sample:b,length:c,missing:S}}}},"./src/demux/base-audio-demuxer.ts":function(N,w,f){f.r(w),f.d(w,"initPTSFn",function(){return o});var _=f("./src/polyfills/number.ts"),T=f("./src/demux/id3.ts"),A=f("./src/demux/dummy-demuxed-track.ts"),R=f("./src/utils/mp4-tools.ts"),I=f("./src/utils/typed-array.ts"),k=function(){function L(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var m=L.prototype;return m.resetInitSegment=function(h,E,y){this._id3Track={type:"id3",id:0,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},m.resetTimeStamp=function(){},m.resetContiguity=function(){},m.canParse=function(h,E){return!1},m.appendFrame=function(h,E,y){},m.demux=function(h,E){this.cachedData&&(h=Object(R.appendUint8Array)(this.cachedData,h),this.cachedData=null);var y,d,t=T.getID3Data(h,0),a=t?t.length:0,e=this._audioTrack,s=this._id3Track,u=t?T.getTimeStamp(t):void 0,n=h.length;for(this.frameIndex!==0&&this.initPTS!==null||(this.initPTS=o(u,E)),t&&t.length>0&&s.samples.push({pts:this.initPTS,dts:this.initPTS,data:t}),d=this.initPTS;aI?(this.word<<=I,this.bitsAvailable-=I):(I-=this.bitsAvailable,I-=(k=I>>3)>>3,this.bytesAvailable-=k,this.loadWord(),this.word<<=I,this.bitsAvailable-=I)},R.readBits=function(I){var k=Math.min(this.bitsAvailable,I),o=this.word>>>32-k;return I>32&&_.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=k,this.bitsAvailable>0?this.word<<=k:this.bytesAvailable>0&&this.loadWord(),(k=I-k)>0&&this.bitsAvailable?o<>>I)!=0)return this.word<<=I,this.bitsAvailable-=I,I;return this.loadWord(),I+this.skipLZ()},R.skipUEG=function(){this.skipBits(1+this.skipLZ())},R.skipEG=function(){this.skipBits(1+this.skipLZ())},R.readUEG=function(){var I=this.skipLZ();return this.readBits(I+1)-1},R.readEG=function(){var I=this.readUEG();return 1&I?1+I>>>1:-1*(I>>>1)},R.readBoolean=function(){return this.readBits(1)===1},R.readUByte=function(){return this.readBits(8)},R.readUShort=function(){return this.readBits(16)},R.readUInt=function(){return this.readBits(32)},R.skipScalingList=function(I){for(var k=8,o=8,L=0;L0)return u.subarray(l,l+p)},I=function(u,n){var l=0;return l=(127&u[n])<<21,l|=(127&u[n+1])<<14,l|=(127&u[n+2])<<7,l|=127&u[n+3]},k=function(u,n){return T(u,n)&&I(u,n+6)+10<=u.length-n},o=function(u){for(var n=h(u),l=0;l>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:S+=String.fromCharCode(v);break;case 12:case 13:r=u[b++],S+=String.fromCharCode((31&v)<<6|63&r);break;case 14:r=u[b++],i=u[b++],S+=String.fromCharCode((15&v)<<12|(63&r)<<6|(63&i)<<0)}}return S},s={decodeTextFrame:d}},"./src/demux/mp3demuxer.ts":function(N,w,f){f.r(w);var _=f("./src/demux/base-audio-demuxer.ts"),T=f("./src/demux/id3.ts"),A=f("./src/utils/logger.ts"),R=f("./src/demux/mpegaudio.ts");function I(o,L){return(I=Object.setPrototypeOf||function(m,h){return m.__proto__=h,m})(o,L)}var k=function(o){var L,m;function h(){return o.apply(this,arguments)||this}m=o,(L=h).prototype=Object.create(m.prototype),L.prototype.constructor=L,I(L,m);var E=h.prototype;return E.resetInitSegment=function(y,d,t){o.prototype.resetInitSegment.call(this,y,d,t),this._audioTrack={container:"audio/mpeg",type:"audio",id:0,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:y,duration:t,inputTimeScale:9e4,dropped:0}},h.probe=function(y){if(!y)return!1;for(var d=(T.getID3Data(y,0)||[]).length,t=y.length;d0},I.demux=function(k){var o=k,L=Object(T.dummyTrack)();if(this.config.progressive){this.remainderData&&(o=Object(_.appendUint8Array)(this.remainderData,k));var m=Object(_.segmentValidRange)(o);this.remainderData=m.remainder,L.samples=m.valid||new Uint8Array}else L.samples=o;return{audioTrack:Object(T.dummyTrack)(),avcTrack:L,id3Track:Object(T.dummyTrack)(),textTrack:Object(T.dummyTrack)()}},I.flush=function(){var k=Object(T.dummyTrack)();return k.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(T.dummyTrack)(),avcTrack:k,id3Track:Object(T.dummyTrack)(),textTrack:Object(T.dummyTrack)()}},I.demuxSampleAes=function(k,o,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},I.destroy=function(){},R}();A.minProbeByteLength=1024,w.default=A},"./src/demux/mpegaudio.ts":function(N,w,f){f.r(w),f.d(w,"appendFrame",function(){return k}),f.d(w,"parseHeader",function(){return o}),f.d(w,"isHeaderPattern",function(){return L}),f.d(w,"isHeader",function(){return m}),f.d(w,"canParse",function(){return h}),f.d(w,"probe",function(){return E});var _=null,T=[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],A=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],R=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],I=[0,1,1,4];function k(y,d,t,a,e){if(!(t+24>d.length)){var s=o(d,t);if(s&&t+s.frameLength<=d.length){var u=a+e*(9e4*s.samplesPerFrame/s.sampleRate),n={unit:d.subarray(t,t+s.frameLength),pts:u,dts:u};return y.config=[],y.channelCount=s.channelCount,y.samplerate=s.sampleRate,y.samples.push(n),{sample:n,length:s.frameLength,missing:0}}}}function o(y,d){var t=y[d+1]>>3&3,a=y[d+1]>>1&3,e=y[d+2]>>4&15,s=y[d+2]>>2&3;if(t!==1&&e!==0&&e!==15&&s!==3){var u=y[d+2]>>1&1,n=y[d+3]>>6,l=1e3*T[14*(t===3?3-a:a===3?3:4)+e-1],p=A[3*(t===3?0:t===2?1:2)+s],g=n===3?1:2,v=R[t][a],r=I[a],i=8*v*r,c=Math.floor(v*l/p+u)*r;if(_===null){var S=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);_=S?parseInt(S[1]):0}return!!_&&_<=87&&a===2&&l>=224e3&&n===0&&(y[d+3]=128|y[d+3]),{sampleRate:p,channelCount:g,frameLength:c,samplesPerFrame:i}}}function L(y,d){return y[d]===255&&(224&y[d+1])==224&&(6&y[d+1])!=0}function m(y,d){return d+1=k.length)return void L();if(!(k[o].unit.length<32)){var m=this.decrypter.isSync();if(this.decryptAacSample(k,o,L,m),!m)return}}},I.getAvcEncryptedData=function(k){for(var o=16*Math.floor((k.length-48)/160)+16,L=new Int8Array(o),m=0,h=32;h<=k.length-16;h+=160,m+=16)L.set(k.subarray(h,h+16),m);return L},I.getAvcDecryptedUnit=function(k,o){for(var L=new Uint8Array(o),m=0,h=32;h<=k.length-16;h+=160,m+=16)k.set(L.subarray(m,m+16),h);return k},I.decryptAvcSample=function(k,o,L,m,h,E){var y=Object(T.discardEPB)(h.data),d=this.getAvcEncryptedData(y),t=this;this.decryptBuffer(d.buffer,function(a){h.data=t.getAvcDecryptedUnit(y,a),E||t.decryptAvcSamples(k,o,L+1,m)})},I.decryptAvcSamples=function(k,o,L,m){if(k instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;o++,L=0){if(o>=k.length)return void m();for(var h=k[o].units;!(L>=h.length);L++){var E=h[L];if(!(E.data.length<=48||E.type!==1&&E.type!==5)){var y=this.decrypter.isSync();if(this.decryptAvcSample(k,o,L,m,E,y),!y)return}}}},R}();w.default=A},"./src/demux/transmuxer-interface.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return m});var _=f("./node_modules/webworkify-webpack/index.js"),T=f("./src/events.ts"),A=f("./src/demux/transmuxer.ts"),R=f("./src/utils/logger.ts"),I=f("./src/errors.ts"),k=f("./src/utils/mediasource-helper.ts"),o=f("./node_modules/eventemitter3/index.js"),L=Object(k.getMediaSource)()||{isTypeSupported:function(){return!1}},m=function(){function h(y,d,t,a){var e=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=y,this.id=d,this.onTransmuxComplete=t,this.onFlush=a;var s=y.config,u=function(g,v){(v=v||{}).frag=e.frag,v.id=e.id,y.trigger(g,v)};this.observer=new o.EventEmitter,this.observer.on(T.Events.FRAG_DECRYPTED,u),this.observer.on(T.Events.ERROR,u);var n={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(s.enableWorker&&typeof Worker<"u"){var p;R.logger.log("demuxing in webworker");try{p=this.worker=_("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(g){y.trigger(T.Events.ERROR,{type:I.ErrorTypes.OTHER_ERROR,details:I.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(g.message+" ("+g.filename+":"+g.lineno+")")})},p.postMessage({cmd:"init",typeSupported:n,vendor:l,id:d,config:JSON.stringify(s)})}catch(g){R.logger.warn("Error in worker:",g),R.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new A.default(this.observer,n,s,l,d),this.worker=null}}else this.transmuxer=new A.default(this.observer,n,s,l,d)}var E=h.prototype;return E.destroy=function(){var y=this.worker;if(y)y.removeEventListener("message",this.onwmsg),y.terminate(),this.worker=null;else{var d=this.transmuxer;d&&(d.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.observer=null},E.push=function(y,d,t,a,e,s,u,n,l,p){var g=this;l.transmuxing.start=self.performance.now();var v=this.transmuxer,r=this.worker,i=s?s.start:e.start,c=e.decryptdata,S=this.frag,b=!(S&&e.cc===S.cc),D=!(S&&l.level===S.level),O=S?l.sn-S.sn:-1,C=this.part?l.part-this.part.index:1,x=!D&&(O===1||O===0&&C===1),P=self.performance.now();(D||O||e.stats.parsing.start===0)&&(e.stats.parsing.start=P),!s||!C&&x||(s.stats.parsing.start=P);var F=new A.TransmuxState(b,x,n,D,i);if(!x||b){R.logger.log("[transmuxer-interface, "+e.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+` discontinuity: `+b+` trackSwitch: `+D+` contiguous: `+x+` accurateTimeOffset: `+n+` timeOffset: `+i);var M=new A.TransmuxConfig(t,a,d,u,p);this.configureTransmuxer(M)}if(this.frag=e,this.part=s,r)r.postMessage({cmd:"demux",data:y,decryptdata:c,chunkMeta:l,state:F},y instanceof ArrayBuffer?[y]:[]);else if(v){var B=v.push(y,c,l,F);Object(A.isPromise)(B)?B.then(function(U){g.handleTransmuxComplete(U)}):this.handleTransmuxComplete(B)}},E.flush=function(y){var d=this;y.transmuxing.start=self.performance.now();var t=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:y});else if(t){var e=t.flush(y);Object(A.isPromise)(e)?e.then(function(s){d.handleFlushResult(s,y)}):this.handleFlushResult(e,y)}},E.handleFlushResult=function(y,d){var t=this;y.forEach(function(a){t.handleTransmuxComplete(a)}),this.onFlush(d)},E.onWorkerMessage=function(y){var d=y.data,t=this.hls;switch(d.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(d.data);break;case"flush":this.onFlush(d.data);break;default:d.data=d.data||{},d.data.frag=this.frag,d.data.id=this.id,t.trigger(d.event,d.data)}},E.configureTransmuxer=function(y){var d=this.worker,t=this.transmuxer;d?d.postMessage({cmd:"configure",config:y}):t&&t.configure(y)},E.handleTransmuxComplete=function(y){y.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(y)},h}()},"./src/demux/transmuxer-worker.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return I});var _=f("./src/demux/transmuxer.ts"),T=f("./src/events.ts"),A=f("./src/utils/logger.ts"),R=f("./node_modules/eventemitter3/index.js");function I(m){var h=new R.EventEmitter,E=function(y,d){m.postMessage({event:y,data:d})};h.on(T.Events.FRAG_DECRYPTED,E),h.on(T.Events.ERROR,E),m.addEventListener("message",function(y){var d=y.data;switch(d.cmd){case"init":var t=JSON.parse(d.config);m.transmuxer=new _.default(h,d.typeSupported,t,d.vendor,d.id),Object(A.enableLogs)(t.debug),E("init",null);break;case"configure":m.transmuxer.configure(d.config);break;case"demux":var a=m.transmuxer.push(d.data,d.decryptdata,d.chunkMeta,d.state);Object(_.isPromise)(a)?a.then(function(u){k(m,u)}):k(m,a);break;case"flush":var e=d.chunkMeta,s=m.transmuxer.flush(e);Object(_.isPromise)(s)?s.then(function(u){L(m,u,e)}):L(m,s,e)}})}function k(m,h){if((E=h.remuxResult).audio||E.video||E.text||E.id3||E.initSegment){var E,y=[],d=h.remuxResult,t=d.audio,a=d.video;t&&o(y,t),a&&o(y,a),m.postMessage({event:"transmuxComplete",data:h},y)}}function o(m,h){h.data1&&m.push(h.data1.buffer),h.data2&&m.push(h.data2.buffer)}function L(m,h,E){h.forEach(function(y){k(m,y)}),m.postMessage({event:"flush",data:E})}},"./src/demux/transmuxer.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return e}),f.d(w,"isPromise",function(){return u}),f.d(w,"TransmuxConfig",function(){return n}),f.d(w,"TransmuxState",function(){return l});var _,T=f("./src/events.ts"),A=f("./src/errors.ts"),R=f("./src/crypt/decrypter.ts"),I=f("./src/demux/aacdemuxer.ts"),k=f("./src/demux/mp4demuxer.ts"),o=f("./src/demux/tsdemuxer.ts"),L=f("./src/demux/mp3demuxer.ts"),m=f("./src/remux/mp4-remuxer.ts"),h=f("./src/remux/passthrough-remuxer.ts"),E=f("./src/demux/chunk-cache.ts"),y=f("./src/utils/mp4-tools.ts"),d=f("./src/utils/logger.ts");try{_=self.performance.now.bind(self.performance)}catch{d.logger.debug("Unable to use Performance API on this environment"),_=self.Date.now}var t=[{demux:o.default,remux:m.default},{demux:k.default,remux:h.default},{demux:I.default,remux:m.default},{demux:L.default,remux:m.default}],a=1024;t.forEach(function(p){var g=p.demux;a=Math.max(a,g.minProbeByteLength)});var e=function(){function p(v,r,i,c,S){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=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.cache=new E.default,this.observer=v,this.typeSupported=r,this.config=i,this.vendor=c,this.id=S}var g=p.prototype;return g.configure=function(v){this.transmuxConfig=v,this.decrypter&&this.decrypter.reset()},g.push=function(v,r,i,c){var S=this,b=i.transmuxing;b.executeStart=_();var D=new Uint8Array(v),O=this.cache,C=this.config,x=this.currentTransmuxState,P=this.transmuxConfig;c&&(this.currentTransmuxState=c);var F=function(nt,it){var dt=null;return nt.byteLength>0&&it!=null&&it.key!=null&&it.iv!==null&&it.method!=null&&(dt=it),dt}(D,r);if(F&&F.method==="AES-128"){var M=this.getDecrypter();if(!C.enableSoftwareAES)return this.decryptionPromise=M.webCryptoDecrypt(D,F.key.buffer,F.iv.buffer).then(function(nt){var it=S.push(nt,null,i);return S.decryptionPromise=null,it}),this.decryptionPromise;var B=M.softwareDecrypt(D,F.key.buffer,F.iv.buffer);if(!B)return b.executeEnd=_(),s(i);D=new Uint8Array(B)}var U=c||x,G=U.contiguous,K=U.discontinuity,H=U.trackSwitch,Y=U.accurateTimeOffset,W=U.timeOffset,q=P.audioCodec,Q=P.videoCodec,tt=P.defaultInitPts,rt=P.duration,z=P.initSegmentData;if((K||H)&&this.resetInitSegment(z,q,Q,rt),K&&this.resetInitialTimestamp(tt),G||this.resetContiguity(),this.needsProbing(D,K,H)){if(O.dataLength){var at=O.flush();D=Object(y.appendUint8Array)(at,D)}this.configureTransmuxer(D,P)}var X=this.transmux(D,F,W,Y,i),J=this.currentTransmuxState;return J.contiguous=!0,J.discontinuity=!1,J.trackSwitch=!1,b.executeEnd=_(),X},g.flush=function(v){var r=this,i=v.transmuxing;i.executeStart=_();var c=this.decrypter,S=this.cache,b=this.currentTransmuxState,D=this.decryptionPromise;if(D)return D.then(function(){return r.flush(v)});var O=[],C=b.timeOffset;if(c){var x=c.flush();x&&O.push(this.push(x,null,v))}var P=S.dataLength;S.reset();var F=this.demuxer,M=this.remuxer;if(!F||!M)return P>=a&&this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:A.ErrorTypes.MEDIA_ERROR,details:A.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),i.executeEnd=_(),[s(v)];var B=F.flush(C);return u(B)?B.then(function(U){return r.flushRemux(O,U,v),O}):(this.flushRemux(O,B,v),O)},g.flushRemux=function(v,r,i){var c=r.audioTrack,S=r.avcTrack,b=r.id3Track,D=r.textTrack,O=this.currentTransmuxState,C=O.accurateTimeOffset,x=O.timeOffset;d.logger.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var P=this.remuxer.remux(c,S,b,D,x,C,!0,this.id);v.push({remuxResult:P,chunkMeta:i}),i.transmuxing.executeEnd=_()},g.resetInitialTimestamp=function(v){var r=this.demuxer,i=this.remuxer;r&&i&&(r.resetTimeStamp(v),i.resetTimeStamp(v))},g.resetContiguity=function(){var v=this.demuxer,r=this.remuxer;v&&r&&(v.resetContiguity(),r.resetNextTimestamp())},g.resetInitSegment=function(v,r,i,c){var S=this.demuxer,b=this.remuxer;S&&b&&(S.resetInitSegment(r,i,c),b.resetInitSegment(v,r,i))},g.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},g.transmux=function(v,r,i,c,S){return r&&r.method==="SAMPLE-AES"?this.transmuxSampleAes(v,r,i,c,S):this.transmuxUnencrypted(v,i,c,S)},g.transmuxUnencrypted=function(v,r,i,c){var S=this.demuxer.demux(v,r,!1,!this.config.progressive),b=S.audioTrack,D=S.avcTrack,O=S.id3Track,C=S.textTrack;return{remuxResult:this.remuxer.remux(b,D,O,C,r,i,!1,this.id),chunkMeta:c}},g.transmuxSampleAes=function(v,r,i,c,S){var b=this;return this.demuxer.demuxSampleAes(v,r,i).then(function(D){return{remuxResult:b.remuxer.remux(D.audioTrack,D.avcTrack,D.id3Track,D.textTrack,i,c,!1,b.id),chunkMeta:S}})},g.configureTransmuxer=function(v,r){for(var i,c=this.config,S=this.observer,b=this.typeSupported,D=this.vendor,O=r.audioCodec,C=r.defaultInitPts,x=r.duration,P=r.initSegmentData,F=r.videoCodec,M=0,B=t.length;M>4>1){if((q=H+5+p[H+4])===H+188)continue}else q=H+4;switch(W){case D:Y&&(O&&(i=a(O))&&this.parseAVCPES(i,!1),O={data:[],size:0}),O&&(O.data.push(p.subarray(q,H+188)),O.size+=H+188-q);break;case C:Y&&(P&&(i=a(P))&&(S.isAAC?this.parseAACPES(i):this.parseMPEGPES(i)),P={data:[],size:0}),P&&(P.data.push(p.subarray(q,H+188)),P.size+=H+188-q);break;case x:Y&&(F&&(i=a(F))&&this.parseID3PES(i),F={data:[],size:0}),F&&(F.data.push(p.subarray(q,H+188)),F.size+=H+188-q);break;case 0:Y&&(q+=p[q]+1),U=this._pmtId=d(p,q);break;case U:Y&&(q+=p[q]+1);var Q=t(p,q,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,v);(D=Q.avc)>0&&(c.pid=D),(C=Q.audio)>0&&(S.pid=C,S.isAAC=Q.isAAC),(x=Q.id3)>0&&(b.pid=x),M&&!B&&(L.logger.log("reparse from beginning"),M=!1,H=K-188),B=this.pmtParsed=!0;break;case 17:case 8191:break;default:M=!0}}else this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:m.ErrorTypes.MEDIA_ERROR,details:m.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});c.pesData=O,S.pesData=P,b.pesData=F;var tt={audioTrack:S,avcTrack:c,id3Track:b,textTrack:this._txtTrack};return r&&this.extractRemainingSamples(tt),tt},l.flush=function(){var p,g=this.remainderData;return this.remainderData=null,p=g?this.demux(g,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(p),this.sampleAes?this.decrypt(p,this.sampleAes):p},l.extractRemainingSamples=function(p){var g,v=p.audioTrack,r=p.avcTrack,i=p.id3Track,c=r.pesData,S=v.pesData,b=i.pesData;c&&(g=a(c))?(this.parseAVCPES(g,!0),r.pesData=null):r.pesData=c,S&&(g=a(S))?(v.isAAC?this.parseAACPES(g):this.parseMPEGPES(g),v.pesData=null):(S!=null&&S.size&&L.logger.log("last AAC PES packet truncated,might overlap between fragments"),v.pesData=S),b&&(g=a(b))?(this.parseID3PES(g),i.pesData=null):i.pesData=b},l.demuxSampleAes=function(p,g,v){var r=this.demux(p,v,!0,!this.config.progressive),i=this.sampleAes=new I.default(this.observer,this.config,g);return this.decrypt(r,i)},l.decrypt=function(p,g){return new Promise(function(v){var r=p.audioTrack,i=p.avcTrack;r.samples&&r.isAAC?g.decryptAacSamples(r.samples,0,function(){i.samples?g.decryptAvcSamples(i.samples,0,0,function(){v(p)}):v(p)}):i.samples&&g.decryptAvcSamples(i.samples,0,0,function(){v(p)})})},l.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},l.parseAVCPES=function(p,g){var v,r=this,i=this._avcTrack,c=this.parseAVCNALu(p.data),S=this.avcSample,b=!1;p.data=null,S&&c.length&&!i.audFound&&(e(S,i),S=this.avcSample=y(!1,p.pts,p.dts,"")),c.forEach(function(D){switch(D.type){case 1:v=!0,S||(S=r.avcSample=y(!0,p.pts,p.dts,"")),S.frame=!0;var O=D.data;if(b&&O.length>4){var C=new A.default(O).readSliceType();C!==2&&C!==4&&C!==7&&C!==9||(S.key=!0)}break;case 5:v=!0,S||(S=r.avcSample=y(!0,p.pts,p.dts,"")),S.key=!0,S.frame=!0;break;case 6:v=!0;var x=new A.default(u(D.data));x.readUByte();for(var P=0,F=0,M=!1,B=0;!M&&x.bytesAvailable>1;){P=0;do P+=B=x.readUByte();while(B===255);F=0;do F+=B=x.readUByte();while(B===255);if(P===4&&x.bytesAvailable!==0){if(M=!0,x.readUByte()===181&&x.readUShort()===49&&x.readUInt()===1195456820&&x.readUByte()===3){for(var U=x.readUByte(),G=31&U,K=[U,x.readUByte()],H=0;H16){for(var Y=[],W=0;W<16;W++)Y.push(x.readUByte().toString(16)),W!==3&&W!==5&&W!==7&&W!==9||Y.push("-");for(var q=F-16,Q=new Uint8Array(q),tt=0;tt=0){var x={data:p.subarray(O,D-c-1),type:C};b.push(x)}else{var P=this.getLastNalUnit();if(P&&(S&&D<=4-S&&P.state&&(P.data=P.data.subarray(0,P.data.byteLength-S)),(v=D-c-1)>0)){var F=new Uint8Array(P.data.byteLength+v);F.set(P.data,0),F.set(p.subarray(0,v),P.data.byteLength),P.data=F}}D=0&&c>=0){var M={data:p.subarray(O,r),type:C,state:c};b.push(M)}if(b.length===0){var B=this.getLastNalUnit();if(B){var U=new Uint8Array(B.data.byteLength+p.byteLength);U.set(B.data,0),U.set(p,B.data.byteLength),B.data=U}}return i.naluState=c,b},l.parseAACPES=function(p){var g,v,r,i,c,S=0,b=this._audioTrack,D=this.aacOverFlow,O=p.data;if(D){this.aacOverFlow=null;var C=D.sample.unit.byteLength,x=Math.min(D.missing,C),P=C-x;D.sample.unit.set(O.subarray(0,x),P),b.samples.push(D.sample),S=D.missing}for(g=S,v=O.length;g1;){var S=new Uint8Array(c[0].length+c[1].length);S.set(c[0]),S.set(c[1],c[0].length),c[0]=S,c.splice(1,1)}if(((l=c[0])[0]<<16)+(l[1]<<8)+l[2]===1){if((p=(l[4]<<8)+l[5])&&p>n.size-6)return null;var b=l[7];192&b&&(v=536870912*(14&l[9])+4194304*(255&l[10])+16384*(254&l[11])+128*(255&l[12])+(254&l[13])/2,64&b?v-(r=536870912*(14&l[14])+4194304*(255&l[15])+16384*(254&l[16])+128*(255&l[17])+(254&l[18])/2)>54e5&&(L.logger.warn(Math.round((v-r)/9e4)+"s delta between PTS and DTS, align them"),v=r):r=v);var D=(g=l[8])+9;if(n.size<=D)return null;n.size-=D;for(var O=new Uint8Array(n.size),C=0,x=c.length;CP){D-=P;continue}l=l.subarray(D),P-=D,D=0}O.set(l,i),i+=P}return p&&(p-=g+3),{data:O,pts:v,dts:r,len:p}}return null}function e(n,l){if(n.units.length&&n.frame){if(n.pts===void 0){var p=l.samples,g=p.length;if(!g)return void l.dropped++;var v=p[g-1];n.pts=v.pts,n.dts=v.dts}l.samples.push(n)}n.debug.length&&L.logger.log(n.pts+"/"+n.dts+":"+n.debug)}function s(n,l){var p=n.length;if(p>0){if(l.pts>=n[p-1].pts)n.push(l);else for(var g=p-1;g>=0;g--)if(l.ptsv)return i;return 0}},{key:"maxAutoLevel",get:function(){var g=this.levels,v=this.autoLevelCapping;return v===-1&&g&&g.length?g.length-1:v}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(g){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,g)}},{key:"audioTracks",get:function(){var g=this.audioTrackController;return g?g.audioTracks:[]}},{key:"audioTrack",get:function(){var g=this.audioTrackController;return g?g.audioTrack:-1},set:function(g){var v=this.audioTrackController;v&&(v.audioTrack=g)}},{key:"subtitleTracks",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var g=this.subtitleTrackController;return g?g.subtitleTrack:-1},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleTrack=g)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var g=this.subtitleTrackController;return!!g&&g.subtitleDisplay},set:function(g){var v=this.subtitleTrackController;v&&(v.subtitleDisplay=g)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(g){this.config.lowLatencyMode=g}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&a(u.prototype,n),l&&a(u,l),s}();e.defaultConfig=void 0},"./src/is-supported.ts":function(N,w,f){f.r(w),f.d(w,"isSupported",function(){return A}),f.d(w,"changeTypeSupported",function(){return R});var _=f("./src/utils/mediasource-helper.ts");function T(){return self.SourceBuffer||self.WebKitSourceBuffer}function A(){var I=Object(_.getMediaSource)();if(!I)return!1;var k=T(),o=I&&typeof I.isTypeSupported=="function"&&I.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),L=!k||k.prototype&&typeof k.prototype.appendBuffer=="function"&&typeof k.prototype.remove=="function";return!!o&&!!L}function R(){var I,k=T();return typeof(k==null||(I=k.prototype)===null||I===void 0?void 0:I.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return m}),f.d(w,"LoadError",function(){return E});var _=f("./src/polyfills/number.ts"),T=f("./src/errors.ts");function A(y){var d=typeof Map=="function"?new Map:void 0;return(A=function(t){if(t===null||(a=t,Function.toString.call(a).indexOf("[native code]")===-1))return t;var a;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(d!==void 0){if(d.has(t))return d.get(t);d.set(t,e)}function e(){return R(t,arguments,o(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),k(e,t)})(y)}function R(y,d,t){return(R=I()?Reflect.construct:function(a,e,s){var u=[null];u.push.apply(u,e);var n=new(Function.bind.apply(a,u));return s&&k(n,s.prototype),n}).apply(null,arguments)}function I(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function k(y,d){return(k=Object.setPrototypeOf||function(t,a){return t.__proto__=a,t})(y,d)}function o(y){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(d){return d.__proto__||Object.getPrototypeOf(d)})(y)}var L=Math.pow(2,17),m=function(){function y(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var d=y.prototype;return d.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},d.abort=function(){this.loader&&this.loader.abort()},d.load=function(t,a){var e=this,s=t.url;if(!s)return Promise.reject(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(s?"part list":"url")));this.abort();var u=this.config,n=u.fLoader,l=u.loader;return new Promise(function(p,g){e.loader&&e.loader.destroy();var v=e.loader=t.loader=n?new n(u):new l(u),r=h(t),i={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:L};t.stats=v.stats,v.load(r,i,{onSuccess:function(c,S,b,D){e.resetLoader(t,v),p({frag:t,part:null,payload:c.data,networkDetails:D})},onError:function(c,S,b){e.resetLoader(t,v),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:c,networkDetails:b}))},onAbort:function(c,S,b){e.resetLoader(t,v),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:b}))},onTimeout:function(c,S,b){e.resetLoader(t,v),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:b}))},onProgress:function(c,S,b,D){a&&a({frag:t,part:null,payload:b,networkDetails:D})}})})},d.loadPart=function(t,a,e){var s=this;this.abort();var u=this.config,n=u.fLoader,l=u.loader;return new Promise(function(p,g){s.loader&&s.loader.destroy();var v=s.loader=t.loader=n?new n(u):new l(u),r=h(t,a),i={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:L};a.stats=v.stats,v.load(r,i,{onSuccess:function(c,S,b,D){s.resetLoader(t,v),s.updateStatsFromPart(t,a);var O={frag:t,part:a,payload:c.data,networkDetails:D};e(O),p(O)},onError:function(c,S,b){s.resetLoader(t,v),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:a,response:c,networkDetails:b}))},onAbort:function(c,S,b){t.stats.aborted=a.stats.aborted,s.resetLoader(t,v),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:a,networkDetails:b}))},onTimeout:function(c,S,b){s.resetLoader(t,v),g(new E({type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:a,networkDetails:b}))}})})},d.updateStatsFromPart=function(t,a){var e=t.stats,s=a.stats,u=s.total;if(e.loaded+=s.loaded,u){var n=Math.round(t.duration/a.duration),l=Math.min(Math.round(e.loaded/u),n),p=(n-l)*Math.round(e.loaded/l);e.total=e.loaded+p}else e.total=Math.max(e.loaded,e.total);var g=e.loading,v=s.loading;g.start?g.first+=v.first-v.start:(g.start=v.start,g.first=v.first),g.end=v.end},d.resetLoader=function(t,a){t.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},y}();function h(y,d){d===void 0&&(d=null);var t=d||y,a={frag:y,part:d,responseType:"arraybuffer",url:t.url,rangeStart:0,rangeEnd:0},e=t.byteRangeStartOffset,s=t.byteRangeEndOffset;return Object(_.isFiniteNumber)(e)&&Object(_.isFiniteNumber)(s)&&(a.rangeStart=e,a.rangeEnd=s),a}var E=function(y){var d,t;function a(e){for(var s,u=arguments.length,n=new Array(u>1?u-1:0),l=1;l>8*(15-l)&255;return n},s.setDecryptDataFromLevelKey=function(u,n){var l=u;return(u==null?void 0:u.method)==="AES-128"&&u.uri&&!u.iv&&((l=k.LevelKey.fromURI(u.uri)).method=u.method,l.iv=this.createInitializationVector(n),l.keyFormat="identity"),l},s.setElementaryStreamInfo=function(u,n,l,p,g,v){v===void 0&&(v=!1);var r=this.elementaryStreams,i=r[u];i?(i.startPTS=Math.min(i.startPTS,n),i.endPTS=Math.max(i.endPTS,l),i.startDTS=Math.min(i.startDTS,p),i.endDTS=Math.max(i.endDTS,g)):r[u]={startPTS:n,endPTS:l,startDTS:p,endDTS:g,partial:v}},s.clearElementaryStreamInfo=function(){var u=this.elementaryStreams;u[_.AUDIO]=null,u[_.VIDEO]=null,u[_.AUDIOVIDEO]=null},E(e,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var u=this.sn;typeof u!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),u=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,u)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(A.isFiniteNumber)(this.programDateTime))return null;var u=Object(A.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*u}},{key:"encrypted",get:function(){var u;return!((u=this.decryptdata)===null||u===void 0||!u.keyFormat||!this.decryptdata.uri)}}]),e}(y),t=function(a){function e(s,u,n,l,p){var g;(g=a.call(this,n)||this).fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new o.LoadStats,g.duration=s.decimalFloatingPoint("DURATION"),g.gap=s.bool("GAP"),g.independent=s.bool("INDEPENDENT"),g.relurl=s.enumeratedString("URI"),g.fragment=u,g.index=l;var v=s.enumeratedString("BYTERANGE");return v&&g.setByteRange(v,p),p&&(g.fragOffset=p.fragOffset+p.duration),g}return L(e,a),E(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var s=this.elementaryStreams;return!!(s.audio||s.video||s.audiovideo)}}]),e}(y)},"./src/loader/key-loader.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return R});var _=f("./src/events.ts"),T=f("./src/errors.ts"),A=f("./src/utils/logger.ts"),R=function(){function I(o){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=o,this._registerListeners()}var k=I.prototype;return k._registerListeners=function(){this.hls.on(_.Events.KEY_LOADING,this.onKeyLoading,this)},k._unregisterListeners=function(){this.hls.off(_.Events.KEY_LOADING,this.onKeyLoading)},k.destroy=function(){for(var o in this._unregisterListeners(),this.loaders){var L=this.loaders[o];L&&L.destroy()}this.loaders={}},k.onKeyLoading=function(o,L){var m=L.frag,h=m.type,E=this.loaders[h];if(m.decryptdata){var y=m.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var d=this.hls.config;if(E&&(A.logger.warn("abort previous key loader for type:"+h),E.abort()),!y)return void A.logger.warn("key uri is falsy");var t=d.loader,a=m.loader=this.loaders[h]=new t(d);this.decrypturl=y,this.decryptkey=null;var e={url:y,frag:m,responseType:"arraybuffer"},s={timeout:d.fragLoadingTimeOut,maxRetry:0,retryDelay:d.fragLoadingRetryDelay,maxRetryDelay:d.fragLoadingMaxRetryTimeout,highWaterMark:0},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(e,s,u)}else this.decryptkey&&(m.decryptdata.key=this.decryptkey,this.hls.trigger(_.Events.KEY_LOADED,{frag:m}))}else A.logger.warn("Missing decryption data on fragment in onKeyLoading")},k.loadsuccess=function(o,L,m){var h=m.frag;h.decryptdata?(this.decryptkey=h.decryptdata.key=new Uint8Array(o.data),h.loader=null,delete this.loaders[h.type],this.hls.trigger(_.Events.KEY_LOADED,{frag:h})):A.logger.error("after key load, decryptdata unset")},k.loaderror=function(o,L){var m=L.frag,h=m.loader;h&&h.abort(),delete this.loaders[m.type],this.hls.trigger(_.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:m,response:o})},k.loadtimeout=function(o,L){var m=L.frag,h=m.loader;h&&h.abort(),delete this.loaders[m.type],this.hls.trigger(_.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:m})},I}()},"./src/loader/level-details.ts":function(N,w,f){f.r(w),f.d(w,"LevelDetails",function(){return A});var _=f("./src/polyfills/number.ts");function T(R,I){for(var k=0;ko.endSN||L>0||L===0&&m>0,this.updated||this.advanced?this.misses=Math.floor(.6*o.misses):this.misses=o.misses+1,this.availabilityDelay=o.availabilityDelay},I=R,(k=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(_.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var o=this.driftEndTime-this.driftStartTime;return o>0?1e3*(this.driftEnd-this.driftStart)/o:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var o;return(o=this.partList)!==null&&o!==void 0&&o.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var o;return(o=this.fragments)!==null&&o!==void 0&&o.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var o;return(o=this.partList)!==null&&o!==void 0&&o.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var o;return(o=this.partList)!==null&&o!==void 0&&o.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&T(I.prototype,k),R}()},"./src/loader/level-key.ts":function(N,w,f){f.r(w),f.d(w,"LevelKey",function(){return A});var _=f("./node_modules/url-toolkit/src/url-toolkit.js");function T(R,I){for(var k=0;k2){var p=l.shift()+".";return p+=parseInt(l.shift()).toString(16),p+=("000"+parseInt(l.shift()).toString(16)).substr(-4)}return n},u.resolve=function(n,l){return T.buildAbsoluteURL(l,n,{alwaysNormalize:!0})},u.parseMasterPlaylist=function(n,l){var p,g=[],v={},r=!1;for(m.lastIndex=0;(p=m.exec(n))!=null;)if(p[1]){var i=new k.AttrList(p[1]),c={attrs:i,bitrate:i.decimalInteger("AVERAGE-BANDWIDTH")||i.decimalInteger("BANDWIDTH"),name:i.NAME,url:u.resolve(p[2],l)},S=i.decimalResolution("RESOLUTION");S&&(c.width=S.width,c.height=S.height),a((i.CODECS||"").split(/[ ,]+/).filter(function(D){return D}),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=u.convertAVC1ToAVCOTI(c.videoCodec)),g.push(c)}else if(p[3]){var b=new k.AttrList(p[3]);b["DATA-ID"]&&(r=!0,v[b["DATA-ID"]]=b)}return{levels:g,sessionData:r?v:null}},u.parseMasterPlaylistMedia=function(n,l,p,g){var v;g===void 0&&(g=[]);var r=[],i=0;for(h.lastIndex=0;(v=h.exec(n))!==null;){var c=new k.AttrList(v[1]);if(c.TYPE===p){var S={attrs:c,bitrate:0,id:i++,groupId:c["GROUP-ID"],instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:p,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?u.resolve(c.URI,l):""};if(g.length){var b=u.findGroup(g,S.groupId)||g[0];e(S,b,"audioCodec"),e(S,b,"textCodec")}r.push(S)}}return r},u.parseLevelPlaylist=function(n,l,p,g,v){var r,i,c,S=new R.LevelDetails(l),b=S.fragments,D=null,O=0,C=0,x=0,P=0,F=null,M=new A.Fragment(g,l),B=-1,U=!1;for(E.lastIndex=0,S.m3u8=n;(r=E.exec(n))!==null;){U&&(U=!1,(M=new A.Fragment(g,l)).start=x,M.sn=O,M.cc=P,M.level=p,D&&(M.initSegment=D,M.rawProgramDateTime=D.rawProgramDateTime));var G=r[1];if(G){M.duration=parseFloat(G);var K=(" "+r[2]).slice(1);M.title=K||null,M.tagList.push(K?["INF",G,K]:["INF",G])}else if(r[3])Object(_.isFiniteNumber)(M.duration)&&(M.start=x,c&&(M.levelkey=c),M.sn=O,M.level=p,M.cc=P,M.urlId=v,b.push(M),M.relurl=(" "+r[3]).slice(1),s(M,F),F=M,x+=M.duration,O++,C=0,U=!0);else if(r[4]){var H=(" "+r[4]).slice(1);F?M.setByteRange(H,F):M.setByteRange(H)}else if(r[5])M.rawProgramDateTime=(" "+r[5]).slice(1),M.tagList.push(["PROGRAM-DATE-TIME",M.rawProgramDateTime]),B===-1&&(B=b.length);else{if(!(r=r[0].match(y))){o.logger.warn("No matches on slow regex match for level playlist!");continue}for(i=1;i-1){o.logger.warn("Keyformat "+vt+" is not supported from the manifest");continue}if(vt!=="identity")continue;J&&(c=I.LevelKey.fromURL(l,nt),nt&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(J)>=0&&(c.method=J,c.keyFormat=vt,gt&&(c.keyID=gt),dt&&(c.keyFormatVersions=dt),c.iv=it));break;case"START":var mt=new k.AttrList(W).decimalFloatingPoint("TIME-OFFSET");Object(_.isFiniteNumber)(mt)&&(S.startTimeOffset=mt);break;case"MAP":var lt=new k.AttrList(W);M.relurl=lt.URI,lt.BYTERANGE&&M.setByteRange(lt.BYTERANGE),M.level=p,M.sn="initSegment",c&&(M.levelkey=c),M.initSegment=null,D=M,U=!0;break;case"SERVER-CONTROL":var ot=new k.AttrList(W);S.canBlockReload=ot.bool("CAN-BLOCK-RELOAD"),S.canSkipUntil=ot.optionalFloat("CAN-SKIP-UNTIL",0),S.canSkipDateRanges=S.canSkipUntil>0&&ot.bool("CAN-SKIP-DATERANGES"),S.partHoldBack=ot.optionalFloat("PART-HOLD-BACK",0),S.holdBack=ot.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Mt=new k.AttrList(W);S.partTarget=Mt.decimalFloatingPoint("PART-TARGET");break;case"PART":var yt=S.partList;yt||(yt=S.partList=[]);var Lt=C>0?yt[yt.length-1]:void 0,Nt=C++,kt=new A.Part(new k.AttrList(W),M,l,Nt,Lt);yt.push(kt),M.duration+=kt.duration;break;case"PRELOAD-HINT":var St=new k.AttrList(W);S.preloadHint=St;break;case"RENDITION-REPORT":var Kt=new k.AttrList(W);S.renditionReports=S.renditionReports||[],S.renditionReports.push(Kt);break;default:o.logger.warn("line parsed but not handled: "+r)}}}F&&!F.relurl?(b.pop(),x-=F.duration,S.partList&&(S.fragmentHint=F)):S.partList&&(s(M,F),M.cc=P,S.fragmentHint=M);var Bt=b.length,bt=b[0],Vt=b[Bt-1];if((x+=S.skippedSegments*S.targetduration)>0&&Bt&&Vt){S.averagetargetduration=x/Bt;var Ut=Vt.sn;S.endSN=Ut!=="initSegment"?Ut:0,bt&&(S.startCC=bt.cc,bt.initSegment||S.fragments.every(function(Rt){return Rt.relurl&&(At=Rt.relurl,d.test((_t=(Et=T.parseURL(At))===null||Et===void 0?void 0:Et.path)!=null?_t:""));var At,_t,Et})&&(o.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(M=new A.Fragment(g,l)).relurl=Vt.relurl,M.level=p,M.sn="initSegment",bt.initSegment=M,S.needSidxRanges=!0))}else S.endSN=0,S.startCC=0;return S.fragmentHint&&(x+=S.fragmentHint.duration),S.totalduration=x,S.endCC=P,B>0&&function(Rt,At){for(var _t=Rt[At],Et=At;Et--;){var It=Rt[Et];if(!It)return;It.programDateTime=_t.programDateTime-1e3*It.duration,_t=It}}(b,B),S},u}();function a(u,n){["video","audio","text"].forEach(function(l){var p=u.filter(function(v){return Object(L.isCodecType)(v,l)});if(p.length){var g=p.filter(function(v){return v.lastIndexOf("avc1",0)===0||v.lastIndexOf("mp4a",0)===0});n[l+"Codec"]=g.length>0?g[0]:p[0],u=u.filter(function(v){return p.indexOf(v)===-1})}}),n.unknownCodecs=u}function e(u,n,l){var p=n[l];p&&(u[l]=p)}function s(u,n){u.rawProgramDateTime?u.programDateTime=Date.parse(u.rawProgramDateTime):n!=null&&n.programDateTime&&(u.programDateTime=n.endProgramDateTime),Object(_.isFiniteNumber)(u.programDateTime)||(u.programDateTime=null,u.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(N,w,f){f.r(w);var _=f("./src/polyfills/number.ts"),T=f("./src/events.ts"),A=f("./src/errors.ts"),R=f("./src/utils/logger.ts"),I=f("./src/utils/mp4-tools.ts"),k=f("./src/loader/m3u8-parser.ts"),o=f("./src/types/loader.ts"),L=f("./src/utils/attr-list.ts");function m(E,y){var d=E.url;return d!==void 0&&d.indexOf("data:")!==0||(d=y.url),d}var h=function(){function E(d){this.hls=void 0,this.loaders=Object.create(null),this.hls=d,this.registerListeners()}var y=E.prototype;return y.registerListeners=function(){var d=this.hls;d.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(T.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(T.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),d.on(T.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var d=this.hls;d.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(T.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(T.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),d.off(T.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(d){var t=this.hls.config,a=t.pLoader,e=t.loader,s=new(a||e)(t);return d.loader=s,this.loaders[d.type]=s,s},y.getInternalLoader=function(d){return this.loaders[d.type]},y.resetInternalLoader=function(d){this.loaders[d]&&delete this.loaders[d]},y.destroyInternalLoaders=function(){for(var d in this.loaders){var t=this.loaders[d];t&&t.destroy(),this.resetInternalLoader(d)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(d,t){var a=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:o.PlaylistContextType.MANIFEST,url:a,deliveryDirectives:null})},y.onLevelLoading=function(d,t){var a=t.id,e=t.level,s=t.url,u=t.deliveryDirectives;this.load({id:a,groupId:null,level:e,responseType:"text",type:o.PlaylistContextType.LEVEL,url:s,deliveryDirectives:u})},y.onAudioTrackLoading=function(d,t){var a=t.id,e=t.groupId,s=t.url,u=t.deliveryDirectives;this.load({id:a,groupId:e,level:null,responseType:"text",type:o.PlaylistContextType.AUDIO_TRACK,url:s,deliveryDirectives:u})},y.onSubtitleTrackLoading=function(d,t){var a=t.id,e=t.groupId,s=t.url,u=t.deliveryDirectives;this.load({id:a,groupId:e,level:null,responseType:"text",type:o.PlaylistContextType.SUBTITLE_TRACK,url:s,deliveryDirectives:u})},y.load=function(d){var t,a,e,s,u,n,l=this.hls.config,p=this.getInternalLoader(d);if(p){var g=p.context;if(g&&g.url===d.url)return void R.logger.trace("[playlist-loader]: playlist request ongoing");R.logger.log("[playlist-loader]: aborting previous loader for type: "+d.type),p.abort()}switch(d.type){case o.PlaylistContextType.MANIFEST:a=l.manifestLoadingMaxRetry,e=l.manifestLoadingTimeOut,s=l.manifestLoadingRetryDelay,u=l.manifestLoadingMaxRetryTimeout;break;case o.PlaylistContextType.LEVEL:case o.PlaylistContextType.AUDIO_TRACK:case o.PlaylistContextType.SUBTITLE_TRACK:a=0,e=l.levelLoadingTimeOut;break;default:a=l.levelLoadingMaxRetry,e=l.levelLoadingTimeOut,s=l.levelLoadingRetryDelay,u=l.levelLoadingMaxRetryTimeout}if(p=this.createInternalLoader(d),(t=d.deliveryDirectives)!==null&&t!==void 0&&t.part&&(d.type===o.PlaylistContextType.LEVEL&&d.level!==null?n=this.hls.levels[d.level].details:d.type===o.PlaylistContextType.AUDIO_TRACK&&d.id!==null?n=this.hls.audioTracks[d.id].details:d.type===o.PlaylistContextType.SUBTITLE_TRACK&&d.id!==null&&(n=this.hls.subtitleTracks[d.id].details),n)){var v=n.partTarget,r=n.targetduration;v&&r&&(e=Math.min(1e3*Math.max(3*v,.8*r),e))}var i={timeout:e,maxRetry:a,retryDelay:s,maxRetryDelay:u,highWaterMark:0},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};p.load(d,i,c)},y.loadsuccess=function(d,t,a,e){if(e===void 0&&(e=null),a.isSidxRequest)return this.handleSidxRequest(d,a),void this.handlePlaylistLoaded(d,t,a,e);this.resetInternalLoader(a.type);var s=d.data;s.indexOf("#EXTM3U")===0?(t.parsing.start=performance.now(),s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(d,t,a,e):this.handleMasterPlaylist(d,t,a,e)):this.handleManifestParsingError(d,a,"no EXTM3U delimiter",e)},y.loaderror=function(d,t,a){a===void 0&&(a=null),this.handleNetworkError(t,a,!1,d)},y.loadtimeout=function(d,t,a){a===void 0&&(a=null),this.handleNetworkError(t,a,!0)},y.handleMasterPlaylist=function(d,t,a,e){var s=this.hls,u=d.data,n=m(d,a),l=k.default.parseMasterPlaylist(u,n),p=l.levels,g=l.sessionData;if(p.length){var v=p.map(function(b){return{id:b.attrs.AUDIO,audioCodec:b.audioCodec}}),r=p.map(function(b){return{id:b.attrs.SUBTITLES,textCodec:b.textCodec}}),i=k.default.parseMasterPlaylistMedia(u,n,"AUDIO",v),c=k.default.parseMasterPlaylistMedia(u,n,"SUBTITLES",r),S=k.default.parseMasterPlaylistMedia(u,n,"CLOSED-CAPTIONS");i.length&&(i.some(function(b){return!b.url})||!p[0].audioCodec||p[0].attrs.AUDIO||(R.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),i.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new L.AttrList({}),bitrate:0,url:""}))),s.trigger(T.Events.MANIFEST_LOADED,{levels:p,audioTracks:i,subtitles:c,captions:S,url:n,stats:t,networkDetails:e,sessionData:g})}else this.handleManifestParsingError(d,a,"no level found in manifest",e)},y.handleTrackOrLevelPlaylist=function(d,t,a,e){var s=this.hls,u=a.id,n=a.level,l=a.type,p=m(d,a),g=Object(_.isFiniteNumber)(u)?u:0,v=Object(_.isFiniteNumber)(n)?n:g,r=function(D){switch(D.type){case o.PlaylistContextType.AUDIO_TRACK:return o.PlaylistLevelType.AUDIO;case o.PlaylistContextType.SUBTITLE_TRACK:return o.PlaylistLevelType.SUBTITLE;default:return o.PlaylistLevelType.MAIN}}(a),i=k.default.parseLevelPlaylist(d.data,p,v,r,g);if(i.fragments.length){if(l===o.PlaylistContextType.MANIFEST){var c={attrs:new L.AttrList({}),bitrate:0,details:i,name:"",url:p};s.trigger(T.Events.MANIFEST_LOADED,{levels:[c],audioTracks:[],url:p,stats:t,networkDetails:e,sessionData:null})}if(t.parsing.end=performance.now(),i.needSidxRanges){var S,b=(S=i.fragments[0].initSegment)===null||S===void 0?void 0:S.url;this.load({url:b,isSidxRequest:!0,type:l,level:n,levelDetails:i,id:u,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else a.levelDetails=i,this.handlePlaylistLoaded(d,t,a,e)}else s.trigger(T.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:p,reason:"no fragments found in level",level:typeof a.level=="number"?a.level:void 0})},y.handleSidxRequest=function(d,t){var a=Object(I.parseSegmentIndex)(new Uint8Array(d.data));if(a){var e=a.references,s=t.levelDetails;e.forEach(function(u,n){var l=u.info,p=s.fragments[n];p.byteRange.length===0&&p.setByteRange(String(1+l.end-l.start)+"@"+String(l.start)),p.initSegment&&p.initSegment.setByteRange(String(a.moovEndOffset)+"@0")})}},y.handleManifestParsingError=function(d,t,a,e){this.hls