import { h } from "@stencil/core";
export class BceElementIcon {
    constructor() {
        this.handleClick = (event) => {
            const target = event.target;
            if (!target || !this.template)
                return;
            this.value = parseInt(target.parentElement.dataset.index, 10);
            this.el.dispatchEvent(new Event('input', { bubbles: true }));
        };
    }
    render() {
        if (!this.template)
            return;
        return [
            h("p", null, this.template.question),
            h("div", null, this.template.options.map((option, index) => (h("bce-button", { icon: option.text, "data-index": index, "data-checked": this.value === index, "icon-only": true, onClick: this.handleClick, style: { color: option.color } }))))
        ];
    }
    static get is() { return "bce-element-icon"; }
    static get originalStyleUrls() { return {
        "$": ["bce-element-icon.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["bce-element-icon.css"]
    }; }
    static get properties() { return {
        "template": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "Block.ElementIcon.Template",
                "resolved": "undefined | { readonly metadata: ElementMetadata; readonly question: string; readonly required: boolean; readonly options: IconElementOption[]; }",
                "references": {
                    "Block": {
                        "location": "import",
                        "path": "../../../models/block"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "value": {
            "type": "number",
            "mutable": true,
            "complexType": {
                "original": "number",
                "resolved": "number | undefined",
                "references": {}
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "value",
            "reflect": false
        }
    }; }
    static get elementRef() { return "el"; }
}
