import { HighlightScope } from "../../ts-types";

import { clearColHover, updateColHover } from "./col";

import { clearRowHover, updateRowHover } from "./row";

import { clearSingleHover, updateSingleHover } from "./single";

export function updateHoverPosition(state, col, row) {
    var _a;
    const {table: table} = state, {scenegraph: scenegraph} = table, {highlightScope: highlightScope, singleStyle: singleStyle, disableHeader: disableHeader, cellPos: cellPos, cellPosContainHeader: cellPosContainHeader} = state.hover, prevHoverCellCol = cellPos.col, prevHoverCellRow = cellPos.row;
    if (highlightScope === HighlightScope.none || disableHeader && (cellPosContainHeader.col !== col || cellPosContainHeader.row !== row)) {
        const prevHoverCellCol = cellPosContainHeader.col, prevHoverCellRow = cellPosContainHeader.row;
        scenegraph.hideHoverIcon(prevHoverCellCol, prevHoverCellRow), scenegraph.showHoverIcon(col, row), 
        cellPosContainHeader.col = col, cellPosContainHeader.row = row;
    }
    if ((disableHeader && table.isHeader(col, row) || highlightScope === HighlightScope.none) && (col = -1, 
    row = -1), prevHoverCellCol === col && prevHoverCellRow === row) return;
    cellPos.col = col, cellPos.row = row, (null === (_a = state.table.options.customConfig) || void 0 === _a ? void 0 : _a.disableBuildInChartActive) || (scenegraph.deactivateChart(prevHoverCellCol, prevHoverCellRow), 
    scenegraph.activateChart(col, row));
    let updateScenegraph = !1;
    const {ranges: ranges, highlightScope: selectMode} = state.select;
    if (-1 !== prevHoverCellCol && -1 !== prevHoverCellRow && (updateScenegraph = clearHover(scenegraph, prevHoverCellCol, prevHoverCellRow, ranges, singleStyle, highlightScope, selectMode), 
    disableHeader || scenegraph.hideHoverIcon(prevHoverCellCol, prevHoverCellRow)), 
    -1 === col || -1 === row) return cellPos.col = -1, cellPos.row = -1, void (!updateScenegraph || prevHoverCellCol === col && prevHoverCellRow === row || state.table.scenegraph.updateNextFrame());
    highlightScope === HighlightScope.single ? updateScenegraph = !!updateSingleHover(scenegraph, col, row, ranges, selectMode) || updateScenegraph : highlightScope === HighlightScope.row ? updateScenegraph = !!updateRowHover(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph : highlightScope === HighlightScope.column ? updateScenegraph = !!updateColHover(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph : highlightScope === HighlightScope.cross && (updateScenegraph = !!updateRowHover(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph, 
    updateScenegraph = !!updateColHover(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph), 
    highlightScope === HighlightScope.none || disableHeader || scenegraph.showHoverIcon(col, row), 
    updateScenegraph && state.table.scenegraph.updateNextFrame();
}

function clearHover(scenegraph, col, row, selectRanges, singleStyle, mode, selectMode) {
    let updateScenegraph = !1;
    return mode === HighlightScope.single ? updateScenegraph = !!clearSingleHover(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph : mode === HighlightScope.row ? updateScenegraph = !!clearRowHover(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph : mode === HighlightScope.column ? updateScenegraph = !!clearColHover(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph : mode === HighlightScope.cross && (updateScenegraph = !!clearRowHover(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph, 
    updateScenegraph = !!clearColHover(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph), 
    updateScenegraph;
}
//# sourceMappingURL=update-position.js.map
