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