Socket
Socket
Sign inDemoInstall

@formatjs/intl-displaynames

Package Overview
Dependencies
Maintainers
3
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/intl-displaynames - npm Package Compare versions

Comparing version 3.3.4 to 3.3.5

2

_validate_dist-base_options.optionsvalid.d.ts
// /home/longlho/.cache/bazel/_bazel_longlho/576c18efaac10246ec115c72af79fca6/sandbox/linux-sandbox/1011/execroot/formatjs/node_modules/@bazel/typescript/internal/ts_project_options_validator.js checked attributes for //packages/intl-displaynames:dist-base
// /home/longlho/.cache/bazel/_bazel_longlho/576c18efaac10246ec115c72af79fca6/sandbox/linux-sandbox/715/execroot/formatjs/node_modules/@bazel/typescript/internal/ts_project_options_validator.js checked attributes for //packages/intl-displaynames:dist-base
// composite: false

@@ -4,0 +4,0 @@ // declaration: true

// /home/longlho/.cache/bazel/_bazel_longlho/576c18efaac10246ec115c72af79fca6/sandbox/linux-sandbox/313/execroot/formatjs/node_modules/@bazel/typescript/internal/ts_project_options_validator.js checked attributes for //packages/intl-displaynames:dist-esm
// /home/longlho/.cache/bazel/_bazel_longlho/576c18efaac10246ec115c72af79fca6/sandbox/linux-sandbox/720/execroot/formatjs/node_modules/@bazel/typescript/internal/ts_project_options_validator.js checked attributes for //packages/intl-displaynames:dist-esm
// composite: false

@@ -4,0 +4,0 @@ // declaration: true

