"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LabelEntity = void 0;
exports.makeLabelEntity = makeLabelEntity;
const core_1 = require("@vived/core");
class LabelEntity extends core_1.AppObjectEntity {
    static addIfMissing(appObj) {
        const existing = appObj.getComponent(this.type);
        if (existing) {
            return existing;
        }
        else {
            return makeLabelEntity(appObj);
        }
    }
    static get(appObj) {
        return appObj.getComponent(this.type);
    }
    static getByID(id, appObjects) {
        const appObj = appObjects.get(id);
        if (!appObj)
            return;
        return appObj.getComponent(this.type);
    }
}
exports.LabelEntity = LabelEntity;
LabelEntity.type = "LabelEntity";
function makeLabelEntity(appObject) {
    return new LabelEntityImp(appObject);
}
class LabelEntityImp extends LabelEntity {
    get default() {
        return this.memoizedDefault.val;
    }
    set default(val) {
        this.memoizedDefault.val = val;
    }
    get custom() {
        return this.memoizedCustom.val;
    }
    set custom(val) {
        this.memoizedCustom.val = val;
    }
    get display() {
        if (this.memoizedCustom.val) {
            return this.memoizedCustom.val;
        }
        else {
            return this.memoizedDefault.val;
        }
    }
    get hasCustomLabel() {
        return this.memoizedCustom.val ? true : false;
    }
    get customLabelValidationMessage() {
        return this.customLabelValidator(this.memoizedCustom.val);
    }
    constructor(appObject) {
        super(appObject, LabelEntity.type);
        this.memoizedDefault = new core_1.MemoizedString("", this.notifyOnChange);
        this.memoizedCustom = new core_1.MemoizedString("", this.notifyOnChange);
        this.customLabelValidator = (val) => {
            return null;
        };
    }
}
//# sourceMappingURL=LabelEntity.js.map