define(["loading","appRouter","layoutManager","appSettings","apphost","focusManager","connectionManager","backdrop","globalize","staticBackdrops","actionsheet","dom","material-icons","flexStyles","emby-scroller","emby-itemscontainer","cardStyle","emby-button"],function(loading,appRouter,layoutManager,appSettings,appHost,focusManager,connectionManager,backdrop,globalize,staticBackdrops,actionSheet,dom){"use strict";function renderSelectServerItems(view,servers){var items=servers.map(function(server){return{name:server.Name,showIcon:!0,icon:"",cardType:"",id:server.Id,server:server}}),html=items.map(function(item){var cardImageContainer;cardImageContainer=item.showIcon?''+item.icon+"":'
';var cardBoxCssClass="cardBox";layoutManager.tv&&(cardBoxCssClass+=" cardBox-focustransform");var tagName="button",innerOpening='"+globalize.translate("sharedcomponents#MessageNoServersAvailableToConnect")+"
"),itemsContainer.innerHTML=html,loading.hide()}function updatePageStyle(view,params){"1"==params.showuser?(view.classList.add("libraryPage"),view.classList.remove("standalonePage"),view.classList.add("noSecondaryNavPage")):(view.classList.add("standalonePage"),view.classList.remove("libraryPage"),view.classList.remove("noSecondaryNavPage"))}function showGeneralError(){loading.hide(),alertText(globalize.translate("sharedcomponents#DefaultErrorMessage"))}function alertText(text){alertTextWithOptions({text:text})}function alertTextWithOptions(options){require(["alert"],function(alert){alert(options)})}function showServerConnectionFailure(){alertText(globalize.translate("MessageUnableToConnectToServer"),globalize.translate("HeaderConnectionFailure"))}return function(view,params){function connectToServer(server){loading.show(),connectionManager.connectToServer(server,{enableAutoLogin:appSettings.enableAutoLogin()}).then(function(result){loading.hide();var apiClient=result.ApiClient;switch(result.State){case MediaBrowser.ConnectionState.SignedIn:Dashboard.onServerChanged(apiClient.getCurrentUserId(),apiClient.accessToken(),apiClient),Dashboard.navigate("home.html");break;case MediaBrowser.ConnectionState.ServerSignIn:Dashboard.onServerChanged(null,null,apiClient),Dashboard.navigate("login.html?serverid="+result.Servers[0].Id);break;case MediaBrowser.ConnectionState.ServerUpdateNeeded:alertTextWithOptions({text:globalize.translate("core#ServerUpdateNeeded","https://emby.media"),html:globalize.translate("core#ServerUpdateNeeded",'https://emby.media')});break;default:showServerConnectionFailure()}})}function deleteServer(server){loading.show(),connectionManager.deleteServer(server.Id).then(function(){loading.hide(),loadServers()},function(){loading.hide(),loadServers()})}function acceptInvitation(id){loading.show(),connectionManager.acceptServer(id).then(function(){loading.hide(),loadServers(),loadInvitations()},showGeneralError)}function rejectInvitation(id){loading.show(),connectionManager.rejectServer(id).then(function(){loading.hide(),loadServers(),loadInvitations()},showGeneralError)}function showPendingInviteMenu(elem){var card=dom.parentWithClass(elem,"inviteItem"),invitationId=card.getAttribute("data-id"),menuItems=[];menuItems.push({name:globalize.translate("sharedcomponents#Accept"),id:"accept"}),menuItems.push({name:globalize.translate("sharedcomponents#Reject"),id:"reject"}),require(["actionsheet"],function(actionsheet){actionsheet.show({items:menuItems,positionTo:elem,callback:function(id){switch(id){case"accept":acceptInvitation(invitationId);break;case"reject":rejectInvitation(invitationId)}}})})}function getPendingInviteHtml(item){var cardImageContainer='',cardBoxCssClass="cardBox";layoutManager.tv&&(cardBoxCssClass+=" cardBox-focustransform");var tagName="button",innerOpening='