'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 index_esm_min$1 = require('./index.esm.min-1101deb1.js');
const reduxStore_service = require('./redux-store.service-10b7725a.js');

const bpSdkOfflineQuoteCss = ".bp-sdk-quote__request{--bp-sdk-quote-request-color:var(--theme-color);color:var(--bp-sdk-quote-request-color)}.bp-sdk-quote__price{display:flex;flex-direction:row}";
const BpSdkOfflineQuoteStyle0 = bpSdkOfflineQuoteCss;

const BpSdkOfflineQuote = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.carrier = undefined;
        this.product = undefined;
        this.showLogo = true;
        this.showCustomLogo = false;
        this.customLogoBaseUrl = '';
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-offline-quote');
        customElements.whenDefined('bp-sdk-external-offline-quote').then(() => {
            this.useExternal = true;
        });
    }
    renderProduct(product) {
        if (product) {
            return (index.h("div", { class: "bp-sdk-quote__product bp-sdk-offline-quote__product" }, index.h("h2", { class: "bp-sdk-quote__product-name bp-sdk-offline-quote__product-name" }, product.name)));
        }
    }
    logoUrl() {
        var _a;
        switch (this.showCustomLogo) {
            case true:
                return `${this.customLogoBaseUrl}${this.carrier.name.toLowerCase()}.png`;
            case false:
            default:
                return (_a = this.carrier) === null || _a === void 0 ? void 0 : _a.logo_url;
        }
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-offline-quote", { carrier: this.carrier, product: this.product, customLogoBaseUrl: this.customLogoBaseUrl, showCustomLogo: this.showCustomLogo, showLogo: this.showLogo }));
    }
    renderInternal() {
        var _a, _b;
        return (index.h("div", { class: "bp-sdk-quote__container bp-sdk-offline-quote__container" }, index.h("div", { class: "bp-sdk-quote__header bp-sdk-offline-quote__header" }, index.h("div", { class: "bp-sdk-quote__carrier bp-sdk-offline-quote__carrier" }, index.h("h1", { class: "bp-sdk-quote__carrier-name bp-sdk-offline-quote__carrier-name" }, (_a = this.carrier) === null || _a === void 0 ? void 0 : _a.name), this.showLogo && (index.h("img", { class: "bp-sdk-quote__carrier-logo bp-sdk-offline-quote__carrier-logo", src: this.logoUrl(), alt: (_b = this.carrier) === null || _b === void 0 ? void 0 : _b.name })))), index.h("div", { class: "bp-sdk-quote__details bp-sdk-offline-quote__details" }, index.h("div", { class: "bp-sdk-quote__products bp-sdk-offline-quote__products" }, this.renderProduct(this.product)))));
    }
};
BpSdkOfflineQuote.style = BpSdkOfflineQuoteStyle0;

const bpSdkQuoteLoadCss = "";
const BpSdkQuoteLoadStyle0 = bpSdkQuoteLoadCss;

const BpSdkQuoteLoad = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-load');
        customElements.whenDefined('bp-sdk-external-quote-load').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-quote-load", null);
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-quote-load__container" }, index.h("bp-sdk-spinner", null)));
    }
};
BpSdkQuoteLoad.style = BpSdkQuoteLoadStyle0;

const bpSdkQuotePaymentCss = "";
const BpSdkQuotePaymentStyle0 = bpSdkQuotePaymentCss;

const BpSdkQuotePayment = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.quoteRequest = undefined;
        this.useExternal = false;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-payment');
        customElements.whenDefined('bp-sdk-external-quote-payment').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-quote-payment", { quoteRequest: this.quoteRequest });
    }
    renderInternal() {
        return index.h("div", { class: "bp-sdk-quote-payment__container" });
    }
};
BpSdkQuotePayment.style = BpSdkQuotePaymentStyle0;

const bpSdkQuoteRequestCss = ".bp-sdk-quote__request{--bp-sdk-quote-request-color:var(--theme-color);color:var(--bp-sdk-quote-request-color)}.bp-sdk-quote__price{display:flex;flex-direction:row}";
const BpSdkQuoteRequestStyle0 = bpSdkQuoteRequestCss;

