import { TryShowHoverLabel } from "../UseCases/TryShowHoverLabel";
import { HoverLabelEntity } from "../Entities/HoverLabelEntity";
import { AppObjectController } from "@vived/core";
import { MouseInputEntity, } from "../../MouseInput";
export class HoverLabelMouse extends AppObjectController {
}
HoverLabelMouse.type = "Mouse_HoverLabel_Controller";
export function makeHoverLabelMouse(appObject) {
    return new HoverLabelMouseImp(appObject);
}
class HoverLabelMouseImp extends HoverLabelMouse {
    constructor(appObject) {
        super(appObject, HoverLabelMouse.type);
        this.hoverLabelDelay = 500;
        this.allow = (e) => {
            return true;
        };
        this.onMove = (e) => {
            if (!this.allow(e))
                return;
            if (!this.hoverLabelEntity)
                return;
            if (!this.tryShowHoverLabel)
                return;
            this.hoverLabelEntity.hideHoverLabel();
            if (this.currentTimeout) {
                clearTimeout(this.currentTimeout);
            }
            this.currentTimeout = setTimeout(() => {
                this.tryShowHoverLabel?.tryShowScreenHoverLabel(e.position);
                this.currentTimeout = undefined;
            }, this.hoverLabelDelay);
        };
        this.hoverLabelEntity = this.appObject.getComponent(HoverLabelEntity.type);
        if (!this.hoverLabelEntity) {
            this.warn("Serializer has been added to an App Object that does not have a HoverLabelEntity. Add the Entity first");
            return;
        }
        this.tryShowHoverLabel = TryShowHoverLabel.get(this.appObjects);
        if (!this.tryShowHoverLabel) {
            this.warn("Unable to find TryShowHoverLabel UC");
            return;
        }
        const mouseInput = MouseInputEntity.get(this.appObjects);
        if (mouseInput) {
            mouseInput.registerController(this);
        }
        else {
            this.warn("Unable to find MouseInputEntity");
        }
    }
}
//# sourceMappingURL=HoverLabelMouse.js.map