import { h } from "@stencil/core";
export class EclTag {
    constructor() {
        this.theme = 'ec';
        this.styleClass = undefined;
        this.external = false;
        this.variant = 'display';
        this.toBeRemoved = false;
    }
    getClass() {
        return [
            `ecl-tag`,
            `ecl-tag--${this.variant}`,
            this.styleClass
        ].join(' ');
    }
    getTag(variant) {
        switch (variant) {
            case 'link':
                return 'a';
            case 'display':
                return 'span';
            case 'removable':
                return 'button';
            default:
        }
    }
    getExternal() {
        return (h("ecl-icon", { icon: "external", "style-class": `ecl-tag__icon ecl-tag__icon--external sc-ecl-tag-${this.theme}`, size: "2xs" }));
    }
    getRemovable() {
        return (h("span", { class: "ecl-tag__icon" }, h("ecl-icon", { icon: "close", "style-class": `ecl-tag__icon-close sc-ecl-tag-${this.theme}` }), h("ecl-icon", { icon: "close-filled", "style-class": `ecl-tag__icon-close-filled sc-ecl-tag-${this.theme}` })));
    }
    componentDidRender() {
        const closeButton = this.el.querySelector('.ecl-tag__icon');
        if (closeButton) {
            closeButton.addEventListener('click', () => {
                this.toBeRemoved = true;
            });
        }
    }
    render() {
        const Element = this.getTag(this.variant);
        return (h(Element, { class: this.getClass() }, h("slot", null), this.variant === 'link' && this.external ? this.getExternal() : '', this.variant === 'removable' ? this.getRemovable() : ''));
    }
    static get is() { return "ecl-tag"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-tag-ec.css"],
            "eu": ["./build/styles/ecl-tag-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-tag-ec.css"],
            "eu": ["build/styles/ecl-tag-eu.css"]
        };
    }
    static get properties() {
        return {
            "theme": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "theme",
                "reflect": false,
                "defaultValue": "'ec'"
            },
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "style-class",
                "reflect": false
            },
            "external": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "external",
                "reflect": false,
                "defaultValue": "false"
            },
            "variant": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "variant",
                "reflect": false,
                "defaultValue": "'display'"
            },
            "toBeRemoved": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "to-be-removed",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=ecl-tag.js.map
