import { r as registerInstance, h, c as createEvent, g as getElement } from './index-77a9c9e7.js';
import { a0 as d8, u as up, h as SL, i as MN, V as VN, a1 as gL } from './index.esm.min-db2d29e8.js';
import { T } from './index.esm.min-9889e78b.js';
import { s as store } from './redux-store.service-dc54f48e.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) {
        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 (h("div", { class: "bp-sdk-quote__product bp-sdk-offline-quote__product" }, 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 (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 (h("div", { class: "bp-sdk-quote__container bp-sdk-offline-quote__container" }, h("div", { class: "bp-sdk-quote__header bp-sdk-offline-quote__header" }, h("div", { class: "bp-sdk-quote__carrier bp-sdk-offline-quote__carrier" }, 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 && (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 })))), h("div", { class: "bp-sdk-quote__details bp-sdk-offline-quote__details" }, 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) {
        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 h("bp-sdk-external-quote-load", null);
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-quote-load__container" }, h("bp-sdk-spinner", null)));
    }
};
BpSdkQuoteLoad.style = BpSdkQuoteLoadStyle0;

const bpSdkQuotePaymentCss = "";
const BpSdkQuotePaymentStyle0 = bpSdkQuotePaymentCss;

const BpSdkQuotePayment = class {
    constructor(hostRef) {
        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 h("bp-sdk-external-quote-payment", { quoteRequest: this.quoteRequest });
    }
    renderInternal() {
        return 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) {
        registerInstance(this, hostRef);
        this.bpAnalyticsTrack = 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 (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 (h("div", { class: "bp-sdk-online-quote__container bp-sdk-quote__container" }, h("bp-sdk-quote-request-status-list-container", { quoteStatus: this.quoteStatus }), h("bp-sdk-quote-request-header-container", { carrier: this.carrier, customLogoBaseUrl: this.customLogoBaseUrl, showCustomLogo: this.showCustomLogo, showLogo: this.showLogo, quoteId: this.quoteId }), h("div", { class: "bp-sdk-online-quote__details bp-sdk-quote__details" }, h("div", { class: "bp-sdk-online-quote__pricing bp-sdk-quote__pricing" }, h("bp-sdk-quote-request-premium-container", { quoteInfo: this.quoteInfo }), this.renderBindContainer()), h("bp-sdk-quote-request-product-list-container", { products: this.products }), 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 (h("div", { class: "bp-sdk-quote-actions__container" }, this.actions.map((action) => (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 (h("div", { class: "bp-sdk-quote-attachments__container" }, this.attachments.map((attachment) => (h("button", { type: "button", onClick: () => this.handleDownload(attachment.id, attachment.filename) }, "Download ", attachment.filename)))));
        }
    }
    renderBindContainer() {
        return (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) {
        registerInstance(this, hostRef);
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            store.mapDispatchToProps(this, {
                createQuestionSet: d8,
            });
            this.storeUnsubscribe = store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => ({
            config: up(state),
            appFormId: SL(state),
            isCurrentOwner: MN(state),
            canSendToExchange: VN(state, { permission: T.SendToExchange }),
            hasSentToExchange: !!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 (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 && (h("div", { class: "bp-sdk-quote__send-to-exchange" }, h("bp-sdk-send-to-exchange", { buttonDisabled: this.hasSentToExchange, sendToExchangeHandler: this.sendToExchange }))));
    }
    get el() { return getElement(this); }
};
BpSdkSendToExchangeContainer.style = BpSdkSendToExchangeContainerStyle0;

export { BpSdkOfflineQuote as bp_sdk_offline_quote, BpSdkQuoteLoad as bp_sdk_quote_load, BpSdkQuotePayment as bp_sdk_quote_payment, BpSdkQuoteRequest as bp_sdk_quote_request, BpSdkSendToExchangeContainer as bp_sdk_send_to_exchange_container };
