"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StylusIsInUsePM = void 0;
exports.makeStylusIsInUsePM = makeStylusIsInUsePM;
const core_1 = require("@vived/core");
const StylusEntity_1 = require("../Entity/StylusEntity");
class StylusIsInUsePM extends core_1.AppObjectPM {
}
exports.StylusIsInUsePM = StylusIsInUsePM;
StylusIsInUsePM.type = "StylusIsInUsePM";
StylusIsInUsePM.get = (appObjects) => (0, core_1.getSingletonComponent)(StylusIsInUsePM.type, appObjects);
function makeStylusIsInUsePM(appObject) {
    return new StylusIsInUsePMImp(appObject);
}
class StylusIsInUsePMImp extends StylusIsInUsePM {
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, StylusIsInUsePM.type);
        this.onStylusChange = () => {
            if (!this.stylus)
                return;
            this.doUpdateView(this.stylus.isInUse);
        };
        this.stylus = appObject.getComponent(StylusEntity_1.StylusEntity.type);
        if (this.stylus) {
            this.stylus.addChangeObserver(this.onStylusChange);
            this.onStylusChange();
        }
        else {
            this.warn("App Object does not have a Stylus Entity");
        }
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=StylusIsInUsePM.js.map