import { dispatchStateChange } from "../../Dispatcher";
import { UndoRedoEntity } from "../../UndoRedo";
import { LandmarkRepo } from "../Entities/LandmarkRepo";
export class DeleteAllLandmarksUndoRedo {
    constructor(deletedLandmarks, appObjects) {
        this.deletedLandmarks = deletedLandmarks;
        this.appObjects = appObjects;
        this.undoAction = () => {
            this.deletedLandmarks.forEach((deletedLandmark) => {
                const landmarkRepo = LandmarkRepo.getByID(deletedLandmark.parentID, this.appObjects);
                if (!landmarkRepo) {
                    return;
                }
                const landmark = landmarkRepo.createLandmark(deletedLandmark.id);
                landmark.data = deletedLandmark;
            });
            dispatchStateChange(this.appObjects);
        };
        this.redoAction = () => {
            this.deletedLandmarks.forEach((deletedLandmark) => {
                const repo = LandmarkRepo.getByID(deletedLandmark.parentID, this.appObjects);
                repo?.deleteLandmark(deletedLandmark.id);
            });
            dispatchStateChange(this.appObjects);
        };
        const undoRedo = UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("DeleteAllLandmarksUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
//# sourceMappingURL=DeleteAllLandmarksUndoRedo.js.map