import { css, type CSSResultGroup, html, LitElement, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import { fireEvent } from "../../../../common/dom/fire_event"; import "../../../../components/ha-button"; import { createCloseHeading } from "../../../../components/ha-dialog"; import "../../../../components/ha-yaml-editor"; import type { HassDialog } from "../../../../dialogs/make-dialog-manager"; import { haStyle, haStyleDialog } from "../../../../resources/styles"; import type { HomeAssistant } from "../../../../types"; import type { PasteReplaceDialogParams } from "./show-dialog-paste-replace"; @customElement("ha-dialog-paste-replace") class DialogPasteReplace extends LitElement implements HassDialog { @property({ attribute: false }) public hass!: HomeAssistant; @state() private _opened = false; @state() private _params!: PasteReplaceDialogParams; public showDialog(params: PasteReplaceDialogParams): void { this._opened = true; this._params = params; } public closeDialog() { if (this._opened) { fireEvent(this, "dialog-closed", { dialog: this.localName }); } this._opened = false; return true; } public render() { if (!this._opened) { return nothing; } return html`

${this.hass.localize( `ui.panel.config.${this._params.domain}.editor.paste_confirm.text` )}

${this.hass.localize("ui.common.append")} ${this.hass.localize("ui.common.replace")}
`; } private _handleReplace() { this._params?.onReplace(); this.closeDialog(); } private _handleAppend() { this._params?.onAppend(); this.closeDialog(); } static get styles(): CSSResultGroup { return [ haStyle, haStyleDialog, css` h3 { margin: 0; font-size: inherit; font-weight: inherit; } div[slot="primaryAction"] { display: flex; gap: 8px; } `, ]; } } declare global { interface HTMLElementTagNameMap { "ha-dialog-paste-replace": DialogPasteReplace; } }