import { AppObjectPM } from "@vived/core";
import { Hideable } from "../Entities/Hideable";
export class IsHiddenPM extends AppObjectPM {
    static get(appObjID, appObjects) {
        const appObj = appObjects.get(appObjID);
        if (appObj === undefined) {
            return undefined;
        }
        return appObj.getComponent(IsHiddenPM.type);
    }
}
IsHiddenPM.type = "IsHiddenPM";
export function makeIsHiddenPM(appObject) {
    return new IsHiddenPMImp(appObject);
}
class IsHiddenPMImp extends IsHiddenPM {
    get hideable() {
        return this.getCachedLocalComponent(Hideable.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, IsHiddenPM.type);
        this.onIsHiddenChange = () => {
            if (!this.hideable)
                return;
            this.doUpdateView(this.hideable.isHidden);
        };
        this.dispose = () => {
            super.dispose();
            this.hideable?.removeChangeObserver(this.onIsHiddenChange);
            this.hideable?.removeOnDisposeObserver(this.dispose);
        };
        if (!this.hideable) {
            this.error("Unable to find Hideable Entity");
            return;
        }
        else {
            this.hideable.addChangeObserver(this.onIsHiddenChange);
            this.hideable.addOnDisposeObserver(this.dispose);
            this.onIsHiddenChange();
        }
    }
}
//# sourceMappingURL=IsHiddenPM.js.map