import { h } from "@stencil/core";
export class Segment {
    constructor() {
        this.selected = false;
    }
    handleSegmentClick() {
        if (this.selected)
            return;
        this.selected = true;
        this.segmentSelect.emit(this.segmentIndex);
    }
    handleSegmentKeyDown(event) {
        if (event.code === 'Enter' || event.code === 'Space') {
            if (this.selected)
                return;
            this.selected = true;
            this.segmentSelect.emit(this.segmentIndex);
        }
    }
    render() {
        return (h("div", { key: '7e3de00d0927c957e99a81faf334f096a1f3b4fc', class: `segment ${this.selected ? 'segment--selected' : ''}`, tabIndex: 0, onClick: () => { this.handleSegmentClick(); }, onKeyDown: (e) => { this.handleSegmentKeyDown(e); } }, h("ifx-icon", { key: '6d6d9d9d02bebbe45aa32250fe73ee4deac9876a', icon: this.icon }), " ", h("slot", { key: '2c860e35d492f81d846356e60bdcf04919cc6bc7' })));
    }
    static get is() { return "ifx-segment"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["segment.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["segment.css"]
        };
    }
    static get properties() {
        return {
            "icon": {
                "type": "string",
                "attribute": "icon",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "segmentIndex": {
                "type": "number",
                "attribute": "segment-index",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "selected": {
                "type": "boolean",
                "attribute": "selected",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "value": {
                "type": "string",
                "attribute": "value",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            }
        };
    }
    static get events() {
        return [{
                "method": "segmentSelect",
                "name": "segmentSelect",
                "bubbles": true,
                "cancelable": true,
                "composed": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                }
            }];
    }
}
//# sourceMappingURL=segment.js.map
