import { dispatchStateChange } from "../../Dispatcher/UC/DispatchStateChangeUC";
import { UndoRedoEntity, } from "../../UndoRedo/Entities/UndoRedoEntity";
import { CalloutRepo } from "../Entities/CalloutRepo";
export class DeleteCalloutUndoRedo {
    constructor(deletedCallout, appObjects) {
        this.deletedCallout = deletedCallout;
        this.appObjects = appObjects;
        this.undoAction = () => {
            const repo = CalloutRepo.getById(this.deletedCallout.parentID, this.appObjects);
            if (!repo) {
                return;
            }
            const callout = repo.makeCallout(this.deletedCallout.id);
            callout.data = this.deletedCallout;
            dispatchStateChange(this.appObjects);
        };
        this.redoAction = () => {
            const repo = CalloutRepo.getById(this.deletedCallout.parentID, this.appObjects);
            if (!repo) {
                return;
            }
            repo.deleteCallout(this.deletedCallout.id);
            dispatchStateChange(this.appObjects);
        };
        const undoRedo = UndoRedoEntity.get(this.appObjects);
        if (!undoRedo) {
            this.appObjects.submitWarning("DeleteCalloutUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
//# sourceMappingURL=DeleteCalloutUndoRedo.js.map