import type { EMSClient } from '@elastic/ems-client' ; import type { EMSSettings } from '../../common' ; let lazyLoaded ; export async function createEMSClientLazy ( emsSettings , version ) { if ( lazyLoaded ) { return await lazyLoaded ( emsSettings , version ) ; } lazyLoaded = await new Promise ( async ( resolve , reject ) => { try { try { const { createEMSClient } = await import ( './create_ems_client' ) ; resolve ( createEMSClient ) ; } catch ( error ) { reject ( error ) ; } } catch ( error ) { reject ( error ) ; } } ) ; return await lazyLoaded ( emsSettings , version ) ; }