@@ -13,9 +13,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DisplayNames = void 0;
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
var ToString_1 = __importDefault(require("es-abstract/2019/ToString"));
var DisplayNames = /** @class */ (function () {

@@ -28,4 +24,3 @@ function DisplayNames(locales, options) {

}
var requestedLocales = Intl
.getCanonicalLocales(locales);
var requestedLocales = ecma402_abstract_1.CanonicalizeLocaleList(locales);
var matcher = ecma402_abstract_1.GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');

@@ -47,3 +42,3 @@ var r = ecma402_abstract_1.ResolveLocale(DisplayNames.availableLocales, requestedLocales, { localeMatcher: matcher }, [], // there is no relevantExtensionKeys

DisplayNames.supportedLocalesOf = function (locales, options) {
return ecma402_abstract_1.SupportedLocales(DisplayNames.availableLocales, Intl.getCanonicalLocales(locales), options);
return ecma402_abstract_1.SupportedLocales(DisplayNames.availableLocales, ecma402_abstract_1.CanonicalizeLocaleList(locales), options);
};

@@ -76,3 +71,3 @@ DisplayNames.__addLocaleData = function () {

var type = getSlot(this, 'type');
var codeAsString = ToString_1.default(code);
var codeAsString = ecma402_abstract_1.ToString(code);
if (!isValidCodeForDisplayNames(type, codeAsString)) {

@@ -89,4 +84,3 @@ throw RangeError('invalid code for Intl.DisplayNames.prototype.of');

case 'language': {
canonicalCode = Intl
.getCanonicalLocales(codeAsString)[0];
canonicalCode = ecma402_abstract_1.CanonicalizeLocaleList(codeAsString)[0];
var regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);

@@ -93,0 +87,0 @@ if (regionMatch) {

@@ -12,4 +12,3 @@ var __assign = (this && this.__assign) || function () {

};
import { getInternalSlot, setInternalSlot, GetOption, ResolveLocale, invariant, SupportedLocales, IsWellFormedCurrencyCode, getMultiInternalSlots, unpackData, } from '@formatjs/ecma402-abstract';
import ToString from 'es-abstract/2019/ToString';
import { getInternalSlot, setInternalSlot, GetOption, ResolveLocale, invariant, SupportedLocales, IsWellFormedCurrencyCode, getMultiInternalSlots, unpackData, ToString, CanonicalizeLocaleList, } from '@formatjs/ecma402-abstract';
var DisplayNames = /** @class */ (function () {

@@ -22,4 +21,3 @@ function DisplayNames(locales, options) {

}
var requestedLocales = Intl
.getCanonicalLocales(locales);
var requestedLocales = CanonicalizeLocaleList(locales);
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');

@@ -41,3 +39,3 @@ var r = ResolveLocale(DisplayNames.availableLocales, requestedLocales, { localeMatcher: matcher }, [], // there is no relevantExtensionKeys

DisplayNames.supportedLocalesOf = function (locales, options) {
return SupportedLocales(DisplayNames.availableLocales, Intl.getCanonicalLocales(locales), options);
return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
};

@@ -82,4 +80,3 @@ DisplayNames.__addLocaleData = function () {

case 'language': {
canonicalCode = Intl
.getCanonicalLocales(codeAsString)[0];
canonicalCode = CanonicalizeLocaleList(codeAsString)[0];
var regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);

@@ -86,0 +83,0 @@ if (regionMatch) {

{
"name": "@formatjs/intl-displaynames",
"version": "3.3.4",
"version": "3.3.5",
"description": "Polyfill for: https://tc39.es/proposal-intl-displaynames",

@@ -24,5 +24,3 @@ "keywords": [

"dependencies": {
"@formatjs/ecma402-abstract": "^1.0.3",
"@types/es-abstract": "^1.17.1",
"es-abstract": "^1.17.6"
"@formatjs/ecma402-abstract": "^1.1.0"
},

@@ -29,0 +27,0 @@ "bugs": {

(function (factory) {
typeof define === 'function' && define.amd ? define(factory) :
factory();
typeof define === 'function' && define.amd ? define(factory) :
factory();
}((function () { 'use strict';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
/**
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
* @param locales
*/
function CanonicalizeLocaleList(locales) {
// TODO
return Intl.getCanonicalLocales(locales);
}
/* eslint complexity: [2, 18], max-statements: [2, 33] */
var shams = function hasSymbols() {
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
if (typeof Symbol.iterator === 'symbol') { return true; }
/**
* Cannot do Math.log(x) / Math.log(10) bc if IEEE floating point issue
* @param x number
*/
function setInternalSlot(map, pl, field, value) {
if (!map.get(pl)) {
map.set(pl, Object.create(null));
}
var slots = map.get(pl);
slots[field] = value;
}
function getInternalSlot(map, pl, field) {
return getMultiInternalSlots(map, pl, field)[field];
}
function getMultiInternalSlots(map, pl) {
var fields = [];
for (var _i = 2; _i < arguments.length; _i++) {
fields[_i - 2] = arguments[_i];
}
var slots = map.get(pl);
if (!slots) {
throw new TypeError(pl + " InternalSlot has not been initialized");
}
return fields.reduce(function (all, f) {
all[f] = slots[f];
return all;
}, Object.create(null));
}
var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
function invariant(condition, message, Err) {
if (Err === void 0) { Err = Error; }
if (!condition) {
throw new Err(message);
}
}
var obj = {};
var sym = Symbol('test');
var symObj = Object(sym);
if (typeof sym === 'string') { return false; }
/**
* https://tc39.es/ecma262/#sec-tostring
*/
function ToString(o) {
// Only symbol is irregular...
if (typeof o === 'symbol') {
throw TypeError('Cannot convert a Symbol value to a string');
}
return String(o);
}
/**
* https://tc39.es/ecma262/#sec-toobject
* @param arg
*/
function ToObject(arg) {
if (arg == null) {
throw new TypeError('undefined/null cannot be converted to object');
}
return Object(arg);
}
if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
/**
* https://tc39.es/ecma402/#sec-getoption
* @param opts
* @param prop
* @param type
* @param values
* @param fallback
*/
function GetOption(opts, prop, type, values, fallback) {
// const descriptor = Object.getOwnPropertyDescriptor(opts, prop);
var value = opts[prop];
if (value !== undefined) {
if (type !== 'boolean' && type !== 'string') {
throw new TypeError('invalid type');
}
if (type === 'boolean') {
value = Boolean(value);
}
if (type === 'string') {
value = ToString(value);
}
if (values !== undefined && !values.filter(function (val) { return val == value; }).length) {
throw new RangeError(value + " is not within " + values.join(', '));
}
return value;
}
return fallback;
}
// temp disabled per https://github.com/ljharb/object.assign/issues/17
// if (sym instanceof Symbol) { return false; }
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
// if (!(symObj instanceof Symbol)) { return false; }
/**
* https://tc39.es/ecma402/#sec-bestavailablelocale
* @param availableLocales
* @param locale
*/
function BestAvailableLocale(availableLocales, locale) {
var candidate = locale;
while (true) {
if (~availableLocales.indexOf(candidate)) {
return candidate;
}
var pos = candidate.lastIndexOf('-');
if (!~pos) {
return undefined;
}
if (pos >= 2 && candidate[pos - 2] === '-') {
pos -= 2;
}
candidate = candidate.slice(0, pos);
}
}
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
/**
* https://tc39.es/ecma402/#sec-lookupmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
var result = { locale: '' };
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
var locale = requestedLocales_1[_i];
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
result.locale = availableLocale;
if (locale !== noExtensionLocale) {
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
}
return result;
}
}
result.locale = getDefaultLocale();
return result;
}
var symVal = 42;
obj[sym] = symVal;
for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
/**
* https://tc39.es/ecma402/#sec-bestfitmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
var result = { locale: '' };
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
var locale = requestedLocales_1[_i];
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
result.locale = availableLocale;
if (locale !== noExtensionLocale) {
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
}
return result;
}
}
result.locale = getDefaultLocale();
return result;
}
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
/**
* https://tc39.es/ecma402/#sec-unicodeextensionvalue
* @param extension
* @param key
*/
function UnicodeExtensionValue(extension, key) {
invariant(key.length === 2, 'key must have 2 elements');
var size = extension.length;
var searchValue = "-" + key + "-";
var pos = extension.indexOf(searchValue);
if (pos !== -1) {
var start = pos + 4;
var end = start;
var k = start;
var done = false;
while (!done) {
var e = extension.indexOf('-', k);
var len = void 0;
if (e === -1) {
len = size - k;
}
else {
len = e - k;
}
if (len === 2) {
done = true;
}
else if (e === -1) {
end = size;
done = true;
}
else {
end = e;
k = e + 1;
}
}
return extension.slice(start, end);
}
searchValue = "-" + key;
pos = extension.indexOf(searchValue);
if (pos !== -1 && pos + 3 === size) {
return '';
}
return undefined;
}
var syms = Object.getOwnPropertySymbols(obj);
if (syms.length !== 1 || syms[0] !== sym) { return false; }
/**
* https://tc39.es/ecma402/#sec-resolvelocale
*/
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
var matcher = options.localeMatcher;
var r;
if (matcher === 'lookup') {
r = LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
}
else {
r = BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
}
var foundLocale = r.locale;
var result = { locale: '', dataLocale: foundLocale };
var supportedExtension = '-u';
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
var key = relevantExtensionKeys_1[_i];
var foundLocaleData = localeData[foundLocale];
invariant(typeof foundLocaleData === 'object' && foundLocaleData !== null, "locale data " + key + " must be an object");
var keyLocaleData = foundLocaleData[key];
invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
var value = keyLocaleData[0];
invariant(typeof value === 'string' || value === null, "value must be string or null but got " + typeof value + " in key " + key);
var supportedExtensionAddition = '';
if (r.extension) {
var requestedValue = UnicodeExtensionValue(r.extension, key);
if (requestedValue !== undefined) {
if (requestedValue !== '') {
if (~keyLocaleData.indexOf(requestedValue)) {
value = requestedValue;
supportedExtensionAddition = "-" + key + "-" + value;
}
}
else if (~requestedValue.indexOf('true')) {
value = 'true';
supportedExtensionAddition = "-" + key;
}
}
}
if (key in options) {
var optionsValue = options[key];
invariant(typeof optionsValue === 'string' ||
typeof optionsValue === 'undefined' ||
optionsValue === null, 'optionsValue must be String, Undefined or Null');
if (~keyLocaleData.indexOf(optionsValue)) {
if (optionsValue !== value) {
value = optionsValue;
supportedExtensionAddition = '';
}
}
}
result[key] = value;
supportedExtension += supportedExtensionAddition;
}
if (supportedExtension.length > 2) {
var privateIndex = foundLocale.indexOf('-x-');
if (privateIndex === -1) {
foundLocale = foundLocale + supportedExtension;
}
else {
var preExtension = foundLocale.slice(0, privateIndex);
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
foundLocale = preExtension + supportedExtension + postExtension;
}
foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
}
result.locale = foundLocale;
return result;
}
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
/**
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
* @param str string to convert
*/
function toUpperCase(str) {
return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
}
var NOT_A_Z_REGEX = /[^A-Z]/;
/**
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
*/
function IsWellFormedCurrencyCode(currency) {
currency = toUpperCase(currency);
if (currency.length !== 3) {
return false;
}
if (NOT_A_Z_REGEX.test(currency)) {
return false;
}
return true;
}
if (typeof Object.getOwnPropertyDescriptor === 'function') {
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
}
/**
* https://tc39.es/ecma402/#sec-lookupsupportedlocales
* @param availableLocales
* @param requestedLocales
*/
function LookupSupportedLocales(availableLocales, requestedLocales) {
var subset = [];
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
var locale = requestedLocales_1[_i];
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
subset.push(availableLocale);
}
}
return subset;
}
return true;
};
/**
* https://tc39.es/ecma402/#sec-supportedlocales
* @param availableLocales
* @param requestedLocales
* @param options
*/
function SupportedLocales(availableLocales, requestedLocales, options) {
var matcher = 'best fit';
if (options !== undefined) {
options = ToObject(options);
matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
}
if (matcher === 'best fit') {
return LookupSupportedLocales(availableLocales, requestedLocales);
}
return LookupSupportedLocales(availableLocales, requestedLocales);
}
var origSymbol = commonjsGlobal.Symbol;
var __extends = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function getLocaleHierarchy(locale) {
var results = [locale];
var localeParts = locale.split('-');
for (var i = localeParts.length; i > 1; i--) {
results.push(localeParts.slice(0, i - 1).join('-'));
}
return results;
}
var MissingLocaleDataError = /** @class */ (function (_super) {
__extends(MissingLocaleDataError, _super);
function MissingLocaleDataError() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = 'MISSING_LOCALE_DATA';
return _this;
}
return MissingLocaleDataError;
}(Error));
function unpackData(locale, localeData,
/** By default shallow merge the dictionaries. */
reducer) {
if (reducer === void 0) { reducer = function (all, d) { return (__assign(__assign({}, all), d)); }; }
var localeHierarchy = getLocaleHierarchy(locale);
var dataToMerge = localeHierarchy
.map(function (l) { return localeData.data[l]; })
.filter(Boolean);
if (!dataToMerge.length) {
throw new MissingLocaleDataError("Missing locale data for \"" + locale + "\", lookup hierarchy: " + localeHierarchy.join(', '));
}
dataToMerge.reverse();
return dataToMerge.reduce(reducer, {});
}
var __assign$1 = (undefined && undefined.__assign) || function () {
__assign$1 = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign$1.apply(this, arguments);
};
var DisplayNames = /** @class */ (function () {
function DisplayNames(locales, options) {
var _newTarget = this.constructor;
if (options === void 0) { options = Object.create(null); }
if (_newTarget === undefined) {
throw TypeError("Constructor Intl.DisplayNames requires 'new'");
}
var requestedLocales = CanonicalizeLocaleList(locales);
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
var r = ResolveLocale(DisplayNames.availableLocales, requestedLocales, { localeMatcher: matcher }, [], // there is no relevantExtensionKeys
DisplayNames.localeData, DisplayNames.getDefaultLocale);
var style = GetOption(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
setSlot(this, 'style', style);
var type = GetOption(options, 'type', 'string', ['language', 'currency', 'region', 'script'], 'language');
setSlot(this, 'type', type);
var fallback = GetOption(options, 'fallback', 'string', ['code', 'none'], 'code');
setSlot(this, 'fallback', fallback);
setSlot(this, 'locale', r.locale);
var dataLocale = r.dataLocale;
var dataLocaleData = DisplayNames.localeData[dataLocale];
invariant(dataLocaleData !== undefined, "locale data for " + r.locale + " does not exist.");
setSlot(this, 'localeData', dataLocaleData);
}
DisplayNames.supportedLocalesOf = function (locales, options) {
return SupportedLocales(DisplayNames.availableLocales, CanonicalizeLocaleList(locales), options);
};
DisplayNames.__addLocaleData = function () {
var data = [];
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
var datum = data_1[_a];
var availableLocales = datum.availableLocales;
for (var _b = 0, availableLocales_1 = availableLocales; _b < availableLocales_1.length; _b++) {
var locale = availableLocales_1[_b];
try {
DisplayNames.localeData[locale] = unpackData(locale, datum);
}
catch (e) {
// If we can't unpack this data, ignore the locale
}
}
}
DisplayNames.availableLocales = Object.keys(DisplayNames.localeData);
if (!DisplayNames.__defaultLocale) {
DisplayNames.__defaultLocale = DisplayNames.availableLocales[0];
}
};
DisplayNames.prototype.of = function (code) {
checkReceiver(this, 'of');
var type = getSlot(this, 'type');
var codeAsString = ToString(code);
if (!isValidCodeForDisplayNames(type, codeAsString)) {
throw RangeError('invalid code for Intl.DisplayNames.prototype.of');
}
var _a = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), localeData = _a.localeData, style = _a.style, fallback = _a.fallback;
// Canonicalize the case.
var canonicalCode;
// This is only used to store extracted language region.
var regionSubTag;
switch (type) {
// Normalize the locale id and remove the region.
case 'language': {
canonicalCode = CanonicalizeLocaleList(codeAsString)[0];
var regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);
if (regionMatch) {
// Remove region subtag
canonicalCode =
canonicalCode.substring(0, regionMatch.index) +
canonicalCode.substring(regionMatch.index + regionMatch[0].length);
regionSubTag = regionMatch[1];
}
break;
}
// currency code should be all upper-case.
case 'currency':
canonicalCode = codeAsString.toUpperCase();
break;
// script code should be title case
case 'script':
canonicalCode =
codeAsString[0] + codeAsString.substring(1).toLowerCase();
break;
// region shold be all upper-case
case 'region':
canonicalCode = codeAsString.toUpperCase();
break;
}
var typesData = localeData.types[type];
// If the style of choice does not exist, fallback to "long".
var name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
if (name !== undefined) {
// If there is a region subtag in the language id, use locale pattern to interpolate the region
if (regionSubTag) {
// Retrieve region display names
var regionsData = localeData.types.region;
var regionDisplayName = regionsData[style][regionSubTag] || regionsData.long[regionSubTag];
if (regionDisplayName || fallback === 'code') {
// Interpolate into locale-specific pattern.
var pattern = localeData.patterns.locale;
return pattern
.replace('{0}', name)
.replace('{1}', regionDisplayName || regionSubTag);
}
}
else {
return name;
}
}
if (fallback === 'code') {
return codeAsString;
}
};
DisplayNames.prototype.resolvedOptions = function () {
checkReceiver(this, 'resolvedOptions');
return __assign$1({}, getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'locale', 'style', 'type', 'fallback'));
};
DisplayNames.getDefaultLocale = function () {
return DisplayNames.__defaultLocale;
};
DisplayNames.localeData = {};
DisplayNames.availableLocales = [];
DisplayNames.__defaultLocale = 'en';
DisplayNames.polyfilled = true;
return DisplayNames;
}());
// https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames
function isValidCodeForDisplayNames(type, code) {
switch (type) {
case 'language':
// subset of unicode_language_id
// languageCode ["-" scriptCode] ["-" regionCode] *("-" variant)
// where:
// - languageCode is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.
// - scriptCode is should be an ISO-15924 four letters script code
// - regionCode is either an ISO-3166 two letters region code, or a three digits UN M49 Geographic Regions.
return /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*$/i.test(code);
case 'region':
// unicode_region_subtag
return /^([a-z]{2}|\d{3})$/i.test(code);
case 'script':
// unicode_script_subtag
return /^[a-z]{4}$/i.test(code);
case 'currency':
return IsWellFormedCurrencyCode(code);
}
}
try {
// IE11 does not have Symbol
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {
value: 'Intl.DisplayNames',
configurable: true,
enumerable: false,
writable: false,
});
}
Object.defineProperty(DisplayNames, 'length', {
value: 2,
writable: false,
enumerable: false,
configurable: true,
});
}
catch (e) {
// Make test 262 compliant
}
var __INTERNAL_SLOT_MAP__ = new WeakMap();
function getSlot(instance, key) {
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
}
function setSlot(instance, key, value) {
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
}
function checkReceiver(receiver, methodName) {
if (!(receiver instanceof DisplayNames)) {
throw TypeError("Method Intl.DisplayNames.prototype." + methodName + " called on incompatible receiver");
}
}
var hasSymbols = function hasNativeSymbols() {
if (typeof origSymbol !== 'function') { return false; }
if (typeof Symbol !== 'function') { return false; }
if (typeof origSymbol('foo') !== 'symbol') { return false; }
if (typeof Symbol('bar') !== 'symbol') { return false; }
/**
* https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
*/
function hasMissingICUBug() {
if (Intl.DisplayNames) {
var regionNames = new Intl.DisplayNames(['en'], {
type: 'region',
});
return regionNames.of('CA') === 'CA';
}
return false;
}
function shouldPolyfill() {
return !Intl.DisplayNames || hasMissingICUBug();
}
return shams();
};
if (shouldPolyfill()) {
Object.defineProperty(Intl, 'DisplayNames', {
value: DisplayNames,
enumerable: false,
writable: true,
configurable: true,
});
}
/* eslint no-invalid-this: 1 */
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
var slice = Array.prototype.slice;
var toStr = Object.prototype.toString;
var funcType = '[object Function]';
var implementation = function bind(that) {
var target = this;
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target);
}
var args = slice.call(arguments, 1);
var bound;
var binder = function () {
if (this instanceof bound) {
var result = target.apply(
this,
args.concat(slice.call(arguments))
);
if (Object(result) === result) {
return result;
}
return this;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
};
var boundLength = Math.max(0, target.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs.push('$' + i);
}
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
if (target.prototype) {
var Empty = function Empty() {};
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
};
var functionBind = Function.prototype.bind || implementation;
/* globals
Atomics,
SharedArrayBuffer,
*/
var undefined$1;
var $TypeError = TypeError;
var $gOPD = Object.getOwnPropertyDescriptor;
if ($gOPD) {
try {
$gOPD({}, '');
} catch (e) {
$gOPD = null; // this is IE 8, which has a broken gOPD
}
}
var throwTypeError = function () { throw new $TypeError(); };
var ThrowTypeError = $gOPD
? (function () {
try {
// eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
arguments.callee; // IE 8 does not throw here
return throwTypeError;
} catch (calleeThrows) {
try {
// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
return $gOPD(arguments, 'callee').get;
} catch (gOPDthrows) {
return throwTypeError;
}
}
}())
: throwTypeError;
var hasSymbols$1 = hasSymbols();
var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
var generatorFunction = undefined$1;
var asyncFunction = undefined$1;
var asyncGenFunction = undefined$1;
var TypedArray = typeof Uint8Array === 'undefined' ? undefined$1 : getProto(Uint8Array);
var INTRINSICS = {
'%Array%': Array,
'%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
'%ArrayBufferPrototype%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer.prototype,
'%ArrayIteratorPrototype%': hasSymbols$1 ? getProto([][Symbol.iterator]()) : undefined$1,
'%ArrayPrototype%': Array.prototype,
'%ArrayProto_entries%': Array.prototype.entries,
'%ArrayProto_forEach%': Array.prototype.forEach,
'%ArrayProto_keys%': Array.prototype.keys,
'%ArrayProto_values%': Array.prototype.values,
'%AsyncFromSyncIteratorPrototype%': undefined$1,
'%AsyncFunction%': asyncFunction,
'%AsyncFunctionPrototype%': undefined$1,
'%AsyncGenerator%': undefined$1,
'%AsyncGeneratorFunction%': asyncGenFunction,
'%AsyncGeneratorPrototype%': undefined$1,
'%AsyncIteratorPrototype%': undefined$1,
'%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
'%Boolean%': Boolean,
'%BooleanPrototype%': Boolean.prototype,
'%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
'%DataViewPrototype%': typeof DataView === 'undefined' ? undefined$1 : DataView.prototype,
'%Date%': Date,
'%DatePrototype%': Date.prototype,
'%decodeURI%': decodeURI,
'%decodeURIComponent%': decodeURIComponent,
'%encodeURI%': encodeURI,
'%encodeURIComponent%': encodeURIComponent,
'%Error%': Error,
'%ErrorPrototype%': Error.prototype,
'%eval%': eval, // eslint-disable-line no-eval
'%EvalError%': EvalError,
'%EvalErrorPrototype%': EvalError.prototype,
'%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
'%Float32ArrayPrototype%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array.prototype,
'%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
'%Float64ArrayPrototype%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array.prototype,
'%Function%': Function,
'%FunctionPrototype%': Function.prototype,
'%Generator%': undefined$1,
'%GeneratorFunction%': generatorFunction,
'%GeneratorPrototype%': undefined$1,
'%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
'%Int8ArrayPrototype%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array.prototype,
'%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
'%Int16ArrayPrototype%': typeof Int16Array === 'undefined' ? undefined$1 : Int8Array.prototype,
'%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
'%Int32ArrayPrototype%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array.prototype,
'%isFinite%': isFinite,
'%isNaN%': isNaN,
'%IteratorPrototype%': hasSymbols$1 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
'%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
'%JSONParse%': typeof JSON === 'object' ? JSON.parse : undefined$1,
'%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$1 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
'%MapPrototype%': typeof Map === 'undefined' ? undefined$1 : Map.prototype,
'%Math%': Math,
'%Number%': Number,
'%NumberPrototype%': Number.prototype,
'%Object%': Object,
'%ObjectPrototype%': Object.prototype,
'%ObjProto_toString%': Object.prototype.toString,
'%ObjProto_valueOf%': Object.prototype.valueOf,
'%parseFloat%': parseFloat,
'%parseInt%': parseInt,
'%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
'%PromisePrototype%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype,
'%PromiseProto_then%': typeof Promise === 'undefined' ? undefined$1 : Promise.prototype.then,
'%Promise_all%': typeof Promise === 'undefined' ? undefined$1 : Promise.all,
'%Promise_reject%': typeof Promise === 'undefined' ? undefined$1 : Promise.reject,
'%Promise_resolve%': typeof Promise === 'undefined' ? undefined$1 : Promise.resolve,
'%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
'%RangeError%': RangeError,
'%RangeErrorPrototype%': RangeError.prototype,
'%ReferenceError%': ReferenceError,
'%ReferenceErrorPrototype%': ReferenceError.prototype,
'%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
'%RegExp%': RegExp,
'%RegExpPrototype%': RegExp.prototype,
'%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
'%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$1 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
'%SetPrototype%': typeof Set === 'undefined' ? undefined$1 : Set.prototype,
'%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
'%SharedArrayBufferPrototype%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer.prototype,
'%String%': String,
'%StringIteratorPrototype%': hasSymbols$1 ? getProto(''[Symbol.iterator]()) : undefined$1,
'%StringPrototype%': String.prototype,
'%Symbol%': hasSymbols$1 ? Symbol : undefined$1,
'%SymbolPrototype%': hasSymbols$1 ? Symbol.prototype : undefined$1,
'%SyntaxError%': SyntaxError,
'%SyntaxErrorPrototype%': SyntaxError.prototype,
'%ThrowTypeError%': ThrowTypeError,
'%TypedArray%': TypedArray,
'%TypedArrayPrototype%': TypedArray ? TypedArray.prototype : undefined$1,
'%TypeError%': $TypeError,
'%TypeErrorPrototype%': $TypeError.prototype,
'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
'%Uint8ArrayPrototype%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array.prototype,
'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
'%Uint8ClampedArrayPrototype%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray.prototype,
'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
'%Uint16ArrayPrototype%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array.prototype,
'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
'%Uint32ArrayPrototype%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array.prototype,
'%URIError%': URIError,
'%URIErrorPrototype%': URIError.prototype,
'%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
'%WeakMapPrototype%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap.prototype,
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet,
'%WeakSetPrototype%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet.prototype
};
var $replace = functionBind.call(Function.call, String.prototype.replace);
/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
var stringToPath = function stringToPath(string) {
var result = [];
$replace(string, rePropName, function (match, number, quote, subString) {
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : (number || match);
});
return result;
};
/* end adaptation */
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
if (!(name in INTRINSICS)) {
throw new SyntaxError('intrinsic ' + name + ' does not exist!');
}
// istanbul ignore if // hopefully this is impossible to test :-)
if (typeof INTRINSICS[name] === 'undefined' && !allowMissing) {
throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
}
return INTRINSICS[name];
};
var GetIntrinsic = function GetIntrinsic(name, allowMissing) {
if (typeof name !== 'string' || name.length === 0) {
throw new TypeError('intrinsic name must be a non-empty string');
}
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
throw new TypeError('"allowMissing" argument must be a boolean');
}
var parts = stringToPath(name);
var value = getBaseIntrinsic('%' + (parts.length > 0 ? parts[0] : '') + '%', allowMissing);
for (var i = 1; i < parts.length; i += 1) {
if (value != null) {
if ($gOPD && (i + 1) >= parts.length) {
var desc = $gOPD(value, parts[i]);
if (!allowMissing && !(parts[i] in value)) {
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
}
value = desc ? (desc.get || desc.value) : value[parts[i]];
} else {
value = value[parts[i]];
}
}
}
return value;
};
var $String = GetIntrinsic('%String%');
var $TypeError$1 = GetIntrinsic('%TypeError%');
// https://www.ecma-international.org/ecma-262/6.0/#sec-tostring
var ToString = function ToString(argument) {
if (typeof argument === 'symbol') {
throw new $TypeError$1('Cannot convert a Symbol value to a string');
}
return $String(argument);
};
/**
* https://tc39.es/ecma402/#sec-getoption
* @param opts
* @param prop
* @param type
* @param values
* @param fallback
*/
function GetOption(opts, prop, type, values, fallback) {
// const descriptor = Object.getOwnPropertyDescriptor(opts, prop);
var value = opts[prop];
if (value !== undefined) {
if (type !== 'boolean' && type !== 'string') {
throw new TypeError('invalid type');
}
if (type === 'boolean') {
value = Boolean(value);
}
if (type === 'string') {
value = ToString(value);
}
if (values !== undefined && !values.filter(function (val) { return val == value; }).length) {
throw new RangeError(value + " is not within " + values.join(', '));
}
return value;
}
return fallback;
}
/**
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
* @param str string to convert
*/
function toUpperCase(str) {
return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
}
var NOT_A_Z_REGEX = /[^A-Z]/;
/**
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
*/
function IsWellFormedCurrencyCode(currency) {
currency = toUpperCase(currency);
if (currency.length !== 3) {
return false;
}
if (NOT_A_Z_REGEX.test(currency)) {
return false;
}
return true;
}
/**
* Cannot do Math.log(x) / Math.log(10) bc if IEEE floating point issue
* @param x number
*/
function setInternalSlot(map, pl, field, value) {
if (!map.get(pl)) {
map.set(pl, Object.create(null));
}
var slots = map.get(pl);
slots[field] = value;
}
function getInternalSlot(map, pl, field) {
return getMultiInternalSlots(map, pl, field)[field];
}
function getMultiInternalSlots(map, pl) {
var fields = [];
for (var _i = 2; _i < arguments.length; _i++) {
fields[_i - 2] = arguments[_i];
}
var slots = map.get(pl);
if (!slots) {
throw new TypeError(pl + " InternalSlot has not been initialized");
}
return fields.reduce(function (all, f) {
all[f] = slots[f];
return all;
}, Object.create(null));
}
var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
function invariant(condition, message, Err) {
if (Err === void 0) { Err = Error; }
if (!condition) {
throw new Err(message);
}
}
/**
* https://tc39.es/ecma402/#sec-bestavailablelocale
* @param availableLocales
* @param locale
*/
function BestAvailableLocale(availableLocales, locale) {
var candidate = locale;
while (true) {
if (~availableLocales.indexOf(candidate)) {
return candidate;
}
var pos = candidate.lastIndexOf('-');
if (!~pos) {
return undefined;
}
if (pos >= 2 && candidate[pos - 2] === '-') {
pos -= 2;
}
candidate = candidate.slice(0, pos);
}
}
/**
* https://tc39.es/ecma402/#sec-lookupmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function LookupMatcher(availableLocales, requestedLocales, getDefaultLocale) {
var result = { locale: '' };
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
var locale = requestedLocales_1[_i];
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
result.locale = availableLocale;
if (locale !== noExtensionLocale) {
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
}
return result;
}
}
result.locale = getDefaultLocale();
return result;
}
/**
* https://tc39.es/ecma402/#sec-bestfitmatcher
* @param availableLocales
* @param requestedLocales
* @param getDefaultLocale
*/
function BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale) {
var result = { locale: '' };
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
var locale = requestedLocales_1[_i];
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
result.locale = availableLocale;
if (locale !== noExtensionLocale) {
result.extension = locale.slice(noExtensionLocale.length + 1, locale.length);
}
return result;
}
}
result.locale = getDefaultLocale();
return result;
}
/**
* https://tc39.es/ecma402/#sec-unicodeextensionvalue
* @param extension
* @param key
*/
function UnicodeExtensionValue(extension, key) {
invariant(key.length === 2, 'key must have 2 elements');
var size = extension.length;
var searchValue = "-" + key + "-";
var pos = extension.indexOf(searchValue);
if (pos !== -1) {
var start = pos + 4;
var end = start;
var k = start;
var done = false;
while (!done) {
var e = extension.indexOf('-', k);
var len = void 0;
if (e === -1) {
len = size - k;
}
else {
len = e - k;
}
if (len === 2) {
done = true;
}
else if (e === -1) {
end = size;
done = true;
}
else {
end = e;
k = e + 1;
}
}
return extension.slice(start, end);
}
searchValue = "-" + key;
pos = extension.indexOf(searchValue);
if (pos !== -1 && pos + 3 === size) {
return '';
}
return undefined;
}
/**
* https://tc39.es/ecma402/#sec-resolvelocale
*/
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
var matcher = options.localeMatcher;
var r;
if (matcher === 'lookup') {
r = LookupMatcher(availableLocales, requestedLocales, getDefaultLocale);
}
else {
r = BestFitMatcher(availableLocales, requestedLocales, getDefaultLocale);
}
var foundLocale = r.locale;
var result = { locale: '', dataLocale: foundLocale };
var supportedExtension = '-u';
for (var _i = 0, relevantExtensionKeys_1 = relevantExtensionKeys; _i < relevantExtensionKeys_1.length; _i++) {
var key = relevantExtensionKeys_1[_i];
var foundLocaleData = localeData[foundLocale];
invariant(typeof foundLocaleData === 'object' && foundLocaleData !== null, "locale data " + key + " must be an object");
var keyLocaleData = foundLocaleData[key];
invariant(Array.isArray(keyLocaleData), "keyLocaleData for " + key + " must be an array");
var value = keyLocaleData[0];
invariant(typeof value === 'string' || value === null, "value must be string or null but got " + typeof value + " in key " + key);
var supportedExtensionAddition = '';
if (r.extension) {
var requestedValue = UnicodeExtensionValue(r.extension, key);
if (requestedValue !== undefined) {
if (requestedValue !== '') {
if (~keyLocaleData.indexOf(requestedValue)) {
value = requestedValue;
supportedExtensionAddition = "-" + key + "-" + value;
}
}
else if (~requestedValue.indexOf('true')) {
value = 'true';
supportedExtensionAddition = "-" + key;
}
}
}
if (key in options) {
var optionsValue = options[key];
invariant(typeof optionsValue === 'string' ||
typeof optionsValue === 'undefined' ||
optionsValue === null, 'optionsValue must be String, Undefined or Null');
if (~keyLocaleData.indexOf(optionsValue)) {
if (optionsValue !== value) {
value = optionsValue;
supportedExtensionAddition = '';
}
}
}
result[key] = value;
supportedExtension += supportedExtensionAddition;
}
if (supportedExtension.length > 2) {
var privateIndex = foundLocale.indexOf('-x-');
if (privateIndex === -1) {
foundLocale = foundLocale + supportedExtension;
}
else {
var preExtension = foundLocale.slice(0, privateIndex);
var postExtension = foundLocale.slice(privateIndex, foundLocale.length);
foundLocale = preExtension + supportedExtension + postExtension;
}
foundLocale = Intl.getCanonicalLocales(foundLocale)[0];
}
result.locale = foundLocale;
return result;
}
var $TypeError$2 = GetIntrinsic('%TypeError%');
// http://www.ecma-international.org/ecma-262/5.1/#sec-9.10
var CheckObjectCoercible = function CheckObjectCoercible(value, optMessage) {
if (value == null) {
throw new $TypeError$2(optMessage || ('Cannot call method on ' + value));
}
return value;
};
var RequireObjectCoercible = CheckObjectCoercible;
var $Object = GetIntrinsic('%Object%');
// https://www.ecma-international.org/ecma-262/6.0/#sec-toobject
var ToObject = function ToObject(value) {
RequireObjectCoercible(value);
return $Object(value);
};
/**
* https://tc39.es/ecma402/#sec-lookupsupportedlocales
* @param availableLocales
* @param requestedLocales
*/
function LookupSupportedLocales(availableLocales, requestedLocales) {
var subset = [];
for (var _i = 0, requestedLocales_1 = requestedLocales; _i < requestedLocales_1.length; _i++) {
var locale = requestedLocales_1[_i];
var noExtensionLocale = locale.replace(UNICODE_EXTENSION_SEQUENCE_REGEX, '');
var availableLocale = BestAvailableLocale(availableLocales, noExtensionLocale);
if (availableLocale) {
subset.push(availableLocale);
}
}
return subset;
}
/**
* https://tc39.es/ecma402/#sec-supportedlocales
* @param availableLocales
* @param requestedLocales
* @param options
*/
function SupportedLocales(availableLocales, requestedLocales, options) {
var matcher = 'best fit';
if (options !== undefined) {
options = ToObject(options);
matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
}
if (matcher === 'best fit') {
return LookupSupportedLocales(availableLocales, requestedLocales);
}
return LookupSupportedLocales(availableLocales, requestedLocales);
}
var __extends = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function getLocaleHierarchy(locale) {
var results = [locale];
var localeParts = locale.split('-');
for (var i = localeParts.length; i > 1; i--) {
results.push(localeParts.slice(0, i - 1).join('-'));
}
return results;
}
var MissingLocaleDataError = /** @class */ (function (_super) {
__extends(MissingLocaleDataError, _super);
function MissingLocaleDataError() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = 'MISSING_LOCALE_DATA';
return _this;
}
return MissingLocaleDataError;
}(Error));
function unpackData(locale, localeData,
/** By default shallow merge the dictionaries. */
reducer) {
if (reducer === void 0) { reducer = function (all, d) { return (__assign(__assign({}, all), d)); }; }
var localeHierarchy = getLocaleHierarchy(locale);
var dataToMerge = localeHierarchy
.map(function (l) { return localeData.data[l]; })
.filter(Boolean);
if (!dataToMerge.length) {
throw new MissingLocaleDataError("Missing locale data for \"" + locale + "\", lookup hierarchy: " + localeHierarchy.join(', '));
}
dataToMerge.reverse();
return dataToMerge.reduce(reducer, {});
}
var __assign$1 = (undefined && undefined.__assign) || function () {
__assign$1 = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign$1.apply(this, arguments);
};
var DisplayNames = /** @class */ (function () {
function DisplayNames(locales, options) {
var _newTarget = this.constructor;
if (options === void 0) { options = Object.create(null); }
if (_newTarget === undefined) {
throw TypeError("Constructor Intl.DisplayNames requires 'new'");
}
var requestedLocales = Intl
.getCanonicalLocales(locales);
var matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
var r = ResolveLocale(DisplayNames.availableLocales, requestedLocales, { localeMatcher: matcher }, [], // there is no relevantExtensionKeys
DisplayNames.localeData, DisplayNames.getDefaultLocale);
var style = GetOption(options, 'style', 'string', ['narrow', 'short', 'long'], 'long');
setSlot(this, 'style', style);
var type = GetOption(options, 'type', 'string', ['language', 'currency', 'region', 'script'], 'language');
setSlot(this, 'type', type);
var fallback = GetOption(options, 'fallback', 'string', ['code', 'none'], 'code');
setSlot(this, 'fallback', fallback);
setSlot(this, 'locale', r.locale);
var dataLocale = r.dataLocale;
var dataLocaleData = DisplayNames.localeData[dataLocale];
invariant(dataLocaleData !== undefined, "locale data for " + r.locale + " does not exist.");
setSlot(this, 'localeData', dataLocaleData);
}
DisplayNames.supportedLocalesOf = function (locales, options) {
return SupportedLocales(DisplayNames.availableLocales, Intl.getCanonicalLocales(locales), options);
};
DisplayNames.__addLocaleData = function () {
var data = [];
for (var _i = 0; _i < arguments.length; _i++) {
data[_i] = arguments[_i];
}
for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
var datum = data_1[_a];
var availableLocales = datum.availableLocales;
for (var _b = 0, availableLocales_1 = availableLocales; _b < availableLocales_1.length; _b++) {
var locale = availableLocales_1[_b];
try {
DisplayNames.localeData[locale] = unpackData(locale, datum);
}
catch (e) {
// If we can't unpack this data, ignore the locale
}
}
}
DisplayNames.availableLocales = Object.keys(DisplayNames.localeData);
if (!DisplayNames.__defaultLocale) {
DisplayNames.__defaultLocale = DisplayNames.availableLocales[0];
}
};
DisplayNames.prototype.of = function (code) {
checkReceiver(this, 'of');
var type = getSlot(this, 'type');
var codeAsString = ToString(code);
if (!isValidCodeForDisplayNames(type, codeAsString)) {
throw RangeError('invalid code for Intl.DisplayNames.prototype.of');
}
var _a = getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'localeData', 'style', 'fallback'), localeData = _a.localeData, style = _a.style, fallback = _a.fallback;
// Canonicalize the case.
var canonicalCode;
// This is only used to store extracted language region.
var regionSubTag;
switch (type) {
// Normalize the locale id and remove the region.
case 'language': {
canonicalCode = Intl
.getCanonicalLocales(codeAsString)[0];
var regionMatch = /-([a-z]{2}|\d{3})\b/i.exec(canonicalCode);
if (regionMatch) {
// Remove region subtag
canonicalCode =
canonicalCode.substring(0, regionMatch.index) +
canonicalCode.substring(regionMatch.index + regionMatch[0].length);
regionSubTag = regionMatch[1];
}
break;
}
// currency code should be all upper-case.
case 'currency':
canonicalCode = codeAsString.toUpperCase();
break;
// script code should be title case
case 'script':
canonicalCode =
codeAsString[0] + codeAsString.substring(1).toLowerCase();
break;
// region shold be all upper-case
case 'region':
canonicalCode = codeAsString.toUpperCase();
break;
}
var typesData = localeData.types[type];
// If the style of choice does not exist, fallback to "long".
var name = typesData[style][canonicalCode] || typesData.long[canonicalCode];
if (name !== undefined) {
// If there is a region subtag in the language id, use locale pattern to interpolate the region
if (regionSubTag) {
// Retrieve region display names
var regionsData = localeData.types.region;
var regionDisplayName = regionsData[style][regionSubTag] || regionsData.long[regionSubTag];
if (regionDisplayName || fallback === 'code') {
// Interpolate into locale-specific pattern.
var pattern = localeData.patterns.locale;
return pattern
.replace('{0}', name)
.replace('{1}', regionDisplayName || regionSubTag);
}
}
else {
return name;
}
}
if (fallback === 'code') {
return codeAsString;
}
};
DisplayNames.prototype.resolvedOptions = function () {
checkReceiver(this, 'resolvedOptions');
return __assign$1({}, getMultiInternalSlots(__INTERNAL_SLOT_MAP__, this, 'locale', 'style', 'type', 'fallback'));
};
DisplayNames.getDefaultLocale = function () {
return DisplayNames.__defaultLocale;
};
DisplayNames.localeData = {};
DisplayNames.availableLocales = [];
DisplayNames.__defaultLocale = 'en';
DisplayNames.polyfilled = true;
return DisplayNames;
}());
// https://tc39.es/proposal-intl-displaynames/#sec-isvalidcodefordisplaynames
function isValidCodeForDisplayNames(type, code) {
switch (type) {
case 'language':
// subset of unicode_language_id
// languageCode ["-" scriptCode] ["-" regionCode] *("-" variant)
// where:
// - languageCode is either a two letters ISO 639-1 language code or a three letters ISO 639-2 language code.
// - scriptCode is should be an ISO-15924 four letters script code
// - regionCode is either an ISO-3166 two letters region code, or a three digits UN M49 Geographic Regions.
return /^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*$/i.test(code);
case 'region':
// unicode_region_subtag
return /^([a-z]{2}|\d{3})$/i.test(code);
case 'script':
// unicode_script_subtag
return /^[a-z]{4}$/i.test(code);
case 'currency':
return IsWellFormedCurrencyCode(code);
}
}
try {
// IE11 does not have Symbol
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(DisplayNames.prototype, Symbol.toStringTag, {
value: 'Intl.DisplayNames',
configurable: true,
enumerable: false,
writable: false,
});
}
Object.defineProperty(DisplayNames, 'length', {
value: 2,
writable: false,
enumerable: false,
configurable: true,
});
}
catch (e) {
// Make test 262 compliant
}
var __INTERNAL_SLOT_MAP__ = new WeakMap();
function getSlot(instance, key) {
return getInternalSlot(__INTERNAL_SLOT_MAP__, instance, key);
}
function setSlot(instance, key, value) {
setInternalSlot(__INTERNAL_SLOT_MAP__, instance, key, value);
}
function checkReceiver(receiver, methodName) {
if (!(receiver instanceof DisplayNames)) {
throw TypeError("Method Intl.DisplayNames.prototype." + methodName + " called on incompatible receiver");
}
}
/**
* https://bugs.chromium.org/p/chromium/issues/detail?id=1097432
*/
function hasMissingICUBug() {
if (Intl.DisplayNames) {
var regionNames = new Intl.DisplayNames(['en'], {
type: 'region',
});
return regionNames.of('CA') === 'CA';
}
return false;
}
function shouldPolyfill() {
return !Intl.DisplayNames || hasMissingICUBug();
}
if (shouldPolyfill()) {
Object.defineProperty(Intl, 'DisplayNames', {
value: DisplayNames,
enumerable: false,
writable: true,
configurable: true,
});
}
})));
//# sourceMappingURL=polyfill.umd.js.map

@@ -1,1 +0,1 @@

!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).Symbol,t="Function.prototype.bind called on incompatible ",r=Array.prototype.slice,o=Object.prototype.toString,n=Function.prototype.bind||function e(n){var a=this;if("function"!=typeof a||"[object Function]"!==o.call(a))throw new TypeError(t+a);for(var i,l=r.call(arguments,1),y=function(){if(this instanceof i){var e=a.apply(this,l.concat(r.call(arguments)));return Object(e)===e?e:this}return a.apply(n,l.concat(r.call(arguments)))},p=Math.max(0,a.length-l.length),f=[],c=0;c<p;c++)f.push("$"+c);if(i=Function("binder","return function ("+f.join(",")+"){ return binder.apply(this,arguments); }")(y),a.prototype){var u=function e(){};u.prototype=a.prototype,i.prototype=new u,u.prototype=null}return i},a=TypeError,i=Object.getOwnPropertyDescriptor;if(i)try{i({},"")}catch(e){i=null}var l=function(){throw new a},y=i?function(){try{return l}catch(e){try{return i(arguments,"callee").get}catch(e){return l}}}():l,p=function t(){return"function"==typeof e&&"function"==typeof Symbol&&"symbol"==typeof e("foo")&&"symbol"==typeof Symbol("bar")&&function e(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},r=Symbol("test"),o=Object(r);if("string"==typeof r)return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;if("[object Symbol]"!==Object.prototype.toString.call(o))return!1;for(r in t[r]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var n=Object.getOwnPropertySymbols(t);if(1!==n.length||n[0]!==r)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var a=Object.getOwnPropertyDescriptor(t,r);if(42!==a.value||!0!==a.enumerable)return!1}return!0}()}(),f=Object.getPrototypeOf||function(e){return e.__proto__},c="undefined"==typeof Uint8Array?void 0:f(Uint8Array),u={"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayBufferPrototype%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer.prototype,"%ArrayIteratorPrototype%":p?f([][Symbol.iterator]()):void 0,"%ArrayPrototype%":Array.prototype,"%ArrayProto_entries%":Array.prototype.entries,"%ArrayProto_forEach%":Array.prototype.forEach,"%ArrayProto_keys%":Array.prototype.keys,"%ArrayProto_values%":Array.prototype.values,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":void 0,"%AsyncFunctionPrototype%":void 0,"%AsyncGenerator%":void 0,"%AsyncGeneratorFunction%":void 0,"%AsyncGeneratorPrototype%":void 0,"%AsyncIteratorPrototype%":void 0,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%Boolean%":Boolean,"%BooleanPrototype%":Boolean.prototype,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%DataViewPrototype%":"undefined"==typeof DataView?void 0:DataView.prototype,"%Date%":Date,"%DatePrototype%":Date.prototype,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%ErrorPrototype%":Error.prototype,"%eval%":eval,"%EvalError%":EvalError,"%EvalErrorPrototype%":EvalError.prototype,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float32ArrayPrototype%":"undefined"==typeof Float32Array?void 0:Float32Array.prototype,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%Float64ArrayPrototype%":"undefined"==typeof Float64Array?void 0:Float64Array.prototype,"%Function%":Function,"%FunctionPrototype%":Function.prototype,"%Generator%":void 0,"%GeneratorFunction%":void 0,"%GeneratorPrototype%":void 0,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int8ArrayPrototype%":"undefined"==typeof Int8Array?void 0:Int8Array.prototype,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int16ArrayPrototype%":"undefined"==typeof Int16Array?void 0:Int8Array.prototype,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%Int32ArrayPrototype%":"undefined"==typeof Int32Array?void 0:Int32Array.prototype,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":p?f(f([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%JSONParse%":"object"==typeof JSON?JSON.parse:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&p?f((new Map)[Symbol.iterator]()):void 0,"%MapPrototype%":"undefined"==typeof Map?void 0:Map.prototype,"%Math%":Math,"%Number%":Number,"%NumberPrototype%":Number.prototype,"%Object%":Object,"%ObjectPrototype%":Object.prototype,"%ObjProto_toString%":Object.prototype.toString,"%ObjProto_valueOf%":Object.prototype.valueOf,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%PromisePrototype%":"undefined"==typeof Promise?void 0:Promise.prototype,"%PromiseProto_then%":"undefined"==typeof Promise?void 0:Promise.prototype.then,"%Promise_all%":"undefined"==typeof Promise?void 0:Promise.all,"%Promise_reject%":"undefined"==typeof Promise?void 0:Promise.reject,"%Promise_resolve%":"undefined"==typeof Promise?void 0:Promise.resolve,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":RangeError,"%RangeErrorPrototype%":RangeError.prototype,"%ReferenceError%":ReferenceError,"%ReferenceErrorPrototype%":ReferenceError.prototype,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%RegExpPrototype%":RegExp.prototype,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&p?f((new Set)[Symbol.iterator]()):void 0,"%SetPrototype%":"undefined"==typeof Set?void 0:Set.prototype,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%SharedArrayBufferPrototype%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer.prototype,"%String%":String,"%StringIteratorPrototype%":p?f(""[Symbol.iterator]()):void 0,"%StringPrototype%":String.prototype,"%Symbol%":p?Symbol:void 0,"%SymbolPrototype%":p?Symbol.prototype:void 0,"%SyntaxError%":SyntaxError,"%SyntaxErrorPrototype%":SyntaxError.prototype,"%ThrowTypeError%":y,"%TypedArray%":c,"%TypedArrayPrototype%":c?c.prototype:void 0,"%TypeError%":a,"%TypeErrorPrototype%":a.prototype,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ArrayPrototype%":"undefined"==typeof Uint8Array?void 0:Uint8Array.prototype,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint8ClampedArrayPrototype%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray.prototype,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint16ArrayPrototype%":"undefined"==typeof Uint16Array?void 0:Uint16Array.prototype,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%Uint32ArrayPrototype%":"undefined"==typeof Uint32Array?void 0:Uint32Array.prototype,"%URIError%":URIError,"%URIErrorPrototype%":URIError.prototype,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakMapPrototype%":"undefined"==typeof WeakMap?void 0:WeakMap.prototype,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%WeakSetPrototype%":"undefined"==typeof WeakSet?void 0:WeakSet.prototype},d=n.call(Function.call,String.prototype.replace),s=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,v=/\\(\\)?/g,b=function e(t){var r=[];return d(t,s,(function(e,t,o,n){r[r.length]=o?d(n,v,"$1"):t||e})),r},g=function e(t,r){if(!(t in u))throw new SyntaxError("intrinsic "+t+" does not exist!");if(void 0===u[t]&&!r)throw new a("intrinsic "+t+" exists, but is not available. Please file an issue!");return u[t]},h=function e(t,r){if("string"!=typeof t||0===t.length)throw new TypeError("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof r)throw new TypeError('"allowMissing" argument must be a boolean');for(var o=b(t),n=g("%"+(o.length>0?o[0]:"")+"%",r),l=1;l<o.length;l+=1)if(null!=n)if(i&&l+1>=o.length){var y=i(n,o[l]);if(!r&&!(o[l]in n))throw new a("base intrinsic for "+t+" exists, but the property is not available.");n=y?y.get||y.value:n[o[l]]}else n=n[o[l]];return n},A=h("%String%"),m=h("%TypeError%"),P=function e(t){if("symbol"==typeof t)throw new m("Cannot convert a Symbol value to a string");return A(t)};function S(e,t,r,o,n){var a=e[t];if(void 0!==a){if("boolean"!==r&&"string"!==r)throw new TypeError("invalid type");if("boolean"===r&&(a=Boolean(a)),"string"===r&&(a=P(a)),void 0!==o&&!o.filter((function(e){return e==a})).length)throw new RangeError(a+" is not within "+o.join(", "));return a}return n}var O=/[^A-Z]/;function w(e,t){for(var r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];var n=e.get(t);if(!n)throw new TypeError(t+" InternalSlot has not been initialized");return r.reduce((function(e,t){return e[t]=n[t],e}),Object.create(null))}var I=/-u(?:-[0-9a-z]{2,8})+/gi;function E(e,t,r){if(void 0===r&&(r=Error),!e)throw new r(t)}function j(e,t){for(var r=t;;){if(~e.indexOf(r))return r;var o=r.lastIndexOf("-");if(!~o)return;o>=2&&"-"===r[o-2]&&(o-=2),r=r.slice(0,o)}}function U(e,t){E(2===t.length,"key must have 2 elements");var r=e.length,o="-"+t+"-",n=e.indexOf(o);if(-1!==n){for(var a=n+4,i=a,l=a,y=!1;!y;){var p=e.indexOf("-",l);2==(-1===p?r-l:p-l)?y=!0:-1===p?(i=r,y=!0):(i=p,l=p+1)}return e.slice(a,i)}if(-1!==(n=e.indexOf(o="-"+t))&&n+3===r)return""}var x=h("%TypeError%"),D=h("%Object%");var _,k=(_=function(e,t){return(_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}_(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),F=function(){return(F=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},R=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="MISSING_LOCALE_DATA",t}return k(t,e),t}(Error);function M(e,t,r){void 0===r&&(r=function(e,t){return F(F({},e),t)});var o=function n(e){for(var t=[e],r=e.split("-"),o=r.length;o>1;o--)t.push(r.slice(0,o-1).join("-"));return t}(e),a=o.map((function(e){return t.data[e]})).filter(Boolean);if(!a.length)throw new R('Missing locale data for "'+e+'", lookup hierarchy: '+o.join(", "));return a.reverse(),a.reduce(r,{})}var N=function(){return(N=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)},C=function(){function e(t,r){var o=this.constructor;if(void 0===r&&(r=Object.create(null)),void 0===o)throw TypeError("Constructor Intl.DisplayNames requires 'new'");var n=Intl.getCanonicalLocales(t),a=S(r,"localeMatcher","string",["lookup","best fit"],"best fit"),i=function l(e,t,r,o,n,a){for(var i,l=(i="lookup"===r.localeMatcher?function y(e,t,r){for(var o={locale:""},n=0,a=t;n<a.length;n++){var i=a[n],l=i.replace(I,""),y=j(e,l);if(y)return o.locale=y,i!==l&&(o.extension=i.slice(l.length+1,i.length)),o}return o.locale=r(),o}(e,t,a):function p(e,t,r){for(var o={locale:""},n=0,a=t;n<a.length;n++){var i=a[n],l=i.replace(I,""),y=j(e,l);if(y)return o.locale=y,i!==l&&(o.extension=i.slice(l.length+1,i.length)),o}return o.locale=r(),o}(e,t,a)).locale,f={locale:"",dataLocale:l},c="-u",u=0,d=o;u<d.length;u++){var s=d[u],v=n[l];E("object"==typeof v&&null!==v,"locale data "+s+" must be an object");var b=v[s];E(Array.isArray(b),"keyLocaleData for "+s+" must be an array");var g=b[0];E("string"==typeof g||null===g,"value must be string or null but got "+typeof g+" in key "+s);var h="";if(i.extension){var A=U(i.extension,s);void 0!==A&&(""!==A?~b.indexOf(A)&&(h="-"+s+"-"+(g=A)):~A.indexOf("true")&&(g="true",h="-"+s))}if(s in r){var m=r[s];E("string"==typeof m||null==m,"optionsValue must be String, Undefined or Null"),~b.indexOf(m)&&m!==g&&(g=m,h="")}f[s]=g,c+=h}if(c.length>2){var P=l.indexOf("-x-");if(-1===P)l+=c;else{var S=l.slice(0,P),O=l.slice(P,l.length);l=S+c+O}l=Intl.getCanonicalLocales(l)[0]}return f.locale=l,f}(e.availableLocales,n,{localeMatcher:a},[],e.localeData,e.getDefaultLocale);T(this,"style",S(r,"style","string",["narrow","short","long"],"long")),T(this,"type",S(r,"type","string",["language","currency","region","script"],"language")),T(this,"fallback",S(r,"fallback","string",["code","none"],"code")),T(this,"locale",i.locale);var y=e.localeData[i.dataLocale];E(void 0!==y,"locale data for "+i.locale+" does not exist."),T(this,"localeData",y)}return e.supportedLocalesOf=function(t,r){return function o(e,t,r){return void 0!==r&&S(r=function e(t){return function e(t,r){if(null==t)throw new x(r||"Cannot call method on "+t)}(t),D(t)}(r),"localeMatcher","string",["lookup","best fit"],"best fit"),function o(e,t){for(var r=[],o=0,n=t;o<n.length;o++){var a=j(e,n[o].replace(I,""));a&&r.push(a)}return r}(e,t)}(e.availableLocales,Intl.getCanonicalLocales(t),r)},e.__addLocaleData=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=0,n=t;o<n.length;o++)for(var a=n[o],i=a.availableLocales,l=0,y=i;l<y.length;l++){var p=y[l];try{e.localeData[p]=M(p,a)}catch(e){}}e.availableLocales=Object.keys(e.localeData),e.__defaultLocale||(e.__defaultLocale=e.availableLocales[0])},e.prototype.of=function(e){B(this,"of");var t=function r(e,t){return function r(e,t,o){return w(e,t,o)[o]}(L,e,t)}(this,"type"),o=P(e);if(!function n(e,t){switch(e){case"language":return/^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*$/i.test(t);case"region":return/^([a-z]{2}|\d{3})$/i.test(t);case"script":return/^[a-z]{4}$/i.test(t);case"currency":return function r(e){return 3===(e=function t(e){return e.replace(/([a-z])/g,(function(e,t){return t.toUpperCase()}))}(e)).length&&!O.test(e)}(t)}}(t,o))throw RangeError("invalid code for Intl.DisplayNames.prototype.of");var a,i,l=w(L,this,"localeData","style","fallback"),y=l.localeData,p=l.style,f=l.fallback;switch(t){case"language":a=Intl.getCanonicalLocales(o)[0];var c=/-([a-z]{2}|\d{3})\b/i.exec(a);c&&(a=a.substring(0,c.index)+a.substring(c.index+c[0].length),i=c[1]);break;case"currency":a=o.toUpperCase();break;case"script":a=o[0]+o.substring(1).toLowerCase();break;case"region":a=o.toUpperCase()}var u=y.types[t],d=u[p][a]||u.long[a];if(void 0!==d){if(!i)return d;var s=y.types.region,v=s[p][i]||s.long[i];if(v||"code"===f)return y.patterns.locale.replace("{0}",d).replace("{1}",v||i)}if("code"===f)return o},e.prototype.resolvedOptions=function(){return B(this,"resolvedOptions"),N({},w(L,this,"locale","style","type","fallback"))},e.getDefaultLocale=function(){return e.__defaultLocale},e.localeData={},e.availableLocales=[],e.__defaultLocale="en",e.polyfilled=!0,e}();try{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(C.prototype,Symbol.toStringTag,{value:"Intl.DisplayNames",configurable:!0,enumerable:!1,writable:!1}),Object.defineProperty(C,"length",{value:2,writable:!1,enumerable:!1,configurable:!0})}catch(e){}var L=new WeakMap;function T(e,t,r){!function o(e,t,r,n){e.get(t)||e.set(t,Object.create(null)),e.get(t)[r]=n}(L,e,t,r)}function B(e,t){if(!(e instanceof C))throw TypeError("Method Intl.DisplayNames.prototype."+t+" called on incompatible receiver")}(function W(){return!Intl.DisplayNames||function e(){return!!Intl.DisplayNames&&"CA"===new Intl.DisplayNames(["en"],{type:"region"}).of("CA")}()})()&&Object.defineProperty(Intl,"DisplayNames",{value:C,enumerable:!1,writable:!0,configurable:!0})}));
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(e){return Intl.getCanonicalLocales(e)}function t(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var a=e.get(t);if(!a)throw new TypeError(t+" InternalSlot has not been initialized");return n.reduce((function(e,t){return e[t]=a[t],e}),Object.create(null))}var n=/-u(?:-[0-9a-z]{2,8})+/gi;function r(e,t,n){if(void 0===n&&(n=Error),!e)throw new n(t)}function a(e){if("symbol"==typeof e)throw TypeError("Cannot convert a Symbol value to a string");return String(e)}function o(e,t,n,r,o){var l=e[t];if(void 0!==l){if("boolean"!==n&&"string"!==n)throw new TypeError("invalid type");if("boolean"===n&&(l=Boolean(l)),"string"===n&&(l=a(l)),void 0!==r&&!r.filter((function(e){return e==l})).length)throw new RangeError(l+" is not within "+r.join(", "));return l}return o}function l(e,t){for(var n=t;;){if(~e.indexOf(n))return n;var r=n.lastIndexOf("-");if(!~r)return;r>=2&&"-"===n[r-2]&&(r-=2),n=n.slice(0,r)}}function i(e,t){r(2===t.length,"key must have 2 elements");var n=e.length,a="-"+t+"-",o=e.indexOf(a);if(-1!==o){for(var l=o+4,i=l,c=l,u=!1;!u;){var f=e.indexOf("-",c);2==(-1===f?n-c:f-c)?u=!0:-1===f?(i=n,u=!0):(i=f,c=f+1)}return e.slice(l,i)}if(-1!==(o=e.indexOf(a="-"+t))&&o+3===n)return""}var c=/[^A-Z]/;var u,f=(u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type="MISSING_LOCALE_DATA",t}return f(t,e),t}(Error);function g(e,t,n){void 0===n&&(n=function(e,t){return s(s({},e),t)});var r=function a(e){for(var t=[e],n=e.split("-"),r=n.length;r>1;r--)t.push(n.slice(0,r-1).join("-"));return t}(e),o=r.map((function(e){return t.data[e]})).filter(Boolean);if(!o.length)throw new p('Missing locale data for "'+e+'", lookup hierarchy: '+r.join(", "));return o.reverse(),o.reduce(n,{})}var v=function(){return(v=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},y=function(){function u(t,a){var c=this.constructor;if(void 0===a&&(a=Object.create(null)),void 0===c)throw TypeError("Constructor Intl.DisplayNames requires 'new'");var f=e(t),s=o(a,"localeMatcher","string",["lookup","best fit"],"best fit"),p=function g(e,t,a,o,c,u){for(var f,s=(f="lookup"===a.localeMatcher?function p(e,t,r){for(var a={locale:""},o=0,i=t;o<i.length;o++){var c=i[o],u=c.replace(n,""),f=l(e,u);if(f)return a.locale=f,c!==u&&(a.extension=c.slice(u.length+1,c.length)),a}return a.locale=r(),a}(e,t,u):function g(e,t,r){for(var a={locale:""},o=0,i=t;o<i.length;o++){var c=i[o],u=c.replace(n,""),f=l(e,u);if(f)return a.locale=f,c!==u&&(a.extension=c.slice(u.length+1,c.length)),a}return a.locale=r(),a}(e,t,u)).locale,v={locale:"",dataLocale:s},y="-u",d=0,h=o;d<h.length;d++){var b=h[d],w=c[s];r("object"==typeof w&&null!==w,"locale data "+b+" must be an object");var O=w[b];r(Array.isArray(O),"keyLocaleData for "+b+" must be an array");var m=O[0];r("string"==typeof m||null===m,"value must be string or null but got "+typeof m+" in key "+b);var L="";if(f.extension){var D=i(f.extension,b);void 0!==D&&(""!==D?~O.indexOf(D)&&(L="-"+b+"-"+(m=D)):~D.indexOf("true")&&(m="true",L="-"+b))}if(b in a){var j=a[b];r("string"==typeof j||null==j,"optionsValue must be String, Undefined or Null"),~O.indexOf(j)&&j!==m&&(m=j,L="")}v[b]=m,y+=L}if(y.length>2){var _=s.indexOf("-x-");if(-1===_)s+=y;else{var x=s.slice(0,_),k=s.slice(_,s.length);s=x+y+k}s=Intl.getCanonicalLocales(s)[0]}return v.locale=s,v}(u.availableLocales,f,{localeMatcher:s},[],u.localeData,u.getDefaultLocale);h(this,"style",o(a,"style","string",["narrow","short","long"],"long")),h(this,"type",o(a,"type","string",["language","currency","region","script"],"language")),h(this,"fallback",o(a,"fallback","string",["code","none"],"code")),h(this,"locale",p.locale);var v=u.localeData[p.dataLocale];r(void 0!==v,"locale data for "+p.locale+" does not exist."),h(this,"localeData",v)}return u.supportedLocalesOf=function(t,r){return function a(e,t,r){return void 0!==r&&o(r=function a(e){if(null==e)throw new TypeError("undefined/null cannot be converted to object");return Object(e)}(r),"localeMatcher","string",["lookup","best fit"],"best fit"),function i(e,t){for(var r=[],a=0,o=t;a<o.length;a++){var i=l(e,o[a].replace(n,""));i&&r.push(i)}return r}(e,t)}(u.availableLocales,e(t),r)},u.__addLocaleData=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=0,r=e;n<r.length;n++)for(var a=r[n],o=a.availableLocales,l=0,i=o;l<i.length;l++){var c=i[l];try{u.localeData[c]=g(c,a)}catch(e){}}u.availableLocales=Object.keys(u.localeData),u.__defaultLocale||(u.__defaultLocale=u.availableLocales[0])},u.prototype.of=function(n){b(this,"of");var r=function o(e,n){return function r(e,n,a){return t(e,n,a)[a]}(d,e,n)}(this,"type"),l=a(n);if(!function i(e,t){switch(e){case"language":return/^[a-z]{2,3}(-[a-z]{4})?(-([a-z]{2}|\d{3}))?(-([a-z\d]{5,8}|\d[a-z\d]{3}))*$/i.test(t);case"region":return/^([a-z]{2}|\d{3})$/i.test(t);case"script":return/^[a-z]{4}$/i.test(t);case"currency":return function n(e){return 3===(e=function t(e){return e.replace(/([a-z])/g,(function(e,t){return t.toUpperCase()}))}(e)).length&&!c.test(e)}(t)}}(r,l))throw RangeError("invalid code for Intl.DisplayNames.prototype.of");var u,f,s=t(d,this,"localeData","style","fallback"),p=s.localeData,g=s.style,v=s.fallback;switch(r){case"language":u=e(l)[0];var y=/-([a-z]{2}|\d{3})\b/i.exec(u);y&&(u=u.substring(0,y.index)+u.substring(y.index+y[0].length),f=y[1]);break;case"currency":u=l.toUpperCase();break;case"script":u=l[0]+l.substring(1).toLowerCase();break;case"region":u=l.toUpperCase()}var h=p.types[r],w=h[g][u]||h.long[u];if(void 0!==w){if(!f)return w;var O=p.types.region,m=O[g][f]||O.long[f];if(m||"code"===v)return p.patterns.locale.replace("{0}",w).replace("{1}",m||f)}if("code"===v)return l},u.prototype.resolvedOptions=function(){return b(this,"resolvedOptions"),v({},t(d,this,"locale","style","type","fallback"))},u.getDefaultLocale=function(){return u.__defaultLocale},u.localeData={},u.availableLocales=[],u.__defaultLocale="en",u.polyfilled=!0,u}();try{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(y.prototype,Symbol.toStringTag,{value:"Intl.DisplayNames",configurable:!0,enumerable:!1,writable:!1}),Object.defineProperty(y,"length",{value:2,writable:!1,enumerable:!1,configurable:!0})}catch(e){}var d=new WeakMap;function h(e,t,n){!function r(e,t,n,a){e.get(t)||e.set(t,Object.create(null)),e.get(t)[n]=a}(d,e,t,n)}function b(e,t){if(!(e instanceof y))throw TypeError("Method Intl.DisplayNames.prototype."+t+" called on incompatible receiver")}(function w(){return!Intl.DisplayNames||function e(){return!!Intl.DisplayNames&&"CA"===new Intl.DisplayNames(["en"],{type:"region"}).of("CA")}()})()&&Object.defineProperty(Intl,"DisplayNames",{value:y,enumerable:!1,writable:!0,configurable:!0})}));
# `intl-displaynames`
We've migrated the docs to https://formatjs.io.
We've migrated the docs to https://formatjs.io/docs/polyfills/intl-displaynames.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc