@everymatrix/lottery-hakuna-ticket-history 0.0.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 (64) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-dc95b9af.js +1336 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/lottery-button_8.cjs.entry.js +1427 -0
  6. package/dist/cjs/lottery-hakuna-ticket-history-84d9a41b.js +2697 -0
  7. package/dist/cjs/lottery-hakuna-ticket-history.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +50 -0
  9. package/dist/collection/components/lottery-hakuna-ticket-history/index.js +1 -0
  10. package/dist/collection/components/lottery-hakuna-ticket-history/lottery-hakuna-ticket-history.css +74 -0
  11. package/dist/collection/components/lottery-hakuna-ticket-history/lottery-hakuna-ticket-history.js +589 -0
  12. package/dist/collection/components/lottery-infinite-scroll/lottery-infinite-scroll.css +69 -0
  13. package/dist/collection/components/lottery-infinite-scroll/lottery-infinite-scroll.js +556 -0
  14. package/dist/collection/index.js +1 -0
  15. package/dist/collection/models/index.js +21 -0
  16. package/dist/collection/utils/api.js +149 -0
  17. package/dist/collection/utils/locale.utils.js +42 -0
  18. package/dist/collection/utils/utils.js +3 -0
  19. package/dist/esm/app-globals-0f993ce5.js +3 -0
  20. package/dist/esm/index-50addd47.js +1307 -0
  21. package/dist/esm/index.js +2 -0
  22. package/dist/esm/loader.js +11 -0
  23. package/dist/esm/lottery-button_8.entry.js +1417 -0
  24. package/dist/esm/lottery-hakuna-ticket-history-cdab50d9.js +2691 -0
  25. package/dist/esm/lottery-hakuna-ticket-history.js +20 -0
  26. package/dist/index.cjs.js +1 -0
  27. package/dist/index.js +1 -0
  28. package/dist/lottery-hakuna-ticket-history/app-globals-0f993ce5.js +1 -0
  29. package/dist/lottery-hakuna-ticket-history/index-50addd47.js +2 -0
  30. package/dist/lottery-hakuna-ticket-history/index.esm.js +1 -0
  31. package/dist/lottery-hakuna-ticket-history/lottery-button_8.entry.js +1 -0
  32. package/dist/lottery-hakuna-ticket-history/lottery-hakuna-ticket-history-cdab50d9.js +1 -0
  33. package/dist/lottery-hakuna-ticket-history/lottery-hakuna-ticket-history.esm.js +1 -0
  34. package/dist/stencil.config.dev.js +19 -0
  35. package/dist/stencil.config.js +19 -0
  36. package/dist/storybook/main.js +43 -0
  37. package/dist/storybook/preview.js +9 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/packages/stencil/lottery-hakuna-ticket-history/stencil.config.d.ts +2 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/packages/stencil/lottery-hakuna-ticket-history/stencil.config.dev.d.ts +2 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/packages/stencil/lottery-hakuna-ticket-history/storybook/main.d.ts +3 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/packages/stencil/lottery-hakuna-ticket-history/storybook/preview.d.ts +70 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/tools/plugins/index.d.ts +4 -0
  44. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  45. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  46. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  47. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-hakuna-ticket-history/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  48. package/dist/types/components/lottery-hakuna-ticket-history/index.d.ts +1 -0
  49. package/dist/types/components/lottery-hakuna-ticket-history/lottery-hakuna-ticket-history.d.ts +131 -0
  50. package/dist/types/components/lottery-infinite-scroll/lottery-infinite-scroll.d.ts +106 -0
  51. package/dist/types/components.d.ts +362 -0
  52. package/dist/types/index.d.ts +1 -0
  53. package/dist/types/models/index.d.ts +199 -0
  54. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  55. package/dist/types/utils/api.d.ts +8 -0
  56. package/dist/types/utils/locale.utils.d.ts +3 -0
  57. package/dist/types/utils/utils.d.ts +1 -0
  58. package/loader/cdn.js +1 -0
  59. package/loader/index.cjs.js +1 -0
  60. package/loader/index.d.ts +24 -0
  61. package/loader/index.es2017.js +1 -0
  62. package/loader/index.js +2 -0
  63. package/loader/package.json +11 -0
  64. package/package.json +27 -0
