import { Host, h } from "@stencil/core";
import { cls } from "../../utils/helpers";
export class XSelectOption {
    constructor() {
        this.value = undefined;
        this.selected = undefined;
        this.disabled = undefined;
    }
    /**
     * Element click event listener
     *
     * @returns
     */
    handleClick() {
        if (this.disabled) {
            return;
        }
        const parent = this.el.parentElement;
        if (parent.multiple) {
            this.selected = !this.selected;
        }
        else {
            if (this.selected && parent.unselectable) {
                this.selected = false;
            }
            else {
                parent.querySelectorAll('x-selector-tag').forEach(item => {
                    item.selected = false;
                });
                this.selected = true;
            }
        }
        parent.dispatchEvent(new CustomEvent('changed'));
    }
    /**
     * Element render
     */
    render() {
        return h(Host, { key: '00c216b0754f340a145b4ac0a0843286c2989f9d', class: cls({
                'selected': this.selected,
                'disabled': this.disabled,
            }) }, h("div", { key: '0705131f126979ab7ae35cec7e7ce6184c89b5e2', class: "wrapper" }, h("slot", { key: 'b58fd4abcb05451884bea5373f8b4ed200f76475' })));
    }
    static get is() { return "x-selector-tag"; }
    static get originalStyleUrls() {
        return {
            "$": ["./style.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["style.css"]
        };
    }
    static get properties() {
        return {
            "value": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element value"
                },
                "attribute": "value",
                "reflect": false
            },
            "selected": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element selected state"
                },
                "attribute": "selected",
                "reflect": false
            },
            "disabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Element disabled state"
                },
                "attribute": "disabled",
                "reflect": false
            }
        };
    }
    static get elementRef() { return "el"; }
    static get listeners() {
        return [{
                "name": "click",
                "method": "handleClick",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
