import { TooltipInfo } from '../../../../components/tooltip/types' ; import { DOMElement } from '../../../../state/actions/dom_element' ; import { GlobalChartState } from '../../../../state/chart_state' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getChartRotationSelector } from '../../../../state/selectors/get_chart_rotation' ; import { Rotation } from '../../../../utils/common' ; import { Dimensions } from '../../../../utils/dimensions' ; import { AnnotationId } from '../../../../utils/ids' ; import { Point } from '../../../../utils/point' ; import { computeMultipleRectAnnotationTooltipState } from '../../annotations/tooltip' ; import { AnnotationTooltipState , AnnotationDimensions } from '../../annotations/types' ; import { AxisSpec , AnnotationSpec , AnnotationType } from '../../utils/specs' ; import { ComputedGeometries } from '../utils/types' ; import { computeAnnotationDimensionsSelector } from './compute_annotations' ; import { computeChartDimensionsSelector } from './compute_chart_dimensions' ; import { computeSeriesGeometriesSelector } from './compute_series_geometries' ; import { getTooltipStateForDOMElements } from './get_annotation_tooltip_state' ; import { getAxisSpecsSelector , getAnnotationSpecsSelector } from './get_specs' ; import { getTooltipInfoSelector } from './get_tooltip_values_highlighted_geoms' ; const getCurrentPointerPosition = ( state ) => state . interactions . pointer . current . position ; const getHoveredDOMElement = ( state ) => state . interactions . hoveredDOMElement ; internal export const getMultipleRectangleAnnotations = createCustomCachedSelector ( [ getCurrentPointerPosition , computeChartDimensionsSelector , computeSeriesGeometriesSelector , getChartRotationSelector , getAnnotationSpecsSelector , getAxisSpecsSelector , computeAnnotationDimensionsSelector , getTooltipInfoSelector , getHoveredDOMElement , ] , getMultipleRectangularAnnotationTooltipState ) ; function getMultipleRectangularAnnotationTooltipState ( cursorPosition , { chartDimensions , } , geometries , chartRotation , annotationSpecs , axesSpecs , annotationDimensions , tooltip , hoveredDOMElement ) { const hoveredTooltip = getTooltipStateForDOMElements ( chartDimensions , annotationSpecs , annotationDimensions , hoveredDOMElement ) ; if ( hoveredTooltip ) { return [ hoveredTooltip ] ; } const tooltipState = computeMultipleRectAnnotationTooltipState ( cursorPosition , annotationDimensions , annotationSpecs , chartRotation , chartDimensions ) ; const isChartTooltipDisplayed = tooltip . values . some ( ( { isHighlighted } ) => isHighlighted ) ; tooltipState ?. forEach ( ( rectAnnotation ) => { if ( tooltipState && rectAnnotation . isVisible && rectAnnotation . annotationType === AnnotationType . Rectangle && isChartTooltipDisplayed ) { return null ; } } ) ; return tooltipState ; }