import { h } from "@stencil/core";
import { ElementQuestionBase } from '../../utils/element-question-base';
import { linker } from '../../utils/input-linker';
export class BceElementSliderTemplate {
    constructor() {
        this.question = '';
        this.required = false;
        this.step = 1;
        this.min = 1;
        this.max = 5;
        this.minText = '';
        this.maxText = '';
        this.labelQuestion = 'Formulate your question';
        this.labelRequired = 'Required';
        this.labelStep = 'Step size';
        this.labelMin = 'Min';
        this.labelMax = 'Max';
        this.labelMinText = 'Text left';
        this.labelMaxText = 'Text right';
        this._link = linker(this, this.handleInput);
        this._question = this._link('question');
        this._required = this._link('required');
        this._step = this._link('step');
        this._min = this._link('min');
        this._max = this._link('max');
        this._minText = this._link('minText');
        this._maxText = this._link('maxText');
    }
    handleInput(name, event) {
        const input = event.target;
        if (!input)
            return;
        event.cancelBubble = true;
        this[name] = input.value;
        this.value = this.updateValue({ [name]: input.value });
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    updateValue(part = {}) {
        const current = {
            question: this.question,
            required: this.required,
            step: this.step,
            min: this.min,
            max: this.max,
            minText: this.minText,
            maxText: this.maxText
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        return (h(ElementQuestionBase, { question: this._question, required: this._required },
            h("bce-input", Object.assign({ type: "number" }, this._step)),
            h("bce-input", Object.assign({ type: "number" }, this._min)),
            h("bce-input", Object.assign({ type: "number" }, this._max)),
            h("bce-input", Object.assign({ type: "text" }, this._minText)),
            h("bce-input", Object.assign({ type: "text" }, this._maxText))));
    }
    static get is() { return "bce-element-slider-template"; }
    static get properties() { return {
        "value": {
            "type": "unknown",
            "mutable": true,
            "complexType": {
                "original": "SliderTemplate",
                "resolved": "undefined | { readonly question: string; readonly required: boolean; readonly min: number; readonly max: number; readonly step: number; readonly minText: string; readonly maxText: string; }",
                "references": {
                    "SliderTemplate": {
                        "location": "local"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "question": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "question",
            "reflect": false,
            "defaultValue": "''"
        },
        "required": {
            "type": "boolean",
            "mutable": true,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "required",
            "reflect": false,
            "defaultValue": "false"
        },
        "step": {
            "type": "number",
            "mutable": true,
            "complexType": {
                "original": "number",
                "resolved": "number",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "step",
            "reflect": false,
            "defaultValue": "1"
        },
        "min": {
            "type": "number",
            "mutable": true,
            "complexType": {
                "original": "number",
                "resolved": "number",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "min",
            "reflect": false,
            "defaultValue": "1"
        },
        "max": {
            "type": "number",
            "mutable": true,
            "complexType": {
                "original": "number",
                "resolved": "number",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "max",
            "reflect": false,
            "defaultValue": "5"
        },
        "minText": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "min-text",
            "reflect": false,
            "defaultValue": "''"
        },
        "maxText": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "max-text",
            "reflect": false,
            "defaultValue": "''"
        },
        "labelQuestion": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-question",
            "reflect": false,
            "defaultValue": "'Formulate your question'"
        },
        "labelRequired": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-required",
            "reflect": false,
            "defaultValue": "'Required'"
        },
        "labelStep": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-step",
            "reflect": false,
            "defaultValue": "'Step size'"
        },
        "labelMin": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-min",
            "reflect": false,
            "defaultValue": "'Min'"
        },
        "labelMax": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-max",
            "reflect": false,
            "defaultValue": "'Max'"
        },
        "labelMinText": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-min-text",
            "reflect": false,
            "defaultValue": "'Text left'"
        },
        "labelMaxText": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-max-text",
            "reflect": false,
            "defaultValue": "'Text right'"
        }
    }; }
    static get elementRef() { return "el"; }
}
