import { DEFAULT_CSS_CURSOR } from '../../../../common/constants' ; import { GlobalChartState } from '../../../../state/chart_state' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_specs' ; import { computeChartDimensionsSelector } from './compute_chart_dimensions' ; import { getAnnotationTooltipStateSelector } from './get_annotation_tooltip_state' ; import { getProjectedScaledValues } from './get_projected_scaled_values' ; import { getHighlightedGeomsSelector } from './get_tooltip_values_highlighted_geoms' ; import { isBrushAvailableSelector } from './is_brush_available' ; const getCurrentPointerPositionSelector = ( state ) => state . interactions . pointer . current . position ; internal export const getPointerCursorSelector = createCustomCachedSelector ( [ getHighlightedGeomsSelector , getSettingsSpecSelector , getCurrentPointerPositionSelector , getProjectedScaledValues , computeChartDimensionsSelector , isBrushAvailableSelector , getAnnotationTooltipStateSelector , ] , ( highlightedGeometries , settingsSpec , currentPointerPosition , projectedValues , { chartDimensions } , isBrushAvailable , annotationTooltipState ) : string => { const { x , y } = currentPointerPosition ; const xPos = x - chartDimensions . left ; const yPos = y - chartDimensions . top ; if ( xPos < 0 || xPos >= chartDimensions . width || yPos < 0 || yPos >= chartDimensions . height ) { return DEFAULT_CSS_CURSOR ; } if ( highlightedGeometries . length > 0 && settingsSpec . onElementClick ) { return 'pointer' ; } if ( highlightedGeometries . length === 0 && settingsSpec . onAnnotationClick && annotationTooltipState ) { return 'pointer' ; } if ( projectedValues !== null && settingsSpec . onProjectionClick ) { return 'pointer' ; } return isBrushAvailable ? 'crosshair' : DEFAULT_CSS_CURSOR ; } ) ;