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