define(["playbackManager","events","globalize","inputManager","userSettings"],function(playbackManager,events,globalize,inputManager,userSettings){"use strict";function confirmStillPlaying(){var maxIdleTime=userSettings.stillWatchingTimeMs();return maxIdleTime<=0||inputManager.idleTime()<maxIdleTime?Promise.resolve():require(["confirm"]).then(function(responses){return(0,responses[0])({title:null,text:globalize.translate("AreYouStillWatching"),confirmText:globalize.translate("Yes"),cancelText:globalize.translate("No"),timeout:6e4})})}return function(){var confirmTimeout;function resetConfirmTimer(){clearConfirmTimer(),confirmTimeout=setTimeout(onConfirmTimeout,6e4)}function clearConfirmTimer(){confirmTimeout&&(clearTimeout(confirmTimeout),confirmTimeout=null)}function onConfirmTimeout(){confirmStillPlaying().then(resetConfirmTimer,function(result){"cancel"!==result&&"_timeout"!==result||playbackManager.stop()})}this.name="Are You Still Watching?",this.type="preplayintercept",this.id="stillplaying",this.intercept=function(options){return clearConfirmTimer(),"Video"===options.mediaType&&options.fullscreen?confirmStillPlaying():Promise.resolve()},events.on(playbackManager,"playbackstart",function(e,player,state){("Video"===(state.NowPlayingItem||{}).MediaType&&!player.isExternalPlayer&&0<userSettings.stillWatchingTimeMs()?resetConfirmTimer:clearConfirmTimer)()}),events.on(playbackManager,"playbackstop",clearConfirmTimer)}});