import { AppObjectController } from "@vived/core";
import { MouseInputEntity, } from "../../MouseInput";
import { ToolRepository, ToolState } from "../../Tools";
import { DragScaleSceneRootUC } from "../UC/DragScaleSceneRoot";
export class MouseScale extends AppObjectController {
    get dragScaleRootUC() {
        return this.getCachedLocalComponent(DragScaleSceneRootUC.type);
    }
    get toolRepo() {
        return this.getCachedSingleton(ToolRepository.type);
    }
    constructor(appObject) {
        super(appObject, MouseScale.type);
        this.isDollying = false;
        this.allow = (e) => {
            const zoomTool = this.toolRepo?.getTool("ZOOM");
            if (!zoomTool)
                return false;
            const zoomToolIsActive = zoomTool.state === ToolState.ACTIVE;
            if (e.button === 0 && zoomToolIsActive) {
                return true;
            }
            return false;
        };
        this.onDown = (e) => {
            this.isDollying = false;
            if (!this.allow(e))
                return;
            const pixelPosition = e.position;
            this.dragScaleRootUC?.initializeScale(pixelPosition);
            this.isDollying = true;
        };
        this.onMove = (e) => {
            if (!this.isDollying)
                return;
            this.dragScaleRootUC?.doScale(e.position);
        };
        this.onUp = () => {
            this.isDollying = false;
            this.dragScaleRootUC?.finishScaling();
        };
        const mouseInput = MouseInputEntity.get(this.appObjects);
        if (mouseInput) {
            mouseInput.registerController(this);
        }
        else {
            this.warn("Unable to find MouseInputEntity");
        }
    }
}
MouseScale.type = "MouseScale";
//# sourceMappingURL=MouseScale.js.map