import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { FramedScreenEntity } from "../Entities";
export class FramedScreenSizePM extends AppObjectPM {
}
FramedScreenSizePM.type = "FramedScreenSizePM";
FramedScreenSizePM.get = (appObjects) => getSingletonComponent(FramedScreenSizePM.type, appObjects);
export function makeFramedScreenSizePM(appObject) {
    return new FramedScreenSizePMImp(appObject);
}
class FramedScreenSizePMImp extends FramedScreenSizePM {
    get screen() {
        return this.getCachedSingleton(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);
    }
}
export const defaultFramedScreenVM = {
    height: 0,
    width: 0,
};
//# sourceMappingURL=FramedScreenSizePM.js.map