import { AppObjectUC } from "@vived/core";
import { dispatchStateChange } from "../../Dispatcher/UC/DispatchStateChangeUC";
import { CalloutEntity } from "../Entities/CalloutEntity";
import { DeleteCalloutUndoRedo } from "./DeleteCalloutUndoRedo";
export class DeleteCalloutUC extends AppObjectUC {
    static get(appObj) {
        return appObj.getComponent(this.type);
    }
    static getById(id, appObjects) {
        return appObjects.get(id)?.getComponent(this.type);
    }
}
DeleteCalloutUC.type = "DeleteCalloutUC";
export function makeDeleteCalloutUC(appObject) {
    return new DeleteCalloutUCImp(appObject);
}
class DeleteCalloutUCImp extends DeleteCalloutUC {
    get callout() {
        return this.getCachedLocalComponent(CalloutEntity.type);
    }
    constructor(appObject) {
        super(appObject, DeleteCalloutUC.type);
        this.delete = () => {
            if (!this.callout)
                return;
            new DeleteCalloutUndoRedo(this.callout.data, this.appObjects);
            this.callout.inRepo?.deleteCallout(this.callout.id);
            dispatchStateChange(this.appObjects);
        };
    }
}
//# sourceMappingURL=DeleteCallout.js.map