import { r as registerInstance, h, g as getElement } from './core-095fd691.js';
import { B as Block } from './block-4aa42112.js';
import { l as linker } from './input-linker-2b74e80e.js';
import { E as ElementQuestionBase } from './element-question-base-5de5ce16.js';
var BceElementCheckboxTemplate = /** @class */ (function () {
    function class_1(hostRef) {
        var _this = this;
        registerInstance(this, hostRef);
        this.optionIcon = Block.ICON_MAP[Block.Type.Checkbox];
        this.question = '';
        this.required = false;
        this.options = [];
        this.other = false;
        this.orientation = 'vertical';
        this.answer = [];
        this.labelQuestion = 'Formulate your question';
        this.labelRequired = 'Required';
        this.labelOCAddButton = 'Add';
        this.labelOCRemoveButton = 'Delete';
        this.labelOCOther = 'Other';
        this.labelOCImage = 'Image';
        this.labelOrientation = 'Oriëntation';
        this.labelOrientationH = 'Horizontal';
        this.labelOrientationV = 'Vertical';
        this.placeholderOptions = 'Option';
        this._link = linker(this, this.handleInput);
        this._question = this._link('question');
        this._required = this._link('required');
        this._options = this._link('options');
        // private _answer = this._link('answer');
        this._orientation = this._link('orientation');
        this.handleOther = function (event) {
            var input = event.target;
            if (!input)
                return;
            _this.other = event.detail;
            _this.value = _this.updateValue({
                options: input.value,
                other: event.detail
            });
            _this.el.dispatchEvent(new Event('input', { bubbles: true }));
        };
    }
    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,
            options: this.options,
            other: this.other,
            orientation: this.orientation,
            answer: this.answer
        };
        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 options = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage, other: this.other, onOther: this.handleOther, allowOther: true }, this._options);
        return (h(ElementQuestionBase, { question: this._question, required: this._required }, h("bce-option-creator", Object.assign({}, options)), h("bce-input", Object.assign({ type: "radio", value: this.orientation }, this._orientation), h("bce-option", { value: "horizontal" }, this.labelOrientationH), h("bce-option", { value: "vertical" }, this.labelOrientationV))));
    };
    Object.defineProperty(class_1.prototype, "el", {
        get: function () { return getElement(this); },
        enumerable: true,
        configurable: true
    });
    return class_1;
}());
export { BceElementCheckboxTemplate as bce_element_checkbox_template };
