define(["exports","./../dialoghelper/dialoghelper.js","./../layoutmanager.js","./../common/globalize.js","./../loading/loading.js","./../common/servicelocator.js","./../emby-elements/emby-input/emby-input.js","./../emby-elements/emby-button/emby-button.js","./../emby-elements/emby-button/paper-icon-button-light.js","./../emby-elements/emby-scroller/emby-scroller.js"],function(_exports,_dialoghelper,_layoutmanager,_globalize,_loading,_servicelocator,_embyInput,_embyButton,_paperIconButtonLight,_embyScroller){var currentApiClient,currentDlg,currentInstance;function reloadPageWhenServerAvailable(retryCount){var apiClient=currentApiClient;apiClient&&apiClient.getJSON(apiClient.getUrl("System/Info")).then(function(info){info.IsShuttingDown?retryReload(retryCount):(currentInstance.restarted=!0,_dialoghelper.default.close(currentDlg))},function(){retryReload(retryCount)})}function retryReload(retryCount){setTimeout(function(){retryCount=retryCount||0,++retryCount<150&&reloadPageWhenServerAvailable(retryCount)},500)}function showDialog(instance,options,template){for(var dialogOptions={removeOnClose:!0,scrollY:!1},enableTvLayout=_layoutmanager.default.tv,dlg=(enableTvLayout&&(dialogOptions.size="fullscreen"),_dialoghelper.default.createDialog(dialogOptions)),configuredButtons=[],dialogOptions=(dlg.classList.add("formDialog"),dlg.innerHTML=_globalize.default.translateHtml(template,"sharedcomponents"),dlg.classList.add("align-items-center"),dlg.classList.add("justify-items-center"),dlg.querySelector(".formDialogContent")),html=(dialogOptions.style["flex-grow"]="initial",enableTvLayout?(dialogOptions.style["max-width"]="50%",dialogOptions.style["max-height"]="60%"):(dlg.style.maxWidth="25em",dlg.classList.add("dialog-fullscreen-lowres")),dlg.querySelector(".formDialogHeaderTitle").innerHTML=_globalize.default.translate("HeaderRestartingEmbyServer"),dlg.querySelector(".dialogContentInner").innerHTML=_globalize.default.translate("RestartPleaseWaitMessage"),""),i=0,length=configuredButtons.length;i<length;i++){var item=configuredButtons[i],buttonClass="btnOption raised formDialogFooterItem formDialogFooterItem-autosize";item.type&&(buttonClass+=" button-"+item.type),html+='<button is="emby-button" type="button" class="'+buttonClass+'" data-id="'+item.id+'">'+item.name+"</button>"}function onButtonClick(){_dialoghelper.default.close(dlg)}dlg.querySelector(".formDialogFooter").innerHTML=html;var buttons=dlg.querySelectorAll(".btnOption");for(i=0,length=buttons.length;i<length;i++)buttons[i].addEventListener("click",onButtonClick);template=_dialoghelper.default.open(dlg);return function(instance,apiClient,dlg){currentDlg=dlg,currentInstance=instance,(currentApiClient=apiClient).restartServer().then(function(){setTimeout(reloadPageWhenServerAvailable,250)})}(instance,options.apiClient,dlg),template.then(function(){instance.destroy(),_loading.default.hide(),instance.restarted&&(_servicelocator.appHost.supports("multiserver")?options.apiClient.ensureWebSocket():window.location.reload(!0))})}function ServerRestartDialog(options){this.options=options}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["material-icons","formDialogStyle","flexStyles"]),ServerRestartDialog.prototype.show=function(){var instance=this;return _loading.default.show(),new Promise(function(resolve,reject){require(["dialogTemplateHtml"],function(template){showDialog(instance,instance.options,template).then(resolve,reject)})})},ServerRestartDialog.prototype.destroy=function(){currentInstance=currentDlg=currentApiClient=null,this.options=null};_exports.default=ServerRestartDialog});