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