import { h } from "@stencil/core";
import { getConfigOptions } from "@boldpenguin/sdk-redux";
import store from "../../services/redux-store.service";
export class BpSdkBusinessClassificationSelectorListContainer {
    constructor() {
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            this.storeUnsubscribe = store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => {
            return {
                groupedChoicesConfig: { maxResults: getConfigOptions(state).bcsChoiceLimit },
            };
        };
        this.choiceId = undefined;
        this.choices = [];
        this.showConfidence = undefined;
        this.showNaicsCode = undefined;
        this.groupedChoicesConfig = { maxResults: 7 };
        this.useExternal = false;
    }
    resetState() {
        this.groupedChoicesConfig = { maxResults: 7 };
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-list-container');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-list-container').then(() => {
            this.useExternal = true;
        });
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    disconnectedCallback() {
        this.storeUnsubscribe && this.storeUnsubscribe();
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-business-classification-selector-list-container", { choices: this.choices, choiceId: this.choiceId, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, groupedChoicesConfig: this.groupedChoicesConfig }));
    }
    renderInternal() {
        return (h("bp-sdk-business-classification-selector-list", { choices: this.choices, choiceId: this.choiceId, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, groupedChoicesConfig: this.groupedChoicesConfig }));
    }
    static get is() { return "bp-sdk-business-classification-selector-list-container"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-business-classification-selector-list-container.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-business-classification-selector-list-container.css"]
        };
    }
    static get properties() {
        return {
            "choiceId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "*\nSelected choice id"
                },
                "attribute": "choice_id",
                "reflect": false
            },
            "choices": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IChoice[]",
                    "resolved": "IChoice[]",
                    "references": {
                        "IChoice": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IChoice"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "*\nChoices to display"
                },
                "defaultValue": "[]"
            },
            "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
            },
            "showNaicsCode": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should show confidence"
                },
                "attribute": "show-naics-code",
                "reflect": false
            },
            "groupedChoicesConfig": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IGroupedChoicesConfig",
                    "resolved": "IGroupedChoicesConfig",
                    "references": {
                        "IGroupedChoicesConfig": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IGroupedChoicesConfig"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Grouped choices config"
                },
                "defaultValue": "{ maxResults: 7 }"
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
    static get elementRef() { return "el"; }
}
