/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { Point } from "@vertexvis/geometry";
import { toProtoDuration } from "@vertexvis/stream-api";
export class FlyToPartKeyInteraction {
    constructor(stream, configProvider, imageScaleProvider) {
        this.stream = stream;
        this.configProvider = configProvider;
        this.imageScaleProvider = imageScaleProvider;
    }
    predicate(e) {
        return e.altKey && !e.shiftKey;
    }
    async fn(e) {
        var _a;
        const scale = this.imageScaleProvider();
        const hitResult = await this.stream.hitItems({
            point: Point.scale(e.position, (scale === null || scale === void 0 ? void 0 : scale.x) || 1, (scale === null || scale === void 0 ? void 0 : scale.y) || 1),
        }, true);
        if (((_a = hitResult.hitItems) === null || _a === void 0 ? void 0 : _a.hits) != null &&
            hitResult.hitItems.hits.length > 0) {
            await this.stream.flyTo({
                itemId: hitResult.hitItems.hits[0].itemId,
                animation: {
                    duration: toProtoDuration(this.configProvider().animation.durationMs),
                },
            });
        }
        else {
            console.debug(`No hit results found for fly to part [position={x: ${e.position.x}, y: ${e.position.y}}]`);
        }
    }
}
//# sourceMappingURL=flyToPartKeyInteraction.js.map
