import { faTimes } from "@fortawesome/free-solid-svg-icons";
import { h } from "@stencil/core";
import classNames from "classnames";
import { DataTestIdsEnum } from "../../../../../../../constants/dataTestIds.enum";
import { getIconHtmlFromIconDefinition } from "../../../../../../../utils/icons/getIconHtmlFromIconDefinition";
import { getIconHtmlFromIconName } from "../../../../../../../utils/icons/getIconHtmlFromIconName";
export class SimpleToast {
    handleDeleteToast() {
        this.deleteToast.emit();
    }
    renderIcon() {
        const { icon, iconClassName } = this.toast;
        let iconHtml = null;
        if (typeof icon === 'string') {
            iconHtml = getIconHtmlFromIconName(icon);
        }
        if (icon instanceof HTMLElement) {
            iconHtml = icon.outerHTML;
        }
        if (!iconHtml) {
            return null;
        }
        return (h("div", { class: {
                'content-icon': true,
                [iconClassName]: Boolean(iconClassName),
            }, innerHTML: iconHtml }));
    }
    render() {
        const { title, message, subtitle } = this.toast;
        return (h("div", { key: '59d77d492e9b57e6947a39cc6eb81de3135415c7', class: "content", "data-testid": DataTestIdsEnum.transactionToastContent, id: `toast-${this.toast.toastId}` }, h("div", { key: 'd71e0688b2f67550c31711fba471c9f1abf52503', class: "content-left" }, this.renderIcon(), h("div", { key: '5438f67b56e32fcc8b6bfd32f95b73599ad13e6d', class: "content-right" }, h("div", { key: '11cb843822786579ec06b86ebe3a595a72c3a3ce', class: "content-heading" }, title && (h("h5", { key: 'bbb0c735840701ab9f63c20d89d33f4eecc42054', class: "content-heading-title", "data-testid": DataTestIdsEnum.transactionToastTitle }, title)), h("button", { key: '5eed2f17bada143530e9e3e7791c659e35d35c26', onClick: this.handleDeleteToast.bind(this), type: "button", class: "icon-close", innerHTML: getIconHtmlFromIconDefinition(faTimes) })), subtitle && h("div", { key: 'e46c8c582c4423367b3260efe5b4a2425ef992be', class: "subtitle" }, subtitle), message && h("div", { key: '6d42232d31096f6c7ecd064a8b1a5483f9a3f658', class: classNames('content-message', { 'no-margin': !title && !subtitle }) }, message)))));
    }
    static get is() { return "mvx-simple-toast"; }
    static get originalStyleUrls() {
        return {
            "$": ["simple-toast.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["simple-toast.css"]
        };
    }
    static get properties() {
        return {
            "toast": {
                "type": "unknown",
                "attribute": "toast",
                "mutable": false,
                "complexType": {
                    "original": "ISimpleToast",
                    "resolved": "ISimpleToast",
                    "references": {
                        "ISimpleToast": {
                            "location": "import",
                            "path": "components/functional/toasts-list/components/transaction-toast/transaction-toast.type",
                            "id": "src/components/functional/toasts-list/components/transaction-toast/transaction-toast.type.ts::ISimpleToast"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            }
        };
    }
    static get events() {
        return [{
                "method": "deleteToast",
                "name": "deleteToast",
                "bubbles": false,
                "cancelable": true,
                "composed": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
}
//# sourceMappingURL=simple-toast.js.map
