{"version":3,"sources":["../source/PhoneInputWithCountry.js"],"names":["React","PropTypes","classNames","InputSmart","InputBasic","Flag","InternationalIcon","sortCountryOptions","isCountrySupportedWithError","getSupportedCountries","getSupportedCountryOptions","getCountries","createCountryIconComponent","metadata","metadataPropType","labels","labelsPropType","getPreSelectedCountry","getCountrySelectOptions","parsePhoneNumber","generateNationalNumberDigits","migrateParsedInputForNewCountry","getCountryForPartialE164Number","getInitialParsedInput","parseInput","e164","PhoneNumberInput_","props","createRef","country","newCountry","international","onChange","state","prevParsedInput","parsedInput","prevCountry","newParsedInput","newValue","getInputRef","current","focus","setState","hasUserSelectedACountry","value","_input","defaultCountry","addInternationalOption","limitMaxLength","countries","input","isFocused","event","_onFocus","onFocus","onBlur","_onBlur","countrySelectProps","countryOptionsOrder","undefined","phoneNumber","CountryIcon","generateInitialParsedInput","onCountryChange","selectedCountry","prevProps","prevState","inputRef","name","disabled","autoComplete","style","className","inputComponent","numberInputProps","smartCaret","CountrySelectComponent","countrySelectComponent","ContainerComponent","containerComponent","flags","flagComponent","flagUrl","internationalIcon","displayInitialValueAsLocalNumber","reset","rest","InputComponent","countrySelectOptions","useMemoCountrySelectOptions","onCountryFocus","onCountryBlur","prevDefaultCountry","prevValue","prevReset","newDefaultCountry","newReset","newState","parsedCountry","indexOf","PureComponent","PhoneNumberInput","forwardRef","ref","propTypes","string","func","isRequired","onKeyDown","bool","arrayOf","objectOf","elementType","object","defaultProps","any","countrySelectOptionsMemo","countrySelectOptionsMemoDependencies","generator","dependencies","areEqualArrays","a","b","length","i"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,iBAAP,MAA8B,qBAA9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QAAvC,CAA5B;AACA;;AAED,IAAIuG,wBAAJ;AACA,IAAIC,oCAAJ;;AACA,SAAS5B,2BAAT,CAAqC6B,SAArC,EAAgDC,YAAhD,EAA8D;AAC7D,MAAI,CAACF,oCAAD,IACH,CAACG,cAAc,CAACD,YAAD,EAAeF,oCAAf,CADhB,EACsE;AACrED,IAAAA,wBAAwB,GAAGE,SAAS,EAApC;AACAD,IAAAA,oCAAoC,GAAGE,YAAvC;AACA;;AACD,SAAOH,wBAAP;AACA;;AAED,SAASI,cAAT,CAAwBC,CAAxB,EAA2BC,CAA3B,EAA8B;AAC7B,MAAID,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAAnB,EAA2B;AAC1B,WAAO,KAAP;AACA;;AACD,MAAIC,CAAC,GAAG,CAAR;;AACA,SAAOA,CAAC,GAAGH,CAAC,CAACE,MAAb,EAAqB;AACpB,QAAIF,CAAC,CAACG,CAAD,CAAD,KAASF,CAAC,CAACE,CAAD,CAAd,EAAmB;AAClB,aAAO,KAAP;AACA;;AACDA,IAAAA,CAAC;AACD;;AACD,SAAO,IAAP;AACA","sourcesContent":["import React from 'react'\r\nimport PropTypes from 'prop-types'\r\nimport classNames from 'classnames'\r\n\r\nimport InputSmart from './InputSmart'\r\nimport InputBasic from './InputBasic'\r\n\r\nimport Flag from './Flag'\r\nimport InternationalIcon from './InternationalIcon'\r\n\r\nimport {\r\n\tsortCountryOptions,\r\n\tisCountrySupportedWithError,\r\n\tgetSupportedCountries,\r\n\tgetSupportedCountryOptions,\r\n\tgetCountries\r\n} from './countries'\r\n\r\nimport { createCountryIconComponent } from './CountryIcon'\r\n\r\nimport {\r\n\tmetadata as metadataPropType,\r\n\tlabels as labelsPropType\r\n} from './PropTypes'\r\n\r\nimport {\r\n\tgetPreSelectedCountry,\r\n\tgetCountrySelectOptions,\r\n\tparsePhoneNumber,\r\n\tgenerateNationalNumberDigits,\r\n\tmigrateParsedInputForNewCountry,\r\n\tgetCountryForPartialE164Number,\r\n\tgetInitialParsedInput,\r\n\tparseInput,\r\n\te164\r\n} from './phoneInputHelpers'\r\n\r\nclass PhoneNumberInput_ extends React.PureComponent {\r\n\tinputRef = React.createRef()\r\n\r\n\tconstructor(props) {\r\n\t\tsuper(props)\r\n\r\n\t\tconst {\r\n\t\t\tvalue,\r\n\t\t\tlabels,\r\n\t\t\taddInternationalOption,\r\n\t\t\tmetadata,\r\n\t\t\tcountryOptionsOrder\r\n\t\t} = this.props\r\n\r\n\t\tlet {\r\n\t\t\tdefaultCountry,\r\n\t\t\tcountries\r\n\t\t} = this.props\r\n\r\n\t\t// Validate `defaultCountry`.\r\n\t\tif (defaultCountry) {\r\n\t\t\tif (!this.isCountrySupportedWithError(defaultCountry)) {\r\n\t\t\t\tdefaultCountry = undefined\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Validate `countries`.\r\n\t\tcountries = getSupportedCountries(countries, metadata)\r\n\r\n\t\tconst phoneNumber = parsePhoneNumber(value, metadata)\r\n\r\n\t\tthis.CountryIcon = createCountryIconComponent(this.props)\r\n\r\n\t\tthis.state = {\r\n\t\t\t// Workaround for `this.props` inside `getDerivedStateFromProps()`.\r\n\t\t\tprops: this.props,\r\n\r\n\t\t\t// The country selected.\r\n\t\t\tcountry: getPreSelectedCountry(\r\n\t\t\t\tphoneNumber,\r\n\t\t\t\tdefaultCountry,\r\n\t\t\t\tcountries || getCountries(metadata),\r\n\t\t\t\taddInternationalOption,\r\n\t\t\t\tmetadata\r\n\t\t\t),\r\n\r\n\t\t\t// `countries` are stored in `this.state` because they're filtered.\r\n\t\t\t// For example, a developer might theoretically pass some unsupported\r\n\t\t\t// countries as part of the `countries` property, and because of that\r\n\t\t\t// the component uses `this.state.countries` (which are filtered)\r\n\t\t\t// instead of `this.props.countries`\r\n\t\t\t// (which could potentially contain unsupported countries).\r\n\t\t\tcountries,\r\n\r\n\t\t\t// `parsedInput` state property holds non-formatted user's input.\r\n\t\t\t// The reason is that there's no way of finding out\r\n\t\t\t// in which form should `value` be displayed: international or national.\r\n\t\t\t// E.g. if `value` is `+78005553535` then it could be input\r\n\t\t\t// by a user both as `8 (800) 555-35-35` and `+7 800 555 35 35`.\r\n\t\t\t// Hence storing just `value`is not sufficient for correct formatting.\r\n\t\t\t// E.g. if a user entered `8 (800) 555-35-35`\r\n\t\t\t// then value is `+78005553535` and `parsedInput` is `88005553535`\r\n\t\t\t// and if a user entered `+7 800 555 35 35`\r\n\t\t\t// then value is `+78005553535` and `parsedInput` is `+78005553535`.\r\n\t\t\tparsedInput: generateInitialParsedInput(value, phoneNumber, this.props),\r\n\r\n\t\t\t// `value` property is duplicated in state.\r\n\t\t\t// The reason is that `getDerivedStateFromProps()`\r\n\t\t\t// needs this `value` to compare to the new `value` property\r\n\t\t\t// to find out if `parsedInput` needs updating:\r\n\t\t\t// If the `value` property was changed externally\r\n\t\t\t// then it won't be equal to `state.value`\r\n\t\t\t// in which case `parsedInput` and `country` should be updated.\r\n\t\t\tvalue\r\n\t\t}\r\n\t}\r\n\r\n\tcomponentDidMount() {\r\n\t\tconst { onCountryChange } = this.props\r\n\t\tlet { defaultCountry } = this.props\r\n\t\tconst { country: selectedCountry } = this.state\r\n\t\tif (onCountryChange) {\r\n\t\t\tif (defaultCountry) {\r\n\t\t\t\tif (!this.isCountrySupportedWithError(defaultCountry)) {\r\n\t\t\t\t\tdefaultCountry = undefined\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (selectedCountry !== defaultCountry) {\r\n\t\t\t\tonCountryChange(selectedCountry)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tcomponentDidUpdate(prevProps, prevState) {\r\n\t\tconst { onCountryChange } = this.props\r\n\t\tconst { country } = this.state\r\n\t\t// Call `onCountryChange` when user selects another country.\r\n\t\tif (onCountryChange && country !== prevState.country) {\r\n\t\t\tonCountryChange(country)\r\n\t\t}\r\n\t}\r\n\r\n\t// A shorthand for not passing `metadata` as a second argument.\r\n\tisCountrySupportedWithError = (country) => {\r\n\t\tconst { metadata } = this.props\r\n\t\treturn isCountrySupportedWithError(country, metadata)\r\n\t}\r\n\r\n\t// Country `` `onChange` handler.\r\n\tonCountryChange = (newCountry) => {\r\n\t\tconst {\r\n\t\t\tinternational,\r\n\t\t\tmetadata,\r\n\t\t\tonChange\r\n\t\t} = this.props\r\n\r\n\t\tconst {\r\n\t\t\tparsedInput: prevParsedInput,\r\n\t\t\tcountry: prevCountry\r\n\t\t} = this.state\r\n\r\n\t\t// After the new `country` has been selected,\r\n\t\t// if the phone number `` holds any digits\r\n\t\t// then migrate those digits for the new `country`.\r\n\t\tconst newParsedInput = migrateParsedInputForNewCountry(\r\n\t\t\tprevParsedInput,\r\n\t\t\tprevCountry,\r\n\t\t\tnewCountry,\r\n\t\t\tmetadata,\r\n\t\t\t// Convert the phone number to \"national\" format\r\n\t\t\t// when the user changes the selected country by hand.\r\n\t\t\tinternational ? false : true\r\n\t\t)\r\n\r\n\t\tconst newValue = e164(newParsedInput, newCountry, metadata)\r\n\r\n\t\t// Focus phone number `` upon country selection.\r\n\t\tthis.getInputRef().current.focus()\r\n\r\n\t\t// If the user has already manually selected a country\r\n\t\t// then don't override that already selected country\r\n\t\t// if the `defaultCountry` property changes.\r\n\t\t// That's what `hasUserSelectedACountry` flag is for.\r\n\r\n\t\tthis.setState({\r\n\t\t\tcountry: newCountry,\r\n\t\t\thasUserSelectedACountry: true,\r\n\t\t\tparsedInput: newParsedInput,\r\n\t\t\tvalue: newValue\r\n\t\t},\r\n\t\t() => {\r\n\t\t\t// Update the new `value` property.\r\n\t\t\t// Doing it after the `state` has been updated\r\n\t\t\t// because `onChange()` will trigger `getDerivedStateFromProps()`\r\n\t\t\t// with the new `value` which will be compared to `state.value` there.\r\n\t\t\tonChange(newValue)\r\n\t\t})\r\n\t}\r\n\r\n\t/**\r\n\t * `` `onChange()` handler.\r\n\t * Updates `value` property accordingly (so that they are kept in sync).\r\n\t * @param {string?} input — Either a parsed phone number or an empty string. Examples: `\"\"`, `\"+\"`, `\"+123\"`, `\"123\"`.\r\n\t */\r\n\tonChange = (_input) => {\r\n\t\tconst {\r\n\t\t\tdefaultCountry,\r\n\t\t\tonChange,\r\n\t\t\taddInternationalOption,\r\n\t\t\tinternational,\r\n\t\t\tlimitMaxLength,\r\n\t\t\tmetadata\r\n\t\t} = this.props\r\n\r\n\t\tconst {\r\n\t\t\tinput,\r\n\t\t\tcountry,\r\n\t\t\tvalue\r\n\t\t} = parseInput(\r\n\t\t\t_input,\r\n\t\t\tthis.state.parsedInput,\r\n\t\t\tthis.state.country,\r\n\t\t\tdefaultCountry,\r\n\t\t\tthis.state.countries,\r\n\t\t\taddInternationalOption,\r\n\t\t\tinternational,\r\n\t\t\tlimitMaxLength,\r\n\t\t\tmetadata\r\n\t\t)\r\n\r\n\t\tthis.setState({\r\n\t\t\tparsedInput: input,\r\n\t\t\tvalue,\r\n\t\t\tcountry\r\n\t\t},\r\n\t\t// Update the new `value` property.\r\n\t\t// Doing it after the `state` has been updated\r\n\t\t// because `onChange()` will trigger `getDerivedStateFromProps()`\r\n\t\t// with the new `value` which will be compared to `state.value` there.\r\n\t\t() => onChange(value))\r\n\t}\r\n\r\n\t// Toggles the `--focus` CSS class.\r\n\t_onFocus = () => this.setState({ isFocused: true })\r\n\r\n\t// Toggles the `--focus` CSS class.\r\n\t_onBlur = () => this.setState({ isFocused: false })\r\n\r\n\tonFocus = (event) => {\r\n\t\tthis._onFocus()\r\n\t\tconst { onFocus } = this.props\r\n\t\tif (onFocus) {\r\n\t\t\tonFocus(event)\r\n\t\t}\r\n\t}\r\n\r\n\tonBlur = (event) => {\r\n\t\tconst { onBlur } = this.props\r\n\t\tthis._onBlur()\r\n\t\tif (onBlur) {\r\n\t\t\tonBlur(event)\r\n\t\t}\r\n\t}\r\n\r\n\tonCountryFocus = (event) => {\r\n\t\tthis._onFocus()\r\n\t\t// this.setState({ countrySelectFocused: true })\r\n\t\tconst { countrySelectProps } = this.props\r\n\t\tif (countrySelectProps) {\r\n\t\t\tconst { onFocus } = countrySelectProps\r\n\t\t\tif (onFocus) {\r\n\t\t\t\tonFocus(event)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tonCountryBlur = (event) => {\r\n\t\tthis._onBlur()\r\n\t\t// this.setState({ countrySelectFocused: false })\r\n\t\tconst { countrySelectProps } = this.props\r\n\t\tif (countrySelectProps) {\r\n\t\t\tconst { onBlur } = countrySelectProps\r\n\t\t\tif (onBlur) {\r\n\t\t\t\tonBlur(event)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetInputRef() {\r\n\t\tconst { inputRef } = this.props\r\n\t\treturn inputRef || this.inputRef\r\n\t}\r\n\r\n\t// `state` holds previous props as `props`, and also:\r\n\t// * `country` — The currently selected country, e.g. `\"RU\"`.\r\n\t// * `value` — The currently entered phone number (E.164), e.g. `+78005553535`.\r\n\t// * `parsedInput` — The parsed `` value, e.g. `8005553535`.\r\n\t// (and a couple of other less significant properties)\r\n\tstatic getDerivedStateFromProps(props, state) {\r\n\t\tconst {\r\n\t\t\tcountry,\r\n\t\t\thasUserSelectedACountry,\r\n\t\t\tvalue,\r\n\t\t\tprops: {\r\n\t\t\t\tdefaultCountry: prevDefaultCountry,\r\n\t\t\t\tvalue: prevValue,\r\n\t\t\t\treset: prevReset\r\n\t\t\t}\r\n\t\t} = state\r\n\r\n\t\tconst {\r\n\t\t\tmetadata,\r\n\t\t\tcountries,\r\n\t\t\tdefaultCountry: newDefaultCountry,\r\n\t\t\tvalue: newValue,\r\n\t\t\treset: newReset,\r\n\t\t\tinternational\r\n\t\t} = props\r\n\r\n\t\tconst newState = {\r\n\t\t\t// Emulate `prevProps` via `state.props`.\r\n\t\t\tprops,\r\n\t\t\t// If the user has already manually selected a country\r\n\t\t\t// then don't override that already selected country\r\n\t\t\t// if the `defaultCountry` property changes.\r\n\t\t\t// That's what `hasUserSelectedACountry` flag is for.\r\n\t\t\thasUserSelectedACountry\r\n\t\t}\r\n\r\n\t\t// Some users requested a way to reset the component\r\n\t\t// (both number `` and country ``).\r\n\t\t// Whenever `reset` property changes both number ``\r\n\t\t// and country `` are reset.\r\n\t\t// It's not implemented as some instance `.reset()` method\r\n\t\t// because `ref` is forwarded to ``.\r\n\t\t// It's also not replaced with just resetting `country` on\r\n\t\t// external `value` reset, because a user could select a country\r\n\t\t// and then not input any `value`, and so the selected country\r\n\t\t// would be \"stuck\", if not using this `reset` property.\r\n\t\t// https://github.com/catamphetamine/react-phone-number-input/issues/300\r\n\t\tif (newReset !== prevReset) {\r\n\t\t\treturn {\r\n\t\t\t\t...newState,\r\n\t\t\t\tparsedInput: undefined,\r\n\t\t\t\tvalue: undefined,\r\n\t\t\t\tcountry: newDefaultCountry,\r\n\t\t\t\thasUserSelectedACountry: undefined\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If the default country changed.\r\n\t\t// (e.g. in case of ajax GeoIP detection after page loaded)\r\n\t\t// then select it but only if the user hasn't already manually\r\n\t\t// selected a country and no phone number has been entered so far.\r\n\t\t// Because if the user has already started inputting a phone number\r\n\t\t// then he's okay with no country being selected at all (\"International\")\r\n\t\t// and doesn't want to be disturbed, doesn't want his input to be screwed, etc.\r\n\t\tif (newDefaultCountry !== prevDefaultCountry &&\r\n\t\t\t!hasUserSelectedACountry && (\r\n\t\t\t\t(!value && !newValue) ||\r\n\t\t\t\t(international &&\r\n\t\t\t\t\tvalue === getInitialParsedInput(undefined, prevDefaultCountry, international, metadata) &&\r\n\t\t\t\t\tvalue === getInitialParsedInput(undefined, newDefaultCountry, international, metadata)\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t) {\r\n\t\t\treturn {\r\n\t\t\t\t...newState,\r\n\t\t\t\tcountry: isCountrySupportedWithError(newDefaultCountry, metadata) ? newDefaultCountry : prevDefaultCountry,\r\n\t\t\t\t// If `parsedInput` is empty, then automatically select the new `country`\r\n\t\t\t\t// and set `parsedInput` to `+{getCountryCallingCode(newCountry)}`.\r\n\t\t\t\tparsedInput: generateInitialParsedInput(newValue, undefined, props)\r\n\t\t\t\t// `value` is `undefined`.\r\n\t\t\t\t// `parsedInput` is `undefined` because `value` is `undefined`.\r\n\t\t\t}\r\n\t\t}\r\n\t\t// If a new `value` is set externally.\r\n\t\t// (e.g. as a result of an ajax API request\r\n\t\t// to get user's phone after page loaded)\r\n\t\t// The first part — `newValue !== prevValue` —\r\n\t\t// is basically `props.value !== prevProps.value`\r\n\t\t// so it means \"if value property was changed externally\".\r\n\t\t// The second part — `newValue !== value` —\r\n\t\t// is for ignoring the `getDerivedStateFromProps()` call\r\n\t\t// which happens in `this.onChange()` right after `this.setState()`.\r\n\t\t// If this `getDerivedStateFromProps()` call isn't ignored\r\n\t\t// then the country flag would reset on each input.\r\n\t\telse if (newValue !== prevValue && newValue !== value) {\r\n\t\t\tconst phoneNumber = parsePhoneNumber(newValue, metadata)\r\n\t\t\tlet parsedCountry\r\n\t\t\tif (phoneNumber) {\r\n\t\t\t\tconst countries = getSupportedCountries(props.countries, metadata)\r\n\t\t\t\tif (!countries || countries.indexOf(phoneNumber.country) >= 0) {\r\n\t\t\t\t\tparsedCountry = phoneNumber.country\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (!newValue) {\r\n\t\t\t\tnewState.hasUserSelectedACountry = undefined\r\n\t\t\t}\r\n\t\t\treturn {\r\n\t\t\t\t...newState,\r\n\t\t\t\tparsedInput: generateInitialParsedInput(newValue, phoneNumber, props),\r\n\t\t\t\tvalue: newValue,\r\n\t\t\t\tcountry: newValue ? parsedCountry : newDefaultCountry\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `defaultCountry` didn't change.\r\n\t\t// `value` didn't change.\r\n\t\t// `parsedInput` didn't change, because `value` didn't change.\r\n\t\t//\r\n\t\t// So no need to update state here really.\r\n\t\t// Could as well return `null` explicitly\r\n\t\t// to indicate that the `state` hasn't changed.\r\n\t\t// But just in case, returns `newState`.\r\n\t\t// (who knows if someone adds something\r\n\t\t// changing `newState` above in some future)\r\n\t\treturn newState\r\n\t}\r\n\r\n\trender() {\r\n\t\tconst {\r\n\t\t\t// Generic HTML attributes.\r\n\t\t\tname,\r\n\t\t\tdisabled,\r\n\t\t\tautoComplete,\r\n\t\t\tstyle,\r\n\t\t\tclassName,\r\n\r\n\t\t\t// Number `` properties.\r\n\t\t\tinputRef,\r\n\t\t\tinputComponent,\r\n\t\t\tnumberInputProps,\r\n\t\t\tsmartCaret,\r\n\r\n\t\t\t// Country `` properties.\r\n\t\t\tcountrySelectComponent: CountrySelectComponent,\r\n\t\t\tcountrySelectProps,\r\n\r\n\t\t\t// Container `
` properties.\r\n\t\t\tcontainerComponent: ContainerComponent,\r\n\r\n\t\t\t// Get \"rest\" properties (passed through to number ``).\r\n\t\t\tdefaultCountry,\r\n\t\t\tcountries,\r\n\t\t\tcountryOptionsOrder,\r\n\t\t\tlabels,\r\n\t\t\tflags,\r\n\t\t\tflagComponent,\r\n\t\t\tflagUrl,\r\n\t\t\taddInternationalOption,\r\n\t\t\tinternationalIcon,\r\n\t\t\tdisplayInitialValueAsLocalNumber,\r\n\t\t\tonCountryChange,\r\n\t\t\tlimitMaxLength,\r\n\t\t\treset,\r\n\t\t\tmetadata,\r\n\t\t\tinternational,\r\n\t\t\t...rest\r\n\t\t} = this.props\r\n\r\n\t\tconst {\r\n\t\t\tcountry,\r\n\t\t\tparsedInput,\r\n\t\t\tisFocused\r\n\t\t} = this.state\r\n\r\n\t\tconst InputComponent = smartCaret ? InputSmart : InputBasic\r\n\r\n\t\tconst countrySelectOptions = useMemoCountrySelectOptions(() => {\r\n\t\t\treturn sortCountryOptions(\r\n\t\t\t\tgetCountrySelectOptions(\r\n\t\t\t\t\tcountries || getCountries(metadata),\r\n\t\t\t\t\tlabels,\r\n\t\t\t\t\taddInternationalOption\r\n\t\t\t\t),\r\n\t\t\t\tgetSupportedCountryOptions(countryOptionsOrder, metadata)\r\n\t\t\t)\r\n\t\t}, [\r\n\t\t\tcountries,\r\n\t\t\tcountryOptionsOrder,\r\n\t\t\taddInternationalOption,\r\n\t\t\tlabels,\r\n\t\t\tmetadata\r\n\t\t])\r\n\r\n\t\treturn (\r\n\t\t\t