import { isFacetFilter } from '@empathyco/x-types' ; import { groupItemsBy } from '../../../../utils/array' ; import { map } from '../../../../utils/object' ; import { FacetsXStoreModule } from '../types' ; /**
 * Default implementation for the  FacetsGetters . facets getter.
 *
 *  param state - Current  https of the facets
 * module.
 *  returns public export const facets = state => { const filtersByFacet = groupItemsBy ( Object . values ( state . filters ) , filter => isFacetFilter ( filter ) ? filter . facetId : '__unknown-facet__' ) ; return map ( state . facets , ( _id , facet ) => ( { ... facet , filters : filtersByFacet [ facet . id ] ?? [ ] } ) ) ; } ;