import { LegendItem } from '../../../../common/legend' ; import { createCustomCachedSelector } from '../../../../state/create_selector' ; import { getDeselectedSeriesSelector } from '../../../../state/selectors/get_deselected_data_series' ; import { getColorScale } from './get_color_scale' ; import { getSpecOrNull } from './heatmap_spec' ; import { isEmptySelector } from './is_empty' ; const EMPTY_LEGEND = [ ] ; internal export const computeLegendSelector = createCustomCachedSelector ( [ getSpecOrNull , getColorScale , getDeselectedSeriesSelector , isEmptySelector ] , ( spec , { bands } , deselectedDataSeries , empty ) : LegendItem [ ] => { if ( spec === null || empty ) { return EMPTY_LEGEND ; } return bands . map ( ( { label , color } ) => { return { seriesIdentifiers : [ { key : label , specId : label } ] , color , label , isSeriesHidden : deselectedDataSeries . some ( ( dataSeries ) => dataSeries . key === label ) , isToggleable : true , path : [ { index : 0 , value : label } ] , keys : [ ] , } ; } ) ; } ) ;