define(["exports","./../../modules/common/itemmanager/itemmanager.js","./../../modules/common/itemmanager/baseitemcontroller.js","./../../modules/emby-apiclient/connectionmanager.js","./../../modules/common/globalize.js"],function(_exports,_itemmanager,_baseitemcontroller,_connectionmanager,_globalize){function SyncJobItemController(){_baseitemcontroller.default.apply(this,arguments)}function getDeleteMessages(item){var title,text,confirmText=_globalize.default.translate("Remove");return"Convert"===item.SyncJobType?"Completed"!==item.Status&&"Synced"!==item.Status?(title=_globalize.default.translate("CancelConversion"),text="ConfirmCancelConversion",confirmText=_globalize.default.translate("CancelConversion")):(title=_globalize.default.translate("RemoveFromHistory"),text="ConfirmRemoveFromHistory"):(title=_globalize.default.translate("RemoveDownload"),text="ConfirmRemoveDownload"),{single:{text:text,title:title,confirmText:confirmText},plural:{text:text,title:title,confirmText:confirmText}}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(SyncJobItemController.prototype,_baseitemcontroller.default.prototype),SyncJobItemController.prototype.getTypeNames=function(){return["SyncJobItem"]},SyncJobItemController.prototype.getDisplayName=function(item,options){return item.ItemName},SyncJobItemController.prototype.isSingleItemFetchRequired=function(typeName){return!1},SyncJobItemController.prototype.getDefaultIcon=function(item){return"&#xe627;"},SyncJobItemController.prototype.canDelete=function(item,user){return!0},SyncJobItemController.prototype.enableLibraryItemDeleteConfirmation=function(){return!1},SyncJobItemController.prototype.canRate=function(item){return!1},SyncJobItemController.prototype.canMarkPlayed=function(item){return!1},SyncJobItemController.prototype.canAddToPlaylist=function(item){return!1},SyncJobItemController.prototype.canAddToCollection=function(item,user){return!1},SyncJobItemController.prototype.canConvert=function(item,user){return!1},SyncJobItemController.prototype.canEdit=function(items,user){return!1},SyncJobItemController.prototype.canEditImages=function(item,user){return!1},SyncJobItemController.prototype.canEditSubtitles=function(item,user){return!1},SyncJobItemController.prototype.isDeletePrimaryCommand=function(itemType){return!0},SyncJobItemController.prototype.getDeleteCommand=function(items){var item=items[0],itemType=item.Type,item=getDeleteMessages(item);return{name:(1<items.length?item.plural:item.single).title,id:"delete",icon:"remove_circle_outline",primaryCommand:this.isDeletePrimaryCommand(itemType)}},SyncJobItemController.prototype.getDeleteMessages=getDeleteMessages,SyncJobItemController.prototype.canRefreshMetadata=function(item,user){return!1},SyncJobItemController.prototype.deleteItemsInternal=function(options){for(var isLocalTarget,apiClient=_connectionmanager.default.getApiClient(options.items[0]),localTargetId=_connectionmanager.default.deviceId(),ids=[],i=0,length=options.items.length;i<length;i++){var item=options.items[i];ids.push(item.Id),item.TargetId===localTargetId&&(isLocalTarget=!0)}return apiClient.cancelSyncJobItems(ids).then(function(result){return isLocalTarget&&require(["localsync"],function(localSync){localSync.sync()}),Promise.resolve(result)})},SyncJobItemController.prototype.getNameSortOption=function(itemType){return null},SyncJobItemController.prototype.editItems=function(items,options){return Promise.reject()},SyncJobItemController.prototype.resolveField=function(item,field){if("SyncJobItemStatus"!==field)return _baseitemcontroller.default.prototype.resolveField.apply(this,arguments);var jobItem=item,status=jobItem.Status;switch(status){case"Completed":case"Synced":status="Convert"===jobItem.SyncJobType?_globalize.default.translate("Converted"):_globalize.default.translate("Downloaded");break;case"Failed":case"Cancelled":status=_globalize.default.translate(status);break;default:status=_globalize.default.translate("SyncJobItemStatus"+status)}var progress,html=status;return"Transferring"!==jobItem.Status&&"Converting"!==jobItem.Status||jobItem.Progress&&(html=(html+=" ")+(progress=0<(progress=jobItem.Progress||0)&&progress<100?progress.toFixed(1):progress)+"%"),html};var instance=new SyncJobItemController;_itemmanager.default.registerItemController(instance),_exports.default=instance});