`}_handleInputKeyDown(t){"Enter"===t.key&&this._handleSave()}_handleSave(){let t,e=this._textfield.value||"";if(this._error=void 0,""===e&&(e=Jr),-1===e.indexOf("://"))return this._textfield.setCustomValidity("Please enter your full URL, including the protocol part (https://)."),void this._textfield.reportValidity();try{t=new URL(e)}catch(t){return this._textfield.setCustomValidity("Invalid URL"),void this._textfield.reportValidity()}const r=`${t.protocol}//${t.host}`;try{window.localStorage.setItem("hassUrl",r)}catch(t){return void(this._error="Failed to store your URL!")}((t,e,r,i)=>{i=i||{},r=null==r?{}:r;const o=new Event(e,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});o.detail=r,t.dispatchEvent(o)})(this,"value-changed",{value:r})}static get styles(){return s`
: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;
}
`}};t([nt()],Xr.prototype,"value",void 0),t([lt()],Xr.prototype,"_error",void 0),t([ct("md-filled-text-field",!0)],Xr.prototype,"_textfield",void 0),Xr=t([ot("my-url-input")],Xr);const Qr=2;class ti{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}class ei extends ti{constructor(t){if(super(t),this.it=q,t.type!==Qr)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===q||null==t)return this._t=void 0,this.it=t;if(t===j)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}ei.directiveName="unsafeHTML",ei.resultType=1;class ri extends ei{}ri.directiveName="unsafeSVG",ri.resultType=2;const ii=(t=>(...e)=>({_$litDirective$:t,values:e}))(ri);let oi=class extends it{createRenderRoot(){return this}render(){return this.instanceUrl?V`
Configure My Home Assistant by entering the URL of your Home
Assistant instance.
`}
${this._error?V`
${this._error}
`:""}
Note: This URL is only stored in your browser.
`:V`
`}_handleEdit(){this._updatingUrl=!0}_handleUrlChanged(t){const e=t.detail.value;e?(this._error=void 0,this._updatingUrl=!1,this._instanceUrl=e):this._error="You need to configure a URL to use My Home Assistant."}};t([lt()],ni.prototype,"_updatingUrl",void 0),t([lt()],ni.prototype,"_instanceUrl",void 0),t([lt()],ni.prototype,"_error",void 0),t([ct("my-url-input")],ni.prototype,"_urlInput",void 0),ni=t([ot("my-index")],ni)}();