@@ -0,0 +1,2691 @@
1
+ import { r as registerInstance, h } from './index-50addd47.js';
2
+
3
+ /**
4
+ * @name setClientStyling
5
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
6
+ * @param {HTMLElement} stylingContainer The reference element of the widget
7
+ * @param {string} clientStyling The style content
8
+ */
9
+ function setClientStyling(stylingContainer, clientStyling) {
10
+ if (stylingContainer) {
11
+ const sheet = document.createElement('style');
12
+ sheet.innerHTML = clientStyling;
13
+ stylingContainer.appendChild(sheet);
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @name setClientStylingURL
19
+ * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
20
+ * @param {HTMLElement} stylingContainer The reference element of the widget
21
+ * @param {string} clientStylingUrl The URL of the style content
22
+ */
23
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
24
+ if (!stylingContainer || !clientStylingUrl) return;
25
+
26
+ const url = new URL(clientStylingUrl);
27
+
28
+ fetch(url.href)
29
+ .then((res) => res.text())
30
+ .then((data) => {
31
+ const cssFile = document.createElement('style');
32
+ cssFile.innerHTML = data;
33
+ if (stylingContainer) {
34
+ stylingContainer.appendChild(cssFile);
35
+ }
36
+ })
37
+ .catch((err) => {
38
+ console.error('There was an error while trying to load client styling from URL', err);
39
+ });
40
+ }
41
+
42
+ /**
43
+ * @name setStreamLibrary
44
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
45
+ * @param {HTMLElement} stylingContainer The highest element of the widget
46
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
47
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
48
+ */
49
+ function setStreamStyling(stylingContainer, domain, subscription) {
50
+ if (window.emMessageBus) {
51
+ const sheet = document.createElement('style');
52
+
53
+ window.emMessageBus.subscribe(domain, (data) => {
54
+ sheet.innerHTML = data;
55
+ if (stylingContainer) {
56
+ stylingContainer.appendChild(sheet);
57
+ }
58
+ });
59
+ }
60
+ }
61
+
62
+ var GameType;
63
+ (function (GameType) {
64
+ GameType["Lottery"] = "Lottery";
65
+ GameType["PoolGame"] = "PoolGame";
66
+ })(GameType || (GameType = {}));
67
+ var GameBettingObject;
68
+ (function (GameBettingObject) {
69
+ GameBettingObject["Tipping"] = "HomeDrawAway";
70
+ GameBettingObject["Oddsbomben"] = "CorrectScore";
71
+ })(GameBettingObject || (GameBettingObject = {}));
72
+ var TicketStatus;
73
+ (function (TicketStatus) {
74
+ TicketStatus["Settled"] = "Settled";
75
+ TicketStatus["Purchased"] = "Purchased";
76
+ TicketStatus["Canceled"] = "Canceled";
77
+ })(TicketStatus || (TicketStatus = {}));
78
+ var DrawResult;
79
+ (function (DrawResult) {
80
+ DrawResult["WON"] = "Won";
81
+ DrawResult["LOST"] = "Lost";
82
+ })(DrawResult || (DrawResult = {}));
83
+
84
+ function _typeof(o) {
85
+ "@babel/helpers - typeof";
86
+
87
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
88
+ return typeof o;
89
+ } : function (o) {
90
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
91
+ }, _typeof(o);
92
+ }
93
+
94
+ function toInteger(dirtyNumber) {
95
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
96
+ return NaN;
97
+ }
98
+ var number = Number(dirtyNumber);
99
+ if (isNaN(number)) {
100
+ return number;
101
+ }
102
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
103
+ }
104
+
105
+ function requiredArgs(required, args) {
106
+ if (args.length < required) {
107
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
108
+ }
109
+ }
110
+
111
+ /**
112
+ * @name toDate
113
+ * @category Common Helpers
114
+ * @summary Convert the given argument to an instance of Date.
115
+ *
116
+ * @description
117
+ * Convert the given argument to an instance of Date.
118
+ *
119
+ * If the argument is an instance of Date, the function returns its clone.
120
+ *
121
+ * If the argument is a number, it is treated as a timestamp.
122
+ *
123
+ * If the argument is none of the above, the function returns Invalid Date.
124
+ *
125
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
126
+ *
127
+ * @param {Date|Number} argument - the value to convert
128
+ * @returns {Date} the parsed date in the local time zone
129
+ * @throws {TypeError} 1 argument required
130
+ *
131
+ * @example
132
+ * // Clone the date:
133
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
134
+ * //=> Tue Feb 11 2014 11:30:30
135
+ *
136
+ * @example
137
+ * // Convert the timestamp to date:
138
+ * const result = toDate(1392098430000)
139
+ * //=> Tue Feb 11 2014 11:30:30
140
+ */
141
+ function toDate(argument) {
142
+ requiredArgs(1, arguments);
143
+ var argStr = Object.prototype.toString.call(argument);
144
+
145
+ // Clone the date
146
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
147
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
148
+ return new Date(argument.getTime());
149
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
150
+ return new Date(argument);
151
+ } else {
152
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
153
+ // eslint-disable-next-line no-console
154
+ console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
155
+ // eslint-disable-next-line no-console
156
+ console.warn(new Error().stack);
157
+ }
158
+ return new Date(NaN);
159
+ }
160
+ }
161
+
162
+ /**
163
+ * @name addMilliseconds
164
+ * @category Millisecond Helpers
165
+ * @summary Add the specified number of milliseconds to the given date.
166
+ *
167
+ * @description
168
+ * Add the specified number of milliseconds to the given date.
169
+ *
170
+ * @param {Date|Number} date - the date to be changed
171
+ * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
172
+ * @returns {Date} the new date with the milliseconds added
173
+ * @throws {TypeError} 2 arguments required
174
+ *
175
+ * @example
176
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
177
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
178
+ * //=> Thu Jul 10 2014 12:45:30.750
179
+ */
180
+ function addMilliseconds(dirtyDate, dirtyAmount) {
181
+ requiredArgs(2, arguments);
182
+ var timestamp = toDate(dirtyDate).getTime();
183
+ var amount = toInteger(dirtyAmount);
184
+ return new Date(timestamp + amount);
185
+ }
186
+
187
+ var defaultOptions = {};
188
+ function getDefaultOptions() {
189
+ return defaultOptions;
190
+ }
191
+
192
+ /**
193
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
194
+ * They usually appear for dates that denote time before the timezones were introduced
195
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
196
+ * and GMT+01:00:00 after that date)
197
+ *
198
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
199
+ * which would lead to incorrect calculations.
200
+ *
201
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
202
+ */
203
+ function getTimezoneOffsetInMilliseconds(date) {
204
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
205
+ utcDate.setUTCFullYear(date.getFullYear());
206
+ return date.getTime() - utcDate.getTime();
207
+ }
208
+
209
+ /**
210
+ * @name isDate
211
+ * @category Common Helpers
212
+ * @summary Is the given value a date?
213
+ *
214
+ * @description
215
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
216
+ *
217
+ * @param {*} value - the value to check
218
+ * @returns {boolean} true if the given value is a date
219
+ * @throws {TypeError} 1 arguments required
220
+ *
221
+ * @example
222
+ * // For a valid date:
223
+ * const result = isDate(new Date())
224
+ * //=> true
225
+ *
226
+ * @example
227
+ * // For an invalid date:
228
+ * const result = isDate(new Date(NaN))
229
+ * //=> true
230
+ *
231
+ * @example
232
+ * // For some value:
233
+ * const result = isDate('2014-02-31')
234
+ * //=> false
235
+ *
236
+ * @example
237
+ * // For an object:
238
+ * const result = isDate({})
239
+ * //=> false
240
+ */
241
+ function isDate(value) {
242
+ requiredArgs(1, arguments);
243
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
244
+ }
245
+
246
+ /**
247
+ * @name isValid
248
+ * @category Common Helpers
249
+ * @summary Is the given date valid?
250
+ *
251
+ * @description
252
+ * Returns false if argument is Invalid Date and true otherwise.
253
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
254
+ * Invalid Date is a Date, whose time value is NaN.
255
+ *
256
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
257
+ *
258
+ * @param {*} date - the date to check
259
+ * @returns {Boolean} the date is valid
260
+ * @throws {TypeError} 1 argument required
261
+ *
262
+ * @example
263
+ * // For the valid date:
264
+ * const result = isValid(new Date(2014, 1, 31))
265
+ * //=> true
266
+ *
267
+ * @example
268
+ * // For the value, convertable into a date:
269
+ * const result = isValid(1393804800000)
270
+ * //=> true
271
+ *
272
+ * @example
273
+ * // For the invalid date:
274
+ * const result = isValid(new Date(''))
275
+ * //=> false
276
+ */
277
+ function isValid(dirtyDate) {
278
+ requiredArgs(1, arguments);
279
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
280
+ return false;
281
+ }
282
+ var date = toDate(dirtyDate);
283
+ return !isNaN(Number(date));
284
+ }
285
+
286
+ /**
287
+ * @name subMilliseconds
288
+ * @category Millisecond Helpers
289
+ * @summary Subtract the specified number of milliseconds from the given date.
290
+ *
291
+ * @description
292
+ * Subtract the specified number of milliseconds from the given date.
293
+ *
294
+ * @param {Date|Number} date - the date to be changed
295
+ * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
296
+ * @returns {Date} the new date with the milliseconds subtracted
297
+ * @throws {TypeError} 2 arguments required
298
+ *
299
+ * @example
300
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
301
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
302
+ * //=> Thu Jul 10 2014 12:45:29.250
303
+ */
304
+ function subMilliseconds(dirtyDate, dirtyAmount) {
305
+ requiredArgs(2, arguments);
306
+ var amount = toInteger(dirtyAmount);
307
+ return addMilliseconds(dirtyDate, -amount);
308
+ }
309
+
310
+ var MILLISECONDS_IN_DAY = 86400000;
311
+ function getUTCDayOfYear(dirtyDate) {
312
+ requiredArgs(1, arguments);
313
+ var date = toDate(dirtyDate);
314
+ var timestamp = date.getTime();
315
+ date.setUTCMonth(0, 1);
316
+ date.setUTCHours(0, 0, 0, 0);
317
+ var startOfYearTimestamp = date.getTime();
318
+ var difference = timestamp - startOfYearTimestamp;
319
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
320
+ }
321
+
322
+ function startOfUTCISOWeek(dirtyDate) {
323
+ requiredArgs(1, arguments);
324
+ var weekStartsOn = 1;
325
+ var date = toDate(dirtyDate);
326
+ var day = date.getUTCDay();
327
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
328
+ date.setUTCDate(date.getUTCDate() - diff);
329
+ date.setUTCHours(0, 0, 0, 0);
330
+ return date;
331
+ }
332
+
333
+ function getUTCISOWeekYear(dirtyDate) {
334
+ requiredArgs(1, arguments);
335
+ var date = toDate(dirtyDate);
336
+ var year = date.getUTCFullYear();
337
+ var fourthOfJanuaryOfNextYear = new Date(0);
338
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
339
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
340
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
341
+ var fourthOfJanuaryOfThisYear = new Date(0);
342
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
343
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
344
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
345
+ if (date.getTime() >= startOfNextYear.getTime()) {
346
+ return year + 1;
347
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
348
+ return year;
349
+ } else {
350
+ return year - 1;
351
+ }
352
+ }
353
+
354
+ function startOfUTCISOWeekYear(dirtyDate) {
355
+ requiredArgs(1, arguments);
356
+ var year = getUTCISOWeekYear(dirtyDate);
357
+ var fourthOfJanuary = new Date(0);
358
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
359
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
360
+ var date = startOfUTCISOWeek(fourthOfJanuary);
361
+ return date;
362
+ }
363
+
364
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
365
+ function getUTCISOWeek(dirtyDate) {
366
+ requiredArgs(1, arguments);
367
+ var date = toDate(dirtyDate);
368
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
369
+
370
+ // Round the number of days to the nearest integer
371
+ // because the number of milliseconds in a week is not constant
372
+ // (e.g. it's different in the week of the daylight saving time clock shift)
373
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
374
+ }
375
+
376
+ function startOfUTCWeek(dirtyDate, options) {
377
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
378
+ requiredArgs(1, arguments);
379
+ var defaultOptions = getDefaultOptions();
380
+ var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
381
+
382
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
383
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
384
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
385
+ }
386
+ var date = toDate(dirtyDate);
387
+ var day = date.getUTCDay();
388
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
389
+ date.setUTCDate(date.getUTCDate() - diff);
390
+ date.setUTCHours(0, 0, 0, 0);
391
+ return date;
392
+ }
393
+
394
+ function getUTCWeekYear(dirtyDate, options) {
395
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
396
+ requiredArgs(1, arguments);
397
+ var date = toDate(dirtyDate);
398
+ var year = date.getUTCFullYear();
399
+ var defaultOptions = getDefaultOptions();
400
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
401
+
402
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
403
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
404
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
405
+ }
406
+ var firstWeekOfNextYear = new Date(0);
407
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
408
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
409
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
410
+ var firstWeekOfThisYear = new Date(0);
411
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
412
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
413
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
414
+ if (date.getTime() >= startOfNextYear.getTime()) {
415
+ return year + 1;
416
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
417
+ return year;
418
+ } else {
419
+ return year - 1;
420
+ }
421
+ }
422
+
423
+ function startOfUTCWeekYear(dirtyDate, options) {
424
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
425
+ requiredArgs(1, arguments);
426
+ var defaultOptions = getDefaultOptions();
427
+ var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
428
+ var year = getUTCWeekYear(dirtyDate, options);
429
+ var firstWeek = new Date(0);
430
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
431
+ firstWeek.setUTCHours(0, 0, 0, 0);
432
+ var date = startOfUTCWeek(firstWeek, options);
433
+ return date;
434
+ }
435
+
436
+ var MILLISECONDS_IN_WEEK = 604800000;
437
+ function getUTCWeek(dirtyDate, options) {
438
+ requiredArgs(1, arguments);
439
+ var date = toDate(dirtyDate);
440
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
441
+
442
+ // Round the number of days to the nearest integer
443
+ // because the number of milliseconds in a week is not constant
444
+ // (e.g. it's different in the week of the daylight saving time clock shift)
445
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
446
+ }
447
+
448
+ function addLeadingZeros(number, targetLength) {
449
+ var sign = number < 0 ? '-' : '';
450
+ var output = Math.abs(number).toString();
451
+ while (output.length < targetLength) {
452
+ output = '0' + output;
453
+ }
454
+ return sign + output;
455
+ }
456
+
457
+ /*
458
+ * | | Unit | | Unit |
459
+ * |-----|--------------------------------|-----|--------------------------------|
460
+ * | a | AM, PM | A* | |
461
+ * | d | Day of month | D | |
462
+ * | h | Hour [1-12] | H | Hour [0-23] |
463
+ * | m | Minute | M | Month |
464
+ * | s | Second | S | Fraction of second |
465
+ * | y | Year (abs) | Y | |
466
+ *
467
+ * Letters marked by * are not implemented but reserved by Unicode standard.
468
+ */
469
+ var formatters$2 = {
470
+ // Year
471
+ y: function y(date, token) {
472
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
473
+ // | Year | y | yy | yyy | yyyy | yyyyy |
474
+ // |----------|-------|----|-------|-------|-------|
475
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
476
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
477
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
478
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
479
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
480
+
481
+ var signedYear = date.getUTCFullYear();
482
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
483
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
484
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
485
+ },
486
+ // Month
487
+ M: function M(date, token) {
488
+ var month = date.getUTCMonth();
489
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
490
+ },
491
+ // Day of the month
492
+ d: function d(date, token) {
493
+ return addLeadingZeros(date.getUTCDate(), token.length);
494
+ },
495
+ // AM or PM
496
+ a: function a(date, token) {
497
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
498
+ switch (token) {
499
+ case 'a':
500
+ case 'aa':
501
+ return dayPeriodEnumValue.toUpperCase();
502
+ case 'aaa':
503
+ return dayPeriodEnumValue;
504
+ case 'aaaaa':
505
+ return dayPeriodEnumValue[0];
506
+ case 'aaaa':
507
+ default:
508
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
509
+ }
510
+ },
511
+ // Hour [1-12]
512
+ h: function h(date, token) {
513
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
514
+ },
515
+ // Hour [0-23]
516
+ H: function H(date, token) {
517
+ return addLeadingZeros(date.getUTCHours(), token.length);
518
+ },
519
+ // Minute
520
+ m: function m(date, token) {
521
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
522
+ },
523
+ // Second
524
+ s: function s(date, token) {
525
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
526
+ },
527
+ // Fraction of second
528
+ S: function S(date, token) {
529
+ var numberOfDigits = token.length;
530
+ var milliseconds = date.getUTCMilliseconds();
531
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
532
+ return addLeadingZeros(fractionalSeconds, token.length);
533
+ }
534
+ };
535
+ const formatters$3 = formatters$2;
536
+
537
+ var dayPeriodEnum = {
538
+ am: 'am',
539
+ pm: 'pm',
540
+ midnight: 'midnight',
541
+ noon: 'noon',
542
+ morning: 'morning',
543
+ afternoon: 'afternoon',
544
+ evening: 'evening',
545
+ night: 'night'
546
+ };
547
+ /*
548
+ * | | Unit | | Unit |
549
+ * |-----|--------------------------------|-----|--------------------------------|
550
+ * | a | AM, PM | A* | Milliseconds in day |
551
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
552
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
553
+ * | d | Day of month | D | Day of year |
554
+ * | e | Local day of week | E | Day of week |
555
+ * | f | | F* | Day of week in month |
556
+ * | g* | Modified Julian day | G | Era |
557
+ * | h | Hour [1-12] | H | Hour [0-23] |
558
+ * | i! | ISO day of week | I! | ISO week of year |
559
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
560
+ * | k | Hour [1-24] | K | Hour [0-11] |
561
+ * | l* | (deprecated) | L | Stand-alone month |
562
+ * | m | Minute | M | Month |
563
+ * | n | | N | |
564
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
565
+ * | p! | Long localized time | P! | Long localized date |
566
+ * | q | Stand-alone quarter | Q | Quarter |
567
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
568
+ * | s | Second | S | Fraction of second |
569
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
570
+ * | u | Extended year | U* | Cyclic year |
571
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
572
+ * | w | Local week of year | W* | Week of month |
573
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
574
+ * | y | Year (abs) | Y | Local week-numbering year |
575
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
576
+ *
577
+ * Letters marked by * are not implemented but reserved by Unicode standard.
578
+ *
579
+ * Letters marked by ! are non-standard, but implemented by date-fns:
580
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
581
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
582
+ * i.e. 7 for Sunday, 1 for Monday, etc.
583
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
584
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
585
+ * `R` is supposed to be used in conjunction with `I` and `i`
586
+ * for universal ISO week-numbering date, whereas
587
+ * `Y` is supposed to be used in conjunction with `w` and `e`
588
+ * for week-numbering date specific to the locale.
589
+ * - `P` is long localized date format
590
+ * - `p` is long localized time format
591
+ */
592
+
593
+ var formatters = {
594
+ // Era
595
+ G: function G(date, token, localize) {
596
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
597
+ switch (token) {
598
+ // AD, BC
599
+ case 'G':
600
+ case 'GG':
601
+ case 'GGG':
602
+ return localize.era(era, {
603
+ width: 'abbreviated'
604
+ });
605
+ // A, B
606
+ case 'GGGGG':
607
+ return localize.era(era, {
608
+ width: 'narrow'
609
+ });
610
+ // Anno Domini, Before Christ
611
+ case 'GGGG':
612
+ default:
613
+ return localize.era(era, {
614
+ width: 'wide'
615
+ });
616
+ }
617
+ },
618
+ // Year
619
+ y: function y(date, token, localize) {
620
+ // Ordinal number
621
+ if (token === 'yo') {
622
+ var signedYear = date.getUTCFullYear();
623
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
624
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
625
+ return localize.ordinalNumber(year, {
626
+ unit: 'year'
627
+ });
628
+ }
629
+ return formatters$3.y(date, token);
630
+ },
631
+ // Local week-numbering year
632
+ Y: function Y(date, token, localize, options) {
633
+ var signedWeekYear = getUTCWeekYear(date, options);
634
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
635
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
636
+
637
+ // Two digit year
638
+ if (token === 'YY') {
639
+ var twoDigitYear = weekYear % 100;
640
+ return addLeadingZeros(twoDigitYear, 2);
641
+ }
642
+
643
+ // Ordinal number
644
+ if (token === 'Yo') {
645
+ return localize.ordinalNumber(weekYear, {
646
+ unit: 'year'
647
+ });
648
+ }
649
+
650
+ // Padding
651
+ return addLeadingZeros(weekYear, token.length);
652
+ },
653
+ // ISO week-numbering year
654
+ R: function R(date, token) {
655
+ var isoWeekYear = getUTCISOWeekYear(date);
656
+
657
+ // Padding
658
+ return addLeadingZeros(isoWeekYear, token.length);
659
+ },
660
+ // Extended year. This is a single number designating the year of this calendar system.
661
+ // The main difference between `y` and `u` localizers are B.C. years:
662
+ // | Year | `y` | `u` |
663
+ // |------|-----|-----|
664
+ // | AC 1 | 1 | 1 |
665
+ // | BC 1 | 1 | 0 |
666
+ // | BC 2 | 2 | -1 |
667
+ // Also `yy` always returns the last two digits of a year,
668
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
669
+ u: function u(date, token) {
670
+ var year = date.getUTCFullYear();
671
+ return addLeadingZeros(year, token.length);
672
+ },
673
+ // Quarter
674
+ Q: function Q(date, token, localize) {
675
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
676
+ switch (token) {
677
+ // 1, 2, 3, 4
678
+ case 'Q':
679
+ return String(quarter);
680
+ // 01, 02, 03, 04
681
+ case 'QQ':
682
+ return addLeadingZeros(quarter, 2);
683
+ // 1st, 2nd, 3rd, 4th
684
+ case 'Qo':
685
+ return localize.ordinalNumber(quarter, {
686
+ unit: 'quarter'
687
+ });
688
+ // Q1, Q2, Q3, Q4
689
+ case 'QQQ':
690
+ return localize.quarter(quarter, {
691
+ width: 'abbreviated',
692
+ context: 'formatting'
693
+ });
694
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
695
+ case 'QQQQQ':
696
+ return localize.quarter(quarter, {
697
+ width: 'narrow',
698
+ context: 'formatting'
699
+ });
700
+ // 1st quarter, 2nd quarter, ...
701
+ case 'QQQQ':
702
+ default:
703
+ return localize.quarter(quarter, {
704
+ width: 'wide',
705
+ context: 'formatting'
706
+ });
707
+ }
708
+ },
709
+ // Stand-alone quarter
710
+ q: function q(date, token, localize) {
711
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
712
+ switch (token) {
713
+ // 1, 2, 3, 4
714
+ case 'q':
715
+ return String(quarter);
716
+ // 01, 02, 03, 04
717
+ case 'qq':
718
+ return addLeadingZeros(quarter, 2);
719
+ // 1st, 2nd, 3rd, 4th
720
+ case 'qo':
721
+ return localize.ordinalNumber(quarter, {
722
+ unit: 'quarter'
723
+ });
724
+ // Q1, Q2, Q3, Q4
725
+ case 'qqq':
726
+ return localize.quarter(quarter, {
727
+ width: 'abbreviated',
728
+ context: 'standalone'
729
+ });
730
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
731
+ case 'qqqqq':
732
+ return localize.quarter(quarter, {
733
+ width: 'narrow',
734
+ context: 'standalone'
735
+ });
736
+ // 1st quarter, 2nd quarter, ...
737
+ case 'qqqq':
738
+ default:
739
+ return localize.quarter(quarter, {
740
+ width: 'wide',
741
+ context: 'standalone'
742
+ });
743
+ }
744
+ },
745
+ // Month
746
+ M: function M(date, token, localize) {
747
+ var month = date.getUTCMonth();
748
+ switch (token) {
749
+ case 'M':
750
+ case 'MM':
751
+ return formatters$3.M(date, token);
752
+ // 1st, 2nd, ..., 12th
753
+ case 'Mo':
754
+ return localize.ordinalNumber(month + 1, {
755
+ unit: 'month'
756
+ });
757
+ // Jan, Feb, ..., Dec
758
+ case 'MMM':
759
+ return localize.month(month, {
760
+ width: 'abbreviated',
761
+ context: 'formatting'
762
+ });
763
+ // J, F, ..., D
764
+ case 'MMMMM':
765
+ return localize.month(month, {
766
+ width: 'narrow',
767
+ context: 'formatting'
768
+ });
769
+ // January, February, ..., December
770
+ case 'MMMM':
771
+ default:
772
+ return localize.month(month, {
773
+ width: 'wide',
774
+ context: 'formatting'
775
+ });
776
+ }
777
+ },
778
+ // Stand-alone month
779
+ L: function L(date, token, localize) {
780
+ var month = date.getUTCMonth();
781
+ switch (token) {
782
+ // 1, 2, ..., 12
783
+ case 'L':
784
+ return String(month + 1);
785
+ // 01, 02, ..., 12
786
+ case 'LL':
787
+ return addLeadingZeros(month + 1, 2);
788
+ // 1st, 2nd, ..., 12th
789
+ case 'Lo':
790
+ return localize.ordinalNumber(month + 1, {
791
+ unit: 'month'
792
+ });
793
+ // Jan, Feb, ..., Dec
794
+ case 'LLL':
795
+ return localize.month(month, {
796
+ width: 'abbreviated',
797
+ context: 'standalone'
798
+ });
799
+ // J, F, ..., D
800
+ case 'LLLLL':
801
+ return localize.month(month, {
802
+ width: 'narrow',
803
+ context: 'standalone'
804
+ });
805
+ // January, February, ..., December
806
+ case 'LLLL':
807
+ default:
808
+ return localize.month(month, {
809
+ width: 'wide',
810
+ context: 'standalone'
811
+ });
812
+ }
813
+ },
814
+ // Local week of year
815
+ w: function w(date, token, localize, options) {
816
+ var week = getUTCWeek(date, options);
817
+ if (token === 'wo') {
818
+ return localize.ordinalNumber(week, {
819
+ unit: 'week'
820
+ });
821
+ }
822
+ return addLeadingZeros(week, token.length);
823
+ },
824
+ // ISO week of year
825
+ I: function I(date, token, localize) {
826
+ var isoWeek = getUTCISOWeek(date);
827
+ if (token === 'Io') {
828
+ return localize.ordinalNumber(isoWeek, {
829
+ unit: 'week'
830
+ });
831
+ }
832
+ return addLeadingZeros(isoWeek, token.length);
833
+ },
834
+ // Day of the month
835
+ d: function d(date, token, localize) {
836
+ if (token === 'do') {
837
+ return localize.ordinalNumber(date.getUTCDate(), {
838
+ unit: 'date'
839
+ });
840
+ }
841
+ return formatters$3.d(date, token);
842
+ },
843
+ // Day of year
844
+ D: function D(date, token, localize) {
845
+ var dayOfYear = getUTCDayOfYear(date);
846
+ if (token === 'Do') {
847
+ return localize.ordinalNumber(dayOfYear, {
848
+ unit: 'dayOfYear'
849
+ });
850
+ }
851
+ return addLeadingZeros(dayOfYear, token.length);
852
+ },
853
+ // Day of week
854
+ E: function E(date, token, localize) {
855
+ var dayOfWeek = date.getUTCDay();
856
+ switch (token) {
857
+ // Tue
858
+ case 'E':
859
+ case 'EE':
860
+ case 'EEE':
861
+ return localize.day(dayOfWeek, {
862
+ width: 'abbreviated',
863
+ context: 'formatting'
864
+ });
865
+ // T
866
+ case 'EEEEE':
867
+ return localize.day(dayOfWeek, {
868
+ width: 'narrow',
869
+ context: 'formatting'
870
+ });
871
+ // Tu
872
+ case 'EEEEEE':
873
+ return localize.day(dayOfWeek, {
874
+ width: 'short',
875
+ context: 'formatting'
876
+ });
877
+ // Tuesday
878
+ case 'EEEE':
879
+ default:
880
+ return localize.day(dayOfWeek, {
881
+ width: 'wide',
882
+ context: 'formatting'
883
+ });
884
+ }
885
+ },
886
+ // Local day of week
887
+ e: function e(date, token, localize, options) {
888
+ var dayOfWeek = date.getUTCDay();
889
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
890
+ switch (token) {
891
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
892
+ case 'e':
893
+ return String(localDayOfWeek);
894
+ // Padded numerical value
895
+ case 'ee':
896
+ return addLeadingZeros(localDayOfWeek, 2);
897
+ // 1st, 2nd, ..., 7th
898
+ case 'eo':
899
+ return localize.ordinalNumber(localDayOfWeek, {
900
+ unit: 'day'
901
+ });
902
+ case 'eee':
903
+ return localize.day(dayOfWeek, {
904
+ width: 'abbreviated',
905
+ context: 'formatting'
906
+ });
907
+ // T
908
+ case 'eeeee':
909
+ return localize.day(dayOfWeek, {
910
+ width: 'narrow',
911
+ context: 'formatting'
912
+ });
913
+ // Tu
914
+ case 'eeeeee':
915
+ return localize.day(dayOfWeek, {
916
+ width: 'short',
917
+ context: 'formatting'
918
+ });
919
+ // Tuesday
920
+ case 'eeee':
921
+ default:
922
+ return localize.day(dayOfWeek, {
923
+ width: 'wide',
924
+ context: 'formatting'
925
+ });
926
+ }
927
+ },
928
+ // Stand-alone local day of week
929
+ c: function c(date, token, localize, options) {
930
+ var dayOfWeek = date.getUTCDay();
931
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
932
+ switch (token) {
933
+ // Numerical value (same as in `e`)
934
+ case 'c':
935
+ return String(localDayOfWeek);
936
+ // Padded numerical value
937
+ case 'cc':
938
+ return addLeadingZeros(localDayOfWeek, token.length);
939
+ // 1st, 2nd, ..., 7th
940
+ case 'co':
941
+ return localize.ordinalNumber(localDayOfWeek, {
942
+ unit: 'day'
943
+ });
944
+ case 'ccc':
945
+ return localize.day(dayOfWeek, {
946
+ width: 'abbreviated',
947
+ context: 'standalone'
948
+ });
949
+ // T
950
+ case 'ccccc':
951
+ return localize.day(dayOfWeek, {
952
+ width: 'narrow',
953
+ context: 'standalone'
954
+ });
955
+ // Tu
956
+ case 'cccccc':
957
+ return localize.day(dayOfWeek, {
958
+ width: 'short',
959
+ context: 'standalone'
960
+ });
961
+ // Tuesday
962
+ case 'cccc':
963
+ default:
964
+ return localize.day(dayOfWeek, {
965
+ width: 'wide',
966
+ context: 'standalone'
967
+ });
968
+ }
969
+ },
970
+ // ISO day of week
971
+ i: function i(date, token, localize) {
972
+ var dayOfWeek = date.getUTCDay();
973
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
974
+ switch (token) {
975
+ // 2
976
+ case 'i':
977
+ return String(isoDayOfWeek);
978
+ // 02
979
+ case 'ii':
980
+ return addLeadingZeros(isoDayOfWeek, token.length);
981
+ // 2nd
982
+ case 'io':
983
+ return localize.ordinalNumber(isoDayOfWeek, {
984
+ unit: 'day'
985
+ });
986
+ // Tue
987
+ case 'iii':
988
+ return localize.day(dayOfWeek, {
989
+ width: 'abbreviated',
990
+ context: 'formatting'
991
+ });
992
+ // T
993
+ case 'iiiii':
994
+ return localize.day(dayOfWeek, {
995
+ width: 'narrow',
996
+ context: 'formatting'
997
+ });
998
+ // Tu
999
+ case 'iiiiii':
1000
+ return localize.day(dayOfWeek, {
1001
+ width: 'short',
1002
+ context: 'formatting'
1003
+ });
1004
+ // Tuesday
1005
+ case 'iiii':
1006
+ default:
1007
+ return localize.day(dayOfWeek, {
1008
+ width: 'wide',
1009
+ context: 'formatting'
1010
+ });
1011
+ }
1012
+ },
1013
+ // AM or PM
1014
+ a: function a(date, token, localize) {
1015
+ var hours = date.getUTCHours();
1016
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1017
+ switch (token) {
1018
+ case 'a':
1019
+ case 'aa':
1020
+ return localize.dayPeriod(dayPeriodEnumValue, {
1021
+ width: 'abbreviated',
1022
+ context: 'formatting'
1023
+ });
1024
+ case 'aaa':
1025
+ return localize.dayPeriod(dayPeriodEnumValue, {
1026
+ width: 'abbreviated',
1027
+ context: 'formatting'
1028
+ }).toLowerCase();
1029
+ case 'aaaaa':
1030
+ return localize.dayPeriod(dayPeriodEnumValue, {
1031
+ width: 'narrow',
1032
+ context: 'formatting'
1033
+ });
1034
+ case 'aaaa':
1035
+ default:
1036
+ return localize.dayPeriod(dayPeriodEnumValue, {
1037
+ width: 'wide',
1038
+ context: 'formatting'
1039
+ });
1040
+ }
1041
+ },
1042
+ // AM, PM, midnight, noon
1043
+ b: function b(date, token, localize) {
1044
+ var hours = date.getUTCHours();
1045
+ var dayPeriodEnumValue;
1046
+ if (hours === 12) {
1047
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1048
+ } else if (hours === 0) {
1049
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1050
+ } else {
1051
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1052
+ }
1053
+ switch (token) {
1054
+ case 'b':
1055
+ case 'bb':
1056
+ return localize.dayPeriod(dayPeriodEnumValue, {
1057
+ width: 'abbreviated',
1058
+ context: 'formatting'
1059
+ });
1060
+ case 'bbb':
1061
+ return localize.dayPeriod(dayPeriodEnumValue, {
1062
+ width: 'abbreviated',
1063
+ context: 'formatting'
1064
+ }).toLowerCase();
1065
+ case 'bbbbb':
1066
+ return localize.dayPeriod(dayPeriodEnumValue, {
1067
+ width: 'narrow',
1068
+ context: 'formatting'
1069
+ });
1070
+ case 'bbbb':
1071
+ default:
1072
+ return localize.dayPeriod(dayPeriodEnumValue, {
1073
+ width: 'wide',
1074
+ context: 'formatting'
1075
+ });
1076
+ }
1077
+ },
1078
+ // in the morning, in the afternoon, in the evening, at night
1079
+ B: function B(date, token, localize) {
1080
+ var hours = date.getUTCHours();
1081
+ var dayPeriodEnumValue;
1082
+ if (hours >= 17) {
1083
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1084
+ } else if (hours >= 12) {
1085
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1086
+ } else if (hours >= 4) {
1087
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1088
+ } else {
1089
+ dayPeriodEnumValue = dayPeriodEnum.night;
1090
+ }
1091
+ switch (token) {
1092
+ case 'B':
1093
+ case 'BB':
1094
+ case 'BBB':
1095
+ return localize.dayPeriod(dayPeriodEnumValue, {
1096
+ width: 'abbreviated',
1097
+ context: 'formatting'
1098
+ });
1099
+ case 'BBBBB':
1100
+ return localize.dayPeriod(dayPeriodEnumValue, {
1101
+ width: 'narrow',
1102
+ context: 'formatting'
1103
+ });
1104
+ case 'BBBB':
1105
+ default:
1106
+ return localize.dayPeriod(dayPeriodEnumValue, {
1107
+ width: 'wide',
1108
+ context: 'formatting'
1109
+ });
1110
+ }
1111
+ },
1112
+ // Hour [1-12]
1113
+ h: function h(date, token, localize) {
1114
+ if (token === 'ho') {
1115
+ var hours = date.getUTCHours() % 12;
1116
+ if (hours === 0) hours = 12;
1117
+ return localize.ordinalNumber(hours, {
1118
+ unit: 'hour'
1119
+ });
1120
+ }
1121
+ return formatters$3.h(date, token);
1122
+ },
1123
+ // Hour [0-23]
1124
+ H: function H(date, token, localize) {
1125
+ if (token === 'Ho') {
1126
+ return localize.ordinalNumber(date.getUTCHours(), {
1127
+ unit: 'hour'
1128
+ });
1129
+ }
1130
+ return formatters$3.H(date, token);
1131
+ },
1132
+ // Hour [0-11]
1133
+ K: function K(date, token, localize) {
1134
+ var hours = date.getUTCHours() % 12;
1135
+ if (token === 'Ko') {
1136
+ return localize.ordinalNumber(hours, {
1137
+ unit: 'hour'
1138
+ });
1139
+ }
1140
+ return addLeadingZeros(hours, token.length);
1141
+ },
1142
+ // Hour [1-24]
1143
+ k: function k(date, token, localize) {
1144
+ var hours = date.getUTCHours();
1145
+ if (hours === 0) hours = 24;
1146
+ if (token === 'ko') {
1147
+ return localize.ordinalNumber(hours, {
1148
+ unit: 'hour'
1149
+ });
1150
+ }
1151
+ return addLeadingZeros(hours, token.length);
1152
+ },
1153
+ // Minute
1154
+ m: function m(date, token, localize) {
1155
+ if (token === 'mo') {
1156
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1157
+ unit: 'minute'
1158
+ });
1159
+ }
1160
+ return formatters$3.m(date, token);
1161
+ },
1162
+ // Second
1163
+ s: function s(date, token, localize) {
1164
+ if (token === 'so') {
1165
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1166
+ unit: 'second'
1167
+ });
1168
+ }
1169
+ return formatters$3.s(date, token);
1170
+ },
1171
+ // Fraction of second
1172
+ S: function S(date, token) {
1173
+ return formatters$3.S(date, token);
1174
+ },
1175
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1176
+ X: function X(date, token, _localize, options) {
1177
+ var originalDate = options._originalDate || date;
1178
+ var timezoneOffset = originalDate.getTimezoneOffset();
1179
+ if (timezoneOffset === 0) {
1180
+ return 'Z';
1181
+ }
1182
+ switch (token) {
1183
+ // Hours and optional minutes
1184
+ case 'X':
1185
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1186
+
1187
+ // Hours, minutes and optional seconds without `:` delimiter
1188
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1189
+ // so this token always has the same output as `XX`
1190
+ case 'XXXX':
1191
+ case 'XX':
1192
+ // Hours and minutes without `:` delimiter
1193
+ return formatTimezone(timezoneOffset);
1194
+
1195
+ // Hours, minutes and optional seconds with `:` delimiter
1196
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1197
+ // so this token always has the same output as `XXX`
1198
+ case 'XXXXX':
1199
+ case 'XXX': // Hours and minutes with `:` delimiter
1200
+ default:
1201
+ return formatTimezone(timezoneOffset, ':');
1202
+ }
1203
+ },
1204
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1205
+ x: function x(date, token, _localize, options) {
1206
+ var originalDate = options._originalDate || date;
1207
+ var timezoneOffset = originalDate.getTimezoneOffset();
1208
+ switch (token) {
1209
+ // Hours and optional minutes
1210
+ case 'x':
1211
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1212
+
1213
+ // Hours, minutes and optional seconds without `:` delimiter
1214
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1215
+ // so this token always has the same output as `xx`
1216
+ case 'xxxx':
1217
+ case 'xx':
1218
+ // Hours and minutes without `:` delimiter
1219
+ return formatTimezone(timezoneOffset);
1220
+
1221
+ // Hours, minutes and optional seconds with `:` delimiter
1222
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1223
+ // so this token always has the same output as `xxx`
1224
+ case 'xxxxx':
1225
+ case 'xxx': // Hours and minutes with `:` delimiter
1226
+ default:
1227
+ return formatTimezone(timezoneOffset, ':');
1228
+ }
1229
+ },
1230
+ // Timezone (GMT)
1231
+ O: function O(date, token, _localize, options) {
1232
+ var originalDate = options._originalDate || date;
1233
+ var timezoneOffset = originalDate.getTimezoneOffset();
1234
+ switch (token) {
1235
+ // Short
1236
+ case 'O':
1237
+ case 'OO':
1238
+ case 'OOO':
1239
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1240
+ // Long
1241
+ case 'OOOO':
1242
+ default:
1243
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1244
+ }
1245
+ },
1246
+ // Timezone (specific non-location)
1247
+ z: function z(date, token, _localize, options) {
1248
+ var originalDate = options._originalDate || date;
1249
+ var timezoneOffset = originalDate.getTimezoneOffset();
1250
+ switch (token) {
1251
+ // Short
1252
+ case 'z':
1253
+ case 'zz':
1254
+ case 'zzz':
1255
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1256
+ // Long
1257
+ case 'zzzz':
1258
+ default:
1259
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1260
+ }
1261
+ },
1262
+ // Seconds timestamp
1263
+ t: function t(date, token, _localize, options) {
1264
+ var originalDate = options._originalDate || date;
1265
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1266
+ return addLeadingZeros(timestamp, token.length);
1267
+ },
1268
+ // Milliseconds timestamp
1269
+ T: function T(date, token, _localize, options) {
1270
+ var originalDate = options._originalDate || date;
1271
+ var timestamp = originalDate.getTime();
1272
+ return addLeadingZeros(timestamp, token.length);
1273
+ }
1274
+ };
1275
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1276
+ var sign = offset > 0 ? '-' : '+';
1277
+ var absOffset = Math.abs(offset);
1278
+ var hours = Math.floor(absOffset / 60);
1279
+ var minutes = absOffset % 60;
1280
+ if (minutes === 0) {
1281
+ return sign + String(hours);
1282
+ }
1283
+ var delimiter = dirtyDelimiter || '';
1284
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1285
+ }
1286
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1287
+ if (offset % 60 === 0) {
1288
+ var sign = offset > 0 ? '-' : '+';
1289
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1290
+ }
1291
+ return formatTimezone(offset, dirtyDelimiter);
1292
+ }
1293
+ function formatTimezone(offset, dirtyDelimiter) {
1294
+ var delimiter = dirtyDelimiter || '';
1295
+ var sign = offset > 0 ? '-' : '+';
1296
+ var absOffset = Math.abs(offset);
1297
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1298
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1299
+ return sign + hours + delimiter + minutes;
1300
+ }
1301
+ const formatters$1 = formatters;
1302
+
1303
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1304
+ switch (pattern) {
1305
+ case 'P':
1306
+ return formatLong.date({
1307
+ width: 'short'
1308
+ });
1309
+ case 'PP':
1310
+ return formatLong.date({
1311
+ width: 'medium'
1312
+ });
1313
+ case 'PPP':
1314
+ return formatLong.date({
1315
+ width: 'long'
1316
+ });
1317
+ case 'PPPP':
1318
+ default:
1319
+ return formatLong.date({
1320
+ width: 'full'
1321
+ });
1322
+ }
1323
+ };
1324
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1325
+ switch (pattern) {
1326
+ case 'p':
1327
+ return formatLong.time({
1328
+ width: 'short'
1329
+ });
1330
+ case 'pp':
1331
+ return formatLong.time({
1332
+ width: 'medium'
1333
+ });
1334
+ case 'ppp':
1335
+ return formatLong.time({
1336
+ width: 'long'
1337
+ });
1338
+ case 'pppp':
1339
+ default:
1340
+ return formatLong.time({
1341
+ width: 'full'
1342
+ });
1343
+ }
1344
+ };
1345
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1346
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1347
+ var datePattern = matchResult[1];
1348
+ var timePattern = matchResult[2];
1349
+ if (!timePattern) {
1350
+ return dateLongFormatter(pattern, formatLong);
1351
+ }
1352
+ var dateTimeFormat;
1353
+ switch (datePattern) {
1354
+ case 'P':
1355
+ dateTimeFormat = formatLong.dateTime({
1356
+ width: 'short'
1357
+ });
1358
+ break;
1359
+ case 'PP':
1360
+ dateTimeFormat = formatLong.dateTime({
1361
+ width: 'medium'
1362
+ });
1363
+ break;
1364
+ case 'PPP':
1365
+ dateTimeFormat = formatLong.dateTime({
1366
+ width: 'long'
1367
+ });
1368
+ break;
1369
+ case 'PPPP':
1370
+ default:
1371
+ dateTimeFormat = formatLong.dateTime({
1372
+ width: 'full'
1373
+ });
1374
+ break;
1375
+ }
1376
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1377
+ };
1378
+ var longFormatters = {
1379
+ p: timeLongFormatter,
1380
+ P: dateTimeLongFormatter
1381
+ };
1382
+ const longFormatters$1 = longFormatters;
1383
+
1384
+ var protectedDayOfYearTokens = ['D', 'DD'];
1385
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1386
+ function isProtectedDayOfYearToken(token) {
1387
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1388
+ }
1389
+ function isProtectedWeekYearToken(token) {
1390
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1391
+ }
1392
+ function throwProtectedError(token, format, input) {
1393
+ if (token === 'YYYY') {
1394
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1395
+ } else if (token === 'YY') {
1396
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1397
+ } else if (token === 'D') {
1398
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1399
+ } else if (token === 'DD') {
1400
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1401
+ }
1402
+ }
1403
+
1404
+ var formatDistanceLocale = {
1405
+ lessThanXSeconds: {
1406
+ one: 'less than a second',
1407
+ other: 'less than {{count}} seconds'
1408
+ },
1409
+ xSeconds: {
1410
+ one: '1 second',
1411
+ other: '{{count}} seconds'
1412
+ },
1413
+ halfAMinute: 'half a minute',
1414
+ lessThanXMinutes: {
1415
+ one: 'less than a minute',
1416
+ other: 'less than {{count}} minutes'
1417
+ },
1418
+ xMinutes: {
1419
+ one: '1 minute',
1420
+ other: '{{count}} minutes'
1421
+ },
1422
+ aboutXHours: {
1423
+ one: 'about 1 hour',
1424
+ other: 'about {{count}} hours'
1425
+ },
1426
+ xHours: {
1427
+ one: '1 hour',
1428
+ other: '{{count}} hours'
1429
+ },
1430
+ xDays: {
1431
+ one: '1 day',
1432
+ other: '{{count}} days'
1433
+ },
1434
+ aboutXWeeks: {
1435
+ one: 'about 1 week',
1436
+ other: 'about {{count}} weeks'
1437
+ },
1438
+ xWeeks: {
1439
+ one: '1 week',
1440
+ other: '{{count}} weeks'
1441
+ },
1442
+ aboutXMonths: {
1443
+ one: 'about 1 month',
1444
+ other: 'about {{count}} months'
1445
+ },
1446
+ xMonths: {
1447
+ one: '1 month',
1448
+ other: '{{count}} months'
1449
+ },
1450
+ aboutXYears: {
1451
+ one: 'about 1 year',
1452
+ other: 'about {{count}} years'
1453
+ },
1454
+ xYears: {
1455
+ one: '1 year',
1456
+ other: '{{count}} years'
1457
+ },
1458
+ overXYears: {
1459
+ one: 'over 1 year',
1460
+ other: 'over {{count}} years'
1461
+ },
1462
+ almostXYears: {
1463
+ one: 'almost 1 year',
1464
+ other: 'almost {{count}} years'
1465
+ }
1466
+ };
1467
+ var formatDistance = function formatDistance(token, count, options) {
1468
+ var result;
1469
+ var tokenValue = formatDistanceLocale[token];
1470
+ if (typeof tokenValue === 'string') {
1471
+ result = tokenValue;
1472
+ } else if (count === 1) {
1473
+ result = tokenValue.one;
1474
+ } else {
1475
+ result = tokenValue.other.replace('{{count}}', count.toString());
1476
+ }
1477
+ if (options !== null && options !== void 0 && options.addSuffix) {
1478
+ if (options.comparison && options.comparison > 0) {
1479
+ return 'in ' + result;
1480
+ } else {
1481
+ return result + ' ago';
1482
+ }
1483
+ }
1484
+ return result;
1485
+ };
1486
+ const formatDistance$1 = formatDistance;
1487
+
1488
+ function buildFormatLongFn(args) {
1489
+ return function () {
1490
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1491
+ // TODO: Remove String()
1492
+ var width = options.width ? String(options.width) : args.defaultWidth;
1493
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1494
+ return format;
1495
+ };
1496
+ }
1497
+
1498
+ var dateFormats = {
1499
+ full: 'EEEE, MMMM do, y',
1500
+ long: 'MMMM do, y',
1501
+ medium: 'MMM d, y',
1502
+ short: 'MM/dd/yyyy'
1503
+ };
1504
+ var timeFormats = {
1505
+ full: 'h:mm:ss a zzzz',
1506
+ long: 'h:mm:ss a z',
1507
+ medium: 'h:mm:ss a',
1508
+ short: 'h:mm a'
1509
+ };
1510
+ var dateTimeFormats = {
1511
+ full: "{{date}} 'at' {{time}}",
1512
+ long: "{{date}} 'at' {{time}}",
1513
+ medium: '{{date}}, {{time}}',
1514
+ short: '{{date}}, {{time}}'
1515
+ };
1516
+ var formatLong = {
1517
+ date: buildFormatLongFn({
1518
+ formats: dateFormats,
1519
+ defaultWidth: 'full'
1520
+ }),
1521
+ time: buildFormatLongFn({
1522
+ formats: timeFormats,
1523
+ defaultWidth: 'full'
1524
+ }),
1525
+ dateTime: buildFormatLongFn({
1526
+ formats: dateTimeFormats,
1527
+ defaultWidth: 'full'
1528
+ })
1529
+ };
1530
+ const formatLong$1 = formatLong;
1531
+
1532
+ var formatRelativeLocale = {
1533
+ lastWeek: "'last' eeee 'at' p",
1534
+ yesterday: "'yesterday at' p",
1535
+ today: "'today at' p",
1536
+ tomorrow: "'tomorrow at' p",
1537
+ nextWeek: "eeee 'at' p",
1538
+ other: 'P'
1539
+ };
1540
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1541
+ return formatRelativeLocale[token];
1542
+ };
1543
+ const formatRelative$1 = formatRelative;
1544
+
1545
+ function buildLocalizeFn(args) {
1546
+ return function (dirtyIndex, options) {
1547
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1548
+ var valuesArray;
1549
+ if (context === 'formatting' && args.formattingValues) {
1550
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1551
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1552
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1553
+ } else {
1554
+ var _defaultWidth = args.defaultWidth;
1555
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1556
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1557
+ }
1558
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1559
+ // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1560
+ return valuesArray[index];
1561
+ };
1562
+ }
1563
+
1564
+ var eraValues = {
1565
+ narrow: ['B', 'A'],
1566
+ abbreviated: ['BC', 'AD'],
1567
+ wide: ['Before Christ', 'Anno Domini']
1568
+ };
1569
+ var quarterValues = {
1570
+ narrow: ['1', '2', '3', '4'],
1571
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1572
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1573
+ };
1574
+
1575
+ // Note: in English, the names of days of the week and months are capitalized.
1576
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1577
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1578
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1579
+ var monthValues = {
1580
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1581
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1582
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1583
+ };
1584
+ var dayValues = {
1585
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1586
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1587
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1588
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1589
+ };
1590
+ var dayPeriodValues = {
1591
+ narrow: {
1592
+ am: 'a',
1593
+ pm: 'p',
1594
+ midnight: 'mi',
1595
+ noon: 'n',
1596
+ morning: 'morning',
1597
+ afternoon: 'afternoon',
1598
+ evening: 'evening',
1599
+ night: 'night'
1600
+ },
1601
+ abbreviated: {
1602
+ am: 'AM',
1603
+ pm: 'PM',
1604
+ midnight: 'midnight',
1605
+ noon: 'noon',
1606
+ morning: 'morning',
1607
+ afternoon: 'afternoon',
1608
+ evening: 'evening',
1609
+ night: 'night'
1610
+ },
1611
+ wide: {
1612
+ am: 'a.m.',
1613
+ pm: 'p.m.',
1614
+ midnight: 'midnight',
1615
+ noon: 'noon',
1616
+ morning: 'morning',
1617
+ afternoon: 'afternoon',
1618
+ evening: 'evening',
1619
+ night: 'night'
1620
+ }
1621
+ };
1622
+ var formattingDayPeriodValues = {
1623
+ narrow: {
1624
+ am: 'a',
1625
+ pm: 'p',
1626
+ midnight: 'mi',
1627
+ noon: 'n',
1628
+ morning: 'in the morning',
1629
+ afternoon: 'in the afternoon',
1630
+ evening: 'in the evening',
1631
+ night: 'at night'
1632
+ },
1633
+ abbreviated: {
1634
+ am: 'AM',
1635
+ pm: 'PM',
1636
+ midnight: 'midnight',
1637
+ noon: 'noon',
1638
+ morning: 'in the morning',
1639
+ afternoon: 'in the afternoon',
1640
+ evening: 'in the evening',
1641
+ night: 'at night'
1642
+ },
1643
+ wide: {
1644
+ am: 'a.m.',
1645
+ pm: 'p.m.',
1646
+ midnight: 'midnight',
1647
+ noon: 'noon',
1648
+ morning: 'in the morning',
1649
+ afternoon: 'in the afternoon',
1650
+ evening: 'in the evening',
1651
+ night: 'at night'
1652
+ }
1653
+ };
1654
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1655
+ var number = Number(dirtyNumber);
1656
+
1657
+ // If ordinal numbers depend on context, for example,
1658
+ // if they are different for different grammatical genders,
1659
+ // use `options.unit`.
1660
+ //
1661
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1662
+ // 'day', 'hour', 'minute', 'second'.
1663
+
1664
+ var rem100 = number % 100;
1665
+ if (rem100 > 20 || rem100 < 10) {
1666
+ switch (rem100 % 10) {
1667
+ case 1:
1668
+ return number + 'st';
1669
+ case 2:
1670
+ return number + 'nd';
1671
+ case 3:
1672
+ return number + 'rd';
1673
+ }
1674
+ }
1675
+ return number + 'th';
1676
+ };
1677
+ var localize = {
1678
+ ordinalNumber: ordinalNumber,
1679
+ era: buildLocalizeFn({
1680
+ values: eraValues,
1681
+ defaultWidth: 'wide'
1682
+ }),
1683
+ quarter: buildLocalizeFn({
1684
+ values: quarterValues,
1685
+ defaultWidth: 'wide',
1686
+ argumentCallback: function argumentCallback(quarter) {
1687
+ return quarter - 1;
1688
+ }
1689
+ }),
1690
+ month: buildLocalizeFn({
1691
+ values: monthValues,
1692
+ defaultWidth: 'wide'
1693
+ }),
1694
+ day: buildLocalizeFn({
1695
+ values: dayValues,
1696
+ defaultWidth: 'wide'
1697
+ }),
1698
+ dayPeriod: buildLocalizeFn({
1699
+ values: dayPeriodValues,
1700
+ defaultWidth: 'wide',
1701
+ formattingValues: formattingDayPeriodValues,
1702
+ defaultFormattingWidth: 'wide'
1703
+ })
1704
+ };
1705
+ const localize$1 = localize;
1706
+
1707
+ function buildMatchFn(args) {
1708
+ return function (string) {
1709
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1710
+ var width = options.width;
1711
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1712
+ var matchResult = string.match(matchPattern);
1713
+ if (!matchResult) {
1714
+ return null;
1715
+ }
1716
+ var matchedString = matchResult[0];
1717
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1718
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1719
+ return pattern.test(matchedString);
1720
+ }) : findKey(parsePatterns, function (pattern) {
1721
+ return pattern.test(matchedString);
1722
+ });
1723
+ var value;
1724
+ value = args.valueCallback ? args.valueCallback(key) : key;
1725
+ value = options.valueCallback ? options.valueCallback(value) : value;
1726
+ var rest = string.slice(matchedString.length);
1727
+ return {
1728
+ value: value,
1729
+ rest: rest
1730
+ };
1731
+ };
1732
+ }
1733
+ function findKey(object, predicate) {
1734
+ for (var key in object) {
1735
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1736
+ return key;
1737
+ }
1738
+ }
1739
+ return undefined;
1740
+ }
1741
+ function findIndex(array, predicate) {
1742
+ for (var key = 0; key < array.length; key++) {
1743
+ if (predicate(array[key])) {
1744
+ return key;
1745
+ }
1746
+ }
1747
+ return undefined;
1748
+ }
1749
+
1750
+ function buildMatchPatternFn(args) {
1751
+ return function (string) {
1752
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1753
+ var matchResult = string.match(args.matchPattern);
1754
+ if (!matchResult) return null;
1755
+ var matchedString = matchResult[0];
1756
+ var parseResult = string.match(args.parsePattern);
1757
+ if (!parseResult) return null;
1758
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1759
+ value = options.valueCallback ? options.valueCallback(value) : value;
1760
+ var rest = string.slice(matchedString.length);
1761
+ return {
1762
+ value: value,
1763
+ rest: rest
1764
+ };
1765
+ };
1766
+ }
1767
+
1768
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1769
+ var parseOrdinalNumberPattern = /\d+/i;
1770
+ var matchEraPatterns = {
1771
+ narrow: /^(b|a)/i,
1772
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1773
+ wide: /^(before christ|before common era|anno domini|common era)/i
1774
+ };
1775
+ var parseEraPatterns = {
1776
+ any: [/^b/i, /^(a|c)/i]
1777
+ };
1778
+ var matchQuarterPatterns = {
1779
+ narrow: /^[1234]/i,
1780
+ abbreviated: /^q[1234]/i,
1781
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1782
+ };
1783
+ var parseQuarterPatterns = {
1784
+ any: [/1/i, /2/i, /3/i, /4/i]
1785
+ };
1786
+ var matchMonthPatterns = {
1787
+ narrow: /^[jfmasond]/i,
1788
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1789
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1790
+ };
1791
+ var parseMonthPatterns = {
1792
+ narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
1793
+ any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
1794
+ };
1795
+ var matchDayPatterns = {
1796
+ narrow: /^[smtwf]/i,
1797
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1798
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1799
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1800
+ };
1801
+ var parseDayPatterns = {
1802
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1803
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1804
+ };
1805
+ var matchDayPeriodPatterns = {
1806
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1807
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1808
+ };
1809
+ var parseDayPeriodPatterns = {
1810
+ any: {
1811
+ am: /^a/i,
1812
+ pm: /^p/i,
1813
+ midnight: /^mi/i,
1814
+ noon: /^no/i,
1815
+ morning: /morning/i,
1816
+ afternoon: /afternoon/i,
1817
+ evening: /evening/i,
1818
+ night: /night/i
1819
+ }
1820
+ };
1821
+ var match = {
1822
+ ordinalNumber: buildMatchPatternFn({
1823
+ matchPattern: matchOrdinalNumberPattern,
1824
+ parsePattern: parseOrdinalNumberPattern,
1825
+ valueCallback: function valueCallback(value) {
1826
+ return parseInt(value, 10);
1827
+ }
1828
+ }),
1829
+ era: buildMatchFn({
1830
+ matchPatterns: matchEraPatterns,
1831
+ defaultMatchWidth: 'wide',
1832
+ parsePatterns: parseEraPatterns,
1833
+ defaultParseWidth: 'any'
1834
+ }),
1835
+ quarter: buildMatchFn({
1836
+ matchPatterns: matchQuarterPatterns,
1837
+ defaultMatchWidth: 'wide',
1838
+ parsePatterns: parseQuarterPatterns,
1839
+ defaultParseWidth: 'any',
1840
+ valueCallback: function valueCallback(index) {
1841
+ return index + 1;
1842
+ }
1843
+ }),
1844
+ month: buildMatchFn({
1845
+ matchPatterns: matchMonthPatterns,
1846
+ defaultMatchWidth: 'wide',
1847
+ parsePatterns: parseMonthPatterns,
1848
+ defaultParseWidth: 'any'
1849
+ }),
1850
+ day: buildMatchFn({
1851
+ matchPatterns: matchDayPatterns,
1852
+ defaultMatchWidth: 'wide',
1853
+ parsePatterns: parseDayPatterns,
1854
+ defaultParseWidth: 'any'
1855
+ }),
1856
+ dayPeriod: buildMatchFn({
1857
+ matchPatterns: matchDayPeriodPatterns,
1858
+ defaultMatchWidth: 'any',
1859
+ parsePatterns: parseDayPeriodPatterns,
1860
+ defaultParseWidth: 'any'
1861
+ })
1862
+ };
1863
+ const match$1 = match;
1864
+
1865
+ /**
1866
+ * @type {Locale}
1867
+ * @category Locales
1868
+ * @summary English locale (United States).
1869
+ * @language English
1870
+ * @iso-639-2 eng
1871
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1872
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1873
+ */
1874
+ var locale = {
1875
+ code: 'en-US',
1876
+ formatDistance: formatDistance$1,
1877
+ formatLong: formatLong$1,
1878
+ formatRelative: formatRelative$1,
1879
+ localize: localize$1,
1880
+ match: match$1,
1881
+ options: {
1882
+ weekStartsOn: 0 /* Sunday */,
1883
+ firstWeekContainsDate: 1
1884
+ }
1885
+ };
1886
+ const defaultLocale = locale;
1887
+
1888
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1889
+ // (one of the certain letters followed by `o`)
1890
+ // - (\w)\1* matches any sequences of the same letter
1891
+ // - '' matches two quote characters in a row
1892
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
1893
+ // except a single quote symbol, which ends the sequence.
1894
+ // Two quote characters do not end the sequence.
1895
+ // If there is no matching single quote
1896
+ // then the sequence will continue until the end of the string.
1897
+ // - . matches any single character unmatched by previous parts of the RegExps
1898
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
1899
+
1900
+ // This RegExp catches symbols escaped by quotes, and also
1901
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
1902
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1903
+ var escapedStringRegExp = /^'([^]*?)'?$/;
1904
+ var doubleQuoteRegExp = /''/g;
1905
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1906
+
1907
+ /**
1908
+ * @name format
1909
+ * @category Common Helpers
1910
+ * @summary Format the date.
1911
+ *
1912
+ * @description
1913
+ * Return the formatted date string in the given format. The result may vary by locale.
1914
+ *
1915
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
1916
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
1917
+ *
1918
+ * The characters wrapped between two single quotes characters (') are escaped.
1919
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
1920
+ * (see the last example)
1921
+ *
1922
+ * Format of the string is based on Unicode Technical Standard #35:
1923
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
1924
+ * with a few additions (see note 7 below the table).
1925
+ *
1926
+ * Accepted patterns:
1927
+ * | Unit | Pattern | Result examples | Notes |
1928
+ * |---------------------------------|---------|-----------------------------------|-------|
1929
+ * | Era | G..GGG | AD, BC | |
1930
+ * | | GGGG | Anno Domini, Before Christ | 2 |
1931
+ * | | GGGGG | A, B | |
1932
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
1933
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
1934
+ * | | yy | 44, 01, 00, 17 | 5 |
1935
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
1936
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
1937
+ * | | yyyyy | ... | 3,5 |
1938
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
1939
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
1940
+ * | | YY | 44, 01, 00, 17 | 5,8 |
1941
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
1942
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
1943
+ * | | YYYYY | ... | 3,5 |
1944
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
1945
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
1946
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
1947
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
1948
+ * | | RRRRR | ... | 3,5,7 |
1949
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
1950
+ * | | uu | -43, 01, 1900, 2017 | 5 |
1951
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
1952
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
1953
+ * | | uuuuu | ... | 3,5 |
1954
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
1955
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
1956
+ * | | QQ | 01, 02, 03, 04 | |
1957
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
1958
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
1959
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
1960
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
1961
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
1962
+ * | | qq | 01, 02, 03, 04 | |
1963
+ * | | qqq | Q1, Q2, Q3, Q4 | |
1964
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
1965
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
1966
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
1967
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
1968
+ * | | MM | 01, 02, ..., 12 | |
1969
+ * | | MMM | Jan, Feb, ..., Dec | |
1970
+ * | | MMMM | January, February, ..., December | 2 |
1971
+ * | | MMMMM | J, F, ..., D | |
1972
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
1973
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
1974
+ * | | LL | 01, 02, ..., 12 | |
1975
+ * | | LLL | Jan, Feb, ..., Dec | |
1976
+ * | | LLLL | January, February, ..., December | 2 |
1977
+ * | | LLLLL | J, F, ..., D | |
1978
+ * | Local week of year | w | 1, 2, ..., 53 | |
1979
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
1980
+ * | | ww | 01, 02, ..., 53 | |
1981
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
1982
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
1983
+ * | | II | 01, 02, ..., 53 | 7 |
1984
+ * | Day of month | d | 1, 2, ..., 31 | |
1985
+ * | | do | 1st, 2nd, ..., 31st | 7 |
1986
+ * | | dd | 01, 02, ..., 31 | |
1987
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
1988
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
1989
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
1990
+ * | | DDD | 001, 002, ..., 365, 366 | |
1991
+ * | | DDDD | ... | 3 |
1992
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
1993
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
1994
+ * | | EEEEE | M, T, W, T, F, S, S | |
1995
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
1996
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
1997
+ * | | io | 1st, 2nd, ..., 7th | 7 |
1998
+ * | | ii | 01, 02, ..., 07 | 7 |
1999
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2000
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2001
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2002
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2003
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2004
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2005
+ * | | ee | 02, 03, ..., 01 | |
2006
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2007
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2008
+ * | | eeeee | M, T, W, T, F, S, S | |
2009
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2010
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2011
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2012
+ * | | cc | 02, 03, ..., 01 | |
2013
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2014
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2015
+ * | | ccccc | M, T, W, T, F, S, S | |
2016
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2017
+ * | AM, PM | a..aa | AM, PM | |
2018
+ * | | aaa | am, pm | |
2019
+ * | | aaaa | a.m., p.m. | 2 |
2020
+ * | | aaaaa | a, p | |
2021
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2022
+ * | | bbb | am, pm, noon, midnight | |
2023
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2024
+ * | | bbbbb | a, p, n, mi | |
2025
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2026
+ * | | BBBB | at night, in the morning, ... | 2 |
2027
+ * | | BBBBB | at night, in the morning, ... | |
2028
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2029
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2030
+ * | | hh | 01, 02, ..., 11, 12 | |
2031
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2032
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2033
+ * | | HH | 00, 01, 02, ..., 23 | |
2034
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2035
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2036
+ * | | KK | 01, 02, ..., 11, 00 | |
2037
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2038
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2039
+ * | | kk | 24, 01, 02, ..., 23 | |
2040
+ * | Minute | m | 0, 1, ..., 59 | |
2041
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2042
+ * | | mm | 00, 01, ..., 59 | |
2043
+ * | Second | s | 0, 1, ..., 59 | |
2044
+ * | | so | 0th, 1st, ..., 59th | 7 |
2045
+ * | | ss | 00, 01, ..., 59 | |
2046
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2047
+ * | | SS | 00, 01, ..., 99 | |
2048
+ * | | SSS | 000, 001, ..., 999 | |
2049
+ * | | SSSS | ... | 3 |
2050
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2051
+ * | | XX | -0800, +0530, Z | |
2052
+ * | | XXX | -08:00, +05:30, Z | |
2053
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2054
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2055
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2056
+ * | | xx | -0800, +0530, +0000 | |
2057
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2058
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2059
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2060
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2061
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2062
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2063
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2064
+ * | Seconds timestamp | t | 512969520 | 7 |
2065
+ * | | tt | ... | 3,7 |
2066
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2067
+ * | | TT | ... | 3,7 |
2068
+ * | Long localized date | P | 04/29/1453 | 7 |
2069
+ * | | PP | Apr 29, 1453 | 7 |
2070
+ * | | PPP | April 29th, 1453 | 7 |
2071
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2072
+ * | Long localized time | p | 12:00 AM | 7 |
2073
+ * | | pp | 12:00:00 AM | 7 |
2074
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2075
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2076
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2077
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2078
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2079
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2080
+ * Notes:
2081
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2082
+ * are the same as "stand-alone" units, but are different in some languages.
2083
+ * "Formatting" units are declined according to the rules of the language
2084
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2085
+ *
2086
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2087
+ *
2088
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2089
+ *
2090
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2091
+ * the single quote characters (see below).
2092
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2093
+ * the output will be the same as default pattern for this unit, usually
2094
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2095
+ * are marked with "2" in the last column of the table.
2096
+ *
2097
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2098
+ *
2099
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2100
+ *
2101
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2102
+ *
2103
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2104
+ *
2105
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2106
+ *
2107
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2108
+ * The output will be padded with zeros to match the length of the pattern.
2109
+ *
2110
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2111
+ *
2112
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2113
+ * These tokens represent the shortest form of the quarter.
2114
+ *
2115
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2116
+ *
2117
+ * | Year | `y` | `u` |
2118
+ * |------|-----|-----|
2119
+ * | AC 1 | 1 | 1 |
2120
+ * | BC 1 | 1 | 0 |
2121
+ * | BC 2 | 2 | -1 |
2122
+ *
2123
+ * Also `yy` always returns the last two digits of a year,
2124
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2125
+ *
2126
+ * | Year | `yy` | `uu` |
2127
+ * |------|------|------|
2128
+ * | 1 | 01 | 01 |
2129
+ * | 14 | 14 | 14 |
2130
+ * | 376 | 76 | 376 |
2131
+ * | 1453 | 53 | 1453 |
2132
+ *
2133
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2134
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2135
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2136
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2137
+ *
2138
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2139
+ * so right now these tokens fall back to GMT timezones.
2140
+ *
2141
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2142
+ * - `i`: ISO day of week
2143
+ * - `I`: ISO week of year
2144
+ * - `R`: ISO week-numbering year
2145
+ * - `t`: seconds timestamp
2146
+ * - `T`: milliseconds timestamp
2147
+ * - `o`: ordinal number modifier
2148
+ * - `P`: long localized date
2149
+ * - `p`: long localized time
2150
+ *
2151
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2152
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2153
+ *
2154
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2155
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2156
+ *
2157
+ * @param {Date|Number} date - the original date
2158
+ * @param {String} format - the string of tokens
2159
+ * @param {Object} [options] - an object with options.
2160
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2161
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2162
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2163
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2164
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2165
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2166
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2167
+ * @returns {String} the formatted date string
2168
+ * @throws {TypeError} 2 arguments required
2169
+ * @throws {RangeError} `date` must not be Invalid Date
2170
+ * @throws {RangeError} `options.locale` must contain `localize` property
2171
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2172
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2173
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2174
+ * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2175
+ * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2176
+ * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2177
+ * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2178
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2179
+ *
2180
+ * @example
2181
+ * // Represent 11 February 2014 in middle-endian format:
2182
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2183
+ * //=> '02/11/2014'
2184
+ *
2185
+ * @example
2186
+ * // Represent 2 July 2014 in Esperanto:
2187
+ * import { eoLocale } from 'date-fns/locale/eo'
2188
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2189
+ * locale: eoLocale
2190
+ * })
2191
+ * //=> '2-a de julio 2014'
2192
+ *
2193
+ * @example
2194
+ * // Escape string by single quote characters:
2195
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2196
+ * //=> "3 o'clock"
2197
+ */
2198
+
2199
+ function format(dirtyDate, dirtyFormatStr, options) {
2200
+ var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2201
+ requiredArgs(2, arguments);
2202
+ var formatStr = String(dirtyFormatStr);
2203
+ var defaultOptions = getDefaultOptions();
2204
+ var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;
2205
+ var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2206
+
2207
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2208
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2209
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2210
+ }
2211
+ var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2212
+
2213
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2214
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2215
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2216
+ }
2217
+ if (!locale.localize) {
2218
+ throw new RangeError('locale must contain localize property');
2219
+ }
2220
+ if (!locale.formatLong) {
2221
+ throw new RangeError('locale must contain formatLong property');
2222
+ }
2223
+ var originalDate = toDate(dirtyDate);
2224
+ if (!isValid(originalDate)) {
2225
+ throw new RangeError('Invalid time value');
2226
+ }
2227
+
2228
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2229
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2230
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2231
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2232
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2233
+ var formatterOptions = {
2234
+ firstWeekContainsDate: firstWeekContainsDate,
2235
+ weekStartsOn: weekStartsOn,
2236
+ locale: locale,
2237
+ _originalDate: originalDate
2238
+ };
2239
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2240
+ var firstCharacter = substring[0];
2241
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2242
+ var longFormatter = longFormatters$1[firstCharacter];
2243
+ return longFormatter(substring, locale.formatLong);
2244
+ }
2245
+ return substring;
2246
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2247
+ // Replace two single quote characters with one single quote character
2248
+ if (substring === "''") {
2249
+ return "'";
2250
+ }
2251
+ var firstCharacter = substring[0];
2252
+ if (firstCharacter === "'") {
2253
+ return cleanEscapedString(substring);
2254
+ }
2255
+ var formatter = formatters$1[firstCharacter];
2256
+ if (formatter) {
2257
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2258
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2259
+ }
2260
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2261
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2262
+ }
2263
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
2264
+ }
2265
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2266
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2267
+ }
2268
+ return substring;
2269
+ }).join('');
2270
+ return result;
2271
+ }
2272
+ function cleanEscapedString(input) {
2273
+ var matched = input.match(escapedStringRegExp);
2274
+ if (!matched) {
2275
+ return input;
2276
+ }
2277
+ return matched[1].replace(doubleQuoteRegExp, "'");
2278
+ }
2279
+
2280
+ const generateUUID = () => {
2281
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
2282
+ var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
2283
+ return v.toString(16);
2284
+ });
2285
+ };
2286
+ function fetchRequest(url, method = 'GET', body = null, headers = {}) {
2287
+ return new Promise((resolve, reject) => {
2288
+ const uuid = generateUUID();
2289
+ const headersOrigin = Object.assign({ 'Content-Type': 'application/json' }, headers);
2290
+ if (method !== 'GET' && method !== 'HEAD') {
2291
+ headersOrigin['X-Idempotency-Key'] = uuid;
2292
+ }
2293
+ const options = {
2294
+ method,
2295
+ headers: headersOrigin,
2296
+ body: null
2297
+ };
2298
+ if (body && method !== 'GET' && method !== 'HEAD') {
2299
+ options.body = JSON.stringify(body);
2300
+ }
2301
+ else {
2302
+ delete options.body;
2303
+ }
2304
+ fetch(url, options)
2305
+ .then((response) => {
2306
+ if (!response.ok) {
2307
+ return response.json().then((errorData) => {
2308
+ const error = {
2309
+ status: response.status,
2310
+ statusText: response.statusText,
2311
+ code: errorData.code || 'UNKNOWN_ERROR',
2312
+ message: errorData.message || 'An unknown error occurred',
2313
+ data: errorData.data || null
2314
+ };
2315
+ reject(error);
2316
+ }, () => reject({
2317
+ status: response.status,
2318
+ statusText: response.statusText,
2319
+ code: 'PARSE_ERROR',
2320
+ message: 'Failed to parse error response'
2321
+ }));
2322
+ }
2323
+ else {
2324
+ return response.json();
2325
+ }
2326
+ })
2327
+ .then((data) => resolve(data), (error) => reject(error));
2328
+ });
2329
+ }
2330
+ function isEmptyValueOfArray(arr) {
2331
+ if (arr.length === 0) {
2332
+ return true;
2333
+ }
2334
+ const len = arr.length;
2335
+ let count = 0;
2336
+ for (let i = 0; i < len; i++) {
2337
+ if (isEmptyValue(arr[i])) {
2338
+ count++;
2339
+ }
2340
+ else {
2341
+ return false;
2342
+ }
2343
+ }
2344
+ if (count === len) {
2345
+ return true;
2346
+ }
2347
+ return false;
2348
+ }
2349
+ function isEmptyValueOfObject(obj) {
2350
+ if (Object.keys(obj).length === 0) {
2351
+ return true;
2352
+ }
2353
+ const len = Object.keys(obj).length;
2354
+ let count = 0;
2355
+ for (const val of Object.values(obj)) {
2356
+ if (isEmptyValue(val)) {
2357
+ count++;
2358
+ }
2359
+ else {
2360
+ return false;
2361
+ }
2362
+ }
2363
+ if (count === len) {
2364
+ return true;
2365
+ }
2366
+ return false;
2367
+ }
2368
+ function isEmptyValue(value, allowZero) {
2369
+ if (value === null || value === undefined || value === '') {
2370
+ return true;
2371
+ }
2372
+ else if (value === 0 && allowZero) {
2373
+ return false;
2374
+ }
2375
+ else if (Array.isArray(value)) {
2376
+ return isEmptyValueOfArray(value);
2377
+ }
2378
+ else if (Object.prototype.toString.call(value) === '[object Object]') {
2379
+ return isEmptyValueOfObject(value);
2380
+ }
2381
+ else {
2382
+ return !value;
2383
+ }
2384
+ }
2385
+ function toQueryParams(params) {
2386
+ const finalParams = {};
2387
+ Object.entries(params).forEach(([key, value]) => {
2388
+ if (!isEmptyValue(value, true)) {
2389
+ finalParams[key] = value;
2390
+ }
2391
+ });
2392
+ const queryString = Object.entries(finalParams)
2393
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
2394
+ .join('&');
2395
+ return queryString ? `?${queryString}` : '';
2396
+ }
2397
+ const SPLIT_CHAR = '?';
2398
+ function transformResults(results, meta) {
2399
+ if (results && results.length > 0) {
2400
+ return results.map((item) => {
2401
+ const [date, time] = format(new Date(item.createdAt), `MMM d,yyyy${SPLIT_CHAR}HH:mm:ss a 'UTC'`).split(SPLIT_CHAR);
2402
+ return {
2403
+ id: item.id,
2404
+ name: (meta === null || meta === void 0 ? void 0 : meta.name) || item.gameName,
2405
+ imageSrc: meta === null || meta === void 0 ? void 0 : meta.imageSrc,
2406
+ totalAmount: (meta === null || meta === void 0 ? void 0 : meta.currency) ? `${meta === null || meta === void 0 ? void 0 : meta.currency} ${item.amount}` : item.amount,
2407
+ date,
2408
+ time,
2409
+ selectedNumbers: item.selection
2410
+ .map((item) => {
2411
+ return item.selections;
2412
+ })
2413
+ .join(',')
2414
+ };
2415
+ });
2416
+ }
2417
+ return [];
2418
+ }
2419
+ async function fetchTicketList({ endpoint, filterData, sessionId, meta }) {
2420
+ const { items = [], total } = (await fetchRequest(`${endpoint}/tickets${toQueryParams(filterData)}`, 'GET', null, {
2421
+ Authorization: `Bearer ${sessionId}`
2422
+ })) || { items: [], total: 0 };
2423
+ return {
2424
+ items: transformResults(items, meta),
2425
+ total: total
2426
+ };
2427
+ }
2428
+
2429
+ const DEFAULT_LANGUAGE = 'en';
2430
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
2431
+ const TRANSLATIONS = {
2432
+ en: {
2433
+ releaseToRefresh: 'Release to refresh...',
2434
+ youHaveReachedTheEnd: 'You have reached the end.',
2435
+ failToShowTicketList: 'Fail to show ticket list.',
2436
+ unauthorized: 'Unauthorized, please login.'
2437
+ }
2438
+ };
2439
+ const translate = (key, customLang, replacements) => {
2440
+ const lang = customLang;
2441
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
2442
+ if (replacements) {
2443
+ Object.keys(replacements).forEach((placeholder) => {
2444
+ translation = translation.replace(`{${placeholder}}`, replacements[placeholder]);
2445
+ });
2446
+ }
2447
+ return translation;
2448
+ };
2449
+ const getTranslations = (data) => {
2450
+ Object.keys(data).forEach((item) => {
2451
+ for (let key in data[item]) {
2452
+ TRANSLATIONS[item][key] = data[item][key];
2453
+ }
2454
+ });
2455
+ };
2456
+ const resolveTranslationUrl = async (translationUrl) => {
2457
+ if (translationUrl) {
2458
+ try {
2459
+ const response = await fetch(translationUrl);
2460
+ if (!response.ok) {
2461
+ throw new Error(`HTTP error! status: ${response.status}`);
2462
+ }
2463
+ const translations = await response.json();
2464
+ getTranslations(translations);
2465
+ }
2466
+ catch (error) {
2467
+ console.error('Failed to fetch or parse translations from URL:', error);
2468
+ }
2469
+ }
2470
+ };
2471
+
2472
+ // This icon file is generated automatically.
2473
+ var LoadingOutlined = { "icon": { "tag": "svg", "attrs": { "viewBox": "0 0 1024 1024", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" } }] }, "name": "loading", "theme": "outlined" };
2474
+ const LoadingOutlined$1 = LoadingOutlined;
2475
+
2476
+ var __assign = (undefined && undefined.__assign) || function () {
2477
+ __assign = Object.assign || function(t) {
2478
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2479
+ s = arguments[i];
2480
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2481
+ t[p] = s[p];
2482
+ }
2483
+ return t;
2484
+ };
2485
+ return __assign.apply(this, arguments);
2486
+ };
2487
+ var defaultColors = {
2488
+ primaryColor: '#333',
2489
+ secondaryColor: '#E6E6E6'
2490
+ };
2491
+ function renderIconDefinitionToSVGElement(icond, options) {
2492
+ if (options === void 0) { options = {}; }
2493
+ if (typeof icond.icon === 'function') {
2494
+ // two-tone
2495
+ var placeholders = options.placeholders || defaultColors;
2496
+ return renderAbstractNodeToSVGElement(icond.icon(placeholders.primaryColor, placeholders.secondaryColor), options);
2497
+ }
2498
+ // fill, outline
2499
+ return renderAbstractNodeToSVGElement(icond.icon, options);
2500
+ }
2501
+ function renderAbstractNodeToSVGElement(node, options) {
2502
+ var targetAttrs = node.tag === 'svg'
2503
+ ? __assign(__assign({}, node.attrs), (options.extraSVGAttrs || {})) : node.attrs;
2504
+ var attrs = Object.keys(targetAttrs).reduce(function (acc, nextKey) {
2505
+ var key = nextKey;
2506
+ var value = targetAttrs[key];
2507
+ var token = "".concat(key, "=\"").concat(value, "\"");
2508
+ acc.push(token);
2509
+ return acc;
2510
+ }, []);
2511
+ var attrsToken = attrs.length ? ' ' + attrs.join(' ') : '';
2512
+ var children = (node.children || [])
2513
+ .map(function (child) { return renderAbstractNodeToSVGElement(child, options); })
2514
+ .join('');
2515
+ if (children && children.length) {
2516
+ return "<".concat(node.tag).concat(attrsToken, ">").concat(children, "</").concat(node.tag, ">");
2517
+ }
2518
+ return "<".concat(node.tag).concat(attrsToken, " />");
2519
+ }
2520
+
2521
+ const lotteryHakunaTicketHistoryCss = ":host{display:block}.lottery-hakuna-ticket-history__container{padding:var(--lottery-hakuna-container-padding, 0);display:flex;flex-direction:var(--lottery-hakuna-container-flex-direction, column);align-items:var(--lottery-hakuna-container-align-items, center)}.lottery-hakuna-ticket-history__title{color:var(--lottery-hakuna-title-color, #000);font-size:var(--lottery-hakuna-title-font-size, 14px);font-style:var(--lottery-hakuna-title-font-style, normal);font-weight:var(--lottery-hakuna-title-font-weight, 700);line-height:var(--lottery-hakuna-title-line-height, normal);text-transform:var(--lottery-hakuna-title-text-transform, uppercase);margin-bottom:var(--lottery-hakuna-title-margin-bottom, 18px)}lottery-hakuna-ticket-history-item{width:var(--lottery-hakuna-ticket-history-item-width, 100%)}lottery-infinite-scroll{max-width:var(--lottery-hakuna-ticket-history-item-max-width, 100%);height:var(--lottery-hakuna-ticket-history-item-height, 500px)}.lottery-hakuna-ticket-history__end-message{width:var(--lottery-hakuna-end-message-width, 100%);text-align:var(--lottery-hakuna-end-message-text-align, center);font-size:var(--lottery-hakuna-end-message-font-size, 14px)}.lottery-hakuna-ticket-history__loading-more{width:var(--lottery-hakuna-loading-more-width, 100%);display:flex;align-items:center;justify-content:center;font-size:var(--lottery-hakuna-loading-more-font-size, 14px);gap:var(--lottery-hakuna-loading-spinner-text-gap, 8px);}.lottery-hakuna-ticket-history__loading-more .loading-spinner{animation:spin var(--lottery-hakuna-loading-spinner-animation-duration, 1s) linear infinite;color:var(--lottery-hakuna-loading-spinner-color, currentColor);}.lottery-hakuna-ticket-history__loading-more .loading-spinner svg{width:var(--lottery-hakuna-loading-spinner-size, 16px);height:var(--lottery-hakuna-loading-spinner-size, 16px)}@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}.lottery-hakuna-ticket-history__error-message{display:flex;align-items:center;justify-content:center;gap:8px;margin-bottom:10px}.lottery-hakuna-ticket-history__error-message svg{width:20px;height:20px}";
2522
+ const LotteryHakunaTicketHistoryStyle0 = lotteryHakunaTicketHistoryCss;
2523
+
2524
+ const loadingOutLinedSvg = renderIconDefinitionToSVGElement(LoadingOutlined$1, {
2525
+ extraSVGAttrs: { width: '14px', height: '14px', fill: 'currentColor' }
2526
+ });
2527
+ const LotteryHakunaTicketHistory = class {
2528
+ constructor(hostRef) {
2529
+ registerInstance(this, hostRef);
2530
+ this.page = 0;
2531
+ this.vendorGameType = GameType.Lottery;
2532
+ this.customStyle = `
2533
+ :host {
2534
+ --lottery-hakuna-ticket-history-item-container-min-width: ${this.minItemWidth}px;
2535
+
2536
+ .lottery-hakuna-ticket-history-item__container {
2537
+ justify-content: flex-start;
2538
+ }
2539
+ }
2540
+
2541
+ .lottery-hakuna-ticket-history-item__container-wrapper {
2542
+ height: 100%;
2543
+ box-sizing: border-box;
2544
+ }
2545
+ .lottery-hakuna-ticket-history-item__container {
2546
+ height: 100%;
2547
+ box-sizing: border-box;
2548
+ }
2549
+ `;
2550
+ this.handleLoadMore = () => {
2551
+ if (!this.isLoading && this.hasMore) {
2552
+ this.getTicketList(this.page + 1);
2553
+ }
2554
+ };
2555
+ this.handleRefresh = () => {
2556
+ if (!this.isRefreshing) {
2557
+ this.page = 1; // Reset page number
2558
+ this.getTicketList(1, true);
2559
+ }
2560
+ };
2561
+ this.renderSkeleton = () => {
2562
+ return (h("lottery-hakuna-ticket-history-item", { "client-styling": this.customStyle + (this.clientStyling || ''), "client-styling-url": this.clientStylingUrl, "mb-source": this.mbSource, translationUrl: this.translationUrl, language: this.language, showSkeleton: true }));
2563
+ };
2564
+ this.renderItem = (ticket) => {
2565
+ return (h("lottery-hakuna-ticket-history-item", { "client-styling": this.customStyle + (this.clientStyling || ''), "client-styling-url": this.clientStylingUrl, "mb-source": this.mbSource, translationUrl: this.translationUrl, language: this.language, key: ticket.id, "history-item-name": ticket.name, "history-item-image-src": ticket.imageSrc, "ticket-id": ticket.id, "total-amount": ticket.totalAmount, date: ticket.date, time: ticket.time, "selected-numbers": ticket.selectedNumbers }));
2566
+ };
2567
+ this.mbSource = undefined;
2568
+ this.clientStyling = undefined;
2569
+ this.clientStylingUrl = undefined;
2570
+ this.language = 'en';
2571
+ this.translationUrl = '';
2572
+ this.endpoint = undefined;
2573
+ this.gameId = undefined;
2574
+ this.playerId = undefined;
2575
+ this.sessionId = '';
2576
+ this.scrollThreshold = '0px 0px 200px 0px';
2577
+ this.scrollItemHeight = 110;
2578
+ this.scrollContainerHeight = 500;
2579
+ this.ticketHistoryTitle = 'YOUR TICKET';
2580
+ this.ticketHistoryItemImageSrc = undefined;
2581
+ this.ticketHistoryItemName = undefined;
2582
+ this.ticketHistoryItemCurrency = 'R';
2583
+ this.listLoadingText = undefined;
2584
+ this.listRefreshingText = undefined;
2585
+ this.listEndText = undefined;
2586
+ this.limit = 10;
2587
+ this.visibleTickets = [];
2588
+ this.hasMore = false;
2589
+ this.isLoading = false;
2590
+ this.isRefreshing = false;
2591
+ this.errorMessage = undefined;
2592
+ this.minItemWidth = 300;
2593
+ this.showSkeleton = true;
2594
+ }
2595
+ handleClientStylingChange(newValue, oldValue) {
2596
+ if (newValue != oldValue) {
2597
+ setClientStyling(this.stylingContainer, this.clientStyling);
2598
+ }
2599
+ }
2600
+ handleClientStylingUrlChange(newValue, oldValue) {
2601
+ if (newValue != oldValue) {
2602
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
2603
+ }
2604
+ }
2605
+ handleMbSourceChange(newValue, oldValue) {
2606
+ if (newValue != oldValue) {
2607
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
2608
+ }
2609
+ }
2610
+ componentWillLoad() {
2611
+ resolveTranslationUrl(this.translationUrl);
2612
+ this.getTicketList(1);
2613
+ }
2614
+ async getTicketList(page, isRefresh = false) {
2615
+ try {
2616
+ if (!this.endpoint || !this.sessionId) {
2617
+ return Promise.reject(new Error('Endpoint and sessionId are required'));
2618
+ }
2619
+ if (page <= 0 || !this.limit)
2620
+ return;
2621
+ if (isRefresh) {
2622
+ this.isRefreshing = true;
2623
+ }
2624
+ else {
2625
+ this.isLoading = true;
2626
+ }
2627
+ const { items, total } = await fetchTicketList({
2628
+ endpoint: this.endpoint,
2629
+ filterData: {
2630
+ offset: (page - 1) * this.limit,
2631
+ limit: this.limit,
2632
+ vendorGameType: this.vendorGameType
2633
+ },
2634
+ sessionId: this.sessionId,
2635
+ meta: {
2636
+ name: this.ticketHistoryItemName,
2637
+ imageSrc: this.ticketHistoryItemImageSrc,
2638
+ currency: this.ticketHistoryItemCurrency
2639
+ }
2640
+ });
2641
+ if (isRefresh) {
2642
+ this.visibleTickets = [...items];
2643
+ }
2644
+ else {
2645
+ this.visibleTickets = [...this.visibleTickets, ...items];
2646
+ }
2647
+ this.hasMore = page < Math.ceil(total / this.limit);
2648
+ this.page = page;
2649
+ this.isLoading = false;
2650
+ this.isRefreshing = false;
2651
+ this.errorMessage = null;
2652
+ }
2653
+ catch (err) {
2654
+ this.isLoading = false;
2655
+ this.isRefreshing = false;
2656
+ if (err.status === 401) {
2657
+ this.errorMessage = translate('unauthorized', this.language);
2658
+ window.postMessage({ type: 'SessionExpired' }, window.location.href);
2659
+ return;
2660
+ }
2661
+ this.errorMessage = translate('failToShowTicketList', this.language);
2662
+ }
2663
+ }
2664
+ componentDidLoad() {
2665
+ if (this.stylingContainer) {
2666
+ if (this.mbSource)
2667
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
2668
+ if (this.clientStyling)
2669
+ setClientStyling(this.stylingContainer, this.clientStyling);
2670
+ if (this.clientStylingUrl)
2671
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
2672
+ }
2673
+ }
2674
+ disconnectedCallback() {
2675
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
2676
+ }
2677
+ renderInfoIcon() {
2678
+ return (h("svg", { width: "45", height: "45", viewBox: "0 0 45 45", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", fill: "currentColor", d: "M22.5 5.625C13.1802 5.625 5.625 13.1802 5.625 22.5C5.625 31.8198 13.1802 39.375 22.5 39.375C31.8198 39.375 39.375 31.8198 39.375 22.5C39.375 13.1802 31.8198 5.625 22.5 5.625ZM1.875 22.5C1.875 11.1091 11.1091 1.875 22.5 1.875C33.8909 1.875 43.125 11.1091 43.125 22.5C43.125 33.8909 33.8909 43.125 22.5 43.125C11.1091 43.125 1.875 33.8909 1.875 22.5ZM22.5 13.125C23.5355 13.125 24.375 13.9645 24.375 15V22.5C24.375 23.5355 23.5355 24.375 22.5 24.375C21.4645 24.375 20.625 23.5355 20.625 22.5V15C20.625 13.9645 21.4645 13.125 22.5 13.125ZM20.625 30C20.625 28.9645 21.4645 28.125 22.5 28.125H22.5188C23.5543 28.125 24.3938 28.9645 24.3938 30C24.3938 31.0355 23.5543 31.875 22.5188 31.875H22.5C21.4645 31.875 20.625 31.0355 20.625 30Z" })));
2679
+ }
2680
+ render() {
2681
+ return (h("div", { key: 'f150fbefd3394af032c600f9b939357bc07ef7db', class: "lottery-hakuna-ticket-history__container", ref: (el) => (this.stylingContainer = el) }, h("div", { key: '67e83eb97dbb358b1d057c1c7948fc8f6e4bc363', class: "lottery-hakuna-ticket-history__title" }, this.ticketHistoryTitle), this.errorMessage && (h("div", { key: 'cae8e46734e5ac71874dbd3d28a861218b5c67eb', class: "lottery-hakuna-ticket-history__error-message" }, this.renderInfoIcon(), h("span", { key: '7c8feec0afda57a6546da5ad9ddc5e35d52683ac' }, this.errorMessage))), h("lottery-infinite-scroll", { key: '828de5559807ea0314d05be5e17ce2340b494a5f', "client-styling": this.clientStyling, "client-styling-url": this.clientStylingUrl, "mb-source": this.mbSource, hasMore: this.hasMore, enableVirtualScroll: true, items: [...this.visibleTickets], estimatedItemHeight: this.scrollItemHeight, minItemWidth: this.minItemWidth, threshold: this.scrollThreshold, gridGap: 10, isLoading: this.isLoading, isRefreshing: this.isRefreshing, onLoadMore: this.handleLoadMore, onRefresh: this.handleRefresh, renderItem: this.renderItem, renderSkeleton: this.showSkeleton ? this.renderSkeleton : null, skeletonCount: this.limit }, h("div", { key: '833b363afc9d355fd6ec1e50a848f759f4f7c1b9', slot: "loading-more", class: "lottery-hakuna-ticket-history__loading-more" }, h("span", { key: '8cf28988956c1710e4adfc6c169761bf3c833e6a', class: "loading-spinner", innerHTML: loadingOutLinedSvg })), h("div", { key: '9faed4a64236ff2a7ae920499fe236aec3393433', slot: "refresh-loading", class: "lottery-hakuna-ticket-history__refresh-loading" }, this.listRefreshingText || translate('releaseToRefresh', this.language)), h("div", { key: 'b61b6aeaadda6e8e0b48d58e2f9ad7f77e57badf', slot: "end-message", class: "lottery-hakuna-ticket-history__end-message" }, this.listEndText || translate('youHaveReachedTheEnd', this.language)))));
2682
+ }
2683
+ static get watchers() { return {
2684
+ "clientStyling": ["handleClientStylingChange"],
2685
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
2686
+ "mbSource": ["handleMbSourceChange"]
2687
+ }; }
2688
+ };
2689
+ LotteryHakunaTicketHistory.style = LotteryHakunaTicketHistoryStyle0;
2690
+
2691
+ export { LotteryHakunaTicketHistory as L, setClientStylingURL as a, setStreamStyling as b, renderIconDefinitionToSVGElement as r, setClientStyling as s };