import { h } from "@stencil/core";
import getAssetPath from "../../utils/assetPath";
export class EclSiteHeader {
    constructor() {
        this.theme = 'ec';
        this.styleClass = undefined;
        this.eclScript = false;
        this.loginBlock = false;
        this.languageBlock = false;
        this.searchBlock = true;
        this.logoAlt = undefined;
        this.logoTitle = undefined;
        this.searchText = undefined;
        this.searchPlaceholder = undefined;
        this.language = undefined;
        this.langCode = undefined;
        this.loginText = undefined;
        this.loginLink = undefined;
        this.euLabel = undefined;
        this.nonEuLabel = undefined;
        this.closeLabel = undefined;
        this.languageTitle = undefined;
        this.languageId = undefined;
        this.languageAriaLabel = undefined;
        this.siteName = undefined;
    }
    getClass() {
        const styleClasses = [
            `ecl-site-header`,
            this.styleClass
        ];
        return styleClasses.join(' ');
    }
    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-search-form')) {
            this.el.querySelector('.ecl-search-form').setAttribute('data-ecl-search-form', '');
        }
        if (this.eclScript) {
            // Load the ECL vanilla js if not already present.
            const src = getAssetPath('./build/scripts/ecl-site-header-vanilla.js');
            if (document.querySelector(`script[src="${src}"]`)) {
                document.querySelector(`script[src="${src}"]`).remove();
            }
            const script = document.createElement('script');
            script.src = src;
            script.onload = () => {
                const siteHeader = new ECL.SiteHeader(this.el.firstElementChild);
                siteHeader.init();
            };
            document.body.appendChild(script);
        }
    }
    render() {
        const logoPath = this.theme === 'ec' ?
            getAssetPath(`./build/images/${this.theme}/logos/positive/logo-${this.theme}--${this.langCode}.svg`) :
            getAssetPath(`./build/images/${this.theme}/logos/standard-version/positive/logo-${this.theme}--${this.langCode}.svg`);
        return (h("header", { class: "ecl-site-header" }, h("div", { class: "ecl-site-header__header" }, h("div", { class: "ecl-site-header__container ecl-container" }, h("div", { class: "ecl-site-header__top", "data-ecl-site-header-top": true }, h("ecl-link", { variant: "standalone", styleClass: `ecl-site-header__logo-link sc-ecl-site-header-${this.theme}` }, this.theme === 'eu' ? (h("ecl-picture", { styleClass: `ecl-site-header__picture sc-ecl-picture-${this.theme}`, imageAlt: this.logoAlt, imgClass: `ecl-site-header__logo-image-mobile sc-ecl-site-header-${this.theme}`, image: getAssetPath(`./build/images/${this.theme}/logos/condensed-version/positive/logo-${this.theme}--${this.langCode}.svg`) }, h("slot", { name: "sources" }))) : (''), h("ecl-picture", { styleClass: `ecl-site-header__picture sc-ecl-picture-${this.theme}`, imageAlt: this.logoAlt, imgClass: `ecl-site-header__logo-image ecl-site-header__logo-image-desktop sc-ecl-site-header-${this.theme}`, image: logoPath }, h("slot", { name: "sources" }))), h("div", { class: "ecl-site-header__action" }, this.loginBlock ?
            h("div", { class: "ecl-site-header__login-container" }, h("a", { class: "ecl-button ecl-button--ghost ecl-site-header__login-toggle", href: this.loginLink }, h("ecl-icon", { "style-class": `ecl-site-header__icon sc-ecl-site-header-${this.theme}`, icon: "log-in", size: "s", theme: this.theme }), this.loginText)) : '', this.languageBlock ?
            h("div", { class: "ecl-site-header__language" }, h("a", { class: "ecl-button ecl-button--ghost ecl-site-header__language-selector", "data-ecl-language-selector": true, "aria-label": this.languageAriaLabel, "aria-controls": this.languageId }, h("span", { class: "ecl-site-header__language-icon" }, h("ecl-icon", { icon: "global", size: "s", "style-class": `ecl-site-header__icon sc-ecl-site-header-${this.theme}`, theme: 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("button", { class: "ecl-button ecl-button--ghost ecl-site-header__language-close", type: "submit", "data-ecl-language-list-close": true }, h("span", { class: "ecl-button__container" }, h("span", { class: "ecl-u-sr-only", "data-ecl-label": "true" }, this.closeLabel), h("ecl-icon", { slot: "icon-after", size: "s", "style-class": `ecl-button__icon ecl-button__icon--after sc-ecl-site-header-${this.theme}`, "data-ecl-icon": true, icon: "close-filled", theme: this.theme })))), h("div", { class: "ecl-site-header__language-content" }, 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--ghost 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: "s", theme: this.theme }), this.searchText), h("ecl-search-form", { "style-class": `ecl-site-header__search sc-ecl-site-header-${this.theme}`, theme: this.theme, width: "m", placeholder: this.searchPlaceholder, "button-label": this.searchText, "button-aria-label": this.searchText })) : h("slot", { name: "search" }))))), this.siteName ?
            h("div", { class: "ecl-site-header__banner" }, h("div", { class: "ecl-container" }, h("div", { class: "ecl-site-header__site-name" }, this.siteName))) : '', h("slot", { 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": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "theme",
                "reflect": false,
                "defaultValue": "'ec'"
            },
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "style-class",
                "reflect": false
            },
            "eclScript": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "ecl-script",
                "reflect": false,
                "defaultValue": "false"
            },
            "loginBlock": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "login-block",
                "reflect": false,
                "defaultValue": "false"
            },
            "languageBlock": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "language-block",
                "reflect": false,
                "defaultValue": "false"
            },
            "searchBlock": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "search-block",
                "reflect": false,
                "defaultValue": "true"
            },
            "logoAlt": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "logo-alt",
                "reflect": false
            },
            "logoTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "logo-title",
                "reflect": false
            },
            "searchText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "search-text",
                "reflect": false
            },
            "searchPlaceholder": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "search-placeholder",
                "reflect": false
            },
            "language": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "language",
                "reflect": false
            },
            "langCode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "lang-code",
                "reflect": false
            },
            "loginText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "login-text",
                "reflect": false
            },
            "loginLink": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "login-link",
                "reflect": false
            },
            "euLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "eu-label",
                "reflect": false
            },
            "nonEuLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "non-eu-label",
                "reflect": false
            },
            "closeLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "close-label",
                "reflect": false
            },
            "languageTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "language-title",
                "reflect": false
            },
            "languageId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "language-id",
                "reflect": false
            },
            "languageAriaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "language-aria-label",
                "reflect": false
            },
            "siteName": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "site-name",
                "reflect": false
            }
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=ecl-site-header.js.map
