import { h } from "@stencil/core";
export class Segment {
    /** Fired when this segment is selected (emits the segment index). */
    segmentSelect;
    /** Icon to display inside the segment. */
    icon;
    /** Index of this segment within the segmented control. */
    segmentIndex;
    /** Whether this segment is currently selected. */
    selected = false;
    /** Value associated with this segment. */
    value;
    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: 'fca07da4ca6f793b33a64daf35ad221e3f57c2ac', class: `segment ${this.selected ? "segment--selected" : ""}`, tabIndex: 0, onClick: () => {
                this.handleSegmentClick();
            }, onKeyDown: (e) => {
                this.handleSegmentKeyDown(e);
            } }, h("ifx-icon", { key: '91aba534a87c417ab47c82ff30cbeed2c92b1058', icon: this.icon }), " ", h("slot", { key: '623ca7cf551445328ac2d5966737a66a5874567e' })));
    }
    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",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Icon to display inside the segment."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "icon"
            },
            "segmentIndex": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Index of this segment within the segmented control."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "segment-index"
            },
            "selected": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Whether this segment is currently selected."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "selected",
                "defaultValue": "false"
            },
            "value": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Value associated with this segment."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "value"
            }
        };
    }
    static get events() {
        return [{
                "method": "segmentSelect",
                "name": "segmentSelect",
                "bubbles": true,
                "cancelable": true,
                "composed": false,
                "docs": {
                    "tags": [],
                    "text": "Fired when this segment is selected (emits the segment index)."
                },
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                }
            }];
    }
}
