import { h } from "@stencil/core";
import SiteHeader from "@ecl/site-header";
import getAssetPath from "../../utils/assetPath";
export class EclSiteHeader {
    constructor() {
        this.noScript = false;
        this.loginBlock = false;
        this.languageBlock = false;
        this.searchBlock = true;
        this.logoSize = 'l';
        this.searchFormId = `ecl-site-header-search-form-${Math.random().toString(36).slice(2, 10)}`;
        this.logged = false;
        this.siteNameMobileOnly = false;
    }
    getClass() {
        const styleClasses = [
            `ecl-site-header`,
            `ecl-site-header-with-logo-${this.logoSize}`,
            this.styleClass
        ];
        return styleClasses.join(' ');
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidLoad() {
        if (this.el.querySelector('.ecl-site-header__logo-link')) {
            const logo = this.el.querySelector('.ecl-site-header__logo-link');
            const headerTop = logo.parentElement.parentElement;
            headerTop.insertBefore(logo, headerTop.firstElementChild);
            //logo.parentElement.remove();
        }
        if (this.el.querySelector('.ecl-menu')) {
            this.el.querySelector('.ecl-menu').classList.add(`sc-ecl-site-header-${this.theme}`);
            this.el.firstElementChild.classList.add('ecl-site-header--has-menu');
            const open = this.el.querySelector('.ecl-menu__open');
            open.classList.add(`sc-ecl-site-header-${this.theme}`);
            const close = this.el.querySelector('.ecl-menu__close');
            close.classList.add(`sc-ecl-site-header-${this.theme}`);
            const inner = this.el.querySelector('.ecl-menu__inner-header');
            inner.classList.add(`sc-ecl-site-header-${this.theme}`);
        }
        if (this.el.querySelector('.ecl-mega-menu')) {
            this.el.querySelector('.ecl-mega-menu').classList.add(`sc-ecl-site-header-${this.theme}`);
            this.el.firstElementChild.classList.add('ecl-site-header--has-mega-menu');
            const open = this.el.querySelector('.ecl-mega-menu__open');
            if (open) {
                open.classList.add(`sc-ecl-site-header-${this.theme}`);
            }
        }
        if (!this.noScript) {
            ;
            window.ECL = window.ECL || {};
            ECL.SiteHeader = SiteHeader;
            const siteHeader = new SiteHeader(this.el.firstElementChild);
            siteHeader.init();
        }
    }
    render() {
        const logoPath = this.logo
            ? this.logo
            : this.theme === 'ec'
                ? getAssetPath(`./build/images/${this.theme}/logos/logo-${this.theme}--mute.svg`)
                : getAssetPath(`./build/images/${this.theme}/logos/condensed-version/positive/logo-${this.theme}--${this.langCode}.svg`);
        return (h("header", { key: 'ff5c8f347778a573fa3653610c1c673093155218', class: this.getClass() }, h("div", { key: 'f11f7d193cd60aad8bf3af2c4e3f175e257d708b', class: "ecl-site-header__inner" }, h("div", { key: 'c51e192e21173ac62fb52566aa94f24b9054832a', class: "ecl-site-header__header" }, h("div", { key: '70ea09ca8dc0b219c6aab6bbeece729f6298b181', class: "ecl-site-header__container ecl-container" }, h("div", { key: '1fa5236637d55cda7f1bc471b4f4cb97df67dbb1', class: "ecl-site-header__top", "data-ecl-site-header-top": true }, h("ecl-link", { key: '1246dba88762b8d30e8666e4568464495a690d02', variant: "standalone", styleClass: `ecl-site-header__logo-link sc-ecl-site-header-${this.theme}` }, h("ecl-picture", { key: 'd3bc02eebed9adb0715d5dbe766a92a7e2b1274d', styleClass: `ecl-site-header__picture sc-ecl-picture-${this.theme}`, imageAlt: this.logoAlt, imgClass: `ecl-site-header__logo-image ecl-site-header__logo-image--${this.logoSize} sc-ecl-site-header-${this.theme}`, image: logoPath }, !this.logo && (this.theme === 'eu' ? (h("source", { srcSet: getAssetPath(`./build/images/${this.theme}/logos/standard-version/positive/logo-${this.theme}--${this.langCode}.svg`), media: "(min-width: 996px)" })) : this.theme === 'ec' ? (h("source", { srcSet: getAssetPath(`./build/images/${this.theme}/logos/positive/logo-${this.theme}--${this.langCode}.svg`), media: "(min-width: 415px)" })) : null), h("slot", { key: 'f3b94954db08576f4b207fe194e0c335d2d80c52', name: "logoSources" }))), h("div", { key: '496cee137b3ebb5ec14a609506b6de2a47813781', class: "ecl-site-header__action" }, h("div", { key: '7fa6fcaec25561fdbf86e2254a3e80cf6f8e72f1', class: "ecl-site-header__login-container" }, this.loginBlock &&
            h("a", { key: 'e726b5beb0834fe0215399ae4c981ca6438a06c3', class: `ecl-button ecl-button--tertiary ecl-button--neutral ecl-site-header__login-toggle sc-ecl-site-header-${this.theme}`, "data-ecl-login-toggle": true, "aria-expanded": "false", href: this.loginLink }, h("ecl-icon", { key: '3c694c6009774d43559711515d10e805dc84590b', icon: this.logged ? 'logged-in' : 'log-in', size: "m", "as-image": true, slot: "icon-before", "style-class": `ecl-site-header__icon sc-ecl-site-header-${this.theme}` }), this.logged ? this.loggedInText : this.loginText), (this.loginBlock && this.logged) &&
            h("div", { key: 'c29b82981ee6a1183290eb994fac740ee8043bbc', class: "ecl-site-header__login-box", "data-ecl-login-box": true }, h("p", { key: '32570a2ae6b4b94fa87714714bc757f671c2dbae', class: "ecl-site-header__login-description" }, h("slot", { key: '0e4b6d6dc13140be8767332e872363672f7b14f1', name: "ecl-site-header-login-description" })), h("hr", { key: '53a59ce8add7531c4e39bc53cc104e6d74196fa8', class: "ecl-site-header__login-separator" }), h("ecl-link", { key: 'b597fd6529000f2adb7753441edf9c97405f069e', variant: "standalone", path: this.logoutLink }, this.logoutText))), this.languageBlock ?
            h("div", { class: "ecl-site-header__language" }, h("a", { class: "ecl-button ecl-button--tertiary ecl-button--neutral ecl-site-header__language-selector", "data-ecl-language-selector": true, "aria-label": this.languageAriaLabel, "aria-controls": this.languageId, role: "button" }, h("span", { class: "ecl-site-header__language-icon" }, h("ecl-icon", { icon: "global", size: "m", "style-class": `ecl-site-header__icon sc-ecl-site-header-${this.theme}` }), this.language)), h("div", { class: "ecl-site-header__language-container", id: this.languageId, "data-ecl-language-list-overlay": true, "aria-labelledby": "ecl-site-header__language-title", role: "dialog", "aria-modal": "true", hidden: true }, h("div", { class: "ecl-site-header__language-header" }, h("div", { class: "ecl-site-header__language-title", id: "ecl-site-header__language-title" }, this.languageTitle), h("ecl-button", { "style-class": `ecl-site-header__language-close sc-ecl-site-header-${this.theme}`, type: "submit", "hide-label": true, buttonStyle: "neutral", variant: "tertiary", "data-ecl-language-list-close": true }, this.closeLabel, h("ecl-icon", { slot: "icon-after", size: "m", "style-class": `sc-ecl-site-header-${this.theme}`, "data-ecl-icon": true, icon: "close" }))), h("div", { class: "ecl-site-header__language-content", "data-ecl-language-list-content": true }, h("div", { class: "ecl-site-header__language-category", "data-ecl-language-list-eu": true }, h("div", { class: "ecl-site-header__language-category-title" }, this.euLabel), h("ul", { class: "ecl-site-header__language-list" }, h("slot", { name: "eu-category" }))), this.nonEuLabel ?
                h("div", { class: "ecl-site-header__language-category", "data-ecl-language-list-non-eu": true }, h("div", { class: "ecl-site-header__language-category-title" }, this.nonEuLabel), h("ul", { class: "ecl-site-header__language-list" }, h("slot", { name: "non-eu-category" }))) : ''))) : '', this.searchBlock ?
            h("div", { class: "ecl-site-header__search-container", role: "search" }, h("a", { class: "ecl-button ecl-button--tertiary ecl-button--neutral ecl-site-header__search-toggle", "data-ecl-search-toggle": true, "aria-controls": "search-form-id", "aria-expanded": "false" }, h("ecl-icon", { icon: "search", "style-class": `ecl-icon ecl-icon--s ecl-site-header__icon sc-ecl-site-header-${this.theme}`, size: "m" }), this.searchText), h("ecl-search-form", { "style-class": `ecl-site-header__search sc-ecl-site-header-${this.theme}`, theme: this.theme, "input-id": this.searchFormId, placeholder: this.searchPlaceholder, "button-label": this.searchText, "button-aria-label": this.searchText, "button-class": `ecl-button--neutral sc-ecl-site-header-${this.theme}` })) : h("slot", { name: "search" }))))), this.bannerTop &&
            h("div", { key: 'a865f8e5d9dbeedc413b60f0317466ff9041c04a', class: "ecl-container" }, h("div", { key: 'c59ef146b46ff15227a2f52ea3ff662a3c50f33e', class: "ecl-site-header__banner-top" }, h("ecl-link", { key: 'e006e9259b95588bc33cf23715aefbd23757509b', variant: "standalone", path: this.bannerTopLink }, this.bannerTop))), this.siteName ?
            h("div", { class: `ecl-site-header__banner ${this.siteNameMobileOnly ? 'ecl-site-header__site-name--mobile-only' : ''}` }, h("div", { class: "ecl-container" }, h("div", { class: "ecl-site-header__site-name" }, this.siteName))) : ''), h("slot", { key: '9094b609c71af429bb413ee3101f6a7f61ec4361', name: "menu" })));
    }
    static get is() { return "ecl-site-header"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-site-header-ec.css"],
            "eu": ["./build/styles/ecl-site-header-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-site-header-ec.css"],
            "eu": ["build/styles/ecl-site-header-eu.css"]
        };
    }
    static get assetsDirs() { return ["build"]; }
    static get properties() {
        return {
            "theme": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "theme"
            },
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "style-class"
            },
            "noScript": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "no-script",
                "defaultValue": "false"
            },
            "loginBlock": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "login-block",
                "defaultValue": "false"
            },
            "languageBlock": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "language-block",
                "defaultValue": "false"
            },
            "searchBlock": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "search-block",
                "defaultValue": "true"
            },
            "logo": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logo"
            },
            "logoAlt": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logo-alt"
            },
            "logoTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logo-title"
            },
            "logoSize": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logo-size",
                "defaultValue": "'l'"
            },
            "searchText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "search-text"
            },
            "searchFormId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "search-form-id",
                "defaultValue": "`ecl-site-header-search-form-${Math.random().toString(36).slice(2, 10)}`"
            },
            "searchPlaceholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "search-placeholder"
            },
            "language": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "language"
            },
            "langCode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "lang-code"
            },
            "loginText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "login-text"
            },
            "loggedInText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logged-in-text"
            },
            "loginLink": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "login-link"
            },
            "logged": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logged",
                "defaultValue": "false"
            },
            "logoutLink": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logout-link"
            },
            "logoutText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "logout-text"
            },
            "euLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "eu-label"
            },
            "nonEuLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "non-eu-label"
            },
            "closeLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "close-label"
            },
            "languageTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "language-title"
            },
            "languageId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "language-id"
            },
            "languageAriaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "language-aria-label"
            },
            "siteName": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "site-name"
            },
            "bannerTop": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "banner-top"
            },
            "bannerTopLink": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "banner-top-link"
            },
            "siteNameMobileOnly": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "site-name-mobile-only",
                "defaultValue": "false"
            }
        };
    }
    static get elementRef() { return "el"; }
}
