${To.map((e=>{var t;return ur`${e.name}
`}))}
${Br(Object.entries((null===(e=this._redirect)||void 0===e?void 0:e.params)||[]),(([e,t])=>`${this._redirect.redirect}-${e}`),(([e,t])=>ur`
Eo(e.replace("_"," ").replace("url","URL")))(e)}
data-key="${e}"
@input=${this._paramChanged}
.type=${t.startsWith("url")?"url":"text"}
>`))}
${this.isValid?ur`
Your URL
A URL to share with others, for example, when chatting on
our Discord chat server.
Copy URL
Markdown
A beautiful linked badge in Markdown, for example, when
posting on our Community Forum.
${i}
Copy Markdown
HTML
A beautiful badge in HTML format, which can be used on,
for example, your website or blog.
${i}
Copy HTML
`:""}
`}firstUpdated(e){super.firstUpdated(e);const t={};for(const[e,i]of Object.entries(this._redirect.params||{})){if(!(e in So)||!So[e])continue;const r=Ao(i,So[e]),o=this.querySelector(`md-filled-text-field[data-key=${e}]`);o.value=So[e],r?o.updateComplete.then((()=>{o.setCustomValidity(r),o.reportValidity()})):t[e]=So[e]}this._paramsValues=t}get isValid(){return this._redirect&&(!this._redirect.params||!Object.entries(this._redirect.params).find((([e,t])=>!t.endsWith("?")&&!this._paramsValues[e])))}_itemSelected(e){const t=To.find((t=>t.redirect===e.target.value));t.redirect!==this._redirect.redirect&&(this._redirect=t,this._paramsValues={})}_paramChanged(e){const t=e.currentTarget.dataset.key;let i=e.target.value;const r=this._redirect.params[t];r.startsWith("url")&&(i=decodeURI(i));const o=Ao(r,i);o&&(e.currentTarget.setCustomValidity(o),e.currentTarget.reportValidity(),i=void 0),i?(e.currentTarget.setCustomValidity(""),e.currentTarget.reportValidity(),this._paramsValues=Object.assign(Object.assign({},this._paramsValues),{[t]:i})):(this._paramsValues=Object.assign({},this._paramsValues),delete this._paramsValues[t])}get _url(){return`https://my.home-assistant.io/redirect/${this._redirect.redirect}/${this._redirect.params?`?${(e=>{const t=new URLSearchParams;return Object.entries(e).forEach((([e,i])=>{t.append(e,i)})),t.toString()})(this._paramsValues)}`:""}`}_copyURL(e){this._copy(this._url,e.currentTarget)}_copyHTML(e){this._copy(this._createHTML(),e.currentTarget)}_copyMarkdown(e){this._copy(this._createMarkdown(),e.currentTarget)}async _copy(e,t){try{await qr(e),this._copySuccess(t)}catch(e){this._copyFailure(e)}}_copySuccess(e){const t=e.innerText;e.classList.add("success"),e.innerText="Copied!",setTimeout((()=>{e.classList.remove("success"),e.innerText=t}),1e3)}_copyFailure(e){alert(`Copying failed! Error: ${e.message}`)}get _altText(){return`Open your Home Assistant instance and ${this._redirect.description}.`}_createBadge(){return`/badges/${this._redirect.redirect}.svg`}_createHTML(){return`