define(["dialogHelper","connectionManager","loading","dom","layoutManager","focusManager","globalize","scrollHelper","imageLoader","require","cardStyle","formDialogStyle","emby-button","paper-icon-button-light","css!./imageeditor"],function(dialogHelper,connectionManager,loading,dom,layoutManager,focusManager,globalize,scrollHelper,imageLoader,require){"use strict";function getBaseRemoteOptions(){var options={};return options.itemId=currentItem.Id,options}function reload(page,item,focusContext){loading.show();var apiClient;item?(apiClient=connectionManager.getApiClient(item.ServerId),reloadItem(page,item,apiClient,focusContext)):(apiClient=connectionManager.getApiClient(currentItem.ServerId),apiClient.getItem(apiClient.getCurrentUserId(),currentItem.Id).then(function(item){reloadItem(page,item,apiClient,focusContext)}))}function addListeners(container,className,eventName,fn){container.addEventListener(eventName,function(e){var elem=dom.parentWithClass(e.target,className);elem&&fn.call(elem,e)})}function reloadItem(page,item,apiClient,focusContext){currentItem=item,apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function(providers){for(var btnBrowseAllImages=page.querySelectorAll(".btnBrowseAllImages"),i=0,length=btnBrowseAllImages.length;i',html+='
',html+='
',html+='
';var imageUrl=getImageUrl(currentItem,apiClient,image.ImageType,image.ImageIndex,{maxWidth:imageSize});return html+='
",html+="
",html+="
",html+='
',html+='

'+image.ImageType+"

",html+='
',html+=image.Width&&image.Height?image.Width+" X "+image.Height:" ",html+="
",enableFooterButtons&&(html+='
',"Backdrop"===image.ImageType||"Screenshot"===image.ImageType?(html+=index>0?'':'',html+=indexchevron_right':''):imageProviders.length&&(html+=''),html+='',html+="
"),html+="
",html+="",html+="",html+=""}function deleteImage(context,itemId,type,index,apiClient,enableConfirmation){var afterConfirm=function(){apiClient.deleteItemImage(itemId,type,index).then(function(){hasChanges=!0,reload(context)})};return enableConfirmation?void require(["confirm"],function(confirm){confirm({text:globalize.translate("sharedcomponents#ConfirmDeleteImage"),confirmText:globalize.translate("sharedcomponents#Delete"),primary:"cancel"}).then(afterConfirm)}):void afterConfirm()}function moveImage(context,apiClient,itemId,type,index,newIndex,focusContext){apiClient.updateItemImageIndex(itemId,type,index,newIndex).then(function(){hasChanges=!0,reload(context,null,focusContext)},function(){require(["alert"],function(alert){alert(globalize.translate("sharedcomponents#DefaultErrorMessage"))})})}function renderImages(page,item,apiClient,images,imageProviders,elem){var html="",imageSize=300,windowSize=dom.getWindowSize();windowSize.innerWidth>=1280&&(imageSize=Math.round(windowSize.innerWidth/4));for(var tagName=layoutManager.tv?"button":"div",enableFooterButtons=!layoutManager.tv,i=0,length=images.length;i0&&commands.push({name:globalize.translate("sharedcomponents#MoveLeft"),id:"moveleft"}),index