"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __extends=function(){var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};return function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Compiler=function(){function t(t,e,r){this.locales=[],this.formats={number:{},date:{},time:{}},this.pluralNumberFormat=null,this.currentPlural=null,this.pluralStack=[],this.locales=t,this.formats=e,this.formatters=r}return t.prototype.compile=function(t){return this.pluralStack=[],this.currentPlural=null,this.pluralNumberFormat=null,this.compileMessage(t)},t.prototype.compileMessage=function(t){var e=this;if(!t||"messageFormatPattern"!==t.type)throw new Error('Message AST is not of type: "messageFormatPattern"');var r=t.elements,n=r.filter(function(t){return"messageTextElement"===t.type||"argumentElement"===t.type}).map(function(t){return"messageTextElement"===t.type?e.compileMessageText(t):e.compileArgument(t)});if(n.length!==r.length)throw new Error("Message element does not have a valid type");return n},t.prototype.compileMessageText=function(t){return this.currentPlural&&/(^|[^\\])#/g.test(t.value)?(this.pluralNumberFormat||(this.pluralNumberFormat=new Intl.NumberFormat(this.locales)),new PluralOffsetString(this.currentPlural.id,this.currentPlural.format.offset,this.pluralNumberFormat,t.value)):t.value.replace(/\\#/g,"#")},t.prototype.compileArgument=function(t){var e=t.format,r=t.id,n=this.formatters;if(!e)return new StringFormat(r);var o=this.formats,a=this.locales;switch(e.type){case"numberFormat":return{id:r,format:n.getNumberFormat(a,o.number[e.style]).format};case"dateFormat":return{id:r,format:n.getDateTimeFormat(a,o.date[e.style]).format};case"timeFormat":return{id:r,format:n.getDateTimeFormat(a,o.time[e.style]).format};case"pluralFormat":return new PluralFormat(r,e.offset,this.compileOptions(t),n.getPluralRules(a,{type:e.ordinal?"ordinal":"cardinal"}));case"selectFormat":return new SelectFormat(r,this.compileOptions(t));default:throw new Error("Message element does not have a valid format type")}},t.prototype.compileOptions=function(t){var r=this,e=t.format,n=e.options;this.pluralStack.push(this.currentPlural),this.currentPlural="pluralFormat"===e.type?t:null;var o=n.reduce(function(t,e){return t[e.selector]=r.compileMessage(e.value),t},{});return this.currentPlural=this.pluralStack.pop(),o},t}(),Formatter=function(t){this.id=t},StringFormat=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.format=function(t){return t||"number"==typeof t?"string"==typeof t?t:String(t):""},e}(Formatter),PluralFormat=function(){function t(t,e,r,n){this.id=t,this.offset=e,this.options=r,this.pluralRules=n}return t.prototype.getOption=function(t){var e=this.options;return e["="+t]||e[this.pluralRules.select(t-this.offset)]||e.other},t}(),PluralOffsetString=function(a){function t(t,e,r,n){var o=a.call(this,t)||this;return o.offset=e,o.numberFormat=r,o.string=n,o}return __extends(t,a),t.prototype.format=function(t){var e=this.numberFormat.format(t-this.offset);return this.string.replace(/(^|[^\\])#/g,"$1"+e).replace(/\\#/g,"#")},t}(Formatter),SelectFormat=function(){function t(t,e){this.id=t,this.options=e}return t.prototype.getOption=function(t){var e=this.options;return e[t]||e.other},t}();function isSelectOrPluralFormat(t){return!!t.options}var __extends$1=function(){var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};return function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),__assign=function(){return(__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r