)),n=e.getPrefetchUrl(i),r=n&&t.find((function(e){return e.resolvedUri===n}))
if(r)return r}}catch(e){ql.log.error("Error occurred while checking prefetch cache for playlist selection",e)}finally{this.masterPlaylistController_.selectPlaylist=ql.Vhs.STANDARD_PLAYLIST_SELECTOR.bind(this)}return this.masterPlaylistController_.selectPlaylist()}var g_=function(e){d(i,e)
var t=g(i)
function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}
o(this,i);(n=t.apply(this,arguments))._enabled=r.enabled&&ql.Vhs
if(!n._enabled)return m(n)
n._shouldHookIntoActiveRequests=r.shouldHookIntoActiveRequests
e.ready((function(){n._setUpPlaylistSelector()}))
if(ql.Vhs.xhr._fromWebMediaPrefetchingPlugin)return m(n)
n._overrideVhsXhr()
return n}l(i,[{key:"enabled",get:function(){return this._enabled}},{key:"_overrideVhsXhr",value:function(){var e=this
ql.Vhs.xhr=function(t,i){return new f_({requestOptions:t,callback:i,prefetchCacheKey:"media-infra-prefetch-cache",shouldHookIntoActiveRequests:e._shouldHookIntoActiveRequests})}
ql.Vhs.xhr._fromWebMediaPrefetchingPlugin=!0}},{key:"_setUpPlaylistSelector",value:function(){var e=new window.Proxy(this.player.tech(!0),{set:function(e,t,i){var n
"vhs"===t&&(i.selectPlaylist=m_.bind(i))
return(n=window.Reflect).set.apply(n,arguments)}})
this.player.tech_=e}}])
return i}(ql.getPlugin("plugin"))
ql.registerPlugin("webMediaPrefetching",g_)
var v_=function(e){d(i,e)
var t=g(i)
function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}
o(this,i);(n=t.apply(this,arguments))._enabled=r.enabled&&ql.Vhs
if(!n.enabled)return m(n)
e.ready((function(){n._waitForVhsHandler()}))
return n}l(i,[{key:"enabled",get:function(){return this._enabled}},{key:"ready",value:function(e){var t=this.enabled&&this._vhsHandler
if(!e)return t
t?e():this.on("plugin-ready",(function(){e()}))}},{key:"setPlaylistSelector",value:function(e){var t,i=this.player.tech(!0).vhs
if(i){var n=e.bind(this._vhsHandler)
null!==(t=i.masterPlaylistController_)&&void 0!==t&&t.selectPlaylist&&(i.masterPlaylistController_.selectPlaylist=n)
this._vhsHandler.selectPlaylist=n}}},{key:"setPlaylistSelectorToDefault",value:function(){this.setPlaylistSelector(ql.Vhs.STANDARD_PLAYLIST_SELECTOR)}},{key:"_waitForVhsHandler",value:function(){var e=this,t=new window.Proxy(this.player.tech(!0),{set:function(t,i,n){var r,a=(r=window.Reflect).set.apply(r,arguments)
"vhs"===i&&function(t){e._vhsHandler=t
e.trigger("plugin-ready")}(n)
return a}})
this.player.tech_=t}}])
return i}(ql.getPlugin("plugin"))
ql.registerPlugin("playlistSelectorManager",v_)
var y_=ql.getPlugin("plugin"),__="vjs-interstitial-control-bar",b_="vjs-interstitial-progress-control",T_=function(e){var t=e.player,i=e.mediaUrn,n=e.trackingId,r=e.primaryMediaTrackingId
if(t){t.tracking&&t.tracking().createNewSession({mediaUrn:i,trackingId:n,primaryMediaTrackingId:r})
t.rum&&t.rum().createNewSession({mediaUrn:i,trackingId:n,primaryMediaTrackingId:r})}},k_=function(e){var t=e.player,i=e.tracks
if(null!=i&&i.length)for(var n=t.remoteTextTracks(),r=function(e){var r=n[e]
i.find((function(e){return e.src===r.src}))&&t.removeRemoteTextTrack(r)},a=0;a<n.length;a++)r(a)},S_=function(e){var t=e.player,n=e.tracksToRemove,r=e.tracksToAdd,a=function(e){for(var t=e.remoteTextTracks(),i=0;i<t.length;i++){var n=t[i]
if("showing"===n.mode)return n}return null}(t)
k_({player:t,tracks:n})
null==r||r.forEach((function(e){a&&e.kind===a.kind&&e.srclang===a.language&&(e=i(i({},e),{},{mode:"showing"}))
t.addRemoteTextTrack(e,!0)}))},E_=function(e){var t=e.options,n=e.sources,r=t.plugins.interstitials,a=r.items.filter((function(e){return 0===e.timestamp}))
if(null==a||!a.length)return t
r.primaryContent={sources:n}
t.tracks&&(r.primaryContent.tracks=t.tracks)
var s=i(i({},t),{},{sources:a[0].sources})
a[0].tracks&&(s.tracks=a[0].tracks)
var o=s.plugins,u=o.rum,l=o.tracking,c=(null==l?void 0:l.mediaUrn)||(null==u?void 0:u.mediaUrn)
c&&(r.primaryContent.mediaUrn=c)
var d=ey()
r.primaryContent.trackingId=d
r.items.forEach((function(e){e.trackingId=ey()}))
if(u){u.trackingId=a[0].trackingId
u.mediaUrn=a[0].mediaUrn
u.primaryMediaTrackingId=d}if(l){l.trackingId=a[0].trackingId
l.mediaUrn=a[0].mediaUrn
l.primaryMediaTrackingId=d}return s},C_=function(e){d(i,e)
var t=g(i)
function i(e){var r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}
o(this,i);(r=t.apply(this,arguments))._updateOptions(a)
if(0===r._interstitialItems.length)return m(r)
r._player=e
r._interstitialItemIndex=0
r._watchForSourceChanges()
r._watchForTextTrackAdditions()
e.ready((function(){r._configureProgressControlForInterstitial()
setTimeout((function(){r._stopWatchingForTextTrackAdditions=!0}),0)
r._player.one("play",s(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r._player.autoplay(!0)
e.next=3
return r._player.prefetch().prefetchToFirstSegment(r._primaryContent.sources)
case 3:case"end":return e.stop()}}),e)}))))
r._endedListener=r._onEnded.bind(f(r))
r._player.on("ended",r._endedListener)}))
return r}l(i,[{key:"_updateOptions",value:function(e){var t
this._interstitialItems=(null==e||null===(t=e.items)||void 0===t?void 0:t.filter((function(e){return 0===e.timestamp})))||[]
this._primaryContent=null==e?void 0:e.primaryContent}},{key:"_handlePrimarySourceChange",value:function(e){if(this._primaryContent.sources){k_({player:this._player,tracks:this._currentItemTracks()})
k_({player:this._player,tracks:this._primaryContent.tracks})
var t=E_({options:this._player.options(),sources:e})
this._player.options(t)
this._updateOptions(t.plugins.interstitials)
this._setSourceToFirstInterstitial()}else this._primaryContent.sources=e}},{key:"_watchForSourceChanges",value:function(){var e=this
this._origSource=this._player.src.bind(this._player)
this._player.src=function(t){var i,n
if(!t||e._isDisposed||null===(i=e._player.options().plugins.interstitials)||void 0===i||null===(n=i.items)||void 0===n||!n.length||e._player.options().sources===t)return e._origSource(t)
e._handlePrimarySourceChange(t)}}},{key:"_watchForTextTrackAdditions",value:function(){var e=this,t=this._player.addRemoteTextTrack
this._player.addRemoteTextTrack=function(){for(var i,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a]
var s=r[0],o=s.src,u=s.kind,l=s.label,c=s.srclang,d=((null===(i=e._interstitialItems[0])||void 0===i?void 0:i.tracks)||[]).map((function(e){return e.src}))
if(e._stopWatchingForTextTrackAdditions||"metadata"===u||d.includes(o))return t.apply(e._player,r)
e._primaryContent.tracks=(e._primaryContent.tracks||[]).concat({src:o,kind:u,label:l,srclang:c})}}},{key:"_configureProgressControlForInterstitial",value:function(){var e
if(null!==(e=this._player.controlBar)&&void 0!==e&&e.progressControl){this._player.controlBar.progressControl.disable()
this._player.controlBar.addClass(__)
this._player.controlBar.progressControl.addClass(b_)}}},{key:"_setSourceToFirstInterstitial",value:function(){this._interstitialItemIndex=0
var e=this._interstitialItems[this._interstitialItemIndex]
this._setSourceToInterstitial({nextItem:e})}},{key:"_setSourceToNextInterstitial",value:function(){var e=this._interstitialItemIndex+1,t=this._interstitialItems[e]
if(!t)return null
var i=this._interstitialItems[this._interstitialItemIndex]
this._interstitialItemIndex=e
this._setSourceToInterstitial({currentItem:i,nextItem:t})
return t}},{key:"_setSourceToInterstitial",value:function(e){var t=e.currentItem,i=e.nextItem
if(i){this._configureProgressControlForInterstitial()
S_({player:this._player,tracksToRemove:null==t?void 0:t.tracks,tracksToAdd:i.tracks})
this._setSrc(i.sources)
T_({player:this._player,mediaUrn:i.mediaUrn,trackingId:i.trackingId,primaryMediaTrackingId:this._primaryContent.trackingId})}}},{key:"_setSrc",value:function(e){this._origSource(e)}},{key:"_onEnded",value:function(){if(null!==this._interstitialItemIndex){this._setSourceToNextInterstitial()||this.skipToPrimaryContent()}}},{key:"_currentItemTracks",value:function(){var e
return null===(e=this._interstitialItems[this._interstitialItemIndex])||void 0===e?void 0:e.tracks}},{key:"_configureProgressControlForPrimaryContent",value:function(){this._player.controlBar.progressControl.enable()
this._player.controlBar.removeClass(__)
this._player.controlBar.progressControl.removeClass(b_)}},{key:"skipToPrimaryContent",value:function(){this._player.off("ended",this._endedListener)
S_({player:this._player,tracksToRemove:this._currentItemTracks(),tracksToAdd:this._primaryContent.tracks})
this._interstitialItemIndex=null
this._configureProgressControlForPrimaryContent()
this._setSrc(this._primaryContent.sources)
T_({player:this._player,mediaUrn:this._primaryContent.mediaUrn,trackingId:this._primaryContent.trackingId})}},{key:"isPlayingInterstitial",value:function(){return"number"==typeof this._interstitialItemIndex}},{key:"isFinalSource",value:function(){var e=this._player.src()
return!!this._primaryContent.sources.find((function(t){return t.src===e}))}},{key:"dispose",value:function(){v(h(i.prototype),"dispose",this).call(this)
this._isDisposed=!0}}])
return i}(y_)
ql.registerPlugin("interstitials",C_)
var w_={rum:1,xhrHooks:1,tracking:2},I_=function(e){return w_[e]||1/0}
e.createPlayer=function(e){var t,n,r,a,s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).exposeGlobalVideojsForDebugging&&!window.vjsForDebug&&(window.vjsForDebug=ql)
var u,l={customCaptionsDisplay:!1,playerBanner:!1,children:{playerBanner:{},mediaLoader:{},posterImage:{},bigPlayButton:{},loadingSpinner:{},controlBar:{},errorDisplay:{},customCaptionsDisplay:{},textTrackDisplay:{},resizeManager:{},liveTracker:{}},controlBar:{skipBackButton:!1,skipAheadButton:!1,previousButton:!1,nextButton:!1,settingsMenuButton:!1,backToStartButton:!1,theaterModeButton:!1,fullscreenToggle:!1,captionsToggle:!1,captionsMenuToggle:!1,muteToggle:!1,remainingTimeDisplay:!1,children:i(i({},null!==(t=o.controlBar)&&void 0!==t&&null!==(n=t.progressControl)&&void 0!==n&&n.inline?{playToggle:{},progressControl:{}}:{progressControl:{},playToggle:{}}),{},{backToStartButton:{},skipBackButton:{},skipAheadButton:{},previousButton:{},nextButton:{},liveDisplay:{},timeDisplay:{},remainingTimeDisplay:{},customControlSpacer:{},playbackRateMenuButton:{},captionsToggle:{},captionsMenuToggle:{},settingsMenuButton:{},volumePanel:{inline:!1},muteToggle:{},theaterModeButton:{},fullscreenToggle:{}})},plugins:{disableContextMenu:!0,lifecycle:!0,qualityLevels:!0,verticalSliderMaxHeight:!0,menuOverflow:!0,setAriaLiveToOff:!0,generateTrackingId:!0,xhrHooks:{enabled:!1},stopBufferingHlsOnPause:{enabled:!1},requestQueue:{enabled:!1},delayedSegmentLoading:{enabled:!1},webMediaPrefetching:{enabled:!1},playlistSelectorManager:{enabled:!1}},controls:!0,fluid:!0,responsive:!0,aspectRatio:"auto",enableSourceset:!0,techOrder:["html5"],noUITitleAttributes:!(null===(r=o.plugins)||void 0===r||!r.controlTooltips),html5:{vhs:{withCredentials:!1,limitRenditionByPlayerDimensions:!1,experimentalBufferBasedABR:!0,useNetworkInformationApi:!0,cacheEncryptionKeys:!0},nativeTextTracks:ql.browser.IS_IPHONE}},c=ql.mergeOptions(l,o,{autoplay:!0===o.autoplay?"any":o.autoplay||!1}),d=c.plugins
delete c.plugins
c.plugins={};(u=d,Object.keys(u).sort((function(e,t){return I_(e)-I_(t)}))).forEach((function(e){c.plugins[e]=d[e]}))
null!==(a=c.plugins.interstitials)&&void 0!==a&&null!==(s=a.items)&&void 0!==s&&s.length&&(c=E_({options:c,sources:c.sources}))
return ql(e,c)}
e.videojs=ql
Object.defineProperty(e,"__esModule",{value:!0})}))

//# sourceMappingURL=media-player.amd.mapӘ