"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "singleScrollStrategy", {
    enumerable: true,
    get: function() {
        return singleScrollStrategy;
    }
});
const _utils = require("../utils");
function singleScrollStrategy(hot) {
    return (cellCoords)=>{
        const selectionSource = hot.selection.getSelectionSource();
        const { row, col } = cellCoords;
        const scrollWindow = ()=>{
            (0, _utils.scrollWindowToCell)(hot.getCell(row, col, true));
        };
        // navigating through the column headers (when `navigableHeaders` is enabled)
        // scrolls the viewport horizontally only
        if (row < 0 && col >= 0) {
            hot.scrollViewportTo({
                col
            }, scrollWindow);
        // navigating through the row headers (when `navigableHeaders` is enabled)
        // scrolls the viewport vertically only
        } else if (col < 0 && row >= 0) {
            hot.scrollViewportTo({
                row
            }, scrollWindow);
        // navigating through the cells
        } else {
            if (selectionSource === 'mouse') {
                if (col === hot.view.getLastPartiallyVisibleColumn() || row === hot.view.getLastPartiallyVisibleRow()) {
                    return;
                }
            }
            hot.scrollViewportTo({
                row,
                col
            }, scrollWindow);
        }
    };
}
