define(["exports","./../modules/common/itemmanager/itemmanager.js","./../modules/common/itemmanager/baseitemcontroller.js","./../modules/common/globalize.js","./../modules/humanedate/humanedate.js","./../modules/emby-apiclient/connectionmanager.js","./../modules/approuter.js"],function(_exports,_itemmanager,_baseitemcontroller,_globalize,_humanedate,_connectionmanager,_approuter){function ScheduledTaskController(){_baseitemcontroller.default.apply(this,arguments)}function humane_elapsed(ticks){var ticks=ticks/1e4/1e3,numdays=Math.floor(ticks%31536e3/86400),numhours=Math.floor(ticks%31536e3%86400/3600),numminutes=Math.floor(ticks%31536e3%86400%3600/60),ticks=Math.round(ticks%31536e3%86400%3600%60),elapsedStr=(elapsedStr=(elapsedStr=(elapsedStr="")+(1===numdays?numdays+" day ":"")+(1("+_globalize.default.translate("Failed")+")":"Cancelled"===task.LastExecutionResult.Status?html+=" ("+_globalize.default.translate("Cancelled")+")":"Aborted"===task.LastExecutionResult.Status&&(html+=" "+_globalize.default.translate("LabelAbortedByServerShutdown")+"")):"Running"===task.State?html=(html=(html+='
')+'
')+''+secondDateStr+"%
":html+=""+_globalize.default.translate("LabelStopping")+"",html}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(ScheduledTaskController.prototype,_baseitemcontroller.default.prototype),ScheduledTaskController.prototype.getTypeNames=function(){return["ScheduledTask"]},ScheduledTaskController.prototype.getDisplayName=function(item,options){return item.Name},ScheduledTaskController.prototype.isSingleItemFetchRequired=function(typeName){return!1},ScheduledTaskController.prototype.getDefaultIcon=function(item){return"calendar_month"},ScheduledTaskController.prototype.canDelete=function(item,user){return!1},ScheduledTaskController.prototype.enableLibraryItemDeleteConfirmation=function(){return!1},ScheduledTaskController.prototype.canRefreshMetadata=function(item,user){return!1},ScheduledTaskController.prototype.getNameSortOption=function(itemType){return null},ScheduledTaskController.prototype.canAddToPlaylist=function(item){return!1},ScheduledTaskController.prototype.canAddToCollection=function(item,user){return!1},ScheduledTaskController.prototype.canConvert=function(item,user){return!1},ScheduledTaskController.prototype.canEdit=function(items,user){return!0},ScheduledTaskController.prototype.getEditCommand=function(items){return{name:_globalize.default.translate("Settings"),id:"edit",icon:"settings"}},ScheduledTaskController.prototype.editItems=function(items,options){items=items[0];return _approuter.default.showItem(items)},ScheduledTaskController.prototype.canRate=function(item){return!1},ScheduledTaskController.prototype.canMarkPlayed=function(item){return!1},ScheduledTaskController.prototype.canEditImages=function(item,user){return!1},ScheduledTaskController.prototype.canEditSubtitles=function(item,user){return!1},ScheduledTaskController.prototype.isDeletePrimaryCommand=function(itemType){return!1},ScheduledTaskController.prototype.getDeleteMessages=function(){return{}},ScheduledTaskController.prototype.deleteItemsInternal=function(options){return Promise.reject()},ScheduledTaskController.prototype.getCommands=function(options){var commands=_baseitemcontroller.default.prototype.getCommands.apply(this,arguments),items=options.items;return 1===items.length&&("Idle"===(items=items[0]).State?commands.push({name:_globalize.default.translate("Start"),id:"scheduledtask_start",icon:""}):"Running"===items.State&&commands.push({name:_globalize.default.translate("Stop"),id:"scheduledtask_stop",icon:""})),commands},ScheduledTaskController.prototype.executeCommand=function(command,items,options){var item=items[0];switch(command){case"scheduledtask_start":return _connectionmanager.default.getApiClient(item).startScheduledTask(item.Id);case"scheduledtask_stop":return _connectionmanager.default.getApiClient(item).stopScheduledTask(item.Id);default:return _baseitemcontroller.default.prototype.executeCommand.apply(this,arguments)}},ScheduledTaskController.prototype.resolveField=function(item,field){return"ScheduledTaskRunInfo"!==field?_baseitemcontroller.default.prototype.resolveField.apply(this,arguments):getTaskProgressHtml(item)},ScheduledTaskController.prototype.getDurationDisplay=humane_elapsed;var instance=new ScheduledTaskController;_itemmanager.default.registerItemController(instance),_exports.default=instance});