import { h } from "@stencil/core";
import { currencyStringUSD } from "@boldpenguin/sdk-utility";
export class BpSdkQuoteRequestPremiumMonthly {
    constructor() {
        this.annualPrice = undefined;
        this.downpayment = undefined;
        this.installments = undefined;
        this.monthlyPrice = undefined;
        this.useExternal = false;
        this._annualPrice = undefined;
        this._downpayment = undefined;
        this._monthlyPrice = undefined;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-premium-monthly');
        customElements.whenDefined('bp-sdk-external-quote-request-premium-monthly').then(() => {
            this.useExternal = true;
        });
        this.onMonthlyPriceChange(this.monthlyPrice);
        this.onAnnualPriceChange(this.annualPrice);
        this.onDownpaymentChange(this.downpayment);
    }
    onAnnualPriceChange(annualPrice) {
        this._annualPrice = currencyStringUSD(annualPrice);
    }
    onDownpaymentChange(downpayment) {
        this._downpayment = currencyStringUSD(downpayment);
    }
    onMonthlyPriceChange(monthlyPrice) {
        this._monthlyPrice = currencyStringUSD(monthlyPrice);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-quote-request-premium-monthly", { annualPrice: this.annualPrice, downpayment: this.downpayment, installments: this.installments, monthlyPrice: this.monthlyPrice }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-quote-request-premium-monthly__container" }, h("div", null, h("p", { class: "bp-sdk-online-quote__price-main bp-sdk-quote__price-main" }, h("bp-sdk-quote-request-premium-payment", { period: "mo", price: this.monthlyPrice, showObelus: true })), h("p", { class: "bp-sdk-online-quote__price-disclaimers bp-sdk-quote__price-disclaimer" }, h("sup", null, "\u2020"), "Initial payment of ", this._downpayment, ", then ", this._monthlyPrice, " for ", this.installments, " months."), h("p", { class: "bp-sdk-online-quote__price-alt bp-sdk-quote__price-alt" }, "Or ", this._annualPrice, "/yr"))));
    }
    static get is() { return "bp-sdk-quote-request-premium-monthly"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-quote-request-premium-monthly.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-quote-request-premium-monthly.css"]
        };
    }
    static get properties() {
        return {
            "annualPrice": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Annual price"
                },
                "attribute": "annual-price",
                "reflect": false
            },
            "downpayment": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Downpayment"
                },
                "attribute": "downpayment",
                "reflect": false
            },
            "installments": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Number of installments"
                },
                "attribute": "installments",
                "reflect": false
            },
            "monthlyPrice": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Monthly price"
                },
                "attribute": "monthly-price",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "useExternal": {},
            "_annualPrice": {},
            "_downpayment": {},
            "_monthlyPrice": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "annualPrice",
                "methodName": "onAnnualPriceChange"
            }, {
                "propName": "downpayment",
                "methodName": "onDownpaymentChange"
            }, {
                "propName": "monthlyPrice",
                "methodName": "onMonthlyPriceChange"
            }];
    }
}
