import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';

const getLoginUrl = (useMarketwebLogin, environment) => {
    const environment_Production = "PRODUCTION";
    const devAuthUrl = 'https://atportal.postnord.com/api/unified-login/backend/authorization?redirectionUrl=';
    const prodAuthUrl = 'https://portal.postnord.com/api/unified-login/backend/authorization?redirectionUrl=';
    const marketwebLoginUrl = '/login?returnUrl=';
    if (useMarketwebLogin) {
        return marketwebLoginUrl;
    }
    else if (environment.toUpperCase() !== environment_Production) {
        return devAuthUrl;
    }
    else {
        return prodAuthUrl;
    }
};

const pnMarketwebSiteheaderLoginButtonCss = "";
const PnMarketwebSiteheaderLoginButtonStyle0 = pnMarketwebSiteheaderLoginButtonCss;

const PnMarketwebSiteheaderLoginButton = /*@__PURE__*/ proxyCustomElement(class PnMarketwebSiteheaderLoginButton extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.label = 'Log in';
        this.useMarketwebLogin = false;
        this.environment = 'local';
    }
    get hostElement() { return this; }
    loginUrl;
    componentWillLoad() {
        this.loginUrl = getLoginUrl(this.useMarketwebLogin, this.environment);
    }
    nagivateToLoginUrl() {
        const navigationUrl = `${this.loginUrl}${encodeURIComponent(window.location.href)}`;
        return navigationUrl;
    }
    render() {
        return (h(Host, { key: 'be5764812e9610f5799856b27aa4517469d9a24f' }, h("pn-button", { key: '4a6b17d0e79ddedd0d06094aac2a44c6f9fda666', href: this.nagivateToLoginUrl() }, this.label)));
    }
    static get style() { return PnMarketwebSiteheaderLoginButtonStyle0; }
}, [0, "pn-marketweb-siteheader-login-button", {
        "label": [1],
        "useMarketwebLogin": [4, "use-marketweb-login"],
        "environment": [1]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["pn-marketweb-siteheader-login-button"];
    components.forEach(tagName => { switch (tagName) {
        case "pn-marketweb-siteheader-login-button":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, PnMarketwebSiteheaderLoginButton);
            }
            break;
    } });
}

export { PnMarketwebSiteheaderLoginButton as P, defineCustomElement as d };

//# sourceMappingURL=pn-marketweb-siteheader-login-button2.js.map