import { r as registerInstance, h } from './index-d0047af2.js';
import { E as ElementQuestionBase } from './element-question-base-5ebd9dee.js';

const ElementCheckboxEditor = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.label = {
            name: 'Checkbox',
            labelQuestion: 'Formulate your question',
            labelRequired: 'Required',
            labelMax: 'Max answers',
            labelOCOptionAdd: 'Add Option',
            labelOCOptionRemove: 'Delete Option',
            labelOCOther: 'Other',
            labelOCOtherAdd: 'Add "Other"',
            labelOCOtherRemove: 'Remove "Other"',
            labelOCImageUpload: 'Upload Image',
            labelOCImageDelete: 'Delete Image',
            labelOrientation: 'Oriëntation',
            labelOrientationH: 'Horizontal',
            labelOrientationV: 'Vertical',
            placeholderOptions: 'Option'
        };
        this.handleOther = (event) => {
            const target = event.target;
            this.handler.set('options', target.value);
            this.handler.set('other', event.detail, { emit: true });
        };
        this.transformMax = {
            path: 'validation',
            get: (value) => `max:${value}`,
            set: (value) => value.slice(4)
        };
    }
    prop(path, options = {}) {
        return this.handler.prop(path, Object.assign(Object.assign({}, options), { label: this.label }));
    }
    render() {
        const { labelOrientationH, labelOrientationV } = this.label;
        const { options } = this.value;
        return (h(ElementQuestionBase, { question: this.prop('question', { localize: true }), required: this.prop('required') }, h("bce-option-creator", Object.assign({}, this.prop('options', { default: () => [], localize: true }), { "allow-other": true, label: this.label, other: this.handler.get('other'), onOther: this.handleOther })), h("bce-input", Object.assign({}, this.prop('max', { transform: this.transformMax }), { type: "number", min: options.length ? '1' : '0', max: '' + options.length })), h("bce-select", Object.assign({}, this.prop('orientation'), { type: "radio" }), h("bce-option", { value: "horizontal" }, labelOrientationH), h("bce-option", { value: "vertical" }, labelOrientationV)), h("slot", null)));
    }
};

export { ElementCheckboxEditor as bce_element_checkbox_editor };
