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';

const BceElementSortTemplate = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.optionIcon = Block.ICON_MAP[Block.Type.Sort];
        this.question = '';
        this.required = false;
        this.dual = false;
        this.options = [];
        this.feedbackCorrect = '';
        this.feedbackIncorrect = '';
        this.labelQuestion = 'Formulate your question';
        this.labelRequired = 'Required';
        this.labelOCAddButton = 'Add';
        this.labelOCRemoveButton = 'Delete';
        this.labelOCOther = 'Other';
        this.labelOCImage = 'Image';
        this.labelDual = 'Dual';
        this.labelFeedbackCorrect = 'Feedback correct';
        this.labelFeedbackIncorrect = 'Feedback incorrect';
        this.placeholderOptions = 'Option';
        this.placeholderFeedbackCorrect = 'Feedback on correct answer';
        this.placeholderFeedbackIncorrect = 'Feedback on incorrect answer';
        this._link = linker(this, this.handleInput);
        this._question = this._link('question');
        this._required = this._link('required');
        this._dual = this._link('dual');
        this._options = this._link('options');
        this._feedbackCorrect = this._link('feedbackCorrect');
        this._feedbackIncorrect = this._link('feedbackIncorrect');
    }
    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,
            dual: this.dual,
            options: this.options,
            feedbackCorrect: this.feedbackCorrect,
            feedbackIncorrect: this.feedbackIncorrect
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        const options = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._options);
        return (h(ElementQuestionBase, { question: this._question, required: this._required }, h("bce-option-creator", Object.assign({}, options)), h("bce-input", Object.assign({ type: "switch" }, this._dual)), h("bce-input", Object.assign({ type: "textarea" }, this._feedbackCorrect)), h("bce-input", Object.assign({ type: "textarea" }, this._feedbackIncorrect))));
    }
    get el() { return getElement(this); }
};

export { BceElementSortTemplate as bce_element_sort_template };
