import { h } from "@stencil/core";
export class BpSdkQuoteRequestBindContainer {
    constructor() {
        this.appFormId = '';
        this.carrier = undefined;
        this.isBindable = undefined;
        this.isPermittedToBind = undefined;
        this.quoteId = '';
        this.quoteInfo = undefined;
        this.handleBind = undefined;
        this.useExternal = false;
        this.annualPrice = undefined;
        this.carrierName = undefined;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-bind-container');
        customElements.whenDefined('bp-sdk-external-quote-request-bind-container').then(() => {
            this.useExternal = true;
        });
        this.onQuoteInfoChange(this.quoteInfo);
        this.onCarrierChange(this.carrier);
    }
    onQuoteInfoChange(quoteInfo) {
        var _a;
        this.annualPrice = (_a = quoteInfo === null || quoteInfo === void 0 ? void 0 : quoteInfo.annual_price) !== null && _a !== void 0 ? _a : '0';
    }
    onCarrierChange(carrier) {
        var _a;
        this.carrierName = (_a = carrier === null || carrier === void 0 ? void 0 : carrier.name) !== null && _a !== void 0 ? _a : '';
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-quote-request-bind-container", { appFormId: this.appFormId, carrier: this.carrier, isBindable: this.isBindable, isPermittedToBind: this.isPermittedToBind, quoteId: this.quoteId, quoteInfo: this.quoteInfo, handleBind: this.handleBind }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-quote-request-bind-container__container" }, this.isBindable && (h("bp-sdk-quote-request-button-container", { annualPrice: this.annualPrice, appFormId: this.appFormId, carrierName: this.carrierName, quoteId: this.quoteId, handleBind: this.handleBind }))));
    }
    static get is() { return "bp-sdk-quote-request-bind-container"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-quote-request-bind-container.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-quote-request-bind-container.css"]
        };
    }
    static get properties() {
        return {
            "appFormId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Application form id"
                },
                "attribute": "app-form-id",
                "reflect": false,
                "defaultValue": "''"
            },
            "carrier": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ICarrier",
                    "resolved": "ICarrier",
                    "references": {
                        "ICarrier": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::ICarrier"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Carrier name"
                }
            },
            "isBindable": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is bindable"
                },
                "attribute": "is-bindable",
                "reflect": false
            },
            "isPermittedToBind": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is permitted to bind"
                },
                "attribute": "is-permitted-to-bind",
                "reflect": false
            },
            "quoteId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote id"
                },
                "attribute": "quote-id",
                "reflect": false,
                "defaultValue": "''"
            },
            "quoteInfo": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IQuoteInfo",
                    "resolved": "IQuoteInfo",
                    "references": {
                        "IQuoteInfo": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IQuoteInfo"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote information"
                }
            },
            "handleBind": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "HandleBindFunction",
                    "resolved": "(quoteId: string, appFormId: string, afterResponse?: (response: string) => void) => void",
                    "references": {
                        "HandleBindFunction": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::HandleBindFunction"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "quote bind function"
                }
            }
        };
    }
    static get states() {
        return {
            "useExternal": {},
            "annualPrice": {},
            "carrierName": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "quoteInfo",
                "methodName": "onQuoteInfoChange"
            }, {
                "propName": "carrier",
                "methodName": "onCarrierChange"
            }];
    }
}
