"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSelectOnFocus = void 0;
var scroll_1 = require("../../utils/scroll");
var tiles_1 = require("../../utils/tiles");
exports.useSelectOnFocus = function (containerRef, onSelect) {
    var scrollFocusedElementIntoView = function (evt) {
        if (!containerRef.current)
            return;
        var container = containerRef.current;
        var tiles = tiles_1.getTiles(container);
        var focusedNum = tiles.findIndex(function (tile) { return tile.contains(evt.target); });
        scroll_1.scrollToCenter(container, tiles[focusedNum]);
        onSelect(focusedNum);
    };
    return {
        onFocus: scrollFocusedElementIntoView
    };
};
