Socket
Socket
Sign inDemoInstall

intl-messageformat-parser

Package Overview
Dependencies
Maintainers
4
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-messageformat-parser - npm Package Compare versions

Comparing version 3.3.1 to 3.4.0

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

# [3.4.0](https://github.com/formatjs/formatjs/compare/intl-messageformat-parser@3.3.1...intl-messageformat-parser@3.4.0) (2019-12-01)
### Features
* **intl-messageformat-parser:** add parsing support for notation, signDisplay, currencyDisplay ([eaa0039](https://github.com/formatjs/formatjs/commit/eaa0039c90533b09b0c03aa9dc9cd8c605405dba))
* **intl-messageformat-parser:** add preliminary support for number skeleton ([e993e43](https://github.com/formatjs/formatjs/commit/e993e4387c522fd271996da79e99d2f85fd85b5f))
## [3.3.1](https://github.com/formatjs/formatjs/compare/intl-messageformat-parser@3.3.0...intl-messageformat-parser@3.3.1) (2019-11-26)

@@ -8,0 +20,0 @@

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

import { NumberSkeletonToken } from './types';
import { UnifiedNumberFormatOptions } from '@formatjs/intl-unified-numberformat';
export interface ExtendedDateTimeFormatOptions extends Intl.DateTimeFormatOptions {

@@ -11,1 +13,5 @@ hourCycle?: 'h11' | 'h12' | 'h23' | 'h24';

export declare function parseDateTimeSkeleton(skeleton: string): ExtendedDateTimeFormatOptions;
/**
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
*/
export declare function convertNumberSkeletonToNumberFormatOptions(tokens: NumberSkeletonToken[]): UnifiedNumberFormatOptions;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -125,1 +136,161 @@ /**

exports.parseDateTimeSkeleton = parseDateTimeSkeleton;
function icuUnitToEcma(unit) {
return unit.replace(/^(.*?)-/, '');
}
var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\+|#+)?)?$/g;
var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
function parseSignificantPrecision(str) {
var result = {};
str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
// @@@ case
if (typeof g2 !== 'string') {
result.minimumSignificantDigits = g1.length;
result.maximumSignificantDigits = g1.length;
}
// @@@+ case
else if (g2 === '+') {
result.minimumSignificantDigits = g1.length;
}
// .### case
else if (g1[0] === '#') {
result.maximumSignificantDigits = g1.length;
}
// .@@## or .@@@ case
else {
result.minimumSignificantDigits = g1.length;
result.maximumSignificantDigits =
g1.length + (typeof g2 === 'string' ? g2.length : 0);
}
return '';
});
return result;
}
function parseSign(str) {
switch (str) {
case 'sign-auto':
return {
signDisplay: 'auto',
};
case 'sign-accounting':
return {
currencySign: 'accounting',
};
case 'sign-always':
return {
signDisplay: 'always',
};
case 'sign-accounting-always':
return {
signDisplay: 'always',
currencySign: 'accounting',
};
case 'sign-except-zero':
return {
signDisplay: 'exceptZero',
};
case 'sign-accounting-except-zero':
return {
signDisplay: 'exceptZero',
currencySign: 'accounting',
};
case 'sign-never':
return {
signDisplay: 'never',
};
}
}
function parseNotationOptions(opt) {
var result = {};
var signOpts = parseSign(opt);
if (signOpts) {
return signOpts;
}
return result;
}
/**
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
*/
function convertNumberSkeletonToNumberFormatOptions(tokens) {
var result = {};
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
var token = tokens_1[_i];
switch (token.stem) {
case 'percent':
result.style = 'percent';
continue;
case 'currency':
result.style = 'currency';
result.currency = token.options[0];
continue;
case 'group-off':
result.useGrouping = false;
continue;
case 'precision-integer':
result.maximumFractionDigits = 0;
continue;
case 'measure-unit':
result.style = 'unit';
result.unit = icuUnitToEcma(token.options[0]);
continue;
case 'compact-short':
result.notation = 'compact';
result.compactDisplay = 'short';
continue;
case 'compact-long':
result.notation = 'compact';
result.compactDisplay = 'long';
continue;
case 'scientific':
result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
continue;
case 'engineering':
result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
continue;
case 'notation-simple':
result.notation = 'standard';
continue;
}
// Precision
// https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision
if (FRACTION_PRECISION_REGEX.test(token.stem)) {
if (token.options.length > 1) {
throw new RangeError('Fraction-precision stems only accept a single optional option');
}
token.stem.replace(FRACTION_PRECISION_REGEX, function (match, g1, g2) {
// precision-integer case
if (match === '.') {
result.maximumFractionDigits = 0;
}
// .000+ case
else if (g2 === '+') {
result.minimumFractionDigits = g2.length;
}
// .### case
else if (g1[0] === '#') {
result.maximumFractionDigits = g1.length;
}
// .00## or .000 case
else {
result.minimumFractionDigits = g1.length;
result.maximumFractionDigits =
g1.length + (typeof g2 === 'string' ? g2.length : 0);
}
return '';
});
if (token.options.length) {
result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
}
continue;
}
if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
continue;
}
var signOpts = parseSign(token.stem);
if (signOpts) {
result = __assign(__assign({}, result), signOpts);
}
}
return result;
}
exports.convertNumberSkeletonToNumberFormatOptions = convertNumberSkeletonToNumberFormatOptions;

2

dist/umd/intl-messageformat-parser.min.js

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).IntlMessageFormatParser={})}(this,function(Cr){"use strict";var e;function f(e){return e.type===Cr.TYPE.literal}function n(e){return e.type===Cr.TYPE.select}function a(e){return e.type===Cr.TYPE.plural}(e=Cr.TYPE||(Cr.TYPE={}))[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural";var u,o,r=(u=function(e,r){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)},function(e,r){function t(){this.constructor=e}u(e,r),e.prototype=null===r?Object.create(r):(t.prototype=r.prototype,new t)}),kr=function(){return(kr=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e}).apply(this,arguments)},Pr=(o=Error,r(c,o),c.buildMessage=function(e,r){function t(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"+t(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+t(e)})}function a(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"+t(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+t(e)})}function u(e){switch(e.type){case"literal":return'"'+n(e.text)+'"';case"class":var r=e.parts.map(function(e){return Array.isArray(e)?a(e[0])+"-"+a(e[1]):a(e)});return"["+(e.inverted?"^":"")+r+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var r,t,n=e.map(u);if(n.sort(),0<n.length){for(t=r=1;r<n.length;r++)n[r-1]!==n[r]&&(n[t]=n[r],t++);n.length=t}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 "+((o=r)?'"'+n(o)+'"':"end of input")+" found.";var o},c);function c(e,r,t,n){var a=o.call(this)||this;return a.message=e,a.expected=r,a.found=t,a.location=n,a.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,c),a}var p=function(f,e){e=void 0!==e?e:{};var r,t,n,a,p={},u={start:tr},o=tr,c=function(e){return e.join("")},i=function(e){return kr({type:Cr.TYPE.literal,value:e},xr())},s=Ge("argumentElement"),h="{",d=Xe("{",!1),g="}",v=Xe("}",!1),l=function(e){return kr({type:Cr.TYPE.argument,value:e},xr())},A=Ge("numberSkeletonId"),m=/^['\/{}]/,b=$e(["'","/","{","}"],!1,!1),y={type:"any"},E=Ge("numberSkeletonTokenOption"),w="/",x=Xe("/",!1),C=function(e){return e},k=Ge("numberSkeletonToken"),P=function(e,r){return{stem:e,options:r}},T=function(e){return kr({type:0,tokens:e},xr())},F="::",Y=Xe("::",!1),j=function(e){return e},O=function(e){return e.replace(/\s*$/,"")},R=",",S=Xe(",",!1),B="number",D=Xe("number",!1),_=function(e,r,t){return kr({type:"number"===r?Cr.TYPE.number:"date"===r?Cr.TYPE.date:Cr.TYPE.time,style:t&&t[2],value:e},xr())},Z="'",z=Xe("'",!1),N=/^[^']/,M=$e(["'"],!0,!1),L=/^[^a-zA-Z'{}]/,q=$e([["a","z"],["A","Z"],"'","{","}"],!0,!1),H=/^[a-zA-Z]/,I=$e([["a","z"],["A","Z"]],!1,!1),U=function(e){return kr({type:1,pattern:e},xr())},K="date",Q=Xe("date",!1),V="time",W=Xe("time",!1),X="plural",$=Xe("plural",!1),G="selectordinal",J=Xe("selectordinal",!1),ee="offset:",re=Xe("offset:",!1),te=function(e,r,t,n){return kr({type:Cr.TYPE.plural,pluralType:"plural"===r?"cardinal":"ordinal",value:e,offset:t?t[2]:0,options:n.reduce(function(e,r){var t=r.id,n=r.value,a=r.location;return t in e&&We('Duplicate option "'+t+'" in plural element: "'+Qe()+'"',Ve()),e[t]={value:n,location:a},e},{})},xr())},ne="select",ae=Xe("select",!1),ue=function(e,r){return kr({type:Cr.TYPE.select,value:e,options:r.reduce(function(e,r){var t=r.id,n=r.value,a=r.location;return t in e&&We('Duplicate option "'+t+'" in select element: "'+Qe()+'"',Ve()),e[t]={value:n,location:a},e},{})},xr())},oe="=",ce=Xe("=",!1),ie=function(e,r){return kr({id:e,value:r},xr())},se=function(e,r){return kr({id:e,value:r},xr())},le=Ge("whitespace pattern"),fe=/^[\t-\r \x85\u200E\u200F\u2028\u2029]/,pe=$e([["\t","\r"]," ","…","‎","‏","\u2028","\u2029"],!1,!1),he=Ge("syntax pattern"),de=/^[!-\/:-@[-\^`{-~\xA1-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]/,ge=$e([["!","/"],[":","@"],["[","^"],"`",["{","~"],["¡","§"],"©","«","¬","®","°","±","¶","»","¿","×","÷",["‐","‧"],["‰","‾"],["⁁","⁓"],["⁕","⁞"],["←","⑟"],["─","❵"],["➔","⯿"],["⸀","⹿"],["、","〃"],["〈","〠"],"〰","﴾","﴿","﹅","﹆"],!1,!1),ve=Ge("optional whitespace"),Ae=Ge("number"),me="-",be=Xe("-",!1),ye=function(e,r){return r?e?-r:r:0},Ee=Ge("double apostrophes"),we="''",xe=Xe("''",!1),Ce=function(){return"'"},ke=/^[{}]/,Pe=$e(["{","}"],!1,!1),Te=function(e,r){return e+r.replace("''","'")},Fe=/^[^{}]/,Ye=$e(["{","}"],!0,!1),je=Ge("argNameOrNumber"),Oe=Ge("argNumber"),Re="0",Se=Xe("0",!1),Be=function(){return 0},De=/^[1-9]/,_e=$e([["1","9"]],!1,!1),Ze=/^[0-9]/,ze=$e([["0","9"]],!1,!1),Ne=function(e){return parseInt(e.join(""),10)},Me=Ge("argName"),Le=0,qe=0,He=[{line:1,column:1}],Ie=0,Ue=[],Ke=0;if(void 0!==e.startRule){if(!(e.startRule in u))throw new Error("Can't start parsing from rule \""+e.startRule+'".');o=u[e.startRule]}function Qe(){return f.substring(qe,Le)}function Ve(){return er(qe,Le)}function We(e,r){throw function(e,r){return new Pr(e,[],"",r)}(e,r=void 0!==r?r:er(qe,Le))}function Xe(e,r){return{type:"literal",text:e,ignoreCase:r}}function $e(e,r,t){return{type:"class",parts:e,inverted:r,ignoreCase:t}}function Ge(e){return{type:"other",description:e}}function Je(e){var r,t=He[e];if(t)return t;for(r=e-1;!He[r];)r--;for(t={line:(t=He[r]).line,column:t.column};r<e;)10===f.charCodeAt(r)?(t.line++,t.column=1):t.column++,r++;return He[e]=t}function er(e,r){var t=Je(e),n=Je(r);return{start:{offset:e,line:t.line,column:t.column},end:{offset:r,line:n.line,column:n.column}}}function rr(e){Le<Ie||(Ie<Le&&(Ie=Le,Ue=[]),Ue.push(e))}function tr(){return nr()}function nr(){var e,r;for(e=[],r=ar();r!==p;)e.push(r),r=ar();return e}function ar(){var e;return(e=function(){var e,r;e=Le,(r=ur())!==p&&(qe=e,r=i(r));return e=r}())===p&&(e=function(){var e,r,t,n,a;Ke++,e=Le,123===f.charCodeAt(Le)?(r=h,Le++):(r=p,0===Ke&&rr(d));e=r!==p?(t=gr(),t!==p?(n=yr())!==p?gr()!==p?(125===f.charCodeAt(Le)?(a=g,Le++):(a=p,0===Ke&&rr(v)),a!==p?(qe=e,r=l(n)):(Le=e,p)):(Le=e,p):(Le=e,p):(Le=e,p)):(Le=e,p);Ke--,e===p&&(r=p,0===Ke&&rr(s));return e}())===p&&(e=function(){var e;(e=function(){var e,r,t,n,a,u,o,c,i,s;e=Le,123===f.charCodeAt(Le)?(r=h,Le++):(r=p,0===Ke&&rr(d));e=r!==p?(t=gr(),t!==p?(n=yr())!==p?gr()!==p?(44===f.charCodeAt(Le)?(a=R,Le++):(a=p,0===Ke&&rr(S)),a!==p?gr()!==p?(f.substr(Le,6)===B?(u=B,Le+=6):(u=p,0===Ke&&rr(D)),u!==p?gr()!==p?(o=Le,44===f.charCodeAt(Le)?(c=R,Le++):(c=p,0===Ke&&rr(S)),(o=c!==p?(i=gr())!==p?(s=function(){var e,r,t;e=Le,f.substr(Le,2)===F?(r=F,Le+=2):(r=p,0===Ke&&rr(Y));e=r!==p?(t=function(){var e,r,t;if(e=Le,r=[],(t=ir())!==p)for(;t!==p;)r.push(t),t=ir();else r=p;r!==p&&(qe=e,r=T(r));return e=r}(),t!==p?(qe=e,r=j(t)):(Le=e,p)):(Le=e,p);e===p&&(e=Le,(r=ur())!==p&&(qe=e,r=O(r)),e=r);return e}())!==p?c=[c,i,s]:(Le=o,p):(Le=o,p):(Le=o,p))===p&&(o=null),o!==p?(c=gr())!==p?(125===f.charCodeAt(Le)?(i=g,Le++):(i=p,0===Ke&&rr(v)),i!==p?(qe=e,r=_(n,u,o)):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p):(Le=e,p)):(Le=e,p);return e}())===p&&(e=function(){var e,r,t,n,a,u,o,c,i,s;e=Le,123===f.charCodeAt(Le)?(r=h,Le++):(r=p,0===Ke&&rr(d));e=r!==p?(t=gr(),t!==p?(n=yr())!==p?gr()!==p?(44===f.charCodeAt(Le)?(a=R,Le++):(a=p,0===Ke&&rr(S)),a!==p?gr()!==p?(f.substr(Le,4)===K?(u=K,Le+=4):(u=p,0===Ke&&rr(Q)),u===p&&(f.substr(Le,4)===V?(u=V,Le+=4):(u=p,0===Ke&&rr(W))),u!==p?gr()!==p?(o=Le,44===f.charCodeAt(Le)?(c=R,Le++):(c=p,0===Ke&&rr(S)),(o=c!==p?(i=gr())!==p?(s=function(){var e,r,t;e=Le,f.substr(Le,2)===F?(r=F,Le+=2):(r=p,0===Ke&&rr(Y));e=r!==p?(t=function(){var e,r,t,n;r=e=Le,t=[],(n=sr())===p&&(n=lr());if(n!==p)for(;n!==p;)t.push(n),(n=sr())===p&&(n=lr());else t=p;r=t!==p?f.substring(r,Le):t;r!==p&&(qe=e,r=U(r));return e=r}(),t!==p?(qe=e,r=j(t)):(Le=e,p)):(Le=e,p);e===p&&(e=Le,(r=ur())!==p&&(qe=e,r=O(r)),e=r);return e}())!==p?c=[c,i,s]:(Le=o,p):(Le=o,p):(Le=o,p))===p&&(o=null),o!==p?(c=gr())!==p?(125===f.charCodeAt(Le)?(i=g,Le++):(i=p,0===Ke&&rr(v)),i!==p?(qe=e,r=_(n,u,o)):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p):(Le=e,p)):(Le=e,p);return e}());return e}())===p&&(e=function(){var e,r,t,n,a,u,o,c,i,s,l;e=Le,123===f.charCodeAt(Le)?(r=h,Le++):(r=p,0===Ke&&rr(d));if(r!==p)if(gr()!==p)if((t=yr())!==p)if(gr()!==p)if(44===f.charCodeAt(Le)?(n=R,Le++):(n=p,0===Ke&&rr(S)),n!==p)if(gr()!==p)if(f.substr(Le,6)===X?(a=X,Le+=6):(a=p,0===Ke&&rr($)),a===p&&(f.substr(Le,13)===G?(a=G,Le+=13):(a=p,0===Ke&&rr(J))),a!==p)if(gr()!==p)if(44===f.charCodeAt(Le)?(u=R,Le++):(u=p,0===Ke&&rr(S)),u!==p)if(gr()!==p)if(o=Le,f.substr(Le,7)===ee?(c=ee,Le+=7):(c=p,0===Ke&&rr(re)),(o=c!==p?(i=gr())!==p?(s=vr())!==p?c=[c,i,s]:(Le=o,p):(Le=o,p):(Le=o,p))===p&&(o=null),o!==p)if((c=gr())!==p){if(i=[],(s=pr())!==p)for(;s!==p;)i.push(s),s=pr();else i=p;e=i!==p?(s=gr())!==p?(125===f.charCodeAt(Le)?(l=g,Le++):(l=p,0===Ke&&rr(v)),l!==p?(qe=e,r=te(t,a,o,i)):(Le=e,p)):(Le=e,p):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;return e}())===p&&(e=function(){var e,r,t,n,a,u,o,c,i;e=Le,123===f.charCodeAt(Le)?(r=h,Le++):(r=p,0===Ke&&rr(d));if(r!==p)if(gr()!==p)if((t=yr())!==p)if(gr()!==p)if(44===f.charCodeAt(Le)?(n=R,Le++):(n=p,0===Ke&&rr(S)),n!==p)if(gr()!==p)if(f.substr(Le,6)===ne?(a=ne,Le+=6):(a=p,0===Ke&&rr(ae)),a!==p)if(gr()!==p)if(44===f.charCodeAt(Le)?(u=R,Le++):(u=p,0===Ke&&rr(S)),u!==p)if(gr()!==p){if(o=[],(c=fr())!==p)for(;c!==p;)o.push(c),c=fr();else o=p;e=o!==p?(c=gr())!==p?(125===f.charCodeAt(Le)?(i=g,Le++):(i=p,0===Ke&&rr(v)),i!==p?(qe=e,r=ue(t,o)):(Le=e,p)):(Le=e,p):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;return e}()),e}function ur(){var e,r,t;if(e=Le,r=[],(t=Ar())===p&&(t=mr())===p&&(t=br()),t!==p)for(;t!==p;)r.push(t),(t=Ar())===p&&(t=mr())===p&&(t=br());else r=p;return r!==p&&(qe=e,r=c(r)),e=r}function or(){var e,r,t,n,a;if(Ke++,r=[],n=t=e=Le,Ke++,(a=hr())===p&&(m.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(b))),Ke--,(t=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(y)),a!==p?n=[n,a]:(Le=t,p)):(Le=t,p))!==p)for(;t!==p;)r.push(t),n=t=Le,Ke++,(a=hr())===p&&(m.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(b))),Ke--,t=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(y)),a!==p?n=[n,a]:(Le=t,p)):(Le=t,p);else r=p;return e=r!==p?f.substring(e,Le):r,Ke--,e===p&&(r=p,0===Ke&&rr(A)),e}function cr(){var e,r,t;return Ke++,e=Le,47===f.charCodeAt(Le)?(r=w,Le++):(r=p,0===Ke&&rr(x)),e=r!==p&&(t=or())!==p?(qe=e,r=C(t)):(Le=e,p),Ke--,e===p&&(r=p,0===Ke&&rr(E)),e}function ir(){var e,r,t,n;if(Ke++,e=Le,gr()!==p)if((r=or())!==p){for(t=[],n=cr();n!==p;)t.push(n),n=cr();e=t!==p?(qe=e,P(r,t)):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;return Ke--,e===p&&(p,0===Ke&&rr(k)),e}function sr(){var e,r,t,n;if(e=Le,39===f.charCodeAt(Le)?(r=Z,Le++):(r=p,0===Ke&&rr(z)),r!==p){if(t=[],(n=Ar())===p&&(N.test(f.charAt(Le))?(n=f.charAt(Le),Le++):(n=p,0===Ke&&rr(M))),n!==p)for(;n!==p;)t.push(n),(n=Ar())===p&&(N.test(f.charAt(Le))?(n=f.charAt(Le),Le++):(n=p,0===Ke&&rr(M)));else t=p;e=t!==p?(39===f.charCodeAt(Le)?(n=Z,Le++):(n=p,0===Ke&&rr(z)),n!==p?r=[r,t,n]:(Le=e,p)):(Le=e,p)}else Le=e,e=p;if(e===p)if(e=[],(r=Ar())===p&&(L.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=p,0===Ke&&rr(q))),r!==p)for(;r!==p;)e.push(r),(r=Ar())===p&&(L.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=p,0===Ke&&rr(q)));else e=p;return e}function lr(){var e,r;if(e=[],H.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=p,0===Ke&&rr(I)),r!==p)for(;r!==p;)e.push(r),H.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=p,0===Ke&&rr(I));else e=p;return e}function fr(){var e,r,t,n,a;return e=Le,e=gr()!==p&&(r=wr())!==p&&gr()!==p?(123===f.charCodeAt(Le)?(t=h,Le++):(t=p,0===Ke&&rr(d)),t!==p&&(n=nr())!==p?(125===f.charCodeAt(Le)?(a=g,Le++):(a=p,0===Ke&&rr(v)),a!==p?(qe=e,ie(r,n)):(Le=e,p)):(Le=e,p)):(Le=e,p)}function pr(){var e,r,t,n,a;return e=Le,e=gr()!==p&&(r=function(){var e,r,t,n;return r=e=Le,61===f.charCodeAt(Le)?(t=oe,Le++):(t=p,0===Ke&&rr(ce)),(e=(r=t!==p&&(n=vr())!==p?t=[t,n]:(Le=r,p))!==p?f.substring(e,Le):r)===p&&(e=wr()),e}())!==p&&gr()!==p?(123===f.charCodeAt(Le)?(t=h,Le++):(t=p,0===Ke&&rr(d)),t!==p&&(n=nr())!==p?(125===f.charCodeAt(Le)?(a=g,Le++):(a=p,0===Ke&&rr(v)),a!==p?(qe=e,se(r,n)):(Le=e,p)):(Le=e,p)):(Le=e,p)}function hr(){var e;return Ke++,fe.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=p,0===Ke&&rr(pe)),Ke--,e===p&&0===Ke&&rr(le),e}function dr(){var e;return Ke++,de.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=p,0===Ke&&rr(ge)),Ke--,e===p&&0===Ke&&rr(he),e}function gr(){var e,r,t;for(Ke++,e=Le,r=[],t=hr();t!==p;)r.push(t),t=hr();return e=r!==p?f.substring(e,Le):r,Ke--,e===p&&(r=p,0===Ke&&rr(ve)),e}function vr(){var e,r,t;return Ke++,e=Le,45===f.charCodeAt(Le)?(r=me,Le++):(r=p,0===Ke&&rr(be)),r===p&&(r=null),e=r!==p&&(t=Er())!==p?(qe=e,r=ye(r,t)):(Le=e,p),Ke--,e===p&&(r=p,0===Ke&&rr(Ae)),e}function Ar(){var e,r;return Ke++,e=Le,f.substr(Le,2)===we?(r=we,Le+=2):(r=p,0===Ke&&rr(xe)),r!==p&&(qe=e,r=Ce()),Ke--,(e=r)===p&&(r=p,0===Ke&&rr(Ee)),e}function mr(){var e,r,t,n,a,u;if(e=Le,39===f.charCodeAt(Le)?(r=Z,Le++):(r=p,0===Ke&&rr(z)),r!==p)if(ke.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=p,0===Ke&&rr(Pe)),t!==p){for(n=Le,a=[],f.substr(Le,2)===we?(u=we,Le+=2):(u=p,0===Ke&&rr(xe)),u===p&&(N.test(f.charAt(Le))?(u=f.charAt(Le),Le++):(u=p,0===Ke&&rr(M)));u!==p;)a.push(u),f.substr(Le,2)===we?(u=we,Le+=2):(u=p,0===Ke&&rr(xe)),u===p&&(N.test(f.charAt(Le))?(u=f.charAt(Le),Le++):(u=p,0===Ke&&rr(M)));e=(n=a!==p?f.substring(n,Le):a)!==p?(39===f.charCodeAt(Le)?(a=Z,Le++):(a=p,0===Ke&&rr(z)),a!==p?(qe=e,r=Te(t,n)):(Le=e,p)):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;return e}function br(){var e,r;return e=Le,Fe.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=p,0===Ke&&rr(Ye)),e=r!==p?f.substring(e,Le):r}function yr(){var e,r;return Ke++,e=Le,(r=Er())===p&&(r=wr()),e=r!==p?f.substring(e,Le):r,Ke--,e===p&&(r=p,0===Ke&&rr(je)),e}function Er(){var e,r,t,n,a;if(Ke++,e=Le,48===f.charCodeAt(Le)?(r=Re,Le++):(r=p,0===Ke&&rr(Se)),r!==p&&(qe=e,r=Be()),(e=r)===p){if(r=e=Le,De.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=p,0===Ke&&rr(_e)),t!==p){for(n=[],Ze.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(ze));a!==p;)n.push(a),Ze.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(ze));r=n!==p?t=[t,n]:(Le=r,p)}else Le=r,r=p;r!==p&&(qe=e,r=Ne(r)),e=r}return Ke--,e===p&&(r=p,0===Ke&&rr(Oe)),e}function wr(){var e,r,t,n,a;if(Ke++,r=[],n=t=e=Le,Ke++,(a=hr())===p&&(a=dr()),Ke--,(t=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(y)),a!==p?n=[n,a]:(Le=t,p)):(Le=t,p))!==p)for(;t!==p;)r.push(t),n=t=Le,Ke++,(a=hr())===p&&(a=dr()),Ke--,t=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ke&&rr(y)),a!==p?n=[n,a]:(Le=t,p)):(Le=t,p);else r=p;return e=r!==p?f.substring(e,Le):r,Ke--,e===p&&(r=p,0===Ke&&rr(Me)),e}function xr(){return e&&e.captureLocation?{location:Ve()}:{}}if((r=o())!==p&&Le===f.length)return r;throw r!==p&&Le<f.length&&rr({type:"end"}),t=Ue,n=Ie<f.length?f.charAt(Ie):null,a=Ie<f.length?er(Ie,Ie+1):er(Ie,Ie),new Pr(Pr.buildMessage(t,n),t,n,a)},h=function(){for(var e=0,r=0,t=arguments.length;r<t;r++)e+=arguments[r].length;var n=Array(e),a=0;for(r=0;r<t;r++)for(var u=arguments[r],o=0,c=u.length;o<c;o++,a++)n[a]=u[o];return n},d=/(^|[^\\])#/g;var i=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;Cr.SyntaxError=Pr,Cr.createLiteralElement=function(e){return{type:Cr.TYPE.literal,value:e}},Cr.createNumberElement=function(e,r){return{type:Cr.TYPE.number,value:e,style:r}},Cr.isArgumentElement=function(e){return e.type===Cr.TYPE.argument},Cr.isDateElement=function(e){return e.type===Cr.TYPE.date},Cr.isDateTimeSkeleton=function(e){return!(!e||"object"!=typeof e||1!==e.type)},Cr.isLiteralElement=f,Cr.isNumberElement=function(e){return e.type===Cr.TYPE.number},Cr.isNumberSkeleton=function(e){return!(!e||"object"!=typeof e||0!==e.type)},Cr.isPluralElement=a,Cr.isSelectElement=n,Cr.isTimeElement=function(e){return e.type===Cr.TYPE.time},Cr.parse=function(e,r){var t=p(e,r);return r&&!1===r.normalizeHashtagInPlural||function l(e){e.forEach(function(s){(a(s)||n(s))&&Object.keys(s.options).forEach(function(e){for(var r,t=s.options[e],n=-1,a=void 0,u=0;u<t.value.length;u++){var o=t.value[u];if(f(o)&&d.test(o.value)){n=u,a=o;break}}if(a){var c=a.value.replace(d,"$1{"+s.value+", number}"),i=p(c);(r=t.value).splice.apply(r,h([n,1],i))}l(t.value)})})}(t),t},Cr.parseDateTimeSkeleton=function(e){var t={};return e.replace(i,function(e){var r=e.length;switch(e[0]){case"G":t.era=4===r?"long":5===r?"narrow":"short";break;case"y":t.year=2===r?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":t.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":t.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":t.weekday=4===r?"short":5===r?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"a":t.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":t.hourCycle="h12",t.hour=["numeric","2-digit"][r-1];break;case"H":t.hourCycle="h23",t.hour=["numeric","2-digit"][r-1];break;case"K":t.hourCycle="h11",t.hour=["numeric","2-digit"][r-1];break;case"k":t.hourCycle="h24",t.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":t.minute=["numeric","2-digit"][r-1];break;case"s":t.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) pattenrs are not supported, use `s` instead");case"z":t.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) pattenrs are not supported, use `z` instead")}return""}),t},Cr.pegParse=p,Object.defineProperty(Cr,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).IntlMessageFormatParser={})}(this,function(Ct){"use strict";var e;function f(e){return e.type===Ct.TYPE.literal}function n(e){return e.type===Ct.TYPE.select}function a(e){return e.type===Ct.TYPE.plural}(e=Ct.TYPE||(Ct.TYPE={}))[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural";var u,i,t=(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(e,t){function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),kt=function(){return(kt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},Ft=(i=Error,t(o,i),o.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 a(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 u(e){switch(e.type){case"literal":return'"'+n(e.text)+'"';case"class":var t=e.parts.map(function(e){return Array.isArray(e)?a(e[0])+"-"+a(e[1]):a(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(u);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},o);function o(e,t,r,n){var a=i.call(this)||this;return a.message=e,a.expected=t,a.found=r,a.location=n,a.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,o),a}var p=function(f,e){e=void 0!==e?e:{};var t,r,n,a,p={},u={start:rt},i=rt,o=function(e){return e.join("")},c=function(e){return kt({type:Ct.TYPE.literal,value:e},xt())},s=Xe("argumentElement"),h="{",g=Ve("{",!1),m="}",d=Ve("}",!1),l=function(e){return kt({type:Ct.TYPE.argument,value:e},xt())},v=Xe("numberSkeletonId"),y=/^['\/{}]/,A=We(["'","/","{","}"],!1,!1),b={type:"any"},E=Xe("numberSkeletonTokenOption"),w="/",x=Ve("/",!1),C=function(e){return e},k=Xe("numberSkeletonToken"),F=function(e,t){return{stem:e,options:t}},D=function(e){return kt({type:0,tokens:e},xt())},P="::",T=Ve("::",!1),S=function(e){return e},Y=function(e){return e.replace(/\s*$/,"")},O=",",j=Ve(",",!1),R="number",B=Ve("number",!1),Z=function(e,t,r){return kt({type:"number"===t?Ct.TYPE.number:"date"===t?Ct.TYPE.date:Ct.TYPE.time,style:r&&r[2],value:e},xt())},z="'",N=Ve("'",!1),_=/^[^']/,M=We(["'"],!0,!1),L=/^[^a-zA-Z'{}]/,$=We([["a","z"],["A","Z"],"'","{","}"],!0,!1),q=/^[a-zA-Z]/,H=We([["a","z"],["A","Z"]],!1,!1),I=function(e){return kt({type:1,pattern:e},xt())},U="date",G=Ve("date",!1),K="time",Q=Ve("time",!1),V="plural",W=Ve("plural",!1),X="selectordinal",J=Ve("selectordinal",!1),ee="offset:",te=Ve("offset:",!1),re=function(e,t,r,n){return kt({type:Ct.TYPE.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,a=t.location;return r in e&&Qe('Duplicate option "'+r+'" in plural element: "'+Ge()+'"',Ke()),e[r]={value:n,location:a},e},{})},xt())},ne="select",ae=Ve("select",!1),ue=function(e,t){return kt({type:Ct.TYPE.select,value:e,options:t.reduce(function(e,t){var r=t.id,n=t.value,a=t.location;return r in e&&Qe('Duplicate option "'+r+'" in select element: "'+Ge()+'"',Ke()),e[r]={value:n,location:a},e},{})},xt())},ie="=",oe=Ve("=",!1),ce=function(e,t){return kt({id:e,value:t},xt())},se=function(e,t){return kt({id:e,value:t},xt())},le=Xe("whitespace pattern"),fe=/^[\t-\r \x85\u200E\u200F\u2028\u2029]/,pe=We([["\t","\r"]," ","…","‎","‏","\u2028","\u2029"],!1,!1),he=Xe("syntax pattern"),ge=/^[!-\/:-@[-\^`{-~\xA1-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]/,me=We([["!","/"],[":","@"],["[","^"],"`",["{","~"],["¡","§"],"©","«","¬","®","°","±","¶","»","¿","×","÷",["‐","‧"],["‰","‾"],["⁁","⁓"],["⁕","⁞"],["←","⑟"],["─","❵"],["➔","⯿"],["⸀","⹿"],["、","〃"],["〈","〠"],"〰","﴾","﴿","﹅","﹆"],!1,!1),de=Xe("optional whitespace"),ve=Xe("number"),ye="-",Ae=Ve("-",!1),be=function(e,t){return t?e?-t:t:0},Ee=Xe("double apostrophes"),we="''",xe=Ve("''",!1),Ce=function(){return"'"},ke=/^[{}]/,Fe=We(["{","}"],!1,!1),De=function(e,t){return e+t.replace("''","'")},Pe=/^[^{}]/,Te=We(["{","}"],!0,!1),Se=Xe("argNameOrNumber"),Ye=Xe("argNumber"),Oe="0",je=Ve("0",!1),Re=function(){return 0},Be=/^[1-9]/,Ze=We([["1","9"]],!1,!1),ze=/^[0-9]/,Ne=We([["0","9"]],!1,!1),_e=function(e){return parseInt(e.join(""),10)},Me=Xe("argName"),Le=0,$e=0,qe=[{line:1,column:1}],He=0,Ie=[],Ue=0;if(void 0!==e.startRule){if(!(e.startRule in u))throw new Error("Can't start parsing from rule \""+e.startRule+'".');i=u[e.startRule]}function Ge(){return f.substring($e,Le)}function Ke(){return et($e,Le)}function Qe(e,t){throw function(e,t){return new Ft(e,[],"",t)}(e,t=void 0!==t?t:et($e,Le))}function Ve(e,t){return{type:"literal",text:e,ignoreCase:t}}function We(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function Xe(e){return{type:"other",description:e}}function Je(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 et(e,t){var r=Je(e),n=Je(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function tt(e){Le<He||(He<Le&&(He=Le,Ie=[]),Ie.push(e))}function rt(){return nt()}function nt(){var e,t;for(e=[],t=at();t!==p;)e.push(t),t=at();return e}function at(){var e;return(e=function(){var e,t;e=Le,(t=ut())!==p&&($e=e,t=c(t));return e=t}())===p&&(e=function(){var e,t,r,n,a;Ue++,e=Le,123===f.charCodeAt(Le)?(t=h,Le++):(t=p,0===Ue&&tt(g));e=t!==p?(r=mt(),r!==p?(n=bt())!==p?mt()!==p?(125===f.charCodeAt(Le)?(a=m,Le++):(a=p,0===Ue&&tt(d)),a!==p?($e=e,t=l(n)):(Le=e,p)):(Le=e,p):(Le=e,p):(Le=e,p)):(Le=e,p);Ue--,e===p&&(t=p,0===Ue&&tt(s));return e}())===p&&(e=function(){var e;(e=function(){var e,t,r,n,a,u,i,o,c,s;e=Le,123===f.charCodeAt(Le)?(t=h,Le++):(t=p,0===Ue&&tt(g));e=t!==p?(r=mt(),r!==p?(n=bt())!==p?mt()!==p?(44===f.charCodeAt(Le)?(a=O,Le++):(a=p,0===Ue&&tt(j)),a!==p?mt()!==p?(f.substr(Le,6)===R?(u=R,Le+=6):(u=p,0===Ue&&tt(B)),u!==p?mt()!==p?(i=Le,44===f.charCodeAt(Le)?(o=O,Le++):(o=p,0===Ue&&tt(j)),(i=o!==p?(c=mt())!==p?(s=function(){var e,t,r;e=Le,f.substr(Le,2)===P?(t=P,Le+=2):(t=p,0===Ue&&tt(T));e=t!==p?(r=function(){var e,t,r;if(e=Le,t=[],(r=ct())!==p)for(;r!==p;)t.push(r),r=ct();else t=p;t!==p&&($e=e,t=D(t));return e=t}(),r!==p?($e=e,t=S(r)):(Le=e,p)):(Le=e,p);e===p&&(e=Le,(t=ut())!==p&&($e=e,t=Y(t)),e=t);return e}())!==p?o=[o,c,s]:(Le=i,p):(Le=i,p):(Le=i,p))===p&&(i=null),i!==p?(o=mt())!==p?(125===f.charCodeAt(Le)?(c=m,Le++):(c=p,0===Ue&&tt(d)),c!==p?($e=e,t=Z(n,u,i)):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p):(Le=e,p)):(Le=e,p);return e}())===p&&(e=function(){var e,t,r,n,a,u,i,o,c,s;e=Le,123===f.charCodeAt(Le)?(t=h,Le++):(t=p,0===Ue&&tt(g));e=t!==p?(r=mt(),r!==p?(n=bt())!==p?mt()!==p?(44===f.charCodeAt(Le)?(a=O,Le++):(a=p,0===Ue&&tt(j)),a!==p?mt()!==p?(f.substr(Le,4)===U?(u=U,Le+=4):(u=p,0===Ue&&tt(G)),u===p&&(f.substr(Le,4)===K?(u=K,Le+=4):(u=p,0===Ue&&tt(Q))),u!==p?mt()!==p?(i=Le,44===f.charCodeAt(Le)?(o=O,Le++):(o=p,0===Ue&&tt(j)),(i=o!==p?(c=mt())!==p?(s=function(){var e,t,r;e=Le,f.substr(Le,2)===P?(t=P,Le+=2):(t=p,0===Ue&&tt(T));e=t!==p?(r=function(){var e,t,r,n;t=e=Le,r=[],(n=st())===p&&(n=lt());if(n!==p)for(;n!==p;)r.push(n),(n=st())===p&&(n=lt());else r=p;t=r!==p?f.substring(t,Le):r;t!==p&&($e=e,t=I(t));return e=t}(),r!==p?($e=e,t=S(r)):(Le=e,p)):(Le=e,p);e===p&&(e=Le,(t=ut())!==p&&($e=e,t=Y(t)),e=t);return e}())!==p?o=[o,c,s]:(Le=i,p):(Le=i,p):(Le=i,p))===p&&(i=null),i!==p?(o=mt())!==p?(125===f.charCodeAt(Le)?(c=m,Le++):(c=p,0===Ue&&tt(d)),c!==p?($e=e,t=Z(n,u,i)):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p)):(Le=e,p):(Le=e,p):(Le=e,p)):(Le=e,p);return e}());return e}())===p&&(e=function(){var e,t,r,n,a,u,i,o,c,s,l;e=Le,123===f.charCodeAt(Le)?(t=h,Le++):(t=p,0===Ue&&tt(g));if(t!==p)if(mt()!==p)if((r=bt())!==p)if(mt()!==p)if(44===f.charCodeAt(Le)?(n=O,Le++):(n=p,0===Ue&&tt(j)),n!==p)if(mt()!==p)if(f.substr(Le,6)===V?(a=V,Le+=6):(a=p,0===Ue&&tt(W)),a===p&&(f.substr(Le,13)===X?(a=X,Le+=13):(a=p,0===Ue&&tt(J))),a!==p)if(mt()!==p)if(44===f.charCodeAt(Le)?(u=O,Le++):(u=p,0===Ue&&tt(j)),u!==p)if(mt()!==p)if(i=Le,f.substr(Le,7)===ee?(o=ee,Le+=7):(o=p,0===Ue&&tt(te)),(i=o!==p?(c=mt())!==p?(s=dt())!==p?o=[o,c,s]:(Le=i,p):(Le=i,p):(Le=i,p))===p&&(i=null),i!==p)if((o=mt())!==p){if(c=[],(s=pt())!==p)for(;s!==p;)c.push(s),s=pt();else c=p;e=c!==p?(s=mt())!==p?(125===f.charCodeAt(Le)?(l=m,Le++):(l=p,0===Ue&&tt(d)),l!==p?($e=e,t=re(r,a,i,c)):(Le=e,p)):(Le=e,p):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;return e}())===p&&(e=function(){var e,t,r,n,a,u,i,o,c;e=Le,123===f.charCodeAt(Le)?(t=h,Le++):(t=p,0===Ue&&tt(g));if(t!==p)if(mt()!==p)if((r=bt())!==p)if(mt()!==p)if(44===f.charCodeAt(Le)?(n=O,Le++):(n=p,0===Ue&&tt(j)),n!==p)if(mt()!==p)if(f.substr(Le,6)===ne?(a=ne,Le+=6):(a=p,0===Ue&&tt(ae)),a!==p)if(mt()!==p)if(44===f.charCodeAt(Le)?(u=O,Le++):(u=p,0===Ue&&tt(j)),u!==p)if(mt()!==p){if(i=[],(o=ft())!==p)for(;o!==p;)i.push(o),o=ft();else i=p;e=i!==p?(o=mt())!==p?(125===f.charCodeAt(Le)?(c=m,Le++):(c=p,0===Ue&&tt(d)),c!==p?($e=e,t=ue(r,i)):(Le=e,p)):(Le=e,p):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;else Le=e,e=p;return e}()),e}function ut(){var e,t,r;if(e=Le,t=[],(r=vt())===p&&(r=yt())===p&&(r=At()),r!==p)for(;r!==p;)t.push(r),(r=vt())===p&&(r=yt())===p&&(r=At());else t=p;return t!==p&&($e=e,t=o(t)),e=t}function it(){var e,t,r,n,a;if(Ue++,t=[],n=r=e=Le,Ue++,(a=ht())===p&&(y.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(A))),Ue--,(r=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(b)),a!==p?n=[n,a]:(Le=r,p)):(Le=r,p))!==p)for(;r!==p;)t.push(r),n=r=Le,Ue++,(a=ht())===p&&(y.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(A))),Ue--,r=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(b)),a!==p?n=[n,a]:(Le=r,p)):(Le=r,p);else t=p;return e=t!==p?f.substring(e,Le):t,Ue--,e===p&&(t=p,0===Ue&&tt(v)),e}function ot(){var e,t,r;return Ue++,e=Le,47===f.charCodeAt(Le)?(t=w,Le++):(t=p,0===Ue&&tt(x)),e=t!==p&&(r=it())!==p?($e=e,t=C(r)):(Le=e,p),Ue--,e===p&&(t=p,0===Ue&&tt(E)),e}function ct(){var e,t,r,n;if(Ue++,e=Le,mt()!==p)if((t=it())!==p){for(r=[],n=ot();n!==p;)r.push(n),n=ot();e=r!==p?($e=e,F(t,r)):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;return Ue--,e===p&&(p,0===Ue&&tt(k)),e}function st(){var e,t,r,n;if(e=Le,39===f.charCodeAt(Le)?(t=z,Le++):(t=p,0===Ue&&tt(N)),t!==p){if(r=[],(n=vt())===p&&(_.test(f.charAt(Le))?(n=f.charAt(Le),Le++):(n=p,0===Ue&&tt(M))),n!==p)for(;n!==p;)r.push(n),(n=vt())===p&&(_.test(f.charAt(Le))?(n=f.charAt(Le),Le++):(n=p,0===Ue&&tt(M)));else r=p;e=r!==p?(39===f.charCodeAt(Le)?(n=z,Le++):(n=p,0===Ue&&tt(N)),n!==p?t=[t,r,n]:(Le=e,p)):(Le=e,p)}else Le=e,e=p;if(e===p)if(e=[],(t=vt())===p&&(L.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=p,0===Ue&&tt($))),t!==p)for(;t!==p;)e.push(t),(t=vt())===p&&(L.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=p,0===Ue&&tt($)));else e=p;return e}function lt(){var e,t;if(e=[],q.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=p,0===Ue&&tt(H)),t!==p)for(;t!==p;)e.push(t),q.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=p,0===Ue&&tt(H));else e=p;return e}function ft(){var e,t,r,n,a;return e=Le,e=mt()!==p&&(t=wt())!==p&&mt()!==p?(123===f.charCodeAt(Le)?(r=h,Le++):(r=p,0===Ue&&tt(g)),r!==p&&(n=nt())!==p?(125===f.charCodeAt(Le)?(a=m,Le++):(a=p,0===Ue&&tt(d)),a!==p?($e=e,ce(t,n)):(Le=e,p)):(Le=e,p)):(Le=e,p)}function pt(){var e,t,r,n,a;return e=Le,e=mt()!==p&&(t=function(){var e,t,r,n;return t=e=Le,61===f.charCodeAt(Le)?(r=ie,Le++):(r=p,0===Ue&&tt(oe)),(e=(t=r!==p&&(n=dt())!==p?r=[r,n]:(Le=t,p))!==p?f.substring(e,Le):t)===p&&(e=wt()),e}())!==p&&mt()!==p?(123===f.charCodeAt(Le)?(r=h,Le++):(r=p,0===Ue&&tt(g)),r!==p&&(n=nt())!==p?(125===f.charCodeAt(Le)?(a=m,Le++):(a=p,0===Ue&&tt(d)),a!==p?($e=e,se(t,n)):(Le=e,p)):(Le=e,p)):(Le=e,p)}function ht(){var e;return Ue++,fe.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=p,0===Ue&&tt(pe)),Ue--,e===p&&0===Ue&&tt(le),e}function gt(){var e;return Ue++,ge.test(f.charAt(Le))?(e=f.charAt(Le),Le++):(e=p,0===Ue&&tt(me)),Ue--,e===p&&0===Ue&&tt(he),e}function mt(){var e,t,r;for(Ue++,e=Le,t=[],r=ht();r!==p;)t.push(r),r=ht();return e=t!==p?f.substring(e,Le):t,Ue--,e===p&&(t=p,0===Ue&&tt(de)),e}function dt(){var e,t,r;return Ue++,e=Le,45===f.charCodeAt(Le)?(t=ye,Le++):(t=p,0===Ue&&tt(Ae)),t===p&&(t=null),e=t!==p&&(r=Et())!==p?($e=e,t=be(t,r)):(Le=e,p),Ue--,e===p&&(t=p,0===Ue&&tt(ve)),e}function vt(){var e,t;return Ue++,e=Le,f.substr(Le,2)===we?(t=we,Le+=2):(t=p,0===Ue&&tt(xe)),t!==p&&($e=e,t=Ce()),Ue--,(e=t)===p&&(t=p,0===Ue&&tt(Ee)),e}function yt(){var e,t,r,n,a,u;if(e=Le,39===f.charCodeAt(Le)?(t=z,Le++):(t=p,0===Ue&&tt(N)),t!==p)if(ke.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=p,0===Ue&&tt(Fe)),r!==p){for(n=Le,a=[],f.substr(Le,2)===we?(u=we,Le+=2):(u=p,0===Ue&&tt(xe)),u===p&&(_.test(f.charAt(Le))?(u=f.charAt(Le),Le++):(u=p,0===Ue&&tt(M)));u!==p;)a.push(u),f.substr(Le,2)===we?(u=we,Le+=2):(u=p,0===Ue&&tt(xe)),u===p&&(_.test(f.charAt(Le))?(u=f.charAt(Le),Le++):(u=p,0===Ue&&tt(M)));e=(n=a!==p?f.substring(n,Le):a)!==p?(39===f.charCodeAt(Le)?(a=z,Le++):(a=p,0===Ue&&tt(N)),a!==p?($e=e,t=De(r,n)):(Le=e,p)):(Le=e,p)}else Le=e,e=p;else Le=e,e=p;return e}function At(){var e,t;return e=Le,Pe.test(f.charAt(Le))?(t=f.charAt(Le),Le++):(t=p,0===Ue&&tt(Te)),e=t!==p?f.substring(e,Le):t}function bt(){var e,t;return Ue++,e=Le,(t=Et())===p&&(t=wt()),e=t!==p?f.substring(e,Le):t,Ue--,e===p&&(t=p,0===Ue&&tt(Se)),e}function Et(){var e,t,r,n,a;if(Ue++,e=Le,48===f.charCodeAt(Le)?(t=Oe,Le++):(t=p,0===Ue&&tt(je)),t!==p&&($e=e,t=Re()),(e=t)===p){if(t=e=Le,Be.test(f.charAt(Le))?(r=f.charAt(Le),Le++):(r=p,0===Ue&&tt(Ze)),r!==p){for(n=[],ze.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(Ne));a!==p;)n.push(a),ze.test(f.charAt(Le))?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(Ne));t=n!==p?r=[r,n]:(Le=t,p)}else Le=t,t=p;t!==p&&($e=e,t=_e(t)),e=t}return Ue--,e===p&&(t=p,0===Ue&&tt(Ye)),e}function wt(){var e,t,r,n,a;if(Ue++,t=[],n=r=e=Le,Ue++,(a=ht())===p&&(a=gt()),Ue--,(r=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(b)),a!==p?n=[n,a]:(Le=r,p)):(Le=r,p))!==p)for(;r!==p;)t.push(r),n=r=Le,Ue++,(a=ht())===p&&(a=gt()),Ue--,r=(n=a===p?void 0:(Le=n,p))!==p?(f.length>Le?(a=f.charAt(Le),Le++):(a=p,0===Ue&&tt(b)),a!==p?n=[n,a]:(Le=r,p)):(Le=r,p);else t=p;return e=t!==p?f.substring(e,Le):t,Ue--,e===p&&(t=p,0===Ue&&tt(Me)),e}function xt(){return e&&e.captureLocation?{location:Ke()}:{}}if((t=i())!==p&&Le===f.length)return t;throw t!==p&&Le<f.length&&tt({type:"end"}),r=Ie,n=He<f.length?f.charAt(He):null,a=He<f.length?et(He,He+1):et(He,He),new Ft(Ft.buildMessage(r,n),r,n,a)},h=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),a=0;for(t=0;t<r;t++)for(var u=arguments[t],i=0,o=u.length;i<o;i++,a++)n[a]=u[i];return n},g=/(^|[^\\])#/g;var c=function(){return(c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},s=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;var l=/^\.(?:(0+)(\+|#+)?)?$/g,m=/^(@+)?(\+|#+)?$/g;function d(e){var n={};return e.replace(m,function(e,t,r){return"string"!=typeof r?(n.minimumSignificantDigits=t.length,n.maximumSignificantDigits=t.length):"+"===r?n.minimumSignificantDigits=t.length:"#"===t[0]?n.maximumSignificantDigits=t.length:(n.minimumSignificantDigits=t.length,n.maximumSignificantDigits=t.length+("string"==typeof r?r.length:0)),""}),n}function v(e){switch(e){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":return{currencySign:"accounting"};case"sign-always":return{signDisplay:"always"};case"sign-accounting-always":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":return{signDisplay:"never"}}}function y(e){var t=v(e);return t||{}}Ct.SyntaxError=Ft,Ct.convertNumberSkeletonToNumberFormatOptions=function(e){for(var n={},t=0,r=e;t<r.length;t++){var a=r[t];switch(a.stem){case"percent":n.style="percent";continue;case"currency":n.style="currency",n.currency=a.options[0];continue;case"group-off":n.useGrouping=!1;continue;case"precision-integer":n.maximumFractionDigits=0;continue;case"measure-unit":n.style="unit",n.unit=a.options[0].replace(/^(.*?)-/,"");continue;case"compact-short":n.notation="compact",n.compactDisplay="short";continue;case"compact-long":n.notation="compact",n.compactDisplay="long";continue;case"scientific":n=c(c(c({},n),{notation:"scientific"}),a.options.reduce(function(e,t){return c(c({},e),y(t))},{}));continue;case"engineering":n=c(c(c({},n),{notation:"engineering"}),a.options.reduce(function(e,t){return c(c({},e),y(t))},{}));continue;case"notation-simple":n.notation="standard";continue}if(l.test(a.stem)){if(1<a.options.length)throw new RangeError("Fraction-precision stems only accept a single optional option");a.stem.replace(l,function(e,t,r){return"."===e?n.maximumFractionDigits=0:"+"===r?n.minimumFractionDigits=r.length:"#"===t[0]?n.maximumFractionDigits=t.length:(n.minimumFractionDigits=t.length,n.maximumFractionDigits=t.length+("string"==typeof r?r.length:0)),""}),a.options.length&&(n=c(c({},n),d(a.options[0])))}else if(m.test(a.stem))n=c(c({},n),d(a.stem));else{var u=v(a.stem);u&&(n=c(c({},n),u))}}return n},Ct.createLiteralElement=function(e){return{type:Ct.TYPE.literal,value:e}},Ct.createNumberElement=function(e,t){return{type:Ct.TYPE.number,value:e,style:t}},Ct.isArgumentElement=function(e){return e.type===Ct.TYPE.argument},Ct.isDateElement=function(e){return e.type===Ct.TYPE.date},Ct.isDateTimeSkeleton=function(e){return!(!e||"object"!=typeof e||1!==e.type)},Ct.isLiteralElement=f,Ct.isNumberElement=function(e){return e.type===Ct.TYPE.number},Ct.isNumberSkeleton=function(e){return!(!e||"object"!=typeof e||0!==e.type)},Ct.isPluralElement=a,Ct.isSelectElement=n,Ct.isTimeElement=function(e){return e.type===Ct.TYPE.time},Ct.parse=function(e,t){var r=p(e,t);return t&&!1===t.normalizeHashtagInPlural||function l(e){e.forEach(function(s){(a(s)||n(s))&&Object.keys(s.options).forEach(function(e){for(var t,r=s.options[e],n=-1,a=void 0,u=0;u<r.value.length;u++){var i=r.value[u];if(f(i)&&g.test(i.value)){n=u,a=i;break}}if(a){var o=a.value.replace(g,"$1{"+s.value+", number}"),c=p(o);(t=r.value).splice.apply(t,h([n,1],c))}l(r.value)})})}(r),r},Ct.parseDateTimeSkeleton=function(e){var r={};return e.replace(s,function(e){var t=e.length;switch(e[0]){case"G":r.era=4===t?"long":5===t?"narrow":"short";break;case"y":r.year=2===t?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":r.month=["numeric","2-digit","short","long","narrow"][t-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":r.day=["numeric","2-digit"][t-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":r.weekday=4===t?"short":5===t?"narrow":"short";break;case"e":if(t<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");r.weekday=["short","long","narrow","short"][t-4];break;case"c":if(t<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");r.weekday=["short","long","narrow","short"][t-4];break;case"a":r.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":r.hourCycle="h12",r.hour=["numeric","2-digit"][t-1];break;case"H":r.hourCycle="h23",r.hour=["numeric","2-digit"][t-1];break;case"K":r.hourCycle="h11",r.hour=["numeric","2-digit"][t-1];break;case"k":r.hourCycle="h24",r.hour=["numeric","2-digit"][t-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":r.minute=["numeric","2-digit"][t-1];break;case"s":r.second=["numeric","2-digit"][t-1];break;case"S":case"A":throw new RangeError("`S/A` (second) pattenrs are not supported, use `s` instead");case"z":r.timeZoneName=t<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) pattenrs are not supported, use `z` instead")}return""}),r},Ct.pegParse=p,Object.defineProperty(Ct,"__esModule",{value:!0})});
//# sourceMappingURL=intl-messageformat-parser.min.js.map

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

import { UnifiedNumberFormatOptions } from '@formatjs/intl-unified-numberformat';

@@ -10,2 +11,7 @@ export declare type ArgumentElement = BaseElement<TYPE.argument>;

/**
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
*/
export declare function convertNumberSkeletonToNumberFormatOptions(tokens: NumberSkeletonToken[]): UnifiedNumberFormatOptions;
export declare function createLiteralElement(value: string): LiteralElement;

@@ -12,0 +18,0 @@

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

import { NumberSkeletonToken } from './types';
import { UnifiedNumberFormatOptions } from '@formatjs/intl-unified-numberformat';
export interface ExtendedDateTimeFormatOptions extends Intl.DateTimeFormatOptions {

@@ -11,1 +13,5 @@ hourCycle?: 'h11' | 'h12' | 'h23' | 'h24';

export declare function parseDateTimeSkeleton(skeleton: string): ExtendedDateTimeFormatOptions;
/**
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
*/
export declare function convertNumberSkeletonToNumberFormatOptions(tokens: NumberSkeletonToken[]): UnifiedNumberFormatOptions;

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

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**

@@ -122,1 +133,160 @@ * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table

}
function icuUnitToEcma(unit) {
return unit.replace(/^(.*?)-/, '');
}
var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\+|#+)?)?$/g;
var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
function parseSignificantPrecision(str) {
var result = {};
str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
// @@@ case
if (typeof g2 !== 'string') {
result.minimumSignificantDigits = g1.length;
result.maximumSignificantDigits = g1.length;
}
// @@@+ case
else if (g2 === '+') {
result.minimumSignificantDigits = g1.length;
}
// .### case
else if (g1[0] === '#') {
result.maximumSignificantDigits = g1.length;
}
// .@@## or .@@@ case
else {
result.minimumSignificantDigits = g1.length;
result.maximumSignificantDigits =
g1.length + (typeof g2 === 'string' ? g2.length : 0);
}
return '';
});
return result;
}
function parseSign(str) {
switch (str) {
case 'sign-auto':
return {
signDisplay: 'auto',
};
case 'sign-accounting':
return {
currencySign: 'accounting',
};
case 'sign-always':
return {
signDisplay: 'always',
};
case 'sign-accounting-always':
return {
signDisplay: 'always',
currencySign: 'accounting',
};
case 'sign-except-zero':
return {
signDisplay: 'exceptZero',
};
case 'sign-accounting-except-zero':
return {
signDisplay: 'exceptZero',
currencySign: 'accounting',
};
case 'sign-never':
return {
signDisplay: 'never',
};
}
}
function parseNotationOptions(opt) {
var result = {};
var signOpts = parseSign(opt);
if (signOpts) {
return signOpts;
}
return result;
}
/**
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
*/
export function convertNumberSkeletonToNumberFormatOptions(tokens) {
var result = {};
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
var token = tokens_1[_i];
switch (token.stem) {
case 'percent':
result.style = 'percent';
continue;
case 'currency':
result.style = 'currency';
result.currency = token.options[0];
continue;
case 'group-off':
result.useGrouping = false;
continue;
case 'precision-integer':
result.maximumFractionDigits = 0;
continue;
case 'measure-unit':
result.style = 'unit';
result.unit = icuUnitToEcma(token.options[0]);
continue;
case 'compact-short':
result.notation = 'compact';
result.compactDisplay = 'short';
continue;
case 'compact-long':
result.notation = 'compact';
result.compactDisplay = 'long';
continue;
case 'scientific':
result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
continue;
case 'engineering':
result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
continue;
case 'notation-simple':
result.notation = 'standard';
continue;
}
// Precision
// https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision
if (FRACTION_PRECISION_REGEX.test(token.stem)) {
if (token.options.length > 1) {
throw new RangeError('Fraction-precision stems only accept a single optional option');
}
token.stem.replace(FRACTION_PRECISION_REGEX, function (match, g1, g2) {
// precision-integer case
if (match === '.') {
result.maximumFractionDigits = 0;
}
// .000+ case
else if (g2 === '+') {
result.minimumFractionDigits = g2.length;
}
// .### case
else if (g1[0] === '#') {
result.maximumFractionDigits = g1.length;
}
// .00## or .000 case
else {
result.minimumFractionDigits = g1.length;
result.maximumFractionDigits =
g1.length + (typeof g2 === 'string' ? g2.length : 0);
}
return '';
});
if (token.options.length) {
result = __assign(__assign({}, result), parseSignificantPrecision(token.options[0]));
}
continue;
}
if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
continue;
}
var signOpts = parseSign(token.stem);
if (signOpts) {
result = __assign(__assign({}, result), signOpts);
}
}
return result;
}
{
"name": "intl-messageformat-parser",
"version": "3.3.1",
"version": "3.4.0",
"description": "Parses ICU Message strings into an AST via JavaScript.",

@@ -48,4 +48,7 @@ "main": "dist/index.js",

},
"devDependencies": {
"@formatjs/intl-unified-numberformat": "^2.1.8"
},
"homepage": "https://github.com/formatjs/formatjs",
"gitHead": "6d6aa5ccec18f2f04be72a6e510193c0a1210725"
"gitHead": "3ea32d0792af5e0757bede58b8b6235202ea74f2"
}

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

import {NumberSkeletonToken} from './types';
import {UnifiedNumberFormatOptions} from '@formatjs/intl-unified-numberformat';
/**

@@ -145,1 +148,191 @@ * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table

}
function icuUnitToEcma(unit: string): UnifiedNumberFormatOptions['unit'] {
return unit.replace(/^(.*?)-/, '') as UnifiedNumberFormatOptions['unit'];
}
const FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\+|#+)?)?$/g;
const SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?$/g;
function parseSignificantPrecision(str: string): UnifiedNumberFormatOptions {
const result: UnifiedNumberFormatOptions = {};
str.replace(SIGNIFICANT_PRECISION_REGEX, function(
_: string,
g1: string,
g2: string | number
) {
// @@@ case
if (typeof g2 !== 'string') {
result.minimumSignificantDigits = g1.length;
result.maximumSignificantDigits = g1.length;
}
// @@@+ case
else if (g2 === '+') {
result.minimumSignificantDigits = g1.length;
}
// .### case
else if (g1[0] === '#') {
result.maximumSignificantDigits = g1.length;
}
// .@@## or .@@@ case
else {
result.minimumSignificantDigits = g1.length;
result.maximumSignificantDigits =
g1.length + (typeof g2 === 'string' ? g2.length : 0);
}
return '';
});
return result;
}
function parseSign(str: string): UnifiedNumberFormatOptions | undefined {
switch (str) {
case 'sign-auto':
return {
signDisplay: 'auto',
};
case 'sign-accounting':
return {
currencySign: 'accounting',
};
case 'sign-always':
return {
signDisplay: 'always',
};
case 'sign-accounting-always':
return {
signDisplay: 'always',
currencySign: 'accounting',
};
case 'sign-except-zero':
return {
signDisplay: 'exceptZero',
};
case 'sign-accounting-except-zero':
return {
signDisplay: 'exceptZero',
currencySign: 'accounting',
};
case 'sign-never':
return {
signDisplay: 'never',
};
}
}
function parseNotationOptions(opt: string): UnifiedNumberFormatOptions {
const result: UnifiedNumberFormatOptions = {};
const signOpts = parseSign(opt);
if (signOpts) {
return signOpts;
}
return result;
}
/**
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
*/
export function convertNumberSkeletonToNumberFormatOptions(
tokens: NumberSkeletonToken[]
): UnifiedNumberFormatOptions {
let result: UnifiedNumberFormatOptions = {};
for (const token of tokens) {
switch (token.stem) {
case 'percent':
result.style = 'percent';
continue;
case 'currency':
result.style = 'currency';
result.currency = token.options[0];
continue;
case 'group-off':
result.useGrouping = false;
continue;
case 'precision-integer':
result.maximumFractionDigits = 0;
continue;
case 'measure-unit':
result.style = 'unit';
result.unit = icuUnitToEcma(token.options[0]);
continue;
case 'compact-short':
result.notation = 'compact';
result.compactDisplay = 'short';
continue;
case 'compact-long':
result.notation = 'compact';
result.compactDisplay = 'long';
continue;
case 'scientific':
result = {
...result,
notation: 'scientific',
...token.options.reduce(
(all, opt) => ({...all, ...parseNotationOptions(opt)}),
{}
),
};
continue;
case 'engineering':
result = {
...result,
notation: 'engineering',
...token.options.reduce(
(all, opt) => ({...all, ...parseNotationOptions(opt)}),
{}
),
};
continue;
case 'notation-simple':
result.notation = 'standard';
continue;
}
// Precision
// https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision
if (FRACTION_PRECISION_REGEX.test(token.stem)) {
if (token.options.length > 1) {
throw new RangeError(
'Fraction-precision stems only accept a single optional option'
);
}
token.stem.replace(FRACTION_PRECISION_REGEX, function(
match: string,
g1: string,
g2: string | number
) {
// precision-integer case
if (match === '.') {
result.maximumFractionDigits = 0;
}
// .000+ case
else if (g2 === '+') {
result.minimumFractionDigits = g2.length;
}
// .### case
else if (g1[0] === '#') {
result.maximumFractionDigits = g1.length;
}
// .00## or .000 case
else {
result.minimumFractionDigits = g1.length;
result.maximumFractionDigits =
g1.length + (typeof g2 === 'string' ? g2.length : 0);
}
return '';
});
if (token.options.length) {
result = {...result, ...parseSignificantPrecision(token.options[0])};
}
continue;
}
if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
result = {...result, ...parseSignificantPrecision(token.stem)};
continue;
}
const signOpts = parseSign(token.stem);
if (signOpts) {
result = {...result, ...signOpts};
}
}
return result;
}

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc