"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetCustomLabelUndoRedo = void 0;
const Dispatcher_1 = require("../../Dispatcher");
const UndoRedo_1 = require("../../UndoRedo");
const Entities_1 = require("../Entities");
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;
            (0, Dispatcher_1.dispatchStateChange)(this.appObject.appObjectRepo);
        };
        this.redoAction = () => {
            if (!this.label)
                return;
            this.label.custom = this.curLabel;
            (0, Dispatcher_1.dispatchStateChange)(this.appObject.appObjectRepo);
        };
        this.label = Entities_1.LabelEntity.get(appObject);
        if (!this.label) {
            appObject.appObjectRepo.submitWarning("SetCustomLabelUndoRedo", "Unable to find LabelEntity");
            return;
        }
        const undoRedo = UndoRedo_1.UndoRedoEntity.get(appObject.appObjectRepo);
        if (!undoRedo) {
            appObject.appObjectRepo.submitWarning("SetCustomLabelUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
exports.SetCustomLabelUndoRedo = SetCustomLabelUndoRedo;
//# sourceMappingURL=SetCustomLabelUndoRedo.js.map