const BpSdkQuoteRequest = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.bpAnalyticsTrack = index.createEvent(this, "bpAnalyticsTrack", 7);
        this.actions = undefined;
        this.attachments = undefined;
        this.bindable = undefined;
        this.permittedToBind = undefined;
        this.carrier = undefined;
        this.products = [];
        this.quoteInfo = undefined;
        this.showLogo = true;
        this.showCustomLogo = false;
        this.customLogoBaseUrl = '';
        this.quoteStatus = undefined;
        this.quoteId = '';
        this.appFormId = '';
        this.translatedMessages = undefined;
        this.handleAction = undefined;
        this.handleBind = undefined;
        this.handleDownload = undefined;
        this.isAnnual = undefined;
        this.calls_to_action = undefined;
        this.satisfiesApplicationFormProductRequest = false;
        this.requestStatus = undefined;
        this.supplierName = undefined;
        this.supplierLogoUrl = undefined;
        this.supplierLogoUrlFull = undefined;
        this.supplierCode = undefined;
        this.parentQuoteRequestId = undefined;
        this.useExternal = false;
        this.termLength = 'year';
        this.price = undefined;
        this.totalPremium = undefined;
    }
    onCarrierChange(carrier, oldCarrier) {
        var _a;
        if (this.useExternal) {
            return;
        }
        if ((carrier === null || carrier === void 0 ? void 0 : carrier.id) !== (oldCarrier === null || oldCarrier === void 0 ? void 0 : oldCarrier.id)) {
            this.bpAnalyticsTrack.emit({
                eventName: 'Display',
                eventPayload: {
                    label: `${carrier.name}_RateReturned`,
                    value: 0,
                },
            });
            if (this.bindable) {
                this.bpAnalyticsTrack.emit({
                    eventName: 'Display',
                    eventPayload: {
                        label: 'OnlineBuy',
                        value: 0,
                        dataValue: ((_a = this.quoteInfo) === null || _a === void 0 ? void 0 : _a.annual_price) || 0,
                    },
                });
            }
        }
    }
    onQuoteStatusChange(quoteStatus) {
        var _a, _b;
        if (this.useExternal) {
            return;
        }
        if (quoteStatus === null || quoteStatus === void 0 ? void 0 : quoteStatus.recommended) {
            this.bpAnalyticsTrack.emit({
                eventName: 'Display',
                eventPayload: {
                    label: `Recommended Rate`,
                    value: ((_a = this.quoteInfo) === null || _a === void 0 ? void 0 : _a.annual_price) || '0',
                    dataValue: this.price || 'unknown',
                },
            });
            this.bpAnalyticsTrack.emit({
                eventName: 'Display',
                eventPayload: {
                    label: `Recommended Carrier`,
                    value: ((_b = this.carrier) === null || _b === void 0 ? void 0 : _b.name) || 'unknown',
                },
            });
        }
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request');
        customElements.whenDefined('bp-sdk-external-quote-request').then(() => {
            this.useExternal = true;
        });
        this.onCarrierChange(this.carrier, undefined);
        this.onQuoteStatusChange(this.quoteStatus);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-quote-request", { actions: this.actions, appFormId: this.appFormId, attachments: this.attachments, bindable: this.bindable, carrier: this.carrier, customLogoBaseUrl: this.customLogoBaseUrl, handleAction: this.handleAction, handleBind: this.handleBind, handleDownload: this.handleDownload, isAnnual: this.isAnnual, parentQuoteRequestId: this.parentQuoteRequestId, permittedToBind: this.permittedToBind, products: this.products, quoteId: this.quoteId, quoteInfo: this.quoteInfo, quoteStatus: this.quoteStatus, requestStatus: this.requestStatus, satisfiesApplicationFormProductRequest: this.satisfiesApplicationFormProductRequest, showCustomLogo: this.showCustomLogo, showLogo: this.showLogo, supplierCode: this.supplierCode, supplierLogoUrl: this.supplierLogoUrl, supplierLogoUrlFull: this.supplierLogoUrlFull, supplierName: this.supplierName, translatedMessages: this.translatedMessages }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-online-quote__container bp-sdk-quote__container" }, index.h("bp-sdk-quote-request-status-list-container", { quoteStatus: this.quoteStatus }), index.h("bp-sdk-quote-request-header-container", { carrier: this.carrier, customLogoBaseUrl: this.customLogoBaseUrl, showCustomLogo: this.showCustomLogo, showLogo: this.showLogo, quoteId: this.quoteId }), index.h("div", { class: "bp-sdk-online-quote__details bp-sdk-quote__details" }, index.h("div", { class: "bp-sdk-online-quote__pricing bp-sdk-quote__pricing" }, index.h("bp-sdk-quote-request-premium-container", { quoteInfo: this.quoteInfo }), this.renderBindContainer()), index.h("bp-sdk-quote-request-product-list-container", { products: this.products }), index.h("bp-sdk-quote-request-taxes-and-fees-container", { quoteInfo: this.quoteInfo }), this.renderBindContainer(), this.renderAttachmentContainer(), this.renderActionContainer())));
    }
    renderActionContainer() {
        var _a;
        if (((_a = this.actions) === null || _a === void 0 ? void 0 : _a.length) > 0) {
            return (index.h("div", { class: "bp-sdk-quote-actions__container" }, this.actions.map((action) => (index.h("button", { type: "button", onClick: () => this.handleAction(action, { id: this.quoteId, application_form_id: this.appFormId }) }, action.name)))));
        }
    }
    renderAttachmentContainer() {
        var _a;
        if (((_a = this.attachments) === null || _a === void 0 ? void 0 : _a.length) > 0) {
            return (index.h("div", { class: "bp-sdk-quote-attachments__container" }, this.attachments.map((attachment) => (index.h("button", { type: "button", onClick: () => this.handleDownload(attachment.id, attachment.filename) }, "Download ", attachment.filename)))));
        }
    }
    renderBindContainer() {
        return (index.h("bp-sdk-quote-request-bind-container", { appFormId: this.appFormId, carrier: this.carrier, handleBind: this.handleBind, isBindable: this.bindable, isPermittedToBind: this.permittedToBind, quoteId: this.quoteId, quoteInfo: this.quoteInfo }));
    }
    static get watchers() { return {
        "carrier": ["onCarrierChange"],
        "quoteStatus": ["onQuoteStatusChange"]
    }; }
};
BpSdkQuoteRequest.style = BpSdkQuoteRequestStyle0;

