`}_handleInputKeyDown(e){"Enter"===e.key&&this._handleSave()}_handleSave(){let e,t=this._textfield.value||"";if(this._error=void 0,""===t&&(t=Jt),-1===t.indexOf("://"))return this._textfield.setCustomValidity("Please enter your full URL, including the protocol part (https://)."),void this._textfield.reportValidity();try{e=new URL(t)}catch(e){return this._textfield.setCustomValidity("Invalid URL"),void this._textfield.reportValidity()}const r=`${e.protocol}//${e.host}`;try{window.localStorage.setItem("hassUrl",r)}catch(e){return void(this._error="Failed to store your URL!")}((e,t,r,i)=>{i=i||{},r=null==r?{}:r;const o=new Event(t,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});o.detail=r,e.dispatchEvent(o)})(this,"value-changed",{value:r})}static get styles(){return l`
:host {
display: block;
}
div {
display: flex;
justify-content: space-between;
align-items: center;
}
.error {
color: #db4437;
font-weight: bold;
}
md-filled-text-field {
flex-grow: 1;
margin-right: 8px;
}
`}};e([Fe()],Qt.prototype,"value",void 0),e([je()],Qt.prototype,"_error",void 0),e([We("md-filled-text-field",!0)],Qt.prototype,"_textfield",void 0),Qt=e([Be("my-url-input")],Qt);class er extends ct{constructor(e){if(super(e),this.et=j,e.type!==lt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===j||null==e)return this.vt=void 0,this.et=e;if(e===F)return e;if("string"!=typeof e)throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.et)return this.vt;this.et=e;const t=[e];return t.raw=t,this.vt={_$litType$:this.constructor.resultType,strings:t,values:[]}}}er.directiveName="unsafeHTML",er.resultType=1;class tr extends er{}tr.directiveName="unsafeSVG",tr.resultType=2;const rr=dt(tr);let ir=class extends He{createRenderRoot(){return this}render(){return this.instanceUrl?$e`
Configure My Home Assistant by entering the URL of your Home
Assistant instance.
`}
${this._error?$e`
${this._error}
`:""}
Note: This URL is only stored in your browser.
`:$e`
`}_handleEdit(){this._updatingUrl=!0}_handleUrlChanged(e){const t=e.detail.value;t?(this._error=void 0,this._updatingUrl=!1,this._instanceUrl=t):this._error="You need to configure a URL to use My Home Assistant."}};e([je()],lr.prototype,"_updatingUrl",void 0),e([je()],lr.prototype,"_instanceUrl",void 0),e([je()],lr.prototype,"_error",void 0),e([We("my-url-input")],lr.prototype,"_urlInput",void 0),lr=e([Be("my-index")],lr)}();