import { AppObjectController } from "@vived/core";
import { TouchInputEntity, } from "../../TouchController";
import { TryAddCalloutUC } from "../UC/TryAddCallout";
export class TouchAddCalloutTC extends AppObjectController {
    get tryAddCalloutUc() {
        return this.getCachedSingleton(TryAddCalloutUC.type);
    }
    get touchInput() {
        return this.getCachedSingleton(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);
    }
}
TouchAddCalloutTC.type = "TouchAddCalloutTC";
//# sourceMappingURL=TouchAddCalloutTC.js.map