const bpSdkSendToExchangeContainerCss = "";
const BpSdkSendToExchangeContainerStyle0 = bpSdkSendToExchangeContainerCss;

const BpSdkSendToExchangeContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            reduxStore_service.store.mapDispatchToProps(this, {
                createQuestionSet: index_esm_min.d8,
            });
            this.storeUnsubscribe = reduxStore_service.store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => ({
            config: index_esm_min.up(state),
            appFormId: index_esm_min.SL(state),
            isCurrentOwner: index_esm_min.MN(state),
            canSendToExchange: index_esm_min.VN(state, { permission: index_esm_min$1.T.SendToExchange }),
            hasSentToExchange: !!index_esm_min.gL(state, 'send_to_bold_penguin'),
        });
        this.sendToExchange = () => {
            this.createQuestionSet({
                config: this.config,
                appFormQuestionSet: {
                    application_form_id: this.appFormId,
                    question_set: {
                        code: 'send_to_bold_penguin',
                    },
                },
            });
        };
        this.isCurrentOwner = undefined;
        this.canSendToExchange = undefined;
        this.hasSentToExchange = undefined;
        this.config = undefined;
        this.appFormId = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-send-to-exchange-container');
        customElements.whenDefined('bp-sdk-external-send-to-exchange-container').then(() => {
            this.useExternal = true;
        });
        this.handleSubscriptions();
    }
    disconnectedCallback() {
        this.storeUnsubscribe && this.storeUnsubscribe();
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-send-to-exchange-container", { appFormId: this.appFormId, hasSentToExchange: this.hasSentToExchange, config: this.config, sendToExchangeHandler: this.sendToExchange, canSendToExchange: this.canSendToExchange, isCurrentOwner: this.isCurrentOwner }));
    }
    renderInternal() {
        return (this.canSendToExchange &&
            this.isCurrentOwner && (index.h("div", { class: "bp-sdk-quote__send-to-exchange" }, index.h("bp-sdk-send-to-exchange", { buttonDisabled: this.hasSentToExchange, sendToExchangeHandler: this.sendToExchange }))));
    }
    get el() { return index.getElement(this); }
};
BpSdkSendToExchangeContainer.style = BpSdkSendToExchangeContainerStyle0;

exports.bp_sdk_offline_quote = BpSdkOfflineQuote;
exports.bp_sdk_quote_load = BpSdkQuoteLoad;
exports.bp_sdk_quote_payment = BpSdkQuotePayment;
exports.bp_sdk_quote_request = BpSdkQuoteRequest;
exports.bp_sdk_send_to_exchange_container = BpSdkSendToExchangeContainer;
