import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { ChannelModelRepo } from "../Entities";
export class ActiveModelPM extends AppObjectPM {
    static get(appObjects) {
        return getSingletonComponent(ActiveModelPM.type, appObjects);
    }
}
ActiveModelPM.type = "ActiveModelPM";
export function makeActiveModelPM(appObject) {
    return new ActiveModelPMImp(appObject);
}
class ActiveModelPMImp extends ActiveModelPM {
    get repo() {
        return this.getCachedSingleton(ChannelModelRepo.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, ActiveModelPM.type);
        this.onEntityChange = () => {
            if (!this.repo)
                return;
            this.doUpdateView(this.repo.activeModel);
        };
        this.repo?.addChangeObserver(this.onEntityChange);
        this.onEntityChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=ActiveModelPM.js.map