"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsAuthoringPM = void 0;
exports.makeIsAuthoringPM = makeIsAuthoringPM;
const core_1 = require("@vived/core");
const Entity_1 = require("../Entity");
class IsAuthoringPM extends core_1.AppObjectPM {
}
exports.IsAuthoringPM = IsAuthoringPM;
IsAuthoringPM.type = "IsAuthoringPM";
IsAuthoringPM.get = (appObjects) => (0, core_1.getSingletonComponent)(IsAuthoringPM.type, appObjects);
function makeIsAuthoringPM(appObject) {
    return new IsAuthoringPMImp(appObject);
}
class IsAuthoringPMImp extends IsAuthoringPM {
    get baseAppState() {
        return this.getCachedSingleton(Entity_1.BaseAppState.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    dispose() {
        super.dispose();
        this.baseAppState?.removeChangeObserver(this.onAppStateChange);
    }
    constructor(appObject) {
        super(appObject, IsAuthoringPM.type);
        this.onAppStateChange = () => {
            if (!this.baseAppState)
                return;
            this.doUpdateView(this.baseAppState.isAuthoring);
        };
        this.baseAppState?.addChangeObserver(this.onAppStateChange);
        this.onAppStateChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=IsAuthoringPM.js.map