import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { dispatchStateChange } from "../../Dispatcher";
import { LandmarkRepo } from "../Entities/LandmarkRepo";
import { DeleteAllLandmarksUndoRedo } from "./DeleteAllLandmarksUndoRedo";
export class DeleteAllLandmarksUC extends AppObjectUC {
}
DeleteAllLandmarksUC.type = "DeleteAllLandmarksUC";
DeleteAllLandmarksUC.get = (appObjects) => getSingletonComponent(DeleteAllLandmarksUC.type, appObjects);
export function makeDeleteAllLandmarksUC(appObject) {
    return new DeleteAllCalloutsUCImp(appObject);
}
class DeleteAllCalloutsUCImp extends DeleteAllLandmarksUC {
    deleteAllLandmarks() {
        const deletedLandmarks = [];
        const landmarkRepos = this.appObjects.getAllComponents(LandmarkRepo.type);
        landmarkRepos.forEach((repo) => {
            const callouts = repo.getAll();
            callouts.forEach((landmark) => {
                deletedLandmarks.push(landmark.data);
                repo.removeForAppObject(landmark.appObject.id);
                landmark.appObject.dispose();
            });
        });
        dispatchStateChange(this.appObjects);
        new DeleteAllLandmarksUndoRedo(deletedLandmarks, this.appObjects);
    }
    constructor(appObject) {
        super(appObject, DeleteAllLandmarksUC.type);
    }
}
//# sourceMappingURL=DeleteAllLandmarksUC.js.map