"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LandmarkListPM = void 0;
exports.makeLandmarkListPM = makeLandmarkListPM;
const core_1 = require("@vived/core");
const LandmarkRepo_1 = require("../Entities/LandmarkRepo");
class LandmarkListPM extends core_1.AppObjectPM {
    static get(id, appObjects) {
        return appObjects
            .get(id)
            ?.getComponent(LandmarkListPM.type);
    }
}
exports.LandmarkListPM = LandmarkListPM;
LandmarkListPM.type = "LandmarkListPM";
function makeLandmarkListPM(appObject) {
    return new LandmarkListPMImp(appObject);
}
class LandmarkListPMImp extends LandmarkListPM {
    get landmarkRepo() {
        return this.getCachedLocalComponent(LandmarkRepo_1.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