import { EMSClient , FileLayer , TMSService } from '@elastic/ems-client' ; import { FONTS_API_PATH } from '../common/constants' ; import { getHttp , getTilemap , getEMSSettings , getMapsEmsStart } from './kibana_services' ; import { getLicenseId } from './licensed_features' ; export function getKibanaTileMap ( ) { return getTilemap ( ) ; } export async function getEmsFileLayers ( ) { if ( ! getEMSSettings ( ) . isEMSEnabled ( ) ) { return [ ] ; } return ( await getEMSClient ( ) ) . getFileLayers ( ) ; } export async function getEmsTmsServices ( ) { if ( ! getEMSSettings ( ) . isEMSEnabled ( ) ) { return [ ] ; } return ( await getEMSClient ( ) ) . getTMSServices ( ) ; } let emsClient = null ; let latestLicenseId ; async function getEMSClient ( ) { if ( ! emsClient ) { emsClient = await getMapsEmsStart ( ) . createEMSClient ( ) ; } const licenseId = getLicenseId ( ) ; if ( latestLicenseId !== licenseId ) { latestLicenseId = licenseId ; emsClient . addQueryParams ( { license : licenseId ? licenseId : '' } ) ; } return emsClient ; } export function getGlyphUrl ( ) { const emsSettings = getEMSSettings ( ) ; if ( ! emsSettings ! . isEMSEnabled ( ) ) { return getHttp ( ) . basePath . prepend ( `/${ FONTS_API_PATH }/{fontstack}/{range}` ) ; } return emsSettings ! . getEMSFontLibraryUrl ( ) ; } export function isRetina ( ) { return window . devicePixelRatio === 2 ; }