import{b as xt,o as $,c as Z,K as Ct,L as wt,u as j,bg as Pt,bf as Ft,U as Tt,d as jt,a as V,R as ht,X as ft,W as et,V as st,bI as ie,r as Dt,T as ut,$ as qt,a4 as Ee,w as ue,i as de,_ as ce,Q as Jt,F as Xt,a9 as zt,Y as te,a3 as Te,M as Se,P as be,aa as Ht,n as he,f as Le}from"./@vue.f8dfc830.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.trigger(T.Events.ERROR,{type:A.ErrorTypes.NETWORK_ERROR,details:A.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===o.PlaylistContextType.MANIFEST,url:d.url,reason:a,response:d,context:t,networkDetails:e})},y.handleNetworkError=function(d,t,a,e){a===void 0&&(a=!1),R.logger.warn("[playlist-loader]: A network "+(a?"timeout":"error")+" occurred while loading "+d.type+" level: "+d.level+" id: "+d.id+' group-id: "'+d.groupId+'"');var s=A.ErrorDetails.UNKNOWN,u=!1,n=this.getInternalLoader(d);switch(d.type){case o.PlaylistContextType.MANIFEST:s=a?A.ErrorDetails.MANIFEST_LOAD_TIMEOUT:A.ErrorDetails.MANIFEST_LOAD_ERROR,u=!0;break;case o.PlaylistContextType.LEVEL:s=a?A.ErrorDetails.LEVEL_LOAD_TIMEOUT:A.ErrorDetails.LEVEL_LOAD_ERROR,u=!1;break;case o.PlaylistContextType.AUDIO_TRACK:s=a?A.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:A.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case o.PlaylistContextType.SUBTITLE_TRACK:s=a?A.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:A.ErrorDetails.SUBTITLE_LOAD_ERROR,u=!1}n&&this.resetInternalLoader(d.type);var l={type:A.ErrorTypes.NETWORK_ERROR,details:s,fatal:u,url:d.url,loader:n,context:d,networkDetails:t};e&&(l.response=e),this.hls.trigger(T.Events.ERROR,l)},y.handlePlaylistLoaded=function(d,t,a,e){var s=a.type,u=a.level,n=a.id,l=a.groupId,p=a.loader,g=a.levelDetails,v=a.deliveryDirectives;if(g!=null&&g.targetduration){if(p)switch(g.live&&(p.getCacheAge&&(g.ageHeader=p.getCacheAge()||0),p.getCacheAge&&!isNaN(g.ageHeader)||(g.ageHeader=0)),s){case o.PlaylistContextType.MANIFEST:case o.PlaylistContextType.LEVEL:this.hls.trigger(T.Events.LEVEL_LOADED,{details:g,level:u||0,id:n||0,stats:t,networkDetails:e,deliveryDirectives:v});break;case o.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(T.Events.AUDIO_TRACK_LOADED,{details:g,id:n||0,groupId:l||"",stats:t,networkDetails:e,deliveryDirectives:v});break;case o.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(T.Events.SUBTITLE_TRACK_LOADED,{details:g,id:n||0,groupId:l||"",stats:t,networkDetails:e,deliveryDirectives:v})}}else this.handleManifestParsingError(d,a,"invalid target duration",e)},E}();w.default=h},"./src/polyfills/number.ts":function(N,w,f){f.r(w),f.d(w,"isFiniteNumber",function(){return _}),f.d(w,"MAX_SAFE_INTEGER",function(){return T});var _=Number.isFinite||function(A){return typeof A=="number"&&isFinite(A)},T=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(N,w,f){f.r(w);var _=function(){function T(){}return T.getSilentFrame=function(A,R){switch(A){case"mp4a.40.2":if(R===1)return new Uint8Array([0,200,0,128,35,128]);if(R===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(R===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(R===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(R===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(R===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(R===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(R===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(R===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},T}();w.default=_},"./src/remux/mp4-generator.ts":function(N,w,f){f.r(w);var _=Math.pow(2,32)-1,T=function(){function A(){}return A.init=function(){var R;for(R in A.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},A.types)A.types.hasOwnProperty(R)&&(A.types[R]=[R.charCodeAt(0),R.charCodeAt(1),R.charCodeAt(2),R.charCodeAt(3)]);var I=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),k=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);A.HDLR_TYPES={video:I,audio:k};var o=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),L=new Uint8Array([0,0,0,0,0,0,0,0]);A.STTS=A.STSC=A.STCO=L,A.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),A.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),A.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),A.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var m=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),E=new Uint8Array([0,0,0,1]);A.FTYP=A.box(A.types.ftyp,m,E,m,h),A.DINF=A.box(A.types.dinf,A.box(A.types.dref,o))},A.box=function(R){for(var I=8,k=arguments.length,o=new Array(k>1?k-1:0),L=1;L>24&255,E[1]=I>>16&255,E[2]=I>>8&255,E[3]=255&I,E.set(R,4),m=0,I=8;m>24&255,R>>16&255,R>>8&255,255&R,k>>24,k>>16&255,k>>8&255,255&k,o>>24,o>>16&255,o>>8&255,255&o,85,196,0,0]))},A.mdia=function(R){return A.box(A.types.mdia,A.mdhd(R.timescale,R.duration),A.hdlr(R.type),A.minf(R))},A.mfhd=function(R){return A.box(A.types.mfhd,new Uint8Array([0,0,0,0,R>>24,R>>16&255,R>>8&255,255&R]))},A.minf=function(R){return R.type==="audio"?A.box(A.types.minf,A.box(A.types.smhd,A.SMHD),A.DINF,A.stbl(R)):A.box(A.types.minf,A.box(A.types.vmhd,A.VMHD),A.DINF,A.stbl(R))},A.moof=function(R,I,k){return A.box(A.types.moof,A.mfhd(R),A.traf(k,I))},A.moov=function(R){for(var I=R.length,k=[];I--;)k[I]=A.trak(R[I]);return A.box.apply(null,[A.types.moov,A.mvhd(R[0].timescale,R[0].duration)].concat(k).concat(A.mvex(R)))},A.mvex=function(R){for(var I=R.length,k=[];I--;)k[I]=A.trex(R[I]);return A.box.apply(null,[A.types.mvex].concat(k))},A.mvhd=function(R,I){I*=R;var k=Math.floor(I/(_+1)),o=Math.floor(I%(_+1)),L=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,R>>24&255,R>>16&255,R>>8&255,255&R,k>>24,k>>16&255,k>>8&255,255&k,o>>24,o>>16&255,o>>8&255,255&o,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return A.box(A.types.mvhd,L)},A.sdtp=function(R){var I,k,o=R.samples||[],L=new Uint8Array(4+o.length);for(I=0;I>>8&255),L.push(255&o),L=L.concat(Array.prototype.slice.call(k));for(I=0;I>>8&255),m.push(255&o),m=m.concat(Array.prototype.slice.call(k));var h=A.box(A.types.avcC,new Uint8Array([1,L[3],L[4],L[5],255,224|R.sps.length].concat(L).concat([R.pps.length]).concat(m))),E=R.width,y=R.height,d=R.pixelRatio[0],t=R.pixelRatio[1];return A.box(A.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,E>>8&255,255&E,y>>8&255,255&y,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h,A.box(A.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),A.box(A.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,t>>24,t>>16&255,t>>8&255,255&t])))},A.esds=function(R){var I=R.config.length;return new Uint8Array([0,0,0,0,3,23+I,0,1,0,4,15+I,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([I]).concat(R.config).concat([6,1,2]))},A.mp4a=function(R){var I=R.samplerate;return A.box(A.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]),A.box(A.types.esds,A.esds(R)))},A.mp3=function(R){var I=R.samplerate;return A.box(A.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,R.channelCount,0,16,0,0,0,0,I>>8&255,255&I,0,0]))},A.stsd=function(R){return R.type==="audio"?R.isAAC||R.codec!=="mp3"?A.box(A.types.stsd,A.STSD,A.mp4a(R)):A.box(A.types.stsd,A.STSD,A.mp3(R)):A.box(A.types.stsd,A.STSD,A.avc1(R))},A.tkhd=function(R){var I=R.id,k=R.duration*R.timescale,o=R.width,L=R.height,m=Math.floor(k/(_+1)),h=Math.floor(k%(_+1));return A.box(A.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,I>>24&255,I>>16&255,I>>8&255,255&I,0,0,0,0,m>>24,m>>16&255,m>>8&255,255&m,h>>24,h>>16&255,h>>8&255,255&h,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,o>>8&255,255&o,0,0,L>>8&255,255&L,0,0]))},A.traf=function(R,I){var k=A.sdtp(R),o=R.id,L=Math.floor(I/(_+1)),m=Math.floor(I%(_+1));return A.box(A.types.traf,A.box(A.types.tfhd,new Uint8Array([0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o])),A.box(A.types.tfdt,new Uint8Array([1,0,0,0,L>>24,L>>16&255,L>>8&255,255&L,m>>24,m>>16&255,m>>8&255,255&m])),A.trun(R,k.length+16+20+8+16+8+8),k)},A.trak=function(R){return R.duration=R.duration||4294967295,A.box(A.types.trak,A.tkhd(R),A.mdia(R))},A.trex=function(R){var I=R.id;return A.box(A.types.trex,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,255&I,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},A.trun=function(R,I){var k,o,L,m,h,E,y=R.samples||[],d=y.length,t=12+16*d,a=new Uint8Array(t);for(I+=8+t,a.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,I>>>24&255,I>>>16&255,I>>>8&255,255&I],0),k=0;k>>24&255,L>>>16&255,L>>>8&255,255&L,m>>>24&255,m>>>16&255,m>>>8&255,255&m,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,E>>>24&255,E>>>16&255,E>>>8&255,255&E],12+16*k);return A.box(A.types.trun,a)},A.initSegment=function(R){A.types||A.init();var I=A.moov(R),k=new Uint8Array(A.FTYP.byteLength+I.byteLength);return k.set(A.FTYP),k.set(I,A.FTYP.byteLength),k},A}();T.types=void 0,T.HDLR_TYPES=void 0,T.STTS=void 0,T.STSC=void 0,T.STCO=void 0,T.STSZ=void 0,T.VMHD=void 0,T.SMHD=void 0,T.STSD=void 0,T.FTYP=void 0,T.DINF=void 0,w.default=T},"./src/remux/mp4-remuxer.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return d}),f.d(w,"normalizePts",function(){return t});var _=f("./src/polyfills/number.ts"),T=f("./src/remux/aac-helper.ts"),A=f("./src/remux/mp4-generator.ts"),R=f("./src/events.ts"),I=f("./src/errors.ts"),k=f("./src/utils/logger.ts"),o=f("./src/types/loader.ts"),L=f("./src/utils/timescale-conversion.ts");function m(){return(m=Object.assign||function(s){for(var u=1;u0?g:v.pts},n[0].pts);return l&&k.logger.debug("PTS rollover detected"),p},u.remux=function(n,l,p,g,v,r,i,c){var S,b,D,O,C,x,P=v,F=v,M=n.pid>-1,B=l.pid>-1,U=l.samples.length,G=n.samples.length>0,K=U>1;if((!M||G)&&(!B||K)||this.ISGenerated||i){this.ISGenerated||(D=this.generateIS(n,l,v));var H=this.isVideoContiguous,Y=-1;if(K&&(Y=function(rt){for(var z=0;z0){k.logger.warn("[mp4-remuxer]: Dropped "+Y+" out of "+U+" video samples due to a missing keyframe");var W=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(Y),l.dropped+=Y,F+=(l.samples[0].pts-W)/(l.timescale||9e4)}else Y===-1&&(k.logger.warn("[mp4-remuxer]: No keyframe found out of "+U+" video samples"),x=!1);if(this.ISGenerated){if(G&&K){var q=this.getVideoStartPts(l.samples),Q=(t(n.samples[0].pts,q)-q)/l.inputTimeScale;P+=Math.max(0,Q),F+=Math.max(0,-Q)}if(G){if(n.samplerate||(k.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),D=this.generateIS(n,l,v)),b=this.remuxAudio(n,P,this.isAudioContiguous,r,B||K||c===o.PlaylistLevelType.AUDIO?F:void 0),K){var tt=b?b.endPTS-b.startPTS:0;l.inputTimeScale||(k.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),D=this.generateIS(n,l,v)),S=this.remuxVideo(l,F,H,tt)}}else K&&(S=this.remuxVideo(l,F,H,0));S&&(S.firstKeyFrame=Y,S.independent=Y!==-1)}}return this.ISGenerated&&(p.samples.length&&(C=this.remuxID3(p,v)),g.samples.length&&(O=this.remuxText(g,v))),{audio:b,video:S,initSegment:D,independent:x,text:O,id3:C}},u.generateIS=function(n,l,p){var g,v,r,i=n.samples,c=l.samples,S=this.typeSupported,b={},D=!Object(_.isFiniteNumber)(this._initPTS),O="audio/mp4";if(D&&(g=v=1/0),n.config&&i.length&&(n.timescale=n.samplerate,n.isAAC||(S.mpeg?(O="audio/mpeg",n.codec=""):S.mp3&&(n.codec="mp3")),b.audio={id:"audio",container:O,codec:n.codec,initSegment:!n.isAAC&&S.mpeg?new Uint8Array(0):A.default.initSegment([n]),metadata:{channelCount:n.channelCount}},D&&(r=n.inputTimeScale,g=v=i[0].pts-Math.round(r*p))),l.sps&&l.pps&&c.length&&(l.timescale=l.inputTimeScale,b.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:A.default.initSegment([l]),metadata:{width:l.width,height:l.height}},D)){r=l.inputTimeScale;var C=this.getVideoStartPts(c),x=Math.round(r*p);v=Math.min(v,t(c[0].dts,C)-x),g=Math.min(g,C-x)}if(Object.keys(b).length)return this.ISGenerated=!0,D&&(this._initPTS=g,this._initDTS=v),{tracks:b,initPTS:g,timescale:r}},u.remuxVideo=function(n,l,p,g){var v,r,i,c=n.inputTimeScale,S=n.samples,b=[],D=S.length,O=this._initPTS,C=this.nextAvcDts,x=8,P=Number.POSITIVE_INFINITY,F=Number.NEGATIVE_INFINITY,M=0,B=!1;p&&C!==null||(C=l*c-(S[0].pts-t(S[0].dts,S[0].pts)));for(var U=0;UG.pts&&(M=Math.max(Math.min(M,G.pts-G.dts),-18e3)),G.dts0?U-1:U].dts&&(B=!0)}B&&S.sort(function(Et,It){var me=Et.dts-It.dts,ye=Et.pts-It.pts;return me||ye}),r=S[0].dts,i=S[S.length-1].dts;var K=Math.round((i-r)/(D-1));if(M<0){if(M<-2*K){k.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(L.toMsFromMpegTsClock)(-K,!0)+" ms");for(var H=M,Y=0;YK;if(Q||q<-1){Q?k.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(q,!0)+" ms ("+q+"dts) hole between fragments detected, filling it"):k.logger.warn("AVC: "+Object(L.toMsFromMpegTsClock)(-q,!0)+" ms ("+q+"dts) overlapping between fragments detected"),r=C;var tt=S[0].pts-q;S[0].dts=r,S[0].pts=tt,k.logger.log("Video: First PTS/DTS adjusted: "+Object(L.toMsFromMpegTsClock)(tt,!0)+"/"+Object(L.toMsFromMpegTsClock)(r,!0)+", delta: "+Object(L.toMsFromMpegTsClock)(q,!0)+" ms")}}y&&(r=Math.max(0,r));for(var rt=0,z=0,at=0;at0?lt-1:lt].dts;if(Bt.stretchShortVideoTrack&&this.nextAudioPts!==null){var Vt=Math.floor(Bt.maxBufferHole*c),Ut=(g?P+g*c:this.nextAudioPts)-ot.pts;Ut>Vt?((v=Ut-bt)<0&&(v=bt),k.logger.log("[mp4-remuxer]: It is approximately "+Ut/90+" ms to the next segment; using duration "+v/90+" ms for the last video frame.")):v=bt}else v=bt}var Rt=Math.round(ot.pts-ot.dts);b.push(new a(ot.key,v,yt,Rt))}if(b.length&&h&&h<70){var At=b[0].flags;At.dependsOn=2,At.isNonSync=0}console.assert(v!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=C=i+v,this.isVideoContiguous=!0;var _t={data1:A.default.moof(n.sequenceNumber++,r,m({},n,{samples:b})),data2:gt,startPTS:P/c,endPTS:(F+v)/c,startDTS:r/c,endDTS:C/c,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:n.dropped};return n.samples=[],n.dropped=0,console.assert(gt.length,"MDAT length must not be zero"),_t},u.remuxAudio=function(n,l,p,g,v){var r=n.inputTimeScale,i=r/(n.samplerate?n.samplerate:r),c=n.isAAC?1024:1152,S=c*i,b=this._initPTS,D=!n.isAAC&&this.typeSupported.mpeg,O=[],C=n.samples,x=D?0:8,P=this.nextAudioPts||-1,F=l*r;if(this.isAudioContiguous=p=p||C.length&&P>0&&(g&&Math.abs(F-P)<9e3||Math.abs(t(C[0].pts-b,F)-P)<20*S),C.forEach(function(St){St.pts=t(St.pts-b,F)}),!p||P<0){if(!(C=C.filter(function(St){return St.pts>=0})).length)return;P=v===0?0:g?Math.max(0,F):C[0].pts}if(n.isAAC)for(var M=v!==void 0,B=this.config.maxAudioFramesDrift,U=0,G=P;U=B*S&&W<1e4&&M){var q=Math.round(Y/S);(G=H-q*S)<0&&(q--,G+=S),U===0&&(this.nextAudioPts=P=G),k.logger.warn("[mp4-remuxer]: Injecting "+q+" audio frame @ "+(G/r).toFixed(3)+"s due to "+Math.round(1e3*Y/r)+" ms gap.");for(var Q=0;Q0))return;J+=x;try{z=new Uint8Array(J)}catch{return void this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:I.ErrorTypes.MUX_ERROR,details:I.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:J,reason:"fail allocating audio mdat "+J})}D||(new DataView(z.buffer).setUint32(0,J),z.set(A.default.types.mdat,4))}z.set(vt,x);var lt=vt.byteLength;x+=lt,O.push(new a(!0,c,lt,0)),X=mt}var ot=O.length;if(ot){var Mt=O[O.length-1];this.nextAudioPts=P=X+i*Mt.duration;var yt=D?new Uint8Array(0):A.default.moof(n.sequenceNumber++,at/i,m({},n,{samples:O}));n.samples=[];var Lt=at/r,Nt=P/r,kt={data1:yt,data2:z,startPTS:Lt,endPTS:Nt,startDTS:Lt,endDTS:Nt,type:"audio",hasAudio:!0,hasVideo:!1,nb:ot};return this.isAudioContiguous=!0,console.assert(z.length,"MDAT length must not be zero"),kt}},u.remuxEmptyAudio=function(n,l,p,g){var v=n.inputTimeScale,r=v/(n.samplerate?n.samplerate:v),i=this.nextAudioPts,c=(i!==null?i:g.startDTS*v)+this._initDTS,S=g.endDTS*v+this._initDTS,b=1024*r,D=Math.ceil((S-c)/b),O=T.default.getSilentFrame(n.manifestCodec||n.codec,n.channelCount);if(k.logger.warn("[mp4-remuxer]: remux empty Audio"),O){for(var C=[],x=0;x4294967296;)s+=n;return s}var a=function(s,u,n,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=u,this.size=n,this.cts=l,this.flags=new e(s)},e=function(s){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=s?2:1,this.isNonSync=s?0:1}},"./src/remux/passthrough-remuxer.ts":function(N,w,f){f.r(w);var _=f("./src/polyfills/number.ts"),T=f("./src/utils/mp4-tools.ts"),A=f("./src/loader/fragment.ts"),R=f("./src/utils/logger.ts"),I=function(){function L(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var m=L.prototype;return m.destroy=function(){},m.resetTimeStamp=function(h){this.initPTS=h,this.lastEndDTS=null},m.resetNextTimestamp=function(){this.lastEndDTS=null},m.resetInitSegment=function(h,E,y){this.audioCodec=E,this.videoCodec=y,this.generateInitSegment(h),this.emitInitSegment=!0},m.generateInitSegment=function(h){var E=this.audioCodec,y=this.videoCodec;if(!h||!h.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var d=this.initData=Object(T.parseInitSegment)(h);E||(E=o(d.audio,A.ElementaryStreamTypes.AUDIO)),y||(y=o(d.video,A.ElementaryStreamTypes.VIDEO));var t={};d.audio&&d.video?t.audiovideo={container:"video/mp4",codec:E+","+y,initSegment:h,id:"main"}:d.audio?t.audio={container:"audio/mp4",codec:E,initSegment:h,id:"audio"}:d.video?t.video={container:"video/mp4",codec:y,initSegment:h,id:"main"}:R.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=t},m.remux=function(h,E,y,d,t){var a=this.initPTS,e=this.lastEndDTS,s={audio:void 0,video:void 0,text:d,id3:y,initSegment:void 0};Object(_.isFiniteNumber)(e)||(e=this.lastEndDTS=t||0);var u=E.samples;if(!u||!u.length)return s;var n={initPTS:void 0,timescale:1},l=this.initData;if(l&&l.length||(this.generateInitSegment(u),l=this.initData),!l||!l.length)return R.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),s;this.emitInitSegment&&(n.tracks=this.initTracks,this.emitInitSegment=!1),Object(_.isFiniteNumber)(a)||(this.initPTS=n.initPTS=a=k(l,u,e));var p=Object(T.getDuration)(u,l),g=e,v=p+g;Object(T.offsetStartDTS)(l,u,a),p>0?this.lastEndDTS=v:(R.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var r=!!l.audio,i=!!l.video,c="";r&&(c+="audio"),i&&(c+="video");var S={data1:u,startPTS:g,startDTS:g,endPTS:v,endDTS:v,type:c,hasAudio:r,hasVideo:i,nb:1,dropped:0};return s.audio=S.type==="audio"?S:void 0,s.video=S.type!=="audio"?S:void 0,s.text=d,s.id3=y,s.initSegment=n,s},L}(),k=function(L,m,h){return Object(T.getStartDTS)(L,m)-h};function o(L,m){var h=L==null?void 0:L.codec;return h&&h.length>4?h:h==="hvc1"?"hvc1.1.c.L120.90":h==="av01"?"av01.0.04M.08":h==="avc1"||m===A.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}w.default=I},"./src/task-loop.ts":function(N,w,f){f.r(w),f.d(w,"default",function(){return _});var _=function(){function T(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var A=T.prototype;return A.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},A.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},A.onHandlerDestroyed=function(){},A.hasInterval=function(){return!!this._tickInterval},A.hasNextTick=function(){return!!this._tickTimer},A.setInterval=function(R){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,R),!0)},A.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},A.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},A.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},A.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},A.doTick=function(){},T}()},"./src/types/level.ts":function(N,w,f){function _(o,L){for(var m=0;mNumber.MAX_SAFE_INTEGER?1/0:o},I.hexadecimalInteger=function(k){if(this[k]){var o=(this[k]||"0x").slice(2);o=(1&o.length?"0":"")+o;for(var L=new Uint8Array(o.length/2),m=0;mNumber.MAX_SAFE_INTEGER?1/0:o},I.decimalFloatingPoint=function(k){return parseFloat(this[k])},I.optionalFloat=function(k,o){var L=this[k];return L?parseFloat(L):o},I.enumeratedString=function(k){return this[k]},I.bool=function(k){return this[k]==="YES"},I.decimalResolution=function(k){var o=_.exec(this[k]);if(o!==null)return{width:parseInt(o[1],10),height:parseInt(o[2],10)}},R.parseAttrList=function(k){var o,L={};for(T.lastIndex=0;(o=T.exec(k))!==null;){var m=o[2];m.indexOf('"')===0&&m.lastIndexOf('"')===m.length-1&&(m=m.slice(1,-1)),L[o[1]]=m}return L},R}()},"./src/utils/binary-search.ts":function(N,w,f){f.r(w),w.default={search:function(_,T){for(var A=0,R=_.length-1,I=null,k=null;A<=R;){var o=T(k=_[I=(A+R)/2|0]);if(o>0)A=I+1;else{if(!(o<0))return k;R=I-1}}return null}}},"./src/utils/buffer-helper.ts":function(N,w,f){f.r(w),f.d(w,"BufferHelper",function(){return A});var _=f("./src/utils/logger.ts"),T={length:0,start:function(){return 0},end:function(){return 0}},A=function(){function R(){}return R.isBuffered=function(I,k){try{if(I){for(var o=R.getBuffered(I),L=0;L=o.start(L)&&k<=o.end(L))return!0}}catch{}return!1},R.bufferInfo=function(I,k,o){try{if(I){var L,m=R.getBuffered(I),h=[];for(L=0;LE&&(L[h-1].end=I[m].end):L.push(I[m])}else L.push(I[m])}else L=I;for(var y,d=0,t=k,a=k,e=0;e=s&&k=r&&A.logger.log(this.time+" ["+r+"] "+i)},v}(),t=function(v){for(var r=[],i=0;io&&(this.logger.log(_.DEBUG,"Too large cursor position "+this.pos),this.pos=o)},r.moveCursor=function(i){var c=this.pos+i;if(i>1)for(var S=this.pos+1;S=144&&this.backSpace();var c=I(i);this.pos>=o?this.logger.log(_.ERROR,"Cannot insert "+i.toString(16)+" ("+c+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(c,this.currPenState),this.moveCursor(1))},r.clearFromPos=function(i){var c;for(c=i;c0&&(S=i?"["+c.join(" | ")+"]":c.join(` `)),S},r.getTextAndFormat=function(){return this.rows},v}(),n=function(){function v(i,c,S){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=i,this.outputFilter=c,this.mode=null,this.verbose=0,this.displayedMemory=new u(S),this.nonDisplayedMemory=new u(S),this.lastOutputScreen=new u(S),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=S}var r=v.prototype;return r.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},r.getHandler=function(){return this.outputFilter},r.setHandler=function(i){this.outputFilter=i},r.setPAC=function(i){this.writeScreen.setPAC(i)},r.setBkgData=function(i){this.writeScreen.setBkgData(i)},r.setMode=function(i){i!==this.mode&&(this.mode=i,this.logger.log(_.INFO,"MODE="+i),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=i)},r.insertChars=function(i){for(var c=0;c=46,c.italics)c.foreground="white";else{var S=Math.floor(i/2)-16;c.foreground=["white","green","blue","cyan","red","yellow","magenta"][S]}this.logger.log(_.INFO,"MIDROW: "+JSON.stringify(c)),this.writeScreen.setPen(c)},r.outputDataUpdate=function(i){i===void 0&&(i=!1);var c=this.logger.time;c!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,c,this.lastOutputScreen),i&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:c):this.cueStartTime=c,this.lastOutputScreen.copy(this.displayedMemory))},r.cueSplitAtTime=function(i){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,i,this.displayedMemory),this.cueStartTime=i))},v}(),l=function(){function v(i,c,S){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var b=new d;this.channels=[null,new n(i,c,b),new n(i+1,S,b)],this.cmdHistory={a:null,b:null},this.logger=b}var r=v.prototype;return r.getHandler=function(i){return this.channels[i].getHandler()},r.setHandler=function(i,c){this.channels[i].setHandler(c)},r.addData=function(i,c){var S,b,D,O=!1;this.logger.time=i;for(var C=0;C ("+t([b,D])+")"),(S=this.parseCmd(b,D))||(S=this.parseMidrow(b,D)),S||(S=this.parsePAC(b,D)),S||(S=this.parseBackgroundAttributes(b,D)),!S&&(O=this.parseChars(b,D))){var x=this.currentChannel;x&&x>0?this.channels[x].insertChars(O):this.logger.log(_.WARNING,"No channel found yet. TEXT-MODE?")}S||O||this.logger.log(_.WARNING,"Couldn't parse cleaned data "+t([b,D])+" orig: "+t([c[C],c[C+1]]))}},r.parseCmd=function(i,c){var S=this.cmdHistory;if(!((i===20||i===28||i===21||i===29)&&c>=32&&c<=47||(i===23||i===31)&&c>=33&&c<=35))return!1;if(g(i,c,S))return p(null,null,S),this.logger.log(_.DEBUG,"Repeated command ("+t([i,c])+") is dropped"),!0;var b=i===20||i===21||i===23?1:2,D=this.channels[b];return i===20||i===21||i===28||i===29?c===32?D.ccRCL():c===33?D.ccBS():c===34?D.ccAOF():c===35?D.ccAON():c===36?D.ccDER():c===37?D.ccRU(2):c===38?D.ccRU(3):c===39?D.ccRU(4):c===40?D.ccFON():c===41?D.ccRDC():c===42?D.ccTR():c===43?D.ccRTD():c===44?D.ccEDM():c===45?D.ccCR():c===46?D.ccENM():c===47&&D.ccEOC():D.ccTO(c-32),p(i,c,S),this.currentChannel=b,!0},r.parseMidrow=function(i,c){var S=0;if((i===17||i===25)&&c>=32&&c<=47){if((S=i===17?1:2)!==this.currentChannel)return this.logger.log(_.ERROR,"Mismatch channel in midrow parsing"),!1;var b=this.channels[S];return!!b&&(b.ccMIDROW(c),this.logger.log(_.DEBUG,"MIDROW ("+t([i,c])+")"),!0)}return!1},r.parsePAC=function(i,c){var S,b=this.cmdHistory;if(!((i>=17&&i<=23||i>=25&&i<=31)&&c>=64&&c<=127||(i===16||i===24)&&c>=64&&c<=95))return!1;if(g(i,c,b))return p(null,null,b),!0;var D=i<=23?1:2;S=c>=64&&c<=95?D===1?L[i]:h[i]:D===1?m[i]:E[i];var O=this.channels[D];return!!O&&(O.setPAC(this.interpretPAC(S,c)),p(i,c,b),this.currentChannel=D,!0)},r.interpretPAC=function(i,c){var S,b={color:null,italics:!1,indent:null,underline:!1,row:i};return S=c>95?c-96:c-64,b.underline=(1&S)==1,S<=13?b.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(S/2)]:S<=15?(b.italics=!0,b.color="white"):b.indent=4*Math.floor((S-16)/2),b},r.parseChars=function(i,c){var S,b,D=null,O=null;if(i>=25?(S=2,O=i-8):(S=1,O=i),O>=17&&O<=19?(b=O===17?c+80:O===18?c+112:c+144,this.logger.log(_.INFO,"Special char '"+I(b)+"' in channel "+S),D=[b]):i>=32&&i<=127&&(D=c===0?[i]:[i,c]),D){var C=t(D);this.logger.log(_.DEBUG,"Char codes = "+C.join(",")),p(i,c,this.cmdHistory)}return D},r.parseBackgroundAttributes=function(i,c){var S;if(!((i===16||i===24)&&c>=32&&c<=47||(i===23||i===31)&&c>=45&&c<=47))return!1;var b={};i===16||i===24?(S=Math.floor((c-32)/2),b.background=y[S],c%2==1&&(b.background=b.background+"_semi")):c===45?b.background="transparent":(b.foreground="black",c===47&&(b.underline=!0));var D=i<=23?1:2;return this.channels[D].setBkgData(b),p(i,c,this.cmdHistory),!0},r.reset=function(){for(var i=0;i=16?d--:d++;var n=Object(_.fixLineBreaks)(t.trim()),l=Object(T.generateCueId)(o,L,n);k&&k.cues&&k.cues.getCueById(l)||((E=new e(o,L,n)).id=l,E.line=s+1,E.align="left",E.position=10+Math.min(80,10*Math.floor(8*d/32)),a.push(E))}return k&&a.length&&(a.sort(function(p,g){return p.line==="auto"||g.line==="auto"?0:p.line>8&&g.line>8?g.line-p.line:p.line-g.line}),a.forEach(function(p){return Object(A.addCueToTrack)(k,p)})),a}};w.default=I},"./src/utils/discontinuities.ts":function(N,w,f){f.r(w),f.d(w,"findFirstFragWithCC",function(){return R}),f.d(w,"shouldAlignOnDiscontinuities",function(){return I}),f.d(w,"findDiscontinuousReferenceFrag",function(){return k}),f.d(w,"adjustSlidingStart",function(){return L}),f.d(w,"alignStream",function(){return m}),f.d(w,"alignPDT",function(){return h});var _=f("./src/polyfills/number.ts"),T=f("./src/utils/logger.ts"),A=f("./src/controller/level-helper.ts");function R(E,y){for(var d=null,t=0,a=E.length;td.startCC||E&&E.cc=this.minWeight_},R.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},R.destroy=function(){},A}();w.default=T},"./src/utils/ewma.ts":function(N,w,f){f.r(w);var _=function(){function T(R,I,k){I===void 0&&(I=0),k===void 0&&(k=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=R,this.alpha_=R?Math.exp(Math.log(.5)/R):0,this.estimate_=I,this.totalWeight_=k}var A=T.prototype;return A.sample=function(R,I){var k=Math.pow(this.alpha_,R);this.estimate_=I*(1-k)+k*this.estimate_,this.totalWeight_+=R},A.getTotalWeight=function(){return this.totalWeight_},A.getEstimate=function(){if(this.alpha_){var R=1-Math.pow(this.alpha_,this.totalWeight_);if(R)return this.estimate_/R}return this.estimate_},T}();w.default=_},"./src/utils/fetch-loader.ts":function(N,w,f){f.r(w),f.d(w,"fetchSupported",function(){return m});var _=f("./src/polyfills/number.ts"),T=f("./src/loader/load-stats.ts"),A=f("./src/demux/chunk-cache.ts");function R(d){var t=typeof Map=="function"?new Map:void 0;return(R=function(a){if(a===null||(e=a,Function.toString.call(e).indexOf("[native code]")===-1))return a;var e;if(typeof a!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(a))return t.get(a);t.set(a,s)}function s(){return I(a,arguments,L(this).constructor)}return s.prototype=Object.create(a.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),o(s,a)})(d)}function I(d,t,a){return(I=k()?Reflect.construct:function(e,s,u){var n=[null];n.push.apply(n,s);var l=new(Function.bind.apply(e,n));return u&&o(l,u.prototype),l}).apply(null,arguments)}function k(){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 o(d,t){return(o=Object.setPrototypeOf||function(a,e){return a.__proto__=e,a})(d,t)}function L(d){return(L=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(d)}function m(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var h=function(){function d(a){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=a.fetchSetup||E,this.controller=new self.AbortController,this.stats=new T.LoadStats}var t=d.prototype;return t.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var a=this.response;a&&a.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var a;this.abortInternal(),(a=this.callbacks)!==null&&a!==void 0&&a.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(a,e,s){var u=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var l=function(r,i){var c={method:"GET",mode:"cors",credentials:"same-origin",signal:i};return r.rangeEnd&&(c.headers=new self.Headers({Range:"bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)})),c}(a,this.controller.signal),p=s.onProgress,g=a.responseType==="arraybuffer",v=g?"byteLength":"length";this.context=a,this.config=e,this.callbacks=s,this.request=this.fetchSetup(a,l),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),s.onTimeout(n,a,u.response)},e.timeout),self.fetch(this.request).then(function(r){if(u.response=u.loader=r,!r.ok){var i=r.status,c=r.statusText;throw new y(c||"fetch, bad network response",i,r)}return n.loading.first=Math.max(self.performance.now(),n.loading.start),n.total=parseInt(r.headers.get("Content-Length")||"0"),p&&Object(_.isFiniteNumber)(e.highWaterMark)?u.loadProgressively(r,n,a,e.highWaterMark,p):g?r.arrayBuffer():r.text()}).then(function(r){var i=u.response;self.clearTimeout(u.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first),n.loaded=n.total=r[v];var c={url:i.url,data:r};p&&!Object(_.isFiniteNumber)(e.highWaterMark)&&p(n,a,r,i),s.onSuccess(c,n,a,i)}).catch(function(r){if(self.clearTimeout(u.requestTimeout),!n.aborted){var i=r.code||0;s.onError({code:i,text:r.message},a,r.details)}})},t.getCacheAge=function(){var a=null;if(this.response){var e=this.response.headers.get("age");a=e?parseFloat(e):null}return a},t.loadProgressively=function(a,e,s,u,n){u===void 0&&(u=0);var l=new A.default,p=a.body.getReader();return function g(){return p.read().then(function(v){if(v.done)return l.dataLength&&n(e,s,l.flush(),a),Promise.resolve(new ArrayBuffer(0));var r=v.value,i=r.length;return e.loaded+=i,i=u&&n(e,s,l.flush(),a)):n(e,s,r,a),g()}).catch(function(){return Promise.reject()})}()},d}();function E(d,t){return new self.Request(d.url,t)}var y=function(d){var t,a;function e(s,u,n){var l;return(l=d.call(this,s)||this).code=void 0,l.details=void 0,l.code=u,l.details=n,l}return a=d,(t=e).prototype=Object.create(a.prototype),t.prototype.constructor=t,o(t,a),e}(R(Error));w.default=h},"./src/utils/imsc1-ttml-parser.ts":function(N,w,f){f.r(w),f.d(w,"IMSC1_CODEC",function(){return L}),f.d(w,"parseIMSC1",function(){return y});var _=f("./src/utils/mp4-tools.ts"),T=f("./src/utils/vttparser.ts"),A=f("./src/utils/vttcue.ts"),R=f("./src/demux/id3.ts"),I=f("./src/utils/timescale-conversion.ts"),k=f("./src/utils/webvtt-parser.ts");function o(){return(o=Object.assign||function(n){for(var l=1;l"):_}function I(o){if(self.console&&o===!0||typeof o=="object"){(function(L){for(var m=arguments.length,h=new Array(m>1?m-1:0),E=1;E>24,u[n+1]=l>>16&255,u[n+2]=l>>8&255,u[n+3]=255&l}function m(u,n){var l,p,g,v=[];if(!n.length)return v;"data"in u?(l=u.data,p=u.start,g=u.end):(p=0,g=(l=u).byteLength);for(var r=p;r1?r+i:g;if(I(l.subarray(r+4,r+8))===n[0])if(n.length===1)v.push({data:l,start:r+8,end:c});else{var S=m({data:l,start:r+8,end:c},n.slice(1));S.length&&R.apply(v,S)}r=c}return v}function h(u){var n=m(u,["moov"])[0],l=n?n.end:null,p=m(u,["sidx"]);if(!p||!p[0])return null;var g=[],v=p[0],r=v.data[0],i=r===0?8:16,c=o(v,i);i+=4,i+=r===0?8:16,i+=2;var S=v.end+0,b=k(v,i);i+=2;for(var D=0;D>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var P=o(v,O);O+=4,g.push({referenceSize:x,subsegmentDuration:P,info:{duration:P/c,start:S,end:S+x-1}}),S+=x,i=O+=4}return{earliestPresentationTime:0,timescale:c,version:r,referencesCount:b,references:g,moovEndOffset:l}}function E(u){for(var n=[],l=m(u,["moov","trak"]),p=0;pR)&&(this.startTime=R),this.endTime=I,this.screen=k,this.timelineController.createCaptionsTrack(this.trackName)},A.reset=function(){this.cueRanges=[]},T}()},"./src/utils/texttrack-utils.ts":function(N,w,f){f.r(w),f.d(w,"sendAddTrackEvent",function(){return T}),f.d(w,"addCueToTrack",function(){return A}),f.d(w,"clearCurrentCues",function(){return R}),f.d(w,"removeCuesInRange",function(){return I}),f.d(w,"getCuesInRange",function(){return k});var _=f("./src/utils/logger.ts");function T(o,L){var m;try{m=new Event("addtrack")}catch{(m=document.createEvent("Event")).initEvent("addtrack",!1,!1)}m.track=o,L.dispatchEvent(m)}function A(o,L){var m=o.mode;if(m==="disabled"&&(o.mode="hidden"),o.cues&&!o.cues.getCueById(L.id))try{if(o.addCue(L),!o.cues.getCueById(L.id))throw new Error("addCue is failed for: "+L)}catch(E){_.logger.debug("[texttrack-utils]: "+E);var h=new self.TextTrackCue(L.startTime,L.endTime,L.text);h.id=L.id,o.addCue(h)}m==="disabled"&&(o.mode=m)}function R(o){var L=o.mode;if(L==="disabled"&&(o.mode="hidden"),o.cues)for(var m=o.cues.length;m--;)o.removeCue(o.cues[m]);L==="disabled"&&(o.mode=L)}function I(o,L,m){var h=o.mode;if(h==="disabled"&&(o.mode="hidden"),o.cues&&o.cues.length>0)for(var E=k(o.cues,L,m),y=0;ya[s].endTime)return-1;for(var u=0,n=s;u<=n;){var l=Math.floor((n+u)/2);if(ea[l].startTime&&u-1)for(var y=E,d=o.length;y=L&&t.endTime<=m)h.push(t);else if(t.startTime>m)return h}return h}},"./src/utils/time-ranges.ts":function(N,w,f){f.r(w),w.default={toString:function(_){for(var T="",A=_.length,R=0;R1?L-1:0),h=1;h100)throw new Error("Position must be between 0 and 100.");g=c,this.hasBeenReset=!0}})),Object.defineProperty(h,"positionAlign",I({},E,{get:function(){return v},set:function(c){var S=R(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");v=S,this.hasBeenReset=!0}})),Object.defineProperty(h,"size",I({},E,{get:function(){return r},set:function(c){if(c<0||c>100)throw new Error("Size must be between 0 and 100.");r=c,this.hasBeenReset=!0}})),Object.defineProperty(h,"align",I({},E,{get:function(){return i},set:function(c){var S=R(c);if(!S)throw new SyntaxError("An invalid or illegal string was specified.");i=S,this.hasBeenReset=!0}})),h.displayState=void 0}return k.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},k}()},"./src/utils/vttparser.ts":function(N,w,f){f.r(w),f.d(w,"parseTimeStamp",function(){return A}),f.d(w,"fixLineBreaks",function(){return m}),f.d(w,"VTTParser",function(){return h});var _=f("./src/utils/vttcue.ts"),T=function(){function E(){}return E.prototype.decode=function(y,d){if(!y)return"";if(typeof y!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(y))},E}();function A(E){function y(t,a,e,s){return 3600*(0|t)+60*(0|a)+(0|e)+parseFloat(s||0)}var d=E.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return d?parseFloat(d[2])>59?y(d[2],d[3],0,d[4]):y(d[1],d[2],d[3],d[4]):null}var R=function(){function E(){this.values=Object.create(null)}var y=E.prototype;return y.set=function(d,t){this.get(d)||t===""||(this.values[d]=t)},y.get=function(d,t,a){return a?this.has(d)?this.values[d]:t[a]:this.has(d)?this.values[d]:t},y.has=function(d){return d in this.values},y.alt=function(d,t,a){for(var e=0;e=0&&a<=100)return this.set(d,a),!0}return!1},E}();function I(E,y,d,t){var a=t?E.split(t):[E];for(var e in a)if(typeof a[e]=="string"){var s=a[e].split(d);s.length===2&&y(s[0],s[1])}}var k=new _.default(0,0,""),o=k.align==="middle"?"middle":"center";function L(E,y,d){var t=E;function a(){var s=A(E);if(s===null)throw new Error("Malformed timestamp: "+t);return E=E.replace(/^[^\sa-zA-Z-]+/,""),s}function e(){E=E.replace(/^\s+/,"")}if(e(),y.startTime=a(),e(),E.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);E=E.substr(3),e(),y.endTime=a(),e(),function(s,u){var n=new R;I(s,function(g,v){var r;switch(g){case"region":for(var i=d.length-1;i>=0;i--)if(d[i].id===v){n.set(g,d[i].region);break}break;case"vertical":n.alt(g,v,["rl","lr"]);break;case"line":r=v.split(","),n.integer(g,r[0]),n.percent(g,r[0])&&n.set("snapToLines",!1),n.alt(g,r[0],["auto"]),r.length===2&&n.alt("lineAlign",r[1],["start",o,"end"]);break;case"position":r=v.split(","),n.percent(g,r[0]),r.length===2&&n.alt("positionAlign",r[1],["start",o,"end","line-left","line-right","auto"]);break;case"size":n.percent(g,v);break;case"align":n.alt(g,v,["start",o,"end","left","right"])}},/:/,/\s/),u.region=n.get("region",null),u.vertical=n.get("vertical","");var l=n.get("line","auto");l==="auto"&&k.line===-1&&(l=-1),u.line=l,u.lineAlign=n.get("lineAlign","start"),u.snapToLines=n.get("snapToLines",!0),u.size=n.get("size",100),u.align=n.get("align",o);var p=n.get("position","auto");p==="auto"&&k.position===50&&(p=u.align==="start"||u.align==="left"?0:u.align==="end"||u.align==="right"?100:50),u.position=p}(E,y)}function m(E){return E.replace(//gi,` `)}var h=function(){function E(){this.state="INITIAL",this.buffer="",this.decoder=new T,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var y=E.prototype;return y.parse=function(d){var t=this;function a(){var l=t.buffer,p=0;for(l=m(l);p")===-1){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{L(e,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var n=e.indexOf("-->")!==-1;if(!e||n&&(u=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=` `),t.cue.text+=e;continue;case"BADCUE":e||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},y.flush=function(){var d=this;try{if((d.cue||d.state==="HEADER")&&(d.buffer+=` `,d.parse()),d.state==="INITIAL"||d.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){d.onparsingerror&&d.onparsingerror(t)}return d.onflush&&d.onflush(),this},E}()},"./src/utils/webvtt-parser.ts":function(N,w,f){f.r(w),f.d(w,"generateCueId",function(){return m}),f.d(w,"parseWebVTT",function(){return h});var _=f("./src/polyfills/number.ts"),T=f("./src/utils/vttparser.ts"),A=f("./src/demux/id3.ts"),R=f("./src/utils/timescale-conversion.ts"),I=f("./src/remux/mp4-remuxer.ts"),k=/\r\n|\n\r|\n|\r/g,o=function(E,y,d){return d===void 0&&(d=0),E.substr(d,y.length)===y},L=function(E){for(var y=5381,d=E.length;d;)y=33*y^E.charCodeAt(--d);return(y>>>0).toString()};function m(E,y,d){return L(E.toString())+L(y.toString())+L(d)}function h(E,y,d,t,a,e,s,u){var n,l=new T.VTTParser,p=Object(A.utf8ArrayToStr)(new Uint8Array(E)).trim().replace(k,` `).split(` `),g=[],v=Object(R.toMpegTsClockFromTimescale)(y,d),r="00:00.000",i=0,c=0,S=!0,b=!1;l.oncue=function(D){var O=t[a],C=t.ccOffset,x=(i-v)/9e4;if(O!=null&&O.new&&(c!==void 0?C=t.ccOffset=O.start:function(B,U,G){var K=B[U],H=B[K.prevCC];if(!H||!H.new&&K.new)return B.ccOffset=B.presentationOffset=K.start,void(K.new=!1);for(;(Y=H)!==null&&Y!==void 0&&Y.new;){var Y;B.ccOffset+=K.start-H.start,K.new=!1,H=B[(K=H).prevCC]}B.presentationOffset=G}(t,a,x)),x&&(C=x-t.presentationOffset),b){var P=D.endTime-D.startTime,F=Object(I.normalizePts)(9e4*(D.startTime+C-c),9e4*e)/9e4;D.startTime=F,D.endTime=F+P}var M=D.text.trim();D.text=decodeURIComponent(encodeURIComponent(M)),D.id||(D.id=m(D.startTime,D.endTime,M)),D.endTime>0&&g.push(D)},l.onparsingerror=function(D){n=D},l.onflush=function(){n?u(n):s(g)},p.forEach(function(D){if(S){if(o(D,"X-TIMESTAMP-MAP=")){S=!1,b=!0,D.substr(16).split(",").forEach(function(O){o(O,"LOCAL:")?r=O.substr(6):o(O,"MPEGTS:")&&(i=parseInt(O.substr(7)))});try{c=function(O){var C=parseInt(O.substr(-3)),x=parseInt(O.substr(-6,2)),P=parseInt(O.substr(-9,2)),F=O.length>9?parseInt(O.substr(0,O.indexOf(":"))):0;if(!(Object(_.isFiniteNumber)(C)&&Object(_.isFiniteNumber)(x)&&Object(_.isFiniteNumber)(P)&&Object(_.isFiniteNumber)(F)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+O);return C+=1e3*x,(C+=6e4*P)+36e5*F}(r)/1e3}catch(O){b=!1,n=O}return}D===""&&(S=!1)}l.parse(D+` `)}),l.flush()}},"./src/utils/xhr-loader.ts":function(N,w,f){f.r(w);var _=f("./src/utils/logger.ts"),T=f("./src/loader/load-stats.ts"),A=/^age:\s*[\d.]+\s*$/m,R=function(){function I(o){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=o?o.xhrSetup:null,this.stats=new T.LoadStats,this.retryDelay=0}var k=I.prototype;return k.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},k.abortInternal=function(){var o=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),o&&(o.onreadystatechange=null,o.onprogress=null,o.readyState!==4&&(this.stats.aborted=!0,o.abort()))},k.abort=function(){var o;this.abortInternal(),(o=this.callbacks)!==null&&o!==void 0&&o.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},k.load=function(o,L,m){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=o,this.config=L,this.callbacks=m,this.retryDelay=L.retryDelay,this.loadInternal()},k.loadInternal=function(){var o=this.config,L=this.context;if(o){var m=this.loader=new self.XMLHttpRequest,h=this.stats;h.loading.first=0,h.loaded=0;var E=this.xhrSetup;try{if(E)try{E(m,L.url)}catch{m.open("GET",L.url,!0),E(m,L.url)}m.readyState||m.open("GET",L.url,!0)}catch(y){return void this.callbacks.onError({code:m.status,text:y.message},L,m)}L.rangeEnd&&m.setRequestHeader("Range","bytes="+L.rangeStart+"-"+(L.rangeEnd-1)),m.onreadystatechange=this.readystatechange.bind(this),m.onprogress=this.loadprogress.bind(this),m.responseType=L.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.timeout),m.send()}},k.readystatechange=function(){var o=this.context,L=this.loader,m=this.stats;if(o&&L){var h=L.readyState,E=this.config;if(!m.aborted&&h>=2)if(self.clearTimeout(this.requestTimeout),m.loading.first===0&&(m.loading.first=Math.max(self.performance.now(),m.loading.start)),h===4){L.onreadystatechange=null,L.onprogress=null;var y=L.status;if(y>=200&&y<300){var d,t;if(m.loading.end=Math.max(self.performance.now(),m.loading.first),t=o.responseType==="arraybuffer"?(d=L.response).byteLength:(d=L.responseText).length,m.loaded=m.total=t,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(m,o,d,L),!this.callbacks)return;var e={url:L.responseURL,data:d};this.callbacks.onSuccess(e,m,o,L)}else m.retry>=E.maxRetry||y>=400&&y<499?(_.logger.error(y+" while loading "+o.url),this.callbacks.onError({code:y,text:L.statusText},o,L)):(_.logger.warn(y+" while loading "+o.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,E.maxRetryDelay),m.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout)}},k.loadtimeout=function(){_.logger.warn("timeout while loading "+this.context.url);var o=this.callbacks;o&&(this.abortInternal(),o.onTimeout(this.stats,this.context,this.loader))},k.loadprogress=function(o){var L=this.stats;L.loaded=o.loaded,o.lengthComputable&&(L.total=o.total)},k.getCacheAge=function(){var o=null;if(this.loader&&A.test(this.loader.getAllResponseHeaders())){var L=this.loader.getResponseHeader("age");o=L?parseFloat(L):null}return o},I}();w.default=R}}).default);var Qt=Ie(fe.exports);const Ce={name:"d-icon"},pt=Object.assign(Ce,{props:{icon:String,size:[Number,String]},setup:function(N){const w=N,f=xt(()=>({fontSize:/^\d+$/.test(w.size)?w.size+"px":w.size}));return(_,T)=>($(),Z("i",{class:Ct(["d-icon iconfont",N.icon]),style:wt(j(f))},null,6))}});pt.__scopeId="data-v-0c690e66";Pt("data-v-4cb76d59");const we={class:"d-player-top"},Oe={class:"top-title"},xe={class:"top-title"};Ft();const Pe={props:{title:{default:""}},setup(N){Date.prototype.format=function(_){let T={"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds()};for(var A in T)new RegExp("("+A+")").test(_)&&(_=_.replace(RegExp.$1,RegExp.$1.length==1?T[A]:("00"+T[A]).substr((""+T[A]).length)));return _};let w=Dt("00:00:00");w.value=new Date().format("hh:mm:ss");let f=null;return f=setInterval(()=>{w.value=new Date().format("hh:mm:ss")},1e3),ce(()=>{clearInterval(f)}),(_,T)=>($(),Z("div",we,[V("p",Oe,st(N.title||""),1),V("p",xe,st(j(w)),1)]))},__scopeId:"data-v-4cb76d59"};Pt("data-v-ac2469ec");const Fe={class:"d-status"},Me={class:"d-flex-center"},Ne={class:"d-flex-center"},Be=Tt("5X\u901F\u64AD\u653E\u4E2D ");Ft();var ge=jt({props:["state"],setup:N=>(w,f)=>ht(($(),Z("div",Fe,[ht(V("li",Me,[et(pt,{size:"18",class:"d-status-icon",icon:"icon-volume-"+(N.state.volume==0?"mute":N.state.volume>.5?"up":"down")},null,8,["icon"]),Tt(" "+st(~~(100*N.state.volume))+"% ",1)],512),[[ft,N.state.handleType=="volume"]]),ht(V("li",Ne,[et(pt,{size:"12",icon:"icon-play"}),et(pt,{size:"12",icon:"icon-play",style:{"margin-right":"5px"}}),Be],512),[[ft,N.state.handleType=="playbackRate"||N.state.isMultiplesPlay]])],512)),[[ft,N.state.handleType||N.state.isMultiplesPlay]])});ge.__scopeId="data-v-ac2469ec",Pt("data-v-385f7870");const Ue=["checked","true-value","false-value"],Ge=V("span",{class:"d-switch_action"},null,-1);Ft();var Yt=jt({props:{modelValue:{type:[Number,String,Boolean]},width:{type:String,default:"40px"},trueValue:{type:[Number,String,Boolean],default:!0},falseValue:{type:[Number,String,Boolean],default:!0},activeColor:{type:[String],default:"#409EFF"}},emits:["update:modelValue","change"],setup(N,{emit:w}){const f=N;ie(R=>({"014e5dc0":N.width,e4e32852:N.activeColor}));const _=Dt(null),T=xt(()=>f.modelValue===f.trueValue),A=()=>{he(()=>{const R=_.value.checked;w("update:modelValue",R),w("change",R)})};return(R,I)=>($(),Z("div",{class:Ct(["d-switch",{"is-checked":j(T)}])},[V("input",{class:"d-switch__input",ref:_,type:"checkbox",checked:j(T),onChange:A,"true-value":N.trueValue,"false-value":N.falseValue},null,40,Ue),Ge],2))}});Yt.__scopeId="data-v-385f7870",Pt("data-v-b2384226");const je={key:0},Ke=V("i",{class:"rotating iconfont icon-loading f50"},null,-1),Ve=[V("i",{class:"rotating iconfont icon-loading f50"},null,-1),V("p",null,"\u6B63\u5728\u7F13\u51B2...",-1)],He=[V("i",{class:"iconfont icon-replay f24 mr5"},null,-1),Tt("\u91CD\u65B0\u64AD\u653E ")],We=[V("i",{class:"iconfont icon-replay f24 mr5"},null,-1),Tt("\u8BF7\u6C42\u9519\u8BEF ")];Ft();var ve=jt({props:{loadType:String,text:{type:String,default:""}},setup(N){const w=N,{proxy:f}=Le(),_=["loadstart","waiting","ended","error","stalled"],T=()=>{f.$parent.play()},A=xt(()=>{let R="background: rgba(0, 0, 0, .1);z-index:1";return w.loadType=="loadstart"&&(R="background: rgba(0, 0, 0, 1);;z-index:3"),R});return(R,I)=>ht(($(),Z("div",{class:"d-loading",style:wt(j(A))},[V("div",null,[N.loadType=="loadstart"?($(),Z("span",je,[Ke,V("p",null,st(N.text),1)])):ut("",!0),ht(V("span",null,Ve,512),[[ft,N.loadType=="waiting"]]),ht(V("span",null,[V("p",{onClick:T,class:"d-flex-x d-pointer"},He)],512),[[ft,N.loadType=="ended"]]),ht(V("span",null,[V("p",{onClick:T,class:"d-flex-x d-pointer"},We)],512),[[ft,N.loadType=="error"||N.loadType=="stalled"]])])],4)),[[ft,_.includes(N.loadType)]])}});ve.__scopeId="data-v-b2384226";const Ot=function(N,w,f,_=!1){N&&w&&f&&N.addEventListener(w,f,_)},ct=function(N,w,f,_=!1){N&&w&&f&&N.removeEventListener(w,f,_)};Pt("data-v-5a794390");const Ye=["onMousedown"];Ft();var Gt=jt(re(ee({},{name:"DSlider"}),{props:{modelValue:{required:!0,type:Number,default:0},disabled:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},hover:{type:Boolean,default:!0},hoverText:{type:String,default:""},preload:{type:Number,default:0},size:{type:String,default:"10px"}},emits:["update:modelValue","change","onMousemove"],setup:function(N,{emit:w}){const f=N;ie(t=>({"5242b67b":N.size}));const _=Dt(null),T=Dt(null),A=qt({dragging:!1,hoverPosition:0,hoverTipsLeft:"50%"}),R=xt(()=>{let t=f.modelValue<0?0:f.modelValue>1?1:f.modelValue;return f.vertical?`height:${100*t}%`:`width:${100*t}%`}),I=xt(()=>{let t=f.preload<0?0:f.preload>1?1:f.preload;return f.vertical?`height:${100*t}%`:`width:${100*t}%`}),k=xt(()=>{let t=A.hoverPosition<0?0:A.hoverPosition>1?1:A.hoverPosition;return f.vertical?`bottom:${100*t}%`:`left:${100*t}%`}),o=t=>{t.preventDefault()},L=t=>{f.disabled||(t.preventDefault(),A.dragging=!0,h(t),Ot(window,"mousemove",y),Ot(window,"touchmove",y),Ot(window,"mouseup",d),Ot(window,"touchend",d))},m=t=>{if(!f.hover)return;let a=E(t);if(w("onMousemove",t,a),A.hoverPosition=a,f.vertical)return;let e=_.value,s=T.value.clientWidth/2,u=t.clientX-e.getBoundingClientRect().left;u{let a=E(t);w("update:modelValue",a),w("change",t,a)},E=t=>{let a=_.value,e=0;if(f.vertical){let s=a.clientHeight;e=(a.getBoundingClientRect().bottom-t.clientY)/s}else e=(t.clientX-a.getBoundingClientRect().left)/a.clientWidth;return e<0?0:e>1?1:e},y=t=>{h(t)},d=t=>{A.dragging&&(ct(window,"mousemove",y),ct(window,"touchmove",y),ct(window,"mouseup",d),ct(window,"touchend",d),ct(window,"contextmenu",d),setTimeout(()=>{A.dragging=!1},0))};return(t,a)=>($(),Z("div",{ref:_,class:Ct(["d-slider",{"is-vertical":f.vertical}]),onMousedown:Ee(L,["stop"]),onContextmenu:o},[V("div",{class:"d-slider__runway",onMousemove:m},[ht(V("div",{class:"d-slider__cursor",style:wt(j(k))},[ht(V("div",{class:"d-slider__tips",ref:T,style:wt({left:j(A).hoverTipsLeft})},st(f.hoverText),5),[[ft,f.hoverText]])],4),[[ft,f.hover]]),V("div",{class:"d-slider__preload",style:wt(j(I))},null,4),V("div",{class:"d-slider__bar",style:wt(j(R))},null,4)],32)],42,Ye))}}));Gt.__scopeId="data-v-5a794390";Pt("data-v-570fa0d1");const qe={key:0,class:"d-player-dialog"},Xe={class:"d-player-dialog-body"},ze={class:"d-player-dialog-title"},$e={class:"d-player-hotkey-panel"},Qe={class:"d-player-filter-panel"},Ze={class:"d-player-filter-panel-item"},Je=V("span",null,"\u9971\u548C\u5EA6",-1),tr={class:"d-player-filter-panel-item"},er=V("span",null,"\u4EAE\u5EA6",-1),rr={class:"d-player-filter-panel-item"},ir=V("span",null,"\u5BF9\u6BD4\u5EA6",-1),nr={key:0,class:"d-player-contextmenu"},ar=["dplayerKeyCode"],sr=V("input",{class:"d-player-copyText"},null,-1);Ft();var pe=jt({setup(N){const w=qt({show:!1,dialogType:"",dialogTitle:"",version:"1.3.1-beta.6",mouseX:0,mouseY:0}),f=[{label:"\u89C6\u9891\u8272\u5F69\u8C03\u6574",key:"filter"},{label:"\u5FEB\u6377\u952E\u8BF4\u660E",key:"hotkey"},{label:"\u590D\u5236\u89C6\u9891\u7F51\u5740",key:"copy"},{label:"\u7248\u672C\uFF1A1.3.1-beta.6",key:"version"}],_=[{key:"Space",label:"\u64AD\u653E/\u6682\u505C"},{key:"\u2192",label:"\u5355\u6B21\u5FEB\u8FDB10s\uFF0C\u957F\u63095\u500D\u901F\u64AD\u653E"},{key:"\u2190",label:"\u5FEB\u90005s"},{key:"\u2191",label:"\u97F3\u91CF\u589E\u52A010%"},{key:"\u2193",label:"\u97F3\u91CF\u589E\u52A0\u964D\u4F4E10%"},{key:"Esc",label:"\u9000\u51FA\u5168\u5C4F/\u9000\u51FA\u7F51\u9875\u5168\u5C4F"},{key:"F",label:"\u5168\u5C4F/\u9000\u51FA\u5168\u5C4F"}],T=qt({saturate:.392,brightness:.392,contrast:.392}),A=xt(()=>({left:w.mouseX+"px",top:w.mouseY+"px"}));ue(T,L=>{let m=document.querySelector("#dPlayerVideo"),h=(2.55*L.saturate).toFixed(2),E=(2.55*L.brightness).toFixed(2),y=(2.55*L.contrast).toFixed(2);m.style.filter=`saturate(${h}) brightness(${E}) contrast(${y})`});const R=()=>{T.saturate=.392,T.brightness=.392,T.contrast=.392},I=L=>{L.key=="Escape"&&o(0)},k=L=>{L.preventDefault(),Ot(window,"keydown",I),Ot(window,"click",o);let m=document.querySelector("#refPlayerWrap"),h=m.clientWidth;m.clientHeight,w.mouseX=L.clientX-m.getBoundingClientRect().left,h-w.mouseX<130&&(w.mouseX=w.mouseX+(h-w.mouseX-130)),w.mouseY=L.clientY-m.getBoundingClientRect().top,w.show=!0},o=L=>{let m=L.path[0].tagName=="LI",h=L.path[0].attributes.dplayerKeyCode&&L.path[0].attributes.dplayerKeyCode.value,E=f.map(y=>y.key);if(m&&E.includes(h))if(w.dialogTitle=L.path[0].innerText,w.dialogType=h,h=="copy"){let y=document.querySelector(".d-player-copyText");y.value=window.location.href,y.select(),document.execCommand("copy"),w.dialogType=""}else h=="version"&&(w.dialogType="");w.show=!1,ct(window,"keydown",I),ct(window,"click",o)};return de(()=>{let L=document.querySelector("#refPlayerWrap");ct(window,"keydown",I),ct(window,"click",o),ct(L,"contextmenu",k),Ot(L,"contextmenu",k)}),ce(()=>{let L=document.querySelector("#refPlayerWrap");ct(window,"keydown",I),ct(window,"click",o),ct(L,"contextmenu",k)}),(L,m)=>($(),Z("div",null,[et(te,{name:"d-fade-in"},{default:Jt(()=>[j(w).dialogType?($(),Z("div",qe,[V("div",Xe,[V("h5",ze,[Tt(st(j(w).dialogTitle)+" ",1),V("i",{onClick:m[0]||(m[0]=h=>j(w).dialogType=!1),class:"icon icon-close"},"X")]),ht(V("ul",$e,[($(),Z(Xt,null,zt(_,h=>V("li",{class:"d-player-hotkey-panel-item",key:h.key},[V("span",null,st(h.key),1),V("span",null,st(h.label),1)])),64))],512),[[ft,j(w).dialogType=="hotkey"]]),ht(V("ul",Qe,[V("li",Ze,[Je,et(Gt,{class:"filter-panel-slider",size:"5px",modelValue:j(T).saturate,"onUpdate:modelValue":m[1]||(m[1]=h=>j(T).saturate=h)},null,8,["modelValue"]),V("span",null,st(Math.round(255*j(T).saturate)),1)]),V("li",tr,[er,et(Gt,{class:"filter-panel-slider",size:"5px",modelValue:j(T).brightness,"onUpdate:modelValue":m[2]||(m[2]=h=>j(T).brightness=h)},null,8,["modelValue"]),V("span",null,st(Math.round(255*j(T).brightness)),1)]),V("li",rr,[ir,et(Gt,{class:"filter-panel-slider",size:"5px",modelValue:j(T).contrast,"onUpdate:modelValue":m[3]||(m[3]=h=>j(T).contrast=h)},null,8,["modelValue"]),V("span",null,st(Math.round(255*j(T).contrast)),1)]),V("span",{onClick:R,title:"\u91CD\u7F6E","aria-label":"\u91CD\u7F6E",class:"d-player-filter-reset"},"\u91CD\u7F6E")],512),[[ft,j(w).dialogType=="filter"]])])])):ut("",!0)]),_:1}),j(w).show?($(),Z("div",nr,[V("ul",{class:"d-player-contextmenu-body",style:wt(j(A))},[($(),Z(Xt,null,zt(f,h=>V("li",{dplayerKeyCode:h.key,key:h.key},st(h.label),9,ar)),64))],4),sr])):ut("",!0)]))}});pe.__scopeId="data-v-570fa0d1";const Zt=N=>{let w=~~(N/3600),f=~~(N%3600/60),_=~~(N%60);return w=w<10?"0"+w:w,f=f<10?"0"+f:f,_=_<10?"0"+_:_,`${w}:${f}:${_}`},Wt="ontouchstart"in window,le=["loadstart","play","pause","playing","seeking","seeked","waiting","durationchange","progress","canplay","timeupdate","ended","error","stalled"],or={width:{type:String,default:"800px"},height:{type:String,default:"450px"},color:{type:String,default:"#409eff"},src:{required:!0,type:String,default:""},title:{type:String,default:""},type:{type:String,default:"video/mp4"},poster:{type:String,default:""},webFullScreen:{type:Boolean,default:!1},speed:{type:Boolean,default:!0},currentTime:{type:Number,default:0},playsinline:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},speedRate:{type:Array,default:()=>["2.0","1.5","1.25","1.0","0.75","0.5"]},autoPlay:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},mirror:{type:Boolean,default:!1},ligthOff:{type:Boolean,default:!1},volume:{type:[String,Number],default:.3},control:{type:Boolean,default:!0},controlBtns:{type:Array,default:["audioTrack","quality","speedRate","volume","setting","pip","pageFullScreen","fullScreen"]},preload:{type:String,default:"auto"}};Pt("data-v-01791e9e");const lr={class:"d-player-video",id:"dPlayerVideo"},ur=["controls","webkit-playsinline","playsinline","volume","muted","loop","preload","src","poster"],dr={class:"d-player-lightoff"},cr={key:1,class:"d-player-state"},hr={class:"d-play-btn"},fr=["onKeyup","onKeydown"],gr={class:"d-control-progress"},vr={class:"d-tool-bar"},pr={key:0,class:"d-tool-item d-tool-time audioTrack-btn"},mr=V("span",{style:{margin:"0 3px"}},"/",-1),yr={class:"total-time"},Er={class:"d-tool-bar"},Tr={key:0,class:"d-tool-item quality-btn"},Sr={class:"d-tool-item-main"},br={class:"speed-main",style:{"text-align":"center"}},Lr=["onClick"],Ar={key:1,class:"d-tool-item speedRate-btn"},Dr={class:"d-tool-item-main"},kr={class:"speed-main"},Rr=["onClick"],_r={key:2,class:"d-tool-item volume-btn"},Ir={class:"d-tool-item-main volume-box",style:{width:"52px"}},Cr={class:"volume-text-size"},wr={key:3,class:"d-tool-item setting-btn"},Or={class:"d-tool-item-main"},xr={class:"speed-main"},Pr=Tt(" \u955C\u50CF\u753B\u9762 "),Fr=Tt(" \u5FAA\u73AF\u64AD\u653E "),Mr=Tt(" \u5173\u706F\u6A21\u5F0F "),Nr=V("div",{class:"d-tool-item-main"},"\u753B\u4E2D\u753B",-1),Br=V("div",{class:"d-tool-item-main"},"\u7F51\u9875\u5168\u5C4F",-1),Ur=V("div",{class:"d-tool-item-main"},"\u5168\u5C4F",-1);Ft();var $t=jt(re(ee({},{name:"vue3VideoPlay",inheritAttrs:!1}),{props:or,emits:[...le,"mirrorChange","loopChange","lightOffChange"],setup:function(N,{expose:w,emit:f}){const _=N;ie(C=>({"51d4439c":j(E),"77e758a6":C.width,b8a1afc0:C.height}));const T=new Qt({fragLoadingTimeOut:2e3}),A=Dt(null),R=Dt(null),I=Dt(null),k=Dt(null),o=qt(re(ee({dVideo:null},_),{muted:_.muted,playBtnState:_.autoPlay?"pause":"play",loadStateType:"loadstart",fullScreen:!1,handleType:"",currentTime:"00:00:00",preloadBar:0,totalTime:"00:00:00",isVideoHovering:!0,speedActive:"1.0",playProgress:0,isMultiplesPlay:!1,longPressTimeout:null,progressCursorTime:"00:00:00",qualityLevels:[],currentLevel:0})),L=(...C)=>x=>C.reverse().reduce((P,F)=>F(P),x),m=le.reduce((C,x)=>{var P;return C[`on${P=x,P.charAt(0).toUpperCase()+P.slice(1)}`]=F=>{o.loadStateType=x,f(x,F)},C},{});m.onCanplay=L(m.onCanplay,()=>{o.playBtnState!="play"&&o.dVideo.play(),o.autoPlay&&(o.dVideo.play(),o.playBtnState="pause")}),m.onEnded=L(m.onEnded,()=>{o.playBtnState="replay"}),m.onDurationchange=C=>{f("durationchange",C),_.currentTime!=0&&(o.dVideo.currentTime=_.currentTime),m.onTimeupdate(C)},m.onProgress=C=>{console.log("\u7F13\u51B2\u4E2D..."),f("progress",C);let x=C.target.duration,P=C.target.buffered,F=C.target.buffered.length&&C.target.buffered.end(P-1);o.preloadBar=F/x},m.onTimeupdate=C=>{f("timeupdate",C);let x=C.duration||C.target.duration||0,P=C.currentTime||C.target.currentTime;o.playProgress=P/x,o.currentTime=Zt(P),o.totalTime=Zt(x)},m.onError=L(m.onError,()=>{o.playBtnState="replay"});let h=Te();for(let C in h)m[C]=h[C];const E=(y=o.color,`${parseInt("0x"+y.slice(1,3))},${parseInt("0x"+y.slice(3,5))},${parseInt("0x"+y.slice(5,7))}`);var y;const d=oe(500,()=>{o.handleType=""}),t=C=>{C.preventDefault(),C.code=="ArrowUp"?o.volume=o.volume+.1>1?1:o.volume+.1:o.volume=o.volume-.1<0?0:o.volume-.1,o.muted=!1,o.handleType="volume",d()},a=C=>{_.speed&&(o.dVideo.currentTime=o.dVideo.currentTime<10?.1:o.dVideo.currentTime-10,m.onTimeupdate(o.dVideo),u())},e=C=>{C.preventDefault();let x=C.type;if(C.key=="ArrowRight"){if(u(),x=="keyup"){if(clearTimeout(o.longPressTimeout),!_.speed&&!o.longPressTimeout)return;o.isMultiplesPlay?(o.dVideo.playbackRate=o.speedActive,o.isMultiplesPlay=!1):(o.dVideo.currentTime=o.dVideo.currentTime+10,m.onTimeupdate(o.dVideo))}else if(x=="keydown"){if(!_.speed)return;o.isMultiplesPlay&&clearTimeout(o.longPressTimeout),o.longPressTimeout=setTimeout(()=>{o.isMultiplesPlay=!0,o.dVideo.playbackRate=5,o.handleType="playbackRate",d()},500)}}},s=()=>{Wt||k.value.focus()},u=()=>{o.loadStateType="play",o.dVideo.play().catch(()=>{setTimeout(()=>{o.playBtnState="replay",o.loadStateType="error"},500)}),o.playBtnState="pause"},n=()=>{o.dVideo.pause(),o.playBtnState="play"},l=C=>{C&&C.preventDefault(),o.playBtnState=="play"||o.playBtnState=="replay"?u():o.playBtnState=="pause"&&n()},p=()=>{o.muted=!o.muted,o.volume==0&&(o.volume=.05)},g=(C,x)=>{let P=o.dVideo.duration||o.dVideo.target.duration;o.dVideo.currentTime=P*x,o.playBtnState=="play"&&(o.dVideo.play(),o.playBtnState="pause")},v=(C,x)=>{o.progressCursorTime=Zt(o.dVideo.duration*x)},r=oe(2500,()=>{o.isVideoHovering=!1}),i=C=>{o.isVideoHovering=!0,r()},c=C=>{f("mirrorChange",C,o.dVideo)},S=C=>{f("loopChange",C,o.dVideo)},b=C=>{f("lightOffChange",C,o.dVideo)},D=()=>{var C;C=o.dVideo,document.pictureInPictureElement?document.exitPictureInPicture().catch(x=>{console.log(x,"Video failed to leave Picture-in-Picture mode.")}):C.requestPictureInPicture().catch(x=>{console.log(x,"Video failed to enter Picture-in-Picture mode.")})},O=()=>{o.fullScreen=(C=>{let x=document,P=x.webkitIsFullScreen||x.fullscreen;return P?(document.exitFullscreen||x.webkitExitFullScreen).call(x):(C.requestFullscreen||C.webkitRequestFullScreen).call(C),!P})(A.value)};return ue(()=>_.src,()=>{he(()=>{o.dVideo.canPlayType(_.type)||o.dVideo.canPlayType("application/vnd.apple.mpegurl")?o.muted=_.autoPlay:Qt.isSupported()&&(T.detachMedia(),T.attachMedia(o.dVideo),T.on(Qt.Events.MEDIA_ATTACHED,()=>{T.loadSource(_.src),T.on("hlsManifestParsed",(C,x)=>{console.log(x),o.currentLevel=x.level,o.qualityLevels=x.levels||[]})}),T.on("hlsLevelSwitching",(C,x)=>{console.log(x),console.log("LEVEL_SWITCHING")}),T.on("hlsLevelSwitched",(C,x)=>{o.currentLevel=x.level,console.log("LEVEL_SWITCHED")}))})},{immediate:!0}),de(()=>{o.dVideo=R,s()}),w({play:u,pause:n,togglePlay:l}),(C,x)=>($(),Z("div",{ref:A,id:"refPlayerWrap",class:Ct(["d-player-wrap",{"web-full-screen":j(o).webFullScreen,"is-lightoff":j(o).lightOff,"d-player-wrap-hover":j(o).playBtnState=="play"||j(o).isVideoHovering}]),onMousemove:i},[V("div",lr,[V("video",Se({ref:R,class:["d-player-video-main",{"video-mirror":j(o).mirror}],id:"dPlayerVideoMain",controls:!(!j(Wt)||!j(o).speed),"webkit-playsinline":_.playsinline,playsinline:_.playsinline},j(m),{volume:j(o).volume,muted:j(o).muted,loop:j(o).loop,preload:C.preload,width:"100%",height:"100%",src:_.src,poster:_.poster}),"\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Video\u6807\u7B7E\u3002",16,ur)]),et(te,{name:"d-fade-in"},{default:Jt(()=>[ht(V("div",dr,null,512),[[ft,j(o).lightOff]])]),_:1}),j(o).fullScreen?($(),be(Pe,{key:0,title:_.title},null,8,["title"])):ut("",!0),j(Wt)?ut("",!0):($(),Z("div",cr,[et(te,{name:"d-scale-out"},{default:Jt(()=>[ht(V("div",hr,[et(pt,{icon:"icon-play",size:40})],512),[[ft,j(o).playBtnState=="play"]])]),_:1}),et(ge,{state:j(o)},null,8,["state"])])),j(Wt)?ut("",!0):($(),Z("input",{key:2,type:"input",readonly:"readonly",ref:k,onDblclick:O,onKeyup:[Ht(O,["f"]),x[0]||(x[0]=Ht(P=>j(o).webFullScreen=!1,["esc"])),e],onClick:l,onKeydown:[Ht(l,["space"]),Ht(a,["arrow-left"]),Ht(t,["arrow-up","arrow-down"]),e],class:"d-player-input",maxlength:"0"},null,40,fr)),et(ve,{loadType:j(o).loadStateType},null,8,["loadType"]),et(pe),!j(Wt)&&j(o).control?($(),Z("div",{key:3,class:"d-player-control",ref:I},[V("div",gr,[et(Gt,{class:"d-progress-bar",onOnMousemove:v,onChange:g,disabled:!j(o).speed,hoverText:j(o).progressCursorTime,modelValue:j(o).playProgress,"onUpdate:modelValue":x[1]||(x[1]=P=>j(o).playProgress=P),preload:j(o).preloadBar},null,8,["disabled","hoverText","modelValue","preload"])]),V("div",{class:"d-control-tool",onClick:s},[V("div",vr,[V("div",{class:"d-tool-item",onClick:l},[et(pt,{size:"24",icon:`icon-${j(o).playBtnState}`},null,8,["icon"])]),_.controlBtns.includes("audioTrack")?($(),Z("div",pr,[V("span",null,st(j(o).currentTime),1),mr,V("span",yr,st(j(o).totalTime),1)])):ut("",!0)]),V("div",Er,[j(o).qualityLevels.length&&_.controlBtns.includes("quality")?($(),Z("div",Tr,[Tt(st(j(o).qualityLevels.length&&(j(o).qualityLevels[j(o).currentLevel]||{}).height)+"P ",1),V("div",Sr,[V("ul",br,[($(!0),Z(Xt,null,zt(j(o).qualityLevels,(P,F)=>($(),Z("li",{class:Ct({"speed-active":j(o).currentLevel==F}),onClick:M=>((B,U)=>{T.currentLevel=U,o.currentLevel=U})(0,F),key:P},st(P.height)+"P",11,Lr))),128))])])])):ut("",!0),_.controlBtns.includes("speedRate")?($(),Z("div",Ar,[Tt(st(j(o).speedActive=="1.0"?"\u500D\u901F":j(o).speedActive+"x")+" ",1),V("div",Dr,[V("ul",kr,[($(!0),Z(Xt,null,zt(j(o).speedRate,P=>($(),Z("li",{class:Ct({"speed-active":j(o).speedActive==P}),onClick:F=>(M=>{o.speedActive=M,o.dVideo.playbackRate=M})(P),key:P},st(P)+"x",11,Rr))),128))])])])):ut("",!0),_.controlBtns.includes("volume")?($(),Z("div",_r,[V("div",Ir,[V("div",{class:Ct(["volume-main",{"is-muted":j(o).muted}])},[V("span",Cr,st(j(o).muted?0:~~(100*j(o).volume))+"%",1),et(Gt,{onChange:x[2]||(x[2]=P=>j(o).muted=!1),hover:!1,size:"5px",vertical:!0,modelValue:j(o).volume,"onUpdate:modelValue":x[3]||(x[3]=P=>j(o).volume=P)},null,8,["modelValue"])],2)]),V("span",{onClick:p,style:{display:"flex"}},[et(pt,{size:"20",icon:"icon-volume-"+(j(o).volume==0||j(o).muted?"mute":j(o).volume>.5?"up":"down")},null,8,["icon"])])])):ut("",!0),_.controlBtns.includes("setting")?($(),Z("div",wr,[et(pt,{size:"20",class:"rotateHover",icon:"icon-settings"}),V("div",Or,[V("ul",xr,[V("li",null,[Pr,et(Yt,{onChange:c,modelValue:j(o).mirror,"onUpdate:modelValue":x[4]||(x[4]=P=>j(o).mirror=P)},null,8,["modelValue"])]),V("li",null,[Fr,et(Yt,{onChange:S,modelValue:j(o).loop,"onUpdate:modelValue":x[5]||(x[5]=P=>j(o).loop=P)},null,8,["modelValue"])]),V("li",null,[Mr,et(Yt,{onChange:b,modelValue:j(o).lightOff,"onUpdate:modelValue":x[6]||(x[6]=P=>j(o).lightOff=P)},null,8,["modelValue"])])])])])):ut("",!0),_.controlBtns.includes("pip")?($(),Z("div",{key:4,class:"d-tool-item pip-btn",onClick:D},[et(pt,{size:"20",icon:"icon-pip"}),Nr])):ut("",!0),_.controlBtns.includes("pageFullScreen")?($(),Z("div",{key:5,class:"d-tool-item pip-btn",onClick:x[7]||(x[7]=P=>j(o).webFullScreen=!j(o).webFullScreen)},[et(pt,{size:"20",icon:"icon-web-screen"}),Br])):ut("",!0),_.controlBtns.includes("fullScreen")?($(),Z("div",{key:6,class:"d-tool-item fullScreen-btn",onClick:O},[Ur,et(pt,{size:"20",icon:"icon-screen"})])):ut("",!0)])])],512)):ut("",!0)],34))}}));function Gr(N){N.component($t.name,$t)}$t.__scopeId="data-v-01791e9e",$t.install=Gr;export{$t as g};