import { AppObjectController } from "@vived/core";
import { MouseInputEntity, } from "../../../MouseInput";
import { TryPanTransformUC } from "../../UC/TryPanTransformUC";
export class MousePanTransformMC extends AppObjectController {
    get mouseInput() {
        return this.getCachedSingleton(MouseInputEntity.type);
    }
    get tryScreenDragUC() {
        return this.getCachedLocalComponent(TryPanTransformUC.type);
    }
    constructor(appObject) {
        super(appObject, MousePanTransformMC.type);
        this.allow = (e) => {
            if (e.button !== 0)
                return false;
            return true;
        };
        this.isDragging = false;
        this.onDown = (e) => {
            if (this.isDragging) {
                this.tryScreenDragUC?.cancel();
                this.isDragging = false;
            }
            if (!this.allow(e)) {
                return;
            }
            this.isDragging = this.tryScreenDragUC?.tryWithPixel(e.position) ?? false;
        };
        this.onMove = (e) => {
            if (!this.isDragging)
                return;
            this.tryScreenDragUC?.moveWithPixel(e.position);
        };
        this.onUp = () => {
            if (!this.isDragging)
                return;
            this.tryScreenDragUC?.stop();
            this.isDragging = false;
        };
        this.mouseInput?.registerController(this);
    }
}
MousePanTransformMC.type = "MousePanTransformMC";
//# sourceMappingURL=MousePanTransformMC.js.map