"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TouchObjectPickTC = void 0;
const core_1 = require("@vived/core");
const BaseAppState_1 = require("../../BaseApp/Entity/BaseAppState");
const TouchInput_1 = require("../../TouchController/Entities/TouchInput");
const TrySelectObjectPickUC_1 = require("../UseCases/TrySelectObjectPickUC");
const TrySubmitObjectPickUC_1 = require("../UseCases/TrySubmitObjectPickUC");
class TouchObjectPickTC extends core_1.AppObjectController {
    get baseApp() {
        return this.getCachedSingleton(BaseAppState_1.BaseAppState.type);
    }
    get touchInput() {
        return this.getCachedSingleton(TouchInput_1.TouchInputEntity.type);
    }
    get trySelectObjectPick() {
        return this.getCachedSingleton(TrySelectObjectPickUC_1.TrySelectObjectPickUC.type)?.tryWithPixel;
    }
    get trySubmitObjectPick() {
        return this.getCachedSingleton(TrySubmitObjectPickUC_1.TrySubmitObjectPickUC.type)?.tryWithPixel;
    }
    constructor(appObject) {
        super(appObject, TouchObjectPickTC.type);
        this.onTap = (e) => {
            if (!this.trySelectObjectPick || !this.trySubmitObjectPick)
                return;
            if (this.baseApp?.isAuthoring) {
                this.trySelectObjectPick(e.touchCenter);
            }
            else {
                this.trySubmitObjectPick(e.touchCenter);
            }
        };
        this.touchInput?.registerController(this);
    }
}
exports.TouchObjectPickTC = TouchObjectPickTC;
TouchObjectPickTC.type = "TouchObjectPickTC";
//# sourceMappingURL=TouchObjectPickTC.js.map