define(["exports","./../common/globalize.js","./../emby-apiclient/events.js","./../common/usersettings/usersettings.js","./../common/inputmanager.js","./../common/playback/playbackmanager.js","./../input/mouse.js","./../common/methodtimer.js"],function(_exports,_globalize,_events,_usersettings,_inputmanager,_playbackmanager,_mouse,_methodtimer){Object.defineProperty(_exports,"__esModule",{value:!0});var IsDebug=!(_exports.default=function(){var confirmTimeout;function clearConfirmTimer(){confirmTimeout&&(confirmTimeout.destroy(),confirmTimeout=null)}function onConfirmTimeout(){confirmStillPlaying()}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.default.on(_playbackmanager.default,"playbackstart",function(e,player,state){"Video"===(state.NowPlayingItem||{}).MediaType&&player.isLocalPlayer&&!player.isExternalPlayer&&0<_usersettings.default.stillWatchingTimeMs()?(clearConfirmTimer(),confirmTimeout=new _methodtimer.default({onInterval:onConfirmTimeout,timeoutMs:IsDebug?3e3:3e4,type:"interval"})):clearConfirmTimer()}),_events.default.on(_playbackmanager.default,"playbackstop",clearConfirmTimer)});var isDialogOpen=!1;function confirmStillPlaying(){var minIdleTime,options;return isDialogOpen||(minIdleTime=IsDebug?1e4:_usersettings.default.stillWatchingTimeMs())<=0||_inputmanager.default.idleTime()<minIdleTime||Date.now()-_mouse.default.lastMouseInputTime()<minIdleTime?Promise.resolve():(isDialogOpen=!0,options={title:null,text:_globalize.default.translate("AreYouStillWatching"),confirmText:_globalize.default.translate("HeaderContinueWatching"),cancelText:_globalize.default.translate("Stop"),cancelResult:"cancel",timeout:6e4},Emby.importModule("./modules/common/dialogs/confirm.js").then(function(confirm){return confirm(options)}).then(function(){isDialogOpen=!1},function(result){isDialogOpen=!1,console.log("confirm still playing result: "+result),"cancel"!==result&&"_timeout"!==result||_playbackmanager.default.stop()}))}});