"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteLandmarkUC = void 0;
exports.makeDeleteLandmarkUC = makeDeleteLandmarkUC;
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const Entities_1 = require("../Entities");
const DeleteLandmarkUndoRedo_1 = require("./DeleteLandmarkUndoRedo");
class DeleteLandmarkUC extends core_1.AppObjectUC {
    static get(appObj) {
        return appObj.getComponent(this.type);
    }
    static getById(id, appObjs) {
        return appObjs.get(id)?.getComponent(this.type);
    }
}
exports.DeleteLandmarkUC = DeleteLandmarkUC;
DeleteLandmarkUC.type = "DeleteLandmarkUC";
function makeDeleteLandmarkUC(appObject) {
    return new DeleteLandmarkUCImp(appObject);
}
class DeleteLandmarkUCImp extends DeleteLandmarkUC {
    get landmark() {
        return this.getCachedLocalComponent(Entities_1.LandmarkEntity.type);
    }
    constructor(appObject) {
        super(appObject, DeleteLandmarkUC.type);
        this.deleteLandmark = () => {
            if (!this.landmark)
                return;
            new DeleteLandmarkUndoRedo_1.DeleteLandmarkUndoRedo(this.landmark.data, this.appObjects);
            this.landmark.inRepo?.deleteLandmark(this.landmark.id);
            (0, Dispatcher_1.dispatchStateChange)(this.appObjects);
        };
    }
}
//# sourceMappingURL=DeleteLandmarkUC.js.map