generaltranslation 8.2.7 → 8.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["intlCache","intlCache","intlCache","intlCache","intlCache","intlCache","IntlMessageFormat","intlCache","intlCache","intlCache","defaultTimeout","ApiError","API_VERSION","API_VERSION","hashSource","decode","intlCache","encode","encode","defaultTimeout","_API_VERSION"],"sources":["../src/locales/isValidLocale.ts","../src/locales/isSameDialect.ts","../src/locales/isSameLanguage.ts","../src/locales/requiresTranslation.ts","../src/locales/customLocaleMapping.ts","../src/locales/getLocaleEmoji.ts","../src/locales/getLocaleProperties.ts","../src/locales/determineLocale.ts","../src/logging/logger.ts","../src/formatting/format.ts","../src/locales/getLocaleName.ts","../src/locales/getLocaleDirection.ts","../src/locales/isSupersetLocale.ts","../src/logging/errors.ts","../src/translate/utils/fetchWithTimeout.ts","../src/translate/utils/validateResponse.ts","../src/translate/utils/handleFetchError.ts","../src/translate/api.ts","../src/translate/utils/generateRequestHeaders.ts","../src/translate/utils/apiRequest.ts","../src/translate/translateMany.ts","../src/translate/setupProject.ts","../src/translate/utils/batch.ts","../src/translate/enqueueFiles.ts","../src/translate/createTag.ts","../src/translate/downloadFileBatch.ts","../src/translate/submitUserEditDiffs.ts","../src/locales/getRegionProperties.ts","../src/locales/resolveAliasLocale.ts","../src/locales/resolveCanonicalLocale.ts","../src/translate/uploadSourceFiles.ts","../src/translate/uploadTranslations.ts","../src/translate/querySourceFile.ts","../src/projects/getProjectData.ts","../src/translate/checkJobStatus.ts","../src/translate/awaitJobs.ts","../src/translate/queryFileData.ts","../src/translate/queryBranchData.ts","../src/translate/createBranch.ts","../src/translate/processFileMoves.ts","../src/translate/getOrphanedFiles.ts","../src/translate/publishFiles.ts","../src/index.ts"],"sourcesContent":["import { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport { CustomMapping } from './customLocaleMapping';\n\nconst scriptExceptions = ['Cham', 'Jamo', 'Kawi', 'Lisu', 'Toto', 'Thai'];\n\n//// According to BCP 47, the range qaa–qtz is reserved for private-use language codes\nconst isCustomLanguage = (language: string) => {\n return language >= 'qaa' && language <= 'qtz';\n};\n\n/**\n * Checks if a given BCP 47 language code is valid.\n * @param {string} code - The BCP 47 language code to validate.\n * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n * @internal\n */\nexport const _isValidLocale = (\n locale: string,\n customMapping?: CustomMapping\n): boolean => {\n // If in custom mapping, return true\n if (\n customMapping?.[locale] &&\n typeof customMapping[locale] === 'object' &&\n 'code' in (customMapping[locale] as Object) &&\n (customMapping[locale] as { code: string }).code\n ) {\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n try {\n const { language, region, script } = intlCache.get('Locale', locale);\n if (\n locale.split('-').length !==\n (() => {\n let partCount = 1;\n if (region) partCount += 1;\n if (script) partCount += 1;\n return partCount;\n })()\n )\n return false;\n const displayLanguageNames = intlCache.get(\n 'DisplayNames',\n [libraryDefaultLocale],\n {\n type: 'language',\n }\n );\n if (\n displayLanguageNames.of(language) === language &&\n !isCustomLanguage(language)\n )\n return false;\n if (region) {\n const displayRegionNames = intlCache.get(\n 'DisplayNames',\n [libraryDefaultLocale],\n {\n type: 'region',\n }\n );\n if (displayRegionNames.of(region) === region) return false;\n }\n if (script) {\n const displayScriptNames = intlCache.get(\n 'DisplayNames',\n [libraryDefaultLocale],\n {\n type: 'script',\n }\n );\n if (\n displayScriptNames.of(script) === script &&\n !scriptExceptions.includes(script)\n )\n return false;\n }\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Standardizes a BCP 47 locale to ensure correct formatting.\n * @param {string} locale - The BCP 47 locale to standardize.\n * @returns {string} The standardized BCP 47 locale, or an empty string if invalid.\n * @internal\n */\nexport const _standardizeLocale = (locale: string): string => {\n try {\n return Intl.getCanonicalLocales(locale)[0];\n } catch {\n return locale;\n }\n};\n","import { intlCache } from '../cache/IntlCache';\nimport { _standardizeLocale } from './isValidLocale';\n\nfunction checkTwoLocalesAreSameDialect(codeA: string, codeB: string) {\n const {\n language: languageA,\n region: regionA,\n script: scriptA,\n } = intlCache.get('Locale', codeA);\n const {\n language: languageB,\n region: regionB,\n script: scriptB,\n } = intlCache.get('Locale', codeB);\n if (languageA !== languageB) return false;\n if (regionA && regionB && regionA !== regionB) return false;\n if (scriptA && scriptB && scriptA !== scriptB) return false;\n return true;\n}\n\n/**\n * Test two or more language codes to determine if they are exactly the same\n * e.g. \"en-US\" and \"en\" would be exactly the same.\n * \"en-GB\" and \"en\" would be exactly the same.\n * \"en-GB\" and \"en-US\" would be different.\n * @internal\n */\nexport default function _isSameDialect(\n ...locales: (string | string[])[]\n): boolean {\n try {\n // standardize codes\n const flattenedCodes = locales.flat().map(_standardizeLocale);\n\n for (let i = 0; i < flattenedCodes.length; i++) {\n for (let j = i + 1; j < flattenedCodes.length; j++) {\n if (\n !checkTwoLocalesAreSameDialect(flattenedCodes[i], flattenedCodes[j])\n )\n return false;\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n","import { intlCache } from '../cache/IntlCache';\n\n/**\n * @internal\n */\nexport default function _isSameLanguage(\n ...locales: (string | string[])[]\n): boolean {\n try {\n const flattenedCodes = locales.flat();\n // Get the language for each code\n const languages = flattenedCodes.map(\n (locale) => intlCache.get('Locale', locale).language\n );\n return languages.every((language) => language === languages[0]);\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n","import { CustomMapping } from './customLocaleMapping';\nimport _isSameDialect from './isSameDialect';\nimport _isSameLanguage from './isSameLanguage';\nimport { _isValidLocale } from './isValidLocale';\n\n/**\n * Given a target locale and a source locale, determines whether a translation is required\n * If the target locale and the source locale are the same, returns false, otherwise returns true\n * If a translation is not possible due to the target locale being outside of the optional approvedLanguages scope, also returns false\n * @internal\n */\nexport default function _requiresTranslation(\n sourceLocale: string,\n targetLocale: string,\n approvedLocales?: string[],\n customMapping?: CustomMapping\n): boolean {\n // If codes are invalid\n if (\n !_isValidLocale(sourceLocale, customMapping) ||\n !_isValidLocale(targetLocale, customMapping) ||\n (approvedLocales &&\n approvedLocales.some(\n (approvedLocale) => !_isValidLocale(approvedLocale, customMapping)\n ))\n ) {\n return false;\n }\n\n // Check if the languages are identical, if so, a translation is not required\n if (_isSameDialect(sourceLocale, targetLocale)) {\n return false;\n }\n\n // Check that the target locale is within the approvedLocales scope, if not, a translation is not required\n // isSameLanguage rather than checkTwoLocalesAreSameDialect so we can show different dialects as a fallback\n if (\n approvedLocales &&\n !approvedLocales.some((approvedLocale) =>\n _isSameLanguage(targetLocale, approvedLocale)\n )\n ) {\n return false;\n }\n // Otherwise, a translation is required!\n return true;\n}\n","import { LocaleProperties } from './getLocaleProperties';\nimport { _isValidLocale } from './isValidLocale';\n\nexport type FullCustomMapping = Record<string, LocaleProperties>;\nexport type CustomMapping = Record<string, string | Partial<LocaleProperties>>;\n\nexport const getCustomProperty = (\n customMapping: CustomMapping,\n locale: string,\n property: keyof LocaleProperties\n): string | undefined => {\n if (customMapping?.[locale]) {\n if (typeof customMapping[locale] === 'string') {\n return property === 'name' ? customMapping[locale] : undefined;\n }\n return customMapping[locale][property];\n }\n return undefined;\n};\n\n/**\n * Checks if a given locale should use the canonical locale.\n * @param locale - The locale to check if it should use the canonical locale\n * @param customMapping - The custom mapping to use for checking if the locale should use the canonical locale\n * @returns True if the locale should use the canonical locale, false otherwise\n */\nexport const shouldUseCanonicalLocale = (\n locale: string,\n customMapping: CustomMapping\n): boolean => {\n return !!(\n customMapping?.[locale] &&\n typeof customMapping[locale] === 'object' &&\n 'code' in (customMapping[locale] as Object) &&\n (customMapping[locale] as { code: string }).code &&\n _isValidLocale((customMapping[locale] as { code: string }).code)\n );\n};\n","import { intlCache } from '../cache/IntlCache';\nimport {\n CustomMapping,\n getCustomProperty,\n shouldUseCanonicalLocale,\n} from './customLocaleMapping';\nimport { _standardizeLocale } from './isValidLocale';\n\n/**\n * @internal\n */\nexport default function _getLocaleEmoji(\n locale: string,\n customMapping?: CustomMapping\n): string {\n // Check for canonical locale\n const aliasedLocale = locale;\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n // Override locale with canonical locale\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n try {\n const standardizedLocale = _standardizeLocale(locale);\n const localeObject = intlCache.get('Locale', standardizedLocale);\n const { language, region } = localeObject;\n\n // if a custom mapping is specified, use it\n if (customMapping) {\n for (const l of [aliasedLocale, locale, standardizedLocale, language]) {\n const customEmoji = getCustomProperty(customMapping, l, 'emoji');\n if (customEmoji) return customEmoji;\n }\n }\n\n // if a region is specified, use it!\n if (region && emojis[region]) return emojis[region];\n\n // if not, attempt to extrapolate\n const extrapolated = localeObject.maximize();\n const extrapolatedRegion = extrapolated.region || '';\n\n return (\n exceptions[extrapolated.language] ||\n emojis[extrapolatedRegion] ||\n defaultEmoji\n );\n } catch {\n return defaultEmoji;\n }\n}\n\n// Default language emoji for when none else can be found\nconst europeAfricaGlobe = '🌍';\nconst asiaAustraliaGlobe = '🌏';\nexport const defaultEmoji = europeAfricaGlobe;\n\n// Exceptions to better reflect linguistic and cultural identities\nconst exceptions = {\n ca: europeAfricaGlobe,\n eu: europeAfricaGlobe,\n ku: europeAfricaGlobe,\n bo: asiaAustraliaGlobe,\n ug: asiaAustraliaGlobe,\n gd: '🏴󠁧󠁢󠁳󠁣󠁴󠁿',\n cy: '🏴󠁧󠁢󠁷󠁬󠁳󠁿',\n gv: '🇮🇲',\n grc: '🏺',\n} as Record<string, string>;\n\nexport const emojis = {\n AF: '🇦🇫', // Afghanistan\n AX: '🇦🇽', // Åland Islands\n AL: '🇦🇱', // Albania\n DZ: '🇩🇿', // Algeria\n AS: '🇦🇸', // American Samoa\n AD: '🇦🇩', // Andorra\n AO: '🇦🇴', // Angola\n AI: '🇦🇮', // Anguilla\n AQ: '🇦🇶', // Antarctica\n AG: '🇦🇬', // Antigua and Barbuda\n AR: '🇦🇷', // Argentina\n AM: '🇦🇲', // Armenia\n AW: '🇦🇼', // Aruba\n AU: '🇦🇺', // Australia\n AT: '🇦🇹', // Austria\n AZ: '🇦🇿', // Azerbaijan\n BS: '🇧🇸', // Bahamas\n BH: '🇧🇭', // Bahrain\n BD: '🇧🇩', // Bangladesh\n BB: '🇧🇧', // Barbados\n BY: '🇧🇾', // Belarus\n BE: '🇧🇪', // Belgium\n BZ: '🇧🇿', // Belize\n BJ: '🇧🇯', // Benin\n BM: '🇧🇲', // Bermuda\n BT: '🇧🇹', // Bhutan\n BO: '🇧🇴', // Bolivia\n BQ: '🇧🇶', // Bonaire, Sint Eustatius and Saba\n BA: '🇧🇦', // Bosnia and Herzegovina\n BW: '🇧🇼', // Botswana\n BV: '🇧🇻', // Bouvet Island\n BR: '🇧🇷', // Brazil\n IO: '🇮🇴', // British Indian Ocean Territory\n BN: '🇧🇳', // Brunei Darussalam\n BG: '🇧🇬', // Bulgaria\n BF: '🇧🇫', // Burkina Faso\n BI: '🇧🇮', // Burundi\n CV: '🇨🇻', // Cabo Verde\n KH: '🇰🇭', // Cambodia\n CM: '🇨🇲', // Cameroon\n CA: '🇨🇦', // Canada\n KY: '🇰🇾', // Cayman Islands\n CF: '🇨🇫', // Central African Republic\n TD: '🇹🇩', // Chad\n CL: '🇨🇱', // Chile\n CN: '🇨🇳', // China\n CX: '🇨🇽', // Christmas Island\n CC: '🇨🇨', // Cocos (Keeling) Islands\n CO: '🇨🇴', // Colombia\n KM: '🇰🇲', // Comoros\n CD: '🇨🇩', // Congo (Democratic Republic)\n CG: '🇨🇬', // Congo (Republic)\n CK: '🇨🇰', // Cook Islands\n CR: '🇨🇷', // Costa Rica\n CI: '🇨🇮', // Côte d'Ivoire\n HR: '🇭🇷', // Croatia\n CU: '🇨🇺', // Cuba\n CW: '🇨🇼', // Curaçao\n CY: '🇨🇾', // Cyprus\n CZ: '🇨🇿', // Czechia\n DK: '🇩🇰', // Denmark\n DJ: '🇩🇯', // Djibouti\n DM: '🇩🇲', // Dominica\n DO: '🇩🇴', // Dominican Republic\n EC: '🇪🇨', // Ecuador\n EG: '🇪🇬', // Egypt\n SV: '🇸🇻', // El Salvador\n GQ: '🇬🇶', // Equatorial Guinea\n ER: '🇪🇷', // Eritrea\n EE: '🇪🇪', // Estonia\n SZ: '🇸🇿', // Eswatini\n ET: '🇪🇹', // Ethiopia\n FK: '🇫🇰', // Falkland Islands\n FO: '🇫🇴', // Faroe Islands\n FJ: '🇫🇯', // Fiji\n FI: '🇫🇮', // Finland\n FR: '🇫🇷', // France\n GF: '🇬🇫', // French Guiana\n PF: '🇵🇫', // French Polynesia\n TF: '🇹🇫', // French Southern Territories\n GA: '🇬🇦', // Gabon\n GM: '🇬🇲', // Gambia\n GE: '🇬🇪', // Georgia\n DE: '🇩🇪', // Germany\n GH: '🇬🇭', // Ghana\n GI: '🇬🇮', // Gibraltar\n GR: '🇬🇷', // Greece\n GL: '🇬🇱', // Greenland\n GD: '🇬🇩', // Grenada\n GP: '🇬🇵', // Guadeloupe\n GU: '🇬🇺', // Guam\n GT: '🇬🇹', // Guatemala\n GG: '🇬🇬', // Guernsey\n GN: '🇬🇳', // Guinea\n GW: '🇬🇼', // Guinea-Bissau\n GY: '🇬🇾', // Guyana\n HT: '🇭🇹', // Haiti\n HM: '🇭🇲', // Heard Island and McDonald Islands\n VA: '🇻🇦', // Holy See\n HN: '🇭🇳', // Honduras\n HK: '🇭🇰', // Hong Kong\n HU: '🇭🇺', // Hungary\n IS: '🇮🇸', // Iceland\n IN: '🇮🇳', // India\n ID: '🇮🇩', // Indonesia\n IR: '🇮🇷', // Iran\n IQ: '🇮🇶', // Iraq\n IE: '🇮🇪', // Ireland\n IM: '🇮🇲', // Isle of Man\n IL: '🇮🇱', // Israel\n IT: '🇮🇹', // Italy\n JM: '🇯🇲', // Jamaica\n JP: '🇯🇵', // Japan\n JE: '🇯🇪', // Jersey\n JO: '🇯🇴', // Jordan\n KZ: '🇰🇿', // Kazakhstan\n KE: '🇰🇪', // Kenya\n KI: '🇰🇮', // Kiribati\n KP: '🇰🇵', // Korea (North)\n KR: '🇰🇷', // Korea (South)\n KW: '🇰🇼', // Kuwait\n KG: '🇰🇬', // Kyrgyzstan\n LA: '🇱🇦', // Laos\n LV: '🇱🇻', // Latvia\n LB: '🇱🇧', // Lebanon\n LS: '🇱🇸', // Lesotho\n LR: '🇱🇷', // Liberia\n LY: '🇱🇾', // Libya\n LI: '🇱🇮', // Liechtenstein\n LT: '🇱🇹', // Lithuania\n LU: '🇱🇺', // Luxembourg\n MO: '🇲🇴', // Macao\n MG: '🇲🇬', // Madagascar\n MW: '🇲🇼', // Malawi\n MY: '🇲🇾', // Malaysia\n MV: '🇲🇻', // Maldives\n ML: '🇲🇱', // Mali\n MT: '🇲🇹', // Malta\n MH: '🇲🇭', // Marshall Islands\n MQ: '🇲🇶', // Martinique\n MR: '🇲🇷', // Mauritania\n MU: '🇲🇺', // Mauritius\n YT: '🇾🇹', // Mayotte\n MX: '🇲🇽', // Mexico\n FM: '🇫🇲', // Micronesia\n MD: '🇲🇩', // Moldova\n MC: '🇲🇨', // Monaco\n MN: '🇲🇳', // Mongolia\n ME: '🇲🇪', // Montenegro\n MS: '🇲🇸', // Montserrat\n MA: '🇲🇦', // Morocco\n MZ: '🇲🇿', // Mozambique\n MM: '🇲🇲', // Myanmar\n NA: '🇳🇦', // Namibia\n NR: '🇳🇷', // Nauru\n NP: '🇳🇵', // Nepal\n NL: '🇳🇱', // Netherlands\n NC: '🇳🇨', // New Caledonia\n NZ: '🇳🇿', // New Zealand\n NI: '🇳🇮', // Nicaragua\n NE: '🇳🇪', // Niger\n NG: '🇳🇬', // Nigeria\n NU: '🇳🇺', // Niue\n NF: '🇳🇫', // Norfolk Island\n MK: '🇲🇰', // North Macedonia\n MP: '🇲🇵', // Northern Mariana Islands\n NO: '🇳🇴', // Norway\n OM: '🇴🇲', // Oman\n PK: '🇵🇰', // Pakistan\n PW: '🇵🇼', // Palau\n PS: '🇵🇸', // Palestine, State of\n PA: '🇵🇦', // Panama\n PG: '🇵🇬', // Papua New Guinea\n PY: '🇵🇾', // Paraguay\n PE: '🇵🇪', // Peru\n PH: '🇵🇭', // Philippines\n PN: '🇵🇳', // Pitcairn\n PL: '🇵🇱', // Poland\n PT: '🇵🇹', // Portugal\n PR: '🇵🇷', // Puerto Rico\n QA: '🇶🇦', // Qatar\n RE: '🇷🇪', // Réunion\n RO: '🇷🇴', // Romania\n RU: '🇷🇺', // Russian Federation\n RW: '🇷🇼', // Rwanda\n BL: '🇧🇱', // Saint Barthélemy\n SH: '🇸🇭', // Saint Helena, Ascension and Tristan da Cunha\n KN: '🇰🇳', // Saint Kitts and Nevis\n LC: '🇱🇨', // Saint Lucia\n MF: '🇲🇫', // Saint Martin (French part)\n PM: '🇵🇲', // Saint Pierre and Miquelon\n VC: '🇻🇨', // Saint Vincent and the Grenadines\n WS: '🇼🇸', // Samoa\n SM: '🇸🇲', // San Marino\n ST: '🇸🇹', // São Tomé and Príncipe\n SA: '🇸🇦', // Saudi Arabia\n SN: '🇸🇳', // Senegal\n RS: '🇷🇸', // Serbia\n SC: '🇸🇨', // Seychelles\n SL: '🇸🇱', // Sierra Leone\n SG: '🇸🇬', // Singapore\n SX: '🇸🇽', // Sint Maarten (Dutch part)\n SK: '🇸🇰', // Slovakia\n SI: '🇸🇮', // Slovenia\n SB: '🇸🇧', // Solomon Islands\n SO: '🇸🇴', // Somalia\n ZA: '🇿🇦', // South Africa\n GS: '🇬🇸', // South Georgia and the South Sandwich Islands\n SS: '🇸🇸', // South Sudan\n ES: '🇪🇸', // Spain\n LK: '🇱🇰', // Sri Lanka\n SD: '🇸🇩', // Sudan\n SR: '🇸🇷', // Suriname\n SJ: '🇸🇯', // Svalbard and Jan Mayen\n SE: '🇸🇪', // Sweden\n CH: '🇨🇭', // Switzerland\n SY: '🇸🇾', // Syrian Arab Republic\n TW: '🇹🇼', // Taiwan\n TJ: '🇹🇯', // Tajikistan\n TZ: '🇹🇿', // Tanzania\n TH: '🇹🇭', // Thailand\n TL: '🇹🇱', // Timor-Leste\n TG: '🇹🇬', // Togo\n TK: '🇹🇰', // Tokelau\n TO: '🇹🇴', // Tonga\n TT: '🇹🇹', // Trinidad and Tobago\n TN: '🇹🇳', // Tunisia\n TR: '🇹🇷', // Türkiye\n TM: '🇹🇲', // Turkmenistan\n TC: '🇹🇨', // Turks and Caicos Islands\n TV: '🇹🇻', // Tuvalu\n UG: '🇺🇬', // Uganda\n UA: '🇺🇦', // Ukraine\n AE: '🇦🇪', // United Arab Emirates\n GB: '🇬🇧', // United Kingdom\n US: '🇺🇸', // United States of America\n UM: '🇺🇲', // United States Minor Outlying Islands\n UY: '🇺🇾', // Uruguay\n UZ: '🇺🇿', // Uzbekistan\n VU: '🇻🇺', // Vanuatu\n VE: '🇻🇪', // Venezuela\n VN: '🇻🇳', // Viet Nam\n VG: '🇻🇬', // Virgin Islands (British)\n VI: '🇻🇮', // Virgin Islands (U.S.)\n WF: '🇼🇫', // Wallis and Futuna\n EH: '🇪🇭', // Western Sahara\n YE: '🇾🇪', // Yemen\n ZM: '🇿🇲', // Zambia\n ZW: '🇿🇼', // Zimbabwe,\n EU: '🇪🇺', // European Union (EU)\n '419': '🌎', // Latin America\n} as Record<string, string>;\n","import { libraryDefaultLocale } from '../internal';\nimport { defaultEmoji } from './getLocaleEmoji';\nimport { _isValidLocale, _standardizeLocale } from './isValidLocale';\nimport _getLocaleEmoji from './getLocaleEmoji';\nimport { intlCache } from '../cache/IntlCache';\nimport { CustomMapping, shouldUseCanonicalLocale } from './customLocaleMapping';\n\nexport type LocaleProperties = {\n // assume code = \"de-AT\", defaultLocale = \"en-US\"\n\n code: string; // \"de-AT\"\n name: string; // \"Austrian German\"\n nativeName: string; // \"Österreichisches Deutsch\"\n\n languageCode: string; // \"de\"\n languageName: string; // \"German\"\n nativeLanguageName: string; // \"Deutsch\"\n\n // note that maximize() is NOT called here!\n\n nameWithRegionCode: string; // \"German (AT)\"\n nativeNameWithRegionCode: string; // \"Deutsch (AT)\"\n\n // for most likely script and region, maximize() is called\n\n regionCode: string; // \"AT\"\n regionName: string; // \"Austria\"\n nativeRegionName: string; // Österreich\n\n scriptCode: string; // \"Latn\"\n scriptName: string; // \"Latin\"\n nativeScriptName: string; // \"Lateinisch\"\n\n maximizedCode: string; // \"de-Latn-AT\"\n maximizedName: string; // \"Austrian German (Latin)\"\n nativeMaximizedName: string; // Österreichisches Deutsch (Lateinisch)\n\n minimizedCode: string; // \"de-AT\", but for \"de-DE\" it would just be \"de\"\n minimizedName: string; // \"\"Austrian German\";\n nativeMinimizedName: string; // \"Österreichisches Deutsch\"\n\n // Emoji depending on region code\n // In order not to accidentally spark international conflict, some emojis are hard-coded\n emoji: string;\n};\n\n/**\n * Creates a set of custom locale properties from a custom mapping.\n *\n * @param lArray - An array of locale codes to search for in the custom mapping.\n * @param customMapping - Optional custom mapping of locale codes to names.\n * @returns A partial set of locale properties, or undefined if no custom mapping is provided.\n */\nexport function createCustomLocaleProperties(\n lArray: string[],\n customMapping?: CustomMapping\n): Partial<LocaleProperties> | undefined {\n if (customMapping) {\n let merged: Partial<LocaleProperties> = {};\n for (const l of lArray) {\n const value = customMapping[l];\n if (value) {\n if (typeof value === 'string') {\n merged.name ||= value;\n } else if (value) {\n merged = { ...value, ...merged };\n }\n }\n }\n return merged;\n }\n return undefined;\n}\n\n/**\n * @internal\n */\nexport default function _getLocaleProperties(\n locale: string,\n defaultLocale: string = libraryDefaultLocale,\n customMapping?: CustomMapping\n): LocaleProperties {\n // Check for canonical locale\n const aliasedLocale = locale;\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n // Override locale with canonical locale\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n defaultLocale ||= libraryDefaultLocale;\n\n try {\n const standardizedLocale = _standardizeLocale(locale); // \"de-AT\"\n\n const localeObject = intlCache.get('Locale', locale);\n const languageCode = localeObject.language; // \"de\"\n\n const customLocaleProperties = createCustomLocaleProperties(\n [aliasedLocale, locale, standardizedLocale, languageCode],\n customMapping\n );\n\n const baseRegion = localeObject.region; // \"AT\"\n\n const maximizedLocale = localeObject.maximize();\n const maximizedCode = maximizedLocale.toString(); // \"de-Latn-AT\"\n const regionCode =\n localeObject.region ||\n customLocaleProperties?.regionCode ||\n maximizedLocale.region ||\n ''; // \"AT\"\n const scriptCode =\n localeObject.script ||\n customLocaleProperties?.scriptCode ||\n maximizedLocale.script ||\n ''; // \"Latn\"\n\n const minimizedLocale = localeObject.minimize();\n const minimizedCode = minimizedLocale.toString(); // \"de-AT\"\n\n // Language names (default and native)\n\n const defaultLanguageOrder = [defaultLocale, locale, libraryDefaultLocale];\n const nativeLanguageOrder = [locale, defaultLocale, libraryDefaultLocale];\n\n const languageNames = intlCache.get('DisplayNames', defaultLanguageOrder, {\n type: 'language',\n });\n const nativeLanguageNames = intlCache.get(\n 'DisplayNames',\n nativeLanguageOrder,\n { type: 'language' }\n );\n\n const customName = customLocaleProperties?.name;\n const customNativeName =\n customLocaleProperties?.nativeName || customLocaleProperties?.name;\n\n const name = customName || languageNames.of(locale) || locale; // \"Austrian German\"\n const nativeName =\n customNativeName || nativeLanguageNames.of(locale) || locale; // \"Österreichisches Deutsch\"\n\n const maximizedName =\n customLocaleProperties?.maximizedName ||\n customName ||\n languageNames.of(maximizedCode) ||\n locale; // \"Austrian German (Latin)\"\n const nativeMaximizedName =\n customLocaleProperties?.nativeMaximizedName ||\n customNativeName ||\n nativeLanguageNames.of(maximizedCode) ||\n locale; // \"Österreichisches Deutsch (Lateinisch)\"\n\n const minimizedName =\n customLocaleProperties?.minimizedName ||\n customName ||\n languageNames.of(minimizedCode) ||\n locale; // \"Austrian German\", but for \"de-DE\" would just be \"German\"\n const nativeMinimizedName =\n customLocaleProperties?.nativeMinimizedName ||\n customNativeName ||\n nativeLanguageNames.of(minimizedCode) ||\n locale; // \"Österreichisches Deutsch\", but for \"de-DE\" would just be \"Deutsch\"\n\n const languageName =\n customLocaleProperties?.languageName ||\n customName ||\n languageNames.of(languageCode) ||\n locale; // \"German\"\n const nativeLanguageName =\n customLocaleProperties?.nativeLanguageName ||\n customNativeName ||\n nativeLanguageNames.of(languageCode) ||\n locale; // \"Deutsch\"\n\n const nameWithRegionCode =\n customLocaleProperties?.nameWithRegionCode || baseRegion\n ? `${languageName} (${baseRegion})`\n : name; // German (AT)\n const nativeNameWithRegionCode =\n customLocaleProperties?.nativeNameWithRegionCode ||\n (baseRegion ? `${nativeLanguageName} (${baseRegion})` : nativeName) ||\n nameWithRegionCode; // \"Deutsch (AT)\"\n\n // Region names (default and native)\n\n const regionNames = intlCache.get('DisplayNames', defaultLanguageOrder, {\n type: 'region',\n });\n const nativeRegionNames = intlCache.get(\n 'DisplayNames',\n nativeLanguageOrder,\n { type: 'region' }\n );\n\n const regionName =\n customLocaleProperties?.regionName ||\n (regionCode ? regionNames.of(regionCode) : '') ||\n ''; // \"Austria\"\n const nativeRegionName =\n customLocaleProperties?.nativeRegionName ||\n (regionCode ? nativeRegionNames.of(regionCode) : '') ||\n ''; // \"Österreich\"\n\n // Script names (default and native)\n\n const scriptNames = intlCache.get('DisplayNames', defaultLanguageOrder, {\n type: 'script',\n });\n const nativeScriptNames = intlCache.get(\n 'DisplayNames',\n nativeLanguageOrder,\n { type: 'script' }\n );\n\n const scriptName =\n customLocaleProperties?.scriptName ||\n (scriptCode ? scriptNames.of(scriptCode) : '') ||\n ''; // \"Latin\"\n const nativeScriptName =\n customLocaleProperties?.nativeScriptName ||\n (scriptCode ? nativeScriptNames.of(scriptCode) : '') ||\n ''; // \"Lateinisch\"\n\n // Emoji\n\n const emoji =\n customLocaleProperties?.emoji ||\n _getLocaleEmoji(standardizedLocale, customMapping);\n\n return {\n code: standardizedLocale,\n name,\n nativeName,\n maximizedCode,\n maximizedName,\n nativeMaximizedName,\n minimizedCode,\n minimizedName,\n nativeMinimizedName,\n languageCode,\n languageName,\n nativeLanguageName,\n nameWithRegionCode,\n nativeNameWithRegionCode,\n regionCode,\n regionName,\n nativeRegionName,\n scriptCode,\n scriptName,\n nativeScriptName,\n emoji,\n };\n } catch {\n let code = _isValidLocale(locale) ? _standardizeLocale(locale) : locale;\n const codeParts = code?.split('-');\n let languageCode = codeParts?.[0] || code || '';\n let regionCode =\n codeParts.length > 2 ? codeParts?.[2] : codeParts?.[1] || '';\n let scriptCode = codeParts?.[3] || '';\n\n const customLocaleProperties = createCustomLocaleProperties(\n [code, languageCode],\n customMapping\n );\n\n code = customLocaleProperties?.code || code;\n const name = customLocaleProperties?.name || code;\n const nativeName = customLocaleProperties?.nativeName || name;\n\n const maximizedCode = customLocaleProperties?.maximizedCode || code;\n const maximizedName = customLocaleProperties?.maximizedName || name;\n const nativeMaximizedName =\n customLocaleProperties?.nativeMaximizedName || nativeName;\n\n const minimizedCode = customLocaleProperties?.minimizedCode || code;\n const minimizedName = customLocaleProperties?.minimizedName || name;\n const nativeMinimizedName =\n customLocaleProperties?.nativeMinimizedName || nativeName;\n\n languageCode = customLocaleProperties?.languageCode || languageCode;\n const languageName = customLocaleProperties?.languageName || name;\n const nativeLanguageName =\n customLocaleProperties?.nativeLanguageName || nativeName;\n\n regionCode = customLocaleProperties?.regionCode || regionCode;\n const regionName = customLocaleProperties?.regionName || '';\n const nativeRegionName = customLocaleProperties?.nativeRegionName || '';\n\n scriptCode = customLocaleProperties?.scriptCode || scriptCode;\n const scriptName = customLocaleProperties?.scriptName || '';\n const nativeScriptName = customLocaleProperties?.nativeScriptName || '';\n\n const nameWithRegionCode =\n customLocaleProperties?.nameWithRegionCode ||\n (regionName ? `${languageName} (${regionName})` : name);\n const nativeNameWithRegionCode =\n customLocaleProperties?.nativeNameWithRegionCode ||\n (nativeRegionName\n ? `${nativeLanguageName} (${nativeRegionName})`\n : nativeName);\n\n const emoji = customLocaleProperties?.emoji || defaultEmoji;\n\n return {\n code,\n name,\n nativeName,\n maximizedCode,\n maximizedName,\n nativeMaximizedName,\n minimizedCode,\n minimizedName,\n nativeMinimizedName,\n languageCode,\n languageName,\n nativeLanguageName,\n nameWithRegionCode,\n nativeNameWithRegionCode,\n regionCode,\n regionName,\n nativeRegionName,\n scriptCode,\n scriptName,\n nativeScriptName,\n emoji,\n };\n }\n}\n","import { _isValidLocale, _standardizeLocale } from './isValidLocale';\nimport _isSameLanguage from './isSameLanguage';\nimport _isSameDialect from './isSameDialect';\nimport _getLocaleProperties from './getLocaleProperties';\nimport { CustomMapping } from './customLocaleMapping';\n\n/**\n * Given a list of locales and a list of approved locales, sorted in preference order\n * Determines which locale is the best match among the approved locales, prioritizing exact matches and falling back to dialects of the same language\n * @internal\n */\nexport default function _determineLocale(\n locales: string | string[],\n approvedLocales: string[],\n customMapping?: CustomMapping\n): string | undefined {\n if (typeof locales === 'string') locales = [locales];\n locales = locales\n .filter((locale) => _isValidLocale(locale, customMapping))\n .map(_standardizeLocale);\n approvedLocales = approvedLocales\n .filter((locale) => _isValidLocale(locale, customMapping))\n .map(_standardizeLocale);\n for (const locale of locales) {\n const candidates = approvedLocales.filter((approvedLocale) =>\n _isSameLanguage(locale, approvedLocale)\n );\n const getMatchingCode = ({\n locale,\n languageCode,\n minimizedCode,\n regionCode,\n scriptCode,\n }: {\n locale: string;\n languageCode: string;\n minimizedCode: string;\n regionCode: string;\n scriptCode: string;\n }) => {\n const locales = [\n locale, // If the full locale is supported under this language category\n `${languageCode}-${regionCode}`, // Attempt to match parts\n `${languageCode}-${scriptCode}`,\n minimizedCode, // If a minimized variant of this locale is supported\n ];\n for (const l of locales) {\n if (candidates.includes(l)) return l;\n }\n return null;\n };\n const { languageCode, ...codes } = _getLocaleProperties(locale);\n const matchingCode =\n getMatchingCode({ locale, languageCode, ...codes }) ||\n getMatchingCode({\n locale: languageCode,\n ..._getLocaleProperties(languageCode),\n });\n if (matchingCode) return matchingCode;\n }\n return undefined;\n}\n","/**\n * Comprehensive logging system for the General Translation library\n * Provides structured logging with multiple levels and configurable output\n */\n\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';\n\nexport interface LogEntry {\n level: LogLevel;\n message: string;\n timestamp: Date;\n context?: string;\n metadata?: Record<string, any>;\n}\n\nexport interface LoggerConfig {\n /** Minimum log level to output */\n level: LogLevel;\n /** Whether to include timestamps in log output */\n includeTimestamp: boolean;\n /** Whether to include context information */\n includeContext: boolean;\n /** Custom prefix for all log messages */\n prefix?: string;\n /** Whether to output to console (default: true) */\n enableConsole: boolean;\n /** Custom log handlers */\n handlers?: LogHandler[];\n}\n\nexport interface LogHandler {\n handle(entry: LogEntry): void;\n}\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n off: 4,\n};\n\nconst LOG_COLORS: Record<LogLevel, string> = {\n debug: '\\x1b[36m', // Cyan\n info: '\\x1b[32m', // Green\n warn: '\\x1b[33m', // Yellow\n error: '\\x1b[31m', // Red\n off: '', // No color needed since 'off' level logs are never displayed\n};\n\nconst RESET_COLOR = '\\x1b[0m';\n\n/**\n * Get the configured log level from environment variable or default to 'warn'\n */\nfunction getConfiguredLogLevel(): LogLevel {\n if (typeof process !== 'undefined' && process.env?._GT_LOG_LEVEL) {\n const envLevel = process.env._GT_LOG_LEVEL.toLowerCase();\n if (envLevel in LOG_LEVELS) {\n return envLevel as LogLevel;\n }\n }\n return 'warn';\n}\n\n/**\n * Console log handler that outputs formatted messages to console\n */\nexport class ConsoleLogHandler implements LogHandler {\n private config: LoggerConfig;\n\n constructor(config: LoggerConfig) {\n this.config = config;\n }\n\n handle(entry: LogEntry): void {\n const parts: string[] = [];\n\n // Add timestamp if enabled\n if (this.config.includeTimestamp) {\n parts.push(`[${entry.timestamp.toISOString()}]`);\n }\n\n // Add level with color\n const colorCode = LOG_COLORS[entry.level];\n const levelText = `[${entry.level.toUpperCase()}]`;\n parts.push(`${colorCode}${levelText}${RESET_COLOR}`);\n\n // Add prefix if configured\n if (this.config.prefix) {\n parts.push(`[${this.config.prefix}]`);\n }\n\n // Add context if available and enabled\n if (this.config.includeContext && entry.context) {\n parts.push(`[${entry.context}]`);\n }\n\n // Add the main message\n parts.push(entry.message);\n\n // Format metadata if available\n if (entry.metadata && Object.keys(entry.metadata).length > 0) {\n parts.push(`\\n Metadata: ${JSON.stringify(entry.metadata, null, 2)}`);\n }\n\n const formattedMessage = parts.join(' ');\n\n // Output to appropriate console method based on level\n switch (entry.level) {\n case 'debug':\n console.debug(formattedMessage);\n break;\n case 'info':\n console.info(formattedMessage);\n break;\n case 'warn':\n console.warn(formattedMessage);\n break;\n case 'error':\n console.error(formattedMessage);\n break;\n }\n }\n}\n\n/**\n * Main Logger class providing structured logging capabilities\n */\nexport class Logger {\n private config: LoggerConfig;\n private handlers: LogHandler[];\n\n constructor(config: Partial<LoggerConfig> = {}) {\n this.config = {\n level: getConfiguredLogLevel(),\n includeTimestamp: true,\n includeContext: true,\n enableConsole: true,\n handlers: [],\n ...config,\n };\n\n this.handlers = [...(this.config.handlers || [])];\n\n // Add console handler if enabled\n if (this.config.enableConsole) {\n this.handlers.push(new ConsoleLogHandler(this.config));\n }\n }\n\n /**\n * Add a custom log handler\n */\n addHandler(handler: LogHandler): void {\n this.handlers.push(handler);\n }\n\n /**\n * Remove a log handler\n */\n removeHandler(handler: LogHandler): void {\n const index = this.handlers.indexOf(handler);\n if (index > -1) {\n this.handlers.splice(index, 1);\n }\n }\n\n /**\n * Update logger configuration\n */\n configure(config: Partial<LoggerConfig>): void {\n this.config = { ...this.config, ...config };\n }\n\n /**\n * Check if a log level should be output based on current configuration\n */\n private shouldLog(level: LogLevel): boolean {\n return LOG_LEVELS[level] >= LOG_LEVELS[this.config.level];\n }\n\n /**\n * Internal logging method that creates log entries and passes them to handlers\n */\n private log(\n level: LogLevel,\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n if (!this.shouldLog(level)) {\n return;\n }\n\n const entry: LogEntry = {\n level,\n message,\n timestamp: new Date(),\n context,\n metadata,\n };\n\n // Pass to all handlers\n this.handlers.forEach((handler) => {\n try {\n handler.handle(entry);\n } catch (error) {\n // Prevent logging errors from breaking the application\n console.error('Error in log handler:', error);\n }\n });\n }\n\n /**\n * Log a debug message\n * Used for detailed diagnostic information, typically of interest only when diagnosing problems\n */\n debug(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('debug', message, context, metadata);\n }\n\n /**\n * Log an info message\n * Used for general information about application operation\n */\n info(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('info', message, context, metadata);\n }\n\n /**\n * Log a warning message\n * Used for potentially problematic situations that don't prevent operation\n */\n warn(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('warn', message, context, metadata);\n }\n\n /**\n * Log an error message\n * Used for error events that might still allow the application to continue\n */\n error(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('error', message, context, metadata);\n }\n\n /**\n * Create a child logger with a specific context\n */\n child(context: string): ContextLogger {\n return new ContextLogger(this, context);\n }\n\n /**\n * Get current logger configuration\n */\n getConfig(): LoggerConfig {\n return { ...this.config };\n }\n}\n\n/**\n * Context logger that automatically includes context information\n */\nexport class ContextLogger {\n private logger: Logger;\n private context: string;\n\n constructor(logger: Logger, context: string) {\n this.logger = logger;\n this.context = context;\n }\n\n debug(message: string, metadata?: Record<string, any>): void {\n this.logger.debug(message, this.context, metadata);\n }\n\n info(message: string, metadata?: Record<string, any>): void {\n this.logger.info(message, this.context, metadata);\n }\n\n warn(message: string, metadata?: Record<string, any>): void {\n this.logger.warn(message, this.context, metadata);\n }\n\n error(message: string, metadata?: Record<string, any>): void {\n this.logger.error(message, this.context, metadata);\n }\n\n child(childContext: string): ContextLogger {\n return new ContextLogger(this.logger, `${this.context}:${childContext}`);\n }\n}\n\n// Default logger instance\nexport const defaultLogger = new Logger({\n level: getConfiguredLogLevel(),\n includeTimestamp: true,\n includeContext: true,\n prefix: 'GT',\n});\n\n// Convenience functions using the default logger\nexport const debug = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.debug(message, context, metadata);\n\nexport const info = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.info(message, context, metadata);\n\nexport const warn = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.warn(message, context, metadata);\n\nexport const error = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.error(message, context, metadata);\n\n// Create context-specific loggers for different parts of the system\nexport const fetchLogger = defaultLogger.child('fetch');\nexport const validationLogger = defaultLogger.child('validation');\nexport const formattingLogger = defaultLogger.child('formatting');\nexport const localeLogger = defaultLogger.child('locale');\nexport const gtInstanceLogger = defaultLogger.child('GT instance');\n\n// Export types and classes\nexport { Logger as GTLogger };\n","import { FormatVariables, I18nextMessage } from '../types';\nimport { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport IntlMessageFormat from 'intl-messageformat';\nimport { formatI18nextWarning, formatJsxWarning } from '../logging/warnings';\nimport { formattingLogger } from '../logging/logger';\nimport { JsxChildren } from '../types';\nimport {\n CutoffFormatOptions,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\n CutoffFormatStyle,\n} from './custom-formats/CutoffFormat/types';\n\n/**\n * Formats a string value with cutoff behavior according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the cutoff formatting.\n * @param {string} params.value - The string value to format with cutoff behavior.\n * @param {string | string[]} [params.locales='en'] - The locales to use for formatting.\n * @param {CutoffFormatOptions} [params.options={}] - Additional options for cutoff formatting.\n * @param {number} [params.options.maxChars] - The maximum number of characters to display.\n * @param {CutoffFormatStyle} [params.options.style='ellipsis'] - The style of the terminator.\n * @param {string} [params.options.terminator] - Optional override for the terminator to use.\n * @param {string} [params.options.separator] - Optional override for the separator between terminator and value.\n *\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n * @internal\n *\n * @example\n * _formatCutoff({ value: 'Hello, world!', options: { maxChars: 8 } }); // Returns 'Hello, w...'\n *\n * Will fallback to an empty string if formatting fails.\n */\nexport function _formatCutoff({\n value,\n locales = libraryDefaultLocale,\n options = {},\n}: {\n value: string;\n locales?: string | string[];\n options?: CutoffFormatOptions;\n}): string {\n return intlCache.get('CutoffFormat', locales, options).format(value);\n}\n\n/**\n * Formats a message according to the specified locales and options.\n *\n * @param {string} message - The message to format.\n * @param {string | string[]} [locales='en'] - The locales to use for formatting.\n * @param {Record<string, any>} [variables={}] - The variables to use for formatting.\n * @returns {string} The formatted message.\n * @internal\n *\n * Will fallback to an empty string\n * TODO: add this to custom formats\n */\nexport function _formatMessageICU(\n message: string,\n locales: string | string[] = libraryDefaultLocale,\n variables: FormatVariables = {}\n): string {\n const messageFormat = new IntlMessageFormat(message, locales);\n return messageFormat.format(variables)?.toString() ?? '';\n}\n\n/**\n * Returns the message as-is without any formatting.\n *\n * @param {string} message - The message to return.\n * @returns {string} The original message, unchanged.\n * @internal\n *\n * TODO: add this to custom formats\n */\nexport function _formatMessageString(message: string): string {\n return message;\n}\n\n/**\n * Formats a number according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.\n *\n * @returns {string} The formatted number.\n * @internal\n */\nexport function _formatNum({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: number;\n locales?: string | string[];\n options?: Intl.NumberFormatOptions;\n}): string {\n const res = intlCache\n .get('NumberFormat', locales, {\n numberingSystem: 'latn',\n ...options,\n })\n .format(value);\n return res;\n}\n\n/**\n * Formats a date according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {string | string[]} [params.locales='en'] - The locales to use for formatting.\n * @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.\n *\n * @returns {string} The formatted date.\n * @internal\n */\nexport function _formatDateTime({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: Date;\n locales?: string | string[];\n options?: Intl.DateTimeFormatOptions;\n}): string {\n return intlCache\n .get('DateTimeFormat', locales, {\n calendar: 'gregory',\n numberingSystem: 'latn',\n ...options,\n })\n .format(value);\n}\n\n/**\n * Formats a currency value according to the specified locales, currency, and options.\n *\n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n *\n * @returns {string} The formatted currency value.\n * @internal\n */\n\nexport function _formatCurrency({\n value,\n locales = [libraryDefaultLocale],\n currency = 'USD',\n options = {},\n}: {\n value: number;\n currency?: string;\n locales?: string | string[];\n options?: Intl.NumberFormatOptions;\n}): string {\n return intlCache\n .get('NumberFormat', locales, {\n style: 'currency',\n currency,\n numberingSystem: 'latn',\n ...options,\n })\n .format(value);\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n *\n * @returns {string} The formatted list.\n * @internal\n */\nexport function _formatList({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: Array<any>;\n locales?: string | string[];\n options?: Intl.ListFormatOptions;\n}): string {\n return intlCache\n .get('ListFormat', locales, {\n type: 'conjunction', // Default type, can be overridden via options\n style: 'long', // Default style, can be overridden via options\n ...options,\n })\n .format(value);\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<T>} params.value - The list of items to format.\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * @returns {Array<T | string>} The formatted list parts.\n * @internal\n */\nexport function _formatListToParts<T>({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: Array<T>;\n locales?: string | string[];\n options?: Intl.ListFormatOptions;\n}) {\n const formatListParts = intlCache\n .get('ListFormat', locales, {\n type: 'conjunction', // Default type, can be overridden via options\n style: 'long', // Default style, can be overridden via options\n ...options,\n })\n .formatToParts(value.map(() => '1'));\n let partIndex = 0;\n return formatListParts.map((part) => {\n if (part.type === 'element') return value[partIndex++];\n return part.value;\n });\n}\n\n/**\n * Selects the best unit and computes the value for relative time formatting\n * based on the difference between a date and a base date.\n * @param {Date} date - The target date.\n * @param {Date} baseDate - The base date to compute relative time from. Must be provided by the caller for hydration safety.\n * @returns {{ value: number, unit: Intl.RelativeTimeFormatUnit }} The computed value and unit.\n * @internal\n */\nexport function _selectRelativeTimeUnit(\n date: Date,\n baseDate: Date\n): {\n value: number;\n unit: Intl.RelativeTimeFormatUnit;\n} {\n const now = baseDate.getTime();\n const diffMs = date.getTime() - now;\n const absDiffMs = Math.abs(diffMs);\n const sign = diffMs < 0 ? -1 : 1;\n\n // Use Math.floor to avoid confusing jumps near boundaries\n // (e.g. 3.5 days rounding to \"1 week ago\" instead of \"3 days ago\")\n const seconds = Math.floor(absDiffMs / 1000);\n const minutes = Math.floor(absDiffMs / (1000 * 60));\n const hours = Math.floor(absDiffMs / (1000 * 60 * 60));\n const days = Math.floor(absDiffMs / (1000 * 60 * 60 * 24));\n const weeks = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 7));\n const months = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 30));\n const years = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 365));\n\n if (seconds < 60) return { value: sign * seconds, unit: 'second' };\n if (minutes < 60) return { value: sign * minutes, unit: 'minute' };\n if (hours < 24) return { value: sign * hours, unit: 'hour' };\n if (days < 7) return { value: sign * days, unit: 'day' };\n if (days < 28) return { value: sign * weeks, unit: 'week' };\n if (months < 1) return { value: sign * weeks, unit: 'week' };\n if (months < 12) return { value: sign * months, unit: 'month' };\n if (years < 1) return { value: sign * months, unit: 'month' };\n return { value: sign * years, unit: 'year' };\n}\n\n/**\n * Formats a relative time from a Date, automatically selecting the best unit.\n * @internal\n */\nexport function _formatRelativeTimeFromDate({\n date,\n baseDate,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n date: Date;\n baseDate: Date;\n locales?: string | string[];\n options?: Intl.RelativeTimeFormatOptions;\n}): string {\n const { value, unit } = _selectRelativeTimeUnit(date, baseDate);\n return _formatRelativeTime({ value, unit, locales, options });\n}\n\n/**\n * Formats a relative time value according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n *\n * @returns {string} The formatted relative time string.\n * @internal\n */\nexport function _formatRelativeTime({\n value,\n unit,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: number;\n unit: Intl.RelativeTimeFormatUnit;\n locales?: string | string[];\n options?: Intl.RelativeTimeFormatOptions;\n}): string {\n return intlCache\n .get('RelativeTimeFormat', locales, {\n style: 'long',\n numeric: 'auto',\n ...options,\n })\n .format(value, unit);\n}\n\n/**\n * @experimental This function is not currently supported but will be implemented in a future version.\n * Use {@link _formatMessageICU} for current ICU message format support.\n * Formats an I18next message according to the specified locales and options.\n *\n * @param message - The I18next message to format.\n * @param variables - The variables to use for formatting.\n * @returns The formatted I18next message.\n * @internal\n */\nexport function _formatI18next(\n message: I18nextMessage,\n // eslint-disable-next-line no-unused-vars\n _variables: FormatVariables = {}\n): string {\n formattingLogger.warn(formatI18nextWarning);\n return message;\n}\n\n/**\n * @experimental This function is not currently supported but will be implemented in a future version.\n * Use {@link _formatMessageICU} for current ICU message format support.\n * Formats a JSX message according to the specified locales and options.\n *\n * @param message - The JSX message to format.\n * @param variables - The variables to use for formatting.\n * @returns The formatted JSX message.\n * @internal\n */\nexport function _formatJsx(\n message: JsxChildren,\n // eslint-disable-next-line no-unused-vars\n _variables: FormatVariables = {}\n): JsxChildren {\n formattingLogger.warn(formatJsxWarning);\n return message;\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport {\n CustomMapping,\n getCustomProperty,\n shouldUseCanonicalLocale,\n} from './customLocaleMapping';\nimport { _standardizeLocale } from './isValidLocale';\n\n/**\n * Retrieves the display name(s) of locale code(s) using Intl.DisplayNames.\n *\n * @param {string} locale - A BCP-47 locale code.\n * @param {string} [defaultLocale=libraryDefaultLocale] - The locale for display names.\n * @returns {string} The display name(s) corresponding to the code(s), or empty string(s) if invalid.\n * @internal\n */\nexport function _getLocaleName(\n locale: string,\n defaultLocale: string = libraryDefaultLocale,\n customMapping?: CustomMapping\n): string {\n // Check for canonical locale\n const aliasedLocale = locale;\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n // Override locale with canonical locale\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n defaultLocale ||= libraryDefaultLocale;\n try {\n const standardizedLocale = _standardizeLocale(locale);\n if (customMapping) {\n for (const l of [\n aliasedLocale,\n locale,\n standardizedLocale,\n intlCache.get('Locale', standardizedLocale).language,\n ]) {\n const customName = getCustomProperty(customMapping, l, 'name');\n if (customName) return customName;\n }\n }\n const displayNames = intlCache.get(\n 'DisplayNames',\n [defaultLocale, standardizedLocale, libraryDefaultLocale], // default locale order\n { type: 'language' }\n );\n return displayNames.of(standardizedLocale) || '';\n } catch {\n // In case Intl.DisplayNames construction fails, return empty string(s)\n return '';\n }\n}\n","import { intlCache } from '../cache/IntlCache';\nimport _getLocaleProperties from './getLocaleProperties';\n\n/**\n * Get the text direction for a given locale code using the Intl.Locale API.\n *\n * @param {string} code - The locale code to check.\n * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.\n * @internal\n */\nexport function _getLocaleDirection(code: string): 'ltr' | 'rtl' {\n // Extract via textInfo property\n try {\n const locale = intlCache.get('Locale', code);\n const textInfoDirection = extractDirectionWithTextInfo(locale);\n if (textInfoDirection) {\n return textInfoDirection;\n }\n } catch {\n // silent\n }\n\n // Fallback to simple heuristics\n const { scriptCode, languageCode } = _getLocaleProperties(code);\n\n // Handle RTL script or language\n if (scriptCode) return isRtlScript(scriptCode) ? 'rtl' : 'ltr';\n if (languageCode) return isRtlLanguage(languageCode) ? 'rtl' : 'ltr';\n\n return 'ltr';\n}\n\n// ===== HELPER CONSTANTS ===== //\n\nconst RTL_SCRIPTS = new Set([\n 'arab',\n 'adlm',\n 'hebr',\n 'nkoo',\n 'rohg',\n 'samr',\n 'syrc',\n 'thaa',\n 'yezi',\n]);\n\nconst RTL_LANGUAGES = new Set([\n 'ar',\n 'arc',\n 'ckb',\n 'dv',\n 'fa',\n 'he',\n 'iw',\n 'ku',\n 'lrc',\n 'nqo',\n 'ps',\n 'pnb',\n 'sd',\n 'syr',\n 'ug',\n 'ur',\n 'yi',\n]);\n\n// ===== HELPER FUNCTIONS ===== //\n\n/**\n * Handles extracting direction via textInfo property\n * @param Locale - Intl.Locale object\n * @returns {'ltr' | 'rtl'} - The direction of the locale\n *\n * Intl.Locale.prototype.getTextInfo() / textInfo property incorporated in ES2024 Specification.\n * This is not supported by all browsers yet.\n * See: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo#browser_compatibility}\n */\nfunction extractDirectionWithTextInfo(\n locale: Intl.Locale\n): 'ltr' | 'rtl' | undefined {\n if (\n 'textInfo' in locale &&\n typeof locale.textInfo === 'object' &&\n locale.textInfo !== null &&\n 'direction' in locale.textInfo &&\n (locale.textInfo?.direction === 'rtl' ||\n locale.textInfo?.direction === 'ltr')\n ) {\n return locale.textInfo?.direction;\n }\n\n return undefined;\n}\n\nfunction isRtlScript(script: string | undefined): boolean {\n return script ? RTL_SCRIPTS.has(script.toLowerCase()) : false;\n}\n\nfunction isRtlLanguage(language: string | undefined): boolean {\n return language ? RTL_LANGUAGES.has(language.toLowerCase()) : false;\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { _standardizeLocale } from './isValidLocale';\n\n/**\n * @internal\n */\nexport default function _isSupersetLocale(\n superLocale: string,\n subLocale: string\n): boolean {\n try {\n const {\n language: languageSuper,\n region: regionSuper,\n script: scriptSuper,\n } = intlCache.get('Locale', _standardizeLocale(superLocale));\n const {\n language: languageSub,\n region: regionSub,\n script: scriptSub,\n } = intlCache.get('Locale', _standardizeLocale(subLocale));\n\n if (languageSuper !== languageSub) return false;\n if (regionSuper && regionSuper !== regionSub) return false;\n if (scriptSuper && scriptSuper !== scriptSub) return false;\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n","const GT_ERROR_PREFIX = 'GT Error:';\n\nexport const translationTimeoutError = (timeout: number) =>\n `${GT_ERROR_PREFIX} Translation request timed out after ${timeout}ms.`;\n\nexport const translationRequestFailedError = (error: string) =>\n `${GT_ERROR_PREFIX} Translation request failed. Error: ${error}`;\n\nexport const apiError = (status: number, statusText: string, error: string) =>\n `${GT_ERROR_PREFIX} API returned error status. Status: ${status}, Status Text: ${statusText}, Error: ${error}`;\n\nexport const invalidAuthError = `${GT_ERROR_PREFIX} Invalid authentication.`;\n\nexport const noTargetLocaleProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified locale. Either pass a locale to the \\`${functionName}\\` function or specify a targetLocale in the GT constructor.`;\n\nexport const noSourceLocaleProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified locale. Either pass a locale to the \\`${functionName}\\` function or specify a sourceLocale in the GT constructor.`;\n\nexport const noProjectIdProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified project ID. Either pass a project ID to the \\`${functionName}\\` function or specify a projectId in the GT constructor.`;\n\nexport const noApiKeyProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified API key. Either pass an API key to the \\`${functionName}\\` function or specify an apiKey in the GT constructor.`;\n\nexport const invalidLocaleError = (locale: string) =>\n `${GT_ERROR_PREFIX} Invalid locale: ${locale}.`;\n\nexport const invalidLocalesError = (locales: string[]) =>\n `${GT_ERROR_PREFIX} Invalid locales: ${locales.join(', ')}.`;\n","import { translationTimeoutError } from '../../logging/errors';\nimport { defaultTimeout } from '../../settings/settings';\n\n/**\n * @internal\n *\n * Wraps the fetch function with a timeout.\n *\n * @param url - The URL to fetch.\n * @param options - The options to pass to the fetch function.\n * @param timeout - The timeout in milliseconds.\n * @returns The response from the fetch function.\n */\nexport default async function fetchWithTimeout(\n url: string | URL | globalThis.Request,\n options: RequestInit,\n timeout?: number\n) {\n const controller = new AbortController();\n const signal = controller.signal;\n\n timeout = timeout ? timeout : defaultTimeout;\n const timeoutId = timeout\n ? setTimeout(() => controller.abort(), timeout)\n : null;\n\n try {\n const response = await fetch(url, { ...options, signal });\n return response;\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n throw translationTimeoutError(timeout);\n }\n throw error;\n } finally {\n if (timeoutId) clearTimeout(timeoutId);\n }\n}\n","import { apiError } from '../../logging/errors';\nimport { ApiError } from '../../errors/ApiError';\n\nexport default async function validateResponse(response: Response) {\n if (!response.ok) {\n let errorMsg = 'Unknown error';\n try {\n const text = await response.text();\n try {\n const errorJson = JSON.parse(text) as { error: string };\n errorMsg = errorJson.error;\n } catch {\n errorMsg = text || 'Unknown error';\n }\n } catch {\n // response.text() failed, keep 'Unknown error'\n }\n const errorMessage = apiError(\n response.status,\n response.statusText,\n errorMsg\n );\n const error = new ApiError(errorMessage, response.status, errorMsg);\n throw error;\n }\n}\n","import { fetchLogger } from '../../logging/logger';\nimport {\n translationRequestFailedError,\n translationTimeoutError,\n} from '../../logging/errors';\n\nexport default function handleFetchError(\n error: unknown,\n timeout: number\n): never {\n if (error instanceof Error && error.name === 'AbortError') {\n const errorMessage = translationTimeoutError(timeout);\n fetchLogger.error(errorMessage);\n throw new Error(errorMessage);\n }\n const errorMessage = translationRequestFailedError(\n error instanceof Error ? error.message : String(error)\n );\n fetchLogger.error(errorMessage);\n throw error;\n}\n","export const API_VERSION = '2026-03-06.v1';\n","import { TranslationRequestConfig } from '../../types';\nimport { API_VERSION } from '../api';\n\nexport default function generateRequestHeaders(\n config: TranslationRequestConfig,\n excludeContentType = false\n) {\n const authHeaders: Record<string, string> = {\n ...(!excludeContentType && { 'Content-Type': 'application/json' }),\n 'x-gt-project-id': config.projectId,\n };\n\n if (config.apiKey) {\n if (config.apiKey.startsWith('gtx-internal-')) {\n authHeaders['x-gt-internal-api-key'] = config.apiKey;\n } else {\n authHeaders['x-gt-api-key'] = config.apiKey;\n }\n }\n\n authHeaders['gt-api-version'] = API_VERSION;\n\n return authHeaders;\n}\n","import { TranslationRequestConfig } from '../../types';\nimport { defaultBaseUrl } from '../../settings/settingsUrls';\nimport { defaultTimeout } from '../../settings/settings';\nimport fetchWithTimeout from './fetchWithTimeout';\nimport validateResponse from './validateResponse';\nimport handleFetchError from './handleFetchError';\nimport generateRequestHeaders from './generateRequestHeaders';\n\nconst MAX_RETRIES = 3;\nconst INITIAL_DELAY_MS = 500;\n\ntype RetryPolicy = 'exponential' | 'linear' | 'none';\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction getRetryDelay(policy: RetryPolicy, attempt: number): number {\n switch (policy) {\n case 'linear':\n return INITIAL_DELAY_MS * (attempt + 1);\n case 'exponential':\n return INITIAL_DELAY_MS * 2 ** attempt;\n default:\n return 0;\n }\n}\n\n/**\n * @internal\n *\n * Makes an API request with automatic retry for 5XX errors.\n *\n * Encapsulates URL construction, fetch with timeout, error handling,\n * response validation, and JSON parsing.\n *\n * @param config - The configuration for the API call\n * @param endpoint - The API endpoint path (e.g. '/v2/project/jobs/info')\n * @param options - Optional request options\n * @returns The parsed JSON response\n */\nexport default async function apiRequest<T>(\n config: TranslationRequestConfig,\n endpoint: string,\n options?: {\n body?: unknown;\n timeout?: number;\n method?: 'GET' | 'POST';\n retryPolicy?: RetryPolicy;\n }\n): Promise<T> {\n const timeout = options?.timeout ?? defaultTimeout;\n const url = `${config.baseUrl || defaultBaseUrl}${endpoint}`;\n const method = options?.method ?? 'POST';\n const retryPolicy = options?.retryPolicy ?? 'exponential';\n const maxRetries = retryPolicy === 'none' ? 0 : MAX_RETRIES;\n\n const requestInit: RequestInit = {\n method,\n headers: generateRequestHeaders(config),\n };\n if (options?.body !== undefined) {\n requestInit.body = JSON.stringify(options.body);\n }\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n let response: Response;\n try {\n response = await fetchWithTimeout(url, requestInit, timeout);\n } catch (error) {\n if (attempt < maxRetries) {\n await sleep(getRetryDelay(retryPolicy, attempt));\n continue;\n }\n handleFetchError(error, timeout);\n }\n\n // Retry on 5XX server errors\n if (response!.status >= 500 && attempt < maxRetries) {\n await sleep(getRetryDelay(retryPolicy, attempt));\n continue;\n }\n\n await validateResponse(response!);\n return (await response!.json()) as T;\n }\n\n throw new Error('Max retries exceeded');\n}\n","import {\n TranslationRequestConfig,\n TranslateManyResult,\n TranslationResult,\n} from '../types';\nimport { defaultRuntimeApiUrl } from '../settings/settingsUrls';\nimport {\n TranslateManyEntry,\n TranslateOptions,\n EntryMetadata,\n} from '../types-dir/api/entry';\nimport apiRequest from './utils/apiRequest';\nimport { Content } from '../types-dir/jsx/content';\nimport { hashSource } from '../id';\n\n/**\n * @internal\n *\n * Translates multiple entries in a single API request for better performance.\n * This function batches multiple translation requests together and sends them\n * to the GT translation API in one call.\n *\n * @param requests - The entries to translate. Can be an array (entries are hashed and results returned in order) or a record keyed by hash (skips hash calculation, returns a record).\n * @param globalMetadata - The metadata for the translation.\n * @param config - The configuration for the translation.\n * @returns The results of the translation. An array if requests was an array, a record if requests was a record.\n */\nexport default async function _translateMany<\n T extends TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n>(\n requests: T,\n globalMetadata: {\n targetLocale: string;\n sourceLocale: string;\n } & TranslateOptions,\n config: TranslationRequestConfig,\n timeout?: number\n): Promise<\n T extends TranslateManyEntry[]\n ? TranslateManyResult\n : Record<string, TranslationResult>\n>;\nexport default async function _translateMany(\n requests: TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n globalMetadata: {\n targetLocale: string;\n sourceLocale: string;\n } & TranslateOptions,\n config: TranslationRequestConfig,\n timeout?: number\n): Promise<TranslateManyResult | Record<string, TranslationResult>> {\n const isArray = Array.isArray(requests);\n\n // normalize and map from requests to requests record\n const hashOrder: string[] | undefined = isArray ? [] : undefined;\n const requestsObject: Record<\n string,\n { source: Content; metadata?: EntryMetadata }\n > = {};\n\n const entries: [string | undefined, TranslateManyEntry][] = isArray\n ? requests.map((r) => [undefined, r])\n : Object.entries(requests);\n\n for (const [key, request] of entries) {\n const normalized =\n typeof request === 'string' ? { source: request } : request;\n const { source, metadata } = normalized;\n const hash =\n key ??\n metadata?.hash ??\n hashSource({\n source,\n dataFormat: metadata?.dataFormat ?? 'STRING',\n ...(metadata ?? {}),\n });\n hashOrder?.push(hash);\n requestsObject[hash] = {\n source,\n metadata: metadata,\n };\n }\n\n const response = await apiRequest<Record<string, TranslationResult>>(\n { ...config, baseUrl: config.baseUrl || defaultRuntimeApiUrl },\n `/v2/translate`,\n {\n body: {\n requests: requestsObject,\n targetLocale: globalMetadata.targetLocale,\n sourceLocale: globalMetadata.sourceLocale,\n metadata: globalMetadata,\n },\n timeout: timeout,\n retryPolicy: 'none',\n }\n );\n\n // If input was an array, map the record response back to an array in input order\n if (hashOrder) {\n return hashOrder.map(\n (hash) =>\n response[hash] ?? {\n success: false,\n error: 'No translation returned',\n code: 500,\n }\n );\n }\n\n // If input was a record, return the record response directly\n return response;\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport type { FileReference } from '../types-dir/api/file';\n\nexport type SetupProjectResult =\n | { setupJobId: string; status: 'queued' }\n | { status: 'completed' };\n\nexport type SetupProjectOptions = {\n force?: boolean;\n locales?: string[];\n timeoutMs?: number;\n};\n\n/**\n * @internal\n * Enqueues files for project setup the General Translation API.\n * @param files - References of files to translate (file content already uploaded)\n * @param config - The configuration for the API call\n * @param timeoutMS - The timeout in milliseconds\n * @returns The result of the API call\n */\nexport default async function _setupProject(\n files: FileReference[],\n config: TranslationRequestConfig,\n options?: SetupProjectOptions\n): Promise<SetupProjectResult> {\n return apiRequest<SetupProjectResult>(config, '/v2/project/setup/generate', {\n body: {\n files: files.map((f) => ({\n branchId: f.branchId,\n fileId: f.fileId,\n versionId: f.versionId,\n })),\n locales: options?.locales,\n force: options?.force,\n },\n timeout: options?.timeoutMs,\n });\n}\n","/**\n * Splits an array into batches of a specified size.\n * @param items - The array to split into batches\n * @param batchSize - The maximum size of each batch\n * @returns An array of batches\n */\nexport function createBatches<T>(items: T[], batchSize: number): T[][] {\n const batches: T[][] = [];\n for (let i = 0; i < items.length; i += batchSize) {\n batches.push(items.slice(i, i + batchSize));\n }\n return batches;\n}\n\n/**\n * Result of processing batches\n */\nexport interface BatchList<T> {\n /** The items successfully processed across all batches */\n data: T[];\n /** The total number of items processed */\n count: number;\n /** The number of batches processed */\n batchCount: number;\n}\n\n/**\n * Options for batch processing\n */\nexport interface BatchProcessOptions {\n /** Maximum number of items per batch (default: 100) */\n batchSize?: number;\n /** Whether to process batches in parallel (default: true) */\n parallel?: boolean;\n}\n\n/**\n * Processes items in batches using a provided processor function.\n *\n * @param items - The items to process\n * @param processor - Async function that processes a single batch and returns items\n * @param options - Optional configuration for batch processing\n * @returns Promise that resolves to a BatchList containing all processed items\n *\n * @example\n * ```typescript\n * const result = await processBatches(\n * files,\n * async (batch) => {\n * const response = await uploadFiles(batch);\n * return response.uploadedFiles;\n * },\n * { batchSize: 100 }\n * );\n *\n * console.log(result.data); // All items\n * console.log(result.count); // Total count\n * console.log(result.batchCount); // Number of batches processed\n * ```\n */\nexport async function processBatches<TInput, TOutput>(\n items: TInput[],\n processor: (batch: TInput[]) => Promise<TOutput[]>,\n options: BatchProcessOptions = {}\n): Promise<BatchList<TOutput>> {\n const { batchSize = 100, parallel = true } = options;\n\n if (items.length === 0) {\n return {\n data: [],\n count: 0,\n batchCount: 0,\n };\n }\n\n const batches = createBatches(items, batchSize);\n const allItems: TOutput[] = [];\n\n if (parallel) {\n // Process all batches in parallel\n const results = await Promise.all(batches.map((batch) => processor(batch)));\n for (const result of results) {\n if (result) {\n allItems.push(...result);\n }\n }\n } else {\n // Process batches sequentially\n for (const batch of batches) {\n const result = await processor(batch);\n if (result) {\n allItems.push(...result);\n }\n }\n }\n\n return {\n data: allItems,\n count: allItems.length,\n batchCount: batches.length,\n };\n}\n","import { TranslationRequestConfig, EnqueueFilesResult } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport type { FileReferenceIds } from '../types-dir/api/file';\nimport { processBatches } from './utils/batch';\n\nexport type EnqueueOptions = {\n sourceLocale?: string;\n targetLocales: string[];\n requireApproval?: boolean;\n modelProvider?: string;\n force?: boolean;\n timeout?: number;\n};\n\n/**\n * @internal\n * Enqueues files for translation in the General Translation API.\n * @param files - References of files to translate (file content already uploaded)\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns The result of the API call\n */\nexport default async function _enqueueFiles(\n files: FileReferenceIds[],\n options: EnqueueOptions,\n config: TranslationRequestConfig\n): Promise<EnqueueFilesResult> {\n const result = await processBatches(\n files,\n async (batch) => {\n const body = {\n files: batch.map((f) => ({\n branchId: f.branchId,\n fileId: f.fileId,\n versionId: f.versionId,\n fileName: f.fileName,\n })),\n targetLocales: options.targetLocales,\n sourceLocale: options.sourceLocale,\n requireApproval: options.requireApproval,\n modelProvider: options.modelProvider,\n force: options.force,\n };\n\n const apiResult = await apiRequest<EnqueueFilesResult>(\n config,\n '/v2/project/translations/enqueue',\n { body, timeout: options.timeout }\n );\n return Array.from(Object.entries(apiResult.jobData));\n },\n { batchSize: 100 }\n );\n // flatten the result\n const jobs = Object.fromEntries(\n result.data.map(([jobId, jobData]) => [jobId, jobData])\n );\n return {\n jobData: jobs,\n locales: options.targetLocales,\n message: `Successfully enqueued ${result.count} file translation jobs in ${result.batchCount} batch(es)`,\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type CreateTagFileReference = {\n fileId: string;\n versionId: string;\n branchId: string;\n};\n\nexport type CreateTagOptions = {\n tagId: string;\n files: CreateTagFileReference[];\n message?: string;\n};\n\nexport type CreateTagResult = {\n tag: {\n id: string;\n tagId: string;\n message: string | null;\n createdAt: string;\n updatedAt: string;\n };\n};\n\n/**\n * @internal\n * Creates or upserts a file tag in the General Translation API.\n * @param options - The tag creation options\n * @param config - The configuration for the API call\n * @returns The created or updated tag\n */\nexport default async function _createTag(\n options: CreateTagOptions,\n config: TranslationRequestConfig\n): Promise<CreateTagResult> {\n return await apiRequest<CreateTagResult>(config, '/v2/project/tags/create', {\n body: {\n tagId: options.tagId,\n files: options.files,\n ...(options.message && { message: options.message }),\n },\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport {\n DownloadFileBatchOptions,\n DownloadFileBatchRequest,\n DownloadFileBatchResult,\n} from '../types-dir/api/downloadFileBatch';\nimport apiRequest from './utils/apiRequest';\nimport { decode } from '../utils/base64';\nimport { processBatches } from './utils/batch';\n\n/**\n * @internal\n * Downloads multiple translation files in batches.\n * @param files - Array of files to download\n * @param options - The options for the API call\n * @param config - The configuration for the request\n * @returns Promise resolving to a BatchList with all downloaded files\n */\nexport default async function _downloadFileBatch(\n requests: DownloadFileBatchRequest,\n options: DownloadFileBatchOptions,\n config: TranslationRequestConfig\n) {\n return processBatches(\n requests,\n async (batch) => {\n const result = await apiRequest<DownloadFileBatchResult>(\n config,\n '/v2/project/files/download',\n { body: batch, timeout: options.timeout }\n );\n\n // convert from base64 to string\n const files = result.files.map((file) => ({\n ...file,\n data: decode(file.data),\n }));\n\n return files;\n },\n { batchSize: 100 }\n );\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { processBatches } from './utils/batch';\n\nexport type SubmitUserEditDiff = {\n fileName: string;\n locale: string;\n diff: string;\n branchId: string;\n versionId: string;\n fileId: string;\n localContent: string;\n};\n\nexport type SubmitUserEditDiffsPayload = {\n diffs: SubmitUserEditDiff[];\n};\n\n/**\n * @internal\n * Submits user edit diffs so the service can learn/persist user-intended rules.\n */\nexport default async function _submitUserEditDiffs(\n payload: SubmitUserEditDiffsPayload,\n config: TranslationRequestConfig,\n options: { timeout?: number } = {}\n): Promise<{ success: boolean }> {\n await processBatches(\n payload.diffs,\n async (batch) => {\n await apiRequest(config, '/v2/project/files/diffs', {\n body: { diffs: batch } satisfies SubmitUserEditDiffsPayload,\n timeout: options.timeout,\n });\n return [{ success: true }];\n },\n { batchSize: 100 }\n );\n\n return { success: true };\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport { defaultEmoji, emojis } from './getLocaleEmoji';\nimport { _standardizeLocale } from './isValidLocale';\n\nexport type CustomRegionMapping = {\n [region: string]: { name?: string; emoji?: string; locale?: string };\n};\n\n/**\n * Retrieves multiple properties for a given region code, including:\n * - `code`: the original region code\n * - `name`: the localized display name\n * - `emoji`: the associated flag or symbol\n *\n * Behavior:\n * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `\"US\"`, `\"FR\"`, `\"419\"`).\n * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.\n * - Otherwise, uses `Intl.DisplayNames` to get the localized region name in the given `defaultLocale`,\n * falling back to `libraryDefaultLocale`.\n * - Falls back to the region code as `name` if display name resolution fails.\n * - Falls back to `defaultEmoji` if no emoji mapping is found in `emojis` or `customMapping`.\n *\n * @param {string} region - The region code to look up (e.g., `\"US\"`, `\"GB\"`, `\"DE\"`).\n * @param {string} [defaultLocale=libraryDefaultLocale] - The locale to use when localizing the region name.\n * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.\n * @returns {{ code: string, name: string, emoji: string }} An object containing:\n * - `code`: the input region code\n * - `name`: the localized or custom region name\n * - `emoji`: the matching emoji flag or symbol\n * @internal\n *\n * @example\n * _getRegionProperties('US', 'en');\n * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }\n *\n * @example\n * _getRegionProperties('US', 'fr');\n * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }\n *\n * @example\n * _getRegionProperties('US', 'en', { US: { name: 'USA', emoji: '🗽' } });\n * // => { code: 'US', name: 'USA', emoji: '🗽' }\n */\nexport function _getRegionProperties(\n region: string,\n defaultLocale: string = libraryDefaultLocale,\n customMapping?: CustomRegionMapping\n): {\n code: string;\n name: string;\n emoji: string;\n locale?: string; // locale is a hidden return field, because we don't want to guarantee it, but we also need customMapping to work with it\n} {\n defaultLocale ||= libraryDefaultLocale;\n try {\n const displayNames = intlCache.get(\n 'DisplayNames',\n [defaultLocale, libraryDefaultLocale], // default language order\n { type: 'region' }\n );\n return {\n code: region,\n name: displayNames.of(region) || region,\n emoji: emojis[region] || defaultEmoji,\n ...customMapping?.[region],\n };\n } catch {\n return {\n code: region,\n name: region,\n emoji: defaultEmoji,\n ...customMapping?.[region],\n };\n }\n}\n","import { CustomMapping } from './customLocaleMapping';\n\n/**\n * Resolves the alias locale for a given locale.\n * @param locale - The locale to resolve the alias locale for\n * @param customMapping - The custom mapping to use for resolving the alias locale\n * @returns The alias locale\n */\nexport function _resolveAliasLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n let reverseCustomMapping: Record<string, string> | undefined;\n if (customMapping) {\n reverseCustomMapping = Object.fromEntries(\n Object.entries(customMapping)\n .filter(\n ([, value]) => value && typeof value === 'object' && 'code' in value\n )\n .map(([key, value]) => [(value as { code: string }).code, key])\n );\n }\n\n return reverseCustomMapping?.[locale] || locale;\n}\n","import { shouldUseCanonicalLocale } from './customLocaleMapping';\nimport { CustomMapping } from './customLocaleMapping';\n\n/**\n * Resolves the canonical locale for a given locale.\n * @param locale - The locale to resolve the canonical locale for\n * @param customMapping - The custom mapping to use for resolving the canonical locale\n * @returns The canonical locale\n */\nexport function _resolveCanonicalLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n return (customMapping[locale] as { code: string }).code;\n }\n\n return locale;\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { encode } from '../utils/base64';\nimport { processBatches } from './utils/batch';\n\nimport {\n FileUpload,\n UploadFilesResponse,\n RequiredUploadFilesOptions,\n} from '../types-dir/api/uploadFiles';\n\n/**\n * @internal\n * Uploads source files to the General Translation API in batches.\n * @param files - The files to upload\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns Promise resolving to a BatchList with all uploaded files\n */\nexport default async function _uploadSourceFiles(\n files: { source: FileUpload }[],\n options: RequiredUploadFilesOptions,\n config: TranslationRequestConfig\n) {\n return processBatches(\n files,\n async (batch) => {\n const body = {\n data: batch.map(({ source }) => ({\n source: {\n content: encode(source.content),\n fileName: source.fileName,\n fileFormat: source.fileFormat,\n locale: source.locale,\n dataFormat: source.dataFormat,\n formatMetadata: source.formatMetadata,\n fileId: source.fileId,\n versionId: source.versionId,\n branchId: source.branchId,\n incomingBranchId: source.incomingBranchId,\n checkedOutBranchId: source.checkedOutBranchId,\n },\n })),\n sourceLocale: options.sourceLocale,\n };\n\n const result = await apiRequest<UploadFilesResponse>(\n config,\n '/v2/project/files/upload-files',\n { body, timeout: options.timeout }\n );\n\n return result.uploadedFiles || [];\n },\n { batchSize: 100 }\n );\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { processBatches } from './utils/batch';\n\nimport {\n FileUpload,\n UploadFilesResponse,\n RequiredUploadFilesOptions,\n} from '../types-dir/api/uploadFiles';\nimport { encode } from '../utils/base64';\n\n/**\n * @internal\n * Uploads multiple translations to the General Translation API in batches.\n * @param files - Translations to upload with their source\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns Promise resolving to a BatchList with all uploaded files\n */\nexport default async function _uploadTranslations(\n files: {\n source: FileUpload;\n translations: FileUpload[];\n }[],\n options: RequiredUploadFilesOptions,\n config: TranslationRequestConfig\n) {\n return processBatches(\n files,\n async (batch) => {\n const body = {\n data: batch.map(({ source, translations }) => ({\n source: {\n content: encode(source.content),\n fileName: source.fileName,\n fileFormat: source.fileFormat,\n locale: source.locale,\n dataFormat: source.dataFormat,\n formatMetadata: source.formatMetadata,\n fileId: source.fileId,\n versionId: source.versionId,\n branchId: source.branchId,\n },\n translations: translations.map((t) => ({\n content: encode(t.content),\n fileName: t.fileName,\n fileFormat: t.fileFormat,\n locale: t.locale,\n dataFormat: t.dataFormat,\n fileId: t.fileId,\n versionId: t.versionId,\n branchId: t.branchId,\n })),\n })),\n sourceLocale: options.sourceLocale,\n };\n\n const result = await apiRequest<UploadFilesResponse>(\n config,\n '/v2/project/files/upload-translations',\n { body, timeout: options.timeout }\n );\n\n return result.uploadedFiles || [];\n },\n { batchSize: 100 }\n );\n}\n","import { TranslationRequestConfig } from '../types';\nimport {\n CheckFileTranslationsOptions,\n FileQueryResult,\n} from '../types-dir/api/checkFileTranslations';\nimport { FileQuery } from '../types-dir/api/checkFileTranslations';\nimport apiRequest from './utils/apiRequest';\n\n/**\n * @internal\n * Gets the source file and translation information for a given file ID and version ID.\n * @param query - The file ID and version ID to get the source file and translation information for\n * @param options - The options for the API call\n * @param config - The configuration for the request\n * @returns The source file and translation information for the given file ID and version ID\n */\nexport default async function _querySourceFile(\n query: FileQuery,\n options: CheckFileTranslationsOptions,\n config: TranslationRequestConfig\n): Promise<FileQueryResult> {\n const branchId = query.branchId;\n const versionId = query.versionId;\n const fileId = query.fileId;\n\n const searchParams = new URLSearchParams();\n if (branchId) {\n searchParams.set('branchId', branchId);\n }\n if (versionId) {\n searchParams.set('versionId', versionId);\n }\n const endpoint = `/v2/project/translations/files/status/${encodeURIComponent(fileId)}?${searchParams.toString()}`;\n\n return apiRequest<FileQueryResult>(config, endpoint, {\n method: 'GET',\n timeout: options.timeout,\n });\n}\n","import { defaultBaseUrl } from '../settings/settingsUrls';\nimport fetchWithTimeout from '../translate/utils/fetchWithTimeout';\nimport { defaultTimeout } from '../settings/settings';\nimport validateResponse from '../translate/utils/validateResponse';\nimport handleFetchError from '../translate/utils/handleFetchError';\nimport { TranslationRequestConfig } from '../types';\nimport generateRequestHeaders from '../translate/utils/generateRequestHeaders';\nimport { ProjectData } from '../types-dir/api/project';\n\n/**\n * @internal\n * Gets the project data for a given project ID.\n * @param projectId - The project ID to get the project data for\n * @param options - The options for the API call\n * @param config - The configuration for the request\n * @returns The project data for the given project ID\n */\nexport default async function _getProjectData(\n projectId: string,\n options: { timeout?: number },\n config: TranslationRequestConfig\n): Promise<ProjectData> {\n const { baseUrl } = config;\n const timeout = options.timeout ? options.timeout : defaultTimeout;\n const url = `${baseUrl || defaultBaseUrl}/v2/project/info/${encodeURIComponent(projectId)}`;\n\n // Get the project data\n let response;\n try {\n response = await fetchWithTimeout(\n url,\n {\n method: 'GET',\n headers: generateRequestHeaders(config),\n },\n timeout\n );\n } catch (error) {\n handleFetchError(error, timeout);\n }\n\n // Validate the response\n await validateResponse(response);\n\n const result = await response.json();\n return result as ProjectData;\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type JobStatus =\n | 'queued'\n | 'processing'\n | 'completed'\n | 'failed'\n | 'unknown';\n\nexport type CheckJobStatusResult = {\n jobId: string;\n status: JobStatus;\n error?: { message: string };\n}[];\n\n/**\n * @internal\n * Queries job statuses for a project\n * @param jobIds - Job IDs\n * @param config - The configuration for the API call\n * @param timeoutMS - The timeout in milliseconds\n * @returns The result of the API call\n */\nexport async function _checkJobStatus(\n jobIds: string[],\n config: TranslationRequestConfig,\n timeoutMs?: number\n): Promise<CheckJobStatusResult> {\n return apiRequest<CheckJobStatusResult>(config, '/v2/project/jobs/info', {\n body: { jobIds },\n timeout: timeoutMs,\n });\n}\n","import { EnqueueFilesResult } from '../types-dir/api/enqueueFiles';\nimport { TranslationRequestConfig } from '../types';\nimport { _checkJobStatus, JobStatus } from './checkJobStatus';\n\nexport type AwaitJobsOptions = {\n /** Polling interval in seconds. Defaults to 5. */\n pollingIntervalSeconds?: number;\n /** Timeout in seconds. Defaults to 600 (10 minutes). If reached, resolves with whatever status is current. */\n timeoutSeconds?: number;\n};\n\nexport type JobResult = {\n jobId: string;\n status: JobStatus;\n error?: { message: string };\n};\n\nexport type AwaitJobsResult = {\n /** Whether all jobs completed (none still in progress). */\n complete: boolean;\n jobs: JobResult[];\n};\n\n/**\n * @internal\n * Polls job statuses until all jobs are finished or the timeout is reached.\n * @param enqueueResult - The result from enqueueFiles\n * @param options - Polling configuration\n * @param config - API credentials and configuration\n * @returns The final status of all jobs\n */\nexport default async function _awaitJobs(\n enqueueResult: EnqueueFilesResult,\n options: AwaitJobsOptions | undefined,\n config: TranslationRequestConfig\n): Promise<AwaitJobsResult> {\n const pollingInterval = (options?.pollingIntervalSeconds ?? 5) * 1000;\n const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes\n const timeout =\n options?.timeoutSeconds !== undefined\n ? options.timeoutSeconds * 1000\n : DEFAULT_TIMEOUT_MS;\n\n const jobIds = Object.keys(enqueueResult.jobData);\n\n if (jobIds.length === 0) {\n return { complete: true, jobs: [] };\n }\n\n const startTime = Date.now();\n const finalStatuses = new Map<string, JobResult>(\n jobIds.map((id) => [id, { jobId: id, status: 'unknown' as JobStatus }])\n );\n const pendingJobIds = new Set(jobIds);\n\n while (pendingJobIds.size > 0) {\n const statuses = await _checkJobStatus(Array.from(pendingJobIds), config);\n\n for (const job of statuses) {\n if (\n job.status === 'completed' ||\n job.status === 'failed' ||\n job.status === 'unknown'\n ) {\n finalStatuses.set(job.jobId, {\n jobId: job.jobId,\n status: job.status,\n ...(job.error ? { error: job.error } : {}),\n });\n pendingJobIds.delete(job.jobId);\n } else {\n finalStatuses.set(job.jobId, {\n jobId: job.jobId,\n status: job.status,\n });\n }\n }\n\n if (pendingJobIds.size === 0) break;\n\n if (Date.now() - startTime >= timeout) break;\n\n await new Promise((resolve) => setTimeout(resolve, pollingInterval));\n }\n\n return {\n complete: pendingJobIds.size === 0,\n jobs: Array.from(finalStatuses.values()),\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport { CheckFileTranslationsOptions } from '../types-dir/api/checkFileTranslations';\nimport apiRequest from './utils/apiRequest';\n\nexport type FileDataQuery = {\n sourceFiles?: {\n fileId: string;\n versionId: string;\n branchId: string;\n }[];\n translatedFiles?: {\n fileId: string;\n versionId: string;\n branchId: string;\n locale: string;\n }[];\n};\n\nexport type FileDataResult = {\n sourceFiles?: {\n branchId: string;\n fileId: string;\n versionId: string;\n fileName: string;\n fileFormat: string;\n dataFormat: string | null;\n createdAt: string;\n updatedAt: string;\n approvalRequiredAt: string | null;\n publishedAt: string | null;\n locales: string[];\n sourceLocale: string;\n }[];\n translatedFiles?: {\n branchId: string;\n fileId: string;\n versionId: string;\n fileFormat: string;\n dataFormat: string | null;\n createdAt: string;\n updatedAt: string;\n approvedAt: string | null;\n publishedAt: string | null;\n completedAt: string | null;\n locale: string;\n }[];\n};\n\n/**\n * @internal\n * Queries data about one or more source or translation files.\n * @param data - Object mapping source or translation file information\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns The file data\n */\nexport default async function _queryFileData(\n data: FileDataQuery,\n options: CheckFileTranslationsOptions = {},\n config: TranslationRequestConfig\n): Promise<FileDataResult> {\n const body = {\n sourceFiles: data.sourceFiles?.map((item) => ({\n fileId: item.fileId,\n versionId: item.versionId,\n branchId: item.branchId,\n })),\n translatedFiles: data.translatedFiles?.map((item) => ({\n fileId: item.fileId,\n versionId: item.versionId,\n branchId: item.branchId,\n locale: item.locale,\n })),\n };\n\n return apiRequest<FileDataResult>(config, '/v2/project/files/info', {\n body,\n timeout: options.timeout,\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport type { BranchDataResult } from '../types-dir/api/branch';\n\nexport type BranchQuery = {\n branchNames: string[];\n};\n\n/**\n * @internal\n * Queries branch information from the API.\n * @param query - Object mapping the current branch and incoming branches\n * @param config - The configuration for the API call\n * @returns The branch information\n */\nexport default async function _queryBranchData(\n query: BranchQuery,\n config: TranslationRequestConfig\n): Promise<BranchDataResult> {\n return apiRequest<BranchDataResult>(config, '/v2/project/branches/info', {\n body: query,\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type CreateBranchQuery = {\n branchName: string;\n defaultBranch: boolean;\n};\n\nexport type CreateBranchResult = {\n branch: { id: string; name: string };\n};\n\n/**\n * @internal\n * Creates a new branch in the API.\n * @param query - Object mapping the branch name and default branch flag\n * @param config - The configuration for the API call\n * @returns The created branch information\n */\nexport default async function _createBranch(\n query: CreateBranchQuery,\n config: TranslationRequestConfig\n): Promise<CreateBranchResult> {\n return apiRequest<CreateBranchResult>(config, '/v2/project/branches/create', {\n body: query,\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { processBatches } from './utils/batch';\n\nexport type MoveMapping = {\n oldFileId: string;\n newFileId: string;\n newFileName: string;\n};\n\nexport type MoveResult = {\n oldFileId: string;\n newFileId: string;\n success: boolean;\n newSourceFileId?: string;\n clonedTranslationsCount?: number;\n error?: string;\n};\n\nexport type ProcessMovesResponse = {\n results: MoveResult[];\n summary: {\n total: number;\n succeeded: number;\n failed: number;\n };\n};\n\nexport type ProcessMovesOptions = {\n timeout?: number;\n branchId?: string;\n};\n\n/**\n * @internal\n * Processes file moves by cloning source files and translations with new fileIds.\n * Called when the CLI detects that files have been moved/renamed.\n * @param moves - Array of move mappings (old fileId to new fileId)\n * @param options - Options including branchId and timeout\n * @param config - The configuration for the API call\n * @returns Promise resolving to the move results\n */\nexport default async function _processFileMoves(\n moves: MoveMapping[],\n options: ProcessMovesOptions,\n config: TranslationRequestConfig\n): Promise<ProcessMovesResponse> {\n if (moves.length === 0) {\n return {\n results: [],\n summary: { total: 0, succeeded: 0, failed: 0 },\n };\n }\n\n const batchResult = await processBatches(\n moves,\n async (batch) => {\n const result = await apiRequest<ProcessMovesResponse>(\n config,\n '/v2/project/files/moves',\n {\n body: { branchId: options.branchId, moves: batch },\n timeout: options.timeout,\n }\n );\n return result.results;\n },\n { batchSize: 100 }\n );\n\n const succeeded = batchResult.data.filter((r) => r.success).length;\n const failed = batchResult.data.filter((r) => !r.success).length;\n\n return {\n results: batchResult.data,\n summary: {\n total: moves.length,\n succeeded,\n failed,\n },\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { createBatches } from './utils/batch';\n\nexport type OrphanedFile = {\n fileId: string;\n versionId: string;\n fileName: string;\n};\n\nexport type GetOrphanedFilesResult = {\n orphanedFiles: OrphanedFile[];\n};\n\n/**\n * @internal\n * Gets orphaned files for a branch - files that exist on the branch\n * but whose fileIds are not in the provided list.\n * Used for move detection.\n * @param branchId - The branch to check for orphaned files\n * @param fileIds - List of current file IDs (files that are NOT orphaned)\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns The orphaned files\n */\nexport default async function _getOrphanedFiles(\n branchId: string,\n fileIds: string[],\n options: { timeout?: number } = {},\n config: TranslationRequestConfig\n): Promise<GetOrphanedFilesResult> {\n const makeRequest = (batchFileIds: string[]) =>\n apiRequest<GetOrphanedFilesResult>(config, '/v2/project/files/orphaned', {\n body: { branchId, fileIds: batchFileIds },\n timeout: options.timeout,\n });\n\n // If no fileIds, make a single request\n if (fileIds.length === 0) {\n return makeRequest([]);\n }\n\n // Split fileIds into batches of 100\n const batches = createBatches(fileIds, 100);\n\n // Process batches in parallel\n // Each batch returns files NOT in that batch's fileIds\n // True orphans are files that appear in ALL batch responses (intersection)\n const batchResults = await Promise.all(\n batches.map((batch) => makeRequest(batch))\n );\n\n if (batchResults.length === 1) {\n return batchResults[0];\n }\n\n // Find intersection of orphaned files across all batches\n // A file is truly orphaned only if it's not in ANY of our fileId batches\n // Start with first batch's orphans\n const orphanedFileMap = new Map<string, OrphanedFile>();\n for (const orphan of batchResults[0].orphanedFiles) {\n orphanedFileMap.set(orphan.fileId, orphan);\n }\n\n // Intersect with each subsequent batch\n for (let i = 1; i < batchResults.length; i++) {\n const batchOrphanIds = new Set(\n batchResults[i].orphanedFiles.map((f) => f.fileId)\n );\n Array.from(orphanedFileMap.keys()).forEach((fileId) => {\n if (!batchOrphanIds.has(fileId)) {\n orphanedFileMap.delete(fileId);\n }\n });\n }\n\n return {\n orphanedFiles: Array.from(orphanedFileMap.values()),\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type PublishFileEntry = {\n fileId: string;\n versionId: string;\n branchId?: string;\n publish: boolean;\n fileName?: string;\n};\n\nexport type PublishFilesResult = {\n results: {\n fileId: string;\n versionId: string;\n locale?: string; // if locale is provided, it means this result is for a translation. Else it is for a source file.\n branchId: string;\n success: boolean;\n error?: string;\n }[];\n};\n\n/**\n * @internal\n * Publishes or unpublishes files on the CDN.\n * @param files - Array of file entries with publish flags\n * @param config - The configuration for the API call\n * @returns The result of the API call\n */\nexport default async function _publishFiles(\n files: PublishFileEntry[],\n config: TranslationRequestConfig\n): Promise<PublishFilesResult> {\n return await apiRequest<PublishFilesResult>(\n config,\n '/v2/project/files/publish',\n {\n body: { files },\n }\n );\n}\n","// `generaltranslation` language toolkit\n// © 2026, General Translation, Inc.\n\n// ----- IMPORTS ----- //\n\nimport _requiresTranslation from './locales/requiresTranslation';\nimport _determineLocale from './locales/determineLocale';\nimport {\n _formatNum,\n _formatCurrency,\n _formatList,\n _formatRelativeTime,\n _formatRelativeTimeFromDate,\n _selectRelativeTimeUnit,\n _formatDateTime,\n _formatMessageICU,\n _formatListToParts,\n _formatCutoff,\n _formatMessageString,\n} from './formatting/format';\nimport {\n CustomMapping,\n FormatVariables,\n TranslateManyResult,\n TranslationError,\n TranslationRequestConfig,\n TranslationResult,\n EnqueueFilesResult,\n CheckFileTranslationsOptions,\n DownloadFileBatchOptions,\n DownloadFileBatchResult,\n DownloadFileOptions,\n TranslateManyEntry,\n} from './types';\nimport _isSameLanguage from './locales/isSameLanguage';\nimport _getLocaleProperties, {\n LocaleProperties,\n} from './locales/getLocaleProperties';\nimport _getLocaleEmoji from './locales/getLocaleEmoji';\nimport { _isValidLocale, _standardizeLocale } from './locales/isValidLocale';\nimport { _getLocaleName } from './locales/getLocaleName';\nimport { _getLocaleDirection } from './locales/getLocaleDirection';\nimport { libraryDefaultLocale } from './internal';\nimport _isSameDialect from './locales/isSameDialect';\nimport _isSupersetLocale from './locales/isSupersetLocale';\nimport {\n noSourceLocaleProvidedError,\n noTargetLocaleProvidedError,\n invalidLocaleError,\n invalidLocalesError,\n noProjectIdProvidedError,\n noApiKeyProvidedError,\n} from './logging/errors';\nimport { gtInstanceLogger } from './logging/logger';\nimport _translateMany from './translate/translateMany';\nimport _setupProject, {\n SetupProjectResult,\n SetupProjectOptions,\n} from './translate/setupProject';\nimport _enqueueFiles, { EnqueueOptions } from './translate/enqueueFiles';\nimport _createTag, {\n CreateTagOptions,\n CreateTagResult,\n} from './translate/createTag';\nimport _downloadFileBatch from './translate/downloadFileBatch';\nimport {\n FileQuery,\n FileQueryResult,\n} from './types-dir/api/checkFileTranslations';\nimport _submitUserEditDiffs, {\n SubmitUserEditDiffsPayload,\n} from './translate/submitUserEditDiffs';\nimport {\n _getRegionProperties,\n CustomRegionMapping,\n} from './locales/getRegionProperties';\nimport { _resolveAliasLocale } from './locales/resolveAliasLocale';\nimport { _resolveCanonicalLocale } from './locales/resolveCanonicalLocale';\nimport _uploadSourceFiles from './translate/uploadSourceFiles';\nimport _uploadTranslations from './translate/uploadTranslations';\nimport {\n FileUpload,\n RequiredUploadFilesOptions,\n UploadFilesOptions,\n UploadFilesResponse,\n} from './types-dir/api/uploadFiles';\nimport _querySourceFile from './translate/querySourceFile';\nimport { ProjectData } from './types-dir/api/project';\nimport _getProjectData from './projects/getProjectData';\nimport { DownloadFileBatchRequest } from './types-dir/api/downloadFileBatch';\nimport {\n _checkJobStatus,\n CheckJobStatusResult,\n} from './translate/checkJobStatus';\nimport _awaitJobs, {\n AwaitJobsOptions,\n AwaitJobsResult,\n} from './translate/awaitJobs';\nimport type { FileDataQuery, FileDataResult } from './translate/queryFileData';\nimport _queryFileData from './translate/queryFileData';\nimport type { BranchQuery } from './translate/queryBranchData';\nimport type { BranchDataResult } from './types-dir/api/branch';\nimport _queryBranchData from './translate/queryBranchData';\nimport type {\n CreateBranchQuery,\n CreateBranchResult,\n} from './translate/createBranch';\nimport _createBranch from './translate/createBranch';\nimport type { FileReference, FileReferenceIds } from './types-dir/api/file';\nimport _processFileMoves, {\n type MoveMapping,\n type ProcessMovesResponse,\n type ProcessMovesOptions,\n} from './translate/processFileMoves';\nimport _getOrphanedFiles, {\n type GetOrphanedFilesResult,\n} from './translate/getOrphanedFiles';\nimport _publishFiles, {\n type PublishFileEntry,\n type PublishFilesResult,\n} from './translate/publishFiles';\nimport { CutoffFormatOptions } from './formatting/custom-formats/CutoffFormat/types';\nimport { TranslateOptions } from './types-dir/api/entry';\nimport { API_VERSION as _API_VERSION } from './translate/api';\nimport { StringFormat } from './types-dir/jsx/content';\n\n// ============================================================ //\n// Core Class //\n// ============================================================ //\n/**\n * Type representing the constructor parameters for the GT class.\n * @typedef {Object} GTConstructorParams\n * @property {string} [apiKey] - The API key for accessing the translation service\n * @property {string} [devApiKey] - The development API key for accessing the translation service\n * @property {string} [sourceLocale] - The default source locale for translations\n * @property {string} [targetLocale] - The default target locale for translations\n * @property {string[]} [locales] - Array of supported locales\n * @property {string} [projectId] - The project ID for the translation service\n * @property {string} [baseUrl] - The base URL for the translation service\n * @property {CustomMapping} [customMapping] - Custom mapping of locale codes to their names\n */\ntype GTConstructorParams = {\n apiKey?: string;\n devApiKey?: string;\n sourceLocale?: string;\n targetLocale?: string;\n locales?: string[];\n projectId?: string;\n baseUrl?: string;\n customMapping?: CustomMapping;\n};\n\n/**\n * GT is the core driver for the General Translation library.\n * This class provides functionality for locale management, formatting, and translation operations.\n *\n * @class GT\n * @description A comprehensive toolkit for handling internationalization and localization.\n *\n * @example\n * const gt = new GT({\n * sourceLocale: 'en-US',\n * targetLocale: 'es-ES',\n * locales: ['en-US', 'es-ES', 'fr-FR']\n * });\n */\nexport class GT {\n /** Base URL for the translation service API */\n baseUrl?: string;\n\n /** Project ID for the translation service */\n projectId?: string;\n\n /** API key for accessing the translation service */\n apiKey?: string;\n\n /** Development API key for accessing the translation service */\n devApiKey?: string;\n\n /** Source locale for translations */\n sourceLocale?: string;\n\n /** Target locale for translations */\n targetLocale?: string;\n\n /** Array of supported locales */\n locales?: string[];\n\n /** Array of locales used for rendering variables */\n _renderingLocales: string[] = [];\n\n /** Custom mapping for locale codes to their names */\n customMapping?: CustomMapping;\n\n /** Lazily derived reverse custom mapping for alias locales */\n reverseCustomMapping?: Record<string, string>;\n\n /** Lazily derived custom mapping for regions */\n customRegionMapping?: CustomRegionMapping;\n\n /**\n * Constructs an instance of the GT class.\n *\n * @param {GTConstructorParams} [params] - The parameters for initializing the GT instance\n * @throws {Error} If an invalid locale is provided\n * @throws {Error} If any of the provided locales are invalid\n *\n * @example\n * const gt = new GT({\n * apiKey: 'your-api-key',\n * sourceLocale: 'en-US',\n * targetLocale: 'es-ES',\n * locales: ['en-US', 'es-ES', 'fr-FR']\n * });\n */\n constructor(params: GTConstructorParams = {}) {\n // Read environment\n if (typeof process !== 'undefined') {\n this.apiKey ||= process.env?.GT_API_KEY;\n this.devApiKey ||= process.env?.GT_DEV_API_KEY;\n this.projectId ||= process.env?.GT_PROJECT_ID;\n }\n // Set up config\n this.setConfig(params);\n }\n\n setConfig({\n apiKey,\n devApiKey,\n sourceLocale,\n targetLocale,\n locales,\n projectId,\n customMapping,\n baseUrl,\n }: GTConstructorParams) {\n // ----- Environment properties ----- //\n if (apiKey) this.apiKey = apiKey;\n if (devApiKey) this.devApiKey = devApiKey;\n if (projectId) this.projectId = projectId;\n\n // ----- Standardize locales ----- //\n\n // source locale\n if (sourceLocale) {\n this.sourceLocale = _standardizeLocale(sourceLocale);\n if (!_isValidLocale(this.sourceLocale, customMapping))\n throw new Error(invalidLocaleError(this.sourceLocale));\n }\n\n // target locale\n if (targetLocale) {\n this.targetLocale = _standardizeLocale(targetLocale);\n if (!_isValidLocale(this.targetLocale, customMapping))\n throw new Error(invalidLocaleError(this.targetLocale));\n }\n\n // rendering locales\n this._renderingLocales = [];\n if (this.sourceLocale) this._renderingLocales.push(this.sourceLocale);\n if (this.targetLocale) this._renderingLocales.push(this.targetLocale);\n this._renderingLocales.push(libraryDefaultLocale);\n\n // locales\n if (locales) {\n const result: string[] = [];\n const invalidLocales: string[] = [];\n locales.forEach((locale) => {\n const standardizedLocale = _standardizeLocale(locale);\n if (_isValidLocale(standardizedLocale)) {\n result.push(standardizedLocale);\n } else {\n invalidLocales.push(locale);\n }\n });\n if (invalidLocales.length > 0) {\n throw new Error(invalidLocalesError(invalidLocales));\n }\n this.locales = result;\n }\n\n // ----- Other properties ----- //\n if (baseUrl) this.baseUrl = baseUrl;\n if (customMapping) {\n this.customMapping = customMapping;\n this.reverseCustomMapping = Object.fromEntries(\n Object.entries(customMapping)\n .filter(\n ([, value]) => value && typeof value === 'object' && 'code' in value\n )\n .map(([key, value]) => [(value as { code: string }).code, key])\n );\n }\n }\n\n // -------------- Private Methods -------------- //\n\n private _getTranslationConfig(): TranslationRequestConfig {\n return {\n baseUrl: this.baseUrl,\n apiKey: this.apiKey || this.devApiKey,\n projectId: this.projectId || '',\n };\n }\n\n private _validateAuth(functionName: string) {\n const errors: string[] = [];\n if (!this.apiKey && !this.devApiKey) {\n const error = noApiKeyProvidedError(functionName);\n errors.push(error);\n }\n if (!this.projectId) {\n const error = noProjectIdProvidedError(functionName);\n errors.push(error);\n }\n if (errors.length) {\n throw new Error(errors.join('\\n'));\n }\n }\n\n // -------------- Branch Methods -------------- //\n\n /**\n * Queries branch information from the API.\n *\n * @param {BranchQuery} query - Object mapping the current branch and incoming branches\n * @returns {Promise<BranchDataResult>} The branch information\n */\n async queryBranchData(query: BranchQuery): Promise<BranchDataResult> {\n this._validateAuth('queryBranchData');\n return await _queryBranchData(query, this._getTranslationConfig());\n }\n\n /**\n * Creates a new branch in the API. If the branch already exists, it will be returned.\n *\n * @param {CreateBranchQuery} query - Object mapping the branch name and default branch flag\n * @returns {Promise<CreateBranchResult>} The created branch information\n */\n async createBranch(query: CreateBranchQuery): Promise<CreateBranchResult> {\n this._validateAuth('createBranch');\n return await _createBranch(query, this._getTranslationConfig());\n }\n\n /**\n * Processes file moves by cloning source files and translations with new fileIds.\n * This is called when files have been moved/renamed and we want to preserve translations.\n *\n * @param {MoveMapping[]} moves - Array of move mappings (old fileId to new fileId)\n * @param {ProcessMovesOptions} options - Options including branchId and timeout\n * @returns {Promise<ProcessMovesResponse>} The move processing results\n *\n * @example\n * const result = await gt.processFileMoves([\n * { oldFileId: 'abc123', newFileId: 'def456', newFileName: 'locales/en.json' }\n * ], { branchId: 'main' });\n */\n async processFileMoves(\n moves: MoveMapping[],\n options: ProcessMovesOptions = {}\n ): Promise<ProcessMovesResponse> {\n this._validateAuth('processFileMoves');\n return await _processFileMoves(\n moves,\n options,\n this._getTranslationConfig()\n );\n }\n\n /**\n * Gets orphaned files for a branch - files that exist on the branch\n * but whose fileIds are not in the provided list.\n * Used for move detection.\n *\n * @param {string} branchId - The branch to check for orphaned files\n * @param {string[]} fileIds - List of current file IDs (files that are NOT orphaned)\n * @param {Object} options - Options including timeout\n * @returns {Promise<GetOrphanedFilesResult>} The orphaned files\n *\n * @example\n * const result = await gt.getOrphanedFiles('branch-id', ['file-1', 'file-2']);\n */\n async getOrphanedFiles(\n branchId: string,\n fileIds: string[],\n options: { timeout?: number } = {}\n ): Promise<GetOrphanedFilesResult> {\n this._validateAuth('getOrphanedFiles');\n return await _getOrphanedFiles(\n branchId,\n fileIds,\n options,\n this._getTranslationConfig()\n );\n }\n\n // -------------- Translation Methods -------------- //\n\n /**\n * Enqueues project setup job using the specified file references\n *\n * This method creates setup jobs that will process source file references\n * and generate a project setup. The files parameter contains references (IDs) to source\n * files that have already been uploaded via uploadSourceFiles. The setup jobs are queued\n * for processing and will generate a project setup based on the source files.\n *\n * @param {FileReference[]} files - Array of file references containing IDs of previously uploaded source files\n * @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout\n * @returns {Promise<SetupProjectResult>} Object containing the jobId and status\n */\n async setupProject(\n files: FileReference[],\n options?: SetupProjectOptions\n ): Promise<SetupProjectResult> {\n this._validateAuth('setupProject');\n options = {\n ...options,\n locales: options?.locales?.map((locale) =>\n this.resolveCanonicalLocale(locale)\n ),\n };\n return await _setupProject(files, this._getTranslationConfig(), options);\n }\n\n /**\n * Checks the current status of one or more project jobs by their unique identifiers.\n *\n * This method polls the API to determine whether one or more jobs are still running,\n * have completed successfully, or have failed. Jobs are created after calling either enqueueFiles or setupProject.\n *\n * @param {string[]} jobIds - The unique identifiers of the jobs to check\n * @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request\n * @returns {Promise<CheckJobStatusResult>} Object containing the job status\n *\n * @example\n * const result = await gt.checkJobStatus([\n * 'job-123',\n * 'job-456',\n * ], {\n * timeout: 10000,\n * });\n */\n async checkJobStatus(\n jobIds: string[],\n timeoutMs?: number\n ): Promise<CheckJobStatusResult> {\n this._validateAuth('checkJobStatus');\n return await _checkJobStatus(\n jobIds,\n this._getTranslationConfig(),\n timeoutMs\n );\n }\n\n /**\n * Polls job statuses until all jobs from enqueueFiles are finished or the timeout is reached.\n *\n * @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles\n * @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout)\n * @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed\n */\n async awaitJobs(\n enqueueResult: EnqueueFilesResult,\n options?: AwaitJobsOptions\n ): Promise<AwaitJobsResult> {\n this._validateAuth('awaitJobs');\n return await _awaitJobs(\n enqueueResult,\n options,\n this._getTranslationConfig()\n );\n }\n\n /**\n * Enqueues translation jobs for previously uploaded source files.\n *\n * This method creates translation jobs that will process existing source files\n * and generate translations in the specified target languages. The files parameter\n * contains references (IDs) to source files that have already been uploaded via\n * uploadSourceFiles. The translation jobs are queued for processing and will\n * generate translated content based on the source files and target locales provided.\n *\n * @param {FileReferenceIds[]} files - Array of file references containing IDs of previously uploaded source files\n * @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings\n * @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information\n */\n async enqueueFiles(\n files: FileReferenceIds[],\n options: EnqueueOptions\n ): Promise<EnqueueFilesResult> {\n // Validation\n this._validateAuth('enqueueFiles');\n\n // Merge instance settings with options\n let mergedOptions: EnqueueOptions = {\n ...options,\n sourceLocale: options.sourceLocale ?? this.sourceLocale!,\n targetLocales: options.targetLocales ?? [this.targetLocale!],\n };\n\n // Require source locale\n if (!mergedOptions.sourceLocale) {\n const error = noSourceLocaleProvidedError('enqueueFiles');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Require target locale(s)\n if (\n !mergedOptions.targetLocales ||\n mergedOptions.targetLocales.length === 0\n ) {\n const error = noTargetLocaleProvidedError('enqueueFiles');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Replace target locales with canonical locales\n mergedOptions = {\n ...mergedOptions,\n targetLocales: mergedOptions.targetLocales.map((locale) =>\n this.resolveCanonicalLocale(locale)\n ),\n };\n\n return await _enqueueFiles(\n files,\n mergedOptions,\n this._getTranslationConfig()\n );\n }\n\n /**\n * Creates or upserts a file tag, associating a set of source files\n * with a user-defined tag ID and optional message.\n *\n * @param {CreateTagOptions} options - Tag creation options including tagId, sourceFileIds, and optional message\n * @returns {Promise<CreateTagResult>} The created or updated tag\n */\n async createTag(options: CreateTagOptions): Promise<CreateTagResult> {\n this._validateAuth('createTag');\n return await _createTag(options, this._getTranslationConfig());\n }\n\n /**\n * Publishes or unpublishes files on the CDN.\n *\n * @param {PublishFileEntry[]} files - Array of file entries with publish flags\n * @returns {Promise<PublishFilesResult>} Result containing per-file success/failure\n */\n async publishFiles(files: PublishFileEntry[]): Promise<PublishFilesResult> {\n this._validateAuth('publishFiles');\n return await _publishFiles(files, this._getTranslationConfig());\n }\n\n /**\n * Submits user edit diffs for existing translations so future generations preserve user intent.\n *\n * @param {SubmitUserEditDiffsPayload} payload - Project-scoped diff payload.\n * @returns {Promise<void>} Resolves when submission succeeds.\n */\n async submitUserEditDiffs(\n payload: SubmitUserEditDiffsPayload\n ): Promise<void> {\n this._validateAuth('submitUserEditDiffs');\n // Normalize locales to canonical form before submission\n const normalized: SubmitUserEditDiffsPayload = {\n ...payload,\n diffs: (payload.diffs || []).map((d) => ({\n ...d,\n locale: this.resolveCanonicalLocale(d.locale),\n })),\n };\n await _submitUserEditDiffs(normalized, this._getTranslationConfig());\n }\n\n /**\n * Queries data about one or more source or translation files.\n *\n * @param {FileDataQuery} data - Object mapping source and translation file information.\n * @param {CheckFileTranslationsOptions} options - Options for the API call.\n * @returns {Promise<FileDataResult>} The source and translation file data information.\n *\n * @example\n * const result = await gt.queryFileData({\n * sourceFiles: [\n * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890' },\n * ],\n * translatedFiles: [\n * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890', locale: 'es-ES' },\n * ],\n * }, {\n * timeout: 10000,\n * });\n *\n */\n async queryFileData(\n data: FileDataQuery,\n options: CheckFileTranslationsOptions = {}\n ): Promise<FileDataResult> {\n // Validation\n this._validateAuth('queryFileData');\n\n // Replace target locales with canonical locales\n data.translatedFiles = data.translatedFiles?.map((item) => ({\n ...item,\n locale: this.resolveCanonicalLocale(item.locale),\n }));\n\n // Request the file translation status\n const result = await _queryFileData(\n data,\n options,\n this._getTranslationConfig()\n );\n\n // Resolve canonical locales\n result.translatedFiles = result.translatedFiles?.map((item) => ({\n ...item,\n ...(item.locale && { locale: this.resolveAliasLocale(item.locale) }),\n }));\n result.sourceFiles = result.sourceFiles?.map((item) => ({\n ...item,\n ...(item.sourceLocale && {\n sourceLocale: this.resolveAliasLocale(item.sourceLocale),\n }),\n locales: item.locales.map((locale) => this.resolveAliasLocale(locale)),\n }));\n return result;\n }\n\n /**\n * Gets source and translation information for a given file ID and version ID.\n *\n * @param {FileQuery} data - File query containing file ID and version ID.\n * @param {CheckFileTranslationsOptions} options - Options for getting source and translation information.\n * @returns {Promise<FileQueryResult>} The source file and translation information.\n *\n * @example\n * const result = await gt.querySourceFile(\n * { fileId: '1234567890', versionId: '1234567890' },\n * { timeout: 10000 }\n * );\n *\n */\n async querySourceFile(\n data: FileQuery,\n options: CheckFileTranslationsOptions = {}\n ): Promise<FileQueryResult> {\n // Validation\n this._validateAuth('querySourceFile');\n\n // Request the file translation status\n const result = await _querySourceFile(\n data,\n options,\n this._getTranslationConfig()\n );\n // Replace locales with canonical locales\n result.translations = result.translations.map((item) => ({\n ...item,\n ...(item.locale && { locale: this.resolveAliasLocale(item.locale) }),\n }));\n result.sourceFile.locales = result.sourceFile.locales.map((locale) =>\n this.resolveAliasLocale(locale)\n );\n if (result.sourceFile.sourceLocale) {\n result.sourceFile.sourceLocale = this.resolveAliasLocale(\n result.sourceFile.sourceLocale\n );\n }\n return result;\n }\n /**\n * Get project data for a given project ID.\n *\n * @param {string} projectId - The ID of the project to get the data for.\n * @returns {Promise<ProjectData>} The project data.\n *\n * @example\n * const result = await gt.getProjectData(\n * '1234567890'\n * );\n *\n */\n async getProjectData(\n projectId: string,\n options: { timeout?: number } = {}\n ): Promise<ProjectData> {\n // Validation\n this._validateAuth('getProjectData');\n\n // Request the file translation status\n const result = await _getProjectData(\n projectId,\n options,\n this._getTranslationConfig()\n );\n // Replace locales with canonical locales\n result.currentLocales = result.currentLocales.map((item) =>\n this.resolveAliasLocale(item)\n );\n result.defaultLocale = this.resolveAliasLocale(result.defaultLocale);\n return result;\n }\n\n /**\n * Downloads a single file.\n *\n * @param file - The file query object.\n * @param {string} file.fileId - The ID of the file to download.\n * @param {string} [file.branchId] - The ID of the branch to download the file from. If not provided, the default branch will be used.\n * @param {string} [file.locale] - The locale to download the file for. If not provided, the source file will be downloaded.\n * @param {string} [file.versionId] - The version ID to download the file from. If not provided, the latest version will be used.\n * @param {DownloadFileOptions} options - Options for downloading the file.\n * @returns {Promise<string>} The downloaded file content.\n *\n * @example\n * const result = await gt.downloadFile({\n * fileId: '1234567890',\n * branchId: '1234567890',\n * locale: 'es-ES',\n * versionId: '1234567890',\n * }, {\n * timeout: 10000,\n * });\n */\n async downloadFile(\n file: {\n fileId: string;\n branchId?: string;\n locale?: string;\n versionId?: string;\n useLatestAvailableVersion?: boolean;\n },\n options: DownloadFileOptions = {}\n ): Promise<string> {\n // Validation\n this._validateAuth('downloadTranslatedFile');\n\n const result = await _downloadFileBatch(\n [\n {\n fileId: file.fileId,\n branchId: file.branchId,\n locale: file.locale\n ? this.resolveCanonicalLocale(file.locale)\n : undefined,\n versionId: file.versionId,\n useLatestAvailableVersion: file.useLatestAvailableVersion,\n },\n ],\n options,\n this._getTranslationConfig()\n );\n return result.data?.[0]?.data ?? '';\n }\n\n /**\n * Downloads multiple files in a batch.\n *\n * @param {DownloadFileBatchRequest} requests - Array of file query objects to download.\n * @param {DownloadFileBatchOptions} options - Options for the batch download.\n * @returns {Promise<DownloadFileBatchResult>} The batch download results.\n *\n * @example\n * const result = await gt.downloadFileBatch([{\n * fileId: '1234567890',\n * locale: 'es-ES',\n * versionId: '1234567890',\n * }], {\n * timeout: 10000,\n * });\n */\n async downloadFileBatch(\n requests: DownloadFileBatchRequest,\n options: DownloadFileBatchOptions = {}\n ): Promise<DownloadFileBatchResult> {\n // Validation\n this._validateAuth('downloadFileBatch');\n\n requests = requests.map((request) => ({\n ...request,\n locale: request.locale\n ? this.resolveCanonicalLocale(request.locale)\n : undefined,\n }));\n\n // Request the batch download\n const result = await _downloadFileBatch(\n requests,\n options,\n this._getTranslationConfig()\n );\n\n return {\n files: result.data.map((file) => ({\n ...file,\n ...(file.locale && {\n locale: this.resolveAliasLocale(file.locale),\n }),\n })),\n count: result.count,\n };\n }\n\n /**\n * Translates a single source string to the target locale.\n * Routes through {@link translateMany} under the hood.\n *\n * @param {string} source - The source string to translate.\n * @param {object} options - Translation options including targetLocale and optional entry metadata.\n * @returns {Promise<TranslationResult | TranslationError>} The translated content.\n *\n * @example\n * const result = await gt.translate('Hello, world!', { targetLocale: 'es' });\n *\n * @example\n * const result = await gt.translate('Hello, world!', {\n * targetLocale: 'es',\n * dataFormat: 'ICU',\n * context: 'A formal greeting',\n * });\n */\n async translate(\n source: TranslateManyEntry,\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<TranslationResult | TranslationError> {\n // Normalize string shorthand to options object\n if (typeof options === 'string') {\n options = { targetLocale: options };\n }\n\n // Validation\n this._validateAuth('translate');\n\n // Require target locale\n let targetLocale = options?.targetLocale || this.targetLocale;\n if (!targetLocale) {\n const error = noTargetLocaleProvidedError('translate');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Replace target locale with canonical locale\n targetLocale = this.resolveCanonicalLocale(targetLocale);\n\n const sourceLocale = this.resolveCanonicalLocale(\n options?.sourceLocale || this.sourceLocale || libraryDefaultLocale\n );\n\n // Request the translation\n const results = await _translateMany(\n [source],\n {\n ...options,\n targetLocale,\n sourceLocale,\n },\n this._getTranslationConfig(),\n timeout\n );\n return results[0];\n }\n\n /**\n * Translates multiple source strings to the target locale.\n * Each entry can be a plain string or an object with source and metadata fields.\n *\n * @param {TranslateManyEntry[] | Record<string, TranslateManyEntry>} sources - The source entries to translate. Can be an array or a record keyed by hash.\n * @param {object} options - Translation options including targetLocale.\n * @returns {Promise<TranslateManyResult | Record<string, TranslationResult>>} The translated contents. An array if sources was an array, a record if sources was a record.\n *\n * @example\n * const result = await gt.translateMany(\n * ['Hello, world!', 'Goodbye, world!'],\n * { targetLocale: 'es' }\n * );\n *\n * @example\n * const result = await gt.translateMany(\n * [{ source: 'Hello, world!', dataFormat: 'ICU' }],\n * { targetLocale: 'es' }\n * );\n *\n * @example\n * const result = await gt.translateMany(\n * { 'my-hash': 'Hello, world!' },\n * { targetLocale: 'es' }\n * );\n */\n async translateMany(\n sources: TranslateManyEntry[],\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<TranslateManyResult>;\n async translateMany(\n sources: Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<Record<string, TranslationResult>>;\n async translateMany(\n sources: TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<TranslateManyResult | Record<string, TranslationResult>> {\n // Normalize string shorthand to options object\n if (typeof options === 'string') {\n options = { targetLocale: options };\n }\n\n // Validation\n this._validateAuth('translateMany');\n\n // Require target locale\n let targetLocale = options?.targetLocale || this.targetLocale;\n if (!targetLocale) {\n const error = noTargetLocaleProvidedError('translateMany');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Replace target locale with canonical locale\n targetLocale = this.resolveCanonicalLocale(targetLocale);\n\n const sourceLocale = this.resolveCanonicalLocale(\n options?.sourceLocale || this.sourceLocale || libraryDefaultLocale\n );\n\n // Request the translation\n return await _translateMany(\n sources,\n {\n ...options,\n targetLocale,\n sourceLocale,\n },\n this._getTranslationConfig(),\n timeout\n );\n }\n\n /**\n * Uploads source files to the translation service without any translation content.\n *\n * This method creates or replaces source file entries in your project. Each uploaded\n * file becomes a source that can later be translated into target languages. The files\n * are processed and stored as base entries that serve as the foundation for generating\n * translations through the translation workflow.\n *\n * @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload\n * @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings\n * @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status\n */\n async uploadSourceFiles(\n files: { source: FileUpload }[],\n options: UploadFilesOptions\n ): Promise<UploadFilesResponse> {\n // Validation\n this._validateAuth('uploadSourceFiles');\n\n // Merge instance settings with options\n const mergedOptions: UploadFilesOptions = {\n ...options,\n sourceLocale: this.resolveCanonicalLocale(\n options.sourceLocale ?? this.sourceLocale ?? libraryDefaultLocale\n ),\n };\n\n // resolve canonical locales\n files = files.map((f) => ({\n ...f,\n source: {\n ...f.source,\n locale: this.resolveCanonicalLocale(f.source.locale),\n },\n }));\n\n // Process files in batches and convert result to UploadFilesResponse\n const result = await _uploadSourceFiles(\n files,\n mergedOptions as RequiredUploadFilesOptions,\n this._getTranslationConfig()\n );\n\n return {\n uploadedFiles: result.data,\n count: result.count,\n message: `Successfully uploaded ${result.count} files in ${result.batchCount} batch(es)`,\n };\n }\n\n /**\n * Uploads translation files that correspond to previously uploaded source files.\n *\n * This method allows you to provide translated content for existing source files in your project.\n * Each translation must reference an existing source file and include the translated content\n * along with the target locale information. This is used when you have pre-existing translations\n * that you want to upload directly rather than generating them through the translation service.\n *\n * @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where:\n * - `source`: Reference to the existing source file (contains IDs but no content)\n * - `translations`: Array of translated files, each containing content, locale, and reference IDs\n * @param {UploadFilesOptions} options - Configuration options including source locale and upload settings\n * @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information\n */\n async uploadTranslations(\n files: {\n source: FileUpload; // reference only (no content)\n translations: FileUpload[]; // each has content + ids + locale\n }[],\n options: UploadFilesOptions\n ): Promise<UploadFilesResponse> {\n // Validation\n this._validateAuth('uploadTranslations');\n\n // Merge instance settings with options\n const mergedOptions: UploadFilesOptions = {\n ...options,\n sourceLocale: options.sourceLocale ?? this.sourceLocale,\n };\n\n // Require source locale\n if (!mergedOptions.sourceLocale) {\n const error = noSourceLocaleProvidedError('uploadTranslations');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Ensure all translation locales use canonical locales\n const targetFiles = files.map((f) => ({\n ...f,\n translations: f.translations.map((t) => ({\n ...t,\n locale: this.resolveCanonicalLocale(t.locale),\n })),\n }));\n\n // Process files in batches and convert result to UploadFilesResponse\n const result = await _uploadTranslations(\n targetFiles,\n mergedOptions as RequiredUploadFilesOptions,\n this._getTranslationConfig()\n );\n\n return {\n uploadedFiles: result.data,\n count: result.count,\n message: `Successfully uploaded ${result.count} files in ${result.batchCount} batch(es)`,\n };\n }\n\n // -------------- Formatting -------------- //\n\n /**\n * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.\n *\n * This method uses the GT instance's rendering locales by default for locale-specific terminator selection,\n * but can be overridden with custom locales in the options.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @param {Object} [options] - Configuration options for cutoff formatting.\n * @param {string | string[]} [options.locales] - The locales to use for terminator selection. Defaults to instance's rendering locales.\n * @param {number} [options.maxChars] - The maximum number of characters to display.\n * - Undefined values are treated as no cutoff.\n * - Negative values follow .slice() behavior and terminator will be added before the value.\n * - 0 will result in an empty string.\n * - If cutoff results in an empty string, no terminator is added.\n * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.\n * @param {string} [options.terminator] - Optional override the terminator to use.\n * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.\n * - If no terminator is provided, then separator is ignored.\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n *\n * @example\n * const gt = new GT({ targetLocale: 'en-US' });\n * gt.formatCutoff('Hello, world!', { maxChars: 8 });\n * // Returns: 'Hello, w...'\n *\n * @example\n * gt.formatCutoff('Hello, world!', { maxChars: -3 });\n * // Returns: '...ld!'\n */\n formatCutoff(\n value: string,\n options?: {\n locales?: string | string[];\n } & CutoffFormatOptions\n ): string {\n return formatCutoff(value, {\n locales: this._renderingLocales,\n ...options,\n });\n }\n\n /**\n * Formats a message according to the specified locales and options.\n *\n * @param {string} message - The message to format.\n * @param {string | string[]} [locales='en'] - The locales to use for formatting.\n * @param {FormatVariables} [variables={}] - The variables to use for formatting.\n * @param {StringFormat} [dataFormat='ICU'] - The format of the message.\n * @returns {string} The formatted message.\n *\n * @example\n * gt.formatMessage('Hello {name}', { name: 'John' });\n * // Returns: \"Hello John\"\n *\n * gt.formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });\n * // Returns: \"Bonjour John\"\n */\n formatMessage(\n message: string,\n options?: {\n locales?: string | string[];\n variables?: FormatVariables;\n dataFormat?: StringFormat;\n }\n ): string {\n return formatMessage(message, {\n locales: this._renderingLocales,\n ...options,\n });\n }\n /**\n * Formats a number according to the specified locales and options.\n *\n * @param {number} number - The number to format\n * @param {Object} [options] - Additional options for number formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options\n * @returns {string} The formatted number\n *\n * @example\n * gt.formatNum(1234.56, { style: 'currency', currency: 'USD' });\n * // Returns: \"$1,234.56\"\n */\n formatNum(\n number: number,\n options?: {\n locales?: string | string[];\n } & Intl.NumberFormatOptions\n ): string {\n return formatNum(number, {\n locales: this._renderingLocales,\n ...options,\n });\n }\n\n /**\n * Formats a date according to the specified locales and options.\n *\n * @param {Date} date - The date to format\n * @param {Object} [options] - Additional options for date formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options\n * @returns {string} The formatted date\n *\n * @example\n * gt.formatDateTime(new Date(), { dateStyle: 'full', timeStyle: 'long' });\n * // Returns: \"Thursday, March 14, 2024 at 2:30:45 PM GMT-7\"\n */\n formatDateTime(\n date: Date,\n options?: {\n locales?: string | string[];\n } & Intl.DateTimeFormatOptions\n ): string {\n return formatDateTime(date, {\n locales: this._renderingLocales,\n ...options,\n });\n }\n\n /**\n * Formats a currency value according to the specified locales and options.\n *\n * @param {number} value - The currency value to format\n * @param {string} currency - The currency code (e.g., 'USD', 'EUR')\n * @param {Object} [options] - Additional options for currency formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options\n * @returns {string} The formatted currency value\n *\n * @example\n * gt.formatCurrency(1234.56, 'USD', { style: 'currency' });\n * // Returns: \"$1,234.56\"\n */\n formatCurrency(\n value: number,\n currency: string,\n options?: {\n locales?: string | string[];\n } & Intl.NumberFormatOptions\n ): string {\n return formatCurrency(value, currency, {\n locales: this._renderingLocales,\n ...options,\n });\n }\n\n /**\n * Formats a list of items according to the specified locales and options.\n *\n * @param {Array<string | number>} array - The list of items to format\n * @param {Object} [options] - Additional options for list formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options\n * @returns {string} The formatted list\n *\n * @example\n * gt.formatList(['apple', 'banana', 'orange'], { type: 'conjunction' });\n * // Returns: \"apple, banana, and orange\"\n */\n formatList(\n array: Array<string | number>,\n options?: {\n locales?: string | string[];\n } & Intl.ListFormatOptions\n ) {\n return _formatList({\n value: array,\n locales: options?.locales || this._renderingLocales,\n options: options,\n });\n }\n\n /**\n * Formats a list of items according to the specified locales and options.\n * @param {Array<T>} array - The list of items to format\n * @param {Object} [options] - Additional options for list formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options\n * @returns {Array<T | string>} The formatted list parts\n *\n * @example\n * gt.formatListToParts(['apple', 42, { foo: 'bar' }], { type: 'conjunction', style: 'short', locales: ['en'] });\n * // Returns: ['apple', ', ', 42, ' and ', '{ foo: \"bar\" }']\n */\n formatListToParts<T>(\n array: Array<T>,\n options?: {\n locales?: string | string[];\n } & Intl.ListFormatOptions\n ): Array<T | string> {\n return _formatListToParts<T>({\n value: array,\n locales: options?.locales || this._renderingLocales,\n options: options,\n });\n }\n\n /**\n * Formats a relative time value according to the specified locales and options.\n *\n * @param {number} value - The relative time value to format\n * @param {Intl.RelativeTimeFormatUnit} unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year')\n * @param {Object} options - Additional options for relative time formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options\n * @returns {string} The formatted relative time string\n *\n * @example\n * gt.formatRelativeTime(-1, 'day', { locales: ['en-US'], numeric: 'auto' });\n * // Returns: \"yesterday\"\n */\n formatRelativeTime(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n options?: {\n locales?: string | string[];\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n ): string {\n return formatRelativeTime(value, unit, {\n locales: this._renderingLocales,\n ...options,\n });\n }\n\n /**\n * Formats a relative time string from a Date, automatically selecting the best unit.\n *\n * @param {Date} date - The date to format relative to now\n * @param {Object} [options] - Additional options for relative time formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @returns {string} The formatted relative time string (e.g., \"2 hours ago\", \"in 3 days\")\n *\n * @example\n * gt.formatRelativeTimeFromDate(new Date(Date.now() - 3600000));\n * // Returns: \"1 hour ago\"\n */\n formatRelativeTimeFromDate(\n date: Date,\n options?: {\n locales?: string | string[];\n baseDate?: Date;\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n ): string {\n return formatRelativeTimeFromDate(date, {\n locales: this._renderingLocales,\n ...options,\n });\n }\n\n // -------------- Locale Properties -------------- //\n\n /**\n * Retrieves the display name of a locale code using Intl.DisplayNames, returning an empty string if no name is found.\n *\n * @param {string} [locale=this.targetLocale] - A BCP-47 locale code\n * @returns {string} The display name corresponding to the code\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.getLocaleName('es-ES');\n * // Returns: \"Spanish (Spain)\"\n */\n getLocaleName(locale = this.targetLocale): string {\n if (!locale) throw new Error(noTargetLocaleProvidedError('getLocaleName'));\n return _getLocaleName(locale, this.sourceLocale, this.customMapping);\n }\n\n /**\n * Retrieves an emoji based on a given locale code.\n * Uses the locale's region (if present) to select an emoji or falls back on default emojis.\n *\n * @param {string} [locale=this.targetLocale] - A BCP-47 locale code (e.g., 'en-US', 'fr-CA')\n * @returns {string} The emoji representing the locale or its region\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.getLocaleEmoji('es-ES');\n * // Returns: \"🇪🇸\"\n */\n getLocaleEmoji(locale = this.targetLocale): string {\n if (!locale) throw new Error(noTargetLocaleProvidedError('getLocaleEmoji'));\n return getLocaleEmoji(locale, this.customMapping);\n }\n\n /**\n * Generates linguistic details for a given locale code.\n *\n * This function returns information about the locale,\n * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).\n * The function provides these names in both your default language and native forms, and an associated emoji.\n *\n * @param {string} [locale=this.targetLocale] - The locale code to get properties for (e.g., \"de-AT\").\n * @returns {LocaleProperties} - An object containing detailed information about the locale.\n *\n * @property {string} code - The full locale code, e.g., \"de-AT\".\n * @property {string} name - Language name in the default display language, e.g., \"Austrian German\".\n * @property {string} nativeName - Language name in the locale's native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} languageCode - The base language code, e.g., \"de\".\n * @property {string} languageName - The language name in the default display language, e.g., \"German\".\n * @property {string} nativeLanguageName - The language name in the native language, e.g., \"Deutsch\".\n * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., \"German (AT)\".\n * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., \"Deutsch (AT)\".\n * @property {string} regionCode - The region code from maximization, e.g., \"AT\".\n * @property {string} regionName - The region name in the default display language, e.g., \"Austria\".\n * @property {string} nativeRegionName - The region name in the native language, e.g., \"Österreich\".\n * @property {string} scriptCode - The script code from maximization, e.g., \"Latn\".\n * @property {string} scriptName - The script name in the default display language, e.g., \"Latin\".\n * @property {string} nativeScriptName - The script name in the native language, e.g., \"Lateinisch\".\n * @property {string} maximizedCode - The maximized locale code, e.g., \"de-Latn-AT\".\n * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., \"Austrian German (Latin)\".\n * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., \"Österreichisches Deutsch (Lateinisch)\".\n * @property {string} minimizedCode - Minimized locale code, e.g., \"de-AT\" (or \"de\" for \"de-DE\").\n * @property {string} minimizedName - Minimized language name in the default language, e.g., \"Austrian German\".\n * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} emoji - The emoji associated with the locale's region, if applicable.\n */\n getLocaleProperties(locale = this.targetLocale): LocaleProperties {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('getLocaleProperties'));\n return getLocaleProperties(locale, this.sourceLocale, this.customMapping);\n }\n\n /**\n * Retrieves multiple properties for a given region code, including:\n * - `code`: the original region code\n * - `name`: the localized display name\n * - `emoji`: the associated flag or symbol\n *\n * Behavior:\n * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `\"US\"`, `\"FR\"`, `\"419\"`).\n * - Uses the instance's `targetLocale` to localize the region name for the user.\n * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.\n * - Otherwise, uses `Intl.DisplayNames` to get the localized region name, falling back to `libraryDefaultLocale`.\n * - Falls back to the region code as `name` if display name resolution fails.\n * - Falls back to a default emoji if no emoji mapping is found in built-in data or `customMapping`.\n *\n * @param {string} [region=this.getLocaleProperties().regionCode] - The region code to look up (e.g., `\"US\"`, `\"GB\"`, `\"DE\"`).\n * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.\n * @returns {{ code: string, name: string, emoji: string }} An object containing:\n * - `code`: the input region code\n * - `name`: the localized or custom region name\n * - `emoji`: the matching emoji flag or symbol\n *\n * @throws {Error} If no target locale is available to determine region properties.\n *\n * @example\n * const gt = new GT({ targetLocale: 'en-US' });\n * gt.getRegionProperties('US');\n * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }\n *\n * @example\n * const gt = new GT({ targetLocale: 'fr-FR' });\n * gt.getRegionProperties('US');\n * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }\n *\n * @example\n * gt.getRegionProperties('US', { US: { name: 'USA', emoji: '🗽' } });\n * // => { code: 'US', name: 'USA', emoji: '🗽' }\n */\n getRegionProperties(\n region = this.getLocaleProperties().regionCode,\n customMapping?: CustomRegionMapping\n ): { code: string; name: string; emoji: string } {\n if (!customMapping) {\n if (this.customMapping && !this.customRegionMapping) {\n // Lazy derive custom region mapping from customMapping\n const customRegionMapping: CustomRegionMapping = {};\n for (const [locale, lp] of Object.entries(this.customMapping)) {\n if (\n lp &&\n typeof lp === 'object' &&\n lp.regionCode &&\n !customRegionMapping[lp.regionCode]\n ) {\n const { regionName: name, emoji } = lp;\n customRegionMapping[lp.regionCode] = {\n locale,\n ...(name && { name }),\n ...(emoji && { emoji }),\n };\n }\n }\n this.customRegionMapping = customRegionMapping;\n }\n customMapping = this.customRegionMapping;\n }\n return _getRegionProperties(\n region,\n this.targetLocale, // this.targetLocale because we want it in the user's language\n customMapping\n );\n }\n\n /**\n * Determines whether a translation is required based on the source and target locales.\n *\n * @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content\n * @param {string} [targetLocale=this.targetLocale] - The locale code to translate into\n * @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales\n * @returns {boolean} True if translation is required, false otherwise\n * @throws {Error} If no source locale is provided\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.requiresTranslation('en-US', 'es-ES');\n * // Returns: true\n */\n requiresTranslation(\n sourceLocale = this.sourceLocale,\n targetLocale = this.targetLocale,\n approvedLocales: string[] | undefined = this.locales,\n customMapping: CustomMapping | undefined = this.customMapping\n ): boolean {\n if (!sourceLocale)\n throw new Error(noSourceLocaleProvidedError('requiresTranslation'));\n if (!targetLocale)\n throw new Error(noTargetLocaleProvidedError('requiresTranslation'));\n return _requiresTranslation(\n sourceLocale,\n targetLocale,\n approvedLocales,\n customMapping\n );\n }\n\n /**\n * Determines the best matching locale from the provided approved locales list.\n *\n * @param {string | string[]} locales - A single locale or array of locales in preference order\n * @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order\n * @returns {string | undefined} The best matching locale or undefined if no match is found\n *\n * @example\n * gt.determineLocale(['fr-CA', 'fr-FR'], ['en-US', 'fr-FR', 'es-ES']);\n * // Returns: \"fr-FR\"\n */\n determineLocale(\n locales: string | string[],\n approvedLocales: string[] | undefined = this.locales || [],\n customMapping: CustomMapping | undefined = this.customMapping\n ): string | undefined {\n return _determineLocale(locales, approvedLocales, customMapping);\n }\n\n /**\n * Gets the text direction for a given locale code.\n *\n * @param {string} [locale=this.targetLocale] - A BCP-47 locale code\n * @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left, otherwise 'ltr'\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.getLocaleDirection('ar-SA');\n * // Returns: \"rtl\"\n */\n getLocaleDirection(locale = this.targetLocale): 'ltr' | 'rtl' {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('getLocaleDirection'));\n return getLocaleDirection(locale);\n }\n\n /**\n * Checks if a given BCP 47 locale code is valid.\n *\n * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate\n * @param {customMapping} [customMapping=this.customMapping] - The custom mapping to use for validation\n * @returns {boolean} True if the locale code is valid, false otherwise\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.isValidLocale('en-US');\n * // Returns: true\n */\n isValidLocale(\n locale = this.targetLocale,\n customMapping: CustomMapping | undefined = this.customMapping\n ): boolean {\n if (!locale) throw new Error(noTargetLocaleProvidedError('isValidLocale'));\n return isValidLocale(locale, customMapping);\n }\n\n /**\n * Resolves the canonical locale for a given locale.\n * @param locale - The locale to resolve the canonical locale for\n * @param customMapping - The custom mapping to use for resolving the canonical locale\n * @returns The canonical locale\n */\n resolveCanonicalLocale(\n locale: string | undefined = this.targetLocale,\n customMapping: CustomMapping | undefined = this.customMapping\n ): string {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('resolveCanonicalLocale'));\n return _resolveCanonicalLocale(locale, customMapping);\n }\n\n /**\n * Resolves the alias locale for a given locale.\n * @param locale - The locale to resolve the alias locale for\n * @param customMapping - The custom mapping to use for resolving the alias locale\n * @returns The alias locale\n */\n resolveAliasLocale(\n locale: string,\n customMapping: CustomMapping | undefined = this.customMapping\n ): string {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('resolveAliasLocale'));\n return _resolveAliasLocale(locale, customMapping);\n }\n\n /**\n * Standardizes a BCP 47 locale code to ensure correct formatting.\n *\n * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize\n * @returns {string} The standardized locale code or empty string if invalid\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.standardizeLocale('en_us');\n * // Returns: \"en-US\"\n */\n standardizeLocale(locale = this.targetLocale): string {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('standardizeLocale'));\n return _standardizeLocale(locale);\n }\n\n /**\n * Checks if multiple BCP 47 locale codes represent the same dialect.\n *\n * @param {...(string | string[])} locales - The BCP 47 locale codes to compare\n * @returns {boolean} True if all codes represent the same dialect, false otherwise\n *\n * @example\n * gt.isSameDialect('en-US', 'en-GB');\n * // Returns: false\n *\n * gt.isSameDialect('en', 'en-US');\n * // Returns: true\n */\n isSameDialect(...locales: (string | string[])[]): boolean {\n return isSameDialect(...locales);\n }\n\n /**\n * Checks if multiple BCP 47 locale codes represent the same language.\n *\n * @param {...(string | string[])} locales - The BCP 47 locale codes to compare\n * @returns {boolean} True if all codes represent the same language, false otherwise\n *\n * @example\n * gt.isSameLanguage('en-US', 'en-GB');\n * // Returns: true\n */\n isSameLanguage(...locales: (string | string[])[]): boolean {\n return _isSameLanguage(...locales);\n }\n\n /**\n * Checks if a locale is a superset of another locale.\n *\n * @param {string} superLocale - The locale to check if it is a superset\n * @param {string} subLocale - The locale to check if it is a subset\n * @returns {boolean} True if superLocale is a superset of subLocale, false otherwise\n *\n * @example\n * gt.isSupersetLocale('en', 'en-US');\n * // Returns: true\n *\n * gt.isSupersetLocale('en-US', 'en');\n * // Returns: false\n */\n isSupersetLocale(superLocale: string, subLocale: string): boolean {\n return isSupersetLocale(superLocale, subLocale);\n }\n}\n\n// ============================================================ //\n// Utility methods //\n// ============================================================ //\n\n// -------------- Formatting -------------- //\n\n/**\n * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.\n *\n * This standalone function provides cutoff formatting functionality without requiring a GT instance.\n * The locales parameter is required for proper terminator selection based on the target language.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @param {Object} [options] - Configuration options for cutoff formatting.\n * @param {string | string[]} [options.locales] - The locales to use for terminator selection.\n * @param {number} [options.maxChars] - The maximum number of characters to display.\n * - Undefined values are treated as no cutoff.\n * - Negative values follow .slice() behavior and terminator will be added before the value.\n * - 0 will result in an empty string.\n * - If cutoff results in an empty string, no terminator is added.\n * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.\n * @param {string} [options.terminator] - Optional override the terminator to use.\n * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.\n * - If no terminator is provided, then separator is ignored.\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n *\n * @example\n * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });\n * // Returns: 'Hello, w...'\n *\n * @example\n * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });\n * // Returns: '...ld!'\n *\n * @example\n * formatCutoff('Very long text that needs cutting', {\n * locales: 'en-US',\n * maxChars: 15,\n * style: 'ellipsis',\n * separator: ' '\n * });\n * // Returns: 'Very long text ...'\n */\nexport function formatCutoff(\n value: string,\n options?: {\n locales?: string | string[];\n } & CutoffFormatOptions\n): string {\n return _formatCutoff({ value, locales: options?.locales, options });\n}\n\n/**\n * Formats a message according to the specified locales and options.\n *\n * @param {string} message - The message to format.\n * @param {string | string[]} [locales='en'] - The locales to use for formatting.\n * @param {FormatVariables} [variables={}] - The variables to use for formatting.\n * @param {StringFormat} [dataFormat='ICU'] - The format of the message. (When STRING, the message is returned as is)\n * @returns {string} The formatted message.\n *\n * @example\n * formatMessage('Hello {name}', { name: 'John' });\n * // Returns: \"Hello John\"\n *\n * formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });\n * // Returns: \"Bonjour John\"\n */\nexport function formatMessage(\n message: string,\n options?: {\n locales?: string | string[];\n variables?: FormatVariables;\n dataFormat?: StringFormat;\n }\n): string {\n switch (options?.dataFormat) {\n case 'STRING':\n return _formatMessageString(message);\n default:\n return _formatMessageICU(message, options?.locales, options?.variables);\n }\n}\n\n/**\n * Formats a number according to the specified locales and options.\n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {Intl.NumberFormatOptions} [params.options] - Additional options for number formatting.\n * @param {string | string[]} [params.options.locales] - The locales to use for formatting.\n * @returns {string} The formatted number.\n */\nexport function formatNum(\n number: number,\n options: {\n locales: string | string[];\n } & Intl.NumberFormatOptions\n): string {\n return _formatNum({\n value: number,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a date according to the specified languages and options.\n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {Intl.DateTimeFormatOptions} [params.options] - Additional options for date formatting.\n * @param {string | string[]} [params.options.locales] - The languages to use for formatting.\n * @returns {string} The formatted date.\n */\nexport function formatDateTime(\n date: Date,\n options?: {\n locales?: string | string[];\n } & Intl.DateTimeFormatOptions\n): string {\n return _formatDateTime({\n value: date,\n locales: options?.locales,\n options,\n });\n}\n\n/**\n * Formats a currency value according to the specified languages, currency, and options.\n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n * @param {string | string[]} [params.options.locales] - The locale codes to use for formatting.\n * @returns {string} The formatted currency value.\n */\nexport function formatCurrency(\n value: number,\n currency: string,\n options: {\n locales: string | string[];\n } & Intl.NumberFormatOptions\n): string {\n return _formatCurrency({\n value,\n currency,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * @param {string | string[]} [params.options.locales] - The locales to use for formatting.\n * @returns {string} The formatted list.\n */\nexport function formatList(\n array: Array<string | number>,\n options: {\n locales: string | string[];\n } & Intl.ListFormatOptions\n): string {\n return _formatList({\n value: array,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n * @param {Array<T>} array - The list of items to format\n * @param {Object} [options] - Additional options for list formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options\n * @returns {Array<T | string>} The formatted list parts\n */\nexport function formatListToParts<T>(\n array: Array<T>,\n options?: {\n locales?: string | string[];\n } & Intl.ListFormatOptions\n): Array<T | string> {\n return _formatListToParts<T>({\n value: array,\n locales: options?.locales,\n options: options,\n });\n}\n\n/**\n * Formats a relative time value according to the specified locales and options.\n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n * @param {string | string[]} [params.options.locales] - The locales to use for formatting.\n * @returns {string} The formatted relative time string.\n */\nexport function formatRelativeTime(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n options: {\n locales: string | string[];\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n): string {\n return _formatRelativeTime({\n value,\n unit,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a relative time string from a Date, automatically selecting the best unit.\n * @param {Date} date - The date to format relative to now.\n * @param {Object} options - Formatting options.\n * @param {string | string[]} options.locales - The locales to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options.\n * @returns {string} The formatted relative time string (e.g., \"2 hours ago\", \"in 3 days\").\n */\nexport function formatRelativeTimeFromDate(\n date: Date,\n options: {\n locales: string | string[];\n baseDate?: Date;\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n): string {\n const { locales, baseDate, ...intlOptions } = options;\n return _formatRelativeTimeFromDate({\n date,\n baseDate: baseDate ?? new Date(),\n locales,\n options: intlOptions,\n });\n}\n\n// -------------- Locale Properties -------------- //\n\n/**\n * Retrieves the display name of locale code using Intl.DisplayNames.\n *\n * @param {string} locale - A BCP-47 locale code.\n * @param {string} [defaultLocale] - The default locale to use for formatting.\n * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.\n * @returns {string} The display name corresponding to the code.\n */\nexport function getLocaleName(\n locale: string,\n defaultLocale?: string,\n customMapping?: CustomMapping\n): string {\n return _getLocaleName(locale, defaultLocale, customMapping);\n}\n\n/**\n * Retrieves an emoji based on a given locale code, taking into account region, language, and specific exceptions.\n *\n * This function uses the locale's region (if present) to select an emoji or falls back on default emojis for certain languages.\n *\n * @param locale - A string representing the locale code (e.g., 'en-US', 'fr-CA').\n * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.\n * @returns The emoji representing the locale or its region, or a default emoji if no specific match is found.\n */\nexport function getLocaleEmoji(\n locale: string,\n customMapping?: CustomMapping\n): string {\n return _getLocaleEmoji(locale, customMapping);\n}\n\n/**\n * Generates linguistic details for a given locale code.\n *\n * This function returns information about the locale,\n * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).\n * The function provides these names in both your default language and native forms, and an associated emoji.\n *\n * @param {string} locale - The locale code to get properties for (e.g., \"de-AT\").\n * @param {string} [defaultLocale] - The default locale to use for formatting.\n * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.\n * @returns {LocaleProperties} - An object containing detailed information about the locale.\n *\n * @property {string} code - The full locale code, e.g., \"de-AT\".\n * @property {string} name - Language name in the default display language, e.g., \"Austrian German\".\n * @property {string} nativeName - Language name in the locale's native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} languageCode - The base language code, e.g., \"de\".\n * @property {string} languageName - The language name in the default display language, e.g., \"German\".\n * @property {string} nativeLanguageName - The language name in the native language, e.g., \"Deutsch\".\n * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., \"German (AT)\".\n * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., \"Deutsch (AT)\".\n * @property {string} regionCode - The region code from maximization, e.g., \"AT\".\n * @property {string} regionName - The region name in the default display language, e.g., \"Austria\".\n * @property {string} nativeRegionName - The region name in the native language, e.g., \"Österreich\".\n * @property {string} scriptCode - The script code from maximization, e.g., \"Latn\".\n * @property {string} scriptName - The script name in the default display language, e.g., \"Latin\".\n * @property {string} nativeScriptName - The script name in the native language, e.g., \"Lateinisch\".\n * @property {string} maximizedCode - The maximized locale code, e.g., \"de-Latn-AT\".\n * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., \"Austrian German (Latin)\".\n * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., \"Österreichisches Deutsch (Lateinisch)\".\n * @property {string} minimizedCode - Minimized locale code, e.g., \"de-AT\" (or \"de\" for \"de-DE\").\n * @property {string} minimizedName - Minimized language name in the default language, e.g., \"Austrian German\".\n * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} emoji - The emoji associated with the locale's region, if applicable.\n */\nexport function getLocaleProperties(\n locale: string,\n defaultLocale?: string,\n customMapping?: CustomMapping\n): LocaleProperties {\n return _getLocaleProperties(locale, defaultLocale, customMapping);\n}\n\n/**\n * Retrieves multiple properties for a given region code, including:\n * - `code`: the original region code\n * - `name`: the localized display name\n * - `emoji`: the associated flag or symbol\n *\n * Behavior:\n * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `\"US\"`, `\"FR\"`, `\"419\"`).\n * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.\n * - Otherwise, uses `Intl.DisplayNames` to get the localized region name in the given `defaultLocale`,\n * falling back to `libraryDefaultLocale`.\n * - Falls back to the region code as `name` if display name resolution fails.\n * - Falls back to `defaultEmoji` if no emoji mapping is found in `emojis` or `customMapping`.\n *\n * @param {string} region - The region code to look up (e.g., `\"US\"`, `\"GB\"`, `\"DE\"`).\n * @param {string} [defaultLocale=libraryDefaultLocale] - The locale to use when localizing the region name.\n * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.\n * @returns {{ code: string, name: string, emoji: string }} An object containing:\n * - `code`: the input region code\n * - `name`: the localized or custom region name\n * - `emoji`: the matching emoji flag or symbol\n *\n * @example\n * getRegionProperties('US', 'en');\n * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }\n *\n * @example\n * getRegionProperties('US', 'fr');\n * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }\n *\n * @example\n * getRegionProperties('US', 'en', { US: { name: 'USA', emoji: '🗽' } });\n * // => { code: 'US', name: 'USA', emoji: '🗽' }\n */\nexport function getRegionProperties(\n region: string,\n defaultLocale?: string,\n customMapping?: CustomRegionMapping\n): { code: string; name: string; emoji: string } {\n return _getRegionProperties(region, defaultLocale, customMapping);\n}\n\n/**\n * Determines whether a translation is required based on the source and target locales.\n *\n * - If the target locale is not specified, the function returns `false`, as translation is not needed.\n * - If the source and target locale are the same, returns `false`, indicating that no translation is necessary.\n * - If the `approvedLocales` array is provided, and the target locale is not within that array, the function also returns `false`.\n * - Otherwise, it returns `true`, meaning that a translation is required.\n *\n * @param {string} sourceLocale - The locale code for the original content (BCP 47 locale code).\n * @param {string} targetLocale - The locale code of the language to translate the content into (BCP 47 locale code).\n * @param {string[]} [approvedLocale] - An optional array of approved target locales.\n *\n * @returns {boolean} - Returns `true` if translation is required, otherwise `false`.\n */\nexport function requiresTranslation(\n sourceLocale: string,\n targetLocale: string,\n approvedLocales?: string[],\n customMapping?: CustomMapping\n): boolean {\n return _requiresTranslation(\n sourceLocale,\n targetLocale,\n approvedLocales,\n customMapping\n );\n}\n\n/**\n * Determines the best matching locale from the provided approved locales list.\n * @param {string | string[]} locales - A single locale or an array of locales sorted in preference order.\n * @param {string[]} [approvedLocales=this.locales] - An array of approved locales, also sorted by preference.\n * @returns {string | undefined} - The best matching locale from the approvedLocales list, or undefined if no match is found.\n */\nexport function determineLocale(\n locales: string | string[],\n approvedLocales: string[] | undefined = [],\n customMapping: CustomMapping | undefined = undefined\n): string | undefined {\n return _determineLocale(locales, approvedLocales, customMapping);\n}\n\n/**\n * Get the text direction for a given locale code using the Intl.Locale API.\n *\n * @param {string} locale - A BCP-47 locale code.\n * @returns {string} - 'rtl' if the locale is right-to-left, otherwise 'ltr'.\n */\nexport function getLocaleDirection(locale: string): 'ltr' | 'rtl' {\n return _getLocaleDirection(locale);\n}\n\n/**\n * Checks if a given BCP 47 locale code is valid.\n * @param {string} locale - The BCP 47 locale code to validate.\n * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n */\nexport function isValidLocale(\n locale: string,\n customMapping?: CustomMapping\n): boolean {\n return _isValidLocale(locale, customMapping);\n}\n\n/**\n * Resolves the alias locale for a given locale.\n * @param {string} locale - The locale to resolve the alias locale for\n * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the alias locale\n * @returns {string} The alias locale\n */\nexport function resolveAliasLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n return _resolveAliasLocale(locale, customMapping);\n}\n\n/**\n * Resolves the canonical locale for a given locale.\n * @param {string} locale - The locale to resolve the canonical locale for\n * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale\n * @returns {string} The canonical locale\n */\nexport function resolveCanonicalLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n return _resolveCanonicalLocale(locale, customMapping);\n}\n\n/**\n * Standardizes a BCP 47 locale code to ensure correct formatting.\n * @param {string} locale - The BCP 47 locale code to standardize.\n * @returns {string} The standardized BCP 47 locale code or an empty string if it is an invalid code.\n */\nexport function standardizeLocale(locale: string): string {\n return _standardizeLocale(locale);\n}\n\n/**\n * Checks if multiple BCP 47 locale codes represent the same dialect.\n * @param {string[]} locales - The BCP 47 locale codes to compare.\n * @returns {boolean} True if all BCP 47 codes represent the same dialect, false otherwise.\n */\nexport function isSameDialect(...locales: (string | string[])[]): boolean {\n return _isSameDialect(...locales);\n}\n\n/**\n * Checks if multiple BCP 47 locale codes represent the same language.\n * @param {string[]} locales - The BCP 47 locale codes to compare.\n * @returns {boolean} True if all BCP 47 codes represent the same language, false otherwise.\n */\nexport function isSameLanguage(...locales: (string | string[])[]): boolean {\n return _isSameLanguage(...locales);\n}\n\n/**\n * Checks if a locale is a superset of another locale.\n * A subLocale is a subset of superLocale if it is an extension of superLocale or are otherwise identical.\n *\n * @param {string} superLocale - The locale to check if it is a superset of the other locale.\n * @param {string} subLocale - The locale to check if it is a subset of the other locale.\n * @returns {boolean} True if the first locale is a superset of the second locale, false otherwise.\n */\nexport function isSupersetLocale(\n superLocale: string,\n subLocale: string\n): boolean {\n return _isSupersetLocale(superLocale, subLocale);\n}\n\nexport const API_VERSION = _API_VERSION;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,mBAAmB;CAAC;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAO;AAGzE,MAAM,oBAAoB,aAAqB;AAC7C,QAAO,YAAY,SAAS,YAAY;;;;;;;;;AAU1C,MAAa,kBACX,QACA,kBACY;AAEZ,KACE,gBAAgB,WAChB,OAAO,cAAc,YAAY,YACjC,UAAW,cAAc,WACxB,cAAc,QAA6B,KAE5C,UAAU,cAAc,QAA6B;AAGvD,KAAI;EACF,MAAM,EAAE,UAAU,QAAQ,WAAWA,iBAAAA,UAAU,IAAI,UAAU,OAAO;AACpE,MACE,OAAO,MAAM,IAAI,CAAC,kBACX;GACL,IAAI,YAAY;AAChB,OAAI,OAAQ,cAAa;AACzB,OAAI,OAAQ,cAAa;AACzB,UAAO;MACL,CAEJ,QAAO;AAQT,MAP6BA,iBAAAA,UAAU,IACrC,gBACA,CAAA,KAAsB,EACtB,EACE,MAAM,YACP,CAGmB,CAAC,GAAG,SAAS,KAAK,YACtC,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B,gBACd,SACA,kBAAwC,EAAE,EAC1C,gBAA2C,KAAA,GACvB;AACpB,QAAO,iBAAiB,SAAS,iBAAiB,cAAc;;;;;;;;AASlE,SAAgB,mBAAmB,QAA+B;AAChE,QAAO,oBAAoB,OAAO;;;;;;;;AASpC,SAAgB,cACd,QACA,eACS;AACT,QAAO,eAAe,QAAQ,cAAc;;;;;;;;AAS9C,SAAgB,mBACd,QACA,eACQ;AACR,QAAO,oBAAoB,QAAQ,cAAc;;;;;;;;AASnD,SAAgB,uBACd,QACA,eACQ;AACR,QAAO,wBAAwB,QAAQ,cAAc;;;;;;;AAQvD,SAAgB,kBAAkB,QAAwB;AACxD,QAAO,mBAAmB,OAAO;;;;;;;AAQnC,SAAgB,cAAc,GAAG,SAAyC;AACxE,QAAO,eAAe,GAAG,QAAQ;;;;;;;AAQnC,SAAgB,eAAe,GAAG,SAAyC;AACzE,QAAO,gBAAgB,GAAG,QAAQ;;;;;;;;;;AAWpC,SAAgB,iBACd,aACA,WACS;AACT,QAAO,kBAAkB,aAAa,UAAU;;AAGlD,MAAa,cAAcC"}
1
+ {"version":3,"file":"index.cjs","names":["intlCache","intlCache","intlCache","intlCache","intlCache","intlCache","IntlMessageFormat","intlCache","intlCache","intlCache","defaultTimeout","ApiError","API_VERSION","API_VERSION","hashSource","decode","intlCache","encode","encode","defaultTimeout","_API_VERSION"],"sources":["../src/locales/isValidLocale.ts","../src/locales/isSameDialect.ts","../src/locales/isSameLanguage.ts","../src/locales/requiresTranslation.ts","../src/locales/customLocaleMapping.ts","../src/locales/getLocaleEmoji.ts","../src/locales/getLocaleProperties.ts","../src/locales/determineLocale.ts","../src/logging/logger.ts","../src/formatting/format.ts","../src/locales/getLocaleName.ts","../src/locales/getLocaleDirection.ts","../src/locales/isSupersetLocale.ts","../src/logging/errors.ts","../src/translate/utils/fetchWithTimeout.ts","../src/translate/utils/validateResponse.ts","../src/translate/utils/handleFetchError.ts","../src/translate/api.ts","../src/translate/utils/generateRequestHeaders.ts","../src/translate/utils/apiRequest.ts","../src/translate/translateMany.ts","../src/translate/setupProject.ts","../src/translate/utils/batch.ts","../src/translate/enqueueFiles.ts","../src/translate/createTag.ts","../src/translate/downloadFileBatch.ts","../src/translate/submitUserEditDiffs.ts","../src/locales/getRegionProperties.ts","../src/locales/resolveAliasLocale.ts","../src/locales/resolveCanonicalLocale.ts","../src/translate/uploadSourceFiles.ts","../src/translate/uploadTranslations.ts","../src/translate/querySourceFile.ts","../src/projects/getProjectData.ts","../src/translate/checkJobStatus.ts","../src/translate/awaitJobs.ts","../src/translate/queryFileData.ts","../src/translate/queryBranchData.ts","../src/translate/createBranch.ts","../src/translate/processFileMoves.ts","../src/translate/getOrphanedFiles.ts","../src/translate/publishFiles.ts","../src/LocaleConfig.ts","../src/index.ts"],"sourcesContent":["import { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport { CustomMapping } from './customLocaleMapping';\n\nconst scriptExceptions = ['Cham', 'Jamo', 'Kawi', 'Lisu', 'Toto', 'Thai'];\n\n//// According to BCP 47, the range qaa–qtz is reserved for private-use language codes\nconst isCustomLanguage = (language: string) => {\n return language >= 'qaa' && language <= 'qtz';\n};\n\n/**\n * Checks if a given BCP 47 language code is valid.\n * @param {string} code - The BCP 47 language code to validate.\n * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n * @internal\n */\nexport const _isValidLocale = (\n locale: string,\n customMapping?: CustomMapping\n): boolean => {\n // If in custom mapping, return true\n if (\n customMapping?.[locale] &&\n typeof customMapping[locale] === 'object' &&\n 'code' in (customMapping[locale] as Object) &&\n (customMapping[locale] as { code: string }).code\n ) {\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n try {\n const { language, region, script } = intlCache.get('Locale', locale);\n if (\n locale.split('-').length !==\n (() => {\n let partCount = 1;\n if (region) partCount += 1;\n if (script) partCount += 1;\n return partCount;\n })()\n )\n return false;\n const displayLanguageNames = intlCache.get(\n 'DisplayNames',\n [libraryDefaultLocale],\n {\n type: 'language',\n }\n );\n if (\n displayLanguageNames.of(language) === language &&\n !isCustomLanguage(language)\n )\n return false;\n if (region) {\n const displayRegionNames = intlCache.get(\n 'DisplayNames',\n [libraryDefaultLocale],\n {\n type: 'region',\n }\n );\n if (displayRegionNames.of(region) === region) return false;\n }\n if (script) {\n const displayScriptNames = intlCache.get(\n 'DisplayNames',\n [libraryDefaultLocale],\n {\n type: 'script',\n }\n );\n if (\n displayScriptNames.of(script) === script &&\n !scriptExceptions.includes(script)\n )\n return false;\n }\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Standardizes a BCP 47 locale to ensure correct formatting.\n * @param {string} locale - The BCP 47 locale to standardize.\n * @returns {string} The standardized BCP 47 locale, or an empty string if invalid.\n * @internal\n */\nexport const _standardizeLocale = (locale: string): string => {\n try {\n return Intl.getCanonicalLocales(locale)[0];\n } catch {\n return locale;\n }\n};\n","import { intlCache } from '../cache/IntlCache';\nimport { _standardizeLocale } from './isValidLocale';\n\nfunction checkTwoLocalesAreSameDialect(codeA: string, codeB: string) {\n const {\n language: languageA,\n region: regionA,\n script: scriptA,\n } = intlCache.get('Locale', codeA);\n const {\n language: languageB,\n region: regionB,\n script: scriptB,\n } = intlCache.get('Locale', codeB);\n if (languageA !== languageB) return false;\n if (regionA && regionB && regionA !== regionB) return false;\n if (scriptA && scriptB && scriptA !== scriptB) return false;\n return true;\n}\n\n/**\n * Test two or more language codes to determine if they are exactly the same\n * e.g. \"en-US\" and \"en\" would be exactly the same.\n * \"en-GB\" and \"en\" would be exactly the same.\n * \"en-GB\" and \"en-US\" would be different.\n * @internal\n */\nexport default function _isSameDialect(\n ...locales: (string | string[])[]\n): boolean {\n try {\n // standardize codes\n const flattenedCodes = locales.flat().map(_standardizeLocale);\n\n for (let i = 0; i < flattenedCodes.length; i++) {\n for (let j = i + 1; j < flattenedCodes.length; j++) {\n if (\n !checkTwoLocalesAreSameDialect(flattenedCodes[i], flattenedCodes[j])\n )\n return false;\n }\n }\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n","import { intlCache } from '../cache/IntlCache';\n\n/**\n * @internal\n */\nexport default function _isSameLanguage(\n ...locales: (string | string[])[]\n): boolean {\n try {\n const flattenedCodes = locales.flat();\n // Get the language for each code\n const languages = flattenedCodes.map(\n (locale) => intlCache.get('Locale', locale).language\n );\n return languages.every((language) => language === languages[0]);\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n","import { CustomMapping } from './customLocaleMapping';\nimport _isSameDialect from './isSameDialect';\nimport _isSameLanguage from './isSameLanguage';\nimport { _isValidLocale } from './isValidLocale';\n\n/**\n * Given a target locale and a source locale, determines whether a translation is required\n * If the target locale and the source locale are the same, returns false, otherwise returns true\n * If a translation is not possible due to the target locale being outside of the optional approvedLanguages scope, also returns false\n * @internal\n */\nexport default function _requiresTranslation(\n sourceLocale: string,\n targetLocale: string,\n approvedLocales?: string[],\n customMapping?: CustomMapping\n): boolean {\n // If codes are invalid\n if (\n !_isValidLocale(sourceLocale, customMapping) ||\n !_isValidLocale(targetLocale, customMapping) ||\n (approvedLocales &&\n approvedLocales.some(\n (approvedLocale) => !_isValidLocale(approvedLocale, customMapping)\n ))\n ) {\n return false;\n }\n\n // Check if the languages are identical, if so, a translation is not required\n if (_isSameDialect(sourceLocale, targetLocale)) {\n return false;\n }\n\n // Check that the target locale is within the approvedLocales scope, if not, a translation is not required\n // isSameLanguage rather than checkTwoLocalesAreSameDialect so we can show different dialects as a fallback\n if (\n approvedLocales &&\n !approvedLocales.some((approvedLocale) =>\n _isSameLanguage(targetLocale, approvedLocale)\n )\n ) {\n return false;\n }\n // Otherwise, a translation is required!\n return true;\n}\n","import { LocaleProperties } from './getLocaleProperties';\nimport { _isValidLocale } from './isValidLocale';\n\nexport type FullCustomMapping = Record<string, LocaleProperties>;\nexport type CustomMapping = Record<string, string | Partial<LocaleProperties>>;\n\nexport const getCustomProperty = (\n customMapping: CustomMapping,\n locale: string,\n property: keyof LocaleProperties\n): string | undefined => {\n if (customMapping?.[locale]) {\n if (typeof customMapping[locale] === 'string') {\n return property === 'name' ? customMapping[locale] : undefined;\n }\n return customMapping[locale][property];\n }\n return undefined;\n};\n\n/**\n * Checks if a given locale should use the canonical locale.\n * @param locale - The locale to check if it should use the canonical locale\n * @param customMapping - The custom mapping to use for checking if the locale should use the canonical locale\n * @returns True if the locale should use the canonical locale, false otherwise\n */\nexport const shouldUseCanonicalLocale = (\n locale: string,\n customMapping: CustomMapping\n): boolean => {\n return !!(\n customMapping?.[locale] &&\n typeof customMapping[locale] === 'object' &&\n 'code' in (customMapping[locale] as Object) &&\n (customMapping[locale] as { code: string }).code &&\n _isValidLocale((customMapping[locale] as { code: string }).code)\n );\n};\n","import { intlCache } from '../cache/IntlCache';\nimport {\n CustomMapping,\n getCustomProperty,\n shouldUseCanonicalLocale,\n} from './customLocaleMapping';\nimport { _standardizeLocale } from './isValidLocale';\n\n/**\n * @internal\n */\nexport default function _getLocaleEmoji(\n locale: string,\n customMapping?: CustomMapping\n): string {\n // Check for canonical locale\n const aliasedLocale = locale;\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n // Override locale with canonical locale\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n try {\n const standardizedLocale = _standardizeLocale(locale);\n const localeObject = intlCache.get('Locale', standardizedLocale);\n const { language, region } = localeObject;\n\n // if a custom mapping is specified, use it\n if (customMapping) {\n for (const l of [aliasedLocale, locale, standardizedLocale, language]) {\n const customEmoji = getCustomProperty(customMapping, l, 'emoji');\n if (customEmoji) return customEmoji;\n }\n }\n\n // if a region is specified, use it!\n if (region && emojis[region]) return emojis[region];\n\n // if not, attempt to extrapolate\n const extrapolated = localeObject.maximize();\n const extrapolatedRegion = extrapolated.region || '';\n\n return (\n exceptions[extrapolated.language] ||\n emojis[extrapolatedRegion] ||\n defaultEmoji\n );\n } catch {\n return defaultEmoji;\n }\n}\n\n// Default language emoji for when none else can be found\nconst europeAfricaGlobe = '🌍';\nconst asiaAustraliaGlobe = '🌏';\nexport const defaultEmoji = europeAfricaGlobe;\n\n// Exceptions to better reflect linguistic and cultural identities\nconst exceptions = {\n ca: europeAfricaGlobe,\n eu: europeAfricaGlobe,\n ku: europeAfricaGlobe,\n bo: asiaAustraliaGlobe,\n ug: asiaAustraliaGlobe,\n gd: '🏴󠁧󠁢󠁳󠁣󠁴󠁿',\n cy: '🏴󠁧󠁢󠁷󠁬󠁳󠁿',\n gv: '🇮🇲',\n grc: '🏺',\n} as Record<string, string>;\n\nexport const emojis = {\n AF: '🇦🇫', // Afghanistan\n AX: '🇦🇽', // Åland Islands\n AL: '🇦🇱', // Albania\n DZ: '🇩🇿', // Algeria\n AS: '🇦🇸', // American Samoa\n AD: '🇦🇩', // Andorra\n AO: '🇦🇴', // Angola\n AI: '🇦🇮', // Anguilla\n AQ: '🇦🇶', // Antarctica\n AG: '🇦🇬', // Antigua and Barbuda\n AR: '🇦🇷', // Argentina\n AM: '🇦🇲', // Armenia\n AW: '🇦🇼', // Aruba\n AU: '🇦🇺', // Australia\n AT: '🇦🇹', // Austria\n AZ: '🇦🇿', // Azerbaijan\n BS: '🇧🇸', // Bahamas\n BH: '🇧🇭', // Bahrain\n BD: '🇧🇩', // Bangladesh\n BB: '🇧🇧', // Barbados\n BY: '🇧🇾', // Belarus\n BE: '🇧🇪', // Belgium\n BZ: '🇧🇿', // Belize\n BJ: '🇧🇯', // Benin\n BM: '🇧🇲', // Bermuda\n BT: '🇧🇹', // Bhutan\n BO: '🇧🇴', // Bolivia\n BQ: '🇧🇶', // Bonaire, Sint Eustatius and Saba\n BA: '🇧🇦', // Bosnia and Herzegovina\n BW: '🇧🇼', // Botswana\n BV: '🇧🇻', // Bouvet Island\n BR: '🇧🇷', // Brazil\n IO: '🇮🇴', // British Indian Ocean Territory\n BN: '🇧🇳', // Brunei Darussalam\n BG: '🇧🇬', // Bulgaria\n BF: '🇧🇫', // Burkina Faso\n BI: '🇧🇮', // Burundi\n CV: '🇨🇻', // Cabo Verde\n KH: '🇰🇭', // Cambodia\n CM: '🇨🇲', // Cameroon\n CA: '🇨🇦', // Canada\n KY: '🇰🇾', // Cayman Islands\n CF: '🇨🇫', // Central African Republic\n TD: '🇹🇩', // Chad\n CL: '🇨🇱', // Chile\n CN: '🇨🇳', // China\n CX: '🇨🇽', // Christmas Island\n CC: '🇨🇨', // Cocos (Keeling) Islands\n CO: '🇨🇴', // Colombia\n KM: '🇰🇲', // Comoros\n CD: '🇨🇩', // Congo (Democratic Republic)\n CG: '🇨🇬', // Congo (Republic)\n CK: '🇨🇰', // Cook Islands\n CR: '🇨🇷', // Costa Rica\n CI: '🇨🇮', // Côte d'Ivoire\n HR: '🇭🇷', // Croatia\n CU: '🇨🇺', // Cuba\n CW: '🇨🇼', // Curaçao\n CY: '🇨🇾', // Cyprus\n CZ: '🇨🇿', // Czechia\n DK: '🇩🇰', // Denmark\n DJ: '🇩🇯', // Djibouti\n DM: '🇩🇲', // Dominica\n DO: '🇩🇴', // Dominican Republic\n EC: '🇪🇨', // Ecuador\n EG: '🇪🇬', // Egypt\n SV: '🇸🇻', // El Salvador\n GQ: '🇬🇶', // Equatorial Guinea\n ER: '🇪🇷', // Eritrea\n EE: '🇪🇪', // Estonia\n SZ: '🇸🇿', // Eswatini\n ET: '🇪🇹', // Ethiopia\n FK: '🇫🇰', // Falkland Islands\n FO: '🇫🇴', // Faroe Islands\n FJ: '🇫🇯', // Fiji\n FI: '🇫🇮', // Finland\n FR: '🇫🇷', // France\n GF: '🇬🇫', // French Guiana\n PF: '🇵🇫', // French Polynesia\n TF: '🇹🇫', // French Southern Territories\n GA: '🇬🇦', // Gabon\n GM: '🇬🇲', // Gambia\n GE: '🇬🇪', // Georgia\n DE: '🇩🇪', // Germany\n GH: '🇬🇭', // Ghana\n GI: '🇬🇮', // Gibraltar\n GR: '🇬🇷', // Greece\n GL: '🇬🇱', // Greenland\n GD: '🇬🇩', // Grenada\n GP: '🇬🇵', // Guadeloupe\n GU: '🇬🇺', // Guam\n GT: '🇬🇹', // Guatemala\n GG: '🇬🇬', // Guernsey\n GN: '🇬🇳', // Guinea\n GW: '🇬🇼', // Guinea-Bissau\n GY: '🇬🇾', // Guyana\n HT: '🇭🇹', // Haiti\n HM: '🇭🇲', // Heard Island and McDonald Islands\n VA: '🇻🇦', // Holy See\n HN: '🇭🇳', // Honduras\n HK: '🇭🇰', // Hong Kong\n HU: '🇭🇺', // Hungary\n IS: '🇮🇸', // Iceland\n IN: '🇮🇳', // India\n ID: '🇮🇩', // Indonesia\n IR: '🇮🇷', // Iran\n IQ: '🇮🇶', // Iraq\n IE: '🇮🇪', // Ireland\n IM: '🇮🇲', // Isle of Man\n IL: '🇮🇱', // Israel\n IT: '🇮🇹', // Italy\n JM: '🇯🇲', // Jamaica\n JP: '🇯🇵', // Japan\n JE: '🇯🇪', // Jersey\n JO: '🇯🇴', // Jordan\n KZ: '🇰🇿', // Kazakhstan\n KE: '🇰🇪', // Kenya\n KI: '🇰🇮', // Kiribati\n KP: '🇰🇵', // Korea (North)\n KR: '🇰🇷', // Korea (South)\n KW: '🇰🇼', // Kuwait\n KG: '🇰🇬', // Kyrgyzstan\n LA: '🇱🇦', // Laos\n LV: '🇱🇻', // Latvia\n LB: '🇱🇧', // Lebanon\n LS: '🇱🇸', // Lesotho\n LR: '🇱🇷', // Liberia\n LY: '🇱🇾', // Libya\n LI: '🇱🇮', // Liechtenstein\n LT: '🇱🇹', // Lithuania\n LU: '🇱🇺', // Luxembourg\n MO: '🇲🇴', // Macao\n MG: '🇲🇬', // Madagascar\n MW: '🇲🇼', // Malawi\n MY: '🇲🇾', // Malaysia\n MV: '🇲🇻', // Maldives\n ML: '🇲🇱', // Mali\n MT: '🇲🇹', // Malta\n MH: '🇲🇭', // Marshall Islands\n MQ: '🇲🇶', // Martinique\n MR: '🇲🇷', // Mauritania\n MU: '🇲🇺', // Mauritius\n YT: '🇾🇹', // Mayotte\n MX: '🇲🇽', // Mexico\n FM: '🇫🇲', // Micronesia\n MD: '🇲🇩', // Moldova\n MC: '🇲🇨', // Monaco\n MN: '🇲🇳', // Mongolia\n ME: '🇲🇪', // Montenegro\n MS: '🇲🇸', // Montserrat\n MA: '🇲🇦', // Morocco\n MZ: '🇲🇿', // Mozambique\n MM: '🇲🇲', // Myanmar\n NA: '🇳🇦', // Namibia\n NR: '🇳🇷', // Nauru\n NP: '🇳🇵', // Nepal\n NL: '🇳🇱', // Netherlands\n NC: '🇳🇨', // New Caledonia\n NZ: '🇳🇿', // New Zealand\n NI: '🇳🇮', // Nicaragua\n NE: '🇳🇪', // Niger\n NG: '🇳🇬', // Nigeria\n NU: '🇳🇺', // Niue\n NF: '🇳🇫', // Norfolk Island\n MK: '🇲🇰', // North Macedonia\n MP: '🇲🇵', // Northern Mariana Islands\n NO: '🇳🇴', // Norway\n OM: '🇴🇲', // Oman\n PK: '🇵🇰', // Pakistan\n PW: '🇵🇼', // Palau\n PS: '🇵🇸', // Palestine, State of\n PA: '🇵🇦', // Panama\n PG: '🇵🇬', // Papua New Guinea\n PY: '🇵🇾', // Paraguay\n PE: '🇵🇪', // Peru\n PH: '🇵🇭', // Philippines\n PN: '🇵🇳', // Pitcairn\n PL: '🇵🇱', // Poland\n PT: '🇵🇹', // Portugal\n PR: '🇵🇷', // Puerto Rico\n QA: '🇶🇦', // Qatar\n RE: '🇷🇪', // Réunion\n RO: '🇷🇴', // Romania\n RU: '🇷🇺', // Russian Federation\n RW: '🇷🇼', // Rwanda\n BL: '🇧🇱', // Saint Barthélemy\n SH: '🇸🇭', // Saint Helena, Ascension and Tristan da Cunha\n KN: '🇰🇳', // Saint Kitts and Nevis\n LC: '🇱🇨', // Saint Lucia\n MF: '🇲🇫', // Saint Martin (French part)\n PM: '🇵🇲', // Saint Pierre and Miquelon\n VC: '🇻🇨', // Saint Vincent and the Grenadines\n WS: '🇼🇸', // Samoa\n SM: '🇸🇲', // San Marino\n ST: '🇸🇹', // São Tomé and Príncipe\n SA: '🇸🇦', // Saudi Arabia\n SN: '🇸🇳', // Senegal\n RS: '🇷🇸', // Serbia\n SC: '🇸🇨', // Seychelles\n SL: '🇸🇱', // Sierra Leone\n SG: '🇸🇬', // Singapore\n SX: '🇸🇽', // Sint Maarten (Dutch part)\n SK: '🇸🇰', // Slovakia\n SI: '🇸🇮', // Slovenia\n SB: '🇸🇧', // Solomon Islands\n SO: '🇸🇴', // Somalia\n ZA: '🇿🇦', // South Africa\n GS: '🇬🇸', // South Georgia and the South Sandwich Islands\n SS: '🇸🇸', // South Sudan\n ES: '🇪🇸', // Spain\n LK: '🇱🇰', // Sri Lanka\n SD: '🇸🇩', // Sudan\n SR: '🇸🇷', // Suriname\n SJ: '🇸🇯', // Svalbard and Jan Mayen\n SE: '🇸🇪', // Sweden\n CH: '🇨🇭', // Switzerland\n SY: '🇸🇾', // Syrian Arab Republic\n TW: '🇹🇼', // Taiwan\n TJ: '🇹🇯', // Tajikistan\n TZ: '🇹🇿', // Tanzania\n TH: '🇹🇭', // Thailand\n TL: '🇹🇱', // Timor-Leste\n TG: '🇹🇬', // Togo\n TK: '🇹🇰', // Tokelau\n TO: '🇹🇴', // Tonga\n TT: '🇹🇹', // Trinidad and Tobago\n TN: '🇹🇳', // Tunisia\n TR: '🇹🇷', // Türkiye\n TM: '🇹🇲', // Turkmenistan\n TC: '🇹🇨', // Turks and Caicos Islands\n TV: '🇹🇻', // Tuvalu\n UG: '🇺🇬', // Uganda\n UA: '🇺🇦', // Ukraine\n AE: '🇦🇪', // United Arab Emirates\n GB: '🇬🇧', // United Kingdom\n US: '🇺🇸', // United States of America\n UM: '🇺🇲', // United States Minor Outlying Islands\n UY: '🇺🇾', // Uruguay\n UZ: '🇺🇿', // Uzbekistan\n VU: '🇻🇺', // Vanuatu\n VE: '🇻🇪', // Venezuela\n VN: '🇻🇳', // Viet Nam\n VG: '🇻🇬', // Virgin Islands (British)\n VI: '🇻🇮', // Virgin Islands (U.S.)\n WF: '🇼🇫', // Wallis and Futuna\n EH: '🇪🇭', // Western Sahara\n YE: '🇾🇪', // Yemen\n ZM: '🇿🇲', // Zambia\n ZW: '🇿🇼', // Zimbabwe,\n EU: '🇪🇺', // European Union (EU)\n '419': '🌎', // Latin America\n} as Record<string, string>;\n","import { libraryDefaultLocale } from '../internal';\nimport { defaultEmoji } from './getLocaleEmoji';\nimport { _isValidLocale, _standardizeLocale } from './isValidLocale';\nimport _getLocaleEmoji from './getLocaleEmoji';\nimport { intlCache } from '../cache/IntlCache';\nimport { CustomMapping, shouldUseCanonicalLocale } from './customLocaleMapping';\n\nexport type LocaleProperties = {\n // assume code = \"de-AT\", defaultLocale = \"en-US\"\n\n code: string; // \"de-AT\"\n name: string; // \"Austrian German\"\n nativeName: string; // \"Österreichisches Deutsch\"\n\n languageCode: string; // \"de\"\n languageName: string; // \"German\"\n nativeLanguageName: string; // \"Deutsch\"\n\n // note that maximize() is NOT called here!\n\n nameWithRegionCode: string; // \"German (AT)\"\n nativeNameWithRegionCode: string; // \"Deutsch (AT)\"\n\n // for most likely script and region, maximize() is called\n\n regionCode: string; // \"AT\"\n regionName: string; // \"Austria\"\n nativeRegionName: string; // Österreich\n\n scriptCode: string; // \"Latn\"\n scriptName: string; // \"Latin\"\n nativeScriptName: string; // \"Lateinisch\"\n\n maximizedCode: string; // \"de-Latn-AT\"\n maximizedName: string; // \"Austrian German (Latin)\"\n nativeMaximizedName: string; // Österreichisches Deutsch (Lateinisch)\n\n minimizedCode: string; // \"de-AT\", but for \"de-DE\" it would just be \"de\"\n minimizedName: string; // \"\"Austrian German\";\n nativeMinimizedName: string; // \"Österreichisches Deutsch\"\n\n // Emoji depending on region code\n // In order not to accidentally spark international conflict, some emojis are hard-coded\n emoji: string;\n};\n\n/**\n * Creates a set of custom locale properties from a custom mapping.\n *\n * @param lArray - An array of locale codes to search for in the custom mapping.\n * @param customMapping - Optional custom mapping of locale codes to names.\n * @returns A partial set of locale properties, or undefined if no custom mapping is provided.\n */\nexport function createCustomLocaleProperties(\n lArray: string[],\n customMapping?: CustomMapping\n): Partial<LocaleProperties> | undefined {\n if (customMapping) {\n let merged: Partial<LocaleProperties> = {};\n for (const l of lArray) {\n const value = customMapping[l];\n if (value) {\n if (typeof value === 'string') {\n merged.name ||= value;\n } else if (value) {\n merged = { ...value, ...merged };\n }\n }\n }\n return merged;\n }\n return undefined;\n}\n\n/**\n * @internal\n */\nexport default function _getLocaleProperties(\n locale: string,\n defaultLocale: string = libraryDefaultLocale,\n customMapping?: CustomMapping\n): LocaleProperties {\n // Check for canonical locale\n const aliasedLocale = locale;\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n // Override locale with canonical locale\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n defaultLocale ||= libraryDefaultLocale;\n\n try {\n const standardizedLocale = _standardizeLocale(locale); // \"de-AT\"\n\n const localeObject = intlCache.get('Locale', locale);\n const languageCode = localeObject.language; // \"de\"\n\n const customLocaleProperties = createCustomLocaleProperties(\n [aliasedLocale, locale, standardizedLocale, languageCode],\n customMapping\n );\n\n const baseRegion = localeObject.region; // \"AT\"\n\n const maximizedLocale = localeObject.maximize();\n const maximizedCode = maximizedLocale.toString(); // \"de-Latn-AT\"\n const regionCode =\n localeObject.region ||\n customLocaleProperties?.regionCode ||\n maximizedLocale.region ||\n ''; // \"AT\"\n const scriptCode =\n localeObject.script ||\n customLocaleProperties?.scriptCode ||\n maximizedLocale.script ||\n ''; // \"Latn\"\n\n const minimizedLocale = localeObject.minimize();\n const minimizedCode = minimizedLocale.toString(); // \"de-AT\"\n\n // Language names (default and native)\n\n const defaultLanguageOrder = [defaultLocale, locale, libraryDefaultLocale];\n const nativeLanguageOrder = [locale, defaultLocale, libraryDefaultLocale];\n\n const languageNames = intlCache.get('DisplayNames', defaultLanguageOrder, {\n type: 'language',\n });\n const nativeLanguageNames = intlCache.get(\n 'DisplayNames',\n nativeLanguageOrder,\n { type: 'language' }\n );\n\n const customName = customLocaleProperties?.name;\n const customNativeName =\n customLocaleProperties?.nativeName || customLocaleProperties?.name;\n\n const name = customName || languageNames.of(locale) || locale; // \"Austrian German\"\n const nativeName =\n customNativeName || nativeLanguageNames.of(locale) || locale; // \"Österreichisches Deutsch\"\n\n const maximizedName =\n customLocaleProperties?.maximizedName ||\n customName ||\n languageNames.of(maximizedCode) ||\n locale; // \"Austrian German (Latin)\"\n const nativeMaximizedName =\n customLocaleProperties?.nativeMaximizedName ||\n customNativeName ||\n nativeLanguageNames.of(maximizedCode) ||\n locale; // \"Österreichisches Deutsch (Lateinisch)\"\n\n const minimizedName =\n customLocaleProperties?.minimizedName ||\n customName ||\n languageNames.of(minimizedCode) ||\n locale; // \"Austrian German\", but for \"de-DE\" would just be \"German\"\n const nativeMinimizedName =\n customLocaleProperties?.nativeMinimizedName ||\n customNativeName ||\n nativeLanguageNames.of(minimizedCode) ||\n locale; // \"Österreichisches Deutsch\", but for \"de-DE\" would just be \"Deutsch\"\n\n const languageName =\n customLocaleProperties?.languageName ||\n customName ||\n languageNames.of(languageCode) ||\n locale; // \"German\"\n const nativeLanguageName =\n customLocaleProperties?.nativeLanguageName ||\n customNativeName ||\n nativeLanguageNames.of(languageCode) ||\n locale; // \"Deutsch\"\n\n const nameWithRegionCode =\n customLocaleProperties?.nameWithRegionCode || baseRegion\n ? `${languageName} (${baseRegion})`\n : name; // German (AT)\n const nativeNameWithRegionCode =\n customLocaleProperties?.nativeNameWithRegionCode ||\n (baseRegion ? `${nativeLanguageName} (${baseRegion})` : nativeName) ||\n nameWithRegionCode; // \"Deutsch (AT)\"\n\n // Region names (default and native)\n\n const regionNames = intlCache.get('DisplayNames', defaultLanguageOrder, {\n type: 'region',\n });\n const nativeRegionNames = intlCache.get(\n 'DisplayNames',\n nativeLanguageOrder,\n { type: 'region' }\n );\n\n const regionName =\n customLocaleProperties?.regionName ||\n (regionCode ? regionNames.of(regionCode) : '') ||\n ''; // \"Austria\"\n const nativeRegionName =\n customLocaleProperties?.nativeRegionName ||\n (regionCode ? nativeRegionNames.of(regionCode) : '') ||\n ''; // \"Österreich\"\n\n // Script names (default and native)\n\n const scriptNames = intlCache.get('DisplayNames', defaultLanguageOrder, {\n type: 'script',\n });\n const nativeScriptNames = intlCache.get(\n 'DisplayNames',\n nativeLanguageOrder,\n { type: 'script' }\n );\n\n const scriptName =\n customLocaleProperties?.scriptName ||\n (scriptCode ? scriptNames.of(scriptCode) : '') ||\n ''; // \"Latin\"\n const nativeScriptName =\n customLocaleProperties?.nativeScriptName ||\n (scriptCode ? nativeScriptNames.of(scriptCode) : '') ||\n ''; // \"Lateinisch\"\n\n // Emoji\n\n const emoji =\n customLocaleProperties?.emoji ||\n _getLocaleEmoji(standardizedLocale, customMapping);\n\n return {\n code: standardizedLocale,\n name,\n nativeName,\n maximizedCode,\n maximizedName,\n nativeMaximizedName,\n minimizedCode,\n minimizedName,\n nativeMinimizedName,\n languageCode,\n languageName,\n nativeLanguageName,\n nameWithRegionCode,\n nativeNameWithRegionCode,\n regionCode,\n regionName,\n nativeRegionName,\n scriptCode,\n scriptName,\n nativeScriptName,\n emoji,\n };\n } catch {\n let code = _isValidLocale(locale) ? _standardizeLocale(locale) : locale;\n const codeParts = code?.split('-');\n let languageCode = codeParts?.[0] || code || '';\n let regionCode =\n codeParts.length > 2 ? codeParts?.[2] : codeParts?.[1] || '';\n let scriptCode = codeParts?.[3] || '';\n\n const customLocaleProperties = createCustomLocaleProperties(\n [code, languageCode],\n customMapping\n );\n\n code = customLocaleProperties?.code || code;\n const name = customLocaleProperties?.name || code;\n const nativeName = customLocaleProperties?.nativeName || name;\n\n const maximizedCode = customLocaleProperties?.maximizedCode || code;\n const maximizedName = customLocaleProperties?.maximizedName || name;\n const nativeMaximizedName =\n customLocaleProperties?.nativeMaximizedName || nativeName;\n\n const minimizedCode = customLocaleProperties?.minimizedCode || code;\n const minimizedName = customLocaleProperties?.minimizedName || name;\n const nativeMinimizedName =\n customLocaleProperties?.nativeMinimizedName || nativeName;\n\n languageCode = customLocaleProperties?.languageCode || languageCode;\n const languageName = customLocaleProperties?.languageName || name;\n const nativeLanguageName =\n customLocaleProperties?.nativeLanguageName || nativeName;\n\n regionCode = customLocaleProperties?.regionCode || regionCode;\n const regionName = customLocaleProperties?.regionName || '';\n const nativeRegionName = customLocaleProperties?.nativeRegionName || '';\n\n scriptCode = customLocaleProperties?.scriptCode || scriptCode;\n const scriptName = customLocaleProperties?.scriptName || '';\n const nativeScriptName = customLocaleProperties?.nativeScriptName || '';\n\n const nameWithRegionCode =\n customLocaleProperties?.nameWithRegionCode ||\n (regionName ? `${languageName} (${regionName})` : name);\n const nativeNameWithRegionCode =\n customLocaleProperties?.nativeNameWithRegionCode ||\n (nativeRegionName\n ? `${nativeLanguageName} (${nativeRegionName})`\n : nativeName);\n\n const emoji = customLocaleProperties?.emoji || defaultEmoji;\n\n return {\n code,\n name,\n nativeName,\n maximizedCode,\n maximizedName,\n nativeMaximizedName,\n minimizedCode,\n minimizedName,\n nativeMinimizedName,\n languageCode,\n languageName,\n nativeLanguageName,\n nameWithRegionCode,\n nativeNameWithRegionCode,\n regionCode,\n regionName,\n nativeRegionName,\n scriptCode,\n scriptName,\n nativeScriptName,\n emoji,\n };\n }\n}\n","import { _isValidLocale, _standardizeLocale } from './isValidLocale';\nimport _isSameLanguage from './isSameLanguage';\nimport _isSameDialect from './isSameDialect';\nimport _getLocaleProperties from './getLocaleProperties';\nimport { CustomMapping } from './customLocaleMapping';\n\n/**\n * Given a list of locales and a list of approved locales, sorted in preference order\n * Determines which locale is the best match among the approved locales, prioritizing exact matches and falling back to dialects of the same language\n * @internal\n */\nexport default function _determineLocale(\n locales: string | string[],\n approvedLocales: string[],\n customMapping?: CustomMapping\n): string | undefined {\n if (typeof locales === 'string') locales = [locales];\n locales = locales\n .filter((locale) => _isValidLocale(locale, customMapping))\n .map(_standardizeLocale);\n approvedLocales = approvedLocales\n .filter((locale) => _isValidLocale(locale, customMapping))\n .map(_standardizeLocale);\n for (const locale of locales) {\n const candidates = approvedLocales.filter((approvedLocale) =>\n _isSameLanguage(locale, approvedLocale)\n );\n const getMatchingCode = ({\n locale,\n languageCode,\n minimizedCode,\n regionCode,\n scriptCode,\n }: {\n locale: string;\n languageCode: string;\n minimizedCode: string;\n regionCode: string;\n scriptCode: string;\n }) => {\n const locales = [\n locale, // If the full locale is supported under this language category\n `${languageCode}-${regionCode}`, // Attempt to match parts\n `${languageCode}-${scriptCode}`,\n minimizedCode, // If a minimized variant of this locale is supported\n ];\n for (const l of locales) {\n if (candidates.includes(l)) return l;\n }\n return null;\n };\n const { languageCode, ...codes } = _getLocaleProperties(locale);\n const matchingCode =\n getMatchingCode({ locale, languageCode, ...codes }) ||\n getMatchingCode({\n locale: languageCode,\n ..._getLocaleProperties(languageCode),\n });\n if (matchingCode) return matchingCode;\n }\n return undefined;\n}\n","/**\n * Comprehensive logging system for the General Translation library\n * Provides structured logging with multiple levels and configurable output\n */\n\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';\n\nexport interface LogEntry {\n level: LogLevel;\n message: string;\n timestamp: Date;\n context?: string;\n metadata?: Record<string, any>;\n}\n\nexport interface LoggerConfig {\n /** Minimum log level to output */\n level: LogLevel;\n /** Whether to include timestamps in log output */\n includeTimestamp: boolean;\n /** Whether to include context information */\n includeContext: boolean;\n /** Custom prefix for all log messages */\n prefix?: string;\n /** Whether to output to console (default: true) */\n enableConsole: boolean;\n /** Custom log handlers */\n handlers?: LogHandler[];\n}\n\nexport interface LogHandler {\n handle(entry: LogEntry): void;\n}\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n off: 4,\n};\n\nconst LOG_COLORS: Record<LogLevel, string> = {\n debug: '\\x1b[36m', // Cyan\n info: '\\x1b[32m', // Green\n warn: '\\x1b[33m', // Yellow\n error: '\\x1b[31m', // Red\n off: '', // No color needed since 'off' level logs are never displayed\n};\n\nconst RESET_COLOR = '\\x1b[0m';\n\n/**\n * Get the configured log level from environment variable or default to 'warn'\n */\nfunction getConfiguredLogLevel(): LogLevel {\n if (typeof process !== 'undefined' && process.env?._GT_LOG_LEVEL) {\n const envLevel = process.env._GT_LOG_LEVEL.toLowerCase();\n if (envLevel in LOG_LEVELS) {\n return envLevel as LogLevel;\n }\n }\n return 'warn';\n}\n\n/**\n * Console log handler that outputs formatted messages to console\n */\nexport class ConsoleLogHandler implements LogHandler {\n private config: LoggerConfig;\n\n constructor(config: LoggerConfig) {\n this.config = config;\n }\n\n handle(entry: LogEntry): void {\n const parts: string[] = [];\n\n // Add timestamp if enabled\n if (this.config.includeTimestamp) {\n parts.push(`[${entry.timestamp.toISOString()}]`);\n }\n\n // Add level with color\n const colorCode = LOG_COLORS[entry.level];\n const levelText = `[${entry.level.toUpperCase()}]`;\n parts.push(`${colorCode}${levelText}${RESET_COLOR}`);\n\n // Add prefix if configured\n if (this.config.prefix) {\n parts.push(`[${this.config.prefix}]`);\n }\n\n // Add context if available and enabled\n if (this.config.includeContext && entry.context) {\n parts.push(`[${entry.context}]`);\n }\n\n // Add the main message\n parts.push(entry.message);\n\n // Format metadata if available\n if (entry.metadata && Object.keys(entry.metadata).length > 0) {\n parts.push(`\\n Metadata: ${JSON.stringify(entry.metadata, null, 2)}`);\n }\n\n const formattedMessage = parts.join(' ');\n\n // Output to appropriate console method based on level\n switch (entry.level) {\n case 'debug':\n console.debug(formattedMessage);\n break;\n case 'info':\n console.info(formattedMessage);\n break;\n case 'warn':\n console.warn(formattedMessage);\n break;\n case 'error':\n console.error(formattedMessage);\n break;\n }\n }\n}\n\n/**\n * Main Logger class providing structured logging capabilities\n */\nexport class Logger {\n private config: LoggerConfig;\n private handlers: LogHandler[];\n\n constructor(config: Partial<LoggerConfig> = {}) {\n this.config = {\n level: getConfiguredLogLevel(),\n includeTimestamp: true,\n includeContext: true,\n enableConsole: true,\n handlers: [],\n ...config,\n };\n\n this.handlers = [...(this.config.handlers || [])];\n\n // Add console handler if enabled\n if (this.config.enableConsole) {\n this.handlers.push(new ConsoleLogHandler(this.config));\n }\n }\n\n /**\n * Add a custom log handler\n */\n addHandler(handler: LogHandler): void {\n this.handlers.push(handler);\n }\n\n /**\n * Remove a log handler\n */\n removeHandler(handler: LogHandler): void {\n const index = this.handlers.indexOf(handler);\n if (index > -1) {\n this.handlers.splice(index, 1);\n }\n }\n\n /**\n * Update logger configuration\n */\n configure(config: Partial<LoggerConfig>): void {\n this.config = { ...this.config, ...config };\n }\n\n /**\n * Check if a log level should be output based on current configuration\n */\n private shouldLog(level: LogLevel): boolean {\n return LOG_LEVELS[level] >= LOG_LEVELS[this.config.level];\n }\n\n /**\n * Internal logging method that creates log entries and passes them to handlers\n */\n private log(\n level: LogLevel,\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n if (!this.shouldLog(level)) {\n return;\n }\n\n const entry: LogEntry = {\n level,\n message,\n timestamp: new Date(),\n context,\n metadata,\n };\n\n // Pass to all handlers\n this.handlers.forEach((handler) => {\n try {\n handler.handle(entry);\n } catch (error) {\n // Prevent logging errors from breaking the application\n console.error('Error in log handler:', error);\n }\n });\n }\n\n /**\n * Log a debug message\n * Used for detailed diagnostic information, typically of interest only when diagnosing problems\n */\n debug(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('debug', message, context, metadata);\n }\n\n /**\n * Log an info message\n * Used for general information about application operation\n */\n info(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('info', message, context, metadata);\n }\n\n /**\n * Log a warning message\n * Used for potentially problematic situations that don't prevent operation\n */\n warn(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('warn', message, context, metadata);\n }\n\n /**\n * Log an error message\n * Used for error events that might still allow the application to continue\n */\n error(\n message: string,\n context?: string,\n metadata?: Record<string, any>\n ): void {\n this.log('error', message, context, metadata);\n }\n\n /**\n * Create a child logger with a specific context\n */\n child(context: string): ContextLogger {\n return new ContextLogger(this, context);\n }\n\n /**\n * Get current logger configuration\n */\n getConfig(): LoggerConfig {\n return { ...this.config };\n }\n}\n\n/**\n * Context logger that automatically includes context information\n */\nexport class ContextLogger {\n private logger: Logger;\n private context: string;\n\n constructor(logger: Logger, context: string) {\n this.logger = logger;\n this.context = context;\n }\n\n debug(message: string, metadata?: Record<string, any>): void {\n this.logger.debug(message, this.context, metadata);\n }\n\n info(message: string, metadata?: Record<string, any>): void {\n this.logger.info(message, this.context, metadata);\n }\n\n warn(message: string, metadata?: Record<string, any>): void {\n this.logger.warn(message, this.context, metadata);\n }\n\n error(message: string, metadata?: Record<string, any>): void {\n this.logger.error(message, this.context, metadata);\n }\n\n child(childContext: string): ContextLogger {\n return new ContextLogger(this.logger, `${this.context}:${childContext}`);\n }\n}\n\n// Default logger instance\nexport const defaultLogger = new Logger({\n level: getConfiguredLogLevel(),\n includeTimestamp: true,\n includeContext: true,\n prefix: 'GT',\n});\n\n// Convenience functions using the default logger\nexport const debug = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.debug(message, context, metadata);\n\nexport const info = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.info(message, context, metadata);\n\nexport const warn = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.warn(message, context, metadata);\n\nexport const error = (\n message: string,\n context?: string,\n metadata?: Record<string, any>\n) => defaultLogger.error(message, context, metadata);\n\n// Create context-specific loggers for different parts of the system\nexport const fetchLogger = defaultLogger.child('fetch');\nexport const validationLogger = defaultLogger.child('validation');\nexport const formattingLogger = defaultLogger.child('formatting');\nexport const localeLogger = defaultLogger.child('locale');\nexport const gtInstanceLogger = defaultLogger.child('GT instance');\n\n// Export types and classes\nexport { Logger as GTLogger };\n","import { FormatVariables, I18nextMessage } from '../types';\nimport { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport IntlMessageFormat from 'intl-messageformat';\nimport { formatI18nextWarning, formatJsxWarning } from '../logging/warnings';\nimport { formattingLogger } from '../logging/logger';\nimport { JsxChildren } from '../types';\nimport {\n CutoffFormatOptions,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\n CutoffFormatStyle,\n} from './custom-formats/CutoffFormat/types';\n\n/**\n * Formats a string value with cutoff behavior according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the cutoff formatting.\n * @param {string} params.value - The string value to format with cutoff behavior.\n * @param {string | string[]} [params.locales='en'] - The locales to use for formatting.\n * @param {CutoffFormatOptions} [params.options={}] - Additional options for cutoff formatting.\n * @param {number} [params.options.maxChars] - The maximum number of characters to display.\n * @param {CutoffFormatStyle} [params.options.style='ellipsis'] - The style of the terminator.\n * @param {string} [params.options.terminator] - Optional override for the terminator to use.\n * @param {string} [params.options.separator] - Optional override for the separator between terminator and value.\n *\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n * @internal\n *\n * @example\n * _formatCutoff({ value: 'Hello, world!', options: { maxChars: 8 } }); // Returns 'Hello, w...'\n *\n * Will fallback to an empty string if formatting fails.\n */\nexport function _formatCutoff({\n value,\n locales = libraryDefaultLocale,\n options = {},\n}: {\n value: string;\n locales?: string | string[];\n options?: CutoffFormatOptions;\n}): string {\n return intlCache.get('CutoffFormat', locales, options).format(value);\n}\n\n/**\n * Formats a message according to the specified locales and options.\n *\n * @param {string} message - The message to format.\n * @param {string | string[]} [locales='en'] - The locales to use for formatting.\n * @param {Record<string, any>} [variables={}] - The variables to use for formatting.\n * @returns {string} The formatted message.\n * @internal\n *\n * Will fallback to an empty string\n * TODO: add this to custom formats\n */\nexport function _formatMessageICU(\n message: string,\n locales: string | string[] = libraryDefaultLocale,\n variables: FormatVariables = {}\n): string {\n const messageFormat = new IntlMessageFormat(message, locales);\n return messageFormat.format(variables)?.toString() ?? '';\n}\n\n/**\n * Returns the message as-is without any formatting.\n *\n * @param {string} message - The message to return.\n * @returns {string} The original message, unchanged.\n * @internal\n *\n * TODO: add this to custom formats\n */\nexport function _formatMessageString(message: string): string {\n return message;\n}\n\n/**\n * Formats a number according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for number formatting.\n *\n * @returns {string} The formatted number.\n * @internal\n */\nexport function _formatNum({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: number;\n locales?: string | string[];\n options?: Intl.NumberFormatOptions;\n}): string {\n const res = intlCache\n .get('NumberFormat', locales, {\n numberingSystem: 'latn',\n ...options,\n })\n .format(value);\n return res;\n}\n\n/**\n * Formats a date according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {string | string[]} [params.locales='en'] - The locales to use for formatting.\n * @param {Intl.DateTimeFormatOptions} [params.options={}] - Additional options for date formatting.\n *\n * @returns {string} The formatted date.\n * @internal\n */\nexport function _formatDateTime({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: Date;\n locales?: string | string[];\n options?: Intl.DateTimeFormatOptions;\n}): string {\n return intlCache\n .get('DateTimeFormat', locales, {\n calendar: 'gregory',\n numberingSystem: 'latn',\n ...options,\n })\n .format(value);\n}\n\n/**\n * Formats a currency value according to the specified locales, currency, and options.\n *\n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n *\n * @returns {string} The formatted currency value.\n * @internal\n */\n\nexport function _formatCurrency({\n value,\n locales = [libraryDefaultLocale],\n currency = 'USD',\n options = {},\n}: {\n value: number;\n currency?: string;\n locales?: string | string[];\n options?: Intl.NumberFormatOptions;\n}): string {\n return intlCache\n .get('NumberFormat', locales, {\n style: 'currency',\n currency,\n numberingSystem: 'latn',\n ...options,\n })\n .format(value);\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n *\n * @returns {string} The formatted list.\n * @internal\n */\nexport function _formatList({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: Array<any>;\n locales?: string | string[];\n options?: Intl.ListFormatOptions;\n}): string {\n return intlCache\n .get('ListFormat', locales, {\n type: 'conjunction', // Default type, can be overridden via options\n style: 'long', // Default style, can be overridden via options\n ...options,\n })\n .format(value);\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<T>} params.value - The list of items to format.\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * @returns {Array<T | string>} The formatted list parts.\n * @internal\n */\nexport function _formatListToParts<T>({\n value,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: Array<T>;\n locales?: string | string[];\n options?: Intl.ListFormatOptions;\n}) {\n const formatListParts = intlCache\n .get('ListFormat', locales, {\n type: 'conjunction', // Default type, can be overridden via options\n style: 'long', // Default style, can be overridden via options\n ...options,\n })\n .formatToParts(value.map(() => '1'));\n let partIndex = 0;\n return formatListParts.map((part) => {\n if (part.type === 'element') return value[partIndex++];\n return part.value;\n });\n}\n\n/**\n * Selects the best unit and computes the value for relative time formatting\n * based on the difference between a date and a base date.\n * @param {Date} date - The target date.\n * @param {Date} baseDate - The base date to compute relative time from. Must be provided by the caller for hydration safety.\n * @returns {{ value: number, unit: Intl.RelativeTimeFormatUnit }} The computed value and unit.\n * @internal\n */\nexport function _selectRelativeTimeUnit(\n date: Date,\n baseDate: Date\n): {\n value: number;\n unit: Intl.RelativeTimeFormatUnit;\n} {\n const now = baseDate.getTime();\n const diffMs = date.getTime() - now;\n const absDiffMs = Math.abs(diffMs);\n const sign = diffMs < 0 ? -1 : 1;\n\n // Use Math.floor to avoid confusing jumps near boundaries\n // (e.g. 3.5 days rounding to \"1 week ago\" instead of \"3 days ago\")\n const seconds = Math.floor(absDiffMs / 1000);\n const minutes = Math.floor(absDiffMs / (1000 * 60));\n const hours = Math.floor(absDiffMs / (1000 * 60 * 60));\n const days = Math.floor(absDiffMs / (1000 * 60 * 60 * 24));\n const weeks = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 7));\n const months = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 30));\n const years = Math.floor(absDiffMs / (1000 * 60 * 60 * 24 * 365));\n\n if (seconds < 60) return { value: sign * seconds, unit: 'second' };\n if (minutes < 60) return { value: sign * minutes, unit: 'minute' };\n if (hours < 24) return { value: sign * hours, unit: 'hour' };\n if (days < 7) return { value: sign * days, unit: 'day' };\n if (days < 28) return { value: sign * weeks, unit: 'week' };\n if (months < 1) return { value: sign * weeks, unit: 'week' };\n if (months < 12) return { value: sign * months, unit: 'month' };\n if (years < 1) return { value: sign * months, unit: 'month' };\n return { value: sign * years, unit: 'year' };\n}\n\n/**\n * Formats a relative time from a Date, automatically selecting the best unit.\n * @internal\n */\nexport function _formatRelativeTimeFromDate({\n date,\n baseDate,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n date: Date;\n baseDate: Date;\n locales?: string | string[];\n options?: Intl.RelativeTimeFormatOptions;\n}): string {\n const { value, unit } = _selectRelativeTimeUnit(date, baseDate);\n return _formatRelativeTime({ value, unit, locales, options });\n}\n\n/**\n * Formats a relative time value according to the specified locales and options.\n *\n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {string | string[]} [params.locales=['en']] - The locales to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n *\n * @returns {string} The formatted relative time string.\n * @internal\n */\nexport function _formatRelativeTime({\n value,\n unit,\n locales = [libraryDefaultLocale],\n options = {},\n}: {\n value: number;\n unit: Intl.RelativeTimeFormatUnit;\n locales?: string | string[];\n options?: Intl.RelativeTimeFormatOptions;\n}): string {\n return intlCache\n .get('RelativeTimeFormat', locales, {\n style: 'long',\n numeric: 'auto',\n ...options,\n })\n .format(value, unit);\n}\n\n/**\n * @experimental This function is not currently supported but will be implemented in a future version.\n * Use {@link _formatMessageICU} for current ICU message format support.\n * Formats an I18next message according to the specified locales and options.\n *\n * @param message - The I18next message to format.\n * @param variables - The variables to use for formatting.\n * @returns The formatted I18next message.\n * @internal\n */\nexport function _formatI18next(\n message: I18nextMessage,\n // eslint-disable-next-line no-unused-vars\n _variables: FormatVariables = {}\n): string {\n formattingLogger.warn(formatI18nextWarning);\n return message;\n}\n\n/**\n * @experimental This function is not currently supported but will be implemented in a future version.\n * Use {@link _formatMessageICU} for current ICU message format support.\n * Formats a JSX message according to the specified locales and options.\n *\n * @param message - The JSX message to format.\n * @param variables - The variables to use for formatting.\n * @returns The formatted JSX message.\n * @internal\n */\nexport function _formatJsx(\n message: JsxChildren,\n // eslint-disable-next-line no-unused-vars\n _variables: FormatVariables = {}\n): JsxChildren {\n formattingLogger.warn(formatJsxWarning);\n return message;\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport {\n CustomMapping,\n getCustomProperty,\n shouldUseCanonicalLocale,\n} from './customLocaleMapping';\nimport { _standardizeLocale } from './isValidLocale';\n\n/**\n * Retrieves the display name(s) of locale code(s) using Intl.DisplayNames.\n *\n * @param {string} locale - A BCP-47 locale code.\n * @param {string} [defaultLocale=libraryDefaultLocale] - The locale for display names.\n * @returns {string} The display name(s) corresponding to the code(s), or empty string(s) if invalid.\n * @internal\n */\nexport function _getLocaleName(\n locale: string,\n defaultLocale: string = libraryDefaultLocale,\n customMapping?: CustomMapping\n): string {\n // Check for canonical locale\n const aliasedLocale = locale;\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n // Override locale with canonical locale\n locale = (customMapping[locale] as { code: string }).code;\n }\n\n defaultLocale ||= libraryDefaultLocale;\n try {\n const standardizedLocale = _standardizeLocale(locale);\n if (customMapping) {\n for (const l of [\n aliasedLocale,\n locale,\n standardizedLocale,\n intlCache.get('Locale', standardizedLocale).language,\n ]) {\n const customName = getCustomProperty(customMapping, l, 'name');\n if (customName) return customName;\n }\n }\n const displayNames = intlCache.get(\n 'DisplayNames',\n [defaultLocale, standardizedLocale, libraryDefaultLocale], // default locale order\n { type: 'language' }\n );\n return displayNames.of(standardizedLocale) || '';\n } catch {\n // In case Intl.DisplayNames construction fails, return empty string(s)\n return '';\n }\n}\n","import { intlCache } from '../cache/IntlCache';\nimport _getLocaleProperties from './getLocaleProperties';\n\n/**\n * Get the text direction for a given locale code using the Intl.Locale API.\n *\n * @param {string} code - The locale code to check.\n * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.\n * @internal\n */\nexport function _getLocaleDirection(code: string): 'ltr' | 'rtl' {\n // Extract via textInfo property\n try {\n const locale = intlCache.get('Locale', code);\n const textInfoDirection = extractDirectionWithTextInfo(locale);\n if (textInfoDirection) {\n return textInfoDirection;\n }\n } catch {\n // silent\n }\n\n // Fallback to simple heuristics\n const { scriptCode, languageCode } = _getLocaleProperties(code);\n\n // Handle RTL script or language\n if (scriptCode) return isRtlScript(scriptCode) ? 'rtl' : 'ltr';\n if (languageCode) return isRtlLanguage(languageCode) ? 'rtl' : 'ltr';\n\n return 'ltr';\n}\n\n// ===== HELPER CONSTANTS ===== //\n\nconst RTL_SCRIPTS = new Set([\n 'arab',\n 'adlm',\n 'hebr',\n 'nkoo',\n 'rohg',\n 'samr',\n 'syrc',\n 'thaa',\n 'yezi',\n]);\n\nconst RTL_LANGUAGES = new Set([\n 'ar',\n 'arc',\n 'ckb',\n 'dv',\n 'fa',\n 'he',\n 'iw',\n 'ku',\n 'lrc',\n 'nqo',\n 'ps',\n 'pnb',\n 'sd',\n 'syr',\n 'ug',\n 'ur',\n 'yi',\n]);\n\n// ===== HELPER FUNCTIONS ===== //\n\n/**\n * Handles extracting direction via textInfo property\n * @param Locale - Intl.Locale object\n * @returns {'ltr' | 'rtl'} - The direction of the locale\n *\n * Intl.Locale.prototype.getTextInfo() / textInfo property incorporated in ES2024 Specification.\n * This is not supported by all browsers yet.\n * See: {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo#browser_compatibility}\n */\nfunction extractDirectionWithTextInfo(\n locale: Intl.Locale\n): 'ltr' | 'rtl' | undefined {\n if (\n 'textInfo' in locale &&\n typeof locale.textInfo === 'object' &&\n locale.textInfo !== null &&\n 'direction' in locale.textInfo &&\n (locale.textInfo?.direction === 'rtl' ||\n locale.textInfo?.direction === 'ltr')\n ) {\n return locale.textInfo?.direction;\n }\n\n return undefined;\n}\n\nfunction isRtlScript(script: string | undefined): boolean {\n return script ? RTL_SCRIPTS.has(script.toLowerCase()) : false;\n}\n\nfunction isRtlLanguage(language: string | undefined): boolean {\n return language ? RTL_LANGUAGES.has(language.toLowerCase()) : false;\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { _standardizeLocale } from './isValidLocale';\n\n/**\n * @internal\n */\nexport default function _isSupersetLocale(\n superLocale: string,\n subLocale: string\n): boolean {\n try {\n const {\n language: languageSuper,\n region: regionSuper,\n script: scriptSuper,\n } = intlCache.get('Locale', _standardizeLocale(superLocale));\n const {\n language: languageSub,\n region: regionSub,\n script: scriptSub,\n } = intlCache.get('Locale', _standardizeLocale(subLocale));\n\n if (languageSuper !== languageSub) return false;\n if (regionSuper && regionSuper !== regionSub) return false;\n if (scriptSuper && scriptSuper !== scriptSub) return false;\n\n return true;\n } catch (error) {\n console.error(error);\n return false;\n }\n}\n","const GT_ERROR_PREFIX = 'GT Error:';\n\nexport const translationTimeoutError = (timeout: number) =>\n `${GT_ERROR_PREFIX} Translation request timed out after ${timeout}ms.`;\n\nexport const translationRequestFailedError = (error: string) =>\n `${GT_ERROR_PREFIX} Translation request failed. Error: ${error}`;\n\nexport const apiError = (status: number, statusText: string, error: string) =>\n `${GT_ERROR_PREFIX} API returned error status. Status: ${status}, Status Text: ${statusText}, Error: ${error}`;\n\nexport const invalidAuthError = `${GT_ERROR_PREFIX} Invalid authentication.`;\n\nexport const noTargetLocaleProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified locale. Either pass a locale to the \\`${functionName}\\` function or specify a targetLocale in the GT constructor.`;\n\nexport const noSourceLocaleProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified locale. Either pass a locale to the \\`${functionName}\\` function or specify a sourceLocale in the GT constructor.`;\n\nexport const noProjectIdProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified project ID. Either pass a project ID to the \\`${functionName}\\` function or specify a projectId in the GT constructor.`;\n\nexport const noApiKeyProvidedError = (functionName: string) =>\n `${GT_ERROR_PREFIX} Cannot call \\`${functionName}\\` without a specified API key. Either pass an API key to the \\`${functionName}\\` function or specify an apiKey in the GT constructor.`;\n\nexport const invalidLocaleError = (locale: string) =>\n `${GT_ERROR_PREFIX} Invalid locale: ${locale}.`;\n\nexport const invalidLocalesError = (locales: string[]) =>\n `${GT_ERROR_PREFIX} Invalid locales: ${locales.join(', ')}.`;\n","import { translationTimeoutError } from '../../logging/errors';\nimport { defaultTimeout } from '../../settings/settings';\n\n/**\n * @internal\n *\n * Wraps the fetch function with a timeout.\n *\n * @param url - The URL to fetch.\n * @param options - The options to pass to the fetch function.\n * @param timeout - The timeout in milliseconds.\n * @returns The response from the fetch function.\n */\nexport default async function fetchWithTimeout(\n url: string | URL | globalThis.Request,\n options: RequestInit,\n timeout?: number\n) {\n const controller = new AbortController();\n const signal = controller.signal;\n\n timeout = timeout ? timeout : defaultTimeout;\n const timeoutId = timeout\n ? setTimeout(() => controller.abort(), timeout)\n : null;\n\n try {\n const response = await fetch(url, { ...options, signal });\n return response;\n } catch (error) {\n if (error instanceof Error && error.name === 'AbortError') {\n throw translationTimeoutError(timeout);\n }\n throw error;\n } finally {\n if (timeoutId) clearTimeout(timeoutId);\n }\n}\n","import { apiError } from '../../logging/errors';\nimport { ApiError } from '../../errors/ApiError';\n\nexport default async function validateResponse(response: Response) {\n if (!response.ok) {\n let errorMsg = 'Unknown error';\n try {\n const text = await response.text();\n try {\n const errorJson = JSON.parse(text) as { error: string };\n errorMsg = errorJson.error;\n } catch {\n errorMsg = text || 'Unknown error';\n }\n } catch {\n // response.text() failed, keep 'Unknown error'\n }\n const errorMessage = apiError(\n response.status,\n response.statusText,\n errorMsg\n );\n const error = new ApiError(errorMessage, response.status, errorMsg);\n throw error;\n }\n}\n","import { fetchLogger } from '../../logging/logger';\nimport {\n translationRequestFailedError,\n translationTimeoutError,\n} from '../../logging/errors';\n\nexport default function handleFetchError(\n error: unknown,\n timeout: number\n): never {\n if (error instanceof Error && error.name === 'AbortError') {\n const errorMessage = translationTimeoutError(timeout);\n fetchLogger.error(errorMessage);\n throw new Error(errorMessage);\n }\n const errorMessage = translationRequestFailedError(\n error instanceof Error ? error.message : String(error)\n );\n fetchLogger.error(errorMessage);\n throw error;\n}\n","export const API_VERSION = '2026-03-06.v1';\n","import { TranslationRequestConfig } from '../../types';\nimport { API_VERSION } from '../api';\n\nexport default function generateRequestHeaders(\n config: TranslationRequestConfig,\n excludeContentType = false\n) {\n const authHeaders: Record<string, string> = {\n ...(!excludeContentType && { 'Content-Type': 'application/json' }),\n 'x-gt-project-id': config.projectId,\n };\n\n if (config.apiKey) {\n if (config.apiKey.startsWith('gtx-internal-')) {\n authHeaders['x-gt-internal-api-key'] = config.apiKey;\n } else {\n authHeaders['x-gt-api-key'] = config.apiKey;\n }\n }\n\n authHeaders['gt-api-version'] = API_VERSION;\n\n return authHeaders;\n}\n","import { TranslationRequestConfig } from '../../types';\nimport { defaultBaseUrl } from '../../settings/settingsUrls';\nimport { defaultTimeout } from '../../settings/settings';\nimport fetchWithTimeout from './fetchWithTimeout';\nimport validateResponse from './validateResponse';\nimport handleFetchError from './handleFetchError';\nimport generateRequestHeaders from './generateRequestHeaders';\n\nconst MAX_RETRIES = 3;\nconst INITIAL_DELAY_MS = 500;\n\ntype RetryPolicy = 'exponential' | 'linear' | 'none';\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction getRetryDelay(policy: RetryPolicy, attempt: number): number {\n switch (policy) {\n case 'linear':\n return INITIAL_DELAY_MS * (attempt + 1);\n case 'exponential':\n return INITIAL_DELAY_MS * 2 ** attempt;\n default:\n return 0;\n }\n}\n\n/**\n * @internal\n *\n * Makes an API request with automatic retry for 5XX errors.\n *\n * Encapsulates URL construction, fetch with timeout, error handling,\n * response validation, and JSON parsing.\n *\n * @param config - The configuration for the API call\n * @param endpoint - The API endpoint path (e.g. '/v2/project/jobs/info')\n * @param options - Optional request options\n * @returns The parsed JSON response\n */\nexport default async function apiRequest<T>(\n config: TranslationRequestConfig,\n endpoint: string,\n options?: {\n body?: unknown;\n timeout?: number;\n method?: 'GET' | 'POST';\n retryPolicy?: RetryPolicy;\n }\n): Promise<T> {\n const timeout = options?.timeout ?? defaultTimeout;\n const url = `${config.baseUrl || defaultBaseUrl}${endpoint}`;\n const method = options?.method ?? 'POST';\n const retryPolicy = options?.retryPolicy ?? 'exponential';\n const maxRetries = retryPolicy === 'none' ? 0 : MAX_RETRIES;\n\n const requestInit: RequestInit = {\n method,\n headers: generateRequestHeaders(config),\n };\n if (options?.body !== undefined) {\n requestInit.body = JSON.stringify(options.body);\n }\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n let response: Response;\n try {\n response = await fetchWithTimeout(url, requestInit, timeout);\n } catch (error) {\n if (attempt < maxRetries) {\n await sleep(getRetryDelay(retryPolicy, attempt));\n continue;\n }\n handleFetchError(error, timeout);\n }\n\n // Retry on 5XX server errors\n if (response!.status >= 500 && attempt < maxRetries) {\n await sleep(getRetryDelay(retryPolicy, attempt));\n continue;\n }\n\n await validateResponse(response!);\n return (await response!.json()) as T;\n }\n\n throw new Error('Max retries exceeded');\n}\n","import {\n TranslationRequestConfig,\n TranslateManyResult,\n TranslationResult,\n} from '../types';\nimport { defaultRuntimeApiUrl } from '../settings/settingsUrls';\nimport {\n TranslateManyEntry,\n TranslateOptions,\n EntryMetadata,\n} from '../types-dir/api/entry';\nimport apiRequest from './utils/apiRequest';\nimport { Content } from '../types-dir/jsx/content';\nimport { hashSource } from '../id';\n\n/**\n * @internal\n *\n * Translates multiple entries in a single API request for better performance.\n * This function batches multiple translation requests together and sends them\n * to the GT translation API in one call.\n *\n * @param requests - The entries to translate. Can be an array (entries are hashed and results returned in order) or a record keyed by hash (skips hash calculation, returns a record).\n * @param globalMetadata - The metadata for the translation.\n * @param config - The configuration for the translation.\n * @returns The results of the translation. An array if requests was an array, a record if requests was a record.\n */\nexport default async function _translateMany<\n T extends TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n>(\n requests: T,\n globalMetadata: {\n targetLocale: string;\n sourceLocale: string;\n } & TranslateOptions,\n config: TranslationRequestConfig,\n timeout?: number\n): Promise<\n T extends TranslateManyEntry[]\n ? TranslateManyResult\n : Record<string, TranslationResult>\n>;\nexport default async function _translateMany(\n requests: TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n globalMetadata: {\n targetLocale: string;\n sourceLocale: string;\n } & TranslateOptions,\n config: TranslationRequestConfig,\n timeout?: number\n): Promise<TranslateManyResult | Record<string, TranslationResult>> {\n const isArray = Array.isArray(requests);\n\n // normalize and map from requests to requests record\n const hashOrder: string[] | undefined = isArray ? [] : undefined;\n const requestsObject: Record<\n string,\n { source: Content; metadata?: EntryMetadata }\n > = {};\n\n const entries: [string | undefined, TranslateManyEntry][] = isArray\n ? requests.map((r) => [undefined, r])\n : Object.entries(requests);\n\n for (const [key, request] of entries) {\n const normalized =\n typeof request === 'string' ? { source: request } : request;\n const { source, metadata } = normalized;\n const hash =\n key ??\n metadata?.hash ??\n hashSource({\n source,\n dataFormat: metadata?.dataFormat ?? 'STRING',\n ...(metadata ?? {}),\n });\n hashOrder?.push(hash);\n requestsObject[hash] = {\n source,\n metadata: metadata,\n };\n }\n\n const response = await apiRequest<Record<string, TranslationResult>>(\n { ...config, baseUrl: config.baseUrl || defaultRuntimeApiUrl },\n `/v2/translate`,\n {\n body: {\n requests: requestsObject,\n targetLocale: globalMetadata.targetLocale,\n sourceLocale: globalMetadata.sourceLocale,\n metadata: globalMetadata,\n },\n timeout: timeout,\n retryPolicy: 'none',\n }\n );\n\n // If input was an array, map the record response back to an array in input order\n if (hashOrder) {\n return hashOrder.map(\n (hash) =>\n response[hash] ?? {\n success: false,\n error: 'No translation returned',\n code: 500,\n }\n );\n }\n\n // If input was a record, return the record response directly\n return response;\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport type { FileReference } from '../types-dir/api/file';\n\nexport type SetupProjectResult =\n | { setupJobId: string; status: 'queued' }\n | { status: 'completed' };\n\nexport type SetupProjectOptions = {\n force?: boolean;\n locales?: string[];\n timeoutMs?: number;\n};\n\n/**\n * @internal\n * Enqueues files for project setup the General Translation API.\n * @param files - References of files to translate (file content already uploaded)\n * @param config - The configuration for the API call\n * @param timeoutMS - The timeout in milliseconds\n * @returns The result of the API call\n */\nexport default async function _setupProject(\n files: FileReference[],\n config: TranslationRequestConfig,\n options?: SetupProjectOptions\n): Promise<SetupProjectResult> {\n return apiRequest<SetupProjectResult>(config, '/v2/project/setup/generate', {\n body: {\n files: files.map((f) => ({\n branchId: f.branchId,\n fileId: f.fileId,\n versionId: f.versionId,\n })),\n locales: options?.locales,\n force: options?.force,\n },\n timeout: options?.timeoutMs,\n });\n}\n","/**\n * Splits an array into batches of a specified size.\n * @param items - The array to split into batches\n * @param batchSize - The maximum size of each batch\n * @returns An array of batches\n */\nexport function createBatches<T>(items: T[], batchSize: number): T[][] {\n const batches: T[][] = [];\n for (let i = 0; i < items.length; i += batchSize) {\n batches.push(items.slice(i, i + batchSize));\n }\n return batches;\n}\n\n/**\n * Result of processing batches\n */\nexport interface BatchList<T> {\n /** The items successfully processed across all batches */\n data: T[];\n /** The total number of items processed */\n count: number;\n /** The number of batches processed */\n batchCount: number;\n}\n\n/**\n * Options for batch processing\n */\nexport interface BatchProcessOptions {\n /** Maximum number of items per batch (default: 100) */\n batchSize?: number;\n /** Whether to process batches in parallel (default: true) */\n parallel?: boolean;\n}\n\n/**\n * Processes items in batches using a provided processor function.\n *\n * @param items - The items to process\n * @param processor - Async function that processes a single batch and returns items\n * @param options - Optional configuration for batch processing\n * @returns Promise that resolves to a BatchList containing all processed items\n *\n * @example\n * ```typescript\n * const result = await processBatches(\n * files,\n * async (batch) => {\n * const response = await uploadFiles(batch);\n * return response.uploadedFiles;\n * },\n * { batchSize: 100 }\n * );\n *\n * console.log(result.data); // All items\n * console.log(result.count); // Total count\n * console.log(result.batchCount); // Number of batches processed\n * ```\n */\nexport async function processBatches<TInput, TOutput>(\n items: TInput[],\n processor: (batch: TInput[]) => Promise<TOutput[]>,\n options: BatchProcessOptions = {}\n): Promise<BatchList<TOutput>> {\n const { batchSize = 100, parallel = true } = options;\n\n if (items.length === 0) {\n return {\n data: [],\n count: 0,\n batchCount: 0,\n };\n }\n\n const batches = createBatches(items, batchSize);\n const allItems: TOutput[] = [];\n\n if (parallel) {\n // Process all batches in parallel\n const results = await Promise.all(batches.map((batch) => processor(batch)));\n for (const result of results) {\n if (result) {\n allItems.push(...result);\n }\n }\n } else {\n // Process batches sequentially\n for (const batch of batches) {\n const result = await processor(batch);\n if (result) {\n allItems.push(...result);\n }\n }\n }\n\n return {\n data: allItems,\n count: allItems.length,\n batchCount: batches.length,\n };\n}\n","import { TranslationRequestConfig, EnqueueFilesResult } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport type { FileReferenceIds } from '../types-dir/api/file';\nimport { processBatches } from './utils/batch';\nimport { validateFileFormatTransforms } from './utils/validateFileFormatTransform';\n\nexport type EnqueueOptions = {\n sourceLocale?: string;\n targetLocales: string[];\n requireApproval?: boolean;\n modelProvider?: string;\n force?: boolean;\n timeout?: number;\n};\n\n/**\n * @internal\n * Enqueues files for translation in the General Translation API.\n * @param files - References of files to translate (file content already uploaded)\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns The result of the API call\n */\nexport default async function _enqueueFiles(\n files: FileReferenceIds[],\n options: EnqueueOptions,\n config: TranslationRequestConfig\n): Promise<EnqueueFilesResult> {\n validateFileFormatTransforms(files);\n\n const result = await processBatches(\n files,\n async (batch) => {\n const body = {\n files: batch.map((f) => ({\n branchId: f.branchId,\n fileId: f.fileId,\n versionId: f.versionId,\n fileName: f.fileName,\n transformFormat: f.transformFormat,\n })),\n targetLocales: options.targetLocales,\n sourceLocale: options.sourceLocale,\n requireApproval: options.requireApproval,\n modelProvider: options.modelProvider,\n force: options.force,\n };\n\n const apiResult = await apiRequest<EnqueueFilesResult>(\n config,\n '/v2/project/translations/enqueue',\n { body, timeout: options.timeout }\n );\n return Array.from(Object.entries(apiResult.jobData));\n },\n { batchSize: 100 }\n );\n // flatten the result\n const jobs = Object.fromEntries(\n result.data.map(([jobId, jobData]) => [jobId, jobData])\n );\n return {\n jobData: jobs,\n locales: options.targetLocales,\n message: `Successfully enqueued ${result.count} file translation jobs in ${result.batchCount} batch(es)`,\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type CreateTagFileReference = {\n fileId: string;\n versionId: string;\n branchId: string;\n};\n\nexport type CreateTagOptions = {\n tagId: string;\n files: CreateTagFileReference[];\n message?: string;\n};\n\nexport type CreateTagResult = {\n tag: {\n id: string;\n tagId: string;\n message: string | null;\n createdAt: string;\n updatedAt: string;\n };\n};\n\n/**\n * @internal\n * Creates or upserts a file tag in the General Translation API.\n * @param options - The tag creation options\n * @param config - The configuration for the API call\n * @returns The created or updated tag\n */\nexport default async function _createTag(\n options: CreateTagOptions,\n config: TranslationRequestConfig\n): Promise<CreateTagResult> {\n return await apiRequest<CreateTagResult>(config, '/v2/project/tags/create', {\n body: {\n tagId: options.tagId,\n files: options.files,\n ...(options.message && { message: options.message }),\n },\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport {\n DownloadFileBatchOptions,\n DownloadFileBatchRequest,\n DownloadFileBatchResult,\n} from '../types-dir/api/downloadFileBatch';\nimport apiRequest from './utils/apiRequest';\nimport { decode } from '../utils/base64';\nimport { processBatches } from './utils/batch';\n\n/**\n * @internal\n * Downloads multiple translation files in batches.\n * @param files - Array of files to download\n * @param options - The options for the API call\n * @param config - The configuration for the request\n * @returns Promise resolving to a BatchList with all downloaded files\n */\nexport default async function _downloadFileBatch(\n requests: DownloadFileBatchRequest,\n options: DownloadFileBatchOptions,\n config: TranslationRequestConfig\n) {\n return processBatches(\n requests,\n async (batch) => {\n const result = await apiRequest<DownloadFileBatchResult>(\n config,\n '/v2/project/files/download',\n { body: batch, timeout: options.timeout }\n );\n\n // convert from base64 to string\n const files = result.files.map((file) => ({\n ...file,\n data: decode(file.data),\n }));\n\n return files;\n },\n { batchSize: 100 }\n );\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { processBatches } from './utils/batch';\n\nexport type SubmitUserEditDiff = {\n fileName: string;\n locale: string;\n diff: string;\n branchId: string;\n versionId: string;\n fileId: string;\n localContent: string;\n};\n\nexport type SubmitUserEditDiffsPayload = {\n diffs: SubmitUserEditDiff[];\n};\n\n/**\n * @internal\n * Submits user edit diffs so the service can learn/persist user-intended rules.\n */\nexport default async function _submitUserEditDiffs(\n payload: SubmitUserEditDiffsPayload,\n config: TranslationRequestConfig,\n options: { timeout?: number } = {}\n): Promise<{ success: boolean }> {\n await processBatches(\n payload.diffs,\n async (batch) => {\n await apiRequest(config, '/v2/project/files/diffs', {\n body: { diffs: batch } satisfies SubmitUserEditDiffsPayload,\n timeout: options.timeout,\n });\n return [{ success: true }];\n },\n { batchSize: 100 }\n );\n\n return { success: true };\n}\n","import { intlCache } from '../cache/IntlCache';\nimport { libraryDefaultLocale } from '../internal';\nimport { defaultEmoji, emojis } from './getLocaleEmoji';\nimport { _standardizeLocale } from './isValidLocale';\n\nexport type CustomRegionMapping = {\n [region: string]: { name?: string; emoji?: string; locale?: string };\n};\n\n/**\n * Retrieves multiple properties for a given region code, including:\n * - `code`: the original region code\n * - `name`: the localized display name\n * - `emoji`: the associated flag or symbol\n *\n * Behavior:\n * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `\"US\"`, `\"FR\"`, `\"419\"`).\n * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.\n * - Otherwise, uses `Intl.DisplayNames` to get the localized region name in the given `defaultLocale`,\n * falling back to `libraryDefaultLocale`.\n * - Falls back to the region code as `name` if display name resolution fails.\n * - Falls back to `defaultEmoji` if no emoji mapping is found in `emojis` or `customMapping`.\n *\n * @param {string} region - The region code to look up (e.g., `\"US\"`, `\"GB\"`, `\"DE\"`).\n * @param {string} [defaultLocale=libraryDefaultLocale] - The locale to use when localizing the region name.\n * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.\n * @returns {{ code: string, name: string, emoji: string }} An object containing:\n * - `code`: the input region code\n * - `name`: the localized or custom region name\n * - `emoji`: the matching emoji flag or symbol\n * @internal\n *\n * @example\n * _getRegionProperties('US', 'en');\n * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }\n *\n * @example\n * _getRegionProperties('US', 'fr');\n * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }\n *\n * @example\n * _getRegionProperties('US', 'en', { US: { name: 'USA', emoji: '🗽' } });\n * // => { code: 'US', name: 'USA', emoji: '🗽' }\n */\nexport function _getRegionProperties(\n region: string,\n defaultLocale: string = libraryDefaultLocale,\n customMapping?: CustomRegionMapping\n): {\n code: string;\n name: string;\n emoji: string;\n locale?: string; // locale is a hidden return field, because we don't want to guarantee it, but we also need customMapping to work with it\n} {\n defaultLocale ||= libraryDefaultLocale;\n try {\n const displayNames = intlCache.get(\n 'DisplayNames',\n [defaultLocale, libraryDefaultLocale], // default language order\n { type: 'region' }\n );\n return {\n code: region,\n name: displayNames.of(region) || region,\n emoji: emojis[region] || defaultEmoji,\n ...customMapping?.[region],\n };\n } catch {\n return {\n code: region,\n name: region,\n emoji: defaultEmoji,\n ...customMapping?.[region],\n };\n }\n}\n","import { CustomMapping } from './customLocaleMapping';\n\n/**\n * Resolves the alias locale for a given locale.\n * @param locale - The locale to resolve the alias locale for\n * @param customMapping - The custom mapping to use for resolving the alias locale\n * @returns The alias locale\n */\nexport function _resolveAliasLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n let reverseCustomMapping: Record<string, string> | undefined;\n if (customMapping) {\n reverseCustomMapping = Object.fromEntries(\n Object.entries(customMapping)\n .filter(\n ([, value]) => value && typeof value === 'object' && 'code' in value\n )\n .map(([key, value]) => [(value as { code: string }).code, key])\n );\n }\n\n return reverseCustomMapping?.[locale] || locale;\n}\n","import { shouldUseCanonicalLocale } from './customLocaleMapping';\nimport { CustomMapping } from './customLocaleMapping';\n\n/**\n * Resolves the canonical locale for a given locale.\n * @param locale - The locale to resolve the canonical locale for\n * @param customMapping - The custom mapping to use for resolving the canonical locale\n * @returns The canonical locale\n */\nexport function _resolveCanonicalLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n if (customMapping && shouldUseCanonicalLocale(locale, customMapping)) {\n return (customMapping[locale] as { code: string }).code;\n }\n\n return locale;\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { encode } from '../utils/base64';\nimport { processBatches } from './utils/batch';\n\nimport {\n FileUpload,\n UploadFilesResponse,\n RequiredUploadFilesOptions,\n} from '../types-dir/api/uploadFiles';\n\n/**\n * @internal\n * Uploads source files to the General Translation API in batches.\n * @param files - The files to upload\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns Promise resolving to a BatchList with all uploaded files\n */\nexport default async function _uploadSourceFiles(\n files: { source: FileUpload }[],\n options: RequiredUploadFilesOptions,\n config: TranslationRequestConfig\n) {\n return processBatches(\n files,\n async (batch) => {\n const body = {\n data: batch.map(({ source }) => ({\n source: {\n content: encode(source.content),\n fileName: source.fileName,\n fileFormat: source.fileFormat,\n locale: source.locale,\n dataFormat: source.dataFormat,\n formatMetadata: source.formatMetadata,\n fileId: source.fileId,\n versionId: source.versionId,\n branchId: source.branchId,\n incomingBranchId: source.incomingBranchId,\n checkedOutBranchId: source.checkedOutBranchId,\n },\n })),\n sourceLocale: options.sourceLocale,\n };\n\n const result = await apiRequest<UploadFilesResponse>(\n config,\n '/v2/project/files/upload-files',\n { body, timeout: options.timeout }\n );\n\n return result.uploadedFiles || [];\n },\n { batchSize: 100 }\n );\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { processBatches } from './utils/batch';\n\nimport {\n FileUpload,\n UploadFilesResponse,\n RequiredUploadFilesOptions,\n} from '../types-dir/api/uploadFiles';\nimport { encode } from '../utils/base64';\nimport { validateFileFormatTransforms } from './utils/validateFileFormatTransform';\n\n/**\n * @internal\n * Uploads multiple translations to the General Translation API in batches.\n * @param files - Translations to upload with their source\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns Promise resolving to a BatchList with all uploaded files\n */\nexport default async function _uploadTranslations(\n files: {\n source: FileUpload;\n translations: FileUpload[];\n }[],\n options: RequiredUploadFilesOptions,\n config: TranslationRequestConfig\n) {\n validateFileFormatTransforms(files.map(({ source }) => source));\n\n return processBatches(\n files,\n async (batch) => {\n const body = {\n data: batch.map(({ source, translations }) => ({\n source: {\n content: encode(source.content),\n fileName: source.fileName,\n fileFormat: source.fileFormat,\n transformFormat: source.transformFormat,\n locale: source.locale,\n dataFormat: source.dataFormat,\n formatMetadata: source.formatMetadata,\n fileId: source.fileId,\n versionId: source.versionId,\n branchId: source.branchId,\n },\n translations: translations.map((t) => ({\n content: encode(t.content),\n fileName: t.fileName,\n fileFormat: t.fileFormat,\n locale: t.locale,\n dataFormat: t.dataFormat,\n fileId: t.fileId,\n versionId: t.versionId,\n branchId: t.branchId,\n })),\n })),\n sourceLocale: options.sourceLocale,\n };\n\n const result = await apiRequest<UploadFilesResponse>(\n config,\n '/v2/project/files/upload-translations',\n { body, timeout: options.timeout }\n );\n\n return result.uploadedFiles || [];\n },\n { batchSize: 100 }\n );\n}\n","import { TranslationRequestConfig } from '../types';\nimport {\n CheckFileTranslationsOptions,\n FileQueryResult,\n} from '../types-dir/api/checkFileTranslations';\nimport { FileQuery } from '../types-dir/api/checkFileTranslations';\nimport apiRequest from './utils/apiRequest';\n\n/**\n * @internal\n * Gets the source file and translation information for a given file ID and version ID.\n * @param query - The file ID and version ID to get the source file and translation information for\n * @param options - The options for the API call\n * @param config - The configuration for the request\n * @returns The source file and translation information for the given file ID and version ID\n */\nexport default async function _querySourceFile(\n query: FileQuery,\n options: CheckFileTranslationsOptions,\n config: TranslationRequestConfig\n): Promise<FileQueryResult> {\n const branchId = query.branchId;\n const versionId = query.versionId;\n const fileId = query.fileId;\n\n const searchParams = new URLSearchParams();\n if (branchId) {\n searchParams.set('branchId', branchId);\n }\n if (versionId) {\n searchParams.set('versionId', versionId);\n }\n const endpoint = `/v2/project/translations/files/status/${encodeURIComponent(fileId)}?${searchParams.toString()}`;\n\n return apiRequest<FileQueryResult>(config, endpoint, {\n method: 'GET',\n timeout: options.timeout,\n });\n}\n","import { defaultBaseUrl } from '../settings/settingsUrls';\nimport fetchWithTimeout from '../translate/utils/fetchWithTimeout';\nimport { defaultTimeout } from '../settings/settings';\nimport validateResponse from '../translate/utils/validateResponse';\nimport handleFetchError from '../translate/utils/handleFetchError';\nimport { TranslationRequestConfig } from '../types';\nimport generateRequestHeaders from '../translate/utils/generateRequestHeaders';\nimport { ProjectData } from '../types-dir/api/project';\n\n/**\n * @internal\n * Gets the project data for a given project ID.\n * @param projectId - The project ID to get the project data for\n * @param options - The options for the API call\n * @param config - The configuration for the request\n * @returns The project data for the given project ID\n */\nexport default async function _getProjectData(\n projectId: string,\n options: { timeout?: number },\n config: TranslationRequestConfig\n): Promise<ProjectData> {\n const { baseUrl } = config;\n const timeout = options.timeout ? options.timeout : defaultTimeout;\n const url = `${baseUrl || defaultBaseUrl}/v2/project/info/${encodeURIComponent(projectId)}`;\n\n // Get the project data\n let response;\n try {\n response = await fetchWithTimeout(\n url,\n {\n method: 'GET',\n headers: generateRequestHeaders(config),\n },\n timeout\n );\n } catch (error) {\n handleFetchError(error, timeout);\n }\n\n // Validate the response\n await validateResponse(response);\n\n const result = await response.json();\n return result as ProjectData;\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type JobStatus =\n | 'queued'\n | 'processing'\n | 'completed'\n | 'failed'\n | 'unknown';\n\nexport type CheckJobStatusResult = {\n jobId: string;\n status: JobStatus;\n error?: { message: string };\n}[];\n\n/**\n * @internal\n * Queries job statuses for a project\n * @param jobIds - Job IDs\n * @param config - The configuration for the API call\n * @param timeoutMS - The timeout in milliseconds\n * @returns The result of the API call\n */\nexport async function _checkJobStatus(\n jobIds: string[],\n config: TranslationRequestConfig,\n timeoutMs?: number\n): Promise<CheckJobStatusResult> {\n return apiRequest<CheckJobStatusResult>(config, '/v2/project/jobs/info', {\n body: { jobIds },\n timeout: timeoutMs,\n });\n}\n","import { EnqueueFilesResult } from '../types-dir/api/enqueueFiles';\nimport { TranslationRequestConfig } from '../types';\nimport { _checkJobStatus, JobStatus } from './checkJobStatus';\n\nexport type AwaitJobsOptions = {\n /** Polling interval in seconds. Defaults to 5. */\n pollingIntervalSeconds?: number;\n /** Timeout in seconds. Defaults to 600 (10 minutes). If reached, resolves with whatever status is current. */\n timeoutSeconds?: number;\n};\n\nexport type JobResult = {\n jobId: string;\n status: JobStatus;\n error?: { message: string };\n};\n\nexport type AwaitJobsResult = {\n /** Whether all jobs completed (none still in progress). */\n complete: boolean;\n jobs: JobResult[];\n};\n\n/**\n * @internal\n * Polls job statuses until all jobs are finished or the timeout is reached.\n * @param enqueueResult - The result from enqueueFiles\n * @param options - Polling configuration\n * @param config - API credentials and configuration\n * @returns The final status of all jobs\n */\nexport default async function _awaitJobs(\n enqueueResult: EnqueueFilesResult,\n options: AwaitJobsOptions | undefined,\n config: TranslationRequestConfig\n): Promise<AwaitJobsResult> {\n const pollingInterval = (options?.pollingIntervalSeconds ?? 5) * 1000;\n const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes\n const timeout =\n options?.timeoutSeconds !== undefined\n ? options.timeoutSeconds * 1000\n : DEFAULT_TIMEOUT_MS;\n\n const jobIds = Object.keys(enqueueResult.jobData);\n\n if (jobIds.length === 0) {\n return { complete: true, jobs: [] };\n }\n\n const startTime = Date.now();\n const finalStatuses = new Map<string, JobResult>(\n jobIds.map((id) => [id, { jobId: id, status: 'unknown' as JobStatus }])\n );\n const pendingJobIds = new Set(jobIds);\n\n while (pendingJobIds.size > 0) {\n const statuses = await _checkJobStatus(Array.from(pendingJobIds), config);\n\n for (const job of statuses) {\n if (\n job.status === 'completed' ||\n job.status === 'failed' ||\n job.status === 'unknown'\n ) {\n finalStatuses.set(job.jobId, {\n jobId: job.jobId,\n status: job.status,\n ...(job.error ? { error: job.error } : {}),\n });\n pendingJobIds.delete(job.jobId);\n } else {\n finalStatuses.set(job.jobId, {\n jobId: job.jobId,\n status: job.status,\n });\n }\n }\n\n if (pendingJobIds.size === 0) break;\n\n if (Date.now() - startTime >= timeout) break;\n\n await new Promise((resolve) => setTimeout(resolve, pollingInterval));\n }\n\n return {\n complete: pendingJobIds.size === 0,\n jobs: Array.from(finalStatuses.values()),\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport { CheckFileTranslationsOptions } from '../types-dir/api/checkFileTranslations';\nimport apiRequest from './utils/apiRequest';\n\nexport type FileDataQuery = {\n sourceFiles?: {\n fileId: string;\n versionId: string;\n branchId: string;\n }[];\n translatedFiles?: {\n fileId: string;\n versionId: string;\n branchId: string;\n locale: string;\n }[];\n};\n\nexport type FileDataResult = {\n sourceFiles?: {\n branchId: string;\n fileId: string;\n versionId: string;\n fileName: string;\n fileFormat: string;\n dataFormat: string | null;\n createdAt: string;\n updatedAt: string;\n approvalRequiredAt: string | null;\n publishedAt: string | null;\n locales: string[];\n sourceLocale: string;\n }[];\n translatedFiles?: {\n branchId: string;\n fileId: string;\n versionId: string;\n fileFormat: string;\n dataFormat: string | null;\n createdAt: string;\n updatedAt: string;\n approvedAt: string | null;\n publishedAt: string | null;\n completedAt: string | null;\n locale: string;\n }[];\n};\n\n/**\n * @internal\n * Queries data about one or more source or translation files.\n * @param data - Object mapping source or translation file information\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns The file data\n */\nexport default async function _queryFileData(\n data: FileDataQuery,\n options: CheckFileTranslationsOptions = {},\n config: TranslationRequestConfig\n): Promise<FileDataResult> {\n const body = {\n sourceFiles: data.sourceFiles?.map((item) => ({\n fileId: item.fileId,\n versionId: item.versionId,\n branchId: item.branchId,\n })),\n translatedFiles: data.translatedFiles?.map((item) => ({\n fileId: item.fileId,\n versionId: item.versionId,\n branchId: item.branchId,\n locale: item.locale,\n })),\n };\n\n return apiRequest<FileDataResult>(config, '/v2/project/files/info', {\n body,\n timeout: options.timeout,\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport type { BranchDataResult } from '../types-dir/api/branch';\n\nexport type BranchQuery = {\n branchNames: string[];\n};\n\n/**\n * @internal\n * Queries branch information from the API.\n * @param query - Object mapping the current branch and incoming branches\n * @param config - The configuration for the API call\n * @returns The branch information\n */\nexport default async function _queryBranchData(\n query: BranchQuery,\n config: TranslationRequestConfig\n): Promise<BranchDataResult> {\n return apiRequest<BranchDataResult>(config, '/v2/project/branches/info', {\n body: query,\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type CreateBranchQuery = {\n branchName: string;\n defaultBranch: boolean;\n};\n\nexport type CreateBranchResult = {\n branch: { id: string; name: string };\n};\n\n/**\n * @internal\n * Creates a new branch in the API.\n * @param query - Object mapping the branch name and default branch flag\n * @param config - The configuration for the API call\n * @returns The created branch information\n */\nexport default async function _createBranch(\n query: CreateBranchQuery,\n config: TranslationRequestConfig\n): Promise<CreateBranchResult> {\n return apiRequest<CreateBranchResult>(config, '/v2/project/branches/create', {\n body: query,\n });\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { processBatches } from './utils/batch';\n\nexport type MoveMapping = {\n oldFileId: string;\n newFileId: string;\n newFileName: string;\n};\n\nexport type MoveResult = {\n oldFileId: string;\n newFileId: string;\n success: boolean;\n newSourceFileId?: string;\n clonedTranslationsCount?: number;\n error?: string;\n};\n\nexport type ProcessMovesResponse = {\n results: MoveResult[];\n summary: {\n total: number;\n succeeded: number;\n failed: number;\n };\n};\n\nexport type ProcessMovesOptions = {\n timeout?: number;\n branchId?: string;\n};\n\n/**\n * @internal\n * Processes file moves by cloning source files and translations with new fileIds.\n * Called when the CLI detects that files have been moved/renamed.\n * @param moves - Array of move mappings (old fileId to new fileId)\n * @param options - Options including branchId and timeout\n * @param config - The configuration for the API call\n * @returns Promise resolving to the move results\n */\nexport default async function _processFileMoves(\n moves: MoveMapping[],\n options: ProcessMovesOptions,\n config: TranslationRequestConfig\n): Promise<ProcessMovesResponse> {\n if (moves.length === 0) {\n return {\n results: [],\n summary: { total: 0, succeeded: 0, failed: 0 },\n };\n }\n\n const batchResult = await processBatches(\n moves,\n async (batch) => {\n const result = await apiRequest<ProcessMovesResponse>(\n config,\n '/v2/project/files/moves',\n {\n body: { branchId: options.branchId, moves: batch },\n timeout: options.timeout,\n }\n );\n return result.results;\n },\n { batchSize: 100 }\n );\n\n const succeeded = batchResult.data.filter((r) => r.success).length;\n const failed = batchResult.data.filter((r) => !r.success).length;\n\n return {\n results: batchResult.data,\n summary: {\n total: moves.length,\n succeeded,\n failed,\n },\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\nimport { createBatches } from './utils/batch';\n\nexport type OrphanedFile = {\n fileId: string;\n versionId: string;\n fileName: string;\n};\n\nexport type GetOrphanedFilesResult = {\n orphanedFiles: OrphanedFile[];\n};\n\n/**\n * @internal\n * Gets orphaned files for a branch - files that exist on the branch\n * but whose fileIds are not in the provided list.\n * Used for move detection.\n * @param branchId - The branch to check for orphaned files\n * @param fileIds - List of current file IDs (files that are NOT orphaned)\n * @param options - The options for the API call\n * @param config - The configuration for the API call\n * @returns The orphaned files\n */\nexport default async function _getOrphanedFiles(\n branchId: string,\n fileIds: string[],\n options: { timeout?: number } = {},\n config: TranslationRequestConfig\n): Promise<GetOrphanedFilesResult> {\n const makeRequest = (batchFileIds: string[]) =>\n apiRequest<GetOrphanedFilesResult>(config, '/v2/project/files/orphaned', {\n body: { branchId, fileIds: batchFileIds },\n timeout: options.timeout,\n });\n\n // If no fileIds, make a single request\n if (fileIds.length === 0) {\n return makeRequest([]);\n }\n\n // Split fileIds into batches of 100\n const batches = createBatches(fileIds, 100);\n\n // Process batches in parallel\n // Each batch returns files NOT in that batch's fileIds\n // True orphans are files that appear in ALL batch responses (intersection)\n const batchResults = await Promise.all(\n batches.map((batch) => makeRequest(batch))\n );\n\n if (batchResults.length === 1) {\n return batchResults[0];\n }\n\n // Find intersection of orphaned files across all batches\n // A file is truly orphaned only if it's not in ANY of our fileId batches\n // Start with first batch's orphans\n const orphanedFileMap = new Map<string, OrphanedFile>();\n for (const orphan of batchResults[0].orphanedFiles) {\n orphanedFileMap.set(orphan.fileId, orphan);\n }\n\n // Intersect with each subsequent batch\n for (let i = 1; i < batchResults.length; i++) {\n const batchOrphanIds = new Set(\n batchResults[i].orphanedFiles.map((f) => f.fileId)\n );\n Array.from(orphanedFileMap.keys()).forEach((fileId) => {\n if (!batchOrphanIds.has(fileId)) {\n orphanedFileMap.delete(fileId);\n }\n });\n }\n\n return {\n orphanedFiles: Array.from(orphanedFileMap.values()),\n };\n}\n","import { TranslationRequestConfig } from '../types';\nimport apiRequest from './utils/apiRequest';\n\nexport type PublishFileEntry = {\n fileId: string;\n versionId: string;\n branchId?: string;\n publish: boolean;\n fileName?: string;\n};\n\nexport type PublishFilesResult = {\n results: {\n fileId: string;\n versionId: string;\n locale?: string; // if locale is provided, it means this result is for a translation. Else it is for a source file.\n branchId: string;\n success: boolean;\n error?: string;\n }[];\n};\n\n/**\n * @internal\n * Publishes or unpublishes files on the CDN.\n * @param files - Array of file entries with publish flags\n * @param config - The configuration for the API call\n * @returns The result of the API call\n */\nexport default async function _publishFiles(\n files: PublishFileEntry[],\n config: TranslationRequestConfig\n): Promise<PublishFilesResult> {\n return await apiRequest<PublishFilesResult>(\n config,\n '/v2/project/files/publish',\n {\n body: { files },\n }\n );\n}\n","import {\n _formatCurrency,\n _formatCutoff,\n _formatDateTime,\n _formatList,\n _formatListToParts,\n _formatMessageICU,\n _formatMessageString,\n _formatNum,\n _formatRelativeTime,\n _formatRelativeTimeFromDate,\n} from './formatting/format';\nimport _requiresTranslation from './locales/requiresTranslation';\nimport _determineLocale from './locales/determineLocale';\nimport _isSameLanguage from './locales/isSameLanguage';\nimport _getLocaleProperties from './locales/getLocaleProperties';\nimport _getLocaleEmoji from './locales/getLocaleEmoji';\nimport { _isValidLocale, _standardizeLocale } from './locales/isValidLocale';\nimport { _getLocaleName } from './locales/getLocaleName';\nimport { _getLocaleDirection } from './locales/getLocaleDirection';\nimport { libraryDefaultLocale } from './settings/settings';\nimport _isSameDialect from './locales/isSameDialect';\nimport _isSupersetLocale from './locales/isSupersetLocale';\nimport { CustomMapping, FormatVariables } from './types';\nimport { _resolveAliasLocale } from './locales/resolveAliasLocale';\nimport { _resolveCanonicalLocale } from './locales/resolveCanonicalLocale';\nimport { CutoffFormatOptions } from './formatting/custom-formats/CutoffFormat/types';\nimport { StringFormat } from './types-dir/jsx/content';\n\nexport type LocaleConfigConstructorParams = {\n defaultLocale?: string;\n locales?: string[];\n customMapping?: CustomMapping;\n};\n\ntype LocalesOption = {\n locales?: string | string[];\n};\n\ntype WithLocales<T = object> = T & LocalesOption;\n\n/**\n * LocaleConfig is a client-safe locale and formatting helper.\n *\n * It intentionally does not store project IDs, API keys, runtime URLs, or any\n * translation credentials. It only stores locale metadata needed to resolve\n * aliases, choose formatting fallbacks, and format values with Intl.\n */\nexport class LocaleConfig {\n readonly defaultLocale: string;\n readonly locales: string[];\n readonly customMapping?: CustomMapping;\n\n constructor({\n defaultLocale = libraryDefaultLocale,\n locales = [],\n customMapping,\n }: LocaleConfigConstructorParams = {}) {\n this.defaultLocale = defaultLocale;\n this.locales = locales;\n this.customMapping = customMapping;\n }\n\n private get translationLocales() {\n return this.locales.length ? this.locales : undefined;\n }\n\n private resolveCanonicalLocaleList(locales: string[]) {\n return locales.map((locale) => this.resolveCanonicalLocale(locale));\n }\n\n private resolveCanonicalLocaleArgs(locales: (string | string[])[]) {\n return locales.map((locale) =>\n Array.isArray(locale)\n ? this.resolveCanonicalLocaleList(locale)\n : this.resolveCanonicalLocale(locale)\n );\n }\n\n private toLocaleList(locales: string | string[]) {\n return Array.isArray(locales) ? locales : [locales];\n }\n\n private getFormattingLocales(\n targetLocale?: string,\n locales?: string | string[]\n ) {\n const localeList =\n locales !== undefined\n ? this.toLocaleList(locales)\n : [targetLocale, this.defaultLocale, libraryDefaultLocale];\n\n return localeList\n .filter((locale): locale is string => !!locale)\n .map((locale) => this.resolveCanonicalLocale(locale));\n }\n\n formatNum(\n value: number,\n targetLocale?: string,\n options: WithLocales<Intl.NumberFormatOptions> = {}\n ) {\n const { locales, ...intlOptions } = options;\n return _formatNum({\n value,\n locales: this.getFormattingLocales(targetLocale, locales),\n options: intlOptions,\n });\n }\n\n formatDateTime(\n value: Date,\n targetLocale?: string,\n options: WithLocales<Intl.DateTimeFormatOptions> = {}\n ) {\n const { locales, ...intlOptions } = options;\n return _formatDateTime({\n value,\n locales: this.getFormattingLocales(targetLocale, locales),\n options: intlOptions,\n });\n }\n\n formatCurrency(\n value: number,\n currency: string,\n targetLocale?: string,\n options: WithLocales<Intl.NumberFormatOptions> = {}\n ) {\n const { locales, ...intlOptions } = options;\n return _formatCurrency({\n value,\n currency,\n locales: this.getFormattingLocales(targetLocale, locales),\n options: intlOptions,\n });\n }\n\n formatRelativeTime(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n targetLocale?: string,\n options: WithLocales<Intl.RelativeTimeFormatOptions> = {}\n ) {\n const { locales, ...intlOptions } = options;\n return _formatRelativeTime({\n value,\n unit,\n locales: this.getFormattingLocales(targetLocale, locales),\n options: intlOptions,\n });\n }\n\n formatRelativeTimeFromDate(\n date: Date,\n targetLocale?: string,\n options: WithLocales<\n Intl.RelativeTimeFormatOptions & { baseDate?: Date }\n > = {}\n ) {\n const { locales, baseDate, ...intlOptions } = options;\n return _formatRelativeTimeFromDate({\n date,\n baseDate: baseDate ?? new Date(),\n locales: this.getFormattingLocales(targetLocale, locales),\n options: intlOptions,\n });\n }\n\n formatCutoff(\n value: string,\n targetLocale?: string,\n options: WithLocales<CutoffFormatOptions> = {}\n ) {\n const { locales, ...formatOptions } = options;\n return _formatCutoff({\n value,\n locales: this.getFormattingLocales(targetLocale, locales),\n options: formatOptions,\n });\n }\n\n formatMessage(\n message: string,\n targetLocale?: string,\n options: WithLocales<{\n variables?: FormatVariables;\n dataFormat?: StringFormat;\n }> = {}\n ) {\n const { locales, variables, dataFormat } = options;\n if (dataFormat === 'STRING') return _formatMessageString(message);\n return _formatMessageICU(\n message,\n this.getFormattingLocales(targetLocale, locales),\n variables\n );\n }\n\n formatList(\n array: Array<string | number>,\n targetLocale?: string,\n options: WithLocales<Intl.ListFormatOptions> = {}\n ) {\n const { locales, ...intlOptions } = options;\n return _formatList({\n value: array,\n locales: this.getFormattingLocales(targetLocale, locales),\n options: intlOptions,\n });\n }\n\n formatListToParts<T>(\n array: Array<T>,\n targetLocale?: string,\n options: WithLocales<Intl.ListFormatOptions> = {}\n ) {\n const { locales, ...intlOptions } = options;\n return _formatListToParts<T>({\n value: array,\n locales: this.getFormattingLocales(targetLocale, locales),\n options: intlOptions,\n });\n }\n\n getLocaleName(locale: string) {\n return _getLocaleName(locale, this.defaultLocale, this.customMapping);\n }\n\n getLocaleEmoji(locale: string) {\n return _getLocaleEmoji(locale, this.customMapping);\n }\n\n getLocaleProperties(locale: string) {\n return _getLocaleProperties(locale, this.defaultLocale, this.customMapping);\n }\n\n requiresTranslation(\n targetLocale: string,\n sourceLocale: string = this.defaultLocale,\n approvedLocales: string[] | undefined = this.translationLocales\n ) {\n return _requiresTranslation(\n this.resolveCanonicalLocale(sourceLocale),\n this.resolveCanonicalLocale(targetLocale),\n approvedLocales\n ? this.resolveCanonicalLocaleList(approvedLocales)\n : undefined,\n this.customMapping\n );\n }\n\n determineLocale(\n locales: string | string[],\n approvedLocales: string[] = this.locales\n ) {\n const approvedLocalePairs = approvedLocales.map((locale) => ({\n locale,\n canonicalLocale: this.resolveCanonicalLocale(locale),\n }));\n const resolvedLocale = _determineLocale(\n Array.isArray(locales)\n ? this.resolveCanonicalLocaleList(locales)\n : this.resolveCanonicalLocale(locales),\n approvedLocalePairs.map(({ canonicalLocale }) => canonicalLocale),\n this.customMapping\n );\n if (!resolvedLocale) return undefined;\n return (\n approvedLocalePairs.find(\n ({ canonicalLocale }) => canonicalLocale === resolvedLocale\n )?.locale || this.resolveAliasLocale(resolvedLocale)\n );\n }\n\n getLocaleDirection(locale: string) {\n return _getLocaleDirection(this.resolveCanonicalLocale(locale));\n }\n\n isValidLocale(locale: string) {\n return _isValidLocale(locale, this.customMapping);\n }\n\n resolveCanonicalLocale(locale: string) {\n return _resolveCanonicalLocale(locale, this.customMapping);\n }\n\n resolveAliasLocale(locale: string) {\n return _resolveAliasLocale(locale, this.customMapping);\n }\n\n standardizeLocale(locale: string) {\n return _standardizeLocale(locale);\n }\n\n isSameDialect(...locales: (string | string[])[]) {\n return _isSameDialect(...this.resolveCanonicalLocaleArgs(locales));\n }\n\n isSameLanguage(...locales: (string | string[])[]) {\n return _isSameLanguage(...this.resolveCanonicalLocaleArgs(locales));\n }\n\n isSupersetLocale(superLocale: string, subLocale: string) {\n return _isSupersetLocale(\n this.resolveCanonicalLocale(superLocale),\n this.resolveCanonicalLocale(subLocale)\n );\n }\n}\n","// `generaltranslation` language toolkit\n// © 2026, General Translation, Inc.\n\n// ----- IMPORTS ----- //\n\nimport _requiresTranslation from './locales/requiresTranslation';\nimport _determineLocale from './locales/determineLocale';\nimport {\n _formatNum,\n _formatCurrency,\n _formatList,\n _formatRelativeTime,\n _formatRelativeTimeFromDate,\n _selectRelativeTimeUnit,\n _formatDateTime,\n _formatMessageICU,\n _formatListToParts,\n _formatCutoff,\n _formatMessageString,\n} from './formatting/format';\nimport {\n CustomMapping,\n FormatVariables,\n TranslateManyResult,\n TranslationError,\n TranslationRequestConfig,\n TranslationResult,\n EnqueueFilesResult,\n CheckFileTranslationsOptions,\n DownloadFileBatchOptions,\n DownloadFileBatchResult,\n DownloadFileOptions,\n TranslateManyEntry,\n} from './types';\nimport _isSameLanguage from './locales/isSameLanguage';\nimport _getLocaleProperties, {\n LocaleProperties,\n} from './locales/getLocaleProperties';\nimport _getLocaleEmoji from './locales/getLocaleEmoji';\nimport { _isValidLocale, _standardizeLocale } from './locales/isValidLocale';\nimport { _getLocaleName } from './locales/getLocaleName';\nimport { _getLocaleDirection } from './locales/getLocaleDirection';\nimport { libraryDefaultLocale } from './internal';\nimport _isSameDialect from './locales/isSameDialect';\nimport _isSupersetLocale from './locales/isSupersetLocale';\nimport {\n noSourceLocaleProvidedError,\n noTargetLocaleProvidedError,\n invalidLocaleError,\n invalidLocalesError,\n noProjectIdProvidedError,\n noApiKeyProvidedError,\n} from './logging/errors';\nimport { gtInstanceLogger } from './logging/logger';\nimport _translateMany from './translate/translateMany';\nimport _setupProject, {\n SetupProjectResult,\n SetupProjectOptions,\n} from './translate/setupProject';\nimport _enqueueFiles, { EnqueueOptions } from './translate/enqueueFiles';\nimport _createTag, {\n CreateTagOptions,\n CreateTagResult,\n} from './translate/createTag';\nimport _downloadFileBatch from './translate/downloadFileBatch';\nimport {\n FileQuery,\n FileQueryResult,\n} from './types-dir/api/checkFileTranslations';\nimport _submitUserEditDiffs, {\n SubmitUserEditDiffsPayload,\n} from './translate/submitUserEditDiffs';\nimport {\n _getRegionProperties,\n CustomRegionMapping,\n} from './locales/getRegionProperties';\nimport { _resolveAliasLocale } from './locales/resolveAliasLocale';\nimport { _resolveCanonicalLocale } from './locales/resolveCanonicalLocale';\nimport _uploadSourceFiles from './translate/uploadSourceFiles';\nimport _uploadTranslations from './translate/uploadTranslations';\nimport {\n FileUpload,\n RequiredUploadFilesOptions,\n UploadFilesOptions,\n UploadFilesResponse,\n} from './types-dir/api/uploadFiles';\nimport _querySourceFile from './translate/querySourceFile';\nimport { ProjectData } from './types-dir/api/project';\nimport _getProjectData from './projects/getProjectData';\nimport { DownloadFileBatchRequest } from './types-dir/api/downloadFileBatch';\nimport {\n _checkJobStatus,\n CheckJobStatusResult,\n} from './translate/checkJobStatus';\nimport _awaitJobs, {\n AwaitJobsOptions,\n AwaitJobsResult,\n} from './translate/awaitJobs';\nimport type { FileDataQuery, FileDataResult } from './translate/queryFileData';\nimport _queryFileData from './translate/queryFileData';\nimport type { BranchQuery } from './translate/queryBranchData';\nimport type { BranchDataResult } from './types-dir/api/branch';\nimport _queryBranchData from './translate/queryBranchData';\nimport type {\n CreateBranchQuery,\n CreateBranchResult,\n} from './translate/createBranch';\nimport _createBranch from './translate/createBranch';\nimport type { FileReference, FileReferenceIds } from './types-dir/api/file';\nimport _processFileMoves, {\n type MoveMapping,\n type ProcessMovesResponse,\n type ProcessMovesOptions,\n} from './translate/processFileMoves';\nimport _getOrphanedFiles, {\n type GetOrphanedFilesResult,\n} from './translate/getOrphanedFiles';\nimport _publishFiles, {\n type PublishFileEntry,\n type PublishFilesResult,\n} from './translate/publishFiles';\nimport { CutoffFormatOptions } from './formatting/custom-formats/CutoffFormat/types';\nimport { TranslateOptions } from './types-dir/api/entry';\nimport { API_VERSION as _API_VERSION } from './translate/api';\nimport { StringFormat } from './types-dir/jsx/content';\nimport { LocaleConfig } from './LocaleConfig';\n\nexport {\n LocaleConfig,\n type LocaleConfigConstructorParams,\n} from './LocaleConfig';\n\n// ============================================================ //\n// Core Class //\n// ============================================================ //\n/**\n * Type representing the constructor parameters for the GT class.\n * @typedef {Object} GTConstructorParams\n * @property {string} [apiKey] - The API key for accessing the translation service\n * @property {string} [devApiKey] - The development API key for accessing the translation service\n * @property {string} [sourceLocale] - The default source locale for translations\n * @property {string} [targetLocale] - The default target locale for translations\n * @property {string[]} [locales] - Array of supported locales\n * @property {string} [projectId] - The project ID for the translation service\n * @property {string} [baseUrl] - The base URL for the translation service\n * @property {CustomMapping} [customMapping] - Custom mapping of locale codes to their names\n */\ntype GTConstructorParams = {\n apiKey?: string;\n devApiKey?: string;\n sourceLocale?: string;\n targetLocale?: string;\n locales?: string[];\n projectId?: string;\n baseUrl?: string;\n customMapping?: CustomMapping;\n};\n\n/**\n * GT is the core driver for the General Translation library.\n * This class provides functionality for locale management, formatting, and translation operations.\n *\n * @class GT\n * @description A comprehensive toolkit for handling internationalization and localization.\n *\n * @example\n * const gt = new GT({\n * sourceLocale: 'en-US',\n * targetLocale: 'es-ES',\n * locales: ['en-US', 'es-ES', 'fr-FR']\n * });\n */\nexport class GT {\n /** Base URL for the translation service API */\n baseUrl?: string;\n\n /** Project ID for the translation service */\n projectId?: string;\n\n /** API key for accessing the translation service */\n apiKey?: string;\n\n /** Development API key for accessing the translation service */\n devApiKey?: string;\n\n /** Source locale for translations */\n sourceLocale?: string;\n\n /** Target locale for translations */\n targetLocale?: string;\n\n /** Array of supported locales */\n locales?: string[];\n\n /** Custom mapping for locale codes to their names */\n customMapping?: CustomMapping;\n\n /** Lazily derived reverse custom mapping for alias locales */\n reverseCustomMapping?: Record<string, string>;\n\n /** Lazily derived custom mapping for regions */\n customRegionMapping?: CustomRegionMapping;\n\n /** Client-safe locale and formatting helpers (backing field) */\n private _localeConfig!: LocaleConfig;\n\n /** Client-safe locale and formatting helpers */\n get localeConfig() {\n return this._localeConfig;\n }\n\n /**\n * Constructs an instance of the GT class.\n *\n * @param {GTConstructorParams} [params] - The parameters for initializing the GT instance\n * @throws {Error} If an invalid locale is provided\n * @throws {Error} If any of the provided locales are invalid\n *\n * @example\n * const gt = new GT({\n * apiKey: 'your-api-key',\n * sourceLocale: 'en-US',\n * targetLocale: 'es-ES',\n * locales: ['en-US', 'es-ES', 'fr-FR']\n * });\n */\n constructor(params: GTConstructorParams = {}) {\n // Read environment\n if (typeof process !== 'undefined') {\n this.apiKey ||= process.env?.GT_API_KEY;\n this.devApiKey ||= process.env?.GT_DEV_API_KEY;\n this.projectId ||= process.env?.GT_PROJECT_ID;\n }\n // Set up config\n this.setConfig(params);\n }\n\n setConfig({\n apiKey,\n devApiKey,\n sourceLocale,\n targetLocale,\n locales,\n projectId,\n customMapping,\n baseUrl,\n }: GTConstructorParams) {\n // ----- Environment properties ----- //\n if (apiKey) this.apiKey = apiKey;\n if (devApiKey) this.devApiKey = devApiKey;\n if (projectId) this.projectId = projectId;\n\n // ----- Standardize locales ----- //\n\n // source locale\n if (sourceLocale) {\n this.sourceLocale = _standardizeLocale(sourceLocale);\n if (!_isValidLocale(this.sourceLocale, customMapping))\n throw new Error(invalidLocaleError(this.sourceLocale));\n }\n\n // target locale\n if (targetLocale) {\n this.targetLocale = _standardizeLocale(targetLocale);\n if (!_isValidLocale(this.targetLocale, customMapping))\n throw new Error(invalidLocaleError(this.targetLocale));\n }\n\n // locales\n if (locales) {\n const result: string[] = [];\n const invalidLocales: string[] = [];\n locales.forEach((locale) => {\n const standardizedLocale = _standardizeLocale(locale);\n if (_isValidLocale(standardizedLocale)) {\n result.push(standardizedLocale);\n } else {\n invalidLocales.push(locale);\n }\n });\n if (invalidLocales.length > 0) {\n throw new Error(invalidLocalesError(invalidLocales));\n }\n this.locales = result;\n }\n\n // ----- Other properties ----- //\n if (baseUrl) this.baseUrl = baseUrl;\n if (customMapping) {\n this.customMapping = customMapping;\n this.reverseCustomMapping = Object.fromEntries(\n Object.entries(customMapping)\n .filter(\n ([, value]) => value && typeof value === 'object' && 'code' in value\n )\n .map(([key, value]) => [(value as { code: string }).code, key])\n );\n }\n this._localeConfig = new LocaleConfig({\n defaultLocale: this.sourceLocale,\n locales: this.locales ?? [],\n customMapping: this.customMapping,\n });\n }\n\n // -------------- Private Methods -------------- //\n\n private _getTranslationConfig(): TranslationRequestConfig {\n return {\n baseUrl: this.baseUrl,\n apiKey: this.apiKey || this.devApiKey,\n projectId: this.projectId || '',\n };\n }\n\n private _validateAuth(functionName: string) {\n const errors: string[] = [];\n if (!this.apiKey && !this.devApiKey) {\n const error = noApiKeyProvidedError(functionName);\n errors.push(error);\n }\n if (!this.projectId) {\n const error = noProjectIdProvidedError(functionName);\n errors.push(error);\n }\n if (errors.length) {\n throw new Error(errors.join('\\n'));\n }\n }\n\n // -------------- Branch Methods -------------- //\n\n /**\n * Queries branch information from the API.\n *\n * @param {BranchQuery} query - Object mapping the current branch and incoming branches\n * @returns {Promise<BranchDataResult>} The branch information\n */\n async queryBranchData(query: BranchQuery): Promise<BranchDataResult> {\n this._validateAuth('queryBranchData');\n return await _queryBranchData(query, this._getTranslationConfig());\n }\n\n /**\n * Creates a new branch in the API. If the branch already exists, it will be returned.\n *\n * @param {CreateBranchQuery} query - Object mapping the branch name and default branch flag\n * @returns {Promise<CreateBranchResult>} The created branch information\n */\n async createBranch(query: CreateBranchQuery): Promise<CreateBranchResult> {\n this._validateAuth('createBranch');\n return await _createBranch(query, this._getTranslationConfig());\n }\n\n /**\n * Processes file moves by cloning source files and translations with new fileIds.\n * This is called when files have been moved/renamed and we want to preserve translations.\n *\n * @param {MoveMapping[]} moves - Array of move mappings (old fileId to new fileId)\n * @param {ProcessMovesOptions} options - Options including branchId and timeout\n * @returns {Promise<ProcessMovesResponse>} The move processing results\n *\n * @example\n * const result = await gt.processFileMoves([\n * { oldFileId: 'abc123', newFileId: 'def456', newFileName: 'locales/en.json' }\n * ], { branchId: 'main' });\n */\n async processFileMoves(\n moves: MoveMapping[],\n options: ProcessMovesOptions = {}\n ): Promise<ProcessMovesResponse> {\n this._validateAuth('processFileMoves');\n return await _processFileMoves(\n moves,\n options,\n this._getTranslationConfig()\n );\n }\n\n /**\n * Gets orphaned files for a branch - files that exist on the branch\n * but whose fileIds are not in the provided list.\n * Used for move detection.\n *\n * @param {string} branchId - The branch to check for orphaned files\n * @param {string[]} fileIds - List of current file IDs (files that are NOT orphaned)\n * @param {Object} options - Options including timeout\n * @returns {Promise<GetOrphanedFilesResult>} The orphaned files\n *\n * @example\n * const result = await gt.getOrphanedFiles('branch-id', ['file-1', 'file-2']);\n */\n async getOrphanedFiles(\n branchId: string,\n fileIds: string[],\n options: { timeout?: number } = {}\n ): Promise<GetOrphanedFilesResult> {\n this._validateAuth('getOrphanedFiles');\n return await _getOrphanedFiles(\n branchId,\n fileIds,\n options,\n this._getTranslationConfig()\n );\n }\n\n // -------------- Translation Methods -------------- //\n\n /**\n * Enqueues project setup job using the specified file references\n *\n * This method creates setup jobs that will process source file references\n * and generate a project setup. The files parameter contains references (IDs) to source\n * files that have already been uploaded via uploadSourceFiles. The setup jobs are queued\n * for processing and will generate a project setup based on the source files.\n *\n * @param {FileReference[]} files - Array of file references containing IDs of previously uploaded source files\n * @param {SetupProjectOptions} [options] - Optional settings for target locales and timeout\n * @returns {Promise<SetupProjectResult>} Object containing the jobId and status\n */\n async setupProject(\n files: FileReference[],\n options?: SetupProjectOptions\n ): Promise<SetupProjectResult> {\n this._validateAuth('setupProject');\n options = {\n ...options,\n locales: options?.locales?.map((locale) =>\n this.resolveCanonicalLocale(locale)\n ),\n };\n return await _setupProject(files, this._getTranslationConfig(), options);\n }\n\n /**\n * Checks the current status of one or more project jobs by their unique identifiers.\n *\n * This method polls the API to determine whether one or more jobs are still running,\n * have completed successfully, or have failed. Jobs are created after calling either enqueueFiles or setupProject.\n *\n * @param {string[]} jobIds - The unique identifiers of the jobs to check\n * @param {number} [timeoutMs] - Optional timeout in milliseconds for the API request\n * @returns {Promise<CheckJobStatusResult>} Object containing the job status\n *\n * @example\n * const result = await gt.checkJobStatus([\n * 'job-123',\n * 'job-456',\n * ], {\n * timeout: 10000,\n * });\n */\n async checkJobStatus(\n jobIds: string[],\n timeoutMs?: number\n ): Promise<CheckJobStatusResult> {\n this._validateAuth('checkJobStatus');\n return await _checkJobStatus(\n jobIds,\n this._getTranslationConfig(),\n timeoutMs\n );\n }\n\n /**\n * Polls job statuses until all jobs from enqueueFiles are finished or the timeout is reached.\n *\n * @param {EnqueueFilesResult} enqueueResult - The result returned from enqueueFiles\n * @param {AwaitJobsOptions} [options] - Polling configuration (interval, timeout)\n * @returns {Promise<AwaitJobsResult>} The final status of all jobs and whether they all completed\n */\n async awaitJobs(\n enqueueResult: EnqueueFilesResult,\n options?: AwaitJobsOptions\n ): Promise<AwaitJobsResult> {\n this._validateAuth('awaitJobs');\n return await _awaitJobs(\n enqueueResult,\n options,\n this._getTranslationConfig()\n );\n }\n\n /**\n * Enqueues translation jobs for previously uploaded source files.\n *\n * This method creates translation jobs that will process existing source files\n * and generate translations in the specified target languages. The files parameter\n * contains references (IDs) to source files that have already been uploaded via\n * uploadSourceFiles. The translation jobs are queued for processing and will\n * generate translated content based on the source files and target locales provided.\n *\n * @param {FileReferenceIds[]} files - Array of file references containing IDs of previously uploaded source files\n * @param {EnqueueOptions} options - Configuration options including source locale, target locales, and job settings\n * @returns {Promise<EnqueueFilesResult>} Result containing job IDs, queue status, and processing information\n */\n async enqueueFiles(\n files: FileReferenceIds[],\n options: EnqueueOptions\n ): Promise<EnqueueFilesResult> {\n // Validation\n this._validateAuth('enqueueFiles');\n\n // Merge instance settings with options\n let mergedOptions: EnqueueOptions = {\n ...options,\n sourceLocale: options.sourceLocale ?? this.sourceLocale!,\n targetLocales: options.targetLocales ?? [this.targetLocale!],\n };\n\n // Require source locale\n if (!mergedOptions.sourceLocale) {\n const error = noSourceLocaleProvidedError('enqueueFiles');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Require target locale(s)\n if (\n !mergedOptions.targetLocales ||\n mergedOptions.targetLocales.length === 0\n ) {\n const error = noTargetLocaleProvidedError('enqueueFiles');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Replace target locales with canonical locales\n mergedOptions = {\n ...mergedOptions,\n targetLocales: mergedOptions.targetLocales.map((locale) =>\n this.resolveCanonicalLocale(locale)\n ),\n };\n\n return await _enqueueFiles(\n files,\n mergedOptions,\n this._getTranslationConfig()\n );\n }\n\n /**\n * Creates or upserts a file tag, associating a set of source files\n * with a user-defined tag ID and optional message.\n *\n * @param {CreateTagOptions} options - Tag creation options including tagId, sourceFileIds, and optional message\n * @returns {Promise<CreateTagResult>} The created or updated tag\n */\n async createTag(options: CreateTagOptions): Promise<CreateTagResult> {\n this._validateAuth('createTag');\n return await _createTag(options, this._getTranslationConfig());\n }\n\n /**\n * Publishes or unpublishes files on the CDN.\n *\n * @param {PublishFileEntry[]} files - Array of file entries with publish flags\n * @returns {Promise<PublishFilesResult>} Result containing per-file success/failure\n */\n async publishFiles(files: PublishFileEntry[]): Promise<PublishFilesResult> {\n this._validateAuth('publishFiles');\n return await _publishFiles(files, this._getTranslationConfig());\n }\n\n /**\n * Submits user edit diffs for existing translations so future generations preserve user intent.\n *\n * @param {SubmitUserEditDiffsPayload} payload - Project-scoped diff payload.\n * @returns {Promise<void>} Resolves when submission succeeds.\n */\n async submitUserEditDiffs(\n payload: SubmitUserEditDiffsPayload\n ): Promise<void> {\n this._validateAuth('submitUserEditDiffs');\n // Normalize locales to canonical form before submission\n const normalized: SubmitUserEditDiffsPayload = {\n ...payload,\n diffs: (payload.diffs || []).map((d) => ({\n ...d,\n locale: this.resolveCanonicalLocale(d.locale),\n })),\n };\n await _submitUserEditDiffs(normalized, this._getTranslationConfig());\n }\n\n /**\n * Queries data about one or more source or translation files.\n *\n * @param {FileDataQuery} data - Object mapping source and translation file information.\n * @param {CheckFileTranslationsOptions} options - Options for the API call.\n * @returns {Promise<FileDataResult>} The source and translation file data information.\n *\n * @example\n * const result = await gt.queryFileData({\n * sourceFiles: [\n * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890' },\n * ],\n * translatedFiles: [\n * { fileId: '1234567890', versionId: '1234567890', branchId: '1234567890', locale: 'es-ES' },\n * ],\n * }, {\n * timeout: 10000,\n * });\n *\n */\n async queryFileData(\n data: FileDataQuery,\n options: CheckFileTranslationsOptions = {}\n ): Promise<FileDataResult> {\n // Validation\n this._validateAuth('queryFileData');\n\n // Replace target locales with canonical locales\n data.translatedFiles = data.translatedFiles?.map((item) => ({\n ...item,\n locale: this.resolveCanonicalLocale(item.locale),\n }));\n\n // Request the file translation status\n const result = await _queryFileData(\n data,\n options,\n this._getTranslationConfig()\n );\n\n // Resolve canonical locales\n result.translatedFiles = result.translatedFiles?.map((item) => ({\n ...item,\n ...(item.locale && { locale: this.resolveAliasLocale(item.locale) }),\n }));\n result.sourceFiles = result.sourceFiles?.map((item) => ({\n ...item,\n ...(item.sourceLocale && {\n sourceLocale: this.resolveAliasLocale(item.sourceLocale),\n }),\n locales: item.locales.map((locale) => this.resolveAliasLocale(locale)),\n }));\n return result;\n }\n\n /**\n * Gets source and translation information for a given file ID and version ID.\n *\n * @param {FileQuery} data - File query containing file ID and version ID.\n * @param {CheckFileTranslationsOptions} options - Options for getting source and translation information.\n * @returns {Promise<FileQueryResult>} The source file and translation information.\n *\n * @example\n * const result = await gt.querySourceFile(\n * { fileId: '1234567890', versionId: '1234567890' },\n * { timeout: 10000 }\n * );\n *\n */\n async querySourceFile(\n data: FileQuery,\n options: CheckFileTranslationsOptions = {}\n ): Promise<FileQueryResult> {\n // Validation\n this._validateAuth('querySourceFile');\n\n // Request the file translation status\n const result = await _querySourceFile(\n data,\n options,\n this._getTranslationConfig()\n );\n // Replace locales with canonical locales\n result.translations = result.translations.map((item) => ({\n ...item,\n ...(item.locale && { locale: this.resolveAliasLocale(item.locale) }),\n }));\n result.sourceFile.locales = result.sourceFile.locales.map((locale) =>\n this.resolveAliasLocale(locale)\n );\n if (result.sourceFile.sourceLocale) {\n result.sourceFile.sourceLocale = this.resolveAliasLocale(\n result.sourceFile.sourceLocale\n );\n }\n return result;\n }\n /**\n * Get project data for a given project ID.\n *\n * @param {string} projectId - The ID of the project to get the data for.\n * @returns {Promise<ProjectData>} The project data.\n *\n * @example\n * const result = await gt.getProjectData(\n * '1234567890'\n * );\n *\n */\n async getProjectData(\n projectId: string,\n options: { timeout?: number } = {}\n ): Promise<ProjectData> {\n // Validation\n this._validateAuth('getProjectData');\n\n // Request the file translation status\n const result = await _getProjectData(\n projectId,\n options,\n this._getTranslationConfig()\n );\n // Replace locales with canonical locales\n result.currentLocales = result.currentLocales.map((item) =>\n this.resolveAliasLocale(item)\n );\n result.defaultLocale = this.resolveAliasLocale(result.defaultLocale);\n return result;\n }\n\n /**\n * Downloads a single file.\n *\n * @param file - The file query object.\n * @param {string} file.fileId - The ID of the file to download.\n * @param {string} [file.branchId] - The ID of the branch to download the file from. If not provided, the default branch will be used.\n * @param {string} [file.locale] - The locale to download the file for. If not provided, the source file will be downloaded.\n * @param {string} [file.versionId] - The version ID to download the file from. If not provided, the latest version will be used.\n * @param {DownloadFileOptions} options - Options for downloading the file.\n * @returns {Promise<string>} The downloaded file content.\n *\n * @example\n * const result = await gt.downloadFile({\n * fileId: '1234567890',\n * branchId: '1234567890',\n * locale: 'es-ES',\n * versionId: '1234567890',\n * }, {\n * timeout: 10000,\n * });\n */\n async downloadFile(\n file: {\n fileId: string;\n branchId?: string;\n locale?: string;\n versionId?: string;\n useLatestAvailableVersion?: boolean;\n },\n options: DownloadFileOptions = {}\n ): Promise<string> {\n // Validation\n this._validateAuth('downloadTranslatedFile');\n\n const result = await _downloadFileBatch(\n [\n {\n fileId: file.fileId,\n branchId: file.branchId,\n locale: file.locale\n ? this.resolveCanonicalLocale(file.locale)\n : undefined,\n versionId: file.versionId,\n useLatestAvailableVersion: file.useLatestAvailableVersion,\n },\n ],\n options,\n this._getTranslationConfig()\n );\n return result.data?.[0]?.data ?? '';\n }\n\n /**\n * Downloads multiple files in a batch.\n *\n * @param {DownloadFileBatchRequest} requests - Array of file query objects to download.\n * @param {DownloadFileBatchOptions} options - Options for the batch download.\n * @returns {Promise<DownloadFileBatchResult>} The batch download results.\n *\n * @example\n * const result = await gt.downloadFileBatch([{\n * fileId: '1234567890',\n * locale: 'es-ES',\n * versionId: '1234567890',\n * }], {\n * timeout: 10000,\n * });\n */\n async downloadFileBatch(\n requests: DownloadFileBatchRequest,\n options: DownloadFileBatchOptions = {}\n ): Promise<DownloadFileBatchResult> {\n // Validation\n this._validateAuth('downloadFileBatch');\n\n requests = requests.map((request) => ({\n ...request,\n locale: request.locale\n ? this.resolveCanonicalLocale(request.locale)\n : undefined,\n }));\n\n // Request the batch download\n const result = await _downloadFileBatch(\n requests,\n options,\n this._getTranslationConfig()\n );\n\n return {\n files: result.data.map((file) => ({\n ...file,\n ...(file.locale && {\n locale: this.resolveAliasLocale(file.locale),\n }),\n })),\n count: result.count,\n };\n }\n\n /**\n * Translates a single source string to the target locale.\n * Routes through {@link translateMany} under the hood.\n *\n * @param {string} source - The source string to translate.\n * @param {object} options - Translation options including targetLocale and optional entry metadata.\n * @returns {Promise<TranslationResult | TranslationError>} The translated content.\n *\n * @example\n * const result = await gt.translate('Hello, world!', { targetLocale: 'es' });\n *\n * @example\n * const result = await gt.translate('Hello, world!', {\n * targetLocale: 'es',\n * dataFormat: 'ICU',\n * context: 'A formal greeting',\n * });\n */\n async translate(\n source: TranslateManyEntry,\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<TranslationResult | TranslationError> {\n // Normalize string shorthand to options object\n if (typeof options === 'string') {\n options = { targetLocale: options };\n }\n\n // Validation\n this._validateAuth('translate');\n\n // Require target locale\n let targetLocale = options?.targetLocale || this.targetLocale;\n if (!targetLocale) {\n const error = noTargetLocaleProvidedError('translate');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Replace target locale with canonical locale\n targetLocale = this.resolveCanonicalLocale(targetLocale);\n\n const sourceLocale = this.resolveCanonicalLocale(\n options?.sourceLocale || this.sourceLocale || libraryDefaultLocale\n );\n\n // Request the translation\n const results = await _translateMany(\n [source],\n {\n ...options,\n targetLocale,\n sourceLocale,\n },\n this._getTranslationConfig(),\n timeout\n );\n return results[0];\n }\n\n /**\n * Translates multiple source strings to the target locale.\n * Each entry can be a plain string or an object with source and metadata fields.\n *\n * @param {TranslateManyEntry[] | Record<string, TranslateManyEntry>} sources - The source entries to translate. Can be an array or a record keyed by hash.\n * @param {object} options - Translation options including targetLocale.\n * @returns {Promise<TranslateManyResult | Record<string, TranslationResult>>} The translated contents. An array if sources was an array, a record if sources was a record.\n *\n * @example\n * const result = await gt.translateMany(\n * ['Hello, world!', 'Goodbye, world!'],\n * { targetLocale: 'es' }\n * );\n *\n * @example\n * const result = await gt.translateMany(\n * [{ source: 'Hello, world!', dataFormat: 'ICU' }],\n * { targetLocale: 'es' }\n * );\n *\n * @example\n * const result = await gt.translateMany(\n * { 'my-hash': 'Hello, world!' },\n * { targetLocale: 'es' }\n * );\n */\n async translateMany(\n sources: TranslateManyEntry[],\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<TranslateManyResult>;\n async translateMany(\n sources: Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<Record<string, TranslationResult>>;\n async translateMany(\n sources: TranslateManyEntry[] | Record<string, TranslateManyEntry>,\n options: string | TranslateOptions,\n timeout?: number\n ): Promise<TranslateManyResult | Record<string, TranslationResult>> {\n // Normalize string shorthand to options object\n if (typeof options === 'string') {\n options = { targetLocale: options };\n }\n\n // Validation\n this._validateAuth('translateMany');\n\n // Require target locale\n let targetLocale = options?.targetLocale || this.targetLocale;\n if (!targetLocale) {\n const error = noTargetLocaleProvidedError('translateMany');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Replace target locale with canonical locale\n targetLocale = this.resolveCanonicalLocale(targetLocale);\n\n const sourceLocale = this.resolveCanonicalLocale(\n options?.sourceLocale || this.sourceLocale || libraryDefaultLocale\n );\n\n // Request the translation\n return await _translateMany(\n sources,\n {\n ...options,\n targetLocale,\n sourceLocale,\n },\n this._getTranslationConfig(),\n timeout\n );\n }\n\n /**\n * Uploads source files to the translation service without any translation content.\n *\n * This method creates or replaces source file entries in your project. Each uploaded\n * file becomes a source that can later be translated into target languages. The files\n * are processed and stored as base entries that serve as the foundation for generating\n * translations through the translation workflow.\n *\n * @param {Array<{source: FileUpload}>} files - Array of objects containing source file data to upload\n * @param {UploadFilesOptions} options - Configuration options including source locale and other upload settings\n * @returns {Promise<UploadFilesResponse>} Upload result containing file IDs, version information, and upload status\n */\n async uploadSourceFiles(\n files: { source: FileUpload }[],\n options: UploadFilesOptions\n ): Promise<UploadFilesResponse> {\n // Validation\n this._validateAuth('uploadSourceFiles');\n\n // Merge instance settings with options\n const mergedOptions: UploadFilesOptions = {\n ...options,\n sourceLocale: this.resolveCanonicalLocale(\n options.sourceLocale ?? this.sourceLocale ?? libraryDefaultLocale\n ),\n };\n\n // resolve canonical locales\n files = files.map((f) => ({\n ...f,\n source: {\n ...f.source,\n locale: this.resolveCanonicalLocale(f.source.locale),\n },\n }));\n\n // Process files in batches and convert result to UploadFilesResponse\n const result = await _uploadSourceFiles(\n files,\n mergedOptions as RequiredUploadFilesOptions,\n this._getTranslationConfig()\n );\n\n return {\n uploadedFiles: result.data,\n count: result.count,\n message: `Successfully uploaded ${result.count} files in ${result.batchCount} batch(es)`,\n };\n }\n\n /**\n * Uploads translation files that correspond to previously uploaded source files.\n *\n * This method allows you to provide translated content for existing source files in your project.\n * Each translation must reference an existing source file and include the translated content\n * along with the target locale information. This is used when you have pre-existing translations\n * that you want to upload directly rather than generating them through the translation service.\n *\n * @param {Array<{source: FileUpload, translations: FileUpload[]}>} files - Array of file objects where:\n * - `source`: Reference to the existing source file (contains IDs but no content)\n * - `translations`: Array of translated files, each containing content, locale, and reference IDs\n * @param {UploadFilesOptions} options - Configuration options including source locale and upload settings\n * @returns {Promise<UploadFilesResponse>} Upload result containing translation IDs, status, and processing information\n */\n async uploadTranslations(\n files: {\n source: FileUpload; // reference only (no content)\n translations: FileUpload[]; // each has content + ids + locale\n }[],\n options: UploadFilesOptions\n ): Promise<UploadFilesResponse> {\n // Validation\n this._validateAuth('uploadTranslations');\n\n // Merge instance settings with options\n const mergedOptions: UploadFilesOptions = {\n ...options,\n sourceLocale: options.sourceLocale ?? this.sourceLocale,\n };\n\n // Require source locale\n if (!mergedOptions.sourceLocale) {\n const error = noSourceLocaleProvidedError('uploadTranslations');\n gtInstanceLogger.error(error);\n throw new Error(error);\n }\n\n // Ensure all translation locales use canonical locales\n const targetFiles = files.map((f) => ({\n ...f,\n translations: f.translations.map((t) => ({\n ...t,\n locale: this.resolveCanonicalLocale(t.locale),\n })),\n }));\n\n // Process files in batches and convert result to UploadFilesResponse\n const result = await _uploadTranslations(\n targetFiles,\n mergedOptions as RequiredUploadFilesOptions,\n this._getTranslationConfig()\n );\n\n return {\n uploadedFiles: result.data,\n count: result.count,\n message: `Successfully uploaded ${result.count} files in ${result.batchCount} batch(es)`,\n };\n }\n\n // -------------- Formatting -------------- //\n\n /**\n * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.\n *\n * This method uses the GT instance's rendering locales by default for locale-specific terminator selection,\n * but can be overridden with custom locales in the options.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @param {Object} [options] - Configuration options for cutoff formatting.\n * @param {string | string[]} [options.locales] - The locales to use for terminator selection. Defaults to instance's rendering locales.\n * @param {number} [options.maxChars] - The maximum number of characters to display.\n * - Undefined values are treated as no cutoff.\n * - Negative values follow .slice() behavior and terminator will be added before the value.\n * - 0 will result in an empty string.\n * - If cutoff results in an empty string, no terminator is added.\n * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.\n * @param {string} [options.terminator] - Optional override the terminator to use.\n * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.\n * - If no terminator is provided, then separator is ignored.\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n *\n * @example\n * const gt = new GT({ targetLocale: 'en-US' });\n * gt.formatCutoff('Hello, world!', { maxChars: 8 });\n * // Returns: 'Hello, w...'\n *\n * @example\n * gt.formatCutoff('Hello, world!', { maxChars: -3 });\n * // Returns: '...ld!'\n */\n formatCutoff(\n value: string,\n options?: {\n locales?: string | string[];\n } & CutoffFormatOptions\n ): string {\n return this.localeConfig.formatCutoff(value, this.targetLocale, options);\n }\n\n /**\n * Formats a message according to the specified locales and options.\n *\n * @param {string} message - The message to format.\n * @param {string | string[]} [locales='en'] - The locales to use for formatting.\n * @param {FormatVariables} [variables={}] - The variables to use for formatting.\n * @param {StringFormat} [dataFormat='ICU'] - The format of the message.\n * @returns {string} The formatted message.\n *\n * @example\n * gt.formatMessage('Hello {name}', { name: 'John' });\n * // Returns: \"Hello John\"\n *\n * gt.formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });\n * // Returns: \"Bonjour John\"\n */\n formatMessage(\n message: string,\n options?: {\n locales?: string | string[];\n variables?: FormatVariables;\n dataFormat?: StringFormat;\n }\n ): string {\n return this.localeConfig.formatMessage(message, this.targetLocale, options);\n }\n /**\n * Formats a number according to the specified locales and options.\n *\n * @param {number} number - The number to format\n * @param {Object} [options] - Additional options for number formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options\n * @returns {string} The formatted number\n *\n * @example\n * gt.formatNum(1234.56, { style: 'currency', currency: 'USD' });\n * // Returns: \"$1,234.56\"\n */\n formatNum(\n number: number,\n options?: {\n locales?: string | string[];\n } & Intl.NumberFormatOptions\n ): string {\n return this.localeConfig.formatNum(number, this.targetLocale, options);\n }\n\n /**\n * Formats a date according to the specified locales and options.\n *\n * @param {Date} date - The date to format\n * @param {Object} [options] - Additional options for date formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.DateTimeFormatOptions} [options] - Additional Intl.DateTimeFormat options\n * @returns {string} The formatted date\n *\n * @example\n * gt.formatDateTime(new Date(), { dateStyle: 'full', timeStyle: 'long' });\n * // Returns: \"Thursday, March 14, 2024 at 2:30:45 PM GMT-7\"\n */\n formatDateTime(\n date: Date,\n options?: {\n locales?: string | string[];\n } & Intl.DateTimeFormatOptions\n ): string {\n return this.localeConfig.formatDateTime(date, this.targetLocale, options);\n }\n\n /**\n * Formats a currency value according to the specified locales and options.\n *\n * @param {number} value - The currency value to format\n * @param {string} currency - The currency code (e.g., 'USD', 'EUR')\n * @param {Object} [options] - Additional options for currency formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.NumberFormatOptions} [options] - Additional Intl.NumberFormat options\n * @returns {string} The formatted currency value\n *\n * @example\n * gt.formatCurrency(1234.56, 'USD', { style: 'currency' });\n * // Returns: \"$1,234.56\"\n */\n formatCurrency(\n value: number,\n currency: string,\n options?: {\n locales?: string | string[];\n } & Intl.NumberFormatOptions\n ): string {\n return this.localeConfig.formatCurrency(\n value,\n currency,\n this.targetLocale,\n options\n );\n }\n\n /**\n * Formats a list of items according to the specified locales and options.\n *\n * @param {Array<string | number>} array - The list of items to format\n * @param {Object} [options] - Additional options for list formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options\n * @returns {string} The formatted list\n *\n * @example\n * gt.formatList(['apple', 'banana', 'orange'], { type: 'conjunction' });\n * // Returns: \"apple, banana, and orange\"\n */\n formatList(\n array: Array<string | number>,\n options?: {\n locales?: string | string[];\n } & Intl.ListFormatOptions\n ) {\n return this.localeConfig.formatList(array, this.targetLocale, options);\n }\n\n /**\n * Formats a list of items according to the specified locales and options.\n * @param {Array<T>} array - The list of items to format\n * @param {Object} [options] - Additional options for list formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options\n * @returns {Array<T | string>} The formatted list parts\n *\n * @example\n * gt.formatListToParts(['apple', 42, { foo: 'bar' }], { type: 'conjunction', style: 'short', locales: ['en'] });\n * // Returns: ['apple', ', ', 42, ' and ', '{ foo: \"bar\" }']\n */\n formatListToParts<T>(\n array: Array<T>,\n options?: {\n locales?: string | string[];\n } & Intl.ListFormatOptions\n ): Array<T | string> {\n return this.localeConfig.formatListToParts<T>(\n array,\n this.targetLocale,\n options\n );\n }\n\n /**\n * Formats a relative time value according to the specified locales and options.\n *\n * @param {number} value - The relative time value to format\n * @param {Intl.RelativeTimeFormatUnit} unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year')\n * @param {Object} options - Additional options for relative time formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options\n * @returns {string} The formatted relative time string\n *\n * @example\n * gt.formatRelativeTime(-1, 'day', { locales: ['en-US'], numeric: 'auto' });\n * // Returns: \"yesterday\"\n */\n formatRelativeTime(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n options?: {\n locales?: string | string[];\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n ): string {\n return this.localeConfig.formatRelativeTime(\n value,\n unit,\n this.targetLocale,\n options\n );\n }\n\n /**\n * Formats a relative time string from a Date, automatically selecting the best unit.\n *\n * @param {Date} date - The date to format relative to now\n * @param {Object} [options] - Additional options for relative time formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @returns {string} The formatted relative time string (e.g., \"2 hours ago\", \"in 3 days\")\n *\n * @example\n * gt.formatRelativeTimeFromDate(new Date(Date.now() - 3600000));\n * // Returns: \"1 hour ago\"\n */\n formatRelativeTimeFromDate(\n date: Date,\n options?: {\n locales?: string | string[];\n baseDate?: Date;\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n ): string {\n return this.localeConfig.formatRelativeTimeFromDate(\n date,\n this.targetLocale,\n options\n );\n }\n\n // -------------- Locale Properties -------------- //\n\n /**\n * Retrieves the display name of a locale code using Intl.DisplayNames, returning an empty string if no name is found.\n *\n * @param {string} [locale=this.targetLocale] - A BCP-47 locale code\n * @returns {string} The display name corresponding to the code\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.getLocaleName('es-ES');\n * // Returns: \"Spanish (Spain)\"\n */\n getLocaleName(locale = this.targetLocale): string {\n if (!locale) throw new Error(noTargetLocaleProvidedError('getLocaleName'));\n return this.localeConfig.getLocaleName(locale);\n }\n\n /**\n * Retrieves an emoji based on a given locale code.\n * Uses the locale's region (if present) to select an emoji or falls back on default emojis.\n *\n * @param {string} [locale=this.targetLocale] - A BCP-47 locale code (e.g., 'en-US', 'fr-CA')\n * @returns {string} The emoji representing the locale or its region\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.getLocaleEmoji('es-ES');\n * // Returns: \"🇪🇸\"\n */\n getLocaleEmoji(locale = this.targetLocale): string {\n if (!locale) throw new Error(noTargetLocaleProvidedError('getLocaleEmoji'));\n return this.localeConfig.getLocaleEmoji(locale);\n }\n\n /**\n * Generates linguistic details for a given locale code.\n *\n * This function returns information about the locale,\n * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).\n * The function provides these names in both your default language and native forms, and an associated emoji.\n *\n * @param {string} [locale=this.targetLocale] - The locale code to get properties for (e.g., \"de-AT\").\n * @returns {LocaleProperties} - An object containing detailed information about the locale.\n *\n * @property {string} code - The full locale code, e.g., \"de-AT\".\n * @property {string} name - Language name in the default display language, e.g., \"Austrian German\".\n * @property {string} nativeName - Language name in the locale's native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} languageCode - The base language code, e.g., \"de\".\n * @property {string} languageName - The language name in the default display language, e.g., \"German\".\n * @property {string} nativeLanguageName - The language name in the native language, e.g., \"Deutsch\".\n * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., \"German (AT)\".\n * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., \"Deutsch (AT)\".\n * @property {string} regionCode - The region code from maximization, e.g., \"AT\".\n * @property {string} regionName - The region name in the default display language, e.g., \"Austria\".\n * @property {string} nativeRegionName - The region name in the native language, e.g., \"Österreich\".\n * @property {string} scriptCode - The script code from maximization, e.g., \"Latn\".\n * @property {string} scriptName - The script name in the default display language, e.g., \"Latin\".\n * @property {string} nativeScriptName - The script name in the native language, e.g., \"Lateinisch\".\n * @property {string} maximizedCode - The maximized locale code, e.g., \"de-Latn-AT\".\n * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., \"Austrian German (Latin)\".\n * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., \"Österreichisches Deutsch (Lateinisch)\".\n * @property {string} minimizedCode - Minimized locale code, e.g., \"de-AT\" (or \"de\" for \"de-DE\").\n * @property {string} minimizedName - Minimized language name in the default language, e.g., \"Austrian German\".\n * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} emoji - The emoji associated with the locale's region, if applicable.\n */\n getLocaleProperties(locale = this.targetLocale): LocaleProperties {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('getLocaleProperties'));\n return this.localeConfig.getLocaleProperties(locale);\n }\n\n /**\n * Retrieves multiple properties for a given region code, including:\n * - `code`: the original region code\n * - `name`: the localized display name\n * - `emoji`: the associated flag or symbol\n *\n * Behavior:\n * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `\"US\"`, `\"FR\"`, `\"419\"`).\n * - Uses the instance's `targetLocale` to localize the region name for the user.\n * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.\n * - Otherwise, uses `Intl.DisplayNames` to get the localized region name, falling back to `libraryDefaultLocale`.\n * - Falls back to the region code as `name` if display name resolution fails.\n * - Falls back to a default emoji if no emoji mapping is found in built-in data or `customMapping`.\n *\n * @param {string} [region=this.getLocaleProperties().regionCode] - The region code to look up (e.g., `\"US\"`, `\"GB\"`, `\"DE\"`).\n * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.\n * @returns {{ code: string, name: string, emoji: string }} An object containing:\n * - `code`: the input region code\n * - `name`: the localized or custom region name\n * - `emoji`: the matching emoji flag or symbol\n *\n * @throws {Error} If no target locale is available to determine region properties.\n *\n * @example\n * const gt = new GT({ targetLocale: 'en-US' });\n * gt.getRegionProperties('US');\n * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }\n *\n * @example\n * const gt = new GT({ targetLocale: 'fr-FR' });\n * gt.getRegionProperties('US');\n * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }\n *\n * @example\n * gt.getRegionProperties('US', { US: { name: 'USA', emoji: '🗽' } });\n * // => { code: 'US', name: 'USA', emoji: '🗽' }\n */\n getRegionProperties(\n region = this.getLocaleProperties().regionCode,\n customMapping?: CustomRegionMapping\n ): { code: string; name: string; emoji: string } {\n if (!customMapping) {\n if (this.customMapping && !this.customRegionMapping) {\n // Lazy derive custom region mapping from customMapping\n const customRegionMapping: CustomRegionMapping = {};\n for (const [locale, lp] of Object.entries(this.customMapping)) {\n if (\n lp &&\n typeof lp === 'object' &&\n lp.regionCode &&\n !customRegionMapping[lp.regionCode]\n ) {\n const { regionName: name, emoji } = lp;\n customRegionMapping[lp.regionCode] = {\n locale,\n ...(name && { name }),\n ...(emoji && { emoji }),\n };\n }\n }\n this.customRegionMapping = customRegionMapping;\n }\n customMapping = this.customRegionMapping;\n }\n return _getRegionProperties(\n region,\n this.targetLocale, // this.targetLocale because we want it in the user's language\n customMapping\n );\n }\n\n /**\n * Determines whether a translation is required based on the source and target locales.\n *\n * @param {string} [sourceLocale=this.sourceLocale] - The locale code for the original content\n * @param {string} [targetLocale=this.targetLocale] - The locale code to translate into\n * @param {string[]} [approvedLocales=this.locales] - Optional array of approved target locales\n * @returns {boolean} True if translation is required, false otherwise\n * @throws {Error} If no source locale is provided\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.requiresTranslation('en-US', 'es-ES');\n * // Returns: true\n */\n requiresTranslation(\n sourceLocale = this.sourceLocale,\n targetLocale = this.targetLocale,\n approvedLocales: string[] | undefined = this.locales,\n customMapping: CustomMapping | undefined = this.customMapping\n ): boolean {\n if (!sourceLocale)\n throw new Error(noSourceLocaleProvidedError('requiresTranslation'));\n if (!targetLocale)\n throw new Error(noTargetLocaleProvidedError('requiresTranslation'));\n if (customMapping === this.customMapping) {\n return this.localeConfig.requiresTranslation(\n targetLocale,\n sourceLocale,\n approvedLocales\n );\n }\n return _requiresTranslation(\n sourceLocale,\n targetLocale,\n approvedLocales,\n customMapping\n );\n }\n\n /**\n * Determines the best matching locale from the provided approved locales list.\n *\n * @param {string | string[]} locales - A single locale or array of locales in preference order\n * @param {string[]} [approvedLocales=this.locales] - Array of approved locales in preference order\n * @returns {string | undefined} The best matching locale or undefined if no match is found\n *\n * @example\n * gt.determineLocale(['fr-CA', 'fr-FR'], ['en-US', 'fr-FR', 'es-ES']);\n * // Returns: \"fr-FR\"\n */\n determineLocale(\n locales: string | string[],\n approvedLocales: string[] | undefined = this.locales || [],\n customMapping: CustomMapping | undefined = this.customMapping\n ): string | undefined {\n if (customMapping === this.customMapping) {\n return this.localeConfig.determineLocale(locales, approvedLocales ?? []);\n }\n return _determineLocale(locales, approvedLocales, customMapping);\n }\n\n /**\n * Gets the text direction for a given locale code.\n *\n * @param {string} [locale=this.targetLocale] - A BCP-47 locale code\n * @returns {'ltr' | 'rtl'} 'rtl' if the locale is right-to-left, otherwise 'ltr'\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.getLocaleDirection('ar-SA');\n * // Returns: \"rtl\"\n */\n getLocaleDirection(locale = this.targetLocale): 'ltr' | 'rtl' {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('getLocaleDirection'));\n return this.localeConfig.getLocaleDirection(locale);\n }\n\n /**\n * Checks if a given BCP 47 locale code is valid.\n *\n * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to validate\n * @param {customMapping} [customMapping=this.customMapping] - The custom mapping to use for validation\n * @returns {boolean} True if the locale code is valid, false otherwise\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.isValidLocale('en-US');\n * // Returns: true\n */\n isValidLocale(\n locale = this.targetLocale,\n customMapping: CustomMapping | undefined = this.customMapping\n ): boolean {\n if (!locale) throw new Error(noTargetLocaleProvidedError('isValidLocale'));\n if (customMapping === this.customMapping) {\n return this.localeConfig.isValidLocale(locale);\n }\n return _isValidLocale(locale, customMapping);\n }\n\n /**\n * Resolves the canonical locale for a given locale.\n * @param locale - The locale to resolve the canonical locale for\n * @param customMapping - The custom mapping to use for resolving the canonical locale\n * @returns The canonical locale\n */\n resolveCanonicalLocale(\n locale: string | undefined = this.targetLocale,\n customMapping: CustomMapping | undefined = this.customMapping\n ): string {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('resolveCanonicalLocale'));\n if (customMapping === this.customMapping) {\n return this.localeConfig.resolveCanonicalLocale(locale);\n }\n return _resolveCanonicalLocale(locale, customMapping);\n }\n\n /**\n * Resolves the alias locale for a given locale.\n * @param locale - The locale to resolve the alias locale for\n * @param customMapping - The custom mapping to use for resolving the alias locale\n * @returns The alias locale\n */\n resolveAliasLocale(\n locale: string,\n customMapping: CustomMapping | undefined = this.customMapping\n ): string {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('resolveAliasLocale'));\n if (customMapping === this.customMapping) {\n return this.localeConfig.resolveAliasLocale(locale);\n }\n return _resolveAliasLocale(locale, customMapping);\n }\n\n /**\n * Standardizes a BCP 47 locale code to ensure correct formatting.\n *\n * @param {string} [locale=this.targetLocale] - The BCP 47 locale code to standardize\n * @returns {string} The standardized locale code or empty string if invalid\n * @throws {Error} If no target locale is provided\n *\n * @example\n * gt.standardizeLocale('en_us');\n * // Returns: \"en-US\"\n */\n standardizeLocale(locale = this.targetLocale): string {\n if (!locale)\n throw new Error(noTargetLocaleProvidedError('standardizeLocale'));\n return this.localeConfig.standardizeLocale(locale);\n }\n\n /**\n * Checks if multiple BCP 47 locale codes represent the same dialect.\n *\n * @param {...(string | string[])} locales - The BCP 47 locale codes to compare\n * @returns {boolean} True if all codes represent the same dialect, false otherwise\n *\n * @example\n * gt.isSameDialect('en-US', 'en-GB');\n * // Returns: false\n *\n * gt.isSameDialect('en', 'en-US');\n * // Returns: true\n */\n isSameDialect(...locales: (string | string[])[]): boolean {\n return this.localeConfig.isSameDialect(...locales);\n }\n\n /**\n * Checks if multiple BCP 47 locale codes represent the same language.\n *\n * @param {...(string | string[])} locales - The BCP 47 locale codes to compare\n * @returns {boolean} True if all codes represent the same language, false otherwise\n *\n * @example\n * gt.isSameLanguage('en-US', 'en-GB');\n * // Returns: true\n */\n isSameLanguage(...locales: (string | string[])[]): boolean {\n return this.localeConfig.isSameLanguage(...locales);\n }\n\n /**\n * Checks if a locale is a superset of another locale.\n *\n * @param {string} superLocale - The locale to check if it is a superset\n * @param {string} subLocale - The locale to check if it is a subset\n * @returns {boolean} True if superLocale is a superset of subLocale, false otherwise\n *\n * @example\n * gt.isSupersetLocale('en', 'en-US');\n * // Returns: true\n *\n * gt.isSupersetLocale('en-US', 'en');\n * // Returns: false\n */\n isSupersetLocale(superLocale: string, subLocale: string): boolean {\n return this.localeConfig.isSupersetLocale(superLocale, subLocale);\n }\n}\n\n// ============================================================ //\n// Utility methods //\n// ============================================================ //\n\n// -------------- Formatting -------------- //\n\n/**\n * Formats a string with cutoff behavior, applying a terminator when the string exceeds the maximum character limit.\n *\n * This standalone function provides cutoff formatting functionality without requiring a GT instance.\n * The locales parameter is required for proper terminator selection based on the target language.\n *\n * @param {string} value - The string value to format with cutoff behavior.\n * @param {Object} [options] - Configuration options for cutoff formatting.\n * @param {string | string[]} [options.locales] - The locales to use for terminator selection.\n * @param {number} [options.maxChars] - The maximum number of characters to display.\n * - Undefined values are treated as no cutoff.\n * - Negative values follow .slice() behavior and terminator will be added before the value.\n * - 0 will result in an empty string.\n * - If cutoff results in an empty string, no terminator is added.\n * @param {CutoffFormatStyle} [options.style='ellipsis'] - The style of the terminator.\n * @param {string} [options.terminator] - Optional override the terminator to use.\n * @param {string} [options.separator] - Optional override the separator to use between the terminator and the value.\n * - If no terminator is provided, then separator is ignored.\n * @returns {string} The formatted string with terminator applied if cutoff occurs.\n *\n * @example\n * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: 8 });\n * // Returns: 'Hello, w...'\n *\n * @example\n * formatCutoff('Hello, world!', { locales: 'en-US', maxChars: -3 });\n * // Returns: '...ld!'\n *\n * @example\n * formatCutoff('Very long text that needs cutting', {\n * locales: 'en-US',\n * maxChars: 15,\n * style: 'ellipsis',\n * separator: ' '\n * });\n * // Returns: 'Very long text ...'\n */\nexport function formatCutoff(\n value: string,\n options?: {\n locales?: string | string[];\n } & CutoffFormatOptions\n): string {\n return _formatCutoff({ value, locales: options?.locales, options });\n}\n\n/**\n * Formats a message according to the specified locales and options.\n *\n * @param {string} message - The message to format.\n * @param {string | string[]} [locales='en'] - The locales to use for formatting.\n * @param {FormatVariables} [variables={}] - The variables to use for formatting.\n * @param {StringFormat} [dataFormat='ICU'] - The format of the message. (When STRING, the message is returned as is)\n * @returns {string} The formatted message.\n *\n * @example\n * formatMessage('Hello {name}', { name: 'John' });\n * // Returns: \"Hello John\"\n *\n * formatMessage('Hello {name}', { name: 'John' }, { locales: ['fr'] });\n * // Returns: \"Bonjour John\"\n */\nexport function formatMessage(\n message: string,\n options?: {\n locales?: string | string[];\n variables?: FormatVariables;\n dataFormat?: StringFormat;\n }\n): string {\n switch (options?.dataFormat) {\n case 'STRING':\n return _formatMessageString(message);\n default:\n return _formatMessageICU(message, options?.locales, options?.variables);\n }\n}\n\n/**\n * Formats a number according to the specified locales and options.\n * @param {Object} params - The parameters for the number formatting.\n * @param {number} params.value - The number to format.\n * @param {Intl.NumberFormatOptions} [params.options] - Additional options for number formatting.\n * @param {string | string[]} [params.options.locales] - The locales to use for formatting.\n * @returns {string} The formatted number.\n */\nexport function formatNum(\n number: number,\n options: {\n locales: string | string[];\n } & Intl.NumberFormatOptions\n): string {\n return _formatNum({\n value: number,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a date according to the specified languages and options.\n * @param {Object} params - The parameters for the date formatting.\n * @param {Date} params.value - The date to format.\n * @param {Intl.DateTimeFormatOptions} [params.options] - Additional options for date formatting.\n * @param {string | string[]} [params.options.locales] - The languages to use for formatting.\n * @returns {string} The formatted date.\n */\nexport function formatDateTime(\n date: Date,\n options?: {\n locales?: string | string[];\n } & Intl.DateTimeFormatOptions\n): string {\n return _formatDateTime({\n value: date,\n locales: options?.locales,\n options,\n });\n}\n\n/**\n * Formats a currency value according to the specified languages, currency, and options.\n * @param {Object} params - The parameters for the currency formatting.\n * @param {number} params.value - The currency value to format.\n * @param {string} params.currency - The currency code (e.g., 'USD').\n * @param {Intl.NumberFormatOptions} [params.options={}] - Additional options for currency formatting.\n * @param {string | string[]} [params.options.locales] - The locale codes to use for formatting.\n * @returns {string} The formatted currency value.\n */\nexport function formatCurrency(\n value: number,\n currency: string,\n options: {\n locales: string | string[];\n } & Intl.NumberFormatOptions\n): string {\n return _formatCurrency({\n value,\n currency,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n * @param {Object} params - The parameters for the list formatting.\n * @param {Array<string | number>} params.value - The list of items to format.\n * @param {Intl.ListFormatOptions} [params.options={}] - Additional options for list formatting.\n * @param {string | string[]} [params.options.locales] - The locales to use for formatting.\n * @returns {string} The formatted list.\n */\nexport function formatList(\n array: Array<string | number>,\n options: {\n locales: string | string[];\n } & Intl.ListFormatOptions\n): string {\n return _formatList({\n value: array,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a list of items according to the specified locales and options.\n * @param {Array<T>} array - The list of items to format\n * @param {Object} [options] - Additional options for list formatting\n * @param {string | string[]} [options.locales] - The locales to use for formatting\n * @param {Intl.ListFormatOptions} [options] - Additional Intl.ListFormat options\n * @returns {Array<T | string>} The formatted list parts\n */\nexport function formatListToParts<T>(\n array: Array<T>,\n options?: {\n locales?: string | string[];\n } & Intl.ListFormatOptions\n): Array<T | string> {\n return _formatListToParts<T>({\n value: array,\n locales: options?.locales,\n options: options,\n });\n}\n\n/**\n * Formats a relative time value according to the specified locales and options.\n * @param {Object} params - The parameters for the relative time formatting.\n * @param {number} params.value - The relative time value to format.\n * @param {Intl.RelativeTimeFormatUnit} params.unit - The unit of time (e.g., 'second', 'minute', 'hour', 'day', 'week', 'month', 'year').\n * @param {Intl.RelativeTimeFormatOptions} [params.options={}] - Additional options for relative time formatting.\n * @param {string | string[]} [params.options.locales] - The locales to use for formatting.\n * @returns {string} The formatted relative time string.\n */\nexport function formatRelativeTime(\n value: number,\n unit: Intl.RelativeTimeFormatUnit,\n options: {\n locales: string | string[];\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n): string {\n return _formatRelativeTime({\n value,\n unit,\n locales: options.locales,\n options,\n });\n}\n\n/**\n * Formats a relative time string from a Date, automatically selecting the best unit.\n * @param {Date} date - The date to format relative to now.\n * @param {Object} options - Formatting options.\n * @param {string | string[]} options.locales - The locales to use for formatting.\n * @param {Intl.RelativeTimeFormatOptions} [options] - Additional Intl.RelativeTimeFormat options.\n * @returns {string} The formatted relative time string (e.g., \"2 hours ago\", \"in 3 days\").\n */\nexport function formatRelativeTimeFromDate(\n date: Date,\n options: {\n locales: string | string[];\n baseDate?: Date;\n } & Omit<Intl.RelativeTimeFormatOptions, 'locales'>\n): string {\n const { locales, baseDate, ...intlOptions } = options;\n return _formatRelativeTimeFromDate({\n date,\n baseDate: baseDate ?? new Date(),\n locales,\n options: intlOptions,\n });\n}\n\n// -------------- Locale Properties -------------- //\n\n/**\n * Retrieves the display name of locale code using Intl.DisplayNames.\n *\n * @param {string} locale - A BCP-47 locale code.\n * @param {string} [defaultLocale] - The default locale to use for formatting.\n * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.\n * @returns {string} The display name corresponding to the code.\n */\nexport function getLocaleName(\n locale: string,\n defaultLocale?: string,\n customMapping?: CustomMapping\n): string {\n return _getLocaleName(locale, defaultLocale, customMapping);\n}\n\n/**\n * Retrieves an emoji based on a given locale code, taking into account region, language, and specific exceptions.\n *\n * This function uses the locale's region (if present) to select an emoji or falls back on default emojis for certain languages.\n *\n * @param locale - A string representing the locale code (e.g., 'en-US', 'fr-CA').\n * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.\n * @returns The emoji representing the locale or its region, or a default emoji if no specific match is found.\n */\nexport function getLocaleEmoji(\n locale: string,\n customMapping?: CustomMapping\n): string {\n return _getLocaleEmoji(locale, customMapping);\n}\n\n/**\n * Generates linguistic details for a given locale code.\n *\n * This function returns information about the locale,\n * script, and region of a given language code both in a standard form and in a maximized form (with likely script and region).\n * The function provides these names in both your default language and native forms, and an associated emoji.\n *\n * @param {string} locale - The locale code to get properties for (e.g., \"de-AT\").\n * @param {string} [defaultLocale] - The default locale to use for formatting.\n * @param {CustomMapping} [customMapping] - A custom mapping of locale codes to their names.\n * @returns {LocaleProperties} - An object containing detailed information about the locale.\n *\n * @property {string} code - The full locale code, e.g., \"de-AT\".\n * @property {string} name - Language name in the default display language, e.g., \"Austrian German\".\n * @property {string} nativeName - Language name in the locale's native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} languageCode - The base language code, e.g., \"de\".\n * @property {string} languageName - The language name in the default display language, e.g., \"German\".\n * @property {string} nativeLanguageName - The language name in the native language, e.g., \"Deutsch\".\n * @property {string} nameWithRegionCode - Language name with region in the default language, e.g., \"German (AT)\".\n * @property {string} nativeNameWithRegionCode - Language name with region in the native language, e.g., \"Deutsch (AT)\".\n * @property {string} regionCode - The region code from maximization, e.g., \"AT\".\n * @property {string} regionName - The region name in the default display language, e.g., \"Austria\".\n * @property {string} nativeRegionName - The region name in the native language, e.g., \"Österreich\".\n * @property {string} scriptCode - The script code from maximization, e.g., \"Latn\".\n * @property {string} scriptName - The script name in the default display language, e.g., \"Latin\".\n * @property {string} nativeScriptName - The script name in the native language, e.g., \"Lateinisch\".\n * @property {string} maximizedCode - The maximized locale code, e.g., \"de-Latn-AT\".\n * @property {string} maximizedName - Maximized locale name with likely script in the default language, e.g., \"Austrian German (Latin)\".\n * @property {string} nativeMaximizedName - Maximized locale name in the native language, e.g., \"Österreichisches Deutsch (Lateinisch)\".\n * @property {string} minimizedCode - Minimized locale code, e.g., \"de-AT\" (or \"de\" for \"de-DE\").\n * @property {string} minimizedName - Minimized language name in the default language, e.g., \"Austrian German\".\n * @property {string} nativeMinimizedName - Minimized language name in the native language, e.g., \"Österreichisches Deutsch\".\n * @property {string} emoji - The emoji associated with the locale's region, if applicable.\n */\nexport function getLocaleProperties(\n locale: string,\n defaultLocale?: string,\n customMapping?: CustomMapping\n): LocaleProperties {\n return _getLocaleProperties(locale, defaultLocale, customMapping);\n}\n\n/**\n * Retrieves multiple properties for a given region code, including:\n * - `code`: the original region code\n * - `name`: the localized display name\n * - `emoji`: the associated flag or symbol\n *\n * Behavior:\n * - Accepts ISO 3166-1 alpha-2 or UN M.49 region codes (e.g., `\"US\"`, `\"FR\"`, `\"419\"`).\n * - If `customMapping` contains a `name` or `emoji` for the region, those override the default values.\n * - Otherwise, uses `Intl.DisplayNames` to get the localized region name in the given `defaultLocale`,\n * falling back to `libraryDefaultLocale`.\n * - Falls back to the region code as `name` if display name resolution fails.\n * - Falls back to `defaultEmoji` if no emoji mapping is found in `emojis` or `customMapping`.\n *\n * @param {string} region - The region code to look up (e.g., `\"US\"`, `\"GB\"`, `\"DE\"`).\n * @param {string} [defaultLocale=libraryDefaultLocale] - The locale to use when localizing the region name.\n * @param {CustomRegionMapping} [customMapping] - Optional mapping of region codes to custom names and/or emojis.\n * @returns {{ code: string, name: string, emoji: string }} An object containing:\n * - `code`: the input region code\n * - `name`: the localized or custom region name\n * - `emoji`: the matching emoji flag or symbol\n *\n * @example\n * getRegionProperties('US', 'en');\n * // => { code: 'US', name: 'United States', emoji: '🇺🇸' }\n *\n * @example\n * getRegionProperties('US', 'fr');\n * // => { code: 'US', name: 'États-Unis', emoji: '🇺🇸' }\n *\n * @example\n * getRegionProperties('US', 'en', { US: { name: 'USA', emoji: '🗽' } });\n * // => { code: 'US', name: 'USA', emoji: '🗽' }\n */\nexport function getRegionProperties(\n region: string,\n defaultLocale?: string,\n customMapping?: CustomRegionMapping\n): { code: string; name: string; emoji: string } {\n return _getRegionProperties(region, defaultLocale, customMapping);\n}\n\n/**\n * Determines whether a translation is required based on the source and target locales.\n *\n * - If the target locale is not specified, the function returns `false`, as translation is not needed.\n * - If the source and target locale are the same, returns `false`, indicating that no translation is necessary.\n * - If the `approvedLocales` array is provided, and the target locale is not within that array, the function also returns `false`.\n * - Otherwise, it returns `true`, meaning that a translation is required.\n *\n * @param {string} sourceLocale - The locale code for the original content (BCP 47 locale code).\n * @param {string} targetLocale - The locale code of the language to translate the content into (BCP 47 locale code).\n * @param {string[]} [approvedLocale] - An optional array of approved target locales.\n *\n * @returns {boolean} - Returns `true` if translation is required, otherwise `false`.\n */\nexport function requiresTranslation(\n sourceLocale: string,\n targetLocale: string,\n approvedLocales?: string[],\n customMapping?: CustomMapping\n): boolean {\n return _requiresTranslation(\n sourceLocale,\n targetLocale,\n approvedLocales,\n customMapping\n );\n}\n\n/**\n * Determines the best matching locale from the provided approved locales list.\n * @param {string | string[]} locales - A single locale or an array of locales sorted in preference order.\n * @param {string[]} [approvedLocales=this.locales] - An array of approved locales, also sorted by preference.\n * @returns {string | undefined} - The best matching locale from the approvedLocales list, or undefined if no match is found.\n */\nexport function determineLocale(\n locales: string | string[],\n approvedLocales: string[] | undefined = [],\n customMapping: CustomMapping | undefined = undefined\n): string | undefined {\n return _determineLocale(locales, approvedLocales, customMapping);\n}\n\n/**\n * Get the text direction for a given locale code using the Intl.Locale API.\n *\n * @param {string} locale - A BCP-47 locale code.\n * @returns {string} - 'rtl' if the locale is right-to-left, otherwise 'ltr'.\n */\nexport function getLocaleDirection(locale: string): 'ltr' | 'rtl' {\n return _getLocaleDirection(locale);\n}\n\n/**\n * Checks if a given BCP 47 locale code is valid.\n * @param {string} locale - The BCP 47 locale code to validate.\n * @param {CustomMapping} [customMapping] - The custom mapping to use for validation.\n * @returns {boolean} True if the BCP 47 code is valid, false otherwise.\n */\nexport function isValidLocale(\n locale: string,\n customMapping?: CustomMapping\n): boolean {\n return _isValidLocale(locale, customMapping);\n}\n\n/**\n * Resolves the alias locale for a given locale.\n * @param {string} locale - The locale to resolve the alias locale for\n * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the alias locale\n * @returns {string} The alias locale\n */\nexport function resolveAliasLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n return _resolveAliasLocale(locale, customMapping);\n}\n\n/**\n * Resolves the canonical locale for a given locale.\n * @param {string} locale - The locale to resolve the canonical locale for\n * @param {CustomMapping} [customMapping] - The custom mapping to use for resolving the canonical locale\n * @returns {string} The canonical locale\n */\nexport function resolveCanonicalLocale(\n locale: string,\n customMapping?: CustomMapping\n): string {\n return _resolveCanonicalLocale(locale, customMapping);\n}\n\n/**\n * Standardizes a BCP 47 locale code to ensure correct formatting.\n * @param {string} locale - The BCP 47 locale code to standardize.\n * @returns {string} The standardized BCP 47 locale code or an empty string if it is an invalid code.\n */\nexport function standardizeLocale(locale: string): string {\n return _standardizeLocale(locale);\n}\n\n/**\n * Checks if multiple BCP 47 locale codes represent the same dialect.\n * @param {string[]} locales - The BCP 47 locale codes to compare.\n * @returns {boolean} True if all BCP 47 codes represent the same dialect, false otherwise.\n */\nexport function isSameDialect(...locales: (string | string[])[]): boolean {\n return _isSameDialect(...locales);\n}\n\n/**\n * Checks if multiple BCP 47 locale codes represent the same language.\n * @param {string[]} locales - The BCP 47 locale codes to compare.\n * @returns {boolean} True if all BCP 47 codes represent the same language, false otherwise.\n */\nexport function isSameLanguage(...locales: (string | string[])[]): boolean {\n return _isSameLanguage(...locales);\n}\n\n/**\n * Checks if a locale is a superset of another locale.\n * A subLocale is a subset of superLocale if it is an extension of superLocale or are otherwise identical.\n *\n * @param {string} superLocale - The locale to check if it is a superset of the other locale.\n * @param {string} subLocale - The locale to check if it is a subset of the other locale.\n * @returns {boolean} True if the first locale is a superset of the second locale, false otherwise.\n */\nexport function isSupersetLocale(\n superLocale: string,\n subLocale: string\n): boolean {\n return _isSupersetLocale(superLocale, subLocale);\n}\n\nexport const API_VERSION = _API_VERSION;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,mBAAmB;CAAC;CAAQ;CAAQ;CAAQ;CAAQ;CAAQ;CAAO;AAGzE,MAAM,oBAAoB,aAAqB;AAC7C,QAAO,YAAY,SAAS,YAAY;;;;;;;;;AAU1C,MAAa,kBACX,QACA,kBACY;AAEZ,KACE,gBAAgB,WAChB,OAAO,cAAc,YAAY,YACjC,UAAW,cAAc,WACxB,cAAc,QAA6B,KAE5C,UAAU,cAAc,QAA6B;AAGvD,KAAI;EACF,MAAM,EAAE,UAAU,QAAQ,WAAWA,iBAAAA,UAAU,IAAI,UAAU,OAAO;AACpE,MACE,OAAO,MAAM,IAAI,CAAC,kBACX;GACL,IAAI,YAAY;AAChB,OAAI,OAAQ,cAAa;AACzB,OAAI,OAAQ,cAAa;AACzB,UAAO;MACL,CAEJ,QAAO;AAQT,MAP6BA,iBAAAA,UAAU,IACrC,gBACA,CAAA,KAAsB,EACtB,EACE,MAAM,YACP,CAGmB,CAAC,GAAG,SAAS,KAAK,YACtC,CAAC,iBAAiB,SAAS,CAE3B,QAAO;AACT,MAAI;OACyBA,iBAAAA,UAAU,IACnC,gBACA,CAAA,KAAsB,EACtB,EACE,MAAM,UACP,CAEmB,CAAC,GAAG,OAAO,KAAK,OAAQ,QAAO;;AAEvD,MAAI;OACyBA,iBAAAA,UAAU,IACnC,gBACA,CAAA,KAAsB,EACtB,EACE,MAAM,UACP,CAGiB,CAAC,GAAG,OAAO,KAAK,UAClC,CAAC,iBAAiB,SAAS,OAAO,CAElC,QAAO;;AAEX,SAAO;SACD;AACN,SAAO;;;;;;;;;AAUX,MAAa,sBAAsB,WAA2B;AAC5D,KAAI;AACF,SAAO,KAAK,oBAAoB,OAAO,CAAC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