react-intl
Advanced tools
Comparing version 3.0.0-beta.18 to 3.0.0-beta.19
@@ -5,2 +5,10 @@ # Changelog | ||
## [3.0.0-beta.19](https://github.com/yahoo/react-intl/compare/v3.0.0-beta.18...v3.0.0-beta.19) (2019-07-25) | ||
### Features | ||
- allow formatDate and formatTime to take string type ([#1369](https://github.com/yahoo/react-intl/issues/1369)) ([d110548](https://github.com/yahoo/react-intl/commit/d110548)) | ||
- Allow formatting embedded XML ([#1379](https://github.com/yahoo/react-intl/issues/1379)) ([61d3c1b](https://github.com/yahoo/react-intl/commit/61d3c1b)) | ||
- Upgrade guide implementing RelativeTime behavior ([#1374](https://github.com/yahoo/react-intl/issues/1374)) ([f8ddcd0](https://github.com/yahoo/react-intl/commit/f8ddcd0)) | ||
## [3.0.0-beta.18](https://github.com/yahoo/react-intl/compare/v3.0.0-beta.17...v3.0.0-beta.18) (2019-07-12) | ||
@@ -7,0 +15,0 @@ |
import * as React from 'react'; | ||
import { BaseFormattedMessage } from './message'; | ||
import { MessageFormatPrimitiveValue } from '../types'; | ||
declare class FormattedHTMLMessage extends BaseFormattedMessage<MessageFormatPrimitiveValue> { | ||
import { PrimitiveType } from 'intl-messageformat/core'; | ||
declare class FormattedHTMLMessage extends BaseFormattedMessage<PrimitiveType> { | ||
static defaultProps: { | ||
@@ -12,7 +12,7 @@ tagName: "span"; | ||
export declare const BaseFormattedHTMLMessage: typeof FormattedHTMLMessage; | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<import("./message").Props<string | number | boolean | null | undefined>>, any> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<string | number | boolean | null | undefined>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<import("./message").Props<string | number | boolean | null | undefined>>> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<string | number | boolean | null | undefined>>; | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<import("./message").Props<PrimitiveType>>, any> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<PrimitiveType>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<import("./message").Props<PrimitiveType>>> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<PrimitiveType>>; | ||
}); | ||
export default _default; |
import * as React from 'react'; | ||
import { MessageDescriptor, IntlShape, MessageFormatPrimitiveValue } from '../types'; | ||
import { MessageDescriptor, IntlShape } from '../types'; | ||
import { PrimitiveType, FormatXMLElementFn } from 'intl-messageformat/core'; | ||
export interface Props<V extends React.ReactNode = React.ReactNode> extends MessageDescriptor { | ||
@@ -9,3 +10,3 @@ intl: IntlShape; | ||
} | ||
export declare class BaseFormattedMessage<V extends MessageFormatPrimitiveValue | React.ReactElement = MessageFormatPrimitiveValue | React.ReactElement> extends React.Component<Props<V>> { | ||
export declare class BaseFormattedMessage<V extends PrimitiveType | FormatXMLElementFn = PrimitiveType | FormatXMLElementFn> extends React.Component<Props<V>> { | ||
static defaultProps: { | ||
@@ -18,7 +19,7 @@ values: {}; | ||
} | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>, any> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>; | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>, any> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>; | ||
}); | ||
export default _default; |
@@ -7,15 +7,15 @@ export * from './types'; | ||
export declare const FormattedDate: (import("react").ComponentClass<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>, any> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>; | ||
}) | (import("react").FunctionComponent<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
@@ -25,15 +25,15 @@ }>; | ||
export declare const FormattedTime: (import("react").ComponentClass<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>, any> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>; | ||
}) | (import("react").FunctionComponent<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
@@ -40,0 +40,0 @@ }>; |
@@ -1,3 +0,4 @@ | ||
import { Formatters, IntlConfig, FormatDateOptions, FormatRelativeTimeOptions, FormatNumberOptions, FormatPluralOptions, MessageDescriptor, MessageFormatPrimitiveValue } from './types'; | ||
import { Formatters, IntlConfig, FormatDateOptions, FormatRelativeTimeOptions, FormatNumberOptions, FormatPluralOptions, MessageDescriptor } from './types'; | ||
import { FormattableUnit } from '@formatjs/intl-relativetimeformat'; | ||
import { PrimitiveType } from 'intl-messageformat/core'; | ||
export declare function formatDate({ locale, formats, onError, timeZone, }: Pick<IntlConfig, 'locale' | 'formats' | 'onError' | 'timeZone'>, state: Formatters, value: number | Date, options?: FormatDateOptions): string; | ||
@@ -8,4 +9,4 @@ export declare function formatTime({ locale, formats, onError, timeZone, }: Pick<IntlConfig, 'locale' | 'formats' | 'onError' | 'timeZone'>, state: Formatters, value: number, options?: FormatDateOptions): string; | ||
export declare function formatPlural({ locale, onError }: Pick<IntlConfig, 'locale' | 'onError'>, state: Formatters, value: number, options?: FormatPluralOptions): string; | ||
export declare function formatMessage({ locale, formats, messages, defaultLocale, defaultFormats, onError, }: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue>): string; | ||
export declare function formatHTMLMessage(config: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, rawValues?: Record<string, MessageFormatPrimitiveValue>): string; | ||
export declare function formatMessage({ locale, formats, messages, defaultLocale, defaultFormats, onError, }: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType>): string; | ||
export declare function formatHTMLMessage(config: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, rawValues?: Record<string, PrimitiveType>): string; | ||
export declare const formatters: { | ||
@@ -12,0 +13,0 @@ formatNumber: typeof formatNumber; |
@@ -21,2 +21,3 @@ "use strict"; | ||
var utils_1 = require("./utils"); | ||
var intl_messageformat_parser_1 = require("intl-messageformat-parser"); | ||
var DATE_TIME_FORMAT_OPTIONS = [ | ||
@@ -180,3 +181,3 @@ 'localeMatcher', | ||
} | ||
invariant(val.length === 1 && val[0].type === 0 /* literal */, 'Message has placeholders but no values was provided'); | ||
invariant(val.length === 1 && val[0].type === intl_messageformat_parser_1.TYPE.literal, 'Message has placeholders but no values was provided'); | ||
return val[0].value; | ||
@@ -190,3 +191,3 @@ } | ||
}); | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} | ||
@@ -211,3 +212,3 @@ catch (e) { | ||
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats); | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} | ||
@@ -226,5 +227,7 @@ catch (e) { | ||
} | ||
return formattedMessageParts.length === 1 | ||
? formattedMessageParts[0].value || defaultMessage || id | ||
: formattedMessageParts.map(function (part) { return part.value; }); | ||
if (formattedMessageParts.length === 1 && | ||
typeof formattedMessageParts[0] === 'string') { | ||
return formattedMessageParts[0] || defaultMessage || id; | ||
} | ||
return formattedMessageParts; | ||
} | ||
@@ -231,0 +234,0 @@ exports.formatMessage = formatMessage; |
@@ -19,2 +19,58 @@ /* | ||
var TYPE; | ||
(function (TYPE) { | ||
/** | ||
* Raw text | ||
*/ | ||
TYPE[TYPE["literal"] = 0] = "literal"; | ||
/** | ||
* Variable w/o any format, e.g `var` in `this is a {var}` | ||
*/ | ||
TYPE[TYPE["argument"] = 1] = "argument"; | ||
/** | ||
* Variable w/ number format | ||
*/ | ||
TYPE[TYPE["number"] = 2] = "number"; | ||
/** | ||
* Variable w/ date format | ||
*/ | ||
TYPE[TYPE["date"] = 3] = "date"; | ||
/** | ||
* Variable w/ time format | ||
*/ | ||
TYPE[TYPE["time"] = 4] = "time"; | ||
/** | ||
* Variable w/ select format | ||
*/ | ||
TYPE[TYPE["select"] = 5] = "select"; | ||
/** | ||
* Variable w/ plural format | ||
*/ | ||
TYPE[TYPE["plural"] = 6] = "plural"; | ||
})(TYPE || (TYPE = {})); | ||
/** | ||
* Type Guards | ||
*/ | ||
function isLiteralElement(el) { | ||
return el.type === TYPE.literal; | ||
} | ||
function isArgumentElement(el) { | ||
return el.type === TYPE.argument; | ||
} | ||
function isNumberElement(el) { | ||
return el.type === TYPE.number; | ||
} | ||
function isDateElement(el) { | ||
return el.type === TYPE.date; | ||
} | ||
function isTimeElement(el) { | ||
return el.type === TYPE.time; | ||
} | ||
function isSelectElement(el) { | ||
return el.type === TYPE.select; | ||
} | ||
function isPluralElement(el) { | ||
return el.type === TYPE.plural; | ||
} | ||
// tslint:disable:only-arrow-functions | ||
@@ -149,73 +205,2 @@ // tslint:disable:object-literal-shorthand | ||
/** | ||
* Type Guards | ||
*/ | ||
function isLiteralElement(el) { | ||
return el.type === 0 /* literal */; | ||
} | ||
function isArgumentElement(el) { | ||
return el.type === 1 /* argument */; | ||
} | ||
function isNumberElement(el) { | ||
return el.type === 2 /* number */; | ||
} | ||
function isDateElement(el) { | ||
return el.type === 3 /* date */; | ||
} | ||
function isTimeElement(el) { | ||
return el.type === 4 /* time */; | ||
} | ||
function isSelectElement(el) { | ||
return el.type === 5 /* select */; | ||
} | ||
function isPluralElement(el) { | ||
return el.type === 6 /* plural */; | ||
} | ||
/* | ||
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | ||
Copyrights licensed under the New BSD License. | ||
See the accompanying LICENSE file for terms. | ||
*/ | ||
// -- Utilities ---------------------------------------------------------------- | ||
function getCacheId(inputs) { | ||
return JSON.stringify(inputs.map(function (input) { | ||
return input && typeof input === 'object' ? orderedProps(input) : input; | ||
})); | ||
} | ||
function orderedProps(obj) { | ||
return Object.keys(obj) | ||
.sort() | ||
.map(function (k) { | ||
var _a; | ||
return (_a = {}, _a[k] = obj[k], _a); | ||
}); | ||
} | ||
var memoizeFormatConstructor = function (FormatConstructor, cache) { | ||
if (cache === void 0) { | ||
cache = {}; | ||
} | ||
return function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var cacheId = getCacheId(args); | ||
var format = cacheId && cache[cacheId]; | ||
if (!format) { | ||
format = new ((_a = FormatConstructor).bind.apply(_a, [void 0].concat(args)))(); | ||
if (cacheId) { | ||
cache[cacheId] = format; | ||
} | ||
} | ||
return format; | ||
}; | ||
}; | ||
/* | ||
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | ||
Copyrights licensed under the New BSD License. | ||
See the accompanying LICENSE file for terms. | ||
*/ | ||
var __extends$1 = (undefined && undefined.__extends) || (function () { | ||
@@ -236,63 +221,12 @@ var extendStatics = function (d, b) { | ||
})(); | ||
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); | ||
}; | ||
// -- MessageFormat -------------------------------------------------------- | ||
function resolveLocale(locales) { | ||
if (typeof locales === 'string') { | ||
locales = [locales]; | ||
var ESCAPE_HASH_REGEX = /\\#/g; | ||
var FormatError = /** @class */ (function (_super) { | ||
__extends$1(FormatError, _super); | ||
function FormatError(msg, variableId) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.variableId = variableId; | ||
return _this; | ||
} | ||
try { | ||
return Intl.NumberFormat.supportedLocalesOf(locales, { | ||
// IE11 localeMatcher `lookup` seems to convert `en` -> `en-US` | ||
// but not other browsers, | ||
localeMatcher: 'best fit' | ||
})[0]; | ||
} | ||
catch (e) { | ||
return IntlMessageFormat.defaultLocale; | ||
} | ||
} | ||
function prewarmFormatters(els, locales, formatters, formats) { | ||
els | ||
.filter(function (el) { return !isArgumentElement(el) && !isLiteralElement(el); }) | ||
.forEach(function (el) { | ||
// Recursively format plural and select parts' option — which can be a | ||
// nested pattern structure. The choosing of the option to use is | ||
// abstracted-by and delegated-to the part helper object. | ||
if (isDateElement(el)) { | ||
var style = el.style ? formats.date[el.style] : undefined; | ||
return formatters.getDateTimeFormat(locales, style); | ||
} | ||
if (isTimeElement(el)) { | ||
var style = el.style ? formats.time[el.style] : undefined; | ||
return formatters.getDateTimeFormat(locales, style); | ||
} | ||
if (isNumberElement(el)) { | ||
var style = el.style ? formats.number[el.style] : undefined; | ||
return formatters.getNumberFormat(locales, style); | ||
} | ||
if (isSelectElement(el)) { | ||
return Object.keys(el.options).forEach(function (id) { | ||
return prewarmFormatters(el.options[id].value, locales, formatters, formats); | ||
}); | ||
} | ||
if (isPluralElement(el)) { | ||
formatters.getPluralRules(locales, { type: el.pluralType }); | ||
return Object.keys(el.options).forEach(function (id) { | ||
return prewarmFormatters(el.options[id].value, locales, formatters, formats); | ||
}); | ||
} | ||
}); | ||
} | ||
var ESCAPE_HASH_REGEX = /\\#/g; | ||
return FormatError; | ||
}(Error)); | ||
function mergeLiteral(parts) { | ||
@@ -429,2 +363,162 @@ if (parts.length < 2) { | ||
} | ||
// Singleton | ||
var domParser; | ||
function formatXMLMessage(els, locales, formatters, formats, values, | ||
// For debugging | ||
originalMessage) { | ||
var parts = formatToParts(els, locales, formatters, formats, values, originalMessage); | ||
var formattedMessage = parts.reduce(function (all, part) { return (all += part.value); }, ''); | ||
// Not designed to filter out aggressively | ||
if (!~formattedMessage.indexOf('<')) { | ||
return [formattedMessage]; | ||
} | ||
if (!values) { | ||
throw new FormatError('Message has placeholders but no values was given'); | ||
} | ||
if (typeof DOMParser === 'undefined') { | ||
throw new FormatError('Cannot format XML message without DOMParser'); | ||
} | ||
if (!domParser) { | ||
domParser = new DOMParser(); | ||
} | ||
// XML, not HTML since HTMl is strict about self-closing tag | ||
var dom = domParser.parseFromString("<template>" + formattedMessage + "</template>", 'application/xml'); | ||
if (dom.getElementsByTagName('parsererror').length) { | ||
throw new FormatError("Malformed XML message " + dom.getElementsByTagName('parsererror')[0].innerHTML); | ||
} | ||
var content = dom.firstChild; | ||
if (!content) { | ||
throw new FormatError("Malformed XML message " + formattedMessage); | ||
} | ||
var tagsToFormat = Object.keys(values).filter(function (varName) { return !!dom.getElementsByTagName(varName).length; }); | ||
// No tags to format | ||
if (!tagsToFormat.length) { | ||
return [formattedMessage]; | ||
} | ||
var reconstructedChunks = []; | ||
for (var i = 0; i < content.childNodes.length; i++) { | ||
var node = content.childNodes[i]; | ||
var tagName = node.tagName; | ||
if (!tagName) { | ||
// Regular text | ||
reconstructedChunks.push(node.textContent || ''); | ||
} | ||
else if (!values[tagName]) { | ||
// Legacy HTML | ||
reconstructedChunks.push(node.outerHTML); | ||
} | ||
else { | ||
var formatFn = values[tagName]; | ||
reconstructedChunks.push(formatFn(node.textContent || undefined)); | ||
} | ||
} | ||
return reconstructedChunks; | ||
} | ||
/* | ||
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | ||
Copyrights licensed under the New BSD License. | ||
See the accompanying LICENSE file for terms. | ||
*/ | ||
// -- Utilities ---------------------------------------------------------------- | ||
function getCacheId(inputs) { | ||
return JSON.stringify(inputs.map(function (input) { | ||
return input && typeof input === 'object' ? orderedProps(input) : input; | ||
})); | ||
} | ||
function orderedProps(obj) { | ||
return Object.keys(obj) | ||
.sort() | ||
.map(function (k) { | ||
var _a; | ||
return (_a = {}, _a[k] = obj[k], _a); | ||
}); | ||
} | ||
var memoizeFormatConstructor = function (FormatConstructor, cache) { | ||
if (cache === void 0) { | ||
cache = {}; | ||
} | ||
return function () { | ||
var _a; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var cacheId = getCacheId(args); | ||
var format = cacheId && cache[cacheId]; | ||
if (!format) { | ||
format = new ((_a = FormatConstructor).bind.apply(_a, [void 0].concat(args)))(); | ||
if (cacheId) { | ||
cache[cacheId] = format; | ||
} | ||
} | ||
return format; | ||
}; | ||
}; | ||
/* | ||
Copyright (c) 2014, Yahoo! Inc. All rights reserved. | ||
Copyrights licensed under the New BSD License. | ||
See the accompanying LICENSE file for terms. | ||
*/ | ||
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); | ||
}; | ||
// -- MessageFormat -------------------------------------------------------- | ||
function resolveLocale(locales) { | ||
if (typeof locales === 'string') { | ||
locales = [locales]; | ||
} | ||
try { | ||
return Intl.NumberFormat.supportedLocalesOf(locales, { | ||
// IE11 localeMatcher `lookup` seems to convert `en` -> `en-US` | ||
// but not other browsers, | ||
localeMatcher: 'best fit' | ||
})[0]; | ||
} | ||
catch (e) { | ||
return IntlMessageFormat.defaultLocale; | ||
} | ||
} | ||
function prewarmFormatters(els, locales, formatters, formats) { | ||
els | ||
.filter(function (el) { return !isArgumentElement(el) && !isLiteralElement(el); }) | ||
.forEach(function (el) { | ||
// Recursively format plural and select parts' option — which can be a | ||
// nested pattern structure. The choosing of the option to use is | ||
// abstracted-by and delegated-to the part helper object. | ||
if (isDateElement(el)) { | ||
var style = el.style ? formats.date[el.style] : undefined; | ||
return formatters.getDateTimeFormat(locales, style); | ||
} | ||
if (isTimeElement(el)) { | ||
var style = el.style ? formats.time[el.style] : undefined; | ||
return formatters.getDateTimeFormat(locales, style); | ||
} | ||
if (isNumberElement(el)) { | ||
var style = el.style ? formats.number[el.style] : undefined; | ||
return formatters.getNumberFormat(locales, style); | ||
} | ||
if (isSelectElement(el)) { | ||
return Object.keys(el.options).forEach(function (id) { | ||
return prewarmFormatters(el.options[id].value, locales, formatters, formats); | ||
}); | ||
} | ||
if (isPluralElement(el)) { | ||
formatters.getPluralRules(locales, { type: el.pluralType }); | ||
return Object.keys(el.options).forEach(function (id) { | ||
return prewarmFormatters(el.options[id].value, locales, formatters, formats); | ||
}); | ||
} | ||
}); | ||
} | ||
function mergeConfig(c1, c2) { | ||
@@ -448,11 +542,2 @@ if (!c2) { | ||
} | ||
var FormatError = /** @class */ (function (_super) { | ||
__extends$1(FormatError, _super); | ||
function FormatError(msg, variableId) { | ||
var _this = _super.call(this, msg) || this; | ||
_this.variableId = variableId; | ||
return _this; | ||
} | ||
return FormatError; | ||
}(Error)); | ||
function createDefaultFormatters(cache) { | ||
@@ -489,2 +574,7 @@ if (cache === void 0) { | ||
}; | ||
this.formatXMLMessage = function (values) { | ||
return formatXMLMessage(_this.ast, _this.locale, _this.formatters, _this.formats, values, _this.message); | ||
}; | ||
this.resolvedOptions = function () { return ({ locale: _this.locale }); }; | ||
this.getAst = function () { return _this.ast; }; | ||
if (typeof message === 'string') { | ||
@@ -513,8 +603,2 @@ this.message = message; | ||
} | ||
IntlMessageFormat.prototype.resolvedOptions = function () { | ||
return { locale: this.locale }; | ||
}; | ||
IntlMessageFormat.prototype.getAst = function () { | ||
return this.ast; | ||
}; | ||
IntlMessageFormat.defaultLocale = 'en'; | ||
@@ -904,3 +988,3 @@ IntlMessageFormat.__parse = undefined; | ||
} | ||
invariant$1(val.length === 1 && val[0].type === 0 /* literal */, 'Message has placeholders but no values was provided'); | ||
invariant$1(val.length === 1 && val[0].type === TYPE.literal, 'Message has placeholders but no values was provided'); | ||
return val[0].value; | ||
@@ -914,3 +998,3 @@ } | ||
}); | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} | ||
@@ -935,3 +1019,3 @@ catch (e) { | ||
var formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats); | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} | ||
@@ -950,5 +1034,7 @@ catch (e) { | ||
} | ||
return formattedMessageParts.length === 1 | ||
? formattedMessageParts[0].value || defaultMessage || id | ||
: formattedMessageParts.map(function (part) { return part.value; }); | ||
if (formattedMessageParts.length === 1 && | ||
typeof formattedMessageParts[0] === 'string') { | ||
return formattedMessageParts[0] || defaultMessage || id; | ||
} | ||
return formattedMessageParts; | ||
} | ||
@@ -955,0 +1041,0 @@ function formatHTMLMessage(config, state, messageDescriptor, rawValues) { |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactIntl={},e.React)}(this,function(e,d){"use strict";var n,a,t=(n=function(e,t){return(n=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}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});a=Error,t(i,a),i.buildMessage=function(e,t){function r(e){return e.charCodeAt(0).toString(16).toUpperCase()}function n(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function a(e){switch(e.type){case"literal":return'"'+n(e.text)+'"';case"class":var t=e.parts.map(function(e){return Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e)});return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var t,r,n=e.map(a);if(n.sort(),0<n.length){for(r=t=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+((i=t)?'"'+n(i)+'"':"end of input")+" found.";var i};function i(e,t,r,n){var o=a.call(this)||this;return o.message=e,o.expected=t,o.found=r,o.location=n,o.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o,i),o}function v(e){return 0===e.type}function g(e){return 1===e.type}function h(e){return 2===e.type}function y(e){return 3===e.type}function b(e){return 4===e.type}function F(e){return 5===e.type}function T(e){return 6===e.type}function u(e){return JSON.stringify(e.map(function(e){return e&&"object"==typeof e?function(r){return Object.keys(r).sort().map(function(e){var t;return(t={})[e]=r[e],t})}(e):e}))}var o,s=function(a,i){return void 0===i&&(i={}),function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=u(t),o=n&&i[n];return o||(o=new((e=a).bind.apply(e,[void 0].concat(t))),n&&(i[n]=o)),o}},r=(o=function(e,t){return(o=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}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var O=/\\#/g;function x(e,t,r,n,o,a){if(1===e.length&&v(e[0]))return[{type:0,value:e[0].value.replace(O,"#")}];for(var i=[],u=0,s=e;u<s.length;u++){var c=s[u];if(v(c))i.push({type:0,value:c.value.replace(O,"#")});else{var l=c.value;if(!(o&&l in o))throw new j("The intl string context variable '"+l+"' was not provided to the string '"+a+"'");var f=o[l];if(g(c))f&&"string"!=typeof f&&"number"!=typeof f?i.push({type:1,value:f}):i.push({type:0,value:"string"==typeof f||"number"==typeof f?String(f):""});else if(y(c)){var m=c.style?n.date[c.style]:void 0;i.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(b(c)){m=c.style?n.time[c.style]:void 0;i.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(h(c)){m=c.style?n.number[c.style]:void 0;i.push({type:0,value:r.getNumberFormat(t,m).format(f)})}else if(F(c)){if(!(p=c.options[f]||c.options.other))throw new RangeError('Invalid values for "'+c.value+'": "'+f+'". Options are "'+Object.keys(c.options).join('", "')+'"');i.push.apply(i,x(p.value,t,r,n,o))}else if(T(c)){var p;if(!(p=c.options["="+f])){var d=r.getPluralRules(t,{type:c.pluralType}).select(f-(c.offset||0));p=c.options[d]||c.options.other}if(!p)throw new RangeError('Invalid values for "'+c.value+'": "'+f+'". Options are "'+Object.keys(c.options).join('", "')+'"');i.push.apply(i,x(p.value,t,r,n,o))}else;}}return function(e){return e.length<2?e:e.reduce(function(e,t){var r=e[e.length-1];return r&&0===r.type&&0===t.type?r.value+=t.value:e.push(t),e},[])}(i)}function l(r,n){return n?Object.keys(r).reduce(function(e,t){return e[t]=function(r,n){return n?c({},r||{},n||{},Object.keys(r).reduce(function(e,t){return e[t]=c({},r[t],n[t]||{}),e},{})):r}(r[t],n[t]),e},c({},r)):r}var f,j=(f=Error,r(m,f),m);function m(e,t){var r=f.call(this,e)||this;return r.variableId=t,r}var p=(E.prototype.resolvedOptions=function(){return{locale:this.locale}},E.prototype.getAst=function(){return this.ast},E.defaultLocale="en",E.__parse=void 0,E.formats={number:{currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},E);function E(e,t,r,n){var o=this;if(void 0===t&&(t=E.defaultLocale),this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(e){return function(e,t,r,n,o,a){var i=x(e,t,r,n,o,a);return 1===i.length?i[0].value:i.reduce(function(e,t){return e+t.value},"")}(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.formatToParts=function(e){return x(o.ast,o.locale,o.formatters,o.formats,e,o.message)},"string"==typeof e){if(this.message=e,!E.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");this.ast=E.__parse(e)}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=l(E.formats,r),this.locale=function(e){"string"==typeof e&&(e=[e]);try{return Intl.NumberFormat.supportedLocalesOf(e,{localeMatcher:"best fit"})[0]}catch(e){return p.defaultLocale}}(t||[]),this.formatters=n&&n.formatters||function(e){return void 0===e&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:s(Intl.NumberFormat,e.number),getDateTimeFormat:s(Intl.DateTimeFormat,e.dateTime),getPluralRules:s(Intl.PluralRules,e.pluralRules)}}(this.formatterCache),function r(e,n,o,a){e.filter(function(e){return!g(e)&&!v(e)}).forEach(function(t){if(y(t)){var e=t.style?a.date[t.style]:void 0;return o.getDateTimeFormat(n,e)}return b(t)?(e=t.style?a.time[t.style]:void 0,o.getDateTimeFormat(n,e)):h(t)?(e=t.style?a.number[t.style]:void 0,o.getNumberFormat(n,e)):F(t)?Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)}):T(t)?(o.getPluralRules(n,{type:t.pluralType}),Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)})):void 0})}(this.ast,this.locale,this.formatters,this.formats)}var _=require("invariant"),I={38:"&",62:">",60:"<",34:""",39:"'"},P=/[&><"']/g;function w(r,e,n){return void 0===n&&(n={}),e.reduce(function(e,t){return r.hasOwnProperty(t)?e[t]=r[t]:n.hasOwnProperty(t)&&(e[t]=n[t]),e},{})}function M(e){var t=(void 0===e?{}:e).intl;_(t,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}function C(e,t){return"[React Intl] "+e+(t?"\n"+t:"")}var N={formats:{},messages:{},timeZone:void 0,textComponent:d.Fragment,defaultLocale:"en",defaultFormats:{},onError:function(e){"production"!==process.env.NODE_ENV&&console.error(e)}};function D(){return{getDateTimeFormat:s(Intl.DateTimeFormat),getNumberFormat:s(Intl.NumberFormat),getMessageFormat:s(p),getRelativeTimeFormat:s(Intl.RelativeTimeFormat),getPluralRules:s(Intl.PluralRules)}}var R=require("hoist-non-react-statics");var S=d.createContext(null),k=S.Consumer,A=S.Provider,L=S;function q(n,e){function r(r){return d.createElement(k,null,function(e){var t;return c&&M({intl:e}),d.createElement(n,Object.assign({},r,((t={})[a]=e,t),{ref:u?r.forwardedRef:null}))})}var t=e||{},o=t.intlPropName,a=void 0===o?"intl":o,i=t.forwardRef,u=void 0!==i&&i,s=t.enforceContext,c=void 0===s||s;return r.displayName="injectIntl("+function(e){return e.displayName||e.name||"Component"}(n)+")",r.WrappedComponent=n,R(u?d.forwardRef(function(e,t){return d.createElement(r,Object.assign({},e,{forwardedRef:t}))}):r,n)}function Z(u){function e(e){var t=e.value,r=e.children,n=e.intl,o=n[u],a=n.textComponent,i=o(t,e);return"function"==typeof r?r(i):a?d.createElement(a,null,i):i}return e.displayName="formatDate"===u?"FormattedDate":"formatTime"===u?"FormattedTime":"FormattedNumber",{BaseComponent:e,Component:q(e)}}var U=function(e,t){return(U=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 V(e,t){function r(){this.constructor=e}U(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var H=require("invariant"),W=["localeMatcher","formatMatcher","timeZone","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"],B=["localeMatcher","style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"],G=["numeric","style"],J=["localeMatcher","type"];function z(e,t,r,n){var o,a=e&&e[t];if(a&&(o=a[r]),o)return o;n(C("No "+t+" format named: "+r))}function K(e,t,r,n){var o=e.locale,a=e.formats,i=e.messages,u=e.defaultLocale,s=e.defaultFormats,c=e.onError;void 0===r&&(r={id:""}),void 0===n&&(n={});var l=r.id,f=r.defaultMessage;H(l,"[React Intl] An `id` must be provided to format a message.");var m=i&&i[l];if(!(0<Object.keys(n).length)&&"production"===process.env.NODE_ENV){var p=m||f||l;return"string"==typeof p?function(e){return e.replace(/\\u([\da-fA-F]{4})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}).replace(/\\\{/g,"{").replace(/\\\}/g,"}")}(p):(H(1===p.length&&0===p[0].type,"Message has placeholders but no values was provided"),p[0].value)}var d=[];if(m)try{d=t.getMessageFormat(m,o,a,{formatters:t}).formatToParts(n)}catch(e){c(C('Error formatting message: "'+l+'" for locale: "'+o+'"'+(f?", using default message as fallback.":""),e))}else(!f||o&&o.toLowerCase()!==u.toLowerCase())&&c(C('Missing message: "'+l+'" for locale: "'+o+'"'+(f?", using default message as fallback.":"")));if(!d.length&&f)try{d=t.getMessageFormat(f,u,s).formatToParts(n)}catch(e){c(C('Error formatting the default message for: "'+l+'"',e))}return d.length?1===d.length?d[0].value||f||l:d.map(function(e){return e.value}):(c(C('Cannot format message: "'+l+'", using message '+(m||f?"source":"id")+" as fallback.")),"string"==typeof m?m||f||l:f||l)}var Q={formatNumber:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError;void 0===n&&(n={});var u=n.format,s=u&&z(a,"number",u,i)||{},c=w(n,B,s);try{return t.getNumberFormat(o,c).format(r)}catch(e){i(C("Error formatting number.",e))}return String(r)},formatDate:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError,u=e.timeZone;void 0===n&&(n={});var s=n.format,c=new Date(r),l=Object.assign({},u&&{timeZone:u},s&&z(a,"date",s,i)),f=w(n,W,l);try{return t.getDateTimeFormat(o,f).format(c)}catch(e){i(C("Error formatting date.",e))}return String(c)},formatTime:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError,u=e.timeZone;void 0===n&&(n={});var s=n.format,c=new Date(r),l=Object.assign({},u&&{timeZone:u},s&&z(a,"time",s,i)),f=w(n,W,l);f.hour||f.minute||f.second||(f=Object.assign({},f,{hour:"numeric",minute:"numeric"}));try{return t.getDateTimeFormat(o,f).format(c)}catch(e){i(C("Error formatting time.",e))}return String(c)},formatMessage:K,formatPlural:function(e,t,r,n){var o=e.locale,a=e.onError;void 0===n&&(n={});var i=w(n,J);try{return t.getPluralRules(o,i).select(r)}catch(e){a(C("Error formatting plural.",e))}return"other"},formatHTMLMessage:function(e,t,r,n){return void 0===r&&(r={id:""}),void 0===n&&(n={}),K(e,t,r,Object.keys(n).reduce(function(e,t){var r=n[t];return e[t]="string"==typeof r?function(e){return(""+e).replace(P,function(e){return I[e.charCodeAt(0)]})}(r):r,e},{}))},formatRelativeTime:function(e,t,r,n,o){var a=e.locale,i=e.formats,u=e.onError;void 0===n&&(n="second"),void 0===o&&(o={});var s=o.format,c=!!s&&z(i,"relative",s,u)||{},l=w(o,G,c);try{return t.getRelativeTimeFormat(a,l).format(r,n)}catch(e){u(C("Error formatting relative time.",e))}return String(r)}},X=[Intl.DateTimeFormat,Intl.NumberFormat,Intl.PluralRules];var Y,$=require("shallow-equal/objects"),ee=["locale","timeZone","formats","messages","textComponent","defaultLocale","defaultFormats","onError"];function te(e){var t=Object.assign({},N,e);for(var r in N)void 0===t[r]&&(t[r]=N[r]);if(!t.locale||!function(t,e){if(void 0===e&&(e=X),"undefined"==typeof Intl)return!1;if(!t)throw new Error("locales must be supplied.");Array.isArray(t)||(t=[t]);var r=e.filter(Boolean);return 0!==r.length&&r.every(function(e){return e.supportedLocalesOf(t).length===t.length})}(t.locale)){var n=t.locale,o=t.defaultLocale,a=t.defaultFormats,i=t.onError;"function"==typeof i&&i(C('Missing locale data for locale: "'+n+'". Using default locale: "'+o+'" as fallback.')),t=Object.assign({},t,{locale:o,formats:a,messages:N.messages})}return t}function re(e,t){return{formatNumber:Q.formatNumber.bind(void 0,e,t),formatRelativeTime:Q.formatRelativeTime.bind(void 0,e,t),formatDate:Q.formatDate.bind(void 0,e,t),formatTime:Q.formatTime.bind(void 0,e,t),formatPlural:Q.formatPlural.bind(void 0,e,t),formatMessage:Q.formatMessage.bind(void 0,e,t),formatHTMLMessage:Q.formatHTMLMessage.bind(void 0,e,t)}}function ne(e){var t=Y.call(this,e)||this,r=e.intl,n=(r||{}).formatters,o=void 0===n?D():n;return t.state={context:Object.assign({},r,{formatters:o})},t}var oe=q((V(ne,Y=d.PureComponent),ne.getDerivedStateFromProps=function(e,t){var r=e.intl,n=w(e,ee,r||{});if($(n,t.filteredProps))return null;var o=te(n),a=re(o,Object.assign({},t.context.formatters));return{filteredProps:n,context:Object.assign({},t.context,o,a)}},ne.prototype.render=function(){return d.createElement(A,{value:this.state.context},this.props.children)},ne),{enforceContext:!1}),ae=require("invariant"),ie=60,ue=3600,se=86400;function ce(e){var t=Math.abs(e);return t<ie?"second":t<ue?"minute":t<se?"hour":"day"}function le(e){switch(e){case"second":return 1;case"minute":return ie;case"hour":return ue;default:return se}}function fe(e,t){if(!e)return 0;switch(t){case"second":return e;case"minute":return e*ie;default:return e*ue}}var me=["second","minute","hour"];function pe(e){return void 0===e&&(e="second"),me.includes(e)}var de,ve=(V(ge,de=d.PureComponent),ge.prototype.scheduleNextUpdate=function(e,t){var r=this,n=e.updateIntervalInSeconds,o=e.unit,a=t.currentValueInSeconds;if(clearTimeout(this._updateTimer),this._updateTimer=null,n&&pe(o)){var i=a-n,u=ce(i);if("day"===u)return this.setState({currentValueInSeconds:i<0?-se:se});var s=le(u),c=i-i%s,l=a<=c?c-s:c,f=Math.abs(l-a);this._updateTimer=setTimeout(function(){return r.setState({currentValueInSeconds:l})},1e3*f)}},ge.prototype.componentDidMount=function(){this.scheduleNextUpdate(this.props,this.state)},ge.prototype.componentDidUpdate=function(){this.scheduleNextUpdate(this.props,this.state)},ge.prototype.componentWillUnmount=function(){clearTimeout(this._updateTimer),this._updateTimer=null},ge.prototype.componentWillReceiveProps=function(e){this.props.value===e.value&&this.props.unit===e.unit||this.setState({currentValueInSeconds:pe(e.unit)?fe(e.value,e.unit):0})},ge.prototype.render=function(){var e=this.props.intl,t=e.formatRelativeTime,r=e.textComponent,n=this.props,o=n.children,a=n.value,i=n.unit,u=n.updateIntervalInSeconds,s=this.state.currentValueInSeconds,c=a||0,l=i;if(pe(i)&&s&&u){var f=le(l=ce(s));c=Math.round(s/f)}var m=t(c,l,Object.assign({},this.props));return"function"==typeof o?o(m):r?d.createElement(r,null,m):m},ge);function ge(e){var t=de.call(this,e)||this;return t._updateTimer=null,t.state={currentValueInSeconds:pe(t.props.unit)?fe(t.props.value,t.props.unit):0},function(e,t){ae(!e||e&&pe(t),"Cannot schedule update with unit longer than hour")}(e.updateIntervalInSeconds,e.unit),t}ve.defaultProps={value:0,unit:"second"};function he(e){var t=e.value,r=e.other,n=e.children,o=e.intl,a=o.formatPlural,i=o.textComponent,u=e[a(t,e)]||r;return"function"==typeof n?n(u):i?d.createElement(i,null,u):u}var ye=q(ve);he.defaultProps={type:"cardinal"},he.displayName="FormattedPlural";function be(e,t){return"production"!==process.env.NODE_ENV&&console.error("[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry. Using default message as fallback."),K(Object.assign({},N,{locale:"en"}),D(),e,t)}var Fe,Te=q(he),Oe=require("shallow-equal/objects"),xe=(V(je,Fe=d.Component),je.prototype.shouldComponentUpdate=function(e){var t=this.props.values,r=e.values;if(!Oe(r,t))return!0;var n=Object.assign({},e,{values:t});return!Oe(this.props,n)},je.prototype.render=function(){var e=this.props.intl||{},t=e.formatMessage,r=void 0===t?be:t,n=e.textComponent,o=void 0===n?d.Fragment:n,a=this.props,i=a.id,u=a.description,s=a.defaultMessage,c=a.values,l=a.tagName,f=void 0===l?o:l,m=a.children,p=r({id:i,description:u,defaultMessage:s},c);return Array.isArray(p)||(p=[p]),"function"==typeof m?m.apply(void 0,p):f?d.createElement.apply(d,[f,null].concat(p)):p},je);function je(e){var t=Fe.call(this,e)||this;return e.defaultMessage||M(e),t}xe.defaultProps={values:{}};var Ee,_e=q(xe,{enforceContext:!1}),Ie=(V(Pe,Ee=xe),Pe.prototype.render=function(){var e=this.props.intl,t=e.formatHTMLMessage,r=e.textComponent,n=this.props,o=n.id,a=n.description,i=n.defaultMessage,u=n.values,s=n.tagName,c=void 0===s?r||"span":s,l=n.children,f=t({id:o,description:a,defaultMessage:i},u);if("function"==typeof l)return l(f);var m={__html:f};return d.createElement(c,{dangerouslySetInnerHTML:m})},Pe);function Pe(){return null!==Ee&&Ee.apply(this,arguments)||this}Ie.defaultProps=Object.assign({},xe.defaultProps,{tagName:"span"});var we=q(Ie);var Me=Z("formatDate").Component,Ce=Z("formatTime").Component,Ne=Z("formatNumber").Component;e.FormattedDate=Me,e.FormattedHTMLMessage=we,e.FormattedMessage=_e,e.FormattedNumber=Ne,e.FormattedPlural=Te,e.FormattedRelativeTime=ye,e.FormattedTime=Ce,e.IntlContext=L,e.IntlProvider=oe,e.defineMessages=function(e){return e},e.generateIntlContext=function(e){var t=D(),r=Object.assign({},N,e);return Object.assign({},r,{formatters:t},re(r,t))},e.injectIntl=q,e.useIntl=function(){var e=d.useContext(L);return M({intl:e}),e},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactIntl={},e.React)}(this,function(e,d){"use strict";var v,t;function g(e){return e.type===v.literal}function h(e){return e.type===v.argument}function y(e){return e.type===v.number}function b(e){return e.type===v.date}function M(e){return e.type===v.time}function T(e){return e.type===v.select}function F(e){return e.type===v.plural}(t=v=v||{})[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural";var n,a,r=(n=function(e,t){return(n=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}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});a=Error,r(i,a),i.buildMessage=function(e,t){function r(e){return e.charCodeAt(0).toString(16).toUpperCase()}function n(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function a(e){switch(e.type){case"literal":return'"'+n(e.text)+'"';case"class":var t=e.parts.map(function(e){return Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e)});return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var t,r,n=e.map(a);if(n.sort(),0<n.length){for(r=t=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+((i=t)?'"'+n(i)+'"':"end of input")+" found.";var i};function i(e,t,r,n){var o=a.call(this)||this;return o.message=e,o.expected=t,o.found=r,o.location=n,o.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o,i),o}var o,u,O,s=(o=function(e,t){return(o=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}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),x=/\\#/g,w=(u=Error,s(l,u),l);function l(e,t){var r=u.call(this,e)||this;return r.variableId=t,r}function E(e,t,r,n,o,a){if(1===e.length&&g(e[0]))return[{type:0,value:e[0].value.replace(x,"#")}];for(var i=[],u=0,s=e;u<s.length;u++){var l=s[u];if(g(l))i.push({type:0,value:l.value.replace(x,"#")});else{var c=l.value;if(!(o&&c in o))throw new w("The intl string context variable '"+c+"' was not provided to the string '"+a+"'");var f=o[c];if(h(l))f&&"string"!=typeof f&&"number"!=typeof f?i.push({type:1,value:f}):i.push({type:0,value:"string"==typeof f||"number"==typeof f?String(f):""});else if(b(l)){var m=l.style?n.date[l.style]:void 0;i.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(M(l)){m=l.style?n.time[l.style]:void 0;i.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(y(l)){m=l.style?n.number[l.style]:void 0;i.push({type:0,value:r.getNumberFormat(t,m).format(f)})}else if(T(l)){if(!(p=l.options[f]||l.options.other))throw new RangeError('Invalid values for "'+l.value+'": "'+f+'". Options are "'+Object.keys(l.options).join('", "')+'"');i.push.apply(i,E(p.value,t,r,n,o))}else if(F(l)){var p;if(!(p=l.options["="+f])){var d=r.getPluralRules(t,{type:l.pluralType}).select(f-(l.offset||0));p=l.options[d]||l.options.other}if(!p)throw new RangeError('Invalid values for "'+l.value+'": "'+f+'". Options are "'+Object.keys(l.options).join('", "')+'"');i.push.apply(i,E(p.value,t,r,n,o))}else;}}return function(e){return e.length<2?e:e.reduce(function(e,t){var r=e[e.length-1];return r&&0===r.type&&0===t.type?r.value+=t.value:e.push(t),e},[])}(i)}function c(e){return JSON.stringify(e.map(function(e){return e&&"object"==typeof e?function(r){return Object.keys(r).sort().map(function(e){var t;return(t={})[e]=r[e],t})}(e):e}))}var f=function(a,i){return void 0===i&&(i={}),function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=c(t),o=n&&i[n];return o||(o=new((e=a).bind.apply(e,[void 0].concat(t))),n&&(i[n]=o)),o}},m=function(){return(m=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function p(r,n){return n?Object.keys(r).reduce(function(e,t){return e[t]=function(r,n){return n?m({},r||{},n||{},Object.keys(r).reduce(function(e,t){return e[t]=m({},r[t],n[t]||{}),e},{})):r}(r[t],n[t]),e},m({},r)):r}var j=(_.defaultLocale="en",_.__parse=void 0,_.formats={number:{currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},_);function _(e,t,r,n){var o=this;if(void 0===t&&(t=_.defaultLocale),this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(e){return function(e,t,r,n,o,a){var i=E(e,t,r,n,o,a);return 1===i.length?i[0].value:i.reduce(function(e,t){return e+t.value},"")}(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.formatToParts=function(e){return E(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.formatXMLMessage=function(e){return function(e,t,r,n,o,a){var i=E(e,t,r,n,o,a).reduce(function(e,t){return e+t.value},"");if(!~i.indexOf("<"))return[i];if(!o)throw new w("Message has placeholders but no values was given");if("undefined"==typeof DOMParser)throw new w("Cannot format XML message without DOMParser");var u=(O=O||new DOMParser).parseFromString("<template>"+i+"</template>","application/xml");if(u.getElementsByTagName("parsererror").length)throw new w("Malformed XML message "+u.getElementsByTagName("parsererror")[0].innerHTML);var s=u.firstChild;if(!s)throw new w("Malformed XML message "+i);if(!Object.keys(o).filter(function(e){return!!u.getElementsByTagName(e).length}).length)return[i];for(var l=[],c=0;c<s.childNodes.length;c++){var f=s.childNodes[c],m=f.tagName;if(m)if(o[m]){var p=o[m];l.push(p(f.textContent||void 0))}else l.push(f.outerHTML);else l.push(f.textContent||"")}return l}(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.resolvedOptions=function(){return{locale:o.locale}},this.getAst=function(){return o.ast},"string"==typeof e){if(this.message=e,!_.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");this.ast=_.__parse(e)}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=p(_.formats,r),this.locale=function(e){"string"==typeof e&&(e=[e]);try{return Intl.NumberFormat.supportedLocalesOf(e,{localeMatcher:"best fit"})[0]}catch(e){return j.defaultLocale}}(t||[]),this.formatters=n&&n.formatters||function(e){return void 0===e&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:f(Intl.NumberFormat,e.number),getDateTimeFormat:f(Intl.DateTimeFormat,e.dateTime),getPluralRules:f(Intl.PluralRules,e.pluralRules)}}(this.formatterCache),function r(e,n,o,a){e.filter(function(e){return!h(e)&&!g(e)}).forEach(function(t){if(b(t)){var e=t.style?a.date[t.style]:void 0;return o.getDateTimeFormat(n,e)}return M(t)?(e=t.style?a.time[t.style]:void 0,o.getDateTimeFormat(n,e)):y(t)?(e=t.style?a.number[t.style]:void 0,o.getNumberFormat(n,e)):T(t)?Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)}):F(t)?(o.getPluralRules(n,{type:t.pluralType}),Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)})):void 0})}(this.ast,this.locale,this.formatters,this.formats)}var I=require("invariant"),P={38:"&",62:">",60:"<",34:""",39:"'"},C=/[&><"']/g;function N(r,e,n){return void 0===n&&(n={}),e.reduce(function(e,t){return r.hasOwnProperty(t)?e[t]=r[t]:n.hasOwnProperty(t)&&(e[t]=n[t]),e},{})}function D(e){var t=(void 0===e?{}:e).intl;I(t,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}function R(e,t){return"[React Intl] "+e+(t?"\n"+t:"")}var S={formats:{},messages:{},timeZone:void 0,textComponent:d.Fragment,defaultLocale:"en",defaultFormats:{},onError:function(e){"production"!==process.env.NODE_ENV&&console.error(e)}};function L(){return{getDateTimeFormat:f(Intl.DateTimeFormat),getNumberFormat:f(Intl.NumberFormat),getMessageFormat:f(j),getRelativeTimeFormat:f(Intl.RelativeTimeFormat),getPluralRules:f(Intl.PluralRules)}}var k=require("hoist-non-react-statics");var A=d.createContext(null),q=A.Consumer,Z=A.Provider,U=A;function V(n,e){function r(r){return d.createElement(q,null,function(e){var t;return l&&D({intl:e}),d.createElement(n,Object.assign({},r,((t={})[a]=e,t),{ref:u?r.forwardedRef:null}))})}var t=e||{},o=t.intlPropName,a=void 0===o?"intl":o,i=t.forwardRef,u=void 0!==i&&i,s=t.enforceContext,l=void 0===s||s;return r.displayName="injectIntl("+function(e){return e.displayName||e.name||"Component"}(n)+")",r.WrappedComponent=n,k(u?d.forwardRef(function(e,t){return d.createElement(r,Object.assign({},e,{forwardedRef:t}))}):r,n)}function H(u){function e(e){var t=e.value,r=e.children,n=e.intl,o=n[u],a=n.textComponent,i=o(t,e);return"function"==typeof r?r(i):a?d.createElement(a,null,i):i}return e.displayName="formatDate"===u?"FormattedDate":"formatTime"===u?"FormattedTime":"FormattedNumber",{BaseComponent:e,Component:V(e)}}var X=function(e,t){return(X=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 B(e,t){function r(){this.constructor=e}X(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var W=require("invariant"),G=["localeMatcher","formatMatcher","timeZone","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"],J=["localeMatcher","style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"],z=["numeric","style"],K=["localeMatcher","type"];function Q(e,t,r,n){var o,a=e&&e[t];if(a&&(o=a[r]),o)return o;n(R("No "+t+" format named: "+r))}function Y(e,t,r,n){var o=e.locale,a=e.formats,i=e.messages,u=e.defaultLocale,s=e.defaultFormats,l=e.onError;void 0===r&&(r={id:""}),void 0===n&&(n={});var c=r.id,f=r.defaultMessage;W(c,"[React Intl] An `id` must be provided to format a message.");var m=i&&i[c];if(!(0<Object.keys(n).length)&&"production"===process.env.NODE_ENV){var p=m||f||c;return"string"==typeof p?function(e){return e.replace(/\\u([\da-fA-F]{4})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}).replace(/\\\{/g,"{").replace(/\\\}/g,"}")}(p):(W(1===p.length&&p[0].type===v.literal,"Message has placeholders but no values was provided"),p[0].value)}var d=[];if(m)try{d=t.getMessageFormat(m,o,a,{formatters:t}).formatXMLMessage(n)}catch(e){l(R('Error formatting message: "'+c+'" for locale: "'+o+'"'+(f?", using default message as fallback.":""),e))}else(!f||o&&o.toLowerCase()!==u.toLowerCase())&&l(R('Missing message: "'+c+'" for locale: "'+o+'"'+(f?", using default message as fallback.":"")));if(!d.length&&f)try{d=t.getMessageFormat(f,u,s).formatXMLMessage(n)}catch(e){l(R('Error formatting the default message for: "'+c+'"',e))}return d.length?1===d.length&&"string"==typeof d[0]?d[0]||f||c:d:(l(R('Cannot format message: "'+c+'", using message '+(m||f?"source":"id")+" as fallback.")),"string"==typeof m?m||f||c:f||c)}var $={formatNumber:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError;void 0===n&&(n={});var u=n.format,s=u&&Q(a,"number",u,i)||{},l=N(n,J,s);try{return t.getNumberFormat(o,l).format(r)}catch(e){i(R("Error formatting number.",e))}return String(r)},formatDate:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError,u=e.timeZone;void 0===n&&(n={});var s=n.format,l=new Date(r),c=Object.assign({},u&&{timeZone:u},s&&Q(a,"date",s,i)),f=N(n,G,c);try{return t.getDateTimeFormat(o,f).format(l)}catch(e){i(R("Error formatting date.",e))}return String(l)},formatTime:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError,u=e.timeZone;void 0===n&&(n={});var s=n.format,l=new Date(r),c=Object.assign({},u&&{timeZone:u},s&&Q(a,"time",s,i)),f=N(n,G,c);f.hour||f.minute||f.second||(f=Object.assign({},f,{hour:"numeric",minute:"numeric"}));try{return t.getDateTimeFormat(o,f).format(l)}catch(e){i(R("Error formatting time.",e))}return String(l)},formatMessage:Y,formatPlural:function(e,t,r,n){var o=e.locale,a=e.onError;void 0===n&&(n={});var i=N(n,K);try{return t.getPluralRules(o,i).select(r)}catch(e){a(R("Error formatting plural.",e))}return"other"},formatHTMLMessage:function(e,t,r,n){return void 0===r&&(r={id:""}),void 0===n&&(n={}),Y(e,t,r,Object.keys(n).reduce(function(e,t){var r=n[t];return e[t]="string"==typeof r?function(e){return(""+e).replace(C,function(e){return P[e.charCodeAt(0)]})}(r):r,e},{}))},formatRelativeTime:function(e,t,r,n,o){var a=e.locale,i=e.formats,u=e.onError;void 0===n&&(n="second"),void 0===o&&(o={});var s=o.format,l=!!s&&Q(i,"relative",s,u)||{},c=N(o,z,l);try{return t.getRelativeTimeFormat(a,c).format(r,n)}catch(e){u(R("Error formatting relative time.",e))}return String(r)}},ee=[Intl.DateTimeFormat,Intl.NumberFormat,Intl.PluralRules];var te,re=require("shallow-equal/objects"),ne=["locale","timeZone","formats","messages","textComponent","defaultLocale","defaultFormats","onError"];function oe(e){var t=Object.assign({},S,e);for(var r in S)void 0===t[r]&&(t[r]=S[r]);if(!t.locale||!function(t,e){if(void 0===e&&(e=ee),"undefined"==typeof Intl)return!1;if(!t)throw new Error("locales must be supplied.");Array.isArray(t)||(t=[t]);var r=e.filter(Boolean);return 0!==r.length&&r.every(function(e){return e.supportedLocalesOf(t).length===t.length})}(t.locale)){var n=t.locale,o=t.defaultLocale,a=t.defaultFormats,i=t.onError;"function"==typeof i&&i(R('Missing locale data for locale: "'+n+'". Using default locale: "'+o+'" as fallback.')),t=Object.assign({},t,{locale:o,formats:a,messages:S.messages})}return t}function ae(e,t){return{formatNumber:$.formatNumber.bind(void 0,e,t),formatRelativeTime:$.formatRelativeTime.bind(void 0,e,t),formatDate:$.formatDate.bind(void 0,e,t),formatTime:$.formatTime.bind(void 0,e,t),formatPlural:$.formatPlural.bind(void 0,e,t),formatMessage:$.formatMessage.bind(void 0,e,t),formatHTMLMessage:$.formatHTMLMessage.bind(void 0,e,t)}}function ie(e){var t=te.call(this,e)||this,r=e.intl,n=(r||{}).formatters,o=void 0===n?L():n;return t.state={context:Object.assign({},r,{formatters:o})},t}var ue=V((B(ie,te=d.PureComponent),ie.getDerivedStateFromProps=function(e,t){var r=e.intl,n=N(e,ne,r||{});if(re(n,t.filteredProps))return null;var o=oe(n),a=ae(o,Object.assign({},t.context.formatters));return{filteredProps:n,context:Object.assign({},t.context,o,a)}},ie.prototype.render=function(){return d.createElement(Z,{value:this.state.context},this.props.children)},ie),{enforceContext:!1}),se=require("invariant"),le=60,ce=3600,fe=86400;function me(e){var t=Math.abs(e);return t<le?"second":t<ce?"minute":t<fe?"hour":"day"}function pe(e){switch(e){case"second":return 1;case"minute":return le;case"hour":return ce;default:return fe}}function de(e,t){if(!e)return 0;switch(t){case"second":return e;case"minute":return e*le;default:return e*ce}}var ve=["second","minute","hour"];function ge(e){return void 0===e&&(e="second"),ve.includes(e)}var he,ye=(B(be,he=d.PureComponent),be.prototype.scheduleNextUpdate=function(e,t){var r=this,n=e.updateIntervalInSeconds,o=e.unit,a=t.currentValueInSeconds;if(clearTimeout(this._updateTimer),this._updateTimer=null,n&&ge(o)){var i=a-n,u=me(i);if("day"===u)return this.setState({currentValueInSeconds:i<0?-fe:fe});var s=pe(u),l=i-i%s,c=a<=l?l-s:l,f=Math.abs(c-a);this._updateTimer=setTimeout(function(){return r.setState({currentValueInSeconds:c})},1e3*f)}},be.prototype.componentDidMount=function(){this.scheduleNextUpdate(this.props,this.state)},be.prototype.componentDidUpdate=function(){this.scheduleNextUpdate(this.props,this.state)},be.prototype.componentWillUnmount=function(){clearTimeout(this._updateTimer),this._updateTimer=null},be.prototype.componentWillReceiveProps=function(e){this.props.value===e.value&&this.props.unit===e.unit||this.setState({currentValueInSeconds:ge(e.unit)?de(e.value,e.unit):0})},be.prototype.render=function(){var e=this.props.intl,t=e.formatRelativeTime,r=e.textComponent,n=this.props,o=n.children,a=n.value,i=n.unit,u=n.updateIntervalInSeconds,s=this.state.currentValueInSeconds,l=a||0,c=i;if(ge(i)&&s&&u){var f=pe(c=me(s));l=Math.round(s/f)}var m=t(l,c,Object.assign({},this.props));return"function"==typeof o?o(m):r?d.createElement(r,null,m):m},be);function be(e){var t=he.call(this,e)||this;return t._updateTimer=null,t.state={currentValueInSeconds:ge(t.props.unit)?de(t.props.value,t.props.unit):0},function(e,t){se(!e||e&&ge(t),"Cannot schedule update with unit longer than hour")}(e.updateIntervalInSeconds,e.unit),t}ye.defaultProps={value:0,unit:"second"};function Me(e){var t=e.value,r=e.other,n=e.children,o=e.intl,a=o.formatPlural,i=o.textComponent,u=e[a(t,e)]||r;return"function"==typeof n?n(u):i?d.createElement(i,null,u):u}var Te=V(ye);Me.defaultProps={type:"cardinal"},Me.displayName="FormattedPlural";function Fe(e,t){return"production"!==process.env.NODE_ENV&&console.error("[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry. Using default message as fallback."),Y(Object.assign({},S,{locale:"en"}),L(),e,t)}var Oe,xe=V(Me),we=require("shallow-equal/objects"),Ee=(B(je,Oe=d.Component),je.prototype.shouldComponentUpdate=function(e){var t=this.props.values,r=e.values;if(!we(r,t))return!0;var n=Object.assign({},e,{values:t});return!we(this.props,n)},je.prototype.render=function(){var e=this.props.intl||{},t=e.formatMessage,r=void 0===t?Fe:t,n=e.textComponent,o=void 0===n?d.Fragment:n,a=this.props,i=a.id,u=a.description,s=a.defaultMessage,l=a.values,c=a.tagName,f=void 0===c?o:c,m=a.children,p=r({id:i,description:u,defaultMessage:s},l);return Array.isArray(p)||(p=[p]),"function"==typeof m?m.apply(void 0,p):f?d.createElement.apply(d,[f,null].concat(p)):p},je);function je(e){var t=Oe.call(this,e)||this;return e.defaultMessage||D(e),t}Ee.defaultProps={values:{}};var _e,Ie=V(Ee,{enforceContext:!1}),Pe=(B(Ce,_e=Ee),Ce.prototype.render=function(){var e=this.props.intl,t=e.formatHTMLMessage,r=e.textComponent,n=this.props,o=n.id,a=n.description,i=n.defaultMessage,u=n.values,s=n.tagName,l=void 0===s?r||"span":s,c=n.children,f=t({id:o,description:a,defaultMessage:i},u);if("function"==typeof c)return c(f);var m={__html:f};return d.createElement(l,{dangerouslySetInnerHTML:m})},Ce);function Ce(){return null!==_e&&_e.apply(this,arguments)||this}Pe.defaultProps=Object.assign({},Ee.defaultProps,{tagName:"span"});var Ne=V(Pe);var De=H("formatDate").Component,Re=H("formatTime").Component,Se=H("formatNumber").Component;e.FormattedDate=De,e.FormattedHTMLMessage=Ne,e.FormattedMessage=Ie,e.FormattedNumber=Se,e.FormattedPlural=xe,e.FormattedRelativeTime=Te,e.FormattedTime=Re,e.IntlContext=U,e.IntlProvider=ue,e.defineMessages=function(e){return e},e.generateIntlContext=function(e){var t=L(),r=Object.assign({},S,e);return Object.assign({},r,{formatters:t},ae(r,t))},e.injectIntl=V,e.useIntl=function(){var e=d.useContext(U);return D({intl:e}),e},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=react-intl-core.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactIntl={},e.React)}(this,function(e,d){"use strict";var n,a,t=(n=function(e,t){return(n=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}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),ft=function(){return(ft=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},mt=(a=Error,t(u,a),u.buildMessage=function(e,t){function r(e){return e.charCodeAt(0).toString(16).toUpperCase()}function n(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function a(e){switch(e.type){case"literal":return'"'+n(e.text)+'"';case"class":var t=e.parts.map(function(e){return Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e)});return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var t,r,n=e.map(a);if(n.sort(),0<n.length){for(r=t=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+((u=t)?'"'+n(u)+'"':"end of input")+" found.";var u},u);function u(e,t,r,n){var o=a.call(this)||this;return o.message=e,o.expected=t,o.found=r,o.location=n,o.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o,u),o}var f=function(f,e){e=void 0!==e?e:{};var t,r,n,o,m={},a={start:$e},u=$e,i=function(e){return e.reduce(function(e,t){return e.concat(t)},[]).join("")},s=function(e){return ft({type:0,value:e},lt())},c=function(e){return e.join("")},l=ze("argumentElement"),p="{",d=He("{",!1),v="}",h=He("}",!1),g=function(e){return ft({type:1,value:e},lt())},y=",",b=He(",",!1),C="number",F=He("number",!1),A="date",O=He("date",!1),T="time",x=He("time",!1),j=function(e,t,r){return ft({type:"number"===t?2:"date"===t?3:4,style:r&&r[2],value:e},lt())},w="plural",E=He("plural",!1),I="selectordinal",_=He("selectordinal",!1),P="offset:",M=He("offset:",!1),N=function(e,t,r,n){return ft({type:6,pluralType:"plural"===t?"cardinal":"ordinal",value:e,offset:r?r[2]:0,options:n.reduce(function(e,t){var r=t.id,n=t.value,o=t.location;return e[r]={value:n,location:o},e},{})},lt())},R="select",D=He("select",!1),S=function(e,t){return ft({type:5,value:e,options:t.reduce(function(e,t){var r=t.id,n=t.value,o=t.location;return e[r]={value:n,location:o},e},{})},lt())},k="=0",L=He("=0",!1),q="=1",Z=He("=1",!1),U="=2",V=He("=2",!1),H="zero",W=He("zero",!1),z="one",B=He("one",!1),G="two",J=He("two",!1),$="few",K=He("few",!1),Q="many",X=He("many",!1),Y="other",ee=He("other",!1),te=function(e,t){return ft({id:e,value:t},lt())},re=function(e,t){return ft({id:e,value:t},lt())},ne=ze("whitespace"),oe=/^[ \t\n\r]/,ae=We([" ","\t","\n","\r"],!1,!1),ue=ze("optionalWhitespace"),ie=/^[0-9]/,se=We([["0","9"]],!1,!1),ce=/^[0-9a-f]/i,le=We([["0","9"],["a","f"]],!1,!0),fe=function(e){return parseInt(e.join(""),10)},me="'",pe=He("'",!1),de=/^[ \t\n\r,.+={}#]/,ve=We([" ","\t","\n","\r",",",".","+","=","{","}","#"],!1,!1),he={type:"any"},ge=function(e){return e},ye=function(e){return e},be=ze("apostrophe"),Ce=/^[^{}\\\0-\x1F\x7F \t\n\r]/,Fe=We(["{","}","\\",["\0",""],""," ","\t","\n","\r"],!0,!1),Ae="\\\\",Oe=He("\\\\",!1),Te=function(){return"\\"},xe="\\#",je=He("\\#",!1),we=function(){return"\\#"},Ee="\\{",Ie=He("\\{",!1),_e=function(){return"{"},Pe="\\}",Me=He("\\}",!1),Ne=function(){return"}"},Re="\\u",De=He("\\u",!1),Se=function(e){return String.fromCharCode(parseInt(e,16))},ke=0,Le=0,qe=[{line:1,column:1}],Ze=0,Ue=[],Ve=0;if(void 0!==e.startRule){if(!(e.startRule in a))throw new Error("Can't start parsing from rule \""+e.startRule+'".');u=a[e.startRule]}function He(e,t){return{type:"literal",text:e,ignoreCase:t}}function We(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function ze(e){return{type:"other",description:e}}function Be(e){var t,r=qe[e];if(r)return r;for(t=e-1;!qe[t];)t--;for(r={line:(r=qe[t]).line,column:r.column};t<e;)10===f.charCodeAt(t)?(r.line++,r.column=1):r.column++,t++;return qe[e]=r}function Ge(e,t){var r=Be(e),n=Be(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function Je(e){ke<Ze||(Ze<ke&&(Ze=ke,Ue=[]),Ue.push(e))}function $e(){return Ke()}function Ke(){var e,t;for(e=[],t=Qe();t!==m;)e.push(t),t=Qe();return e}function Qe(){var e;return(e=function(){var e,t;e=ke,(t=function(){var e,t,r,n,o,a;t=[],r=e=ke,r=(n=rt())!==m?(o=ct(),o!==m?(a=rt())!==m?n=[n,o,a]:(ke=r,m):(ke=r,m)):(ke=r,m);if(r!==m)for(;r!==m;)t.push(r),r=ke,n=rt(),r=n!==m?(o=ct())!==m?(a=rt())!==m?n=[n,o,a]:(ke=r,m):(ke=r,m):(ke=r,m);else t=m;t!==m&&(Le=e,t=i(t));(e=t)===m&&(e=ke,t=tt(),e=t!==m?f.substring(e,ke):t);return e}())!==m&&(Le=e,t=s(t));return e=t}())===m&&(e=function(){var e,t,r,n,o;Ve++,e=ke,123===f.charCodeAt(ke)?(t=p,ke++):(t=m,0===Ve&&Je(d));e=t!==m?(r=rt(),r!==m?(n=Xe())!==m?rt()!==m?(125===f.charCodeAt(ke)?(o=v,ke++):(o=m,0===Ve&&Je(h)),o!==m?(Le=e,t=g(n)):(ke=e,m)):(ke=e,m):(ke=e,m):(ke=e,m)):(ke=e,m);Ve--,e===m&&(t=m,0===Ve&&Je(l));return e}())===m&&(e=function(){var e,t,r,n,o,a,u,i,s,c;e=ke,123===f.charCodeAt(ke)?(t=p,ke++):(t=m,0===Ve&&Je(d));e=t!==m?(r=rt(),r!==m?(n=Xe())!==m?rt()!==m?(44===f.charCodeAt(ke)?(o=y,ke++):(o=m,0===Ve&&Je(b)),o!==m?rt()!==m?(f.substr(ke,6)===C?(a=C,ke+=6):(a=m,0===Ve&&Je(F)),a===m&&(f.substr(ke,4)===A?(a=A,ke+=4):(a=m,0===Ve&&Je(O)),a===m&&(f.substr(ke,4)===T?(a=T,ke+=4):(a=m,0===Ve&&Je(x)))),a!==m?rt()!==m?(u=ke,44===f.charCodeAt(ke)?(i=y,ke++):(i=m,0===Ve&&Je(b)),(u=i!==m?(s=rt())!==m?(c=ct())!==m?i=[i,s,c]:(ke=u,m):(ke=u,m):(ke=u,m))===m&&(u=null),u!==m?(i=rt())!==m?(125===f.charCodeAt(ke)?(s=v,ke++):(s=m,0===Ve&&Je(h)),s!==m?(Le=e,t=j(n,a,u)):(ke=e,m)):(ke=e,m):(ke=e,m)):(ke=e,m):(ke=e,m)):(ke=e,m):(ke=e,m)):(ke=e,m):(ke=e,m):(ke=e,m)):(ke=e,m);return e}())===m&&(e=function(){var e,t,r,n,o,a,u,i,s,c,l;e=ke,123===f.charCodeAt(ke)?(t=p,ke++):(t=m,0===Ve&&Je(d));if(t!==m)if(rt()!==m)if((r=Xe())!==m)if(rt()!==m)if(44===f.charCodeAt(ke)?(n=y,ke++):(n=m,0===Ve&&Je(b)),n!==m)if(rt()!==m)if(f.substr(ke,6)===w?(o=w,ke+=6):(o=m,0===Ve&&Je(E)),o===m&&(f.substr(ke,13)===I?(o=I,ke+=13):(o=m,0===Ve&&Je(_))),o!==m)if(rt()!==m)if(44===f.charCodeAt(ke)?(a=y,ke++):(a=m,0===Ve&&Je(b)),a!==m)if(rt()!==m)if(u=ke,f.substr(ke,7)===P?(i=P,ke+=7):(i=m,0===Ve&&Je(M)),(u=i!==m?(s=rt())!==m?(c=at())!==m?i=[i,s,c]:(ke=u,m):(ke=u,m):(ke=u,m))===m&&(u=null),u!==m)if((i=rt())!==m){if(s=[],(c=et())!==m)for(;c!==m;)s.push(c),c=et();else s=m;e=s!==m?(c=rt())!==m?(125===f.charCodeAt(ke)?(l=v,ke++):(l=m,0===Ve&&Je(h)),l!==m?(Le=e,t=N(r,o,u,s)):(ke=e,m)):(ke=e,m):(ke=e,m)}else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;return e}())===m&&(e=function(){var e,t,r,n,o,a,u,i,s;e=ke,123===f.charCodeAt(ke)?(t=p,ke++):(t=m,0===Ve&&Je(d));if(t!==m)if(rt()!==m)if((r=Xe())!==m)if(rt()!==m)if(44===f.charCodeAt(ke)?(n=y,ke++):(n=m,0===Ve&&Je(b)),n!==m)if(rt()!==m)if(f.substr(ke,6)===R?(o=R,ke+=6):(o=m,0===Ve&&Je(D)),o!==m)if(rt()!==m)if(44===f.charCodeAt(ke)?(a=y,ke++):(a=m,0===Ve&&Je(b)),a!==m)if(rt()!==m){if(u=[],(i=Ye())!==m)for(;i!==m;)u.push(i),i=Ye();else u=m;e=u!==m?(i=rt())!==m?(125===f.charCodeAt(ke)?(s=v,ke++):(s=m,0===Ve&&Je(h)),s!==m?(Le=e,t=S(r,u)):(ke=e,m)):(ke=e,m):(ke=e,m)}else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;else ke=e,e=m;return e}()),e}function Xe(){var e,t,r;if((e=at())===m){for(e=ke,t=[],r=ut();r!==m;)t.push(r),r=ut();t!==m&&(Le=e,t=c(t)),e=t}return e}function Ye(){var e,t,r,n,o;return e=ke,e=rt()!==m&&(t=ct())!==m&&rt()!==m?(123===f.charCodeAt(ke)?(r=p,ke++):(r=m,0===Ve&&Je(d)),r!==m&&(n=Ke())!==m?(125===f.charCodeAt(ke)?(o=v,ke++):(o=m,0===Ve&&Je(h)),o!==m?(Le=e,te(t,n)):(ke=e,m)):(ke=e,m)):(ke=e,m)}function et(){var e,t,r,n,o;return e=ke,e=rt()!==m&&(t=function(){var e;return f.substr(ke,2)===k?(e=k,ke+=2):(e=m,0===Ve&&Je(L)),e===m&&(f.substr(ke,2)===q?(e=q,ke+=2):(e=m,0===Ve&&Je(Z)),e===m&&(f.substr(ke,2)===U?(e=U,ke+=2):(e=m,0===Ve&&Je(V)),e===m&&(f.substr(ke,4)===H?(e=H,ke+=4):(e=m,0===Ve&&Je(W)),e===m&&(f.substr(ke,3)===z?(e=z,ke+=3):(e=m,0===Ve&&Je(B)),e===m&&(f.substr(ke,3)===G?(e=G,ke+=3):(e=m,0===Ve&&Je(J)),e===m&&(f.substr(ke,3)===$?(e=$,ke+=3):(e=m,0===Ve&&Je(K)),e===m&&(f.substr(ke,4)===Q?(e=Q,ke+=4):(e=m,0===Ve&&Je(X)),e===m&&(f.substr(ke,5)===Y?(e=Y,ke+=5):(e=m,0===Ve&&Je(ee)))))))))),e}())!==m&&rt()!==m?(123===f.charCodeAt(ke)?(r=p,ke++):(r=m,0===Ve&&Je(d)),r!==m&&(n=Ke())!==m?(125===f.charCodeAt(ke)?(o=v,ke++):(o=m,0===Ve&&Je(h)),o!==m?(Le=e,re(t,n)):(ke=e,m)):(ke=e,m)):(ke=e,m)}function tt(){var e,t;if(Ve++,e=[],oe.test(f.charAt(ke))?(t=f.charAt(ke),ke++):(t=m,0===Ve&&Je(ae)),t!==m)for(;t!==m;)e.push(t),oe.test(f.charAt(ke))?(t=f.charAt(ke),ke++):(t=m,0===Ve&&Je(ae));else e=m;return Ve--,e===m&&(t=m,0===Ve&&Je(ne)),e}function rt(){var e,t,r;for(Ve++,e=ke,t=[],r=tt();r!==m;)t.push(r),r=tt();return e=t!==m?f.substring(e,ke):t,Ve--,e===m&&(t=m,0===Ve&&Je(ue)),e}function nt(){var e;return ie.test(f.charAt(ke))?(e=f.charAt(ke),ke++):(e=m,0===Ve&&Je(se)),e}function ot(){var e;return ce.test(f.charAt(ke))?(e=f.charAt(ke),ke++):(e=m,0===Ve&&Je(le)),e}function at(){var e,t,r;if(e=ke,t=[],(r=nt())!==m)for(;r!==m;)t.push(r),r=nt();else t=m;return t!==m&&(Le=e,t=fe(t)),e=t}function ut(){var e,t,r;return t=e=ke,Ve++,39===f.charCodeAt(ke)?(r=me,ke++):(r=m,0===Ve&&Je(pe)),r===m&&(de.test(f.charAt(ke))?(r=f.charAt(ke),ke++):(r=m,0===Ve&&Je(ve))),Ve--,(e=(t=r===m?void 0:(ke=t,m))!==m?(f.length>ke?(r=f.charAt(ke),ke++):(r=m,0===Ve&&Je(he)),r!==m?(Le=e,t=ge(r)):(ke=e,m)):(ke=e,m))===m&&(e=ke,39===f.charCodeAt(ke)?(t=me,ke++):(t=m,0===Ve&&Je(pe)),e=t!==m&&(r=function(){var e;de.test(f.charAt(ke))?(e=f.charAt(ke),ke++):(e=m,0===Ve&&Je(ve));e===m&&(e=it());return e}())!==m?(Le=e,t=ye(r)):(ke=e,m)),e}function it(){var e;return Ve++,39===f.charCodeAt(ke)?(e=me,ke++):(e=m,0===Ve&&Je(pe)),Ve--,e===m&&0===Ve&&Je(be),e}function st(){var e,t,r,n,o,a,u,i;return e=ke,39===f.charCodeAt(ke)?(t=me,ke++):(t=m,0===Ve&&Je(pe)),(e=t!==m&&(r=it())!==m?(Le=e,t=ye(r)):(ke=e,m))===m&&(Ce.test(f.charAt(ke))?(e=f.charAt(ke),ke++):(e=m,0===Ve&&Je(Fe)),e===m&&(e=ke,f.substr(ke,2)===Ae?(t=Ae,ke+=2):(t=m,0===Ve&&Je(Oe)),t!==m&&(Le=e,t=Te()),(e=t)===m&&(e=ke,f.substr(ke,2)===xe?(t=xe,ke+=2):(t=m,0===Ve&&Je(je)),t!==m&&(Le=e,t=we()),(e=t)===m&&(e=ke,f.substr(ke,2)===Ee?(t=Ee,ke+=2):(t=m,0===Ve&&Je(Ie)),t!==m&&(Le=e,t=_e()),(e=t)===m&&(e=ke,f.substr(ke,2)===Pe?(t=Pe,ke+=2):(t=m,0===Ve&&Je(Me)),t!==m&&(Le=e,t=Ne()),(e=t)===m&&(e=ke,f.substr(ke,2)===Re?(t=Re,ke+=2):(t=m,0===Ve&&Je(De)),e=t!==m?(n=r=ke,(r=(n=(o=ot())!==m&&(a=ot())!==m&&(u=ot())!==m&&(i=ot())!==m?o=[o,a,u,i]:(ke=n,m))!==m?f.substring(r,ke):n)!==m?(Le=e,t=Se(r)):(ke=e,m)):(ke=e,m))))))),e}function ct(){var e,t,r;if(e=ke,t=[],(r=st())!==m)for(;r!==m;)t.push(r),r=st();else t=m;return t!==m&&(Le=e,t=c(t)),e=t}function lt(){return e&&e.captureLocation?{location:Ge(Le,ke)}:{}}if((t=u())!==m&&ke===f.length)return t;throw t!==m&&ke<f.length&&Je({type:"end"}),r=Ue,n=Ze<f.length?f.charAt(Ze):null,o=Ze<f.length?Ge(Ze,Ze+1):Ge(Ze,Ze),new mt(mt.buildMessage(r,n),r,n,o)};function v(e){return 0===e.type}function h(e){return 1===e.type}function g(e){return 2===e.type}function y(e){return 3===e.type}function b(e){return 4===e.type}function C(e){return 5===e.type}function F(e){return 6===e.type}var m=/(^|[^\\])#/g;function i(e){return JSON.stringify(e.map(function(e){return e&&"object"==typeof e?function(r){return Object.keys(r).sort().map(function(e){var t;return(t={})[e]=r[e],t})}(e):e}))}var o,s=function(a,u){return void 0===u&&(u={}),function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=i(t),o=n&&u[n];return o||(o=new((e=a).bind.apply(e,[void 0].concat(t))),n&&(u[n]=o)),o}},r=(o=function(e,t){return(o=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}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),c=function(){return(c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var A=/\\#/g;function O(e,t,r,n,o,a){if(1===e.length&&v(e[0]))return[{type:0,value:e[0].value.replace(A,"#")}];for(var u=[],i=0,s=e;i<s.length;i++){var c=s[i];if(v(c))u.push({type:0,value:c.value.replace(A,"#")});else{var l=c.value;if(!(o&&l in o))throw new T("The intl string context variable '"+l+"' was not provided to the string '"+a+"'");var f=o[l];if(h(c))f&&"string"!=typeof f&&"number"!=typeof f?u.push({type:1,value:f}):u.push({type:0,value:"string"==typeof f||"number"==typeof f?String(f):""});else if(y(c)){var m=c.style?n.date[c.style]:void 0;u.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(b(c)){m=c.style?n.time[c.style]:void 0;u.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(g(c)){m=c.style?n.number[c.style]:void 0;u.push({type:0,value:r.getNumberFormat(t,m).format(f)})}else if(C(c)){if(!(p=c.options[f]||c.options.other))throw new RangeError('Invalid values for "'+c.value+'": "'+f+'". Options are "'+Object.keys(c.options).join('", "')+'"');u.push.apply(u,O(p.value,t,r,n,o))}else if(F(c)){var p;if(!(p=c.options["="+f])){var d=r.getPluralRules(t,{type:c.pluralType}).select(f-(c.offset||0));p=c.options[d]||c.options.other}if(!p)throw new RangeError('Invalid values for "'+c.value+'": "'+f+'". Options are "'+Object.keys(c.options).join('", "')+'"');u.push.apply(u,O(p.value,t,r,n,o))}else;}}return function(e){return e.length<2?e:e.reduce(function(e,t){var r=e[e.length-1];return r&&0===r.type&&0===t.type?r.value+=t.value:e.push(t),e},[])}(u)}function l(r,n){return n?Object.keys(r).reduce(function(e,t){return e[t]=function(r,n){return n?c({},r||{},n||{},Object.keys(r).reduce(function(e,t){return e[t]=c({},r[t],n[t]||{}),e},{})):r}(r[t],n[t]),e},c({},r)):r}var p,T=(p=Error,r(x,p),x);function x(e,t){var r=p.call(this,e)||this;return r.variableId=t,r}var j=(w.prototype.resolvedOptions=function(){return{locale:this.locale}},w.prototype.getAst=function(){return this.ast},w.defaultLocale="en",w.__parse=void 0,w.formats={number:{currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},w);function w(e,t,r,n){var o=this;if(void 0===t&&(t=w.defaultLocale),this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(e){return function(e,t,r,n,o,a){var u=O(e,t,r,n,o,a);return 1===u.length?u[0].value:u.reduce(function(e,t){return e+t.value},"")}(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.formatToParts=function(e){return O(o.ast,o.locale,o.formatters,o.formats,e,o.message)},"string"==typeof e){if(this.message=e,!w.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");this.ast=w.__parse(e)}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=l(w.formats,r),this.locale=function(e){"string"==typeof e&&(e=[e]);try{return Intl.NumberFormat.supportedLocalesOf(e,{localeMatcher:"best fit"})[0]}catch(e){return j.defaultLocale}}(t||[]),this.formatters=n&&n.formatters||function(e){return void 0===e&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:s(Intl.NumberFormat,e.number),getDateTimeFormat:s(Intl.DateTimeFormat,e.dateTime),getPluralRules:s(Intl.PluralRules,e.pluralRules)}}(this.formatterCache),function r(e,n,o,a){e.filter(function(e){return!h(e)&&!v(e)}).forEach(function(t){if(y(t)){var e=t.style?a.date[t.style]:void 0;return o.getDateTimeFormat(n,e)}return b(t)?(e=t.style?a.time[t.style]:void 0,o.getDateTimeFormat(n,e)):g(t)?(e=t.style?a.number[t.style]:void 0,o.getNumberFormat(n,e)):C(t)?Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)}):F(t)?(o.getPluralRules(n,{type:t.pluralType}),Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)})):void 0})}(this.ast,this.locale,this.formatters,this.formats)}var E=require("invariant"),I={38:"&",62:">",60:"<",34:""",39:"'"},_=/[&><"']/g;function P(r,e,n){return void 0===n&&(n={}),e.reduce(function(e,t){return r.hasOwnProperty(t)?e[t]=r[t]:n.hasOwnProperty(t)&&(e[t]=n[t]),e},{})}function M(e){var t=(void 0===e?{}:e).intl;E(t,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}function N(e,t){return"[React Intl] "+e+(t?"\n"+t:"")}var R={formats:{},messages:{},timeZone:void 0,textComponent:d.Fragment,defaultLocale:"en",defaultFormats:{},onError:function(e){"production"!==process.env.NODE_ENV&&console.error(e)}};function D(){return{getDateTimeFormat:s(Intl.DateTimeFormat),getNumberFormat:s(Intl.NumberFormat),getMessageFormat:s(j),getRelativeTimeFormat:s(Intl.RelativeTimeFormat),getPluralRules:s(Intl.PluralRules)}}var S=require("hoist-non-react-statics");var k=d.createContext(null),L=k.Consumer,q=k.Provider,Z=k;function U(n,e){function r(r){return d.createElement(L,null,function(e){var t;return c&&M({intl:e}),d.createElement(n,Object.assign({},r,((t={})[a]=e,t),{ref:i?r.forwardedRef:null}))})}var t=e||{},o=t.intlPropName,a=void 0===o?"intl":o,u=t.forwardRef,i=void 0!==u&&u,s=t.enforceContext,c=void 0===s||s;return r.displayName="injectIntl("+function(e){return e.displayName||e.name||"Component"}(n)+")",r.WrappedComponent=n,S(i?d.forwardRef(function(e,t){return d.createElement(r,Object.assign({},e,{forwardedRef:t}))}):r,n)}function V(i){function e(e){var t=e.value,r=e.children,n=e.intl,o=n[i],a=n.textComponent,u=o(t,e);return"function"==typeof r?r(u):a?d.createElement(a,null,u):u}return e.displayName="formatDate"===i?"FormattedDate":"formatTime"===i?"FormattedTime":"FormattedNumber",{BaseComponent:e,Component:U(e)}}var H=function(e,t){return(H=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 W(e,t){function r(){this.constructor=e}H(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var z=require("invariant"),B=["localeMatcher","formatMatcher","timeZone","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"],G=["localeMatcher","style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"],J=["numeric","style"],$=["localeMatcher","type"];function K(e,t,r,n){var o,a=e&&e[t];if(a&&(o=a[r]),o)return o;n(N("No "+t+" format named: "+r))}function Q(e,t,r,n){var o=e.locale,a=e.formats,u=e.messages,i=e.defaultLocale,s=e.defaultFormats,c=e.onError;void 0===r&&(r={id:""}),void 0===n&&(n={});var l=r.id,f=r.defaultMessage;z(l,"[React Intl] An `id` must be provided to format a message.");var m=u&&u[l];if(!(0<Object.keys(n).length)&&"production"===process.env.NODE_ENV){var p=m||f||l;return"string"==typeof p?function(e){return e.replace(/\\u([\da-fA-F]{4})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}).replace(/\\\{/g,"{").replace(/\\\}/g,"}")}(p):(z(1===p.length&&0===p[0].type,"Message has placeholders but no values was provided"),p[0].value)}var d=[];if(m)try{d=t.getMessageFormat(m,o,a,{formatters:t}).formatToParts(n)}catch(e){c(N('Error formatting message: "'+l+'" for locale: "'+o+'"'+(f?", using default message as fallback.":""),e))}else(!f||o&&o.toLowerCase()!==i.toLowerCase())&&c(N('Missing message: "'+l+'" for locale: "'+o+'"'+(f?", using default message as fallback.":"")));if(!d.length&&f)try{d=t.getMessageFormat(f,i,s).formatToParts(n)}catch(e){c(N('Error formatting the default message for: "'+l+'"',e))}return d.length?1===d.length?d[0].value||f||l:d.map(function(e){return e.value}):(c(N('Cannot format message: "'+l+'", using message '+(m||f?"source":"id")+" as fallback.")),"string"==typeof m?m||f||l:f||l)}var X={formatNumber:function(e,t,r,n){var o=e.locale,a=e.formats,u=e.onError;void 0===n&&(n={});var i=n.format,s=i&&K(a,"number",i,u)||{},c=P(n,G,s);try{return t.getNumberFormat(o,c).format(r)}catch(e){u(N("Error formatting number.",e))}return String(r)},formatDate:function(e,t,r,n){var o=e.locale,a=e.formats,u=e.onError,i=e.timeZone;void 0===n&&(n={});var s=n.format,c=new Date(r),l=Object.assign({},i&&{timeZone:i},s&&K(a,"date",s,u)),f=P(n,B,l);try{return t.getDateTimeFormat(o,f).format(c)}catch(e){u(N("Error formatting date.",e))}return String(c)},formatTime:function(e,t,r,n){var o=e.locale,a=e.formats,u=e.onError,i=e.timeZone;void 0===n&&(n={});var s=n.format,c=new Date(r),l=Object.assign({},i&&{timeZone:i},s&&K(a,"time",s,u)),f=P(n,B,l);f.hour||f.minute||f.second||(f=Object.assign({},f,{hour:"numeric",minute:"numeric"}));try{return t.getDateTimeFormat(o,f).format(c)}catch(e){u(N("Error formatting time.",e))}return String(c)},formatMessage:Q,formatPlural:function(e,t,r,n){var o=e.locale,a=e.onError;void 0===n&&(n={});var u=P(n,$);try{return t.getPluralRules(o,u).select(r)}catch(e){a(N("Error formatting plural.",e))}return"other"},formatHTMLMessage:function(e,t,r,n){return void 0===r&&(r={id:""}),void 0===n&&(n={}),Q(e,t,r,Object.keys(n).reduce(function(e,t){var r=n[t];return e[t]="string"==typeof r?function(e){return(""+e).replace(_,function(e){return I[e.charCodeAt(0)]})}(r):r,e},{}))},formatRelativeTime:function(e,t,r,n,o){var a=e.locale,u=e.formats,i=e.onError;void 0===n&&(n="second"),void 0===o&&(o={});var s=o.format,c=!!s&&K(u,"relative",s,i)||{},l=P(o,J,c);try{return t.getRelativeTimeFormat(a,l).format(r,n)}catch(e){i(N("Error formatting relative time.",e))}return String(r)}},Y=[Intl.DateTimeFormat,Intl.NumberFormat,Intl.PluralRules];var ee,te=require("shallow-equal/objects"),re=["locale","timeZone","formats","messages","textComponent","defaultLocale","defaultFormats","onError"];function ne(e){var t=Object.assign({},R,e);for(var r in R)void 0===t[r]&&(t[r]=R[r]);if(!t.locale||!function(t,e){if(void 0===e&&(e=Y),"undefined"==typeof Intl)return!1;if(!t)throw new Error("locales must be supplied.");Array.isArray(t)||(t=[t]);var r=e.filter(Boolean);return 0!==r.length&&r.every(function(e){return e.supportedLocalesOf(t).length===t.length})}(t.locale)){var n=t.locale,o=t.defaultLocale,a=t.defaultFormats,u=t.onError;"function"==typeof u&&u(N('Missing locale data for locale: "'+n+'". Using default locale: "'+o+'" as fallback.')),t=Object.assign({},t,{locale:o,formats:a,messages:R.messages})}return t}function oe(e,t){return{formatNumber:X.formatNumber.bind(void 0,e,t),formatRelativeTime:X.formatRelativeTime.bind(void 0,e,t),formatDate:X.formatDate.bind(void 0,e,t),formatTime:X.formatTime.bind(void 0,e,t),formatPlural:X.formatPlural.bind(void 0,e,t),formatMessage:X.formatMessage.bind(void 0,e,t),formatHTMLMessage:X.formatHTMLMessage.bind(void 0,e,t)}}function ae(e){var t=ee.call(this,e)||this,r=e.intl,n=(r||{}).formatters,o=void 0===n?D():n;return t.state={context:Object.assign({},r,{formatters:o})},t}var ue=U((W(ae,ee=d.PureComponent),ae.getDerivedStateFromProps=function(e,t){var r=e.intl,n=P(e,re,r||{});if(te(n,t.filteredProps))return null;var o=ne(n),a=oe(o,Object.assign({},t.context.formatters));return{filteredProps:n,context:Object.assign({},t.context,o,a)}},ae.prototype.render=function(){return d.createElement(q,{value:this.state.context},this.props.children)},ae),{enforceContext:!1}),ie=require("invariant"),se=60,ce=3600,le=86400;function fe(e){var t=Math.abs(e);return t<se?"second":t<ce?"minute":t<le?"hour":"day"}function me(e){switch(e){case"second":return 1;case"minute":return se;case"hour":return ce;default:return le}}function pe(e,t){if(!e)return 0;switch(t){case"second":return e;case"minute":return e*se;default:return e*ce}}var de=["second","minute","hour"];function ve(e){return void 0===e&&(e="second"),de.includes(e)}var he,ge=(W(ye,he=d.PureComponent),ye.prototype.scheduleNextUpdate=function(e,t){var r=this,n=e.updateIntervalInSeconds,o=e.unit,a=t.currentValueInSeconds;if(clearTimeout(this._updateTimer),this._updateTimer=null,n&&ve(o)){var u=a-n,i=fe(u);if("day"===i)return this.setState({currentValueInSeconds:u<0?-le:le});var s=me(i),c=u-u%s,l=a<=c?c-s:c,f=Math.abs(l-a);this._updateTimer=setTimeout(function(){return r.setState({currentValueInSeconds:l})},1e3*f)}},ye.prototype.componentDidMount=function(){this.scheduleNextUpdate(this.props,this.state)},ye.prototype.componentDidUpdate=function(){this.scheduleNextUpdate(this.props,this.state)},ye.prototype.componentWillUnmount=function(){clearTimeout(this._updateTimer),this._updateTimer=null},ye.prototype.componentWillReceiveProps=function(e){this.props.value===e.value&&this.props.unit===e.unit||this.setState({currentValueInSeconds:ve(e.unit)?pe(e.value,e.unit):0})},ye.prototype.render=function(){var e=this.props.intl,t=e.formatRelativeTime,r=e.textComponent,n=this.props,o=n.children,a=n.value,u=n.unit,i=n.updateIntervalInSeconds,s=this.state.currentValueInSeconds,c=a||0,l=u;if(ve(u)&&s&&i){var f=me(l=fe(s));c=Math.round(s/f)}var m=t(c,l,Object.assign({},this.props));return"function"==typeof o?o(m):r?d.createElement(r,null,m):m},ye);function ye(e){var t=he.call(this,e)||this;return t._updateTimer=null,t.state={currentValueInSeconds:ve(t.props.unit)?pe(t.props.value,t.props.unit):0},function(e,t){ie(!e||e&&ve(t),"Cannot schedule update with unit longer than hour")}(e.updateIntervalInSeconds,e.unit),t}ge.defaultProps={value:0,unit:"second"};function be(e){var t=e.value,r=e.other,n=e.children,o=e.intl,a=o.formatPlural,u=o.textComponent,i=e[a(t,e)]||r;return"function"==typeof n?n(i):u?d.createElement(u,null,i):i}var Ce=U(ge);be.defaultProps={type:"cardinal"},be.displayName="FormattedPlural";function Fe(e,t){return"production"!==process.env.NODE_ENV&&console.error("[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry. Using default message as fallback."),Q(Object.assign({},R,{locale:"en"}),D(),e,t)}var Ae,Oe=U(be),Te=require("shallow-equal/objects"),xe=(W(je,Ae=d.Component),je.prototype.shouldComponentUpdate=function(e){var t=this.props.values,r=e.values;if(!Te(r,t))return!0;var n=Object.assign({},e,{values:t});return!Te(this.props,n)},je.prototype.render=function(){var e=this.props.intl||{},t=e.formatMessage,r=void 0===t?Fe:t,n=e.textComponent,o=void 0===n?d.Fragment:n,a=this.props,u=a.id,i=a.description,s=a.defaultMessage,c=a.values,l=a.tagName,f=void 0===l?o:l,m=a.children,p=r({id:u,description:i,defaultMessage:s},c);return Array.isArray(p)||(p=[p]),"function"==typeof m?m.apply(void 0,p):f?d.createElement.apply(d,[f,null].concat(p)):p},je);function je(e){var t=Ae.call(this,e)||this;return e.defaultMessage||M(e),t}xe.defaultProps={values:{}};var we,Ee=U(xe,{enforceContext:!1}),Ie=(W(_e,we=xe),_e.prototype.render=function(){var e=this.props.intl,t=e.formatHTMLMessage,r=e.textComponent,n=this.props,o=n.id,a=n.description,u=n.defaultMessage,i=n.values,s=n.tagName,c=void 0===s?r||"span":s,l=n.children,f=t({id:o,description:a,defaultMessage:u},i);if("function"==typeof l)return l(f);var m={__html:f};return d.createElement(c,{dangerouslySetInnerHTML:m})},_e);function _e(){return null!==we&&we.apply(this,arguments)||this}Ie.defaultProps=Object.assign({},xe.defaultProps,{tagName:"span"});var Pe=U(Ie);var Me=V("formatDate").Component,Ne=V("formatTime").Component,Re=V("formatNumber").Component;j.__parse=function(e,t){var r=f(e,t);return t&&!1===t.normalizeHashtagInPlural||function l(e){e.forEach(function(c){F(c)&&Object.keys(c.options).forEach(function(e){for(var t,r=c.options[e],n=-1,o=void 0,a=0;a<r.value.length;a++){var u=r.value[a];if(v(u)&&m.test(u.value)){n=a,o=u;break}}if(o){var i=o.value.replace(m,"$1{"+c.value+", number}"),s=f(i);(t=r.value).splice.apply(t,[n,1].concat(s))}l(r.value)})})}(r),r},e.FormattedDate=Me,e.FormattedHTMLMessage=Pe,e.FormattedMessage=Ee,e.FormattedNumber=Re,e.FormattedPlural=Oe,e.FormattedRelativeTime=Ce,e.FormattedTime=Ne,e.IntlContext=Z,e.IntlProvider=ue,e.defineMessages=function(e){return e},e.generateIntlContext=function(e){var t=D(),r=Object.assign({},R,e);return Object.assign({},r,{formatters:t},oe(r,t))},e.injectIntl=U,e.useIntl=function(){var e=d.useContext(Z);return M({intl:e}),e},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactIntl={},e.React)}(this,function(e,d){"use strict";var ft,t;function v(e){return e.type===ft.literal}function h(e){return e.type===ft.argument}function g(e){return e.type===ft.number}function y(e){return e.type===ft.date}function b(e){return e.type===ft.time}function C(e){return e.type===ft.select}function w(e){return e.type===ft.plural}(t=ft=ft||{})[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural";var n,a,r=(n=function(e,t){return(n=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}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),mt=function(){return(mt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},pt=(a=Error,r(i,a),i.buildMessage=function(e,t){function r(e){return e.charCodeAt(0).toString(16).toUpperCase()}function n(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function a(e){switch(e.type){case"literal":return'"'+n(e.text)+'"';case"class":var t=e.parts.map(function(e){return Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e)});return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var t,r,n=e.map(a);if(n.sort(),0<n.length){for(r=t=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+((i=t)?'"'+n(i)+'"':"end of input")+" found.";var i},i);function i(e,t,r,n){var o=a.call(this)||this;return o.message=e,o.expected=t,o.found=r,o.location=n,o.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o,i),o}var f=function(f,e){e=void 0!==e?e:{};var t,r,n,o,m={},a={start:Je},i=Je,u=function(e){return e.reduce(function(e,t){return e.concat(t)},[]).join("")},s=function(e){return mt({type:ft.literal,value:e},ct())},l=function(e){return e.join("")},c=Be("argumentElement"),p="{",d=Ve("{",!1),v="}",h=Ve("}",!1),g=function(e){return mt({type:ft.argument,value:e},ct())},y=",",b=Ve(",",!1),C="number",w=Ve("number",!1),O="date",F=Ve("date",!1),M="time",T=Ve("time",!1),x=function(e,t,r){return mt({type:"number"===t?ft.number:"date"===t?ft.date:ft.time,style:r&&r[2],value:e},ct())},A="plural",j=Ve("plural",!1),E="selectordinal",I=Ve("selectordinal",!1),_="offset:",P=Ve("offset:",!1),N=function(e,t,r,n){return mt({type:ft.plural,pluralType:"plural"===t?"cardinal":"ordinal",value:e,offset:r?r[2]:0,options:n.reduce(function(e,t){var r=t.id,n=t.value,o=t.location;return e[r]={value:n,location:o},e},{})},ct())},R="select",D=Ve("select",!1),S=function(e,t){return mt({type:ft.select,value:e,options:t.reduce(function(e,t){var r=t.id,n=t.value,o=t.location;return e[r]={value:n,location:o},e},{})},ct())},L="=0",k=Ve("=0",!1),q="=1",Z=Ve("=1",!1),H="=2",U=Ve("=2",!1),V="zero",X=Ve("zero",!1),B="one",W=Ve("one",!1),z="two",G=Ve("two",!1),J="few",$=Ve("few",!1),K="many",Q=Ve("many",!1),Y="other",ee=Ve("other",!1),te=function(e,t){return mt({id:e,value:t},ct())},re=function(e,t){return mt({id:e,value:t},ct())},ne=Be("whitespace"),oe=/^[ \t\n\r]/,ae=Xe([" ","\t","\n","\r"],!1,!1),ie=Be("optionalWhitespace"),ue=/^[0-9]/,se=Xe([["0","9"]],!1,!1),le=/^[0-9a-f]/i,ce=Xe([["0","9"],["a","f"]],!1,!0),fe=function(e){return parseInt(e.join(""),10)},me="'",pe=Ve("'",!1),de=/^[ \t\n\r,.+={}#]/,ve=Xe([" ","\t","\n","\r",",",".","+","=","{","}","#"],!1,!1),he={type:"any"},ge=function(e){return e},ye=function(e){return e},be=Be("apostrophe"),Ce=/^[^{}\\\0-\x1F\x7F \t\n\r]/,we=Xe(["{","}","\\",["\0",""],""," ","\t","\n","\r"],!0,!1),Oe="\\\\",Fe=Ve("\\\\",!1),Me=function(){return"\\"},Te="\\#",xe=Ve("\\#",!1),Ae=function(){return"\\#"},je="\\{",Ee=Ve("\\{",!1),Ie=function(){return"{"},_e="\\}",Pe=Ve("\\}",!1),Ne=function(){return"}"},Re="\\u",De=Ve("\\u",!1),Se=function(e){return String.fromCharCode(parseInt(e,16))},Le=0,ke=0,qe=[{line:1,column:1}],Ze=0,He=[],Ue=0;if(void 0!==e.startRule){if(!(e.startRule in a))throw new Error("Can't start parsing from rule \""+e.startRule+'".');i=a[e.startRule]}function Ve(e,t){return{type:"literal",text:e,ignoreCase:t}}function Xe(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function Be(e){return{type:"other",description:e}}function We(e){var t,r=qe[e];if(r)return r;for(t=e-1;!qe[t];)t--;for(r={line:(r=qe[t]).line,column:r.column};t<e;)10===f.charCodeAt(t)?(r.line++,r.column=1):r.column++,t++;return qe[e]=r}function ze(e,t){var r=We(e),n=We(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function Ge(e){Le<Ze||(Ze<Le&&(Ze=Le,He=[]),He.push(e))}function Je(){return $e()}function $e(){var e,t;for(e=[],t=Ke();t!==m;)e.push(t),t=Ke();return e}function Ke(){var e;return(e=function(){var e,t;e=Le,(t=function(){var e,t,r,n,o,a;t=[],r=e=Le,r=(n=rt())!==m?(o=lt(),o!==m?(a=rt())!==m?n=[n,o,a]:(Le=r,m):(Le=r,m)):(Le=r,m);if(r!==m)for(;r!==m;)t.push(r),r=Le,n=rt(),r=n!==m?(o=lt())!==m?(a=rt())!==m?n=[n,o,a]:(Le=r,m):(Le=r,m):(Le=r,m);else t=m;t!==m&&(ke=e,t=u(t));(e=t)===m&&(e=Le,t=tt(),e=t!==m?f.substring(e,Le):t);return e}())!==m&&(ke=e,t=s(t));return e=t}())===m&&(e=function(){var e,t,r,n,o;Ue++,e=Le,123===f.charCodeAt(Le)?(t=p,Le++):(t=m,0===Ue&&Ge(d));e=t!==m?(r=rt(),r!==m?(n=Qe())!==m?rt()!==m?(125===f.charCodeAt(Le)?(o=v,Le++):(o=m,0===Ue&&Ge(h)),o!==m?(ke=e,t=g(n)):(Le=e,m)):(Le=e,m):(Le=e,m):(Le=e,m)):(Le=e,m);Ue--,e===m&&(t=m,0===Ue&&Ge(c));return e}())===m&&(e=function(){var e,t,r,n,o,a,i,u,s,l;e=Le,123===f.charCodeAt(Le)?(t=p,Le++):(t=m,0===Ue&&Ge(d));e=t!==m?(r=rt(),r!==m?(n=Qe())!==m?rt()!==m?(44===f.charCodeAt(Le)?(o=y,Le++):(o=m,0===Ue&&Ge(b)),o!==m?rt()!==m?(f.substr(Le,6)===C?(a=C,Le+=6):(a=m,0===Ue&&Ge(w)),a===m&&(f.substr(Le,4)===O?(a=O,Le+=4):(a=m,0===Ue&&Ge(F)),a===m&&(f.substr(Le,4)===M?(a=M,Le+=4):(a=m,0===Ue&&Ge(T)))),a!==m?rt()!==m?(i=Le,44===f.charCodeAt(Le)?(u=y,Le++):(u=m,0===Ue&&Ge(b)),(i=u!==m?(s=rt())!==m?(l=lt())!==m?u=[u,s,l]:(Le=i,m):(Le=i,m):(Le=i,m))===m&&(i=null),i!==m?(u=rt())!==m?(125===f.charCodeAt(Le)?(s=v,Le++):(s=m,0===Ue&&Ge(h)),s!==m?(ke=e,t=x(n,a,i)):(Le=e,m)):(Le=e,m):(Le=e,m)):(Le=e,m):(Le=e,m)):(Le=e,m):(Le=e,m)):(Le=e,m):(Le=e,m):(Le=e,m)):(Le=e,m);return e}())===m&&(e=function(){var e,t,r,n,o,a,i,u,s,l,c;e=Le,123===f.charCodeAt(Le)?(t=p,Le++):(t=m,0===Ue&&Ge(d));if(t!==m)if(rt()!==m)if((r=Qe())!==m)if(rt()!==m)if(44===f.charCodeAt(Le)?(n=y,Le++):(n=m,0===Ue&&Ge(b)),n!==m)if(rt()!==m)if(f.substr(Le,6)===A?(o=A,Le+=6):(o=m,0===Ue&&Ge(j)),o===m&&(f.substr(Le,13)===E?(o=E,Le+=13):(o=m,0===Ue&&Ge(I))),o!==m)if(rt()!==m)if(44===f.charCodeAt(Le)?(a=y,Le++):(a=m,0===Ue&&Ge(b)),a!==m)if(rt()!==m)if(i=Le,f.substr(Le,7)===_?(u=_,Le+=7):(u=m,0===Ue&&Ge(P)),(i=u!==m?(s=rt())!==m?(l=at())!==m?u=[u,s,l]:(Le=i,m):(Le=i,m):(Le=i,m))===m&&(i=null),i!==m)if((u=rt())!==m){if(s=[],(l=et())!==m)for(;l!==m;)s.push(l),l=et();else s=m;e=s!==m?(l=rt())!==m?(125===f.charCodeAt(Le)?(c=v,Le++):(c=m,0===Ue&&Ge(h)),c!==m?(ke=e,t=N(r,o,i,s)):(Le=e,m)):(Le=e,m):(Le=e,m)}else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;return e}())===m&&(e=function(){var e,t,r,n,o,a,i,u,s;e=Le,123===f.charCodeAt(Le)?(t=p,Le++):(t=m,0===Ue&&Ge(d));if(t!==m)if(rt()!==m)if((r=Qe())!==m)if(rt()!==m)if(44===f.charCodeAt(Le)?(n=y,Le++):(n=m,0===Ue&&Ge(b)),n!==m)if(rt()!==m)if(f.substr(Le,6)===R?(o=R,Le+=6):(o=m,0===Ue&&Ge(D)),o!==m)if(rt()!==m)if(44===f.charCodeAt(Le)?(a=y,Le++):(a=m,0===Ue&&Ge(b)),a!==m)if(rt()!==m){if(i=[],(u=Ye())!==m)for(;u!==m;)i.push(u),u=Ye();else i=m;e=i!==m?(u=rt())!==m?(125===f.charCodeAt(Le)?(s=v,Le++):(s=m,0===Ue&&Ge(h)),s!==m?(ke=e,t=S(r,i)):(Le=e,m)):(Le=e,m):(Le=e,m)}else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;else Le=e,e=m;return e}()),e}function Qe(){var e,t,r;if((e=at())===m){for(e=Le,t=[],r=it();r!==m;)t.push(r),r=it();t!==m&&(ke=e,t=l(t)),e=t}return e}function Ye(){var e,t,r,n,o;return e=Le,e=rt()!==m&&(t=lt())!==m&&rt()!==m?(123===f.charCodeAt(Le)?(r=p,Le++):(r=m,0===Ue&&Ge(d)),r!==m&&(n=$e())!==m?(125===f.charCodeAt(Le)?(o=v,Le++):(o=m,0===Ue&&Ge(h)),o!==m?(ke=e,te(t,n)):(Le=e,m)):(Le=e,m)):(Le=e,m)}function et(){var e,t,r,n,o;return e=Le,e=rt()!==m&&(t=function(){var e;return f.substr(Le,2)===L?(e=L,Le+=2):(e=m,0===Ue&&Ge(k)),e===m&&(f.substr(Le,2)===q?(e=q,Le+=2):(e=m,0===Ue&&Ge(Z)),e===m&&(f.substr(Le,2)===H?(e=H,Le+=2):(e=m,0===Ue&&Ge(U)),e===m&&(f.substr(Le,4)===V?(e=V,Le+=4):(e=m,0===Ue&&Ge(X)),e===m&&(f.substr(Le,3)===B?(e=B,Le+=3):(e=m,0===Ue&&Ge(W)),e===m&&(f.substr(Le,3)===z?(e=z,Le+=3):(e=m,0===Ue&&Ge(G)),e===m&&(f.substr(Le,3)===J?(e=J,Le+=3):(e=m,0===Ue&&Ge($)),e===m&&(f.substr(Le,4)===K?(e=K,Le+=4):(e=m,0===Ue&&Ge(Q)),e===m&&(f.substr(Le,5)===Y?(e=Y,Le+=5):(e=m,0===Ue&&Ge(ee)))))))))),e}())!==m&&rt()!==m?(123===f.charCodeAt(Le)?(r=p,Le++):(r=m,0===Ue&&Ge(d)),r!==m&&(n=$e())!==m?(125===f.charCodeAt(Le)?(o=v,Le++):(o=m,0===Ue&&Ge(h)),o!==m?(ke=e,re(t,n)):(Le=e,m)):(Le=e,m)):(Le=e,m)}function tt(){var e,t;if(Ue++,e=[],oe.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=m,0===Ue&&Ge(ae)),t!==m)for(;t!==m;)e.push(t),oe.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=m,0===Ue&&Ge(ae));else e=m;return Ue--,e===m&&(t=m,0===Ue&&Ge(ne)),e}function rt(){var e,t,r;for(Ue++,e=Le,t=[],r=tt();r!==m;)t.push(r),r=tt();return e=t!==m?f.substring(e,Le):t,Ue--,e===m&&(t=m,0===Ue&&Ge(ie)),e}function nt(){var e;return ue.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=m,0===Ue&&Ge(se)),e}function ot(){var e;return le.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=m,0===Ue&&Ge(ce)),e}function at(){var e,t,r;if(e=Le,t=[],(r=nt())!==m)for(;r!==m;)t.push(r),r=nt();else t=m;return t!==m&&(ke=e,t=fe(t)),e=t}function it(){var e,t,r;return t=e=Le,Ue++,39===f.charCodeAt(Le)?(r=me,Le++):(r=m,0===Ue&&Ge(pe)),r===m&&(de.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=m,0===Ue&&Ge(ve))),Ue--,(e=(t=r===m?void 0:(Le=t,m))!==m?(f.length>Le?(r=f.charAt(Le),Le++):(r=m,0===Ue&&Ge(he)),r!==m?(ke=e,t=ge(r)):(Le=e,m)):(Le=e,m))===m&&(e=Le,39===f.charCodeAt(Le)?(t=me,Le++):(t=m,0===Ue&&Ge(pe)),e=t!==m&&(r=function(){var e;de.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=m,0===Ue&&Ge(ve));e===m&&(e=ut());return e}())!==m?(ke=e,t=ye(r)):(Le=e,m)),e}function ut(){var e;return Ue++,39===f.charCodeAt(Le)?(e=me,Le++):(e=m,0===Ue&&Ge(pe)),Ue--,e===m&&0===Ue&&Ge(be),e}function st(){var e,t,r,n,o,a,i,u;return e=Le,39===f.charCodeAt(Le)?(t=me,Le++):(t=m,0===Ue&&Ge(pe)),(e=t!==m&&(r=ut())!==m?(ke=e,t=ye(r)):(Le=e,m))===m&&(Ce.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=m,0===Ue&&Ge(we)),e===m&&(e=Le,f.substr(Le,2)===Oe?(t=Oe,Le+=2):(t=m,0===Ue&&Ge(Fe)),t!==m&&(ke=e,t=Me()),(e=t)===m&&(e=Le,f.substr(Le,2)===Te?(t=Te,Le+=2):(t=m,0===Ue&&Ge(xe)),t!==m&&(ke=e,t=Ae()),(e=t)===m&&(e=Le,f.substr(Le,2)===je?(t=je,Le+=2):(t=m,0===Ue&&Ge(Ee)),t!==m&&(ke=e,t=Ie()),(e=t)===m&&(e=Le,f.substr(Le,2)===_e?(t=_e,Le+=2):(t=m,0===Ue&&Ge(Pe)),t!==m&&(ke=e,t=Ne()),(e=t)===m&&(e=Le,f.substr(Le,2)===Re?(t=Re,Le+=2):(t=m,0===Ue&&Ge(De)),e=t!==m?(n=r=Le,(r=(n=(o=ot())!==m&&(a=ot())!==m&&(i=ot())!==m&&(u=ot())!==m?o=[o,a,i,u]:(Le=n,m))!==m?f.substring(r,Le):n)!==m?(ke=e,t=Se(r)):(Le=e,m)):(Le=e,m))))))),e}function lt(){var e,t,r;if(e=Le,t=[],(r=st())!==m)for(;r!==m;)t.push(r),r=st();else t=m;return t!==m&&(ke=e,t=l(t)),e=t}function ct(){return e&&e.captureLocation?{location:ze(ke,Le)}:{}}if((t=i())!==m&&Le===f.length)return t;throw t!==m&&Le<f.length&&Ge({type:"end"}),r=He,n=Ze<f.length?f.charAt(Ze):null,o=Ze<f.length?ze(Ze,Ze+1):ze(Ze,Ze),new pt(pt.buildMessage(r,n),r,n,o)},m=/(^|[^\\])#/g;var o,u,O,s=(o=function(e,t){return(o=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}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),F=/\\#/g,M=(u=Error,s(l,u),l);function l(e,t){var r=u.call(this,e)||this;return r.variableId=t,r}function T(e,t,r,n,o,a){if(1===e.length&&v(e[0]))return[{type:0,value:e[0].value.replace(F,"#")}];for(var i=[],u=0,s=e;u<s.length;u++){var l=s[u];if(v(l))i.push({type:0,value:l.value.replace(F,"#")});else{var c=l.value;if(!(o&&c in o))throw new M("The intl string context variable '"+c+"' was not provided to the string '"+a+"'");var f=o[c];if(h(l))f&&"string"!=typeof f&&"number"!=typeof f?i.push({type:1,value:f}):i.push({type:0,value:"string"==typeof f||"number"==typeof f?String(f):""});else if(y(l)){var m=l.style?n.date[l.style]:void 0;i.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(b(l)){m=l.style?n.time[l.style]:void 0;i.push({type:0,value:r.getDateTimeFormat(t,m).format(f)})}else if(g(l)){m=l.style?n.number[l.style]:void 0;i.push({type:0,value:r.getNumberFormat(t,m).format(f)})}else if(C(l)){if(!(p=l.options[f]||l.options.other))throw new RangeError('Invalid values for "'+l.value+'": "'+f+'". Options are "'+Object.keys(l.options).join('", "')+'"');i.push.apply(i,T(p.value,t,r,n,o))}else if(w(l)){var p;if(!(p=l.options["="+f])){var d=r.getPluralRules(t,{type:l.pluralType}).select(f-(l.offset||0));p=l.options[d]||l.options.other}if(!p)throw new RangeError('Invalid values for "'+l.value+'": "'+f+'". Options are "'+Object.keys(l.options).join('", "')+'"');i.push.apply(i,T(p.value,t,r,n,o))}else;}}return function(e){return e.length<2?e:e.reduce(function(e,t){var r=e[e.length-1];return r&&0===r.type&&0===t.type?r.value+=t.value:e.push(t),e},[])}(i)}function c(e){return JSON.stringify(e.map(function(e){return e&&"object"==typeof e?function(r){return Object.keys(r).sort().map(function(e){var t;return(t={})[e]=r[e],t})}(e):e}))}var p=function(a,i){return void 0===i&&(i={}),function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=c(t),o=n&&i[n];return o||(o=new((e=a).bind.apply(e,[void 0].concat(t))),n&&(i[n]=o)),o}},x=function(){return(x=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function A(r,n){return n?Object.keys(r).reduce(function(e,t){return e[t]=function(r,n){return n?x({},r||{},n||{},Object.keys(r).reduce(function(e,t){return e[t]=x({},r[t],n[t]||{}),e},{})):r}(r[t],n[t]),e},x({},r)):r}var j=(E.defaultLocale="en",E.__parse=void 0,E.formats={number:{currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},E);function E(e,t,r,n){var o=this;if(void 0===t&&(t=E.defaultLocale),this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(e){return function(e,t,r,n,o,a){var i=T(e,t,r,n,o,a);return 1===i.length?i[0].value:i.reduce(function(e,t){return e+t.value},"")}(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.formatToParts=function(e){return T(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.formatXMLMessage=function(e){return function(e,t,r,n,o,a){var i=T(e,t,r,n,o,a).reduce(function(e,t){return e+t.value},"");if(!~i.indexOf("<"))return[i];if(!o)throw new M("Message has placeholders but no values was given");if("undefined"==typeof DOMParser)throw new M("Cannot format XML message without DOMParser");var u=(O=O||new DOMParser).parseFromString("<template>"+i+"</template>","application/xml");if(u.getElementsByTagName("parsererror").length)throw new M("Malformed XML message "+u.getElementsByTagName("parsererror")[0].innerHTML);var s=u.firstChild;if(!s)throw new M("Malformed XML message "+i);if(!Object.keys(o).filter(function(e){return!!u.getElementsByTagName(e).length}).length)return[i];for(var l=[],c=0;c<s.childNodes.length;c++){var f=s.childNodes[c],m=f.tagName;if(m)if(o[m]){var p=o[m];l.push(p(f.textContent||void 0))}else l.push(f.outerHTML);else l.push(f.textContent||"")}return l}(o.ast,o.locale,o.formatters,o.formats,e,o.message)},this.resolvedOptions=function(){return{locale:o.locale}},this.getAst=function(){return o.ast},"string"==typeof e){if(this.message=e,!E.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");this.ast=E.__parse(e)}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=A(E.formats,r),this.locale=function(e){"string"==typeof e&&(e=[e]);try{return Intl.NumberFormat.supportedLocalesOf(e,{localeMatcher:"best fit"})[0]}catch(e){return j.defaultLocale}}(t||[]),this.formatters=n&&n.formatters||function(e){return void 0===e&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:p(Intl.NumberFormat,e.number),getDateTimeFormat:p(Intl.DateTimeFormat,e.dateTime),getPluralRules:p(Intl.PluralRules,e.pluralRules)}}(this.formatterCache),function r(e,n,o,a){e.filter(function(e){return!h(e)&&!v(e)}).forEach(function(t){if(y(t)){var e=t.style?a.date[t.style]:void 0;return o.getDateTimeFormat(n,e)}return b(t)?(e=t.style?a.time[t.style]:void 0,o.getDateTimeFormat(n,e)):g(t)?(e=t.style?a.number[t.style]:void 0,o.getNumberFormat(n,e)):C(t)?Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)}):w(t)?(o.getPluralRules(n,{type:t.pluralType}),Object.keys(t.options).forEach(function(e){return r(t.options[e].value,n,o,a)})):void 0})}(this.ast,this.locale,this.formatters,this.formats)}var I=require("invariant"),_={38:"&",62:">",60:"<",34:""",39:"'"},P=/[&><"']/g;function N(r,e,n){return void 0===n&&(n={}),e.reduce(function(e,t){return r.hasOwnProperty(t)?e[t]=r[t]:n.hasOwnProperty(t)&&(e[t]=n[t]),e},{})}function R(e){var t=(void 0===e?{}:e).intl;I(t,"[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.")}function D(e,t){return"[React Intl] "+e+(t?"\n"+t:"")}var S={formats:{},messages:{},timeZone:void 0,textComponent:d.Fragment,defaultLocale:"en",defaultFormats:{},onError:function(e){"production"!==process.env.NODE_ENV&&console.error(e)}};function L(){return{getDateTimeFormat:p(Intl.DateTimeFormat),getNumberFormat:p(Intl.NumberFormat),getMessageFormat:p(j),getRelativeTimeFormat:p(Intl.RelativeTimeFormat),getPluralRules:p(Intl.PluralRules)}}var k=require("hoist-non-react-statics");var q=d.createContext(null),Z=q.Consumer,H=q.Provider,U=q;function V(n,e){function r(r){return d.createElement(Z,null,function(e){var t;return l&&R({intl:e}),d.createElement(n,Object.assign({},r,((t={})[a]=e,t),{ref:u?r.forwardedRef:null}))})}var t=e||{},o=t.intlPropName,a=void 0===o?"intl":o,i=t.forwardRef,u=void 0!==i&&i,s=t.enforceContext,l=void 0===s||s;return r.displayName="injectIntl("+function(e){return e.displayName||e.name||"Component"}(n)+")",r.WrappedComponent=n,k(u?d.forwardRef(function(e,t){return d.createElement(r,Object.assign({},e,{forwardedRef:t}))}):r,n)}function X(u){function e(e){var t=e.value,r=e.children,n=e.intl,o=n[u],a=n.textComponent,i=o(t,e);return"function"==typeof r?r(i):a?d.createElement(a,null,i):i}return e.displayName="formatDate"===u?"FormattedDate":"formatTime"===u?"FormattedTime":"FormattedNumber",{BaseComponent:e,Component:V(e)}}var B=function(e,t){return(B=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 W(e,t){function r(){this.constructor=e}B(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var z=require("invariant"),G=["localeMatcher","formatMatcher","timeZone","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"],J=["localeMatcher","style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"],$=["numeric","style"],K=["localeMatcher","type"];function Q(e,t,r,n){var o,a=e&&e[t];if(a&&(o=a[r]),o)return o;n(D("No "+t+" format named: "+r))}function Y(e,t,r,n){var o=e.locale,a=e.formats,i=e.messages,u=e.defaultLocale,s=e.defaultFormats,l=e.onError;void 0===r&&(r={id:""}),void 0===n&&(n={});var c=r.id,f=r.defaultMessage;z(c,"[React Intl] An `id` must be provided to format a message.");var m=i&&i[c];if(!(0<Object.keys(n).length)&&"production"===process.env.NODE_ENV){var p=m||f||c;return"string"==typeof p?function(e){return e.replace(/\\u([\da-fA-F]{4})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}).replace(/\\\{/g,"{").replace(/\\\}/g,"}")}(p):(z(1===p.length&&p[0].type===ft.literal,"Message has placeholders but no values was provided"),p[0].value)}var d=[];if(m)try{d=t.getMessageFormat(m,o,a,{formatters:t}).formatXMLMessage(n)}catch(e){l(D('Error formatting message: "'+c+'" for locale: "'+o+'"'+(f?", using default message as fallback.":""),e))}else(!f||o&&o.toLowerCase()!==u.toLowerCase())&&l(D('Missing message: "'+c+'" for locale: "'+o+'"'+(f?", using default message as fallback.":"")));if(!d.length&&f)try{d=t.getMessageFormat(f,u,s).formatXMLMessage(n)}catch(e){l(D('Error formatting the default message for: "'+c+'"',e))}return d.length?1===d.length&&"string"==typeof d[0]?d[0]||f||c:d:(l(D('Cannot format message: "'+c+'", using message '+(m||f?"source":"id")+" as fallback.")),"string"==typeof m?m||f||c:f||c)}var ee={formatNumber:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError;void 0===n&&(n={});var u=n.format,s=u&&Q(a,"number",u,i)||{},l=N(n,J,s);try{return t.getNumberFormat(o,l).format(r)}catch(e){i(D("Error formatting number.",e))}return String(r)},formatDate:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError,u=e.timeZone;void 0===n&&(n={});var s=n.format,l=new Date(r),c=Object.assign({},u&&{timeZone:u},s&&Q(a,"date",s,i)),f=N(n,G,c);try{return t.getDateTimeFormat(o,f).format(l)}catch(e){i(D("Error formatting date.",e))}return String(l)},formatTime:function(e,t,r,n){var o=e.locale,a=e.formats,i=e.onError,u=e.timeZone;void 0===n&&(n={});var s=n.format,l=new Date(r),c=Object.assign({},u&&{timeZone:u},s&&Q(a,"time",s,i)),f=N(n,G,c);f.hour||f.minute||f.second||(f=Object.assign({},f,{hour:"numeric",minute:"numeric"}));try{return t.getDateTimeFormat(o,f).format(l)}catch(e){i(D("Error formatting time.",e))}return String(l)},formatMessage:Y,formatPlural:function(e,t,r,n){var o=e.locale,a=e.onError;void 0===n&&(n={});var i=N(n,K);try{return t.getPluralRules(o,i).select(r)}catch(e){a(D("Error formatting plural.",e))}return"other"},formatHTMLMessage:function(e,t,r,n){return void 0===r&&(r={id:""}),void 0===n&&(n={}),Y(e,t,r,Object.keys(n).reduce(function(e,t){var r=n[t];return e[t]="string"==typeof r?function(e){return(""+e).replace(P,function(e){return _[e.charCodeAt(0)]})}(r):r,e},{}))},formatRelativeTime:function(e,t,r,n,o){var a=e.locale,i=e.formats,u=e.onError;void 0===n&&(n="second"),void 0===o&&(o={});var s=o.format,l=!!s&&Q(i,"relative",s,u)||{},c=N(o,$,l);try{return t.getRelativeTimeFormat(a,c).format(r,n)}catch(e){u(D("Error formatting relative time.",e))}return String(r)}},te=[Intl.DateTimeFormat,Intl.NumberFormat,Intl.PluralRules];var re,ne=require("shallow-equal/objects"),oe=["locale","timeZone","formats","messages","textComponent","defaultLocale","defaultFormats","onError"];function ae(e){var t=Object.assign({},S,e);for(var r in S)void 0===t[r]&&(t[r]=S[r]);if(!t.locale||!function(t,e){if(void 0===e&&(e=te),"undefined"==typeof Intl)return!1;if(!t)throw new Error("locales must be supplied.");Array.isArray(t)||(t=[t]);var r=e.filter(Boolean);return 0!==r.length&&r.every(function(e){return e.supportedLocalesOf(t).length===t.length})}(t.locale)){var n=t.locale,o=t.defaultLocale,a=t.defaultFormats,i=t.onError;"function"==typeof i&&i(D('Missing locale data for locale: "'+n+'". Using default locale: "'+o+'" as fallback.')),t=Object.assign({},t,{locale:o,formats:a,messages:S.messages})}return t}function ie(e,t){return{formatNumber:ee.formatNumber.bind(void 0,e,t),formatRelativeTime:ee.formatRelativeTime.bind(void 0,e,t),formatDate:ee.formatDate.bind(void 0,e,t),formatTime:ee.formatTime.bind(void 0,e,t),formatPlural:ee.formatPlural.bind(void 0,e,t),formatMessage:ee.formatMessage.bind(void 0,e,t),formatHTMLMessage:ee.formatHTMLMessage.bind(void 0,e,t)}}function ue(e){var t=re.call(this,e)||this,r=e.intl,n=(r||{}).formatters,o=void 0===n?L():n;return t.state={context:Object.assign({},r,{formatters:o})},t}var se=V((W(ue,re=d.PureComponent),ue.getDerivedStateFromProps=function(e,t){var r=e.intl,n=N(e,oe,r||{});if(ne(n,t.filteredProps))return null;var o=ae(n),a=ie(o,Object.assign({},t.context.formatters));return{filteredProps:n,context:Object.assign({},t.context,o,a)}},ue.prototype.render=function(){return d.createElement(H,{value:this.state.context},this.props.children)},ue),{enforceContext:!1}),le=require("invariant"),ce=60,fe=3600,me=86400;function pe(e){var t=Math.abs(e);return t<ce?"second":t<fe?"minute":t<me?"hour":"day"}function de(e){switch(e){case"second":return 1;case"minute":return ce;case"hour":return fe;default:return me}}function ve(e,t){if(!e)return 0;switch(t){case"second":return e;case"minute":return e*ce;default:return e*fe}}var he=["second","minute","hour"];function ge(e){return void 0===e&&(e="second"),he.includes(e)}var ye,be=(W(Ce,ye=d.PureComponent),Ce.prototype.scheduleNextUpdate=function(e,t){var r=this,n=e.updateIntervalInSeconds,o=e.unit,a=t.currentValueInSeconds;if(clearTimeout(this._updateTimer),this._updateTimer=null,n&&ge(o)){var i=a-n,u=pe(i);if("day"===u)return this.setState({currentValueInSeconds:i<0?-me:me});var s=de(u),l=i-i%s,c=a<=l?l-s:l,f=Math.abs(c-a);this._updateTimer=setTimeout(function(){return r.setState({currentValueInSeconds:c})},1e3*f)}},Ce.prototype.componentDidMount=function(){this.scheduleNextUpdate(this.props,this.state)},Ce.prototype.componentDidUpdate=function(){this.scheduleNextUpdate(this.props,this.state)},Ce.prototype.componentWillUnmount=function(){clearTimeout(this._updateTimer),this._updateTimer=null},Ce.prototype.componentWillReceiveProps=function(e){this.props.value===e.value&&this.props.unit===e.unit||this.setState({currentValueInSeconds:ge(e.unit)?ve(e.value,e.unit):0})},Ce.prototype.render=function(){var e=this.props.intl,t=e.formatRelativeTime,r=e.textComponent,n=this.props,o=n.children,a=n.value,i=n.unit,u=n.updateIntervalInSeconds,s=this.state.currentValueInSeconds,l=a||0,c=i;if(ge(i)&&s&&u){var f=de(c=pe(s));l=Math.round(s/f)}var m=t(l,c,Object.assign({},this.props));return"function"==typeof o?o(m):r?d.createElement(r,null,m):m},Ce);function Ce(e){var t=ye.call(this,e)||this;return t._updateTimer=null,t.state={currentValueInSeconds:ge(t.props.unit)?ve(t.props.value,t.props.unit):0},function(e,t){le(!e||e&&ge(t),"Cannot schedule update with unit longer than hour")}(e.updateIntervalInSeconds,e.unit),t}be.defaultProps={value:0,unit:"second"};function we(e){var t=e.value,r=e.other,n=e.children,o=e.intl,a=o.formatPlural,i=o.textComponent,u=e[a(t,e)]||r;return"function"==typeof n?n(u):i?d.createElement(i,null,u):u}var Oe=V(be);we.defaultProps={type:"cardinal"},we.displayName="FormattedPlural";function Fe(e,t){return"production"!==process.env.NODE_ENV&&console.error("[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry. Using default message as fallback."),Y(Object.assign({},S,{locale:"en"}),L(),e,t)}var Me,Te=V(we),xe=require("shallow-equal/objects"),Ae=(W(je,Me=d.Component),je.prototype.shouldComponentUpdate=function(e){var t=this.props.values,r=e.values;if(!xe(r,t))return!0;var n=Object.assign({},e,{values:t});return!xe(this.props,n)},je.prototype.render=function(){var e=this.props.intl||{},t=e.formatMessage,r=void 0===t?Fe:t,n=e.textComponent,o=void 0===n?d.Fragment:n,a=this.props,i=a.id,u=a.description,s=a.defaultMessage,l=a.values,c=a.tagName,f=void 0===c?o:c,m=a.children,p=r({id:i,description:u,defaultMessage:s},l);return Array.isArray(p)||(p=[p]),"function"==typeof m?m.apply(void 0,p):f?d.createElement.apply(d,[f,null].concat(p)):p},je);function je(e){var t=Me.call(this,e)||this;return e.defaultMessage||R(e),t}Ae.defaultProps={values:{}};var Ee,Ie=V(Ae,{enforceContext:!1}),_e=(W(Pe,Ee=Ae),Pe.prototype.render=function(){var e=this.props.intl,t=e.formatHTMLMessage,r=e.textComponent,n=this.props,o=n.id,a=n.description,i=n.defaultMessage,u=n.values,s=n.tagName,l=void 0===s?r||"span":s,c=n.children,f=t({id:o,description:a,defaultMessage:i},u);if("function"==typeof c)return c(f);var m={__html:f};return d.createElement(l,{dangerouslySetInnerHTML:m})},Pe);function Pe(){return null!==Ee&&Ee.apply(this,arguments)||this}_e.defaultProps=Object.assign({},Ae.defaultProps,{tagName:"span"});var Ne=V(_e);var Re=X("formatDate").Component,De=X("formatTime").Component,Se=X("formatNumber").Component;j.__parse=function(e,t){var r=f(e,t);return t&&!1===t.normalizeHashtagInPlural||function c(e){e.forEach(function(l){w(l)&&Object.keys(l.options).forEach(function(e){for(var t,r=l.options[e],n=-1,o=void 0,a=0;a<r.value.length;a++){var i=r.value[a];if(v(i)&&m.test(i.value)){n=a,o=i;break}}if(o){var u=o.value.replace(m,"$1{"+l.value+", number}"),s=f(u);(t=r.value).splice.apply(t,[n,1].concat(s))}c(r.value)})})}(r),r},e.FormattedDate=Re,e.FormattedHTMLMessage=Ne,e.FormattedMessage=Ie,e.FormattedNumber=Se,e.FormattedPlural=Te,e.FormattedRelativeTime=Oe,e.FormattedTime=De,e.IntlContext=U,e.IntlProvider=se,e.defineMessages=function(e){return e},e.generateIntlContext=function(e){var t=L(),r=Object.assign({},S,e);return Object.assign({},r,{formatters:t},ie(r,t))},e.injectIntl=V,e.useIntl=function(){var e=d.useContext(U);return R({intl:e}),e},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=react-intl.min.js.map |
import * as React from 'react'; | ||
import { IntlMessageFormat, Formats } from 'intl-messageformat/core'; | ||
import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn } from 'intl-messageformat/core'; | ||
import IntlRelativeTimeFormat, { IntlRelativeTimeFormatOptions, FormattableUnit } from '@formatjs/intl-relativetimeformat'; | ||
@@ -25,12 +25,11 @@ import { MessageFormatElement } from 'intl-messageformat-parser'; | ||
export declare type FormatPluralOptions = Exclude<Intl.PluralRulesOptions, 'localeMatcher'> & CustomFormatConfig; | ||
export declare type MessageFormatPrimitiveValue = string | number | boolean | null | undefined; | ||
export interface IntlFormatters { | ||
formatDate(value: number | Date, opts: FormatDateOptions): string; | ||
formatTime(value: number | Date, opts: FormatDateOptions): string; | ||
formatDate(value: string | number | Date, opts: FormatDateOptions): string; | ||
formatTime(value: string | number | Date, opts: FormatDateOptions): string; | ||
formatRelativeTime(value: number, unit?: FormattableUnit, opts?: FormatRelativeTimeOptions): string; | ||
formatNumber(value: number, opts: FormatNumberOptions): string; | ||
formatPlural(value: number, opts: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue | React.ReactElement>): string | React.ReactNodeArray; | ||
formatHTMLMessage(descriptor: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn>): string | React.ReactNodeArray; | ||
formatHTMLMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string; | ||
} | ||
@@ -37,0 +36,0 @@ export interface Formatters { |
import * as React from 'react'; | ||
import { BaseFormattedMessage } from './message'; | ||
import { MessageFormatPrimitiveValue } from '../types'; | ||
declare class FormattedHTMLMessage extends BaseFormattedMessage<MessageFormatPrimitiveValue> { | ||
import { PrimitiveType } from 'intl-messageformat/core'; | ||
declare class FormattedHTMLMessage extends BaseFormattedMessage<PrimitiveType> { | ||
static defaultProps: { | ||
@@ -12,7 +12,7 @@ tagName: "span"; | ||
export declare const BaseFormattedHTMLMessage: typeof FormattedHTMLMessage; | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<import("./message").Props<string | number | boolean | null | undefined>>, any> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<string | number | boolean | null | undefined>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<import("./message").Props<string | number | boolean | null | undefined>>> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<string | number | boolean | null | undefined>>; | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<import("./message").Props<PrimitiveType>>, any> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<PrimitiveType>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<import("./message").Props<PrimitiveType>>> & { | ||
WrappedComponent: React.ComponentType<import("./message").Props<PrimitiveType>>; | ||
}); | ||
export default _default; |
import * as React from 'react'; | ||
import { MessageDescriptor, IntlShape, MessageFormatPrimitiveValue } from '../types'; | ||
import { MessageDescriptor, IntlShape } from '../types'; | ||
import { PrimitiveType, FormatXMLElementFn } from 'intl-messageformat/core'; | ||
export interface Props<V extends React.ReactNode = React.ReactNode> extends MessageDescriptor { | ||
@@ -9,3 +10,3 @@ intl: IntlShape; | ||
} | ||
export declare class BaseFormattedMessage<V extends MessageFormatPrimitiveValue | React.ReactElement = MessageFormatPrimitiveValue | React.ReactElement> extends React.Component<Props<V>> { | ||
export declare class BaseFormattedMessage<V extends PrimitiveType | FormatXMLElementFn = PrimitiveType | FormatXMLElementFn> extends React.Component<Props<V>> { | ||
static defaultProps: { | ||
@@ -18,7 +19,7 @@ values: {}; | ||
} | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>, any> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | null | undefined>>; | ||
declare const _default: (React.ComponentClass<import("./injectIntl").WithIntlProps<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>, any> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>; | ||
}) | (React.FunctionComponent<import("./injectIntl").WithIntlProps<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>> & { | ||
WrappedComponent: React.ComponentType<Props<string | number | boolean | FormatXMLElementFn | null | undefined>>; | ||
}); | ||
export default _default; |
@@ -7,15 +7,15 @@ export * from './types'; | ||
export declare const FormattedDate: (import("react").ComponentClass<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>, any> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>; | ||
}) | (import("react").FunctionComponent<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
@@ -25,15 +25,15 @@ }>; | ||
export declare const FormattedTime: (import("react").ComponentClass<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>, any> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>; | ||
}) | (import("react").FunctionComponent<import("./components/injectIntl").WithIntlProps<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
}>> & { | ||
WrappedComponent: import("react").ComponentType<Intl.DateTimeFormatOptions & import("./types").CustomFormatConfig & { | ||
value: number | Date; | ||
value: string | number | Date; | ||
intl: import("./types").IntlShape; | ||
@@ -40,0 +40,0 @@ }>; |
@@ -1,3 +0,4 @@ | ||
import { Formatters, IntlConfig, FormatDateOptions, FormatRelativeTimeOptions, FormatNumberOptions, FormatPluralOptions, MessageDescriptor, MessageFormatPrimitiveValue } from './types'; | ||
import { Formatters, IntlConfig, FormatDateOptions, FormatRelativeTimeOptions, FormatNumberOptions, FormatPluralOptions, MessageDescriptor } from './types'; | ||
import { FormattableUnit } from '@formatjs/intl-relativetimeformat'; | ||
import { PrimitiveType } from 'intl-messageformat/core'; | ||
export declare function formatDate({ locale, formats, onError, timeZone, }: Pick<IntlConfig, 'locale' | 'formats' | 'onError' | 'timeZone'>, state: Formatters, value: number | Date, options?: FormatDateOptions): string; | ||
@@ -8,4 +9,4 @@ export declare function formatTime({ locale, formats, onError, timeZone, }: Pick<IntlConfig, 'locale' | 'formats' | 'onError' | 'timeZone'>, state: Formatters, value: number, options?: FormatDateOptions): string; | ||
export declare function formatPlural({ locale, onError }: Pick<IntlConfig, 'locale' | 'onError'>, state: Formatters, value: number, options?: FormatPluralOptions): string; | ||
export declare function formatMessage({ locale, formats, messages, defaultLocale, defaultFormats, onError, }: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue>): string; | ||
export declare function formatHTMLMessage(config: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, rawValues?: Record<string, MessageFormatPrimitiveValue>): string; | ||
export declare function formatMessage({ locale, formats, messages, defaultLocale, defaultFormats, onError, }: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, values?: Record<string, PrimitiveType>): string; | ||
export declare function formatHTMLMessage(config: Pick<IntlConfig, 'locale' | 'formats' | 'messages' | 'defaultLocale' | 'defaultFormats' | 'onError'>, state: Formatters, messageDescriptor?: MessageDescriptor, rawValues?: Record<string, PrimitiveType>): string; | ||
export declare const formatters: { | ||
@@ -12,0 +13,0 @@ formatNumber: typeof formatNumber; |
@@ -8,2 +8,3 @@ /* | ||
import { createError, escape, filterProps } from './utils'; | ||
import { TYPE } from 'intl-messageformat-parser'; | ||
const DATE_TIME_FORMAT_OPTIONS = [ | ||
@@ -146,3 +147,3 @@ 'localeMatcher', | ||
} | ||
invariant(val.length === 1 && val[0].type === 0 /* literal */, 'Message has placeholders but no values was provided'); | ||
invariant(val.length === 1 && val[0].type === TYPE.literal, 'Message has placeholders but no values was provided'); | ||
return val[0].value; | ||
@@ -156,3 +157,3 @@ } | ||
}); | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} | ||
@@ -177,3 +178,3 @@ catch (e) { | ||
let formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats); | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} | ||
@@ -192,5 +193,7 @@ catch (e) { | ||
} | ||
return formattedMessageParts.length === 1 | ||
? formattedMessageParts[0].value || defaultMessage || id | ||
: formattedMessageParts.map(part => part.value); | ||
if (formattedMessageParts.length === 1 && | ||
typeof formattedMessageParts[0] === 'string') { | ||
return formattedMessageParts[0] || defaultMessage || id; | ||
} | ||
return formattedMessageParts; | ||
} | ||
@@ -197,0 +200,0 @@ export function formatHTMLMessage(config, state, messageDescriptor = { id: '' }, rawValues = {}) { |
import * as React from 'react'; | ||
import { IntlMessageFormat, Formats } from 'intl-messageformat/core'; | ||
import { IntlMessageFormat, Formats, PrimitiveType, FormatXMLElementFn } from 'intl-messageformat/core'; | ||
import IntlRelativeTimeFormat, { IntlRelativeTimeFormatOptions, FormattableUnit } from '@formatjs/intl-relativetimeformat'; | ||
@@ -25,12 +25,11 @@ import { MessageFormatElement } from 'intl-messageformat-parser'; | ||
export declare type FormatPluralOptions = Exclude<Intl.PluralRulesOptions, 'localeMatcher'> & CustomFormatConfig; | ||
export declare type MessageFormatPrimitiveValue = string | number | boolean | null | undefined; | ||
export interface IntlFormatters { | ||
formatDate(value: number | Date, opts: FormatDateOptions): string; | ||
formatTime(value: number | Date, opts: FormatDateOptions): string; | ||
formatDate(value: string | number | Date, opts: FormatDateOptions): string; | ||
formatTime(value: string | number | Date, opts: FormatDateOptions): string; | ||
formatRelativeTime(value: number, unit?: FormattableUnit, opts?: FormatRelativeTimeOptions): string; | ||
formatNumber(value: number, opts: FormatNumberOptions): string; | ||
formatPlural(value: number, opts: FormatPluralOptions): ReturnType<Intl.PluralRules['select']>; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue | React.ReactElement>): string | React.ReactNodeArray; | ||
formatHTMLMessage(descriptor: MessageDescriptor, values?: Record<string, MessageFormatPrimitiveValue>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string; | ||
formatMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType | FormatXMLElementFn>): string | React.ReactNodeArray; | ||
formatHTMLMessage(descriptor: MessageDescriptor, values?: Record<string, PrimitiveType>): string; | ||
} | ||
@@ -37,0 +36,0 @@ export interface Formatters { |
{ | ||
"name": "react-intl", | ||
"version": "3.0.0-beta.18", | ||
"version": "3.0.0-beta.19", | ||
"description": "Internationalize React apps. This library provides React components and an API to format dates, numbers, and strings, including pluralization and handling translations.", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@formatjs/intl-relativetimeformat": "^2.4.0", | ||
"@formatjs/intl-relativetimeformat": "^2.4.2", | ||
"@types/hoist-non-react-statics": "^3.3.1", | ||
@@ -45,6 +45,6 @@ "@types/invariant": "^2.2.30", | ||
"hoist-non-react-statics": "^3.3.0", | ||
"intl-format-cache": "^4.1.0", | ||
"intl-locales-supported": "^1.4.0", | ||
"intl-messageformat": "^5.1.0", | ||
"intl-messageformat-parser": "^2.1.0", | ||
"intl-format-cache": "^4.1.2", | ||
"intl-locales-supported": "^1.4.2", | ||
"intl-messageformat": "^5.2.0", | ||
"intl-messageformat-parser": "^2.1.3", | ||
"invariant": "^2.1.1", | ||
@@ -55,20 +55,20 @@ "react": "^16.3.0", | ||
"devDependencies": { | ||
"@babel/cli": "^7.5.0", | ||
"@babel/core": "^7.5.4", | ||
"@babel/node": "^7.5.0", | ||
"@babel/plugin-proposal-class-properties": "^7.5.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.5.4", | ||
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/node": "^7.5.5", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.5.5", | ||
"@babel/plugin-transform-async-to-generator": "^7.5.0", | ||
"@babel/plugin-transform-modules-commonjs": "^7.5.0", | ||
"@babel/preset-env": "^7.5.4", | ||
"@babel/preset-env": "^7.5.5", | ||
"@babel/preset-react": "^7.0.0", | ||
"@types/benchmark": "^1.0.31", | ||
"@types/enzyme": "^3.10.2", | ||
"@types/enzyme": "^3.10.3", | ||
"@types/jest": "^24.0.13", | ||
"@types/prop-types": "^15.7.1", | ||
"@types/react-dom": "^16.8.4", | ||
"@typescript-eslint/eslint-plugin": "^1.12.0", | ||
"@typescript-eslint/parser": "^1.12.0", | ||
"@types/react-dom": "^16.8.5", | ||
"@typescript-eslint/eslint-plugin": "^1.13.0", | ||
"@typescript-eslint/parser": "^1.13.0", | ||
"babel-jest": "^24.8.0", | ||
"babel-plugin-react-intl": "^4.1.0", | ||
"babel-plugin-react-intl": "^4.1.3", | ||
"babel-plugin-transform-member-expression-literals": "^6.9.4", | ||
@@ -84,4 +84,4 @@ "babel-plugin-transform-property-literals": "^6.9.4", | ||
"enzyme-adapter-react-16": "^1.5.0", | ||
"eslint": "^6.0.0", | ||
"eslint-plugin-react": "^7.0.1", | ||
"eslint": "^6.1.0", | ||
"eslint-plugin-react": "^7.14.3", | ||
"express": "^4.13.3", | ||
@@ -103,3 +103,3 @@ "fs-extra": "^8.1.0", | ||
"rimraf": "^2.4.2", | ||
"rollup": "^1.16.7", | ||
"rollup": "^1.17.0", | ||
"rollup-plugin-commonjs": "^10.0.1", | ||
@@ -106,0 +106,0 @@ "rollup-plugin-node-resolve": "^5.2.0", |
@@ -24,3 +24,2 @@ /* | ||
MessageDescriptor, | ||
MessageFormatPrimitiveValue, | ||
} from './types'; | ||
@@ -34,3 +33,3 @@ | ||
import {LiteralElement, TYPE} from 'intl-messageformat-parser'; | ||
import {MessageFormatPart} from 'intl-messageformat/core'; | ||
import {FormatXMLElementFn, PrimitiveType} from 'intl-messageformat/core'; | ||
@@ -272,3 +271,3 @@ const DATE_TIME_FORMAT_OPTIONS: Array<keyof Intl.DateTimeFormatOptions> = [ | ||
messageDescriptor?: MessageDescriptor, | ||
values?: Record<string, MessageFormatPrimitiveValue> | ||
values?: Record<string, PrimitiveType> | ||
): string; | ||
@@ -294,3 +293,3 @@ export function formatMessage( | ||
messageDescriptor: MessageDescriptor = {id: ''}, | ||
values: Record<string, MessageFormatPrimitiveValue | React.ReactElement> = {} | ||
values: Record<string, PrimitiveType | FormatXMLElementFn> = {} | ||
): string | React.ReactNodeArray { | ||
@@ -319,3 +318,3 @@ const {id, defaultMessage} = messageDescriptor; | ||
let formattedMessageParts: MessageFormatPart[] = []; | ||
let formattedMessageParts: Array<string | object> = []; | ||
@@ -328,3 +327,3 @@ if (message) { | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} catch (e) { | ||
@@ -364,3 +363,3 @@ onError( | ||
formattedMessageParts = formatter.formatToParts(values); | ||
formattedMessageParts = formatter.formatXMLMessage(values); | ||
} catch (e) { | ||
@@ -387,5 +386,9 @@ onError( | ||
} | ||
return formattedMessageParts.length === 1 | ||
? formattedMessageParts[0].value || defaultMessage || id | ||
: formattedMessageParts.map(part => part.value); | ||
if ( | ||
formattedMessageParts.length === 1 && | ||
typeof formattedMessageParts[0] === 'string' | ||
) { | ||
return (formattedMessageParts[0] as string) || defaultMessage || id; | ||
} | ||
return formattedMessageParts; | ||
} | ||
@@ -405,3 +408,3 @@ | ||
messageDescriptor: MessageDescriptor = {id: ''}, | ||
rawValues: Record<string, MessageFormatPrimitiveValue> = {} | ||
rawValues: Record<string, PrimitiveType> = {} | ||
) { | ||
@@ -408,0 +411,0 @@ // Process all the values before they are used when formatting the ICU |
@@ -7,3 +7,8 @@ /* | ||
import * as React from 'react'; | ||
import {IntlMessageFormat, Formats} from 'intl-messageformat/core'; | ||
import { | ||
IntlMessageFormat, | ||
Formats, | ||
PrimitiveType, | ||
FormatXMLElementFn, | ||
} from 'intl-messageformat/core'; | ||
import IntlRelativeTimeFormat, { | ||
@@ -55,12 +60,5 @@ IntlRelativeTimeFormatOptions, | ||
export type MessageFormatPrimitiveValue = | ||
| string | ||
| number | ||
| boolean | ||
| null | ||
| undefined; | ||
export interface IntlFormatters { | ||
formatDate(value: number | Date, opts: FormatDateOptions): string; | ||
formatTime(value: number | Date, opts: FormatDateOptions): string; | ||
formatDate(value: string | number | Date, opts: FormatDateOptions): string; | ||
formatTime(value: string | number | Date, opts: FormatDateOptions): string; | ||
formatRelativeTime( | ||
@@ -78,11 +76,11 @@ value: number, | ||
descriptor: MessageDescriptor, | ||
values?: Record<string, MessageFormatPrimitiveValue> | ||
values?: Record<string, PrimitiveType> | ||
): string; | ||
formatMessage( | ||
descriptor: MessageDescriptor, | ||
values?: Record<string, MessageFormatPrimitiveValue | React.ReactElement> | ||
values?: Record<string, PrimitiveType | FormatXMLElementFn> | ||
): string | React.ReactNodeArray; | ||
formatHTMLMessage( | ||
descriptor: MessageDescriptor, | ||
values?: Record<string, MessageFormatPrimitiveValue> | ||
values?: Record<string, PrimitiveType> | ||
): string; | ||
@@ -89,0 +87,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1173565
8557