import { AnchorPosition } from '../../../../components/portal/types' ; import { GlobalChartState } from '../../../../state/chart_state' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { computeChartElementSizesSelector } from './compute_chart_dimensions' ; import { getPickedShapes } from './picked_shapes' ; function getCurrentPointerPosition ( state ) { return state . interactions . pointer . current . position ; } internal export const getTooltipAnchorSelector = createCustomCachedSelector ( [ getPickedShapes , computeChartElementSizesSelector , getCurrentPointerPosition ] , ( shapes , { grid } , position ) : AnchorPosition => { if ( Array . isArray ( shapes ) && shapes . length > 0 ) { const firstShape = shapes [ 0 ] ; return { x : firstShape . x + grid . left , width : firstShape . width , y : firstShape . y - grid . top , height : firstShape . height , } ; } return { x : position . x , width : 0 , y : position . y , height : 0 , } ; } ) ;