import { h } from "@stencil/core";
export class BpSdkBusinessClassificationSelectorCardHeader {
    constructor() {
        this.confidence = undefined;
        this.alias = undefined;
        this.showNaicsCode = undefined;
        this.showConfidence = undefined;
        this.value = undefined;
        this.highlights = undefined;
        this.highlightFilters = ['synonyms', 'value'];
        this.highlight = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-card-header');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-card-header').then(() => {
            this.useExternal = true;
        });
        this.onHightLightsChange(this.highlights);
        this.onHighlightFilterChanges(this.highlightFilters);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    onHightLightsChange(highlights) {
        this.updateHighlight(this.highlightFilters, highlights);
    }
    onHighlightFilterChanges(filters) {
        this.updateHighlight(filters, this.highlights);
    }
    updateHighlight(filters, highlights = []) {
        const valueHighlight = Array.isArray(highlights) && (highlights === null || highlights === void 0 ? void 0 : highlights.find(({ field }) => filters.includes(field)));
        this.highlight = !!valueHighlight ? valueHighlight.text : this.value;
    }
    renderExternal() {
        return (h("bp-sdk-external-business-classification-selector-card-header", { alias: this.alias, confidence: this.confidence, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, value: this.value, highlights: this.highlights, highlightFilters: this.highlightFilters }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-business-classification-selector-card-header__container" }, h("span", { class: "bp-sdk-business-classification-selector-card-header__text" }, this.highlight && (h("span", { class: "bp-sdk-business-classification-selector-card-header__highlight", innerHTML: this.highlight })), this.showNaicsCode && h("span", { class: "bp-sdk-business-classification-selector-card-header__alias" }, " - ", this.alias)), this.showConfidence && h("bp-sdk-class-selector-relevance-chip", { confidence: this.confidence })));
    }
    static get is() { return "bp-sdk-business-classification-selector-card-header"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-business-classification-selector-card-header.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-business-classification-selector-card-header.css"]
        };
    }
    static get properties() {
        return {
            "confidence": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Confidence level"
                },
                "attribute": "confidence",
                "reflect": false
            },
            "alias": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Alias of choice"
                },
                "attribute": "alias",
                "reflect": false
            },
            "showNaicsCode": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should show naics code"
                },
                "attribute": "show-naics-code",
                "reflect": false
            },
            "showConfidence": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should show confidence"
                },
                "attribute": "show-confidence",
                "reflect": false
            },
            "value": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Value of choice"
                },
                "attribute": "value",
                "reflect": false
            },
            "highlights": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IChoiceHighlight[] | undefined",
                    "resolved": "IChoiceHighlight[]",
                    "references": {
                        "IChoiceHighlight": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IChoiceHighlight"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "List of highlight's"
                }
            },
            "highlightFilters": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "string[]",
                    "resolved": "string[]",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "List of highlight filters"
                },
                "defaultValue": "['synonyms', 'value']"
            }
        };
    }
    static get states() {
        return {
            "highlight": {},
            "useExternal": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "highlights",
                "methodName": "onHightLightsChange"
            }, {
                "propName": "highlightFilters",
                "methodName": "onHighlightFilterChanges"
            }];
    }
}
