import { h } from "@stencil/core";
export class BpSdkOfflineQuote {
    constructor() {
        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)))));
    }
    static get is() { return "bp-sdk-offline-quote"; }
    static get originalStyleUrls() {
        return {
            "$": ["bp-sdk-offline-quote.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-offline-quote.css"]
        };
    }
    static get properties() {
        return {
            "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"
                }
            },
            "product": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IProduct",
                    "resolved": "IProduct",
                    "references": {
                        "IProduct": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IProduct"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Product selection"
                }
            },
            "showLogo": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should show logo"
                },
                "attribute": "show-logo",
                "reflect": false,
                "defaultValue": "true"
            },
            "showCustomLogo": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should show custom logo"
                },
                "attribute": "show-custom-logo",
                "reflect": false,
                "defaultValue": "false"
            },
            "customLogoBaseUrl": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Custom logo url"
                },
                "attribute": "custom-logo-base-url",
                "reflect": false,
                "defaultValue": "''"
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
}
