import { AppObjectPM } from "@vived/core";
import { LandmarkRepo } from "../Entities/LandmarkRepo";
export class LandmarkListPM extends AppObjectPM {
    static get(id, appObjects) {
        return appObjects
            .get(id)
            ?.getComponent(LandmarkListPM.type);
    }
}
LandmarkListPM.type = "LandmarkListPM";
export function makeLandmarkListPM(appObject) {
    return new LandmarkListPMImp(appObject);
}
class LandmarkListPMImp extends LandmarkListPM {
    get landmarkRepo() {
        return this.getCachedLocalComponent(LandmarkRepo.type);
    }
    vmsAreEqual(a, b) {
        return a.length === b.length;
    }
    constructor(appObject) {
        super(appObject, LandmarkListPM.type);
        this.onRepoChange = () => {
            if (!this.landmarkRepo)
                return;
            const landmarks = this.landmarkRepo.getAll();
            const ids = landmarks.map((landmark) => landmark.appObject.id);
            this.doUpdateView(ids);
        };
        this.landmarkRepo?.addChangeObserver(this.onRepoChange);
        this.onRepoChange();
    }
}
//# sourceMappingURL=LandmarkListPM.js.map