function getPreSelectedCountry({
	value,
	phoneNumber,
	defaultCountry,
	getAnyCountry,
	countries,
	required,
	metadata
}) {
	let country

	// If can get country from E.164 phone number
	// then it overrides the `country` passed (or not passed).
	if (phoneNumber && phoneNumber.country) {
		// `country` will be left `undefined` in case of non-detection.
		country = phoneNumber.country
	} else if (defaultCountry) {
		if (!value || couldNumberBelongToCountry(value, defaultCountry, metadata)) {
			country = defaultCountry
		}
	}

	// Only pre-select a country if it's in the available `countries` list.
	if (countries && countries.indexOf(country) < 0) {
		country = undefined
	}

	// If there will be no "International" option
	// then some `country` must be selected.
	// It will still be the wrong country though.
	// But still country `<select/>` can't be left in a broken state.
	if (!country && required && countries && countries.length > 0) {
		country = getAnyCountry()
		// noCountryMatchesTheNumber = true
	}

	return country
}
Decides which country should be pre-selected
when the phone number input component is first mounted.
@param  {object?} phoneNumber - An instance of `PhoneNumber` class.
@param  {string?} country - Pre-defined country (two-letter code).
@param  {string[]?} countries - A list of countries available.
@param  {object} metadata - `libphonenumber-js` metadata
@return {string?}