import { default as EditorModel } from "./EditorModel.js";
export default class MicroEditorModel extends EditorModel {
    get name() {
        return this.state.get("name", "");
    }
    get category() {
        return this.state.get("category", "");
    }
    get description() {
        return this.state.get("description", "");
    }
    get order() {
        return this.state.get("order", 0);
    }
    get label() {
        return this.state.get("label", "");
    }
    get required() {
        return this.attributes["__required__"] == true;
    }
    get readOnly() {
        return this.attributes["__readonly__"] == true;
    }
    get enabled() {
        return this.attributes["__enabled__"] == null
            || this.attributes["__enabled__"] == true;
    }
    get postback() {
        return this.attributes["__postback__"] != null;
    }
    getFeaturePrimaryValue(defaultValue) {
        return this.getFeatureValue(this.name, defaultValue);
    }
    setFeaturePrimaryValue(value, options = {}) {
        this.setFeatureValue(this.name, value, options);
    }
    getFeatureValue(name, defaultValue) {
        return super.getFeatureValue(name, defaultValue);
    }
    setFeatureValue(name, value, options = {}) {
        options.postback = (options.postback == undefined ?
            this.postback : options.postback);
        super.setFeatureValue(name, value, options);
    }
    getFeatureValueByProp(prop, defaultValue) {
        let name = this.state.get(prop);
        let result = null;
        if (name != null) {
            name = _.camelCase(name);
            result = this.feature.getValue(name, defaultValue);
        }
        return result;
    }
    static isMicroEditor(item) {
        return item["label"] !== undefined
            && item["category"] !== undefined
            && item["description"] !== undefined
            && item["name"] !== undefined
            && item["order"] !== undefined;
    }
}
