import { dispatchStateChange } from "../../Dispatcher";
import { UndoRedoEntity } from "../../UndoRedo";
import { LabelEntity } from "../Entities";
export class SetCustomLabelUndoRedo {
    constructor(prevLabel, curLabel, appObject) {
        this.prevLabel = prevLabel;
        this.curLabel = curLabel;
        this.appObject = appObject;
        this.undoAction = () => {
            if (!this.label)
                return;
            this.label.custom = this.prevLabel;
            dispatchStateChange(this.appObject.appObjectRepo);
        };
        this.redoAction = () => {
            if (!this.label)
                return;
            this.label.custom = this.curLabel;
            dispatchStateChange(this.appObject.appObjectRepo);
        };
        this.label = LabelEntity.get(appObject);
        if (!this.label) {
            appObject.appObjectRepo.submitWarning("SetCustomLabelUndoRedo", "Unable to find LabelEntity");
            return;
        }
        const undoRedo = UndoRedoEntity.get(appObject.appObjectRepo);
        if (!undoRedo) {
            appObject.appObjectRepo.submitWarning("SetCustomLabelUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
//# sourceMappingURL=SetCustomLabelUndoRedo.js.map