javascript-time-ago 2.5.12 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +462 -316
  3. package/bundle/javascript-time-ago.js +1 -1
  4. package/bundle/javascript-time-ago.js.map +1 -1
  5. package/bundle/javascript-time-ago.min.js +1 -1
  6. package/bundle/javascript-time-ago.min.js.map +1 -1
  7. package/commonjs/FullDateFormatter.js +72 -0
  8. package/commonjs/FullDateFormatter.js.map +1 -0
  9. package/commonjs/FullDateFormatter.test.js +26 -0
  10. package/commonjs/FullDateFormatter.test.js.map +1 -0
  11. package/commonjs/TimeAgo.js +208 -106
  12. package/commonjs/TimeAgo.js.map +1 -1
  13. package/commonjs/TimeAgo.test.js +95 -10
  14. package/commonjs/TimeAgo.test.js.map +1 -1
  15. package/commonjs/steps/getStepMinTime.js +26 -19
  16. package/commonjs/steps/getStepMinTime.js.map +1 -1
  17. package/commonjs/steps/getTimeToNextUpdate.js +10 -2
  18. package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
  19. package/commonjs/style/twitter.js +2 -3
  20. package/commonjs/style/twitter.js.map +1 -1
  21. package/commonjs/style/twitter.test.js +5 -2
  22. package/commonjs/style/twitter.test.js.map +1 -1
  23. package/full-date-formatter/index.cjs +4 -0
  24. package/full-date-formatter/index.cjs.js +9 -0
  25. package/full-date-formatter/index.d.ts +6 -0
  26. package/full-date-formatter/index.js +1 -0
  27. package/full-date-formatter/package.json +15 -0
  28. package/index.cjs +1 -1
  29. package/index.cjs.js +2 -2
  30. package/index.d.ts +14 -4
  31. package/index.js +3 -1
  32. package/modules/FullDateFormatter.js +67 -0
  33. package/modules/FullDateFormatter.js.map +1 -0
  34. package/modules/FullDateFormatter.test.js +22 -0
  35. package/modules/FullDateFormatter.test.js.map +1 -0
  36. package/modules/TimeAgo.js +208 -107
  37. package/modules/TimeAgo.js.map +1 -1
  38. package/modules/TimeAgo.test.js +95 -8
  39. package/modules/TimeAgo.test.js.map +1 -1
  40. package/modules/steps/getStepMinTime.js +26 -19
  41. package/modules/steps/getStepMinTime.js.map +1 -1
  42. package/modules/steps/getTimeToNextUpdate.js +10 -2
  43. package/modules/steps/getTimeToNextUpdate.js.map +1 -1
  44. package/modules/style/twitter.js +3 -3
  45. package/modules/style/twitter.js.map +1 -1
  46. package/modules/style/twitter.test.js +5 -2
  47. package/modules/style/twitter.test.js.map +1 -1
  48. package/package.json +16 -11
@@ -22,11 +22,6 @@ import { addLocaleData, getLocaleData } from './LocaleDataStore.js';
22
22
  import defaultStyle from './style/roundMinute.js';
23
23
  import getStyleByName from './style/getStyleByName.js';
24
24
  import { getRoundFunction } from './round.js';
