import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { UndoRedoEntity } from "../Entities/UndoRedoEntity";
export class HasRedoPM extends AppObjectPM {
}
HasRedoPM.type = "HasRedoPM";
HasRedoPM.get = (appObjects) => getSingletonComponent(HasRedoPM.type, appObjects);
export function makeHasRedoPM(appObject) {
    return new HasRedoPMImp(appObject);
}
class HasRedoPMImp extends HasRedoPM {
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, HasRedoPM.type);
        this.dispose = () => {
            super.dispose();
            this.undoRedoEntity?.removeChangeObserver(this.onEntityChange);
        };
        this.onEntityChange = () => {
            if (!this.undoRedoEntity)
                return;
            this.doUpdateView(this.undoRedoEntity.hasRedo);
        };
        this.undoRedoEntity = appObject.getComponent(UndoRedoEntity.type);
        if (this.undoRedoEntity) {
            this.undoRedoEntity.addChangeObserver(this.onEntityChange);
            this.onEntityChange();
        }
        else {
            this.warn("HasRedoPM has been added to an app object that does not have UndoRedoEntity");
        }
    }
}
//# sourceMappingURL=HasRedoPM.js.map