import { AppObjectUC, getSingletonComponent, } from "@vived/core";
import { dispatchStateChange } from "../../Dispatcher/UC/DispatchStateChangeUC";
import { UndoRedoEntity } from "../../UndoRedo/Entities/UndoRedoEntity";
import { ObjectPickEntity } from "../Entities/ObjectPickEntity";
export class RemoveCorrectObjectIdUC extends AppObjectUC {
    static get(appObjects) {
        return getSingletonComponent(RemoveCorrectObjectIdUC.type, appObjects);
    }
}
RemoveCorrectObjectIdUC.type = "RemoveCorrectObjectIdUC";
export function makeRemoveCorrectObjectIdUC(appObject) {
    return new RemoveCorrectObjectIdUCImp(appObject);
}
class RemoveCorrectObjectIdUCImp extends RemoveCorrectObjectIdUC {
    get undo() {
        return this.getCachedSingleton(UndoRedoEntity.type);
    }
    get objectPick() {
        return this.getCachedSingleton(ObjectPickEntity.type);
    }
    constructor(appObject) {
        super(appObject, RemoveCorrectObjectIdUC.type);
        this.removeCorrectObjectId = (id) => {
            const objectPick = this.objectPick;
            if (!objectPick)
                return;
            objectPick.removeCorrectObjectId(id);
            dispatchStateChange(this.appObjects);
            this.undo?.submitAction({
                redoAction: () => {
                    objectPick.removeCorrectObjectId(id);
                    dispatchStateChange(this.appObjects);
                },
                undoAction: () => {
                    objectPick.addCorrectObjectId(id);
                    dispatchStateChange(this.appObjects);
                },
            });
        };
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=RemoveCorrectObjectIdUC.js.map