uxerLog:p})}))}({decryptionWorker:i,segment:g,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,isEndOfTimeline:l,endedTimelineFn:c,dataFn:d,doneFn:h,onTransmuxerLog:p})
xd({segment:g,bytes:g.bytes,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:a,audioSegmentTimingInfoFn:s,id3Fn:o,captionsFn:u,isEndOfTimeline:l,endedTimelineFn:c,dataFn:d,doneFn:h,onTransmuxerLog:p})}
g.endOfAllRequests=Date.now()
if(g.map&&g.map.encryptedBytes&&!g.map.bytes)return Ad({decryptionWorker:i,id:g.requestId+"-init",encryptedBytes:g.map.encryptedBytes,key:g.map.key},(function(e){g.map.bytes=e
wd(g,(function(e){if(e){Sd(t)
return h(e,g)}v()}))}))
v()}}}},Ld=function(e){var t=e.segment,i=e.progressFn
e.trackInfoFn
e.timingInfoFn
e.videoSegmentTimingInfoFn
e.audioSegmentTimingInfoFn
e.id3Fn
e.captionsFn
e.isEndOfTimeline
e.endedTimelineFn
e.dataFn
return function(e){if(!e.target.aborted){t.stats=ql.mergeOptions(t.stats,function(e){var t=e.target,i={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0}
i.bytesReceived=e.loaded
i.bandwidth=Math.floor(i.bytesReceived/i.roundTripTime*8*1e3)
return i}(e))
!t.stats.firstBytesReceivedAt&&t.stats.bytesReceived&&(t.stats.firstBytesReceivedAt=Date.now())
return i(e,t)}}},Dd=function(e){var t=e.xhr,i=e.xhrOptions,n=e.decryptionWorker,r=e.segment,a=e.abortFn,s=e.progressFn,o=e.trackInfoFn,u=e.timingInfoFn,l=e.videoSegmentTimingInfoFn,c=e.audioSegmentTimingInfoFn,d=e.id3Fn,h=e.captionsFn,p=e.isEndOfTimeline,f=e.endedTimelineFn,m=e.dataFn,g=e.doneFn,v=e.onTransmuxerLog,y=[],_=Od({activeXhrs:y,decryptionWorker:n,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:c,id3Fn:d,captionsFn:h,isEndOfTimeline:p,endedTimelineFn:f,dataFn:m,doneFn:g,onTransmuxerLog:v})
if(r.key&&!r.key.bytes){var b=[r.key]
r.map&&!r.map.bytes&&r.map.key&&r.map.key.resolvedUri===r.key.resolvedUri&&b.push(r.map.key)
var T=t(ql.mergeOptions(i,{uri:r.key.resolvedUri,responseType:"arraybuffer"}),Cd(r,b,_))
y.push(T)}if(r.map&&!r.map.bytes){if(r.map.key&&(!r.key||r.key.resolvedUri!==r.map.key.resolvedUri)){var k=t(ql.mergeOptions(i,{uri:r.map.key.resolvedUri,responseType:"arraybuffer"}),Cd(r,[r.map.key],_))
y.push(k)}var S=ql.mergeOptions(i,{uri:r.map.resolvedUri,responseType:"arraybuffer",headers:Vc(r.map)}),E=function(e){var t=e.segment,i=e.finishProcessingFn
return function(e,n){var r=Ed(e,n)
if(r)return i(r,t)
var a=new Uint8Array(n.response)
if(t.map.key){t.map.encryptedBytes=a
return i(null,t)}t.map.bytes=a
wd(t,(function(e){if(e){e.xhr=n
e.status=n.status
return i(e,t)}i(null,t)}))}}({segment:r,finishProcessingFn:_}),C=t(S,E)
y.push(C)}var w=ql.mergeOptions(i,{uri:r.part&&r.part.resolvedUri||r.resolvedUri,responseType:"arraybuffer",headers:Vc(r)}),I=t(w,Id({segment:r,finishProcessingFn:_,responseType:w.responseType}))
I.addEventListener("progress",Ld({segment:r,progressFn:s,trackInfoFn:o,timingInfoFn:u,videoSegmentTimingInfoFn:l,audioSegmentTimingInfoFn:c,id3Fn:d,captionsFn:h,isEndOfTimeline:p,endedTimelineFn:f,dataFn:m}))
y.push(I)
var P={}
y.forEach((function(e){e.addEventListener("loadend",function(e){var t=e.loadendState,i=e.abortFn
return function(e){if(e.target.aborted&&i&&!t.calledAbortFn){i()
t.calledAbortFn=!0}}}({loadendState:P,abortFn:a}))}))
return function(){return Sd(y)}},Rd=Xl("CodecUtils"),Md=function(e,t){var i=t.attributes||{}
return e&&e.mediaGroups&&e.mediaGroups.AUDIO&&i.AUDIO&&e.mediaGroups.AUDIO[i.AUDIO]},Nd=function(e){var t={}
e.forEach((function(e){var i=e.mediaType,n=e.type,r=e.details
t[i]=t[i]||[]
t[i].push(We(""+n+r))}))
Object.keys(t).forEach((function(e){if(t[e].length>1){Rd("multiple "+e+" codecs found as attributes: "+t[e].join(", ")+". Setting playlist codecs to null so that we wait for mux.js to probe segments for real codecs.")
t[e]=null}else t[e]=t[e][0]}))
return t},Ud=function(e){var t=0
e.audio&&t++
e.video&&t++
return t},Bd=function(e,t){var i=t.attributes||{},n=Nd(function(e){var t=e.attributes||{}
if(t.CODECS)return Ge(t.CODECS)}(t)||[])
if(Md(e,t)&&!n.audio&&!function(e,t){if(!Md(e,t))return!0
var i=t.attributes||{},n=e.mediaGroups.AUDIO[i.AUDIO]
for(var r in n)if(!n[r].uri&&!n[r].playlists)return!0
return!1}(e,t)){var r=Nd(function(e,t){if(!e.mediaGroups.AUDIO||!t)return null
var i=e.mediaGroups.AUDIO[t]
if(!i)return null
for(var n in i){var r=i[n]
if(r.default&&r.playlists)return Ge(r.playlists[0].attributes.CODECS)}return null}(e,i.AUDIO)||[])
r.audio&&(n.audio=r.audio)}return n},Fd=Xl("PlaylistSelector"),jd=function(e){if(e&&e.playlist){var t=e.playlist
return JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||""})}},Vd=function(e,t){if(!e)return""
var i=x.getComputedStyle(e)
return i?i[t]:""},Hd=function(e,t){var i=e.slice()
e.sort((function(e,n){var r=t(e,n)
return 0===r?i.indexOf(e)-i.indexOf(n):r}))},qd=function(e,t){var i,n
e.attributes.BANDWIDTH&&(i=e.attributes.BANDWIDTH)
i=i||x.Number.MAX_VALUE
t.attributes.BANDWIDTH&&(n=t.attributes.BANDWIDTH)
return i-(n=n||x.Number.MAX_VALUE)},Wd=function(e,t,i,n,r,a){if(e){var s={bandwidth:t,width:i,height:n,limitRenditionByPlayerDimensions:r},o=e.playlists
if(kc.isAudioOnly(e)){o=a.getAudioTrackPlaylists_()
s.audioOnly=!0}var u=o.map((function(e){var t=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,i=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height
return{bandwidth:e.attributes&&e.attributes.BANDWIDTH||x.Number.MAX_VALUE,width:t,height:i,playlist:e}}))
Hd(u,(function(e,t){return e.bandwidth-t.bandwidth}))
var l=(u=u.filter((function(e){return!kc.isIncompatible(e.playlist)}))).filter((function(e){return kc.isEnabled(e.playlist)}))
l.length||(l=u.filter((function(e){return!kc.isDisabled(e.playlist)})))
var c=l.filter((function(e){return e.bandwidth*ad.BANDWIDTH_VARIANCE<t})),d=c[c.length-1],h=c.filter((function(e){return e.bandwidth===d.bandwidth}))[0]
if(!1===r){var p=h||l[0]||u[0]
if(p&&p.playlist){var f="sortedPlaylistReps"
h&&(f="bandwidthBestRep")
l[0]&&(f="enabledPlaylistReps")
Fd("choosing "+jd(p)+" using "+f+" with options",s)
return p.playlist}Fd("could not choose a playlist with options",s)
return null}var m=c.filter((function(e){return e.width&&e.height}))
Hd(m,(function(e,t){return e.width-t.width}))
var g=m.filter((function(e){return e.width===i&&e.height===n}))
d=g[g.length-1]
var v,y,_,b,T=g.filter((function(e){return e.bandwidth===d.bandwidth}))[0]
if(!T){y=(v=m.filter((function(e){return e.width>i||e.height>n}))).filter((function(e){return e.width===v[0].width&&e.height===v[0].height}))
d=y[y.length-1]
_=y.filter((function(e){return e.bandwidth===d.bandwidth}))[0]}if(a.experimentalLeastPixelDiffSelector){var k=m.map((function(e){e.pixelDiff=Math.abs(e.width-i)+Math.abs(e.height-n)
return e}))
Hd(k,(function(e,t){return e.pixelDiff===t.pixelDiff?t.bandwidth-e.bandwidth:e.pixelDiff-t.pixelDiff}))
b=k[0]}var S=b||_||T||h||l[0]||u[0]
if(S&&S.playlist){var E="sortedPlaylistReps"
b?E="leastPixelDiffRep":_?E="resolutionPlusOneRep":T?E="resolutionBestRep":h?E="bandwidthBestRep":l[0]&&(E="enabledPlaylistReps")
Fd("choosing "+jd(S)+" using "+E+" with options",s)
return S.playlist}Fd("could not choose a playlist with options",s)
return null}},Gd=function(){var e=this.useDevicePixelRatio&&x.devicePixelRatio||1
return Wd(this.playlists.master,this.systemBandwidth,parseInt(Vd(this.tech_.el(),"width"),10)*e,parseInt(Vd(this.tech_.el(),"height"),10)*e,this.limitRenditionByPlayerDimensions,this.masterPlaylistController_)},zd=function(e){var t=e.inbandTextTracks,i=e.metadataArray,n=e.timestampOffset,r=e.videoDuration
if(i){var a=x.WebKitDataCue||x.VTTCue,s=t.metadataTrack_
if(s){i.forEach((function(e){var t=e.cueTime+n
!("number"!=typeof t||x.isNaN(t)||t<0)&&t<1/0&&e.frames.forEach((function(e){var i=new a(t,t,e.value||e.url||e.data||"")
i.frame=e
i.value=e
!function(e){Object.defineProperties(e.frame,{id:{get:function(){ql.log.warn("cue.frame.id is deprecated. Use cue.value.key instead.")
return e.value.key}},value:{get:function(){ql.log.warn("cue.frame.value is deprecated. Use cue.value.data instead.")
return e.value.data}},privateData:{get:function(){ql.log.warn("cue.frame.privateData is deprecated. Use cue.value.data instead.")
return e.value.data}}})}(i)
s.addCue(i)}))}))
if(s.cues&&s.cues.length){for(var o=s.cues,u=[],l=0;l<o.length;l++)o[l]&&u.push(o[l])
var c=u.reduce((function(e,t){var i=e[t.startTime]||[]
i.push(t)
e[t.startTime]=i
return e}),{}),d=Object.keys(c).sort((function(e,t){return Number(e)-Number(t)}))
d.forEach((function(e,t){var i=c[e],n=Number(d[t+1])||r
i.forEach((function(e){e.endTime=n}))}))}}}},Kd=function(e,t,i){var n,r
if(i&&i.cues){n=i.cues.length
for(;n--;)(r=i.cues[n]).startTime>=e&&r.endTime<=t&&i.removeCue(r)}},Xd=function(e){return"number"==typeof e&&isFinite(e)},Yd=1/60,Qd=function(e){var t=e.startOfSegment,i=e.duration,n=e.segment,r=e.part,a=e.playlist,s=a.mediaSequence,o=a.id,u=a.segments,l=void 0===u?[]:u,c=e.mediaIndex,d=e.partIndex,h=e.timeline,p=l.length-1,f="mediaIndex/partIndex increment"
e.getMediaInfoForTime?f="getMediaInfoForTime ("+e.getMediaInfoForTime+")":e.isSyncRequest&&(f="getSyncSegmentCandidate (isSyncRequest)")
e.independent&&(f+=" with independent "+e.independent)
var m="number"==typeof d,g=e.segment.uri?"segment":"pre-segment",v=m?uc({preloadSegment:n})-1:0
return g+" ["+(s+c)+"/"+(s+p)+"]"+(m?" part ["+d+"/"+v+"]":"")+" segment start/end ["+n.start+" => "+n.end+"]"+(m?" part start/end ["+r.start+" => "+r.end+"]":"")+" startOfSegment ["+t+"] duration ["+i+"] timeline ["+h+"] selected by ["+f+"] playlist ["+o+"]"},$d=function(e){return e+"TimingInfo"},Jd=function(e){var t=e.timelineChangeController,i=e.currentTimeline,n=e.segmentTimeline,r=e.loaderType,a=e.audioDisabled
if(i===n)return!1
if("audio"===r){var s=t.lastTimelineChange({type:"main"})
return!s||s.to!==n}if("main"===r&&a){var o=t.pendingTimelineChange({type:"audio"})
return!o||o.to!==n}return!1},Zd=function(e){var t=e.segmentDuration,i=e.maxDuration
return!!t&&Math.round(t)>i+Yl},eh=function(e,t){if("hls"!==t)return null
var i=function(e){var t=0;["video","audio"].forEach((function(i){var n=e[i+"TimingInfo"]
if(n){var r,a=n.start,s=n.end
"bigint"==typeof a||"bigint"==typeof s?r=x.BigInt(s)-x.BigInt(a):"number"==typeof a&&"number"==typeof s&&(r=s-a)
void 0!==r&&r>t&&(t=r)}}))
"bigint"==typeof t&&t<Number.MAX_SAFE_INTEGER&&(t=Number(t))
return t}({audioTimingInfo:e.audioTimingInfo,videoTimingInfo:e.videoTimingInfo})
if(!i)return null
var n=e.playlist.targetDuration,r=Zd({segmentDuration:i,maxDuration:2*n}),a=Zd({segmentDuration:i,maxDuration:n}),s="Segment with index "+e.mediaIndex+" from playlist "+e.playlist.id+" has a duration of "+i+" when the reported duration is "+e.duration+" and the target duration is "+n+". For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1"
return r||a?{severity:r?"warn":"info",message:s}:null},th=function(e){B(t,e)
function t(t,i){var n
n=e.call(this)||this
if(!t)throw new TypeError("Initialization settings are required")
if("function"!=typeof t.currentTime)throw new TypeError("No currentTime getter specified")
if(!t.mediaSource)throw new TypeError("No MediaSource specified")
n.bandwidth=t.bandwidth
n.throughput={rate:0,count:0}
n.roundTrip=NaN
n.resetStats_()
n.mediaIndex=null
n.partIndex=null
n.hasPlayed_=t.hasPlayed
n.currentTime_=t.currentTime
n.seekable_=t.seekable
n.seeking_=t.seeking
n.duration_=t.duration
n.mediaSource_=t.mediaSource
n.vhs_=t.vhs
n.loaderType_=t.loaderType
n.currentMediaInfo_=void 0
n.startingMediaInfo_=void 0
n.segmentMetadataTrack_=t.segmentMetadataTrack
n.goalBufferLength_=t.goalBufferLength
n.sourceType_=t.sourceType
n.sourceUpdater_=t.sourceUpdater
n.inbandTextTracks_=t.inbandTextTracks
n.state_="INIT"
n.timelineChangeController_=t.timelineChangeController
n.shouldSaveSegmentTimingInfo_=!0
n.parse708captions_=t.parse708captions
n.useDtsForTimestampOffset_=t.useDtsForTimestampOffset
n.captionServices_=t.captionServices
n.experimentalExactManifestTimings=t.experimentalExactManifestTimings
n.checkBufferTimeout_=null
n.error_=void 0
n.currentTimeline_=-1
n.pendingSegment_=null
n.xhrOptions_=null
n.pendingSegments_=[]
n.audioDisabled_=!1
n.isPendingTimestampOffset_=!1
n.gopBuffer_=[]
n.timeMapping_=0
n.safeAppend_=ql.browser.IE_VERSION>=11
n.appendInitSegment_={audio:!0,video:!0}
n.playlistOfLastInitSegment_={audio:null,video:null}
n.callQueue_=[]
n.loadQueue_=[]
n.metadataQueue_={id3:[],caption:[]}
n.waitingOnRemove_=!1
n.quotaExceededErrorRetryTimeout_=null
n.activeInitSegmentId_=null
n.initSegments_={}
n.cacheEncryptionKeys_=t.cacheEncryptionKeys
n.keyCache_={}
n.decrypter_=t.decrypter
n.syncController_=t.syncController
n.syncPoint_={segmentIndex:0,time:0}
n.transmuxer_=n.createTransmuxer_()
n.triggerSyncInfoUpdate_=function(){return n.trigger("syncinfoupdate")}
n.syncController_.on("syncinfoupdate",n.triggerSyncInfoUpdate_)
n.mediaSource_.addEventListener("sourceopen",(function(){n.isEndOfStream_()||(n.ended_=!1)}))
n.fetchAtBuffer_=!1
n.logger_=Xl("SegmentLoader["+n.loaderType_+"]")
Object.defineProperty(N(n),"state",{get:function(){return this.state_},set:function(e){if(e!==this.state_){this.logger_(this.state_+" -> "+e)
this.state_=e
this.trigger("statechange")}}})
n.sourceUpdater_.on("ready",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_()}))
"main"===n.loaderType_&&n.timelineChangeController_.on("pendingtimelinechange",(function(){n.hasEnoughInfoToAppend_()&&n.processCallQueue_()}))
"audio"===n.loaderType_&&n.timelineChangeController_.on("timelinechange",(function(){n.hasEnoughInfoToLoad_()&&n.processLoadQueue_()
n.hasEnoughInfoToAppend_()&&n.processCallQueue_()}))
return n}var i=t.prototype
i.createTransmuxer_=function(){return yd({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}
i.resetStats_=function(){this.mediaBytesTransferred=0
this.mediaRequests=0
this.mediaRequestsAborted=0
this.mediaRequestsTimedout=0
this.mediaRequestsErrored=0
this.mediaTransferDuration=0
this.mediaSecondsLoaded=0
this.mediaAppends=0}
i.dispose=function(){this.trigger("dispose")
this.state="DISPOSED"
this.pause()
this.abort_()
this.transmuxer_&&this.transmuxer_.terminate()
this.resetStats_()
this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_)
this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off("syncinfoupdate",this.triggerSyncInfoUpdate_)
this.off()}
i.setAudio=function(e){this.audioDisabled_=!e
e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}
i.abort=function(){if("WAITING"===this.state){this.abort_()
this.state="READY"
this.paused()||this.monitorBuffer_()}else this.pendingSegment_&&(this.pendingSegment_=null)}
i.abort_=function(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests()
this.pendingSegment_=null
this.callQueue_=[]
this.loadQueue_=[]
this.metadataQueue_.id3=[]
this.metadataQueue_.caption=[]
this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_)
this.waitingOnRemove_=!1
x.clearTimeout(this.quotaExceededErrorRetryTimeout_)
this.quotaExceededErrorRetryTimeout_=null}
i.checkForAbort_=function(e){if("APPENDING"===this.state&&!this.pendingSegment_){this.state="READY"
return!0}return!this.pendingSegment_||this.pendingSegment_.requestId!==e}
i.error=function(e){if(void 0!==e){this.logger_("error occurred:",e)
this.error_=e}this.pendingSegment_=null
return this.error_}
i.endOfStream=function(){this.ended_=!0
this.transmuxer_&&vd(this.transmuxer_)
this.gopBuffer_.length=0
this.pause()
this.trigger("ended")}
i.buffered_=function(){var e=this.getMediaInfo_()
if(!this.sourceUpdater_||!e)return ql.createTimeRanges()
if("main"===this.loaderType_){var t=e.hasAudio,i=e.hasVideo,n=e.isMuxed
if(i&&t&&!this.audioDisabled_&&!n)return this.sourceUpdater_.buffered()
if(i)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}
i.initSegmentForMap=function(e,t){void 0===t&&(t=!1)
if(!e)return null
var i=zc(e),n=this.initSegments_[i]
t&&!n&&e.bytes&&(this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales})
return n||e}
i.segmentKey=function(e,t){void 0===t&&(t=!1)
if(!e)return null
var i=Kc(e),n=this.keyCache_[i]
this.cacheEncryptionKeys_&&t&&!n&&e.bytes&&(this.keyCache_[i]=n={resolvedUri:e.resolvedUri,bytes:e.bytes})
var r={resolvedUri:(n||e).resolvedUri}
n&&(r.bytes=n.bytes)
return r}
i.couldBeginLoading_=function(){return this.playlist_&&!this.paused()}
i.load=function(){this.monitorBuffer_()
if(this.playlist_){if("INIT"===this.state&&this.couldBeginLoading_())return this.init_()
!this.couldBeginLoading_()||"READY"!==this.state&&"INIT"!==this.state||(this.state="READY")}}
i.init_=function(){this.state="READY"
this.resetEverything()
return this.monitorBuffer_()}
i.playlist=function(e,t){void 0===t&&(t={})
if(e){var i=this.playlist_,n=this.pendingSegment_
this.playlist_=e
this.xhrOptions_=t
if("INIT"===this.state){e.syncInfo={mediaSequence:e.mediaSequence,time:0}
"main"===this.loaderType_&&this.syncController_.setDateTimeMappingForStart(e)}var r=null
i&&(i.id?r=i.id:i.uri&&(r=i.uri))
this.logger_("playlist update ["+r+" => "+(e.id||e.uri)+"]")
this.trigger("syncinfoupdate")
if("INIT"===this.state&&this.couldBeginLoading_())return this.init_()
if(i&&i.uri===e.uri){var a=e.mediaSequence-i.mediaSequence
this.logger_("live window shift ["+a+"]")
if(null!==this.mediaIndex){this.mediaIndex-=a
if(this.mediaIndex<0){this.mediaIndex=null
this.partIndex=null}else{var s=this.playlist_.segments[this.mediaIndex]
if(this.partIndex&&(!s.parts||!s.parts.length||!s.parts[this.partIndex])){var o=this.mediaIndex
this.logger_("currently processing part (index "+this.partIndex+") no longer exists.")
this.resetLoader()
this.mediaIndex=o}}}if(n){n.mediaIndex-=a
if(n.mediaIndex<0){n.mediaIndex=null
n.partIndex=null}else{n.mediaIndex>=0&&(n.segment=e.segments[n.mediaIndex])
n.partIndex>=0&&n.segment.parts&&(n.part=n.segment.parts[n.partIndex])}}this.syncController_.saveExpiredSegmentInfo(i,e)}else{null!==this.mediaIndex&&(e.endList?this.resyncLoader():this.resetLoader())
this.currentMediaInfo_=void 0
this.trigger("playlistupdate")}}}
i.pause=function(){if(this.checkBufferTimeout_){x.clearTimeout(this.checkBufferTimeout_)
this.checkBufferTimeout_=null}}
i.paused=function(){return null===this.checkBufferTimeout_}
i.resetEverything=function(e){this.ended_=!1
this.appendInitSegment_={audio:!0,video:!0}
this.resetLoader()
this.remove(0,1/0,e)
if(this.transmuxer_){this.transmuxer_.postMessage({action:"clearAllMp4Captions"})
this.transmuxer_.postMessage({action:"reset"})}}
i.resetLoader=function(){this.fetchAtBuffer_=!1
this.resyncLoader()}
i.resyncLoader=function(){this.transmuxer_&&vd(this.transmuxer_)
this.mediaIndex=null
this.partIndex=null
this.syncPoint_=null
this.isPendingTimestampOffset_=!1
this.callQueue_=[]
this.loadQueue_=[]
this.metadataQueue_.id3=[]
this.metadataQueue_.caption=[]
this.abort()
this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}
i.remove=function(e,t,i,n){void 0===i&&(i=function(){})
void 0===n&&(n=!1)
t===1/0&&(t=this.duration_())
if(t<=e)this.logger_("skipping remove because end ${end} is <= start ${start}")
else if(this.sourceUpdater_&&this.getMediaInfo_()){var r=1,a=function(){0===--r&&i()}
if(n||!this.audioDisabled_){r++
this.sourceUpdater_.removeAudio(e,t,a)}if(n||"main"===this.loaderType_){this.gopBuffer_=function(e,t,i,n){for(var r=Math.ceil((t-n)*wr),a=Math.ceil((i-n)*wr),s=e.slice(),o=e.length;o--&&!(e[o].pts<=a););if(-1===o)return s
for(var u=o+1;u--&&!(e[u].pts<=r););u=Math.max(u,0)
s.splice(u,o-u+1)
return s}(this.gopBuffer_,e,t,this.timeMapping_)
r++
this.sourceUpdater_.removeVideo(e,t,a)}for(var s in this.inbandTextTracks_)Kd(e,t,this.inbandTextTracks_[s])
Kd(e,t,this.segmentMetadataTrack_)
a()}else this.logger_("skipping remove because no source updater or starting media info")}
i.monitorBuffer_=function(){this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_)
this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),1)}
i.monitorBufferTick_=function(){"READY"===this.state&&this.fillBuffer_()
this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_)
this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),500)}
i.fillBuffer_=function(){if(!this.sourceUpdater_.updating()){var e=this.chooseNextRequest_()
if(e){if("number"==typeof e.timestampOffset){this.isPendingTimestampOffset_=!1
this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})}this.loadSegment_(e)}}}
i.isEndOfStream_=function(e,t,i){void 0===e&&(e=this.mediaIndex)
void 0===t&&(t=this.playlist_)
void 0===i&&(i=this.partIndex)
if(!t||!this.mediaSource_)return!1
var n="number"==typeof e&&t.segments[e],r=e+1===t.segments.length,a=!n||!n.parts||i+1===n.parts.length
return t.endList&&"open"===this.mediaSource_.readyState&&r&&a}
i.chooseNextRequest_=function(){var e=this.buffered_(),t=ic(e)||0,i=nc(e,this.currentTime_()),n=!this.hasPlayed_()&&i>=1,r=i>=this.goalBufferLength_(),a=this.playlist_.segments
if(!a.length||n||r)return null
this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_())
var s={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:Boolean(!this.syncPoint_)}
if(s.isSyncRequest)s.mediaIndex=function(e,t,i){t=t||[]
for(var n=[],r=0,a=0;a<t.length;a++){var s=t[a]
if(e===s.timeline){n.push(a)
if((r+=s.duration)>i)return a}}return 0===n.length?0:n[n.length-1]}(this.currentTimeline_,a,t)
else if(null!==this.mediaIndex){var o=a[this.mediaIndex],u="number"==typeof this.partIndex?this.partIndex:-1
s.startOfSegment=o.end?o.end:t
if(o.parts&&o.parts[u+1]){s.mediaIndex=this.mediaIndex
s.partIndex=u+1}else s.mediaIndex=this.mediaIndex+1}else{var l=kc.getMediaInfoForTime({experimentalExactManifestTimings:this.experimentalExactManifestTimings,playlist:this.playlist_,currentTime:this.fetchAtBuffer_?t:this.currentTime_(),startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time}),c=l.segmentIndex,d=l.startTime,h=l.partIndex
s.getMediaInfoForTime=this.fetchAtBuffer_?"bufferedEnd "+t:"currentTime "+this.currentTime_()
s.mediaIndex=c
s.startOfSegment=d
s.partIndex=h}var p=a[s.mediaIndex],f=p&&"number"==typeof s.partIndex&&p.parts&&p.parts[s.partIndex]
if(!p||"number"==typeof s.partIndex&&!f)return null
if("number"!=typeof s.partIndex&&p.parts){s.partIndex=0
f=p.parts[0]}if(!i&&f&&!f.independent)if(0===s.partIndex){var m=a[s.mediaIndex-1],g=m.parts&&m.parts.length&&m.parts[m.parts.length-1]
if(g&&g.independent){s.mediaIndex-=1
s.partIndex=m.parts.length-1
s.independent="previous segment"}}else if(p.parts[s.partIndex-1].independent){s.partIndex-=1
s.independent="previous part"}var v=this.mediaSource_&&"ended"===this.mediaSource_.readyState
return s.mediaIndex>=a.length-1&&v&&!this.seeking_()?null:this.generateSegmentInfo_(s)}
i.generateSegmentInfo_=function(e){var t=e.independent,i=e.playlist,n=e.mediaIndex,r=e.startOfSegment,a=e.isSyncRequest,s=e.partIndex,o=e.forceTimestampOffset,u=e.getMediaInfoForTime,l=i.segments[n],c="number"==typeof s&&l.parts[s],d={requestId:"segment-loader-"+Math.random(),uri:c&&c.resolvedUri||l.resolvedUri,mediaIndex:n,partIndex:c?s:null,isSyncRequest:a,startOfSegment:r,playlist:i,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:l.timeline,duration:c&&c.duration||l.duration,segment:l,part:c,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:u,independent:t},h=void 0!==o?o:this.isPendingTimestampOffset_
d.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:l.timeline,currentTimeline:this.currentTimeline_,startOfSegment:r,buffered:this.buffered_(),overrideCheck:h})
var p=ic(this.sourceUpdater_.audioBuffered())
"number"==typeof p&&(d.audioAppendStart=p-this.sourceUpdater_.audioTimestampOffset())
this.sourceUpdater_.videoBuffered().length&&(d.gopsToAlignWith=function(e,t,i){if(null==t||!e.length)return[]
var n,r=Math.ceil((t-i+3)*wr)
for(n=0;n<e.length&&!(e[n].pts>r);n++);return e.slice(n)}(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_))
return d}
i.timestampOffsetForSegment_=function(e){return i=(t=e).segmentTimeline,n=t.currentTimeline,r=t.startOfSegment,a=t.buffered,t.overrideCheck||i!==n?i<n?r:a.length?a.end(a.length-1):r:null
var t,i,n,r,a}
i.earlyAbortWhenNeeded_=function(e){if(!this.vhs_.tech_.paused()&&this.xhrOptions_.timeout&&this.playlist_.attributes.BANDWIDTH&&!(Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)){var t=this.currentTime_(),i=e.bandwidth,n=this.pendingSegment_.duration,r=kc.estimateSegmentRequestTime(n,i,this.playlist_,e.bytesReceived),a=function(e,t,i){void 0===i&&(i=1)
return((e.length?e.end(e.length-1):0)-t)/i}(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1
if(!(r<=a)){var s=function(e){var t=e.master,i=e.currentTime,n=e.bandwidth,r=e.duration,a=e.segmentDuration,s=e.timeUntilRebuffer,o=e.currentTimeline,u=e.syncController,l=t.playlists.filter((function(e){return!kc.isIncompatible(e)})),c=l.filter(kc.isEnabled)
c.length||(c=l.filter((function(e){return!kc.isDisabled(e)})))
var d=c.filter(kc.hasAttribute.bind(null,"BANDWIDTH")).map((function(e){var t=u.getSyncPoint(e,r,o,i)?1:2
return{playlist:e,rebufferingImpact:kc.estimateSegmentRequestTime(a,n,e)*t-s}})),h=d.filter((function(e){return e.rebufferingImpact<=0}))
Hd(h,(function(e,t){return qd(t.playlist,e.playlist)}))
if(h.length)return h[0]
Hd(d,(function(e,t){return e.rebufferingImpact-t.rebufferingImpact}))
return d[0]||null}({master:this.vhs_.playlists.master,currentTime:t,bandwidth:i,duration:this.duration_(),segmentDuration:n,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_})
if(s){var o=r-a-s.rebufferingImpact,u=.5
a<=Yl&&(u=1)
if(s.playlist&&s.playlist.uri!==this.playlist_.uri&&!(o<u)){this.bandwidth=s.playlist.attributes.BANDWIDTH*ad.BANDWIDTH_VARIANCE+1
this.trigger("earlyabort")}}}}}
i.handleAbort_=function(e){this.logger_("Aborting "+Qd(e))
this.mediaRequestsAborted+=1}
i.handleProgress_=function(e,t){this.earlyAbortWhenNeeded_(t.stats)
this.checkForAbort_(t.requestId)||this.trigger("progress")}
i.handleTrackInfo_=function(e,t){this.earlyAbortWhenNeeded_(e.stats)
if(!this.checkForAbort_(e.requestId)&&!this.checkForIllegalMediaSwitch(t)){t=t||{}
if(!function(e,t){if(!e&&!t||!e&&t||e&&!t)return!1
if(e===t)return!0
var i=Object.keys(e).sort(),n=Object.keys(t).sort()
if(i.length!==n.length)return!1
for(var r=0;r<i.length;r++){var a=i[r]
if(a!==n[r])return!1
if(e[a]!==t[a])return!1}return!0}(this.currentMediaInfo_,t)){this.appendInitSegment_={audio:!0,video:!0}
this.startingMediaInfo_=t
this.currentMediaInfo_=t
this.logger_("trackinfo update",t)
this.trigger("trackinfo")}if(!this.checkForAbort_(e.requestId)){this.pendingSegment_.trackInfo=t
this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}}}
i.handleTimingInfo_=function(e,t,i,n){this.earlyAbortWhenNeeded_(e.stats)
if(!this.checkForAbort_(e.requestId)){var r=this.pendingSegment_,a=$d(t)
r[a]=r[a]||{}
r[a][i]=n
this.logger_("timinginfo: "+t+" - "+i+" - "+n)
this.hasEnoughInfoToAppend_()&&this.processCallQueue_()}}
i.handleCaptions_=function(e,t){var i=this
this.earlyAbortWhenNeeded_(e.stats)
if(!this.checkForAbort_(e.requestId))if(0!==t.length){if(this.pendingSegment_.hasAppendedData_){var n=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),r={}
t.forEach((function(e){r[e.stream]=r[e.stream]||{startTime:1/0,captions:[],endTime:0}
var t=r[e.stream]
t.startTime=Math.min(t.startTime,e.startTime+n)
t.endTime=Math.max(t.endTime,e.endTime+n)
t.captions.push(e)}))
Object.keys(r).forEach((function(e){var t=r[e],a=t.startTime,s=t.endTime,o=t.captions,u=i.inbandTextTracks_
i.logger_("adding cues from "+a+" -> "+s+" for "+e)
!function(e,t,i){if(!e[i]){t.trigger({type:"usage",name:"vhs-608"})
t.trigger({type:"usage",name:"hls-608"})
var n=i;/^cc708_/.test(i)&&(n="SERVICE"+i.split("_")[1])
var r=t.textTracks().getTrackById(n)
if(r)e[i]=r
else{var a=i,s=i,o=!1,u=(t.options_.vhs&&t.options_.vhs.captionServices||{})[n]
if(u){a=u.label
s=u.language
o=u.default}e[i]=t.addRemoteTextTrack({kind:"captions",id:n,default:o,label:a,language:s},!1).track}}}(u,i.vhs_.tech_,e)
Kd(a,s,u[e])
!function(e){var t=e.inbandTextTracks,i=e.captionArray,n=e.timestampOffset
if(i){var r=x.WebKitDataCue||x.VTTCue
i.forEach((function(e){var i=e.stream
t[i].addCue(new r(e.startTime+n,e.endTime+n,e.text))}))}}({captionArray:o,inbandTextTracks:u,timestampOffset:n})}))
this.transmuxer_&&this.transmuxer_.postMessage({action:"clearParsedMp4Captions"})}else this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t))}else this.logger_("SegmentLoader received no captions from a caption event")}
i.handleId3_=function(e,t,i){this.earlyAbortWhenNeeded_(e.stats)
if(!this.checkForAbort_(e.requestId)){if(this.pendingSegment_.hasAppendedData_){var n=null===this.sourceUpdater_.videoTimestampOffset()?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset()
!function(e,t,i){if(!e.metadataTrack_){e.metadataTrack_=i.addRemoteTextTrack({kind:"metadata",label:"Timed Metadata"},!1).track
e.metadataTrack_.inBandMetadataTrackDispatchType=t}}(this.inbandTextTracks_,i,this.vhs_.tech_)
zd({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:n,videoDuration:this.duration_()})}else this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,i))}}
i.processMetadataQueue_=function(){this.metadataQueue_.id3.forEach((function(e){return e()}))
this.metadataQueue_.caption.forEach((function(e){return e()}))
this.metadataQueue_.id3=[]
this.metadataQueue_.caption=[]}
i.processCallQueue_=function(){var e=this.callQueue_
this.callQueue_=[]
e.forEach((function(e){return e()}))}
i.processLoadQueue_=function(){var e=this.loadQueue_
this.loadQueue_=[]
e.forEach((function(e){return e()}))}
i.hasEnoughInfoToLoad_=function(){if("audio"!==this.loaderType_)return!0
var e=this.pendingSegment_
return!!e&&(!this.getCurrentMediaInfo_()||!Jd({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}
i.getCurrentMediaInfo_=function(e){void 0===e&&(e=this.pendingSegment_)
return e&&e.trackInfo||this.currentMediaInfo_}
i.getMediaInfo_=function(e){void 0===e&&(e=this.pendingSegment_)
return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}
i.hasEnoughInfoToAppend_=function(){if(!this.sourceUpdater_.ready())return!1
if(this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1
var e=this.pendingSegment_,t=this.getCurrentMediaInfo_()
if(!e||!t)return!1
var i=t.hasAudio,n=t.hasVideo,r=t.isMuxed
return!(n&&!e.videoTimingInfo)&&(!(i&&!this.audioDisabled_&&!r&&!e.audioTimingInfo)&&!Jd({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}
i.handleData_=function(e,t){this.earlyAbortWhenNeeded_(e.stats)
if(!this.checkForAbort_(e.requestId))if(!this.callQueue_.length&&this.hasEnoughInfoToAppend_()){var i=this.pendingSegment_
this.setTimeMapping_(i.timeline)
this.updateMediaSecondsLoaded_(i.part||i.segment)
if("closed"!==this.mediaSource_.readyState){if(e.map){e.map=this.initSegmentForMap(e.map,!0)
i.segment.map=e.map}e.key&&this.segmentKey(e.key,!0)
i.isFmp4=e.isFmp4
i.timingInfo=i.timingInfo||{}
if(i.isFmp4){this.trigger("fmp4")
i.timingInfo.start=i[$d(t.type)].start}else{var n,r=this.getCurrentMediaInfo_(),a="main"===this.loaderType_&&r&&r.hasVideo
a&&(n=i.videoTimingInfo.start)
i.timingInfo.start=this.trueSegmentStart_({currentStart:i.timingInfo.start,playlist:i.playlist,mediaIndex:i.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:a,firstVideoFrameTimeForData:n,videoTimingInfo:i.videoTimingInfo,audioTimingInfo:i.audioTimingInfo})}this.updateAppendInitSegmentStatus(i,t.type)
this.updateSourceBufferTimestampOffset_(i)
if(i.isSyncRequest){this.updateTimingInfoEnd_(i)
this.syncController_.saveSegmentTimingInfo({segmentInfo:i,shouldSaveTimelineMapping:"main"===this.loaderType_})
var s=this.chooseNextRequest_()
if(s.mediaIndex!==i.mediaIndex||s.partIndex!==i.partIndex){this.logger_("sync segment was incorrect, not appending")
return}this.logger_("sync segment was correct, appending")}i.hasAppendedData_=!0
this.processMetadataQueue_()
this.appendData_(i,t)}}else this.callQueue_.push(this.handleData_.bind(this,e,t))}
i.updateAppendInitSegmentStatus=function(e,t){"main"!==this.loaderType_||"number"!=typeof e.timestampOffset||e.changedTimestampOffset||(this.appendInitSegment_={audio:!0,video:!0})
this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}
i.getInitSegmentAndUpdateState_=function(e){var t=e.type,i=e.initSegment,n=e.map,r=e.playlist
if(n){var a=zc(n)
if(this.activeInitSegmentId_===a)return null
i=this.initSegmentForMap(n,!0).bytes
this.activeInitSegmentId_=a}if(i&&this.appendInitSegment_[t]){this.playlistOfLastInitSegment_[t]=r
this.appendInitSegment_[t]=!1
this.activeInitSegmentId_=null
return i}return null}
i.handleQuotaExceededError_=function(e,t){var i=this,n=e.segmentInfo,r=e.type,a=e.bytes,s=this.sourceUpdater_.audioBuffered(),o=this.sourceUpdater_.videoBuffered()
s.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: "+tc(s).join(", "))
o.length>1&&this.logger_("On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: "+tc(o).join(", "))
var u=s.length?s.start(0):0,l=s.length?s.end(s.length-1):0,c=o.length?o.start(0):0,d=o.length?o.end(o.length-1):0
if(l-u<=1&&d-c<=1){this.logger_("On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: "+a.byteLength+", audio buffer: "+tc(s).join(", ")+", video buffer: "+tc(o).join(", ")+", ")
this.error({message:"Quota exceeded error with append of a single segment of content",excludeUntil:1/0})
this.trigger("error")}else{this.waitingOnRemove_=!0
this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:n,type:r,bytes:a}))
var h=this.currentTime_()-1
this.logger_("On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to "+h)
this.remove(0,h,(function(){i.logger_("On QUOTA_EXCEEDED_ERR, retrying append in 1s")
i.waitingOnRemove_=!1
i.quotaExceededErrorRetryTimeout_=x.setTimeout((function(){i.logger_("On QUOTA_EXCEEDED_ERR, re-processing call queue")
i.quotaExceededErrorRetryTimeout_=null
i.processCallQueue_()}),1e3)}),!0)}}
i.handleAppendError_=function(e,t){var i=e.segmentInfo,n=e.type,r=e.bytes
if(t)if(22!==t.code){this.logger_("Received non QUOTA_EXCEEDED_ERR on append",t)
this.error(n+" append of "+r.length+"b failed for segment #"+i.mediaIndex+" in playlist "+i.playlist.id)
this.trigger("appenderror")}else this.handleQuotaExceededError_({segmentInfo:i,type:n,bytes:r})}
i.appendToSourceBuffer_=function(e){var t=e.segmentInfo,i=e.type,n=e.initSegment,r=e.data,a=e.bytes
if(!a){var s=[r],o=r.byteLength
if(n){s.unshift(n)
o+=n.byteLength}a=function(e){var t,i=0
if(e.bytes){t=new Uint8Array(e.bytes)
e.segments.forEach((function(e){t.set(e,i)
i+=e.byteLength}))}return t}({bytes:o,segments:s})}this.sourceUpdater_.appendBuffer({segmentInfo:t,type:i,bytes:a},this.handleAppendError_.bind(this,{segmentInfo:t,type:i,bytes:a}))}
i.handleSegmentTimingInfo_=function(e,t,i){if(this.pendingSegment_&&t===this.pendingSegment_.requestId){var n=this.pendingSegment_.segment,r=e+"TimingInfo"
n[r]||(n[r]={})
n[r].transmuxerPrependedSeconds=i.prependedContentDuration||0
n[r].transmuxedPresentationStart=i.start.presentation
n[r].transmuxedDecodeStart=i.start.decode
n[r].transmuxedPresentationEnd=i.end.presentation
n[r].transmuxedDecodeEnd=i.end.decode
n[r].baseMediaDecodeTime=i.baseMediaDecodeTime}}
i.appendData_=function(e,t){var i=t.type,n=t.data
if(n&&n.byteLength&&("audio"!==i||!this.audioDisabled_)){var r=this.getInitSegmentAndUpdateState_({type:i,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null})
this.appendToSourceBuffer_({segmentInfo:e,type:i,initSegment:r,data:n})}}
i.loadSegment_=function(e){var t=this
this.state="WAITING"
this.pendingSegment_=e
this.trimBackBuffer_(e)
"number"==typeof e.timestampOffset&&this.transmuxer_&&this.transmuxer_.postMessage({action:"clearAllMp4Captions"})
this.hasEnoughInfoToLoad_()?this.updateTransmuxerAndRequestSegment_(e):this.loadQueue_.push((function(){var i=R({},e,{forceTimestampOffset:!0})
R(e,t.generateSegmentInfo_(i))
t.isPendingTimestampOffset_=!1
t.updateTransmuxerAndRequestSegment_(e)}))}
i.updateTransmuxerAndRequestSegment_=function(e){var t=this
if(this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)){this.gopBuffer_.length=0
e.gopsToAlignWith=[]
this.timeMapping_=0
this.transmuxer_.postMessage({action:"reset"})
this.transmuxer_.postMessage({action:"setTimestampOffset",timestampOffset:e.timestampOffset})}var i=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),r=null!==this.mediaIndex,a=e.timeline!==this.currentTimeline_&&e.timeline>0,s=n||r&&a
this.logger_("Requesting "+Qd(e))
if(i.map&&!i.map.bytes){this.logger_("going to request init segment.")
this.appendInitSegment_={video:!0,audio:!0}}e.abortRequests=Dd({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:i,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"video",e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,"audio",e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:s,endedTimelineFn:function(){t.logger_("received endedtimeline callback")},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:function(i){var n=i.message,r=i.level,a=i.stream
t.logger_(Qd(e)+" logged from transmuxer stream "+a+" as a "+r+": "+n)}})}
i.trimBackBuffer_=function(e){var t=function(e,t,i){var n=t-ad.BACK_BUFFER_LENGTH
e.length&&(n=Math.max(n,e.start(0)))
var r=t-i
return Math.min(r,n)}(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10)
t>0&&this.remove(0,t)}
i.createSimplifiedSegmentObj_=function(e){var t=e.segment,i=e.part,n={resolvedUri:i?i.resolvedUri:t.resolvedUri,byterange:i?i.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part},r=e.playlist.segments[e.mediaIndex-1]
r&&r.timeline===t.timeline&&(r.videoTimingInfo?n.baseStartTime=r.videoTimingInfo.transmuxedDecodeEnd:r.audioTimingInfo&&(n.baseStartTime=r.audioTimingInfo.transmuxedDecodeEnd))
if(t.key){var a=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence])
n.key=this.segmentKey(t.key)
n.key.iv=a}t.map&&(n.map=this.initSegmentForMap(t.map))
return n}
i.saveTransferStats_=function(e){this.mediaRequests+=1
if(e){this.mediaBytesTransferred+=e.bytesReceived
this.mediaTransferDuration+=e.roundTripTime}}
i.saveBandwidthRelatedStats_=function(e,t){this.pendingSegment_.byteLength=t.bytesReceived
if(e<Yd)this.logger_("Ignoring segment's bandwidth because its duration of "+e+" is less than the min to record "+Yd)
else{this.bandwidth=t.bandwidth
this.roundTrip=t.roundTripTime}}
i.handleTimeout_=function(){this.mediaRequestsTimedout+=1
this.bandwidth=1
this.roundTrip=NaN
this.trigger("bandwidthupdate")}
i.segmentRequestFinished_=function(e,t,i){if(this.callQueue_.length)this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,i))
else{this.saveTransferStats_(t.stats)
if(this.pendingSegment_&&t.requestId===this.pendingSegment_.requestId)if(e){this.pendingSegment_=null
this.state="READY"
if(e.code===kd)return
this.pause()
if(e.code===Td){this.handleTimeout_()
return}this.mediaRequestsErrored+=1
this.error(e)
this.trigger("error")}else{var n=this.pendingSegment_
this.saveBandwidthRelatedStats_(n.duration,t.stats)
n.endOfAllRequests=t.endOfAllRequests
i.gopInfo&&(this.gopBuffer_=function(e,t,i){if(!t.length)return e
if(i)return t.slice()
for(var n=t[0].pts,r=0;r<e.length&&!(e[r].pts>=n);r++);return e.slice(0,r).concat(t)}(this.gopBuffer_,i.gopInfo,this.safeAppend_))
this.state="APPENDING"
this.trigger("appending")
this.waitForAppendsToComplete_(n)}}}
i.setTimeMapping_=function(e){var t=this.syncController_.mappingForTimeline(e)
null!==t&&(this.timeMapping_=t)}
i.updateMediaSecondsLoaded_=function(e){"number"==typeof e.start&&"number"==typeof e.end?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}
i.shouldUpdateTransmuxerTimestampOffset_=function(e){return null!==e&&("main"===this.loaderType_&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset())}
i.trueSegmentStart_=function(e){var t=e.currentStart,i=e.playlist,n=e.mediaIndex,r=e.firstVideoFrameTimeForData,a=e.currentVideoTimestampOffset,s=e.useVideoTimingInfo,o=e.videoTimingInfo,u=e.audioTimingInfo
if(void 0!==t)return t
if(!s)return u.start
var l=i.segments[n-1]
return 0!==n&&l&&void 0!==l.start&&l.end===r+a?o.start:r}
i.waitForAppendsToComplete_=function(e){var t=this.getCurrentMediaInfo_(e)
if(t){var i=t.hasAudio,n=t.hasVideo,r=t.isMuxed,a="main"===this.loaderType_&&n,s=!this.audioDisabled_&&i&&!r
e.waitingOnAppends=0
if(e.hasAppendedData_){a&&e.waitingOnAppends++
s&&e.waitingOnAppends++
a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e))
s&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))}else{e.timingInfo||"number"!=typeof e.timestampOffset||(this.isPendingTimestampOffset_=!0)
e.timingInfo={start:0}
e.waitingOnAppends++
if(!this.isPendingTimestampOffset_){this.updateSourceBufferTimestampOffset_(e)
this.processMetadataQueue_()}this.checkAppendsDone_(e)}}else{this.error({message:"No starting media returned, likely due to an unsupported media format.",blacklistDuration:1/0})
this.trigger("error")}}
i.checkAppendsDone_=function(e){if(!this.checkForAbort_(e.requestId)){e.waitingOnAppends--
0===e.waitingOnAppends&&this.handleAppendsDone_()}}
i.checkForIllegalMediaSwitch=function(e){var t=function(e,t,i){return"main"===e&&t&&i?i.hasAudio||i.hasVideo?t.hasVideo&&!i.hasVideo?"Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.":!t.hasVideo&&i.hasVideo?"Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.":null:"Neither audio nor video found in segment.":null}(this.loaderType_,this.getCurrentMediaInfo_(),e)
if(t){this.error({message:t,blacklistDuration:1/0})
this.trigger("error")
return!0}return!1}
i.updateSourceBufferTimestampOffset_=function(e){if(null!==e.timestampOffset&&"number"==typeof e.timingInfo.start&&!e.changedTimestampOffset&&"main"===this.loaderType_){var t=!1
e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo})
e.changedTimestampOffset=!0
if(e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()){this.sourceUpdater_.videoTimestampOffset(e.timestampOffset)
t=!0}if(e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()){this.sourceUpdater_.audioTimestampOffset(e.timestampOffset)
t=!0}t&&this.trigger("timestampoffset")}}
i.getSegmentStartTimeForTimestampOffsetCalculation_=function(e){var t=e.videoTimingInfo,i=e.audioTimingInfo,n=e.timingInfo
return this.useDtsForTimestampOffset_?t&&"number"==typeof t.transmuxedDecodeStart?t.transmuxedDecodeStart:i&&"number"==typeof i.transmuxedDecodeStart?i.transmuxedDecodeStart:n.start:n.start}
i.updateTimingInfoEnd_=function(e){e.timingInfo=e.timingInfo||{}
var t=this.getMediaInfo_(),i="main"===this.loaderType_&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo
i&&(e.timingInfo.end="number"==typeof i.end?i.end:i.start+e.duration)}
i.handleAppendsDone_=function(){this.pendingSegment_&&this.trigger("appendsdone")
if(this.pendingSegment_){var e=this.pendingSegment_
this.updateTimingInfoEnd_(e)
this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:"main"===this.loaderType_})
var t=eh(e,this.sourceType_)
t&&("warn"===t.severity?ql.log.warn(t.message):this.logger_(t.message))
this.recordThroughput_(e)
this.pendingSegment_=null
this.state="READY"
if(e.isSyncRequest){this.trigger("syncinfoupdate")
if(!e.hasAppendedData_){this.logger_("Throwing away un-appended sync request "+Qd(e))
return}}this.logger_("Appended "+Qd(e))
this.addSegmentMetadataCue_(e)
this.fetchAtBuffer_=!0
if(this.currentTimeline_!==e.timeline){this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})
"main"!==this.loaderType_||this.audioDisabled_||this.timelineChangeController_.lastTimelineChange({type:"audio",from:this.currentTimeline_,to:e.timeline})}this.currentTimeline_=e.timeline
this.trigger("syncinfoupdate")
var i=e.segment,n=e.part,r=i.end&&this.currentTime_()-i.end>3*e.playlist.targetDuration,a=n&&n.end&&this.currentTime_()-n.end>3*e.playlist.partTargetDuration
if(r||a){this.logger_("bad "+(r?"segment":"part")+" "+Qd(e))
this.resetEverything()}else{null!==this.mediaIndex&&this.trigger("bandwidthupdate")
this.trigger("progress")
this.mediaIndex=e.mediaIndex
this.partIndex=e.partIndex
this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream()
this.trigger("appended")
e.hasAppendedData_&&this.mediaAppends++
this.paused()||this.monitorBuffer_()}}else{this.state="READY"
this.paused()||this.monitorBuffer_()}}
i.recordThroughput_=function(e){if(e.duration<Yd)this.logger_("Ignoring segment's throughput because its duration of "+e.duration+" is less than the min to record "+Yd)
else{var t=this.throughput.rate,i=Date.now()-e.endOfAllRequests+1,n=Math.floor(e.byteLength/i*8*1e3)
this.throughput.rate+=(n-t)/++this.throughput.count}}
i.addSegmentMetadataCue_=function(e){if(this.segmentMetadataTrack_){var t=e.segment,i=t.start,n=t.end
if(Xd(i)&&Xd(n)){Kd(i,n,this.segmentMetadataTrack_)
var r=x.WebKitDataCue||x.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:i,end:n},s=new r(i,n,JSON.stringify(a))
s.value=a
this.segmentMetadataTrack_.addCue(s)}}}
return t}(ql.EventTarget)
function ih(){}var nh,rh=function(e){return"string"!=typeof e?e:e.replace(/./,(function(e){return e.toUpperCase()}))},ah=["video","audio"],sh=function(e,t){var i=t[e+"Buffer"]
return i&&i.updating||t.queuePending[e]},oh=function e(t,i){if(0!==i.queue.length){var n=0,r=i.queue[n]
if("mediaSource"!==r.type){if("mediaSource"!==t&&i.ready()&&"closed"!==i.mediaSource.readyState&&!sh(t,i)){if(r.type!==t){n=function(e,t){for(var i=0;i<t.length;i++){var n=t[i]
if("mediaSource"===n.type)return null
if(n.type===e)return i}return null}(t,i.queue)
if(null===n)return
r=i.queue[n]}i.queue.splice(n,1)
i.queuePending[t]=r
r.action(t,i)
if(r.doneFn);else{i.queuePending[t]=null
e(t,i)}}}else if(!i.updating()&&"closed"!==i.mediaSource.readyState){i.queue.shift()
r.action(i)
r.doneFn&&r.doneFn()
e("audio",i)
e("video",i)}}},uh=function(e,t){var i=t[e+"Buffer"],n=rh(e)
if(i){i.removeEventListener("updateend",t["on"+n+"UpdateEnd_"])
i.removeEventListener("error",t["on"+n+"Error_"])
t.codecs[e]=null
t[e+"Buffer"]=null}},lh=function(e,t){return e&&t&&-1!==Array.prototype.indexOf.call(e.sourceBuffers,t)},ch=function(e,t,i){return function(n,r){var a=r[n+"Buffer"]
if(lh(r.mediaSource,a)){r.logger_("Appending segment "+t.mediaIndex+"'s "+e.length+" bytes to "+n+"Buffer")
try{a.appendBuffer(e)}catch(e){r.logger_("Error with code "+e.code+" "+(22===e.code?"(QUOTA_EXCEEDED_ERR) ":"")+"when appending segment "+t.mediaIndex+" to "+n+"Buffer")
r.queuePending[n]=null
i(e)}}}},dh=function(e,t){return function(i,n){var r=n[i+"Buffer"]
if(lh(n.mediaSource,r)){n.logger_("Removing "+e+" to "+t+" from "+i+"Buffer")
try{r.remove(e,t)}catch(r){n.logger_("Remove "+e+" to "+t+" from "+i+"Buffer failed")}}}},hh=function(e){return function(t,i){var n=i[t+"Buffer"]
if(lh(i.mediaSource,n)){i.logger_("Setting "+t+"timestampOffset to "+e)
n.timestampOffset=e}}},ph=function(e){return function(t,i){e()}},fh=function(e){return function(t){if("open"===t.mediaSource.readyState){t.logger_("Calling mediaSource endOfStream("+(e||"")+")")
try{t.mediaSource.endOfStream(e)}catch(e){ql.log.warn("Failed to call media source endOfStream",e)}}}},mh=function(e){return function(t){t.logger_("Setting mediaSource duration to "+e)
try{t.mediaSource.duration=e}catch(e){ql.log.warn("Failed to set media source duration",e)}}},gh=function(){return function(e,t){if("open"===t.mediaSource.readyState){var i=t[e+"Buffer"]
if(lh(t.mediaSource,i)){t.logger_("calling abort on "+e+"Buffer")
try{i.abort()}catch(t){ql.log.warn("Failed to abort on "+e+"Buffer",t)}}}}},vh=function(e,t){return function(i){var n=rh(e),r=Ke(t)
i.logger_("Adding "+e+"Buffer with codec "+t+" to mediaSource")
var a=i.mediaSource.addSourceBuffer(r)
a.addEventListener("updateend",i["on"+n+"UpdateEnd_"])
a.addEventListener("error",i["on"+n+"Error_"])
i.codecs[e]=t
i[e+"Buffer"]=a}},yh=function(e){return function(t){var i=t[e+"Buffer"]
uh(e,t)
if(lh(t.mediaSource,i)){t.logger_("Removing "+e+"Buffer with codec "+t.codecs[e]+" from mediaSource")
try{t.mediaSource.removeSourceBuffer(i)}catch(t){ql.log.warn("Failed to removeSourceBuffer "+e+"Buffer",t)}}}},_h=function(e){return function(t,i){var n=i[t+"Buffer"],r=Ke(e)
if(lh(i.mediaSource,n)&&i.codecs[t]!==e){i.logger_("changing "+t+"Buffer codec from "+i.codecs[t]+" to "+e)
n.changeType(r)
i.codecs[t]=e}}},bh=function(e){var t=e.type,i=e.sourceUpdater,n=e.action,r=e.doneFn,a=e.name
i.queue.push({type:t,action:n,doneFn:r,name:a})
oh(t,i)},Th=function(e,t){return function(i){if(t.queuePending[e]){var n=t.queuePending[e].doneFn
t.queuePending[e]=null
n&&n(t[e+"Error_"])}oh(e,t)}},kh=function(e){B(t,e)
function t(t){var i;(i=e.call(this)||this).mediaSource=t
i.sourceopenListener_=function(){return oh("mediaSource",N(i))}
i.mediaSource.addEventListener("sourceopen",i.sourceopenListener_)
i.logger_=Xl("SourceUpdater")
i.audioTimestampOffset_=0
i.videoTimestampOffset_=0
i.queue=[]
i.queuePending={audio:null,video:null}
i.delayedAudioAppendQueue_=[]
i.videoAppendQueued_=!1
i.codecs={}
i.onVideoUpdateEnd_=Th("video",N(i))
i.onAudioUpdateEnd_=Th("audio",N(i))
i.onVideoError_=function(e){i.videoError_=e}
i.onAudioError_=function(e){i.audioError_=e}
i.createdSourceBuffers_=!1
i.initializedEme_=!1
i.triggeredReady_=!1
return i}var i=t.prototype
i.initializedEme=function(){this.initializedEme_=!0
this.triggerReady()}
i.hasCreatedSourceBuffers=function(){return this.createdSourceBuffers_}
i.hasInitializedAnyEme=function(){return this.initializedEme_}
i.ready=function(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}
i.createSourceBuffers=function(e){if(!this.hasCreatedSourceBuffers()){this.addOrChangeSourceBuffers(e)
this.createdSourceBuffers_=!0
this.trigger("createdsourcebuffers")
this.triggerReady()}}
i.triggerReady=function(){if(this.ready()&&!this.triggeredReady_){this.triggeredReady_=!0
this.trigger("ready")}}
i.addSourceBuffer=function(e,t){bh({type:"mediaSource",sourceUpdater:this,action:vh(e,t),name:"addSourceBuffer"})}
i.abort=function(e){bh({type:e,sourceUpdater:this,action:gh(e),name:"abort"})}
i.removeSourceBuffer=function(e){this.canRemoveSourceBuffer()?bh({type:"mediaSource",sourceUpdater:this,action:yh(e),name:"removeSourceBuffer"}):ql.log.error("removeSourceBuffer is not supported!")}
i.canRemoveSourceBuffer=function(){return!ql.browser.IE_VERSION&&!ql.browser.IS_FIREFOX&&x.MediaSource&&x.MediaSource.prototype&&"function"==typeof x.MediaSource.prototype.removeSourceBuffer}
t.canChangeType=function(){return x.SourceBuffer&&x.SourceBuffer.prototype&&"function"==typeof x.SourceBuffer.prototype.changeType}
i.canChangeType=function(){return this.constructor.canChangeType()}
i.changeType=function(e,t){this.canChangeType()?bh({type:e,sourceUpdater:this,action:_h(t),name:"changeType"}):ql.log.error("changeType is not supported!")}
i.addOrChangeSourceBuffers=function(e){var t=this
if(!e||"object"!=typeof e||0===Object.keys(e).length)throw new Error("Cannot addOrChangeSourceBuffers to undefined codecs")
Object.keys(e).forEach((function(i){var n=e[i]
if(!t.hasCreatedSourceBuffers())return t.addSourceBuffer(i,n)
t.canChangeType()&&t.changeType(i,n)}))}
i.appendBuffer=function(e,t){var i=this,n=e.segmentInfo,r=e.type,a=e.bytes
this.processedAppend_=!0
if("audio"!==r||!this.videoBuffer||this.videoAppendQueued_){bh({type:r,sourceUpdater:this,action:ch(a,n||{mediaIndex:-1},t),doneFn:t,name:"appendBuffer"})
if("video"===r){this.videoAppendQueued_=!0
if(!this.delayedAudioAppendQueue_.length)return
var s=this.delayedAudioAppendQueue_.slice()
this.logger_("queuing delayed audio "+s.length+" appendBuffers")
this.delayedAudioAppendQueue_.length=0
s.forEach((function(e){i.appendBuffer.apply(i,e)}))}}else{this.delayedAudioAppendQueue_.push([e,t])
this.logger_("delayed audio append of "+a.length+" until video append")}}
i.audioBuffered=function(){return lh(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:ql.createTimeRange()}
i.videoBuffered=function(){return lh(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:ql.createTimeRange()}
i.buffered=function(){var e=lh(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=lh(this.mediaSource,this.audioBuffer)?this.audioBuffer:null
return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():function(e,t){var i=null,n=null,r=0,a=[],s=[]
if(!(e&&e.length&&t&&t.length))return ql.createTimeRange()
for(var o=e.length;o--;){a.push({time:e.start(o),type:"start"})
a.push({time:e.end(o),type:"end"})}o=t.length
for(;o--;){a.push({time:t.start(o),type:"start"})
a.push({time:t.end(o),type:"end"})}a.sort((function(e,t){return e.time-t.time}))
for(o=0;o<a.length;o++){"start"===a[o].type?2==++r&&(i=a[o].time):"end"===a[o].type&&1==--r&&(n=a[o].time)
if(null!==i&&null!==n){s.push([i,n])
i=null
n=null}}return ql.createTimeRanges(s)}(this.audioBuffered(),this.videoBuffered())}
i.setDuration=function(e,t){void 0===t&&(t=ih)
bh({type:"mediaSource",sourceUpdater:this,action:mh(e),name:"duration",doneFn:t})}
i.endOfStream=function(e,t){void 0===e&&(e=null)
void 0===t&&(t=ih)
"string"!=typeof e&&(e=void 0)
bh({type:"mediaSource",sourceUpdater:this,action:fh(e),name:"endOfStream",doneFn:t})}
i.removeAudio=function(e,t,i){void 0===i&&(i=ih)
this.audioBuffered().length&&0!==this.audioBuffered().end(0)?bh({type:"audio",sourceUpdater:this,action:dh(e,t),doneFn:i,name:"remove"}):i()}
i.removeVideo=function(e,t,i){void 0===i&&(i=ih)
this.videoBuffered().length&&0!==this.videoBuffered().end(0)?bh({type:"video",sourceUpdater:this,action:dh(e,t),doneFn:i,name:"remove"}):i()}
i.updating=function(){return!(!sh("audio",this)&&!sh("video",this))}
i.audioTimestampOffset=function(e){if(void 0!==e&&this.audioBuffer&&this.audioTimestampOffset_!==e){bh({type:"audio",sourceUpdater:this,action:hh(e),name:"timestampOffset"})
this.audioTimestampOffset_=e}return this.audioTimestampOffset_}
i.videoTimestampOffset=function(e){if(void 0!==e&&this.videoBuffer&&this.videoTimestampOffset!==e){bh({type:"video",sourceUpdater:this,action:hh(e),name:"timestampOffset"})
this.videoTimestampOffset_=e}return this.videoTimestampOffset_}
i.audioQueueCallback=function(e){this.audioBuffer&&bh({type:"audio",sourceUpdater:this,action:ph(e),name:"callback"})}
i.videoQueueCallback=function(e){this.videoBuffer&&bh({type:"video",sourceUpdater:this,action:ph(e),name:"callback"})}
i.dispose=function(){var e=this
this.trigger("dispose")
ah.forEach((function(t){e.abort(t)
e.canRemoveSourceBuffer()?e.removeSourceBuffer(t):e[t+"QueueCallback"]((function(){return uh(t,e)}))}))
this.videoAppendQueued_=!1
this.delayedAudioAppendQueue_.length=0
this.sourceopenListener_&&this.mediaSource.removeEventListener("sourceopen",this.sourceopenListener_)
this.off()}
return t}(ql.EventTarget),Sh=function(e){return decodeURIComponent(escape(String.fromCharCode.apply(null,e)))},Eh=new Uint8Array("\n\n".split("").map((function(e){return e.charCodeAt(0)}))),Ch=function(e){B(t,e)
function t(t,i){var n
void 0===i&&(i={});(n=e.call(this,t,i)||this).mediaSource_=null
n.subtitlesTrack_=null
n.loaderType_="subtitle"
n.featuresNativeTextTracks_=t.featuresNativeTextTracks
n.shouldSaveSegmentTimingInfo_=!1
return n}var i=t.prototype
i.createTransmuxer_=function(){return null}
i.buffered_=function(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return ql.createTimeRanges()
var e=this.subtitlesTrack_.cues,t=e[0].startTime,i=e[e.length-1].startTime
return ql.createTimeRanges([[t,i]])}
i.initSegmentForMap=function(e,t){void 0===t&&(t=!1)
if(!e)return null
var i=zc(e),n=this.initSegments_[i]
if(t&&!n&&e.bytes){var r=Eh.byteLength+e.bytes.byteLength,a=new Uint8Array(r)
a.set(e.bytes)
a.set(Eh,e.bytes.byteLength)
this.initSegments_[i]=n={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:a}}return n||e}
i.couldBeginLoading_=function(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}
i.init_=function(){this.state="READY"
this.resetEverything()
return this.monitorBuffer_()}
i.track=function(e){if(void 0===e)return this.subtitlesTrack_
this.subtitlesTrack_=e
"INIT"===this.state&&this.couldBeginLoading_()&&this.init_()
return this.subtitlesTrack_}
i.remove=function(e,t){Kd(e,t,this.subtitlesTrack_)}
i.fillBuffer_=function(){var e=this,t=this.chooseNextRequest_()
if(t)if(null!==this.syncController_.timestampOffsetForTimeline(t.timeline))this.loadSegment_(t)
else{this.syncController_.one("timestampoffset",(function(){e.state="READY"
e.paused()||e.monitorBuffer_()}))
this.state="WAITING_ON_TIMELINE"}}
i.timestampOffsetForSegment_=function(){return null}
i.chooseNextRequest_=function(){return this.skipEmptySegments_(e.prototype.chooseNextRequest_.call(this))}
i.skipEmptySegments_=function(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null
break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}
i.stopForError=function(e){this.error(e)
this.state="READY"
this.pause()
this.trigger("error")}
i.segmentRequestFinished_=function(e,t,i){var n=this
if(this.subtitlesTrack_){this.saveTransferStats_(t.stats)
if(this.pendingSegment_)if(e){e.code===Td&&this.handleTimeout_()
e.code===kd?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1
this.stopForError(e)}else{var r=this.pendingSegment_
this.saveBandwidthRelatedStats_(r.duration,t.stats)
this.state="APPENDING"
this.trigger("appending")
var a=r.segment
a.map&&(a.map.bytes=t.map.bytes)
r.bytes=t.bytes
if("function"!=typeof x.WebVTT&&this.subtitlesTrack_&&this.subtitlesTrack_.tech_){var s,o=function(){n.subtitlesTrack_.tech_.off("vttjsloaded",s)
n.stopForError({message:"Error loading vtt.js"})}
s=function(){n.subtitlesTrack_.tech_.off("vttjserror",o)
n.segmentRequestFinished_(e,t,i)}
this.state="WAITING_ON_VTTJS"
this.subtitlesTrack_.tech_.one("vttjsloaded",s)
this.subtitlesTrack_.tech_.one("vttjserror",o)}else{a.requested=!0
try{this.parseVTTCues_(r)}catch(e){this.stopForError({message:e.message})
return}this.updateTimeMapping_(r,this.syncController_.timelines[r.timeline],this.playlist_)
r.cues.length?r.timingInfo={start:r.cues[0].startTime,end:r.cues[r.cues.length-1].endTime}:r.timingInfo={start:r.startOfSegment,end:r.startOfSegment+r.duration}
if(r.isSyncRequest){this.trigger("syncinfoupdate")
this.pendingSegment_=null
this.state="READY"}else{r.byteLength=r.bytes.byteLength
this.mediaSecondsLoaded+=a.duration
r.cues.forEach((function(e){n.subtitlesTrack_.addCue(n.featuresNativeTextTracks_?new x.VTTCue(e.startTime,e.endTime,e.text):e)}))
!function(e){var t=e.cues
if(t)for(var i=0;i<t.length;i++){for(var n=[],r=0,a=0;a<t.length;a++)t[i].startTime===t[a].startTime&&t[i].endTime===t[a].endTime&&t[i].text===t[a].text&&++r>1&&n.push(t[a])
n.length&&n.forEach((function(t){return e.removeCue(t)}))}}(this.subtitlesTrack_)
this.handleAppendsDone_()}}}else{this.state="READY"
this.mediaRequestsAborted+=1}}else this.state="READY"}
i.handleData_=function(){}
i.updateTimingInfoEnd_=function(){}
i.parseVTTCues_=function(e){var t,i=!1
if("function"==typeof x.TextDecoder)t=new x.TextDecoder("utf8")
else{t=x.WebVTT.StringDecoder()
i=!0}var n=new x.WebVTT.Parser(x,x.vttjs,t)
e.cues=[]
e.timestampmap={MPEGTS:0,LOCAL:0}
n.oncue=e.cues.push.bind(e.cues)
n.ontimestampmap=function(t){e.timestampmap=t}
n.onparsingerror=function(e){ql.log.warn("Error encountered when parsing cues: "+e.message)}
if(e.segment.map){var r=e.segment.map.bytes
i&&(r=Sh(r))
n.parse(r)}var a=e.bytes
i&&(a=Sh(a))
n.parse(a)
n.flush()}
i.updateTimeMapping_=function(e,t,i){var n=e.segment
if(t)if(e.cues.length){var r=e.timestampmap,a=r.MPEGTS/wr-r.LOCAL+t.mapping
e.cues.forEach((function(e){e.startTime+=a
e.endTime+=a}))
if(!i.syncInfo){var s=e.cues[0].startTime,o=e.cues[e.cues.length-1].startTime
i.syncInfo={mediaSequence:i.mediaSequence+e.mediaIndex,time:Math.min(s,o-n.duration)}}}else n.empty=!0}
return t}(th),wh=function(e,t){for(var i=e.cues,n=0;n<i.length;n++){var r=i[n]
if(t>=r.adStartTime&&t<=r.adEndTime)return r}return null},Ih=[{name:"VOD",run:function(e,t,i,n,r){if(i!==1/0){return{time:0,segmentIndex:0,partIndex:null}}return null}},{name:"ProgramDateTime",run:function(e,t,i,n,r){if(!Object.keys(e.timelineToDatetimeMappings).length)return null
var a=null,s=null,o=sc(t)
r=r||0
for(var u=0;u<o.length;u++){var l=o[t.endList||0===r?u:o.length-(u