`}_handleInputKeyDown(t){"Enter"===t.key&&this._handleSave()}_handleSave(){let t,e=this._textfield.value||"";if(this._error=void 0,""===e&&(e=gr),-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([qt()],br.prototype,"value",void 0),t([Ft()],br.prototype,"_error",void 0),t([Wt("md-filled-text-field",!0)],br.prototype,"_textfield",void 0),br=t([Bt("my-url-input")],br);class yr extends ce{constructor(t){if(super(t),this.et=F,t.type!==se)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===F||null==t)return this.vt=void 0,this.et=t;if(t===q)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.et)return this.vt;this.et=t;const e=[t];return e.raw=e,this.vt={_$litType$:this.constructor.resultType,strings:e,values:[]}}}yr.directiveName="unsafeHTML",yr.resultType=1;class xr extends yr{}xr.directiveName="unsafeSVG",xr.resultType=2;const _r=de(xr);let $r=class extends Ht{createRenderRoot(){return this}render(){return this.instanceUrl?$t`
Configure My Home Assistant by entering the URL of your Home
Assistant instance.
`}
${this._error?$t`
${this._error}
`:""}
Note: This URL is only stored in your browser.
`:$t`
`}_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([Ft()],Cr.prototype,"_updatingUrl",void 0),t([Ft()],Cr.prototype,"_instanceUrl",void 0),t([Ft()],Cr.prototype,"_error",void 0),t([Wt("my-url-input")],Cr.prototype,"_urlInput",void 0),Cr=t([Bt("my-index")],Cr)}();