define(["connectionManager","focusManager","dialogHelper","apphost","globalize","browser","layoutManager","dom","appRouter","cardBuilder","css!./backmenu.css","paper-icon-button-light","material-icons","roundCardStyle","emby-itemscontainer","emby-scroller","flexStyles"],function(connectionManager,focusManager,dialogHelper,apphost,globalize,browser,layoutManager,dom,appRouter,cardBuilder){"use strict";function getListOptions(items){return{renderer:cardBuilder,options:{shape:"auto",centerText:!0,overlayText:!1,fields:["Name"],action:"custom",multiSelect:!1,contextMenu:!1,round:!0,cardClass:"backMenuCard"},virtualScrollLayout:"horizontal-grid"}}function onUpgraded(){var itemsContainer=this;itemsContainer.resume({refresh:!0}).then(function(){focusManager.autoFocus(itemsContainer)})}function onCardAction(e){var dlg=this.closest(".backMenu"),item=e.detail.item;dlg.dialogResult=item.Id,dialogHelper.close(dlg)}return function(options){0;var dlg=dialogHelper.createDialog({entryAnimation:"fadein",exitAnimation:"fadeout",removeOnClose:!0,size:"fullscreen"});dlg.classList.add("backMenu"),dlg.innerHTML='<div is="emby-scroller" class="flex flex-grow" data-mousewheel="true" data-centerfocus="true"><div is="emby-itemscontainer" class="backMenuContent itemsContainer scrollSlider padded-left padded-right flex align-items-center flex-direction-row"></div</div',document.body.appendChild(dlg);var itemsContainer=dlg.querySelector(".itemsContainer");return itemsContainer.fetchData=function(){var items=[];this.showHome&&items.push({Name:globalize.translate("Home"),Id:"home",Icon:"&#xE88A;"});var apiClient=connectionManager.currentApiClient();return apiClient&&(browser.operaTv||browser.web0s)&&"6da60dd6edfc4508bca2c434d4400816"===apiClient.serverId()||items.push({Name:globalize.translate("Settings"),Id:"settings",Icon:"&#xE8B8;"}),apphost.supports("multiserver")&&items.push({Name:globalize.translate("HeaderChangeServer"),Id:"selectserver",Icon:"&#xE63E;"}),items.push({Name:globalize.translate("HeaderSignOut"),Id:"logout",Icon:"&#xE879;"}),apphost.supports("exit")&&items.push({Name:globalize.translate("Exit"),Id:"exit",Icon:"&#xE879;"}),apphost.supports("sleep")&&items.push({Name:globalize.translate("Sleep"),Id:"sleep",Icon:"&#xE426;"}),apphost.supports("shutdown")&&items.push({Name:globalize.translate("Shutdown"),Id:"shutdown",Icon:"&#xE8AC;"}),apphost.supports("restart")&&items.push({Name:globalize.translate("Restart"),Id:"restart",Icon:"&#xE5D5;"}),Promise.resolve({Items:items,TotalRecordCount:items.length})}.bind(options),itemsContainer.getListOptions=getListOptions,itemsContainer.addEventListener("action-null",onCardAction),itemsContainer.resume?onUpgraded.call(itemsContainer):itemsContainer.addEventListener("upgraded",onUpgraded),dialogHelper.open(dlg).then(function(){switch(dlg.dialogResult){case"logout":appRouter.logout();break;case"home":appRouter.goHome();break;case"exit":apphost.exit();break;case"sleep":apphost.sleep();break;case"shutdown":apphost.shutdown();break;case"restart":apphost.restart();break;case"settings":appRouter.showSettings();break;case"selectserver":appRouter.showSelectServer()}})}});