import { h, Host } from "@stencil/core";
import { BEM } from "../../utils/bem";
export class Navbar {
    constructor() {
        /**
         * It `true` the navbar has a white background. Always use the blue header.
         */
        this.light = false;
        /**
         * Defines the type of navbar. App is used for almost every web applications
         * like the portal app. For our sales funnel we recommend to use the simple navbar.
         * Meta and main are used for the website.
         */
        this.interface = 'app';
        /**
         * Sets the content content width with the regular container classes
         */
        this.container = '';
    }
    interfaceHandler() {
        this.updateProps(['bal-navbar-brand', 'bal-navbar-menu', 'bal-navbar-menu-start', 'bal-navbar-menu-end'], 'interface');
    }
    /**
     * Toggles the menu on request method can be used from outside to open or close the menu
     */
    async toggleMenu() {
        const brand = this.element.querySelector('bal-navbar-brand');
        if (brand) {
            await brand.toggle();
        }
    }
    componentWillLoad() {
        this.interfaceHandler();
    }
    updateProps(selectors, key) {
        const value = this[key];
        if (value !== undefined) {
            this.notifyComponents(selectors, input => (input[key] = value));
        }
    }
    notifyComponents(selectors, callback) {
        const components = this.element.querySelectorAll(selectors.join(', '));
        components.forEach(c => callback(c));
    }
    render() {
        const navbarEl = BEM.block('navbar');
        return (h(Host, { key: 'd21b6f612b2111ce0a70adb00e62fc7663d1b651', class: Object.assign(Object.assign(Object.assign({}, navbarEl.class()), navbarEl.modifier(`context-${this.interface}`).class()), navbarEl.modifier(`is-light`).class(this.light)) }, h("nav", { key: 'c04d357d30be897227259035bd86e2f5a7edc936', role: "navigation", "aria-label": "main navigation", class: Object.assign(Object.assign({}, navbarEl.element('nav').class()), { container: true, [`is-${this.container}`]: this.container !== '' }) }, h("slot", { key: '48fba6d236e2dfdbf7d0ae23d76b290f63692ba6' }))));
    }
    static get is() { return "bal-navbar"; }
    static get originalStyleUrls() {
        return {
            "$": ["bal-navbar.sass"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bal-navbar.css"]
        };
    }
    static get properties() {
        return {
            "light": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "It `true` the navbar has a white background. Always use the blue header."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "light",
                "defaultValue": "false"
            },
            "interface": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "BalProps.BalNavbarInterface",
                    "resolved": "\"app\" | \"simple\"",
                    "references": {
                        "BalProps": {
                            "location": "global",
                            "id": "global::BalProps"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Defines the type of navbar. App is used for almost every web applications\nlike the portal app. For our sales funnel we recommend to use the simple navbar.\nMeta and main are used for the website."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "interface",
                "defaultValue": "'app'"
            },
            "container": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'fluid' | 'detail-page' | 'compact' | 'blog-page' | 'wide' | ''",
                    "resolved": "\"\" | \"blog-page\" | \"compact\" | \"detail-page\" | \"fluid\" | \"wide\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Sets the content content width with the regular container classes"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "container",
                "defaultValue": "''"
            }
        };
    }
    static get methods() {
        return {
            "toggleMenu": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        },
                        "HTMLBalNavbarBrandElement": {
                            "location": "global",
                            "id": "global::HTMLBalNavbarBrandElement"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Toggles the menu on request method can be used from outside to open or close the menu",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "element"; }
    static get watchers() {
        return [{
                "propName": "interface",
                "methodName": "interfaceHandler"
            }];
    }
}
