import { i18n } from '@osd/i18n' ; import { OSD_FIELD_TYPES } from '../../osd_field_types/types' ; import { FieldFormat } from '../field_format' ; import { TextContextTypeConvert , FIELD_FORMAT_IDS } from '../types' ; export class IpFormat extends FieldFormat { static id = FIELD_FORMAT_IDS . IP ; static title = i18n . translate ( 'data.fieldFormats.ip.title' , { defaultMessage : 'IP address' , } ) ; static fieldType = OSD_FIELD_TYPES . IP ; textConvert : TextContextTypeConvert = ( val ) => { if ( val === undefined || val === null ) return '-' ; if ( ! isFinite ( val ) ) return val ; return [ val >>> 24 , ( val >>> 16 ) & 0xff , ( val >>> 8 ) & 0xff , val & 0xff ] . join ( '.' ) ; } ; }