import { DispatchStateChangeUC } from "../../Dispatcher/UC/DispatchStateChangeUC";
import { UndoRedoEntity, } from "../../UndoRedo/Entities/UndoRedoEntity";
import { BaseAppState } from "../Entity/BaseAppState";
export class UndoRedoEditSlideText {
    constructor(initialText, appObjects) {
        this.initialText = initialText;
        this.undoAction = () => {
            if (!this.baseAppState || !this.dispatchStateChange)
                return;
            this.baseAppState.slideText = this.initialText;
            this.dispatchStateChange.doDispatch();
        };
        this.redoAction = () => {
            if (!this.baseAppState || !this.dispatchStateChange || !this.finalText)
                return;
            this.baseAppState.slideText = this.finalText;
            this.dispatchStateChange.doDispatch();
        };
        this.baseAppState = BaseAppState.get(appObjects);
        if (!this.baseAppState) {
            appObjects.submitWarning("UndoEditSlideText", "Unable to find BaseAppState");
            return;
        }
        this.finalText = this.baseAppState.slideText;
        if (initialText === this.finalText)
            return;
        this.dispatchStateChange = DispatchStateChangeUC.get(appObjects);
        if (!this.dispatchStateChange) {
            appObjects.submitWarning("UndoEditSlideText", "Unable to find DispatchStateChangeUC");
            return;
        }
        const undoRedo = UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("UndoEditSlideText", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
//# sourceMappingURL=UndoRedoEditSlideText.js.map