import _extends from "@babel/runtime-corejs3/helpers/extends";
import { isLeafNode, makeRecursiveMapper, mergeCellProps } from '../../utils';
export function mergeCellHover() {
  return function (pipeline) {
    var onMouseEnter = function onMouseEnter(e) {
      var InRangeRow = pipeline.ref.current.domHelper.getInRangeRowByCellEvent(e);
      InRangeRow.forEach(function (row) {
        row.classList.add('row-hover');
      });
    };
    var onMouseLeave = function onMouseLeave(e) {
      var InRangeRow = pipeline.ref.current.domHelper.getInRangeRowByCellEvent(e);
      InRangeRow.forEach(function (row) {
        row.classList.remove('row-hover');
      });
    };
    var hoverHandlers = {
      onMouseEnter: onMouseEnter,
      onMouseLeave: onMouseLeave
    };
    return pipeline.mapColumns(makeRecursiveMapper(function (col) {
      if (!isLeafNode(col)) {
        return col;
      }
      var prevGetCellProps = col.getCellProps;
      return _extends(_extends({}, col), {
        getCellProps: function getCellProps(value, record, rowIndex) {
          // 大多数列没有自定义 getCellProps，直接返回静态 handlers 避免 mergeCellProps 开销
          if (!prevGetCellProps) return hoverHandlers;
          var prevCellProps = prevGetCellProps(value, record, rowIndex);
          if (!prevCellProps) return hoverHandlers;
          return mergeCellProps(prevCellProps, hoverHandlers);
        }
      });
    }));
  };
}