import { FilterValueFormatter , GeoBoundingBoxFilter , FILTERS , isGeoBoundingBoxFilter , Filter , } from '../../../../../common' ; const getFormattedValueFn = ( params ) => { return ( formatter ? ) => { const corners = formatter ? { topLeft : formatter . convert ( params . top_left ) , bottomRight : formatter . convert ( params . bottom_right ) , } : { topLeft : JSON . stringify ( params . top_left ) , bottomRight : JSON . stringify ( params . bottom_right ) , } ; return corners . topLeft + ' to ' + corners . bottomRight ; } ; } ; const getParams = ( filter ) => { const key = Object . keys ( filter . geo_bounding_box ) . filter ( ( k ) => k !== 'ignore_unmapped' ) [ 0 ] ; const params = filter . geo_bounding_box [ key ] ; return { key , params , type : FILTERS . GEO_BOUNDING_BOX , value : getFormattedValueFn ( params ) , } ; } ; export const mapGeoBoundingBox = ( filter ) => { if ( ! isGeoBoundingBoxFilter ( filter ) ) { throw filter ; } return getParams ( filter ) ; } ;