import { h } from "@stencil/core";
export class BpSdkVehicleMakes {
    constructor() {
        this.answerId = undefined;
        this.code = undefined;
        this.label = undefined;
        this.pristine = true;
        this.touched = false;
        this.errors = [];
        this.makes = [];
        this.selectedMakeId = undefined;
        this.isVehicleTrailer = false;
        this.answeredBySource = '';
        this.useExternal = false;
        this.fieldType = 'dropdown';
        this.inputComponentType = 'dropdown';
    }
    onIsVehicleTrailerChange(isTrailer) {
        this.fieldType = isTrailer ? 'vehicle' : 'dropdown';
        this.inputComponentType = isTrailer ? 'vehicle' : 'dropdown';
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-vehicle-makes');
        customElements.whenDefined('bp-sdk-external-vehicle-makes').then(() => {
            this.useExternal = true;
        });
        this.onIsVehicleTrailerChange(this.isVehicleTrailer);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-vehicle-makes", { answerId: this.answerId, code: this.code, errors: this.errors, isVehicleTrailer: this.isVehicleTrailer, label: this.label, makes: this.makes, pristine: this.pristine, selectedMakeId: this.selectedMakeId, touched: this.touched }));
    }
    renderInternal() {
        return (h("bp-sdk-dynamic-input", { answerId: this.answerId, choiceId: this.selectedMakeId, choices: this.makes, code: this.code, errors: this.errors, fieldType: this.fieldType, inputComponentType: this.inputComponentType, isAutocomplete: this.isVehicleTrailer, isLabelledField: true, isRequired: true, label: this.label, pristine: this.pristine, referenceType: "makes", touched: this.touched, answeredBySource: this.answeredBySource }));
    }
    static get is() { return "bp-sdk-vehicle-makes"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-vehicle-makes.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-vehicle-makes.css"]
        };
    }
    static get properties() {
        return {
            "answerId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The id of the answer associated with this field"
                },
                "attribute": "answer-id",
                "reflect": false
            },
            "code": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The question code associated with this field"
                },
                "attribute": "code",
                "reflect": false
            },
            "label": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Label to display"
                },
                "attribute": "label",
                "reflect": false
            },
            "pristine": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is pristine"
                },
                "attribute": "pristine",
                "reflect": false,
                "defaultValue": "true"
            },
            "touched": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is touched"
                },
                "attribute": "touched",
                "reflect": false,
                "defaultValue": "false"
            },
            "errors": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "string[]",
                    "resolved": "string[]",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Error messages"
                },
                "defaultValue": "[]"
            },
            "makes": {
                "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": "Makes choices"
                },
                "defaultValue": "[]"
            },
            "selectedMakeId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Selected make ID"
                },
                "attribute": "selected-make-id",
                "reflect": false
            },
            "isVehicleTrailer": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is vehicle a trailer"
                },
                "attribute": "is-vehicle-trailer",
                "reflect": false,
                "defaultValue": "false"
            },
            "answeredBySource": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The source a question was answered by, if not answered directly"
                },
                "attribute": "answered-by-source",
                "reflect": false,
                "defaultValue": "''"
            }
        };
    }
    static get states() {
        return {
            "useExternal": {},
            "fieldType": {},
            "inputComponentType": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "isVehicleTrailer",
                "methodName": "onIsVehicleTrailerChange"
            }];
    }
}
