"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultFramedScreenVM = exports.FramedScreenSizePM = void 0;
exports.makeFramedScreenSizePM = makeFramedScreenSizePM;
const core_1 = require("@vived/core");
const Entities_1 = require("../Entities");
class FramedScreenSizePM extends core_1.AppObjectPM {
}
exports.FramedScreenSizePM = FramedScreenSizePM;
FramedScreenSizePM.type = "FramedScreenSizePM";
FramedScreenSizePM.get = (appObjects) => (0, core_1.getSingletonComponent)(FramedScreenSizePM.type, appObjects);
function makeFramedScreenSizePM(appObject) {
    return new FramedScreenSizePMImp(appObject);
}
class FramedScreenSizePMImp extends FramedScreenSizePM {
    get screen() {
        return this.getCachedSingleton(Entities_1.FramedScreenEntity.type);
    }
    vmsAreEqual(a, b) {
        if (a.height !== b.height)
            return false;
        if (a.width !== b.width)
            return false;
        return true;
    }
    constructor(appObject) {
        super(appObject, FramedScreenSizePM.type);
        this.onContainerChange = () => {
            if (!this.screen)
                return;
            const vm = {
                height: this.screen.screenHeight,
                width: this.screen.screenWidth,
            };
            this.doUpdateView(vm);
        };
        this.screen?.addChangeObserver(this.onContainerChange);
        this.onContainerChange();
        this.appObjects.registerSingleton(this);
    }
}
exports.defaultFramedScreenVM = {
    height: 0,
    width: 0,
};
//# sourceMappingURL=FramedScreenSizePM.js.map