import { generateId } from "@boldpenguin/sdk-utility";
import { h } from "@stencil/core";
const VIN = {
    min: 17,
    max: 17,
    placeholder: 'VIN',
    type: 'vin',
};
const ConfigCode = 'mqs_vehicle_submodel';
export class BpSdkVehicleVin {
    constructor() {
        this.answerId = undefined;
        this.code = undefined;
        this.isSearching = false;
        this.shouldSelectConfiguration = false;
        this.touched = false;
        this.pristine = true;
        this.label = undefined;
        this.errors = [];
        this.errorText = undefined;
        this.canSave = true;
        this.canSearch = true;
        this.hasResult = false;
        this.questionGroupId = undefined;
        this.value = undefined;
        this.answeredBySource = '';
        this.useExternal = false;
        this.labelId = generateId(8);
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-vehicle-vin');
        customElements.whenDefined('bp-sdk-external-vehicle-vin').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-vehicle-vin", { answerId: this.answerId, canSave: this.canSave, canSearch: this.canSearch, code: this.code, errors: this.errors, errorText: this.errorText, hasResult: this.hasResult, isSearching: this.isSearching, label: this.label, labelId: this.labelId, questionGroupId: this.questionGroupId, pristine: this.pristine, shouldSelectConfiguration: this.shouldSelectConfiguration, touched: this.touched, answeredBySource: this.answeredBySource }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-vehicle-vin__container" }, h("div", { class: "bp-sdk-vehicle-vin__wrapper" }, h("bp-sdk-text-input", { answerId: this.answerId, code: this.code, errors: this.errors, errorText: this.errorText, fieldType: VIN.type, isEnabled: this.canSearch, label: this.label, labelId: this.labelId, max: VIN.max, min: VIN.min, placeholder: VIN.placeholder, pristine: this.pristine, questionId: this.labelId, touched: this.touched, text: this.value, answeredBySource: this.answeredBySource }), this.shouldSelectConfiguration && (h("bp-sdk-vehicle-configurations-container", { questionGroupId: this.questionGroupId, checkYmm: false, code: ConfigCode })))));
    }
    static get is() { return "bp-sdk-vehicle-vin"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-vehicle-vin.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-vehicle-vin.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": true
            },
            "isSearching": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is searching"
                },
                "attribute": "is-searching",
                "reflect": false,
                "defaultValue": "false"
            },
            "shouldSelectConfiguration": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should select configuration"
                },
                "attribute": "should-select-configuration",
                "reflect": false,
                "defaultValue": "false"
            },
            "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"
            },
            "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"
            },
            "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
            },
            "errors": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "string[]",
                    "resolved": "string[]",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Error messages"
                },
                "defaultValue": "[]"
            },
            "errorText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Error message"
                },
                "attribute": "error_text",
                "reflect": false
            },
            "canSave": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Can Save"
                },
                "attribute": "can-save",
                "reflect": false,
                "defaultValue": "true"
            },
            "canSearch": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Can search"
                },
                "attribute": "can-search",
                "reflect": false,
                "defaultValue": "true"
            },
            "hasResult": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Has result"
                },
                "attribute": "has-result",
                "reflect": false,
                "defaultValue": "false"
            },
            "questionGroupId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Question group ID"
                },
                "attribute": "question-group-id",
                "reflect": false
            },
            "value": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The current value of the textbox"
                },
                "attribute": "value",
                "reflect": 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": {},
            "labelId": {}
        };
    }
}
