"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteAllLandmarksUndoRedo = void 0;
const Dispatcher_1 = require("../../Dispatcher");
const UndoRedo_1 = require("../../UndoRedo");
const LandmarkRepo_1 = require("../Entities/LandmarkRepo");
class DeleteAllLandmarksUndoRedo {
    constructor(deletedLandmarks, appObjects) {
        this.deletedLandmarks = deletedLandmarks;
        this.appObjects = appObjects;
        this.undoAction = () => {
            this.deletedLandmarks.forEach((deletedLandmark) => {
                const landmarkRepo = LandmarkRepo_1.LandmarkRepo.getByID(deletedLandmark.parentID, this.appObjects);
                if (!landmarkRepo) {
                    return;
                }
                const landmark = landmarkRepo.createLandmark(deletedLandmark.id);
                landmark.data = deletedLandmark;
            });
            (0, Dispatcher_1.dispatchStateChange)(this.appObjects);
        };
        this.redoAction = () => {
            this.deletedLandmarks.forEach((deletedLandmark) => {
                const repo = LandmarkRepo_1.LandmarkRepo.getByID(deletedLandmark.parentID, this.appObjects);
                repo?.deleteLandmark(deletedLandmark.id);
            });
            (0, Dispatcher_1.dispatchStateChange)(this.appObjects);
        };
        const undoRedo = UndoRedo_1.UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("DeleteAllLandmarksUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
exports.DeleteAllLandmarksUndoRedo = DeleteAllLandmarksUndoRedo;
//# sourceMappingURL=DeleteAllLandmarksUndoRedo.js.map