import { a as sortByDeliverySpeedEstimate } from './sortQuotesByDeliverySpeedEstimate-f8c8a1b8.js';

const defaultCountryForCurrency = {
  AED: 'AE',
  AFN: 'AF',
  ALL: 'AL',
  AMD: 'AM',
  ANG: 'AN',
  AOA: 'AO',
  ARS: 'AR',
  AUD: 'AU',
  AZN: 'AZ',
  BAM: 'BA',
  BBD: 'BB',
  BDT: 'BD',
  BGN: 'BG',
  BHD: 'BH',
  BIF: 'BI',
  BMD: 'BM',
  BND: 'BN',
  BOB: 'BO',
  BRL: 'BR',
  BSD: 'BS',
  BWP: 'BW',
  BYR: 'BY',
  BZD: 'BZ',
  CAD: 'CA',
  CDF: 'CD',
  CHF: 'CH',
  CLP: 'CL',
  CNY: 'CN',
  COP: 'CO',
  CRC: 'CR',
  CUP: 'CU',
  CVE: 'CV',
  CZK: 'CZ',
  DJF: 'DJ',
  DKK: 'DK',
  DOP: 'DO',
  DZD: 'DZ',
  EGP: 'EG',
  ETB: 'ET',
  EUR: 'DE',
  FJD: 'FJ',
  FKP: 'FK',
  GBP: 'GB',
  GEL: 'GE',
  GHS: 'GH',
  GIP: 'GI',
  GMD: 'GM',
  GNF: 'GN',
  GTQ: 'GT',
  GYD: 'GY',
  HKD: 'HK',
  HNL: 'HN',
  HRK: 'HR',
  HTG: 'HT',
  HUF: 'HU',
  IDR: 'ID',
  ILS: 'IL',
  INR: 'IN',
  IQD: 'IQ',
  IRR: 'IR',
  ISK: 'IS',
  JMD: 'JM',
  JOD: 'JO',
  JPY: 'JP',
  KES: 'KE',
  KGS: 'KG',
  KHR: 'KH',
  KMF: 'KM',
  KPW: 'KP',
  KRW: 'KR',
  KWD: 'KW',
  KYD: 'KY',
  KZT: 'KZ',
  LAK: 'LA',
  LBP: 'LB',
  LKR: 'LK',
  LRD: 'LR',
  LSL: 'LS',
  LYD: 'LY',
  MAD: 'MA',
  MDL: 'MD',
  MGA: 'MG',
  MKD: 'MK',
  MMK: 'MM',
  MNT: 'MN',
  MOP: 'MO',
  MRO: 'MR',
  MUR: 'MU',
  MVR: 'MV',
  MWK: 'MW',
  MXN: 'MX',
  MYR: 'MY',
  MZN: 'MZ',
  NAD: 'NA',
  NGN: 'NG',
  NIO: 'NI',
  NOK: 'NO',
  NPR: 'NP',
  NZD: 'NZ',
  OMR: 'OM',
  PAB: 'PA',
  PEN: 'PE',
  PGK: 'PG',
  PHP: 'PH',
  PKR: 'PK',
  PLN: 'PL',
  PYG: 'PY',
  QAR: 'QA',
  RON: 'RO',
  RSD: 'RS',
  RUB: 'RU',
  RWF: 'RW',
  SAR: 'SA',
  SBD: 'SB',
  SCR: 'SC',
  SDG: 'SD',
  SEK: 'SE',
  SGD: 'SG',
  SLL: 'SL',
  SOS: 'SO',
  SRD: 'SR',
  STD: 'ST',
  SVC: 'SV',
  SYP: 'SY',
  SZL: 'SZ',
  THB: 'TH',
  TJS: 'TJ',
  TMT: 'TM',
  TND: 'TN',
  TOP: 'TO',
  TRY: 'TR',
  TTD: 'TT',
  TWD: 'TW',
  TZS: 'TZ',
  UAH: 'UA',
  UGX: 'UG',
  USD: 'US',
  UYU: 'UY',
  UZS: 'UZ',
  VES: 'VE',
  VND: 'VN',
  VUV: 'VU',
  XAF: 'CM',
  XCD: 'AI',
  XOF: 'BJ',
  XPF: 'PF',
  YER: 'YE',
  ZAR: 'ZA',
  ZMK: 'ZM',
  ZWD: 'ZW'
};
function getDefaultCountryForCurrency(currency) {
  return defaultCountryForCurrency[currency];
}

function findHighestReceivedAmount(quotes) {
  const [quoteWithHighestReceivedAmount] = quotes.sort((a, b) => b.receivedAmount - a.receivedAmount);
  return quoteWithHighestReceivedAmount.receivedAmount;
}
function allQuotesWithHighestReceivedAmount(quotes) {
  const receivedAmount = findHighestReceivedAmount(quotes);
  return quotes.filter(q => q.receivedAmount === receivedAmount);
}
function findDefaultCurrencyCountry(quotes, targetCurrency) {
  return quotes.find(q => q.targetCountry === getDefaultCountryForCurrency(targetCurrency)) || quotes[0];
}
function extractQuote(quotes, targetCurrency) {
  const quotesWithHighestReceivedAmount = allQuotesWithHighestReceivedAmount([...quotes]);
  const quotesWithFastestDeliverySpeedEstimate = sortByDeliverySpeedEstimate(quotesWithHighestReceivedAmount);
  return findDefaultCurrencyCountry(quotesWithFastestDeliverySpeedEstimate, targetCurrency);
}

export { extractQuote as e };
//# sourceMappingURL=extractQuote-aa1e3309.js.map
