'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-ceff47a0.js');
const index_esm_min = require('./index.esm.min-f57d151c.js');
const reduxStore_service = require('./redux-store.service-10b7725a.js');

const bpSdkQuoteRequestLogoCss = "";
const BpSdkQuoteRequestLogoStyle0 = bpSdkQuoteRequestLogoCss;

const BpSdkQuoteRequestLogo = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.logoUrl = undefined;
        this.name = undefined;
        this.showLogo = undefined;
        this.useExternal = false;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-logo');
        customElements.whenDefined('bp-sdk-external-quote-request-logo').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-quote-request-logo", { logoUrl: this.logoUrl, name: this.name, showLogo: this.showLogo });
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-quote-request-logo__container" }, this.showLogo && index.h("img", { class: "bp-sdk-online-quote__carrier-logo bp-sdk-quote__carrier-logo", src: this.logoUrl, alt: this.name })));
    }
};
BpSdkQuoteRequestLogo.style = BpSdkQuoteRequestLogoStyle0;

const bpSdkQuoteRequestLogoContainerCss = "";
const BpSdkQuoteRequestLogoContainerStyle0 = bpSdkQuoteRequestLogoContainerCss;

const BpSdkQuoteRequestLogoContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.mapStateToProps = (state) => {
            return {
                shouldRenderSupplierLogo: index_esm_min.cN(state),
                quote: index_esm_min.UN(state, this.quoteId),
            };
        };
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            this.storeUnsubscribe = reduxStore_service.store.mapStateToProps(this, this.mapStateToProps);
        };
        this.carrier = undefined;
        this.customLogoBaseUrl = undefined;
        this.showLogo = undefined;
        this.showCustomLogo = undefined;
        this.quoteId = undefined;
        this.shouldRenderSupplierLogo = undefined;
        this.configOptions = undefined;
        this.quote = undefined;
        this.useExternal = false;
        this.name = undefined;
        this.logoUrl = undefined;
    }
    resetState() {
        this.quote = undefined;
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-logo-container');
        customElements.whenDefined('bp-sdk-external-quote-request-logo-container').then(() => {
            this.useExternal = true;
        });
        this.onCarrierChange(this.carrier);
        this.onCustomLogoBaseUrlChange(this.customLogoBaseUrl);
        this.onShowCustomLogoChange(this.showCustomLogo);
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    onCarrierChange(carrier) {
        this.name = carrier === null || carrier === void 0 ? void 0 : carrier.name;
        this.updateLogoUrl(carrier, this.customLogoBaseUrl, this.showCustomLogo);
    }
    onCustomLogoBaseUrlChange(customLogoBaseUrl) {
        this.updateLogoUrl(this.carrier, customLogoBaseUrl, this.showCustomLogo);
    }
    onShowCustomLogoChange(showCustomLogo) {
        this.updateLogoUrl(this.carrier, this.customLogoBaseUrl, showCustomLogo);
    }
    onShouldRenderSupplierLogoChange(shouldRenderSupplierLogo) {
        this.updateLogoUrl(this.carrier, this.customLogoBaseUrl, this.showCustomLogo, shouldRenderSupplierLogo);
    }
    updateLogoUrl(carrier, baseUrl, showCustomLogo, renderSupplierLogo = false) {
        var _a, _b, _c;
        if (showCustomLogo) {
            if (this.shouldRenderSupplierLogo && ((_a = this.quote) === null || _a === void 0 ? void 0 : _a.supplier_name)) {
                this.logoUrl = `${baseUrl}${this.quote.supplier_name.toLowerCase()}.png`;
            }
            else {
                this.logoUrl = `${baseUrl}${(_b = carrier === null || carrier === void 0 ? void 0 : carrier.name) === null || _b === void 0 ? void 0 : _b.toLowerCase()}.png`;
            }
        }
        else {
            if (this.shouldRenderSupplierLogo && ((_c = this.quote) === null || _c === void 0 ? void 0 : _c.supplier_logo_url)) {
                this.logoUrl = this.quote.supplier_logo_url;
            }
            else {
                this.logoUrl = carrier === null || carrier === void 0 ? void 0 : carrier.logo_url;
            }
        }
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-quote-request-logo-container", { carrier: this.carrier, customLogoBaseUrl: this.customLogoBaseUrl, showLogo: this.showLogo, showCustomLogo: this.showCustomLogo, shouldRenderSupplierLogo: this.shouldRenderSupplierLogo }));
    }
    renderInternal() {
        return index.h("bp-sdk-quote-request-logo", { logoUrl: this.logoUrl, name: this.name, showLogo: this.showLogo });
    }
    static get watchers() { return {
        "carrier": ["onCarrierChange"],
        "customLogoBaseUrl": ["onCustomLogoBaseUrlChange"],
        "showCustomLogo": ["onShowCustomLogoChange"],
        "shouldRenderSupplierLogo": ["onShouldRenderSupplierLogoChange"]
    }; }
};
BpSdkQuoteRequestLogoContainer.style = BpSdkQuoteRequestLogoContainerStyle0;

exports.bp_sdk_quote_request_logo = BpSdkQuoteRequestLogo;
exports.bp_sdk_quote_request_logo_container = BpSdkQuoteRequestLogoContainer;