25
-
26
- // Valid time units.
27
- var UNITS = ['now',
28
- // The rest are the same as in `Intl.RelativeTimeFormat`.
29
- 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'];
30
25
  var TimeAgo = /*#__PURE__*/function () {
31
26
  /**
32
27
  * @param {(string|string[])} locales=[] - Preferred locales (or locale).
@@ -91,11 +86,16 @@ var TimeAgo = /*#__PURE__*/function () {
91
86
  *
92
87
  * @param {boolean} [options.getTimeToNextUpdate] — Pass `true` to return `[formattedDate, timeToNextUpdate]` instead of just `formattedDate`.
93
88
  *
89
+ * @param {boolean} [options.getTimeToNextUpdateUncapped] — Pass `true` to not apply the workaround for `setTimeout()` bug. https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values
90
+ *
91
+ * @param {function} [options.refresh] — When `refresh` function is passed, it will be automatically called with a new text when it's time to refresh the label.
92
+ *
94
93
  * @return {string} The formatted relative date/time. If no eligible `step` is found, then an empty string is returned.
95
94
  */
96
95
  _createClass(TimeAgo, [{
97
96
  key: "format",
98
97
  value: function format(input, style, options) {
98
+ var _this = this;
99
99
  if (!options) {
100
100
  if (style && !isStyle(style)) {
101
101
  options = style;
@@ -117,125 +117,203 @@ var TimeAgo = /*#__PURE__*/function () {
117
117
  var _this$getLabels = this.getLabels(style.flavour || style.labels),
118
118
  labels = _this$getLabels.labels,
119
119
  labelsType = _this$getLabels.labelsType;
120
+
121
+ // `round` setting could be passed as a parameter to `.format()` function
122
+ // or be configured globally for a style.
123
+ var round = options.round || style.round;
124
+
125
+ // A developer can pass a custom `now`, e.g. for testing purposes.
120
126
  var now;
121
- // Can pass a custom `now`, e.g. for testing purposes.
122
- //
127
+ var nowRealWhenCalled = Date.now();
128
+ // (deprecated)
123
129
  // Legacy way was passing `now` in `style`.
124
- // That way is deprecated.
125
130
  if (style.now !== undefined) {
126
131
  now = style.now;
127
132
  }
128
- // The new way is passing `now` option to `.format()`.
133
+ // One could pass `now` option to `.format()`.
129
134
  if (now === undefined && options.now !== undefined) {
130
135
  now = options.now;
131
136
  }
137
+ // The default `now` is `Date.now()`.
132
138
  if (now === undefined) {
133
- now = Date.now();
139
+ now = nowRealWhenCalled;
134
140
  }
135
-
136
- // how much time has passed (in seconds)
137
- var secondsPassed = (now - timestamp) / 1000; // in seconds
138
-
139
- var future = options.future || secondsPassed < 0;
140
- var nowLabel = getNowLabel(labels, getLocaleData(this.locale).now, getLocaleData(this.locale)["long"], future);
141
-
142
- // `custom` – A function of `{ elapsed, time, date, now, locale }`.
143
- //
144
- // Looks like `custom` function is deprecated and will be removed
145
- // in the next major version.
146
- //
147
- // If this function returns a value, then the `.format()` call will return that value.
148
- // Otherwise the relative date/time is formatted as usual.
149
- // This feature is currently not used anywhere and is here
150
- // just for providing the ultimate customization point
151
- // in case anyone would ever need that. Prefer using
152
- // `steps[step].format(value, locale)` instead.
153
- //
154
- if (style.custom) {
155
- var custom = style.custom({
156
- now: now,
157
- date: new Date(timestamp),
158
- time: timestamp,
159
- elapsed: secondsPassed,
160
- locale: this.locale
161
- });
162
- if (custom !== undefined) {
163
- // Won't return `timeToNextUpdate` here
164
- // because `custom()` seems deprecated.
165
- return custom;
141
+ var getTextAndTextRefreshDelayGetterFunctions = function getTextAndTextRefreshDelayGetterFunctions(_ref2) {
142
+ var now = _ref2.now;
143
+ // how much time has passed (in seconds)
144
+ var secondsPassed = (now - timestamp) / 1000; // in seconds
145
+
146
+ var future = options.future || secondsPassed < 0;
147
+ var nowLabel = getNowLabel(labels, getLocaleData(_this.locale).now, getLocaleData(_this.locale)["long"], future);
148
+
149
+ // (deprecated)
150
+ //
151
+ // `custom` A function of `{ elapsed, time, date, now, locale }`.
152
+ //
153
+ // If this function returns a value, then the `.format()` call will return that value.
154
+ // Otherwise the relative date/time is formatted as usual.
155
+ // This feature is currently not used anywhere and is here
156
+ // just for providing the ultimate customization point
157
+ // in case anyone would ever need that. Prefer using
158
+ // `steps[step].format(value, locale)` instead.
159
+ //
160
+ if (style.custom) {
161
+ var text = style.custom({
162
+ now: now,
163
+ date: new Date(timestamp),
164
+ time: timestamp,
165
+ elapsed: secondsPassed,
166
+ locale: _this.locale
167
+ });
168
+ if (text !== undefined) {
169
+ // Won't return `timeToNextUpdate` here
170
+ // because `custom()` seems deprecated.
171
+ return {
172
+ getText: function getText() {
173
+ return text;
174
+ },
175
+ getTextRefreshDelay: function getTextRefreshDelay() {
176
+ throw new Error('`getTimeToNextUpdate: true` feature is not supported by legacy "styles" that have a `custom` function');
177
+ }
178
+ };
179
+ }
166
180
  }
167
- }
168
-
169
- // Get the list of available time interval units.
170
- var units = getTimeIntervalMeasurementUnits(
171
- // Controlling `style.steps` through `style.units` seems to be deprecated:
172
- // create a new custom `style` instead.
173
- style.units, labels, nowLabel);
174
181
 
175
- // // If no available time unit is suitable, just output an empty string.
176
- // if (units.length === 0) {
177
- // console.error(`None of the "${units.join(', ')}" time units have been found in "${labelsType}" labels for "${this.locale}" locale.`)
178
- // return ''
179
- // }
180
-
181
- var round = options.round || style.round;
182
+ // Get the list of available time interval units.
183
+ var units = getTimeIntervalMeasurementUnits(
184
+ // Controlling `style.steps` through `style.units` seems to be deprecated:
185
+ // create a new custom `style` instead.
186
+ style.units, labels, nowLabel);
187
+
188
+ // Choose the appropriate time measurement unit
189
+ // and get the corresponding rounded time amount.
190
+ var _getStep = getStep(
191
+ // "gradation" is a legacy name for "steps".
192
+ // For historical reasons, "approximate" steps are used by default.
193
+ // In the next major version, there'll be no default for `steps`.
194
+ style.gradation || style.steps || defaultStyle.steps, secondsPassed, {
195
+ now: now,
196
+ units: units,
197
+ round: round,
198
+ future: future,
199
+ getNextStep: true
200
+ }),
201
+ _getStep2 = _slicedToArray(_getStep, 3),
202
+ prevStep = _getStep2[0],
203
+ step = _getStep2[1],
204
+ nextStep = _getStep2[2];
205
+ var getText = function getText() {
206
+ return _this.formatDateForStep(timestamp, step, secondsPassed, {
207
+ labels: labels,
208
+ labelsType: labelsType,
209
+ nowLabel: nowLabel,
210
+ now: now,
211
+ future: future,
212
+ round: round
213
+ }) || '';
214
+ };
215
+
216
+ // Returns the time (in milliseconds) after which the formatted date label should be refreshed.
217
+ //
218
+ // It will return `undefined` for a custom style
219
+ // that doesn't meet the minimum requirements for this feature.
220
+ // See the README for more details.
221
+ //
222
+ var getTextRefreshDelay = function getTextRefreshDelay() {
223
+ var timeToNextUpdate = getTimeToNextUpdate(timestamp, step, {
224
+ nextStep: nextStep,
225
+ prevStep: prevStep,
226
+ now: now,
227
+ future: future,
228
+ round: round
229
+ });
182
230
 
183
- // Choose the appropriate time measurement unit
184
- // and get the corresponding rounded time amount.
185
- var _getStep = getStep(
186
- // "gradation" is a legacy name for "steps".
187
- // For historical reasons, "approximate" steps are used by default.
188
- // In the next major version, there'll be no default for `steps`.
189
- style.gradation || style.steps || defaultStyle.steps, secondsPassed, {
190
- now: now,
191
- units: units,
192
- round: round,
193
- future: future,
194
- getNextStep: true
231
+ // `timeToNextUpdate` could be `undefined` for a custom style
232
+ // that doesn't meet the minimum requirements for this feature.
233
+ // See the README for more details.
234
+ if (typeof timeToNextUpdate === 'number') {
235
+ // `setTimeout()` function has a bug when it fires immediately
236
+ // when the delay is longer than about `24.85` days.
237
+ // https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values
238
+ //
239
+ // To not burden the end user of this library with manually working around that bug,
240
+ // this library automatically caps the returned delay to a maximum value that
241
+ // still works with `setTimeout()` and doesn't break it.
242
+ //
243
+ // The end user of this library could still opt out of this auto-workaround feature
244
+ // by passing a `getTimeToNextUpdateUncapped: true` option.
245
+ //
246
+ if (options.getTimeToNextUpdateUncapped) {
247
+ return timeToNextUpdate;
248
+ }
249
+ return getSafeTimeoutDelay(timeToNextUpdate);
250
+ }
251
+ };
252
+ return {
253
+ getText: getText,
254
+ getTextRefreshDelay: getTextRefreshDelay
255
+ };
256
+ };
257
+ var _getTextAndTextRefres = getTextAndTextRefreshDelayGetterFunctions({
258
+ now: now
195
259
  }),
196
- _getStep2 = _slicedToArray(_getStep, 3),
197
- prevStep = _getStep2[0],
198
- step = _getStep2[1],
199
- nextStep = _getStep2[2];
200
- var formattedDate = this.formatDateForStep(timestamp, step, secondsPassed, {
201
- labels: labels,
202
- labelsType: labelsType,
203
- nowLabel: nowLabel,
204
- now: now,
205
- future: future,
206
- round: round
207
- }) || '';
260
+ getText = _getTextAndTextRefres.getText,
261
+ getTextRefreshDelay = _getTextAndTextRefres.getTextRefreshDelay;
208
262
  if (options.getTimeToNextUpdate) {
209
- var timeToNextUpdate = getTimeToNextUpdate(timestamp, step, {
210
- nextStep: nextStep,
211
- prevStep: prevStep,
212
- now: now,
213
- future: future,
214
- round: round
215
- });
216
- return [formattedDate, timeToNextUpdate];
263
+ return [getText(), getTextRefreshDelay()];
217
264
  }
218
- return formattedDate;
265
+ if (options.refresh) {
266
+ // `getTextRefreshDelay()` will return `undefined` for a custom style
267
+ // that doesn't meet the minimum requirements for this feature.
268
+ // See the README for more details.
269
+ //
270
+ // This is a "sensible default" interval for refreshing time labels
271
+ // that use such custom style.
272
+ //
273
+ var defaultRefreshInterval = 60 * 1000;
274
+
275
+ // If `refresh` function was passed, schedule it to be called when the time comes,
276
+ // after which schedule the next refresh.
277
+ var refreshTimer;
278
+ var scheduleRefresh = function scheduleRefresh() {
279
+ var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRefreshInterval;
280
+ refreshTimer = setTimeoutSafe(function () {
281
+ var _getTextAndTextRefres2 = getTextAndTextRefreshDelayGetterFunctions({
282
+ now: now + (Date.now() - nowRealWhenCalled)
283
+ }),
284
+ getText = _getTextAndTextRefres2.getText,
285
+ getTextRefreshDelay = _getTextAndTextRefres2.getTextRefreshDelay;
286
+ options.refresh(getText());
287
+ scheduleRefresh(getTextRefreshDelay());
288
+ }, delay);
289
+ };
290
+ scheduleRefresh(getTextRefreshDelay());
291
+ var stopRefreshing = function stopRefreshing() {
292
+ clearTimeout(refreshTimer);
293
+ };
294
+ return [getText(), stopRefreshing];
295
+ }
296
+ return getText();
219
297
  }
220
298
  }, {
221
299
  key: "formatDateForStep",
222
- value: function formatDateForStep(timestamp, step, secondsPassed, _ref2) {
223
- var _this = this;
224
- var labels = _ref2.labels,
225
- labelsType = _ref2.labelsType,
226
- nowLabel = _ref2.nowLabel,
227
- now = _ref2.now,
228
- future = _ref2.future,
229
- round = _ref2.round;
300
+ value: function formatDateForStep(timestamp, step, secondsPassed, _ref3) {
301
+ var _this2 = this;
302
+ var labels = _ref3.labels,
303
+ labelsType = _ref3.labelsType,
304
+ nowLabel = _ref3.nowLabel,
305
+ now = _ref3.now,
306
+ future = _ref3.future,
307
+ round = _ref3.round;
230
308
  // If no step matches, then output an empty string.
231
309
  if (!step) {
232
310
  return;
233
311
  }
234
312
  if (step.format) {
235
313
  return step.format(timestamp, this.locale, {
236
- formatAs: function formatAs(unit, value) {
314
+ formatAs: function formatAs(unit, amount) {
237
315
  // Mimicks `Intl.RelativeTimeFormat.format()`.
238
- return _this.formatValue(value, unit, {
316
+ return _this2.formatValue(amount, unit, {
239
317
  labels: labels,
240
318
  future: future
241
319
  });
@@ -316,9 +394,9 @@ var TimeAgo = /*#__PURE__*/function () {
316
394
  */
317
395
  }, {
318
396
  key: "formatValue",
319
- value: function formatValue(value, unit, _ref3) {
320
- var labels = _ref3.labels,
321
- future = _ref3.future;
397
+ value: function formatValue(value, unit, _ref4) {
398
+ var labels = _ref4.labels,
399
+ future = _ref4.future;
322
400
  return this.getFormattingRule(labels, unit, value, {
323
401
  future: future
324
402
  }).replace('{0}', this.formatNumber(Math.abs(value)));
@@ -337,8 +415,8 @@ var TimeAgo = /*#__PURE__*/function () {
337
415
  */
338
416
  }, {
339
417
  key: "getFormattingRule",
340
- value: function getFormattingRule(formattingRules, unit, value, _ref4) {
341
- var future = _ref4.future;
418
+ value: function getFormattingRule(formattingRules, unit, value, _ref5) {
419
+ var future = _ref5.future;
342
420
  // Passing the language is required in order to
343
421
  // be able to correctly classify the `value` as a number.
344
422
  var locale = this.locale;
@@ -472,7 +550,7 @@ TimeAgo.getDefaultLocale = function () {
472
550
  * @param {string} locale
473
551
  */
474
552
  TimeAgo.setDefaultLocale = function (locale) {
475
- return defaultLocale = locale;
553
+ defaultLocale = locale;
476
554
  };
477
555
 
478
556
  /**
@@ -480,14 +558,19 @@ TimeAgo.setDefaultLocale = function (locale) {
480
558
  * @param {Object} localeData
481
559
  */
482
560
  TimeAgo.addDefaultLocale = function (localeData) {
561
+ // Warn the user if they've previously already added a default locale (a different one).
483
562
  if (defaultLocaleHasBeenSpecified) {
484
- return console.error('[javascript-time-ago] `TimeAgo.addDefaultLocale()` can only be called once. To add other locales, use `TimeAgo.addLocale()`.');
563
+ if (TimeAgo.getDefaultLocale() !== localeData.locale) {
564
+ console.warn("[javascript-time-ago] You're adding \"".concat(localeData.locale, "\" as the default locale but you have already added \"").concat(TimeAgo.getDefaultLocale(), "\" as the default locale. \"").concat(localeData.locale, "\" is the default locale now."));
565
+ }
485
566
  }
486
567
  defaultLocaleHasBeenSpecified = true;
487
- TimeAgo.setDefaultLocale(localeData.locale);
568
+
569
+ // `addDefaultLocale()` is just a shortcut to `addLocale()` + `setDefaultLocale()`.
488
570
  TimeAgo.addLocale(localeData);
571
+ TimeAgo.setDefaultLocale(localeData.locale);
489
572
  };
490
- var defaultLocaleHasBeenSpecified;
573
+ var defaultLocaleHasBeenSpecified = false;
491
574
 
492
575
  /**
493
576
  * Adds locale data for a specific locale.
@@ -594,4 +677,22 @@ function getNowLabel(labels, nowLabels, longLabels, future) {
594
677
  function isStyle(variable) {
595
678
  return typeof variable === 'string' || isStyleObject(variable);
596
679
  }
680
+
681
+ // `setTimeout()` function has a bug when it fires immediately
682
+ // when the delay is longer than about `24.85` days.
683
+ // https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values
684
+ //
685
+ // Since `renderLabel()` function uses `setTimeout()` for recursion,
686
+ // that would mean infinite recursion.
687
+ //
688
+ // `setTimeoutSafe()` function works around that bug
689
+ // by capping the delay at the maximum allowed value.
690
+ //
691
+ function setTimeoutSafe(func, delay) {
692
+ return setTimeout(func, getSafeTimeoutDelay(delay));
693
+ }
694
+ function getSafeTimeoutDelay(delay) {
695
+ return Math.min(delay, SET_TIMEOUT_MAX_SAFE_DELAY);
696
+ }
697
+ var SET_TIMEOUT_MAX_SAFE_DELAY = 2147483647;
597
698
  //# sourceMappingURL=TimeAgo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeAgo.js","names":["RelativeTimeFormatPolyfill","Cache","chooseLocale","isStyleObject","getStep","getStepDenominator","getTimeToNextUpdate","addLocaleData","getLocaleData","defaultStyle","getStyleByName","getRoundFunction","UNITS","TimeAgo","locales","arguments","length","undefined","_ref","polyfill","_classCallCheck","locale","concat","getDefaultLocale","Intl","NumberFormat","numberFormat","IntlRelativeTimeFormat","RelativeTimeFormat","IntlPluralRules","PluralRules","relativeTimeFormatCache","pluralRulesCache","_createClass","key","value","format","input","style","options","isStyle","timestamp","getTimestamp","_this$getLabels","getLabels","flavour","labels","labelsType","now","Date","secondsPassed","future","nowLabel","getNowLabel","custom","date","time","elapsed","units","getTimeIntervalMeasurementUnits","round","_getStep","gradation","steps","getNextStep","_getStep2","_slicedToArray","prevStep","step","nextStep","formattedDate","formatDateForStep","timeToNextUpdate","_ref2","_this","formatAs","unit","formatValue","Error","JSON","stringify","amount","Math","abs","granularity","valueForFormatting","sign","getFormatter","_ref3","getFormattingRule","replace","formatNumber","formattingRules","_ref4","pastOrFuture","quantifierRules","quantifier","getPluralRules","select","other","number","String","get","put","map","localeData","_iterator","_createForOfIteratorHelperLoose","_step","done","_labelsType","default","defaultLocale","setDefaultLocale","addDefaultLocale","defaultLocaleHasBeenSpecified","console","error","addLocale","addLabels","name","constructor","isMockedDate","getTime","_typeof","object","allowedUnits","Object","keys","push","filter","indexOf","nowLabels","longLabels","past","second","current","variable"],"sources":["../source/TimeAgo.js"],"sourcesContent":["import RelativeTimeFormatPolyfill from 'relative-time-format'\r\n\r\nimport Cache from './cache.js'\r\nimport chooseLocale from './locale.js'\r\nimport isStyleObject from './isStyleObject.js'\r\n\r\nimport getStep from './steps/getStep.js'\r\nimport getStepDenominator from './steps/getStepDenominator.js'\r\nimport getTimeToNextUpdate from './steps/getTimeToNextUpdate.js'\r\n\r\nimport {\r\n\taddLocaleData,\r\n\tgetLocaleData\r\n} from './LocaleDataStore.js'\r\n\r\nimport defaultStyle from './style/roundMinute.js'\r\nimport getStyleByName from './style/getStyleByName.js'\r\n\r\nimport { getRoundFunction } from './round.js'\r\n\r\n// Valid time units.\r\nconst UNITS = [\r\n\t'now',\r\n\t// The rest are the same as in `Intl.RelativeTimeFormat`.\r\n\t'second',\r\n\t'minute',\r\n\t'hour',\r\n\t'day',\r\n\t'week',\r\n\t'month',\r\n\t'quarter',\r\n\t'year'\r\n]\r\n\r\nexport default class TimeAgo {\r\n\t/**\r\n\t * @param {(string|string[])} locales=[] - Preferred locales (or locale).\r\n\t * @param {boolean} [polyfill] — Pass `false` to use native `Intl.RelativeTimeFormat` and `Intl.PluralRules` instead of the polyfills.\r\n\t */\r\n\tconstructor(locales = [], { polyfill } = {}) {\r\n\t\t// Convert `locales` to an array.\r\n\t\tif (typeof locales === 'string') {\r\n\t\t\tlocales = [locales]\r\n\t\t}\r\n\r\n\t\t// Choose the most appropriate locale\r\n\t\t// from the list of `locales` added by the user.\r\n\t\t// For example, new TimeAgo(\"en-US\") -> \"en\".\r\n\t\tthis.locale = chooseLocale(\r\n\t\t\tlocales.concat(TimeAgo.getDefaultLocale()),\r\n\t\t\tgetLocaleData\r\n\t\t)\r\n\r\n\t\tif (typeof Intl !== 'undefined') {\r\n\t\t\t// Use `Intl.NumberFormat` for formatting numbers (when available).\r\n\t\t\tif (Intl.NumberFormat) {\r\n\t\t\t\tthis.numberFormat = new Intl.NumberFormat(this.locale)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Some people have requested the ability to use native\r\n\t\t// `Intl.RelativeTimeFormat` and `Intl.PluralRules`\r\n\t\t// instead of the polyfills.\r\n\t\t// https://github.com/catamphetamine/javascript-time-ago/issues/21\r\n\t\tif (polyfill === false) {\r\n\t\t\tthis.IntlRelativeTimeFormat = Intl.RelativeTimeFormat\r\n\t\t\tthis.IntlPluralRules = Intl.PluralRules\r\n\t\t} else {\r\n\t\t\tthis.IntlRelativeTimeFormat = RelativeTimeFormatPolyfill\r\n\t\t\tthis.IntlPluralRules = RelativeTimeFormatPolyfill.PluralRules\r\n\t\t}\r\n\r\n\t\t// Cache `Intl.RelativeTimeFormat` instance.\r\n\t\tthis.relativeTimeFormatCache = new Cache()\r\n\r\n\t\t// Cache `Intl.PluralRules` instance.\r\n\t\tthis.pluralRulesCache = new Cache()\r\n\t}\r\n\r\n\t/**\r\n\t * Formats relative date/time.\r\n\t *\r\n\t * @param {(number|Date)} input — A `Date` or a javascript timestamp.\r\n\t *\r\n\t * @param {(string|object)} style — Date/time formatting style. Either one of the built-in style names or a \"custom\" style definition object having `steps: object[]` and `labels: string[]`.\r\n\t *\r\n\t * @param {number} [options.now] - Sets the current date timestamp.\r\n\t *\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`:\r\n\t * as \"future\" (`true`) or \"past\" (`false`).\r\n\t * Is `false` by default, but should have been `true` actually,\r\n\t * in order to correspond to `Intl.RelativeTimeFormat`\r\n\t * that uses `future` formatting for `0` unless `-0` is passed.\r\n\t *\r\n\t * @param {string} [options.round] — Rounding method. Overrides the style's one.\r\n\t *\r\n\t * @param {boolean} [options.getTimeToNextUpdate] — Pass `true` to return `[formattedDate, timeToNextUpdate]` instead of just `formattedDate`.\r\n\t *\r\n\t * @return {string} The formatted relative date/time. If no eligible `step` is found, then an empty string is returned.\r\n\t */\r\n\tformat(input, style, options) {\r\n\t\tif (!options) {\r\n\t\t\tif (style && !isStyle(style)) {\r\n\t\t\t\toptions = style\r\n\t\t\t\tstyle = undefined\r\n\t\t\t} else {\r\n\t\t\t\toptions = {}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!style) {\r\n\t\t\tstyle = defaultStyle\r\n\t\t}\r\n\r\n\t\tif (typeof style === 'string') {\r\n\t\t\tstyle = getStyleByName(style)\r\n\t\t}\r\n\r\n\t\tconst timestamp = getTimestamp(input)\r\n\r\n\t\t// Get locale messages for this type of labels.\r\n\t\t// \"flavour\" is a legacy name for \"labels\".\r\n\t\tconst { labels, labelsType } = this.getLabels(style.flavour || style.labels)\r\n\r\n\t\tlet now\r\n\t\t// Can pass a custom `now`, e.g. for testing purposes.\r\n\t\t//\r\n\t\t// Legacy way was passing `now` in `style`.\r\n\t\t// That way is deprecated.\r\n\t\tif (style.now !== undefined) {\r\n\t\t\tnow = style.now\r\n\t\t}\r\n\t\t// The new way is passing `now` option to `.format()`.\r\n\t\tif (now === undefined && options.now !== undefined) {\r\n\t\t\tnow = options.now\r\n\t\t}\r\n\t\tif (now === undefined) {\r\n\t\t\tnow = Date.now()\r\n\t\t}\r\n\r\n\t\t// how much time has passed (in seconds)\r\n\t\tconst secondsPassed = (now - timestamp) / 1000 // in seconds\r\n\r\n\t\tconst future = options.future || secondsPassed < 0\r\n\r\n\t\tconst nowLabel = getNowLabel(\r\n\t\t\tlabels,\r\n\t\t\tgetLocaleData(this.locale).now,\r\n\t\t\tgetLocaleData(this.locale).long,\r\n\t\t\tfuture\r\n\t\t)\r\n\r\n\t\t// `custom` – A function of `{ elapsed, time, date, now, locale }`.\r\n\t\t//\r\n\t\t// Looks like `custom` function is deprecated and will be removed\r\n\t\t// in the next major version.\r\n\t\t//\r\n\t\t// If this function returns a value, then the `.format()` call will return that value.\r\n\t\t// Otherwise the relative date/time is formatted as usual.\r\n\t\t// This feature is currently not used anywhere and is here\r\n\t\t// just for providing the ultimate customization point\r\n\t\t// in case anyone would ever need that. Prefer using\r\n\t\t// `steps[step].format(value, locale)` instead.\r\n\t\t//\r\n\t\tif (style.custom) {\r\n\t\t\tconst custom = style.custom({\r\n\t\t\t\tnow,\r\n\t\t\t\tdate: new Date(timestamp),\r\n\t\t\t\ttime: timestamp,\r\n\t\t\t\telapsed: secondsPassed,\r\n\t\t\t\tlocale: this.locale\r\n\t\t\t})\r\n\t\t\tif (custom !== undefined) {\r\n\t\t\t\t// Won't return `timeToNextUpdate` here\r\n\t\t\t\t// because `custom()` seems deprecated.\r\n\t\t\t\treturn custom\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Get the list of available time interval units.\r\n\t\tconst units = getTimeIntervalMeasurementUnits(\r\n\t\t\t// Controlling `style.steps` through `style.units` seems to be deprecated:\r\n\t\t\t// create a new custom `style` instead.\r\n\t\t\tstyle.units,\r\n\t\t\tlabels,\r\n\t\t\tnowLabel\r\n\t\t)\r\n\r\n\t\t// // If no available time unit is suitable, just output an empty string.\r\n\t\t// if (units.length === 0) {\r\n\t\t// \tconsole.error(`None of the \"${units.join(', ')}\" time units have been found in \"${labelsType}\" labels for \"${this.locale}\" locale.`)\r\n\t\t// \treturn ''\r\n\t\t// }\r\n\r\n\t\tconst round = options.round || style.round\r\n\r\n\t\t// Choose the appropriate time measurement unit\r\n\t\t// and get the corresponding rounded time amount.\r\n\t\tconst [prevStep, step, nextStep] = getStep(\r\n\t\t\t// \"gradation\" is a legacy name for \"steps\".\r\n\t\t\t// For historical reasons, \"approximate\" steps are used by default.\r\n\t\t\t// In the next major version, there'll be no default for `steps`.\r\n\t\t\tstyle.gradation || style.steps || defaultStyle.steps,\r\n\t\t\tsecondsPassed,\r\n\t\t\t{ now, units, round, future, getNextStep: true }\r\n\t\t)\r\n\r\n\t\tconst formattedDate = this.formatDateForStep(timestamp, step, secondsPassed, {\r\n\t\t\tlabels,\r\n\t\t\tlabelsType,\r\n\t\t\tnowLabel,\r\n\t\t\tnow,\r\n\t\t\tfuture,\r\n\t\t\tround\r\n\t\t}) || ''\r\n\r\n\t\tif (options.getTimeToNextUpdate) {\r\n\t\t\tconst timeToNextUpdate = getTimeToNextUpdate(timestamp, step, {\r\n\t\t\t\tnextStep,\r\n\t\t\t\tprevStep,\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture,\r\n\t\t\t\tround\r\n\t\t\t})\r\n\t\t\treturn [formattedDate, timeToNextUpdate]\r\n\t\t}\r\n\r\n\t\treturn formattedDate\r\n\t}\r\n\r\n\tformatDateForStep(timestamp, step, secondsPassed, {\r\n\t\tlabels,\r\n\t\tlabelsType,\r\n\t\tnowLabel,\r\n\t\tnow,\r\n\t\tfuture,\r\n\t\tround\r\n\t}) {\r\n\t\t// If no step matches, then output an empty string.\r\n\t\tif (!step) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (step.format) {\r\n\t\t\treturn step.format(timestamp, this.locale, {\r\n\t\t\t\tformatAs: (unit, value) => {\r\n\t\t\t\t\t// Mimicks `Intl.RelativeTimeFormat.format()`.\r\n\t\t\t\t\treturn this.formatValue(value, unit, {\r\n\t\t\t\t\t\tlabels,\r\n\t\t\t\t\t\tfuture\r\n\t\t\t\t\t})\r\n\t\t\t\t},\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\t// \"unit\" is now called \"formatAs\".\r\n\t\tconst unit = step.unit || step.formatAs\r\n\r\n\t\tif (!unit) {\r\n\t\t\tthrow new Error(`[javascript-time-ago] Each step must define either \\`formatAs\\` or \\`format()\\`. Step: ${JSON.stringify(step)}`)\r\n\t\t}\r\n\r\n\t\t// `Intl.RelativeTimeFormat` doesn't operate in \"now\" units.\r\n\t\t// Therefore, threat \"now\" as a special case.\r\n\t\tif (unit === 'now') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\r\n\t\t// Amount in units.\r\n\t\tlet amount = Math.abs(secondsPassed) / getStepDenominator(step)\r\n\r\n\t\t// Apply granularity to the time amount\r\n\t\t// (and fallback to the previous step\r\n\t\t// if the first level of granularity\r\n\t\t// isn't met by this amount)\r\n\t\t//\r\n\t\t// `granularity` — (advanced) Time interval value \"granularity\".\r\n\t\t// For example, it could be set to `5` for minutes to allow only 5-minute increments\r\n\t\t// when formatting time intervals: `0 minutes`, `5 minutes`, `10 minutes`, etc.\r\n\t\t// Perhaps this feature will be removed because there seem to be no use cases\r\n\t\t// of it in the real world.\r\n\t\t//\r\n\t\tif (step.granularity) {\r\n\t\t\t// Recalculate the amount of seconds passed based on granularity\r\n\t\t\tamount = getRoundFunction(round)(amount / step.granularity) * step.granularity\r\n\t\t}\r\n\r\n\t\tlet valueForFormatting = -1 * Math.sign(secondsPassed) * getRoundFunction(round)(amount)\r\n\r\n\t\t// By default, this library formats a `0` in \"past\" mode,\r\n\t\t// unless `future: true` option is passed.\r\n\t\t// This is different to `relative-time-format`'s behavior\r\n\t\t// which formats a `0` in \"future\" mode by default, unless it's a `-0`.\r\n\t\t// So, convert `0` to `-0` if `future: true` option wasn't passed.\r\n\t\t// `=== 0` matches both `0` and `-0`.\r\n\t\tif (valueForFormatting === 0) {\r\n\t\t\tif (future) {\r\n\t\t\t\tvalueForFormatting = 0\r\n\t\t\t} else {\r\n\t\t\t\tvalueForFormatting = -0\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tswitch (labelsType) {\r\n\t\t\tcase 'long':\r\n\t\t\tcase 'short':\r\n\t\t\tcase 'narrow':\r\n\t\t\t\t// Format the amount using `Intl.RelativeTimeFormat`.\r\n\t\t\t\treturn this.getFormatter(labelsType).format(valueForFormatting, unit)\r\n\t\t\tdefault:\r\n\t\t\t\t// Format the amount.\r\n\t\t\t\t// (mimicks `Intl.RelativeTimeFormat` behavior for other time label styles)\r\n\t\t\t\treturn this.formatValue(valueForFormatting, unit, {\r\n\t\t\t\t\tlabels,\r\n\t\t\t\t\tfuture\r\n\t\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Mimicks what `Intl.RelativeTimeFormat` does for additional locale styles.\r\n\t * @param {number} value\r\n\t * @param {string} unit\r\n\t * @param {object} options.labels — Relative time labels.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default, but should have been `true` actually.\r\n\t * @return {string}\r\n\t */\r\n\tformatValue(value, unit, { labels, future }) {\r\n\t\treturn this.getFormattingRule(labels, unit, value, { future })\r\n\t\t\t.replace('{0}', this.formatNumber(Math.abs(value)))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns formatting rule for `value` in `units` (either in past or in future).\r\n\t * @param {object} formattingRules — Relative time labels for different units.\r\n\t * @param {string} unit - Time interval measurement unit.\r\n\t * @param {number} value - Time interval value.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default.\r\n\t * @return {string}\r\n\t * @example\r\n\t * // Returns \"{0} days ago\"\r\n\t * getFormattingRule(en.long, \"day\", -2, 'en')\r\n\t */\r\n\tgetFormattingRule(formattingRules, unit, value, { future }) {\r\n\t\t// Passing the language is required in order to\r\n\t\t// be able to correctly classify the `value` as a number.\r\n\t\tconst locale = this.locale\r\n\t\tformattingRules = formattingRules[unit]\r\n\t\t// Check for a special \"compacted\" rules case:\r\n\t\t// if formatting rules are the same for \"past\" and \"future\",\r\n\t\t// and also for all possible `value`s, then those rules are\r\n\t\t// stored as a single string.\r\n\t\tif (typeof formattingRules === 'string') {\r\n\t\t\treturn formattingRules\r\n\t\t}\r\n\t\t// Choose either \"past\" or \"future\" based on time `value` sign.\r\n\t\t// If \"past\" is same as \"future\" then they're stored as \"other\".\r\n\t\t// If there's only \"other\" then it's being collapsed.\r\n\t\tconst pastOrFuture = value === 0 ? (future ? 'future' : 'past') : (value < 0 ? 'past' : 'future')\r\n\t\tconst quantifierRules = formattingRules[pastOrFuture] || formattingRules\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof quantifierRules === 'string') {\r\n\t\t\treturn quantifierRules\r\n\t\t}\r\n\t\t// Quantify `value`.\r\n\t\tconst quantifier = this.getPluralRules().select(Math.abs(value))\r\n\t\t// \"other\" rule is supposed to always be present.\r\n\t\t// If only \"other\" rule is present then \"rules\" is not an object and is a string.\r\n\t\treturn quantifierRules[quantifier] || quantifierRules.other\r\n\t}\r\n\r\n\t/**\r\n\t * Formats a number into a string.\r\n\t * Uses `Intl.NumberFormat` when available.\r\n\t * @param {number} number\r\n\t * @return {string}\r\n\t */\r\n\tformatNumber(number) {\r\n\t\treturn this.numberFormat ? this.numberFormat.format(number) : String(number)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.RelativeTimeFormat` for a given `labelsType`.\r\n\t * @param {string} labelsType\r\n\t * @return {object} `Intl.RelativeTimeFormat` instance\r\n\t */\r\n\tgetFormatter(labelsType) {\r\n\t\t// `Intl.RelativeTimeFormat` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.relativeTimeFormatCache.get(this.locale, labelsType) ||\r\n\t\t\tthis.relativeTimeFormatCache.put(this.locale, labelsType, new this.IntlRelativeTimeFormat(this.locale, { style: labelsType }))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.PluralRules` instance.\r\n\t * @return {object} `Intl.PluralRules` instance\r\n\t */\r\n\tgetPluralRules() {\r\n\t\t// `Intl.PluralRules` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.pluralRulesCache.get(this.locale) ||\r\n\t\t\tthis.pluralRulesCache.put(this.locale, new this.IntlPluralRules(this.locale))\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Gets localized labels for this type of labels.\r\n\t *\r\n\t * @param {(string|string[])} labelsType - Relative date/time labels type.\r\n\t * If it's an array then all label types are tried\r\n\t * until a suitable one is found.\r\n\t *\r\n\t * @returns {Object} Returns an object of shape { labelsType, labels }\r\n\t */\r\n\tgetLabels(labelsType = []) {\r\n\t\t// Convert `labels` to an array.\r\n\t\tif (typeof labelsType === 'string') {\r\n\t\t\tlabelsType = [labelsType]\r\n\t\t}\r\n\r\n\t\t// Supports legacy \"tiny\" and \"mini-time\" label styles.\r\n\t\tlabelsType = labelsType.map((labelsType) => {\r\n\t\t\tswitch (labelsType) {\r\n\t\t\t\tcase 'tiny':\r\n\t\t\t\tcase 'mini-time':\r\n\t\t\t\t\treturn 'mini'\r\n\t\t\t\tdefault:\r\n\t\t\t\t\treturn labelsType\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\t// \"long\" labels type is the default one.\r\n\t\t// (it's always present for all languages)\r\n\t\tlabelsType = labelsType.concat('long')\r\n\r\n\t\t// Find a suitable labels type.\r\n\t\tconst localeData = getLocaleData(this.locale)\r\n\t\tfor (const _labelsType of labelsType) {\r\n\t\t\tif (localeData[_labelsType]) {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tlabelsType: _labelsType,\r\n\t\t\t\t\tlabels: localeData[_labelsType]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/**\r\n * Default locale global variable.\r\n */\r\nlet defaultLocale = 'en'\r\n\r\n/**\r\n * Gets default locale.\r\n * @return {string} locale\r\n */\r\nTimeAgo.getDefaultLocale = () => defaultLocale\r\n\r\n/**\r\n * Sets default locale.\r\n * @param {string} locale\r\n */\r\nTimeAgo.setDefaultLocale = (locale) => defaultLocale = locale\r\n\r\n/**\r\n * Adds locale data for a specific locale and marks the locale as default.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addDefaultLocale = function(localeData) {\r\n\tif (defaultLocaleHasBeenSpecified) {\r\n\t\treturn console.error('[javascript-time-ago] `TimeAgo.addDefaultLocale()` can only be called once. To add other locales, use `TimeAgo.addLocale()`.')\r\n\t}\r\n\tdefaultLocaleHasBeenSpecified = true\r\n\tTimeAgo.setDefaultLocale(localeData.locale)\r\n\tTimeAgo.addLocale(localeData)\r\n}\r\n\r\nlet defaultLocaleHasBeenSpecified\r\n\r\n/**\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addLocale = function(localeData) {\r\n\taddLocaleData(localeData)\r\n\tRelativeTimeFormatPolyfill.addLocale(localeData)\r\n}\r\n\r\n/**\r\n * (legacy alias)\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n * @deprecated\r\n */\r\nTimeAgo.locale = TimeAgo.addLocale\r\n\r\n/**\r\n * Adds custom labels to locale data.\r\n * @param {string} locale\r\n * @param {string} name\r\n * @param {object} labels\r\n */\r\nTimeAgo.addLabels = (locale, name, labels) => {\r\n\tlet localeData = getLocaleData(locale)\r\n\tif (!localeData) {\r\n\t\taddLocaleData({\r\n\t\t\tlocale\r\n\t\t})\r\n\t\tlocaleData = getLocaleData(locale)\r\n\t\t// throw new Error(`[javascript-time-ago] No data for locale \"${locale}\"`)\r\n\t}\r\n\tlocaleData[name] = labels\r\n}\r\n\r\n// Normalizes `.format()` `time` argument.\r\nfunction getTimestamp(input) {\r\n\tif (input.constructor === Date || isMockedDate(input)) {\r\n\t\treturn input.getTime()\r\n\t}\r\n\r\n\tif (typeof input === 'number') {\r\n\t\treturn input\r\n\t}\r\n\r\n\t// For some weird reason istanbul doesn't see this `throw` covered.\r\n\t/* istanbul ignore next */\r\n\tthrow new Error(`Unsupported relative time formatter input: ${typeof input}, ${input}`)\r\n}\r\n\r\n// During testing via some testing libraries `Date`s aren't actually `Date`s.\r\n// https://github.com/catamphetamine/javascript-time-ago/issues/22\r\nfunction isMockedDate(object) {\r\n\treturn typeof object === 'object' && typeof object.getTime === 'function'\r\n}\r\n\r\n// Get available time interval measurement units.\r\nfunction getTimeIntervalMeasurementUnits(allowedUnits, labels, nowLabel) {\r\n\t// Get all time interval measurement units that're available\r\n\t// in locale data for a given time labels style.\r\n\tlet units = Object.keys(labels)\r\n\r\n\t// `now` unit is handled separately and is shipped in its own `now.json` file.\r\n\t// `now.json` isn't present for all locales, so it could be substituted with\r\n\t// \".second.current\".\r\n\t// Add `now` unit if it's available in locale data.\r\n\tif (nowLabel) {\r\n\t\tunits.push('now')\r\n\t}\r\n\r\n\t// If only a specific set of available time measurement units can be used\r\n\t// then only those units are allowed (if they're present in locale data).\r\n\tif (allowedUnits) {\r\n\t\tunits = allowedUnits.filter(unit => unit === 'now' || units.indexOf(unit) >= 0)\r\n\t}\r\n\r\n\treturn units\r\n}\r\n\r\nfunction getNowLabel(labels, nowLabels, longLabels, future) {\r\n\tconst nowLabel = labels.now || (nowLabels && nowLabels.now)\r\n\t// Specific \"now\" message form extended locale data (if present).\r\n\tif (nowLabel) {\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof nowLabel === 'string') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\t\t// Not handling `value === 0` as `localeData.now.current` here\r\n\t\t// because it wouldn't make sense: \"now\" is a moment,\r\n\t\t// so one can't possibly differentiate between a\r\n\t\t// \"previous\" moment, a \"current\" moment and a \"next moment\".\r\n\t\t// It can only be differentiated between \"past\" and \"future\".\r\n\t\tif (future) {\r\n\t\t\treturn nowLabel.future\r\n\t\t} else {\r\n\t\t\treturn nowLabel.past\r\n\t\t}\r\n\t}\r\n\t// Use \".second.current\" as \"now\" message.\r\n\tif (longLabels && longLabels.second && longLabels.second.current) {\r\n\t\treturn longLabels.second.current\r\n\t}\r\n}\r\n\r\nfunction isStyle(variable) {\r\n\treturn typeof variable === 'string' || isStyleObject(variable)\r\n}"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,0BAA0B,M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OAAIA,IAAI,KAAK,KAAK,IAAIlB,KAAK,CAACyE,OAAO,CAACvD,IAAI,CAAC,IAAI,CAAC;IAAA,EAAC;EAChF;EAEA,OAAOlB,KAAK;AACb;AAEA,SAASL,WAAWA,CAACP,MAAM,EAAEsF,SAAS,EAAEC,UAAU,EAAElF,MAAM,EAAE;EAC3D,IAAMC,QAAQ,GAAGN,MAAM,CAACE,GAAG,IAAKoF,SAAS,IAAIA,SAAS,CAACpF,GAAI;EAC3D;EACA,IAAII,QAAQ,EAAE;IACb;IACA,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MACjC,OAAOA,QAAQ;IAChB;IACA;IACA;IACA;IACA;IACA;IACA,IAAID,MAAM,EAAE;MACX,OAAOC,QAAQ,CAACD,MAAM;IACvB,CAAC,MAAM;MACN,OAAOC,QAAQ,CAACkF,IAAI;IACrB;EACD;EACA;EACA,IAAID,UAAU,IAAIA,UAAU,CAACE,MAAM,IAAIF,UAAU,CAACE,MAAM,CAACC,OAAO,EAAE;IACjE,OAAOH,UAAU,CAACE,MAAM,CAACC,OAAO;EACjC;AACD;AAEA,SAAShG,OAAOA,CAACiG,QAAQ,EAAE;EAC1B,OAAO,OAAOA,QAAQ,KAAK,QAAQ,IAAItI,aAAa,CAACsI,QAAQ,CAAC;AAC/D","ignoreList":[]}
1
+ {"version":3,"file":"TimeAgo.js","names":["RelativeTimeFormatPolyfill","Cache","chooseLocale","isStyleObject","getStep","getStepDenominator","getTimeToNextUpdate","addLocaleData","getLocaleData","defaultStyle","getStyleByName","getRoundFunction","TimeAgo","locales","arguments","length","undefined","_ref","polyfill","_classCallCheck","locale","concat","getDefaultLocale","Intl","NumberFormat","numberFormat","IntlRelativeTimeFormat","RelativeTimeFormat","IntlPluralRules","PluralRules","relativeTimeFormatCache","pluralRulesCache","_createClass","key","value","format","input","style","options","_this","isStyle","timestamp","getTimestamp","_this$getLabels","getLabels","flavour","labels","labelsType","round","now","nowRealWhenCalled","Date","getTextAndTextRefreshDelayGetterFunctions","_ref2","secondsPassed","future","nowLabel","getNowLabel","custom","text","date","time","elapsed","getText","getTextRefreshDelay","Error","units","getTimeIntervalMeasurementUnits","_getStep","gradation","steps","getNextStep","_getStep2","_slicedToArray","prevStep","step","nextStep","formatDateForStep","timeToNextUpdate","getTimeToNextUpdateUncapped","getSafeTimeoutDelay","_getTextAndTextRefres","refresh","defaultRefreshInterval","refreshTimer","scheduleRefresh","delay","setTimeoutSafe","_getTextAndTextRefres2","stopRefreshing","clearTimeout","_ref3","_this2","formatAs","unit","amount","formatValue","JSON","stringify","Math","abs","granularity","valueForFormatting","sign","getFormatter","_ref4","getFormattingRule","replace","formatNumber","formattingRules","_ref5","pastOrFuture","quantifierRules","quantifier","getPluralRules","select","other","number","String","get","put","map","localeData","_iterator","_createForOfIteratorHelperLoose","_step","done","_labelsType","default","defaultLocale","setDefaultLocale","addDefaultLocale","defaultLocaleHasBeenSpecified","console","warn","addLocale","addLabels","name","constructor","isMockedDate","getTime","_typeof","object","allowedUnits","Object","keys","push","filter","indexOf","nowLabels","longLabels","past","second","current","variable","func","setTimeout","min","SET_TIMEOUT_MAX_SAFE_DELAY"],"sources":["../source/TimeAgo.js"],"sourcesContent":["import RelativeTimeFormatPolyfill from 'relative-time-format'\r\n\r\nimport Cache from './cache.js'\r\nimport chooseLocale from './locale.js'\r\nimport isStyleObject from './isStyleObject.js'\r\n\r\nimport getStep from './steps/getStep.js'\r\nimport getStepDenominator from './steps/getStepDenominator.js'\r\nimport getTimeToNextUpdate from './steps/getTimeToNextUpdate.js'\r\n\r\nimport {\r\n\taddLocaleData,\r\n\tgetLocaleData\r\n} from './LocaleDataStore.js'\r\n\r\nimport defaultStyle from './style/roundMinute.js'\r\nimport getStyleByName from './style/getStyleByName.js'\r\n\r\nimport { getRoundFunction } from './round.js'\r\n\r\nexport default class TimeAgo {\r\n\t/**\r\n\t * @param {(string|string[])} locales=[] - Preferred locales (or locale).\r\n\t * @param {boolean} [polyfill] — Pass `false` to use native `Intl.RelativeTimeFormat` and `Intl.PluralRules` instead of the polyfills.\r\n\t */\r\n\tconstructor(locales = [], { polyfill } = {}) {\r\n\t\t// Convert `locales` to an array.\r\n\t\tif (typeof locales === 'string') {\r\n\t\t\tlocales = [locales]\r\n\t\t}\r\n\r\n\t\t// Choose the most appropriate locale\r\n\t\t// from the list of `locales` added by the user.\r\n\t\t// For example, new TimeAgo(\"en-US\") -> \"en\".\r\n\t\tthis.locale = chooseLocale(\r\n\t\t\tlocales.concat(TimeAgo.getDefaultLocale()),\r\n\t\t\tgetLocaleData\r\n\t\t)\r\n\r\n\t\tif (typeof Intl !== 'undefined') {\r\n\t\t\t// Use `Intl.NumberFormat` for formatting numbers (when available).\r\n\t\t\tif (Intl.NumberFormat) {\r\n\t\t\t\tthis.numberFormat = new Intl.NumberFormat(this.locale)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Some people have requested the ability to use native\r\n\t\t// `Intl.RelativeTimeFormat` and `Intl.PluralRules`\r\n\t\t// instead of the polyfills.\r\n\t\t// https://github.com/catamphetamine/javascript-time-ago/issues/21\r\n\t\tif (polyfill === false) {\r\n\t\t\tthis.IntlRelativeTimeFormat = Intl.RelativeTimeFormat\r\n\t\t\tthis.IntlPluralRules = Intl.PluralRules\r\n\t\t} else {\r\n\t\t\tthis.IntlRelativeTimeFormat = RelativeTimeFormatPolyfill\r\n\t\t\tthis.IntlPluralRules = RelativeTimeFormatPolyfill.PluralRules\r\n\t\t}\r\n\r\n\t\t// Cache `Intl.RelativeTimeFormat` instance.\r\n\t\tthis.relativeTimeFormatCache = new Cache()\r\n\r\n\t\t// Cache `Intl.PluralRules` instance.\r\n\t\tthis.pluralRulesCache = new Cache()\r\n\t}\r\n\r\n\t/**\r\n\t * Formats relative date/time.\r\n\t *\r\n\t * @param {(number|Date)} input — A `Date` or a javascript timestamp.\r\n\t *\r\n\t * @param {(string|object)} style — Date/time formatting style. Either one of the built-in style names or a \"custom\" style definition object having `steps: object[]` and `labels: string[]`.\r\n\t *\r\n\t * @param {number} [options.now] - Sets the current date timestamp.\r\n\t *\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`:\r\n\t * as \"future\" (`true`) or \"past\" (`false`).\r\n\t * Is `false` by default, but should have been `true` actually,\r\n\t * in order to correspond to `Intl.RelativeTimeFormat`\r\n\t * that uses `future` formatting for `0` unless `-0` is passed.\r\n\t *\r\n\t * @param {string} [options.round] — Rounding method. Overrides the style's one.\r\n\t *\r\n\t * @param {boolean} [options.getTimeToNextUpdate] — Pass `true` to return `[formattedDate, timeToNextUpdate]` instead of just `formattedDate`.\r\n\t *\r\n\t * @param {boolean} [options.getTimeToNextUpdateUncapped] — Pass `true` to not apply the workaround for `setTimeout()` bug. https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values\r\n\t *\r\n\t * @param {function} [options.refresh] — When `refresh` function is passed, it will be automatically called with a new text when it's time to refresh the label.\r\n\t *\r\n\t * @return {string} The formatted relative date/time. If no eligible `step` is found, then an empty string is returned.\r\n\t */\r\n\tformat(input, style, options) {\r\n\t\tif (!options) {\r\n\t\t\tif (style && !isStyle(style)) {\r\n\t\t\t\toptions = style\r\n\t\t\t\tstyle = undefined\r\n\t\t\t} else {\r\n\t\t\t\toptions = {}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!style) {\r\n\t\t\tstyle = defaultStyle\r\n\t\t}\r\n\r\n\t\tif (typeof style === 'string') {\r\n\t\t\tstyle = getStyleByName(style)\r\n\t\t}\r\n\r\n\t\tconst timestamp = getTimestamp(input)\r\n\r\n\t\t// Get locale messages for this type of labels.\r\n\t\t// \"flavour\" is a legacy name for \"labels\".\r\n\t\tconst { labels, labelsType } = this.getLabels(style.flavour || style.labels)\r\n\r\n\t\t// `round` setting could be passed as a parameter to `.format()` function\r\n\t\t// or be configured globally for a style.\r\n\t\tconst round = options.round || style.round\r\n\r\n\t\t// A developer can pass a custom `now`, e.g. for testing purposes.\r\n\t\tlet now\r\n\t\tconst nowRealWhenCalled = Date.now()\r\n\t\t// (deprecated)\r\n\t\t// Legacy way was passing `now` in `style`.\r\n\t\tif (style.now !== undefined) {\r\n\t\t\tnow = style.now\r\n\t\t}\r\n\t\t// One could pass `now` option to `.format()`.\r\n\t\tif (now === undefined && options.now !== undefined) {\r\n\t\t\tnow = options.now\r\n\t\t}\r\n\t\t// The default `now` is `Date.now()`.\r\n\t\tif (now === undefined) {\r\n\t\t\tnow = nowRealWhenCalled\r\n\t\t}\r\n\r\n\t\tconst getTextAndTextRefreshDelayGetterFunctions = ({ now }) => {\r\n\t\t\t// how much time has passed (in seconds)\r\n\t\t\tconst secondsPassed = (now - timestamp) / 1000 // in seconds\r\n\r\n\t\t\tconst future = options.future || secondsPassed < 0\r\n\r\n\t\t\tconst nowLabel = getNowLabel(\r\n\t\t\t\tlabels,\r\n\t\t\t\tgetLocaleData(this.locale).now,\r\n\t\t\t\tgetLocaleData(this.locale).long,\r\n\t\t\t\tfuture\r\n\t\t\t)\r\n\r\n\t\t\t// (deprecated)\r\n\t\t\t//\r\n\t\t\t// `custom` – A function of `{ elapsed, time, date, now, locale }`.\r\n\t\t\t//\r\n\t\t\t// If this function returns a value, then the `.format()` call will return that value.\r\n\t\t\t// Otherwise the relative date/time is formatted as usual.\r\n\t\t\t// This feature is currently not used anywhere and is here\r\n\t\t\t// just for providing the ultimate customization point\r\n\t\t\t// in case anyone would ever need that. Prefer using\r\n\t\t\t// `steps[step].format(value, locale)` instead.\r\n\t\t\t//\r\n\t\t\tif (style.custom) {\r\n\t\t\t\tconst text = style.custom({\r\n\t\t\t\t\tnow,\r\n\t\t\t\t\tdate: new Date(timestamp),\r\n\t\t\t\t\ttime: timestamp,\r\n\t\t\t\t\telapsed: secondsPassed,\r\n\t\t\t\t\tlocale: this.locale\r\n\t\t\t\t})\r\n\t\t\t\tif (text !== undefined) {\r\n\t\t\t\t\t// Won't return `timeToNextUpdate` here\r\n\t\t\t\t\t// because `custom()` seems deprecated.\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tgetText: () => text,\r\n\t\t\t\t\t\tgetTextRefreshDelay: () => {\r\n\t\t\t\t\t\t\tthrow new Error('`getTimeToNextUpdate: true` feature is not supported by legacy \"styles\" that have a `custom` function')\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Get the list of available time interval units.\r\n\t\t\tconst units = getTimeIntervalMeasurementUnits(\r\n\t\t\t\t// Controlling `style.steps` through `style.units` seems to be deprecated:\r\n\t\t\t\t// create a new custom `style` instead.\r\n\t\t\t\tstyle.units,\r\n\t\t\t\tlabels,\r\n\t\t\t\tnowLabel\r\n\t\t\t)\r\n\r\n\t\t\t// Choose the appropriate time measurement unit\r\n\t\t\t// and get the corresponding rounded time amount.\r\n\t\t\tconst [prevStep, step, nextStep] = getStep(\r\n\t\t\t\t// \"gradation\" is a legacy name for \"steps\".\r\n\t\t\t\t// For historical reasons, \"approximate\" steps are used by default.\r\n\t\t\t\t// In the next major version, there'll be no default for `steps`.\r\n\t\t\t\tstyle.gradation || style.steps || defaultStyle.steps,\r\n\t\t\t\tsecondsPassed,\r\n\t\t\t\t{ now, units, round, future, getNextStep: true }\r\n\t\t\t)\r\n\r\n\t\t\tconst getText = () => {\r\n\t\t\t\treturn this.formatDateForStep(timestamp, step, secondsPassed, {\r\n\t\t\t\t\tlabels,\r\n\t\t\t\t\tlabelsType,\r\n\t\t\t\t\tnowLabel,\r\n\t\t\t\t\tnow,\r\n\t\t\t\t\tfuture,\r\n\t\t\t\t\tround\r\n\t\t\t\t}) || ''\r\n\t\t\t}\r\n\r\n\t\t\t// Returns the time (in milliseconds) after which the formatted date label should be refreshed.\r\n\t\t\t//\r\n\t\t\t// It will return `undefined` for a custom style\r\n\t\t\t// that doesn't meet the minimum requirements for this feature.\r\n\t\t\t// See the README for more details.\r\n\t\t\t//\r\n\t\t\tconst getTextRefreshDelay = () => {\r\n\t\t\t\tconst timeToNextUpdate = getTimeToNextUpdate(timestamp, step, {\r\n\t\t\t\t\tnextStep,\r\n\t\t\t\t\tprevStep,\r\n\t\t\t\t\tnow,\r\n\t\t\t\t\tfuture,\r\n\t\t\t\t\tround\r\n\t\t\t\t})\r\n\r\n\t\t\t\t// `timeToNextUpdate` could be `undefined` for a custom style\r\n\t\t\t\t// that doesn't meet the minimum requirements for this feature.\r\n\t\t\t\t// See the README for more details.\r\n\t\t\t\tif (typeof timeToNextUpdate === 'number') {\r\n\t\t\t\t\t// `setTimeout()` function has a bug when it fires immediately\r\n\t\t\t\t\t// when the delay is longer than about `24.85` days.\r\n\t\t\t\t\t// https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// To not burden the end user of this library with manually working around that bug,\r\n\t\t\t\t\t// this library automatically caps the returned delay to a maximum value that\r\n\t\t\t\t\t// still works with `setTimeout()` and doesn't break it.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// The end user of this library could still opt out of this auto-workaround feature\r\n\t\t\t\t\t// by passing a `getTimeToNextUpdateUncapped: true` option.\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (options.getTimeToNextUpdateUncapped) {\r\n\t\t\t\t\t\treturn timeToNextUpdate\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn getSafeTimeoutDelay(timeToNextUpdate)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn { getText, getTextRefreshDelay }\r\n\t\t}\r\n\r\n\t\tconst { getText, getTextRefreshDelay } = getTextAndTextRefreshDelayGetterFunctions({ now })\r\n\r\n\t\tif (options.getTimeToNextUpdate) {\r\n\t\t\treturn [getText(), getTextRefreshDelay()]\r\n\t\t}\r\n\r\n\t\tif (options.refresh) {\r\n\t\t\t// `getTextRefreshDelay()` will return `undefined` for a custom style\r\n\t\t\t// that doesn't meet the minimum requirements for this feature.\r\n\t\t\t// See the README for more details.\r\n\t\t\t//\r\n\t\t\t// This is a \"sensible default\" interval for refreshing time labels\r\n\t\t\t// that use such custom style.\r\n\t\t\t//\r\n\t\t\tconst defaultRefreshInterval = 60 * 1000\r\n\r\n\t\t\t// If `refresh` function was passed, schedule it to be called when the time comes,\r\n\t\t\t// after which schedule the next refresh.\r\n\t\t\tlet refreshTimer\r\n\t\t\tconst scheduleRefresh = (delay = defaultRefreshInterval) => {\r\n\t\t\t\trefreshTimer = setTimeoutSafe(() => {\r\n\t\t\t\t\tconst { getText, getTextRefreshDelay } = getTextAndTextRefreshDelayGetterFunctions({\r\n\t\t\t\t\t\tnow: now + (Date.now() - nowRealWhenCalled)\r\n\t\t\t\t\t})\r\n\t\t\t\t\toptions.refresh(getText())\r\n\t\t\t\t\tscheduleRefresh(getTextRefreshDelay())\r\n\t\t\t\t}, delay)\r\n\t\t\t}\r\n\r\n\t\t\tscheduleRefresh(getTextRefreshDelay())\r\n\r\n\t\t\tconst stopRefreshing = () => {\r\n\t\t\t\tclearTimeout(refreshTimer)\r\n\t\t\t}\r\n\r\n\t\t\treturn [getText(), stopRefreshing]\r\n\t\t}\r\n\r\n\t\treturn getText()\r\n\t}\r\n\r\n\tformatDateForStep(timestamp, step, secondsPassed, {\r\n\t\tlabels,\r\n\t\tlabelsType,\r\n\t\tnowLabel,\r\n\t\tnow,\r\n\t\tfuture,\r\n\t\tround\r\n\t}) {\r\n\t\t// If no step matches, then output an empty string.\r\n\t\tif (!step) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (step.format) {\r\n\t\t\treturn step.format(timestamp, this.locale, {\r\n\t\t\t\tformatAs: (unit, amount) => {\r\n\t\t\t\t\t// Mimicks `Intl.RelativeTimeFormat.format()`.\r\n\t\t\t\t\treturn this.formatValue(amount, unit, {\r\n\t\t\t\t\t\tlabels,\r\n\t\t\t\t\t\tfuture\r\n\t\t\t\t\t})\r\n\t\t\t\t},\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\t// \"unit\" is now called \"formatAs\".\r\n\t\tconst unit = step.unit || step.formatAs\r\n\r\n\t\tif (!unit) {\r\n\t\t\tthrow new Error(`[javascript-time-ago] Each step must define either \\`formatAs\\` or \\`format()\\`. Step: ${JSON.stringify(step)}`)\r\n\t\t}\r\n\r\n\t\t// `Intl.RelativeTimeFormat` doesn't operate in \"now\" units.\r\n\t\t// Therefore, threat \"now\" as a special case.\r\n\t\tif (unit === 'now') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\r\n\t\t// Amount in units.\r\n\t\tlet amount = Math.abs(secondsPassed) / getStepDenominator(step)\r\n\r\n\t\t// Apply granularity to the time amount\r\n\t\t// (and fallback to the previous step\r\n\t\t// if the first level of granularity\r\n\t\t// isn't met by this amount)\r\n\t\t//\r\n\t\t// `granularity` — (advanced) Time interval value \"granularity\".\r\n\t\t// For example, it could be set to `5` for minutes to allow only 5-minute increments\r\n\t\t// when formatting time intervals: `0 minutes`, `5 minutes`, `10 minutes`, etc.\r\n\t\t// Perhaps this feature will be removed because there seem to be no use cases\r\n\t\t// of it in the real world.\r\n\t\t//\r\n\t\tif (step.granularity) {\r\n\t\t\t// Recalculate the amount of seconds passed based on granularity\r\n\t\t\tamount = getRoundFunction(round)(amount / step.granularity) * step.granularity\r\n\t\t}\r\n\r\n\t\tlet valueForFormatting = -1 * Math.sign(secondsPassed) * getRoundFunction(round)(amount)\r\n\r\n\t\t// By default, this library formats a `0` in \"past\" mode,\r\n\t\t// unless `future: true` option is passed.\r\n\t\t// This is different to `relative-time-format`'s behavior\r\n\t\t// which formats a `0` in \"future\" mode by default, unless it's a `-0`.\r\n\t\t// So, convert `0` to `-0` if `future: true` option wasn't passed.\r\n\t\t// `=== 0` matches both `0` and `-0`.\r\n\t\tif (valueForFormatting === 0) {\r\n\t\t\tif (future) {\r\n\t\t\t\tvalueForFormatting = 0\r\n\t\t\t} else {\r\n\t\t\t\tvalueForFormatting = -0\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tswitch (labelsType) {\r\n\t\t\tcase 'long':\r\n\t\t\tcase 'short':\r\n\t\t\tcase 'narrow':\r\n\t\t\t\t// Format the amount using `Intl.RelativeTimeFormat`.\r\n\t\t\t\treturn this.getFormatter(labelsType).format(valueForFormatting, unit)\r\n\t\t\tdefault:\r\n\t\t\t\t// Format the amount.\r\n\t\t\t\t// (mimicks `Intl.RelativeTimeFormat` behavior for other time label styles)\r\n\t\t\t\treturn this.formatValue(valueForFormatting, unit, {\r\n\t\t\t\t\tlabels,\r\n\t\t\t\t\tfuture\r\n\t\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Mimicks what `Intl.RelativeTimeFormat` does for additional locale styles.\r\n\t * @param {number} value\r\n\t * @param {string} unit\r\n\t * @param {object} options.labels — Relative time labels.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default, but should have been `true` actually.\r\n\t * @return {string}\r\n\t */\r\n\tformatValue(value, unit, { labels, future }) {\r\n\t\treturn this.getFormattingRule(labels, unit, value, { future })\r\n\t\t\t.replace('{0}', this.formatNumber(Math.abs(value)))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns formatting rule for `value` in `units` (either in past or in future).\r\n\t * @param {object} formattingRules — Relative time labels for different units.\r\n\t * @param {string} unit - Time interval measurement unit.\r\n\t * @param {number} value - Time interval value.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default.\r\n\t * @return {string}\r\n\t * @example\r\n\t * // Returns \"{0} days ago\"\r\n\t * getFormattingRule(en.long, \"day\", -2, 'en')\r\n\t */\r\n\tgetFormattingRule(formattingRules, unit, value, { future }) {\r\n\t\t// Passing the language is required in order to\r\n\t\t// be able to correctly classify the `value` as a number.\r\n\t\tconst locale = this.locale\r\n\t\tformattingRules = formattingRules[unit]\r\n\t\t// Check for a special \"compacted\" rules case:\r\n\t\t// if formatting rules are the same for \"past\" and \"future\",\r\n\t\t// and also for all possible `value`s, then those rules are\r\n\t\t// stored as a single string.\r\n\t\tif (typeof formattingRules === 'string') {\r\n\t\t\treturn formattingRules\r\n\t\t}\r\n\t\t// Choose either \"past\" or \"future\" based on time `value` sign.\r\n\t\t// If \"past\" is same as \"future\" then they're stored as \"other\".\r\n\t\t// If there's only \"other\" then it's being collapsed.\r\n\t\tconst pastOrFuture = value === 0 ? (future ? 'future' : 'past') : (value < 0 ? 'past' : 'future')\r\n\t\tconst quantifierRules = formattingRules[pastOrFuture] || formattingRules\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof quantifierRules === 'string') {\r\n\t\t\treturn quantifierRules\r\n\t\t}\r\n\t\t// Quantify `value`.\r\n\t\tconst quantifier = this.getPluralRules().select(Math.abs(value))\r\n\t\t// \"other\" rule is supposed to always be present.\r\n\t\t// If only \"other\" rule is present then \"rules\" is not an object and is a string.\r\n\t\treturn quantifierRules[quantifier] || quantifierRules.other\r\n\t}\r\n\r\n\t/**\r\n\t * Formats a number into a string.\r\n\t * Uses `Intl.NumberFormat` when available.\r\n\t * @param {number} number\r\n\t * @return {string}\r\n\t */\r\n\tformatNumber(number) {\r\n\t\treturn this.numberFormat ? this.numberFormat.format(number) : String(number)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.RelativeTimeFormat` for a given `labelsType`.\r\n\t * @param {string} labelsType\r\n\t * @return {object} `Intl.RelativeTimeFormat` instance\r\n\t */\r\n\tgetFormatter(labelsType) {\r\n\t\t// `Intl.RelativeTimeFormat` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.relativeTimeFormatCache.get(this.locale, labelsType) ||\r\n\t\t\tthis.relativeTimeFormatCache.put(this.locale, labelsType, new this.IntlRelativeTimeFormat(this.locale, { style: labelsType }))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.PluralRules` instance.\r\n\t * @return {object} `Intl.PluralRules` instance\r\n\t */\r\n\tgetPluralRules() {\r\n\t\t// `Intl.PluralRules` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.pluralRulesCache.get(this.locale) ||\r\n\t\t\tthis.pluralRulesCache.put(this.locale, new this.IntlPluralRules(this.locale))\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Gets localized labels for this type of labels.\r\n\t *\r\n\t * @param {(string|string[])} labelsType - Relative date/time labels type.\r\n\t * If it's an array then all label types are tried\r\n\t * until a suitable one is found.\r\n\t *\r\n\t * @returns {Object} Returns an object of shape { labelsType, labels }\r\n\t */\r\n\tgetLabels(labelsType = []) {\r\n\t\t// Convert `labels` to an array.\r\n\t\tif (typeof labelsType === 'string') {\r\n\t\t\tlabelsType = [labelsType]\r\n\t\t}\r\n\r\n\t\t// Supports legacy \"tiny\" and \"mini-time\" label styles.\r\n\t\tlabelsType = labelsType.map((labelsType) => {\r\n\t\t\tswitch (labelsType) {\r\n\t\t\t\tcase 'tiny':\r\n\t\t\t\tcase 'mini-time':\r\n\t\t\t\t\treturn 'mini'\r\n\t\t\t\tdefault:\r\n\t\t\t\t\treturn labelsType\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\t// \"long\" labels type is the default one.\r\n\t\t// (it's always present for all languages)\r\n\t\tlabelsType = labelsType.concat('long')\r\n\r\n\t\t// Find a suitable labels type.\r\n\t\tconst localeData = getLocaleData(this.locale)\r\n\t\tfor (const _labelsType of labelsType) {\r\n\t\t\tif (localeData[_labelsType]) {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tlabelsType: _labelsType,\r\n\t\t\t\t\tlabels: localeData[_labelsType]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/**\r\n * Default locale global variable.\r\n */\r\nlet defaultLocale = 'en'\r\n\r\n/**\r\n * Gets default locale.\r\n * @return {string} locale\r\n */\r\nTimeAgo.getDefaultLocale = () => defaultLocale\r\n\r\n/**\r\n * Sets default locale.\r\n * @param {string} locale\r\n */\r\nTimeAgo.setDefaultLocale = (locale) => {\r\n\tdefaultLocale = locale\r\n}\r\n\r\n/**\r\n * Adds locale data for a specific locale and marks the locale as default.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addDefaultLocale = function(localeData) {\r\n\t// Warn the user if they've previously already added a default locale (a different one).\r\n\tif (defaultLocaleHasBeenSpecified) {\r\n\t\tif (TimeAgo.getDefaultLocale() !== localeData.locale) {\r\n\t\t\tconsole.warn(`[javascript-time-ago] You're adding \"${localeData.locale}\" as the default locale but you have already added \"${TimeAgo.getDefaultLocale()}\" as the default locale. \"${localeData.locale}\" is the default locale now.`)\r\n\t\t}\r\n\t}\r\n\tdefaultLocaleHasBeenSpecified = true\r\n\r\n\t// `addDefaultLocale()` is just a shortcut to `addLocale()` + `setDefaultLocale()`.\r\n\tTimeAgo.addLocale(localeData)\r\n\tTimeAgo.setDefaultLocale(localeData.locale)\r\n}\r\n\r\nlet defaultLocaleHasBeenSpecified = false\r\n\r\n/**\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addLocale = function(localeData) {\r\n\taddLocaleData(localeData)\r\n\tRelativeTimeFormatPolyfill.addLocale(localeData)\r\n}\r\n\r\n/**\r\n * (legacy alias)\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n * @deprecated\r\n */\r\nTimeAgo.locale = TimeAgo.addLocale\r\n\r\n/**\r\n * Adds custom labels to locale data.\r\n * @param {string} locale\r\n * @param {string} name\r\n * @param {object} labels\r\n */\r\nTimeAgo.addLabels = (locale, name, labels) => {\r\n\tlet localeData = getLocaleData(locale)\r\n\tif (!localeData) {\r\n\t\taddLocaleData({\r\n\t\t\tlocale\r\n\t\t})\r\n\t\tlocaleData = getLocaleData(locale)\r\n\t\t// throw new Error(`[javascript-time-ago] No data for locale \"${locale}\"`)\r\n\t}\r\n\tlocaleData[name] = labels\r\n}\r\n\r\n// Normalizes `.format()` `time` argument.\r\nfunction getTimestamp(input) {\r\n\tif (input.constructor === Date || isMockedDate(input)) {\r\n\t\treturn input.getTime()\r\n\t}\r\n\r\n\tif (typeof input === 'number') {\r\n\t\treturn input\r\n\t}\r\n\r\n\t// For some weird reason istanbul doesn't see this `throw` covered.\r\n\t/* istanbul ignore next */\r\n\tthrow new Error(`Unsupported relative time formatter input: ${typeof input}, ${input}`)\r\n}\r\n\r\n// During testing via some testing libraries `Date`s aren't actually `Date`s.\r\n// https://github.com/catamphetamine/javascript-time-ago/issues/22\r\nfunction isMockedDate(object) {\r\n\treturn typeof object === 'object' && typeof object.getTime === 'function'\r\n}\r\n\r\n// Get available time interval measurement units.\r\nfunction getTimeIntervalMeasurementUnits(allowedUnits, labels, nowLabel) {\r\n\t// Get all time interval measurement units that're available\r\n\t// in locale data for a given time labels style.\r\n\tlet units = Object.keys(labels)\r\n\r\n\t// `now` unit is handled separately and is shipped in its own `now.json` file.\r\n\t// `now.json` isn't present for all locales, so it could be substituted with\r\n\t// \".second.current\".\r\n\t// Add `now` unit if it's available in locale data.\r\n\tif (nowLabel) {\r\n\t\tunits.push('now')\r\n\t}\r\n\r\n\t// If only a specific set of available time measurement units can be used\r\n\t// then only those units are allowed (if they're present in locale data).\r\n\tif (allowedUnits) {\r\n\t\tunits = allowedUnits.filter(unit => unit === 'now' || units.indexOf(unit) >= 0)\r\n\t}\r\n\r\n\treturn units\r\n}\r\n\r\nfunction getNowLabel(labels, nowLabels, longLabels, future) {\r\n\tconst nowLabel = labels.now || (nowLabels && nowLabels.now)\r\n\t// Specific \"now\" message form extended locale data (if present).\r\n\tif (nowLabel) {\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof nowLabel === 'string') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\t\t// Not handling `value === 0` as `localeData.now.current` here\r\n\t\t// because it wouldn't make sense: \"now\" is a moment,\r\n\t\t// so one can't possibly differentiate between a\r\n\t\t// \"previous\" moment, a \"current\" moment and a \"next moment\".\r\n\t\t// It can only be differentiated between \"past\" and \"future\".\r\n\t\tif (future) {\r\n\t\t\treturn nowLabel.future\r\n\t\t} else {\r\n\t\t\treturn nowLabel.past\r\n\t\t}\r\n\t}\r\n\t// Use \".second.current\" as \"now\" message.\r\n\tif (longLabels && longLabels.second && longLabels.second.current) {\r\n\t\treturn longLabels.second.current\r\n\t}\r\n}\r\n\r\nfunction isStyle(variable) {\r\n\treturn typeof variable === 'string' || isStyleObject(variable)\r\n}\r\n\r\n// `setTimeout()` function has a bug when it fires immediately\r\n// when the delay is longer than about `24.85` days.\r\n// https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values\r\n//\r\n// Since `renderLabel()` function uses `setTimeout()` for recursion,\r\n// that would mean infinite recursion.\r\n//\r\n// `setTimeoutSafe()` function works around that bug\r\n// by capping the delay at the maximum allowed value.\r\n//\r\nfunction setTimeoutSafe(func, delay) {\r\n return setTimeout(func, getSafeTimeoutDelay(delay))\r\n}\r\nfunction getSafeTimeoutDelay(delay) {\r\n return Math.min(delay, SET_TIMEOUT_MAX_SAFE_DELAY)\r\n}\r\nconst SET_TIMEOUT_MAX_SAFE_DELAY = 2147483647"],"mappings":";;;;;;;;;;;;;AAAA,OAAOA,0BAA0B,MAAM,sBAAsB;AAE7D,OAAOC,KAAK,MAAM,YAAY;AAC9B,OAAOC,YAAY,MAAM,aAAa;AACtC,OAAOC,aAAa,MAAM,oBAAoB;AAE9C,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,kBAAkB,MAAM,+BAA+B;AAC9D,OAAOC,mBAAmB,MAAM,gCAAgC;AAEhE,SACCC,aAAa,EACbC,aAAa,QACP,sBAAsB;AAE7B,OAAOC,YAAY,MAAM,wBAAwB;AACjD,OAAOC,cAAc,MAAM,2BAA2B;AAEtD,SAASC,gBAAgB,QAAQ,YAAY;AAAA,IAExBC,OAAO;EAC3B;AACD;AACA;AACA;EACC,SAAAA,QAAA,EAA6C;IAAA,IAAjCC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAA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