import { h, Host, } from "@stencil/core";
/**
 * Small segmented toggle used for switching between Private and Business menu modes.
 *
 * Responsibilities:
 * - render two selectable links
 * - reflect current active mode
 * - emit the selected mode when changed
 *
 * This component is intentionally presentation-only.
 * The parent header decides what switching mode actually means.
 */
export class PnMarketwebHeaderToggle {
    constructor() {
        this.options = [];
        this.ariaLabel = 'Header mode';
        this.value = 0;
    }
    /** Emitted whenever the user selects a different mode. */
    toggleChange;
    onClick(event, option) {
        if (option.index !== this.value) {
            this.toggleChange.emit(option.index);
        }
        if (!option.href) {
            event.preventDefault();
        }
    }
    renderOption(option) {
        const isActive = option.index === this.value;
        return (h("a", { href: option.href ?? '#', class: {
                'marketweb-header-toggle-button': true,
                'marketweb-header-toggle-button--active': isActive,
            }, "aria-current": isActive ? 'page' : undefined, onClick: (event) => this.onClick(event, option) }, option.label));
    }
    render() {
        if (this.options.length === 0) {
            return h(Host, null);
        }
        return (h(Host, null, h("nav", { class: "marketweb-header-toggle", "aria-label": this.ariaLabel }, this.options.map(option => this.renderOption(option)))));
    }
    static get is() { return "pn-marketweb-header-toggle"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-marketweb-header-toggle.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-marketweb-header-toggle.css"]
        };
    }
    static get properties() {
        return {
            "options": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "HeaderMenuModeOption[]",
                    "resolved": "HeaderMenuModeOption[]",
                    "references": {
                        "HeaderMenuModeOption": {
                            "location": "import",
                            "path": "@/components/layout-components/pn-marketweb-header/types/pn-marketweb-header.types",
                            "id": "src/components/layout-components/pn-marketweb-header/types/pn-marketweb-header.types.ts::HeaderMenuModeOption"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "[]"
            },
            "ariaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Accessible label for the toggle group."
                },
                "attribute": "aria-label",
                "reflect": false,
                "defaultValue": "'Header mode'"
            },
            "value": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "HeaderMenuMode",
                    "resolved": "number",
                    "references": {
                        "HeaderMenuMode": {
                            "location": "import",
                            "path": "@/components/layout-components/pn-marketweb-header/types/pn-marketweb-header.types",
                            "id": "src/components/layout-components/pn-marketweb-header/types/pn-marketweb-header.types.ts::HeaderMenuMode"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Currently active mode."
                },
                "attribute": "value",
                "reflect": true,
                "defaultValue": "0"
            }
        };
    }
    static get events() {
        return [{
                "method": "toggleChange",
                "name": "toggleChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Emitted whenever the user selects a different mode."
                },
                "complexType": {
                    "original": "HeaderMenuMode",
                    "resolved": "number",
                    "references": {
                        "HeaderMenuMode": {
                            "location": "import",
                            "path": "@/components/layout-components/pn-marketweb-header/types/pn-marketweb-header.types",
                            "id": "src/components/layout-components/pn-marketweb-header/types/pn-marketweb-header.types.ts::HeaderMenuMode"
                        }
                    }
                }
            }];
    }
}
//# sourceMappingURL=pn-marketweb-header-toggle.js.map
