import { AppObjectEntity, MemoizedString, } from "@vived/core";
export class LabelEntity extends 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);
    }
}
LabelEntity.type = "LabelEntity";
export 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 MemoizedString("", this.notifyOnChange);
        this.memoizedCustom = new MemoizedString("", this.notifyOnChange);
        this.customLabelValidator = (val) => {
            return null;
        };
    }
}
//# sourceMappingURL=LabelEntity.js.map