define(["exports","./../modules/viewmanager/baseview.js","./../modules/loading/loading.js","./../modules/emby-elements/emby-input/emby-input.js","./../modules/emby-elements/emby-button/emby-button.js","./../modules/emby-elements/emby-scroller/emby-scroller.js","./../modules/emby-apiclient/connectionmanager.js","./../modules/approuter.js"],function(_exports,_baseview,_loading,_embyInput,_embyButton,_embyScroller,_connectionmanager,_approuter){function trimEnd(string,charToRemove){for(;string.charAt(string.length-1)===charToRemove;)string=string.substring(0,string.length-1);return string}function onPortChange(e){var value=(this.value||"").trim();"443"!==value&&"8920"!==value||((value=this.closest("form").querySelector(".txtServerHost")).value=value.value.replace(new RegExp("http:","gi"),"https:"))}function View(view,params){_baseview.default.apply(this,arguments),view.querySelector("form").addEventListener("submit",function(e){e.preventDefault();e=function(address,port){if(port){address=trimEnd(address,"/");try{var url=new URL(address);if(url.port)return address;url.port=port;var urlString=url.toString();if("string"==typeof urlString&&urlString&&!urlString.toLowerCase().includes("object url"))return trimEnd(urlString,"/")}catch(err){console.log("error parsing url: "+err)}address+=":"+port}return address}(this.querySelector(".txtServerHost").value,this.querySelector(".txtServerPort").value);return _loading.default.show(),_connectionmanager.default.connectToAddress(e,{}).then(function(result){_loading.default.hide(),_approuter.default.handleConnectionResult(result)}),!1}),view.querySelector(".txtServerPort").addEventListener("change",onPortChange),view.querySelector(".buttonCancel").addEventListener("click",function(e){_approuter.default.back()})}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,require(["material-icons"]),Object.assign(View.prototype,_baseview.default.prototype),View.prototype.onResume=function(options){_baseview.default.prototype.onResume.apply(this,arguments);var view=this.view;view.querySelector(".txtServerHost").value="",view.querySelector(".txtServerPort").value="8096"};_exports.default=View});