import { TooltipInfo } from '../../../../components/tooltip/types' ; import { getTooltipType } from '../../../../specs' ; import { TooltipType } from '../../../../specs/constants' ; import { GlobalChartState , PointerStates } from '../../../../state/chart_state' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getSettingsSpecSelector } from '../../../../state/selectors/get_settings_specs' ; import { isExternalTooltipVisibleSelector } from '../../../../state/selectors/is_external_tooltip_visible' ; import { Point } from '../../../../utils/point' ; import { getProjectedPointerPositionSelector } from './get_projected_pointer_position' ; import { getTooltipInfoSelector } from './get_tooltip_values_highlighted_geoms' ; import { isAnnotationTooltipVisibleSelector } from './is_annotation_tooltip_visible' ; const getTooltipTypeSelector = ( state ) : TooltipType => getTooltipType ( getSettingsSpecSelector ( state ) ) ; const getPointerSelector = ( state ) => state . interactions . pointer ; internal export const isTooltipVisibleSelector = createCustomCachedSelector ( [ getTooltipTypeSelector , getPointerSelector , getProjectedPointerPositionSelector , getTooltipInfoSelector , isAnnotationTooltipVisibleSelector , isExternalTooltipVisibleSelector , ] , isTooltipVisible ) ; function isTooltipVisible ( tooltipType , pointer , projectedPointerPosition , tooltip , isAnnotationTooltipVisible , externalTooltipVisible ) { const isLocalTooltip = tooltipType !== TooltipType . None && pointer . down === null && projectedPointerPosition . x > - 1 && projectedPointerPosition . y > - 1 && tooltip . values . length > 0 && ! isAnnotationTooltipVisible ; const isExternalTooltip = externalTooltipVisible && tooltip . values . length > 0 ; return { visible : isLocalTooltip || isExternalTooltip , isExternal : externalTooltipVisible , } ; }