'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 BceElementMatrixTemplate = class {
    constructor(hostRef) {
        core.registerInstance(this, hostRef);
        this.optionIcon = 'fas:columns';
        this.question = '';
        this.required = false;
        this.columns = [];
        this.rows = [];
        this.labelQuestion = 'Formulate your question';
        this.labelRequired = 'Required';
        this.labelOCAddButton = 'Add';
        this.labelOCRemoveButton = 'Delete';
        this.labelOCOther = 'Other';
        this.labelOCImage = 'Image';
        this.labelRows = 'Rows';
        this.labelColumns = 'Columns';
        this.placeholderRows = 'Row';
        this.placeholderColumns = 'Column';
        this._link = inputLinker.linker(this, this.handleInput);
        this._question = this._link('question');
        this._required = this._link('required');
        this._columns = this._link('columns');
        this._rows = this._link('rows');
    }
    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,
            columns: this.columns,
            rows: this.rows
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        const rows = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._rows);
        const columns = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._columns);
        return (core.h(elementQuestionBase.ElementQuestionBase, { question: this._question, required: this._required }, core.h("div", null, core.h("bce-option-creator", Object.assign({}, rows)), core.h("bce-option-creator", Object.assign({}, columns)))));
    }
    get el() { return core.getElement(this); }
    static get style() { return "bce-element-matrix-template>div{position:relative;display:-ms-flexbox;display:flex;-ms-flex-flow:column nowrap;flex-flow:column nowrap}bce-element-matrix-template>div>bce-option-creator{-ms-flex:1 1 auto;flex:1 1 auto}bce-element-matrix-template>div>bce-option-creator>:last-child{bottom:-27px}bce-element-matrix-template>div>bce-option-creator:first-child>[data-option]>bce-icon{-webkit-transform:rotate(-90deg) translateX(50%);transform:rotate(-90deg) translateX(50%)}\@media screen and (min-width:600px){bce-element-matrix-template>div{-ms-flex-align:start;align-items:flex-start;-ms-flex-flow:row nowrap;flex-flow:row nowrap}}"; }
};

exports.bce_element_matrix_template = BceElementMatrixTemplate;
