import countries from '../../data/countries.mjs';
import { longestMatchingPrefix } from '../longestMatchingPrefix/index.mjs';

const findCountryByCode = code => {
  if (code.length === 2) {
    const matchingCodes = countries.filter(country => code.toUpperCase() === country.iso2);
    if (matchingCodes.length > 0) {
      return longestMatchingPrefix(matchingCodes);
    }
  }
  return null;
};

export { findCountryByCode };
//# sourceMappingURL=index.mjs.map
