"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteCalloutUndoRedo = void 0;
const DispatchStateChangeUC_1 = require("../../Dispatcher/UC/DispatchStateChangeUC");
const UndoRedoEntity_1 = require("../../UndoRedo/Entities/UndoRedoEntity");
const CalloutRepo_1 = require("../Entities/CalloutRepo");
class DeleteCalloutUndoRedo {
    constructor(deletedCallout, appObjects) {
        this.deletedCallout = deletedCallout;
        this.appObjects = appObjects;
        this.undoAction = () => {
            const repo = CalloutRepo_1.CalloutRepo.getById(this.deletedCallout.parentID, this.appObjects);
            if (!repo) {
                return;
            }
            const callout = repo.makeCallout(this.deletedCallout.id);
            callout.data = this.deletedCallout;
            (0, DispatchStateChangeUC_1.dispatchStateChange)(this.appObjects);
        };
        this.redoAction = () => {
            const repo = CalloutRepo_1.CalloutRepo.getById(this.deletedCallout.parentID, this.appObjects);
            if (!repo) {
                return;
            }
            repo.deleteCallout(this.deletedCallout.id);
            (0, DispatchStateChangeUC_1.dispatchStateChange)(this.appObjects);
        };
        const undoRedo = UndoRedoEntity_1.UndoRedoEntity.get(this.appObjects);
        if (!undoRedo) {
            this.appObjects.submitWarning("DeleteCalloutUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
exports.DeleteCalloutUndoRedo = DeleteCalloutUndoRedo;
//# sourceMappingURL=DeleteCalloutUndoRedo.js.map