import { r as registerInstance, h, g as getElement } from './core-095fd691.js';
import { l as linker } from './input-linker-2b74e80e.js';
import { E as ElementQuestionBase } from './element-question-base-5de5ce16.js';
var BceElementMatrixTemplate = /** @class */ (function () {
    function class_1(hostRef) {
        registerInstance(this, hostRef);
        this.metadata = {};
        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 = linker(this, this.handleInput);
        this._question = this._link('question');
        this._required = this._link('required');
        this._columns = this._link('columns');
        this._rows = this._link('rows');
    }
    class_1.prototype.handleInput = function (name, event) {
        var _a;
        var input = event.target;
        if (!input)
            return;
        event.cancelBubble = true;
        this[name] = input.value;
        this.value = this.updateValue((_a = {}, _a[name] = input.value, _a));
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    };
    class_1.prototype.updateValue = function (part) {
        if (part === void 0) { part = {}; }
        var current = {
            question: this.question,
            required: this.required,
            columns: this.columns,
            rows: this.rows,
            metadata: Object.assign({}, this.metadata)
        };
        return Object.assign({}, current, part);
    };
    class_1.prototype.componentDidLoad = function () {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    };
    class_1.prototype.render = function () {
        var rows = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._rows);
        var columns = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._columns);
        return (h(ElementQuestionBase, { question: this._question, required: this._required }, h("div", null, h("bce-option-creator", Object.assign({}, rows)), h("bce-option-creator", Object.assign({}, columns)))));
    };
    Object.defineProperty(class_1.prototype, "el", {
        get: function () { return getElement(this); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(class_1, "style", {
        get: function () { 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}}"; },
        enumerable: true,
        configurable: true
    });
    return class_1;
}());
export { BceElementMatrixTemplate as bce_element_matrix_template };
