"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TouchAddCalloutTC = void 0;
const core_1 = require("@vived/core");
const TouchController_1 = require("../../TouchController");
const TryAddCallout_1 = require("../UC/TryAddCallout");
class TouchAddCalloutTC extends core_1.AppObjectController {
    get tryAddCalloutUc() {
        return this.getCachedSingleton(TryAddCallout_1.TryAddCalloutUC.type);
    }
    get touchInput() {
        return this.getCachedSingleton(TouchController_1.TouchInputEntity.type);
    }
    constructor(appObject) {
        super(appObject, TouchAddCalloutTC.type);
        this.isAdding = false;
        this.onTouchStart = (e) => {
            if (e.touchCount > 1) {
                if (this.isAdding) {
                    this.tryAddCalloutUc?.cancel();
                }
                this.isAdding = false;
                return;
            }
            this.isAdding =
                this.tryAddCalloutUc?.initializeWithPixel(e.touchCenter) ?? false;
        };
        this.onTouchMove = (e) => {
            if (!this.isAdding)
                return;
            this.tryAddCalloutUc?.moveWithPixel(e.touchCenter);
        };
        this.onTouchEnd = () => {
            if (!this.isAdding)
                return;
            this.tryAddCalloutUc?.stop();
            this.isAdding = false;
        };
        this.touchInput?.registerController(this);
    }
}
exports.TouchAddCalloutTC = TouchAddCalloutTC;
TouchAddCalloutTC.type = "TouchAddCalloutTC";
//# sourceMappingURL=TouchAddCalloutTC.js.map