'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const core = require('./core-0f211bec.js');
const inputLinker = require('./input-linker-dc14a9fc.js');
const elementQuestionBase = require('./element-question-base-45352939.js');

const BceElementSliderTemplate = class {
    constructor(hostRef) {
        core.registerInstance(this, hostRef);
        this.metadata = {};
        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 = inputLinker.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,
            metadata: Object.assign({}, this.metadata)
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        return (core.h(elementQuestionBase.ElementQuestionBase, { question: this._question, required: this._required }, core.h("bce-input", Object.assign({ type: "number" }, this._step)), core.h("bce-input", Object.assign({ type: "number" }, this._min)), core.h("bce-input", Object.assign({ type: "number" }, this._max)), core.h("bce-input", Object.assign({ type: "text" }, this._minText)), core.h("bce-input", Object.assign({ type: "text" }, this._maxText))));
    }
    get el() { return core.getElement(this); }
};

exports.bce_element_slider_template = BceElementSliderTemplate;
