@everymatrix/lottery-oddsbom-bomb 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 (63) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-68db8b3b.js +1245 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/lottery-oddsbom-bomb-2e7290d5.js +3054 -0
  6. package/dist/cjs/lottery-oddsbom-bomb.cjs.entry.js +10 -0
  7. package/dist/cjs/lottery-oddsbom-bomb.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +12 -0
  9. package/dist/collection/components/lottery-oddsbom-bomb/index.js +1 -0
  10. package/dist/collection/components/lottery-oddsbom-bomb/lottery-oddsbom-bomb.css +289 -0
  11. package/dist/collection/components/lottery-oddsbom-bomb/lottery-oddsbom-bomb.js +292 -0
  12. package/dist/collection/components/static/empty-info.svg +1 -0
  13. package/dist/collection/index.js +1 -0
  14. package/dist/collection/models/index.js +6 -0
  15. package/dist/collection/utils/api.js +68 -0
  16. package/dist/collection/utils/locale.utils.js +66 -0
  17. package/dist/collection/utils/utils.js +140 -0
  18. package/dist/esm/app-globals-0f993ce5.js +3 -0
  19. package/dist/esm/index-f361862f.js +1217 -0
  20. package/dist/esm/index.js +2 -0
  21. package/dist/esm/loader.js +11 -0
  22. package/dist/esm/lottery-oddsbom-bomb-eaeeaf9f.js +3052 -0
  23. package/dist/esm/lottery-oddsbom-bomb.entry.js +2 -0
  24. package/dist/esm/lottery-oddsbom-bomb.js +20 -0
  25. package/dist/index.cjs.js +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/lottery-oddsbom-bomb/app-globals-0f993ce5.js +1 -0
  28. package/dist/lottery-oddsbom-bomb/index-f361862f.js +2 -0
  29. package/dist/lottery-oddsbom-bomb/index.esm.js +1 -0
  30. package/dist/lottery-oddsbom-bomb/lottery-oddsbom-bomb-eaeeaf9f.js +1 -0
  31. package/dist/lottery-oddsbom-bomb/lottery-oddsbom-bomb.entry.js +1 -0
  32. package/dist/lottery-oddsbom-bomb/lottery-oddsbom-bomb.esm.js +1 -0
  33. package/dist/static/empty-info.svg +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-oddsbom-bomb/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/packages/stencil/lottery-oddsbom-bomb/stencil.config.d.ts +2 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/packages/stencil/lottery-oddsbom-bomb/stencil.config.dev.d.ts +2 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/packages/stencil/lottery-oddsbom-bomb/storybook/main.d.ts +3 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/packages/stencil/lottery-oddsbom-bomb/storybook/preview.d.ts +70 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/tools/plugins/index.d.ts +4 -0
  44. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  45. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  46. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  47. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-oddsbom-bomb/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  48. package/dist/types/components/lottery-oddsbom-bomb/index.d.ts +1 -0
  49. package/dist/types/components/lottery-oddsbom-bomb/lottery-oddsbom-bomb.d.ts +54 -0
  50. package/dist/types/components.d.ts +103 -0
  51. package/dist/types/index.d.ts +1 -0
  52. package/dist/types/models/index.d.ts +75 -0
  53. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  54. package/dist/types/utils/api.d.ts +30 -0
  55. package/dist/types/utils/locale.utils.d.ts +2 -0
  56. package/dist/types/utils/utils.d.ts +9 -0
  57. package/loader/cdn.js +1 -0
  58. package/loader/index.cjs.js +1 -0
  59. package/loader/index.d.ts +24 -0
  60. package/loader/index.es2017.js +1 -0
  61. package/loader/index.js +2 -0
  62. package/loader/package.json +11 -0
  63. package/package.json +27 -0
@@ -0,0 +1,3052 @@
1
+ import { h, r as registerInstance, c as createEvent, g as getAssetPath } from './index-f361862f.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 Bomb;
63
+ (function (Bomb) {
64
+ Bomb["Football"] = "Football";
65
+ Bomb["IceHockey"] = "IceHockey";
66
+ Bomb["Mixed"] = "Mixed";
67
+ })(Bomb || (Bomb = {}));
68
+
69
+ function _typeof(o) {
70
+ "@babel/helpers - typeof";
71
+
72
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
73
+ return typeof o;
74
+ } : function (o) {
75
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
76
+ }, _typeof(o);
77
+ }
78
+
79
+ function toInteger(dirtyNumber) {
80
+ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
81
+ return NaN;
82
+ }
83
+ var number = Number(dirtyNumber);
84
+ if (isNaN(number)) {
85
+ return number;
86
+ }
87
+ return number < 0 ? Math.ceil(number) : Math.floor(number);
88
+ }
89
+
90
+ function requiredArgs(required, args) {
91
+ if (args.length < required) {
92
+ throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
93
+ }
94
+ }
95
+
96
+ /**
97
+ * @name toDate
98
+ * @category Common Helpers
99
+ * @summary Convert the given argument to an instance of Date.
100
+ *
101
+ * @description
102
+ * Convert the given argument to an instance of Date.
103
+ *
104
+ * If the argument is an instance of Date, the function returns its clone.
105
+ *
106
+ * If the argument is a number, it is treated as a timestamp.
107
+ *
108
+ * If the argument is none of the above, the function returns Invalid Date.
109
+ *
110
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
111
+ *
112
+ * @param {Date|Number} argument - the value to convert
113
+ * @returns {Date} the parsed date in the local time zone
114
+ * @throws {TypeError} 1 argument required
115
+ *
116
+ * @example
117
+ * // Clone the date:
118
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
119
+ * //=> Tue Feb 11 2014 11:30:30
120
+ *
121
+ * @example
122
+ * // Convert the timestamp to date:
123
+ * const result = toDate(1392098430000)
124
+ * //=> Tue Feb 11 2014 11:30:30
125
+ */
126
+ function toDate(argument) {
127
+ requiredArgs(1, arguments);
128
+ var argStr = Object.prototype.toString.call(argument);
129
+
130
+ // Clone the date
131
+ if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
132
+ // Prevent the date to lose the milliseconds when passed to new Date() in IE10
133
+ return new Date(argument.getTime());
134
+ } else if (typeof argument === 'number' || argStr === '[object Number]') {
135
+ return new Date(argument);
136
+ } else {
137
+ if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
138
+ // eslint-disable-next-line no-console
139
+ 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");
140
+ // eslint-disable-next-line no-console
141
+ console.warn(new Error().stack);
142
+ }
143
+ return new Date(NaN);
144
+ }
145
+ }
146
+
147
+ /**
148
+ * @name addDays
149
+ * @category Day Helpers
150
+ * @summary Add the specified number of days to the given date.
151
+ *
152
+ * @description
153
+ * Add the specified number of days to the given date.
154
+ *
155
+ * @param {Date|Number} date - the date to be changed
156
+ * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
157
+ * @returns {Date} - the new date with the days added
158
+ * @throws {TypeError} - 2 arguments required
159
+ *
160
+ * @example
161
+ * // Add 10 days to 1 September 2014:
162
+ * const result = addDays(new Date(2014, 8, 1), 10)
163
+ * //=> Thu Sep 11 2014 00:00:00
164
+ */
165
+ function addDays(dirtyDate, dirtyAmount) {
166
+ requiredArgs(2, arguments);
167
+ var date = toDate(dirtyDate);
168
+ var amount = toInteger(dirtyAmount);
169
+ if (isNaN(amount)) {
170
+ return new Date(NaN);
171
+ }
172
+ if (!amount) {
173
+ // If 0 days, no-op to avoid changing times in the hour before end of DST
174
+ return date;
175
+ }
176
+ date.setDate(date.getDate() + amount);
177
+ return date;
178
+ }
179
+
180
+ /**
181
+ * @name addMilliseconds
182
+ * @category Millisecond Helpers
183
+ * @summary Add the specified number of milliseconds to the given date.
184
+ *
185
+ * @description
186
+ * Add the specified number of milliseconds to the given date.
187
+ *
188
+ * @param {Date|Number} date - the date to be changed
189
+ * @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`.
190
+ * @returns {Date} the new date with the milliseconds added
191
+ * @throws {TypeError} 2 arguments required
192
+ *
193
+ * @example
194
+ * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
195
+ * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
196
+ * //=> Thu Jul 10 2014 12:45:30.750
197
+ */
198
+ function addMilliseconds(dirtyDate, dirtyAmount) {
199
+ requiredArgs(2, arguments);
200
+ var timestamp = toDate(dirtyDate).getTime();
201
+ var amount = toInteger(dirtyAmount);
202
+ return new Date(timestamp + amount);
203
+ }
204
+
205
+ var defaultOptions = {};
206
+ function getDefaultOptions() {
207
+ return defaultOptions;
208
+ }
209
+
210
+ /**
211
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
212
+ * They usually appear for dates that denote time before the timezones were introduced
213
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
214
+ * and GMT+01:00:00 after that date)
215
+ *
216
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
217
+ * which would lead to incorrect calculations.
218
+ *
219
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
220
+ */
221
+ function getTimezoneOffsetInMilliseconds(date) {
222
+ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
223
+ utcDate.setUTCFullYear(date.getFullYear());
224
+ return date.getTime() - utcDate.getTime();
225
+ }
226
+
227
+ /**
228
+ * @name startOfDay
229
+ * @category Day Helpers
230
+ * @summary Return the start of a day for the given date.
231
+ *
232
+ * @description
233
+ * Return the start of a day for the given date.
234
+ * The result will be in the local timezone.
235
+ *
236
+ * @param {Date|Number} date - the original date
237
+ * @returns {Date} the start of a day
238
+ * @throws {TypeError} 1 argument required
239
+ *
240
+ * @example
241
+ * // The start of a day for 2 September 2014 11:55:00:
242
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
243
+ * //=> Tue Sep 02 2014 00:00:00
244
+ */
245
+ function startOfDay(dirtyDate) {
246
+ requiredArgs(1, arguments);
247
+ var date = toDate(dirtyDate);
248
+ date.setHours(0, 0, 0, 0);
249
+ return date;
250
+ }
251
+
252
+ /**
253
+ * Days in 1 week.
254
+ *
255
+ * @name daysInWeek
256
+ * @constant
257
+ * @type {number}
258
+ * @default
259
+ */
260
+
261
+ /**
262
+ * Milliseconds in 1 minute
263
+ *
264
+ * @name millisecondsInMinute
265
+ * @constant
266
+ * @type {number}
267
+ * @default
268
+ */
269
+ var millisecondsInMinute = 60000;
270
+
271
+ /**
272
+ * Milliseconds in 1 hour
273
+ *
274
+ * @name millisecondsInHour
275
+ * @constant
276
+ * @type {number}
277
+ * @default
278
+ */
279
+ var millisecondsInHour = 3600000;
280
+
281
+ /**
282
+ * @name isSameDay
283
+ * @category Day Helpers
284
+ * @summary Are the given dates in the same day (and year and month)?
285
+ *
286
+ * @description
287
+ * Are the given dates in the same day (and year and month)?
288
+ *
289
+ * @param {Date|Number} dateLeft - the first date to check
290
+ * @param {Date|Number} dateRight - the second date to check
291
+ * @returns {Boolean} the dates are in the same day (and year and month)
292
+ * @throws {TypeError} 2 arguments required
293
+ *
294
+ * @example
295
+ * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
296
+ * const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
297
+ * //=> true
298
+ *
299
+ * @example
300
+ * // Are 4 September and 4 October in the same day?
301
+ * const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
302
+ * //=> false
303
+ *
304
+ * @example
305
+ * // Are 4 September, 2014 and 4 September, 2015 in the same day?
306
+ * const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
307
+ * //=> false
308
+ */
309
+ function isSameDay(dirtyDateLeft, dirtyDateRight) {
310
+ requiredArgs(2, arguments);
311
+ var dateLeftStartOfDay = startOfDay(dirtyDateLeft);
312
+ var dateRightStartOfDay = startOfDay(dirtyDateRight);
313
+ return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime();
314
+ }
315
+
316
+ /**
317
+ * @name isDate
318
+ * @category Common Helpers
319
+ * @summary Is the given value a date?
320
+ *
321
+ * @description
322
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
323
+ *
324
+ * @param {*} value - the value to check
325
+ * @returns {boolean} true if the given value is a date
326
+ * @throws {TypeError} 1 arguments required
327
+ *
328
+ * @example
329
+ * // For a valid date:
330
+ * const result = isDate(new Date())
331
+ * //=> true
332
+ *
333
+ * @example
334
+ * // For an invalid date:
335
+ * const result = isDate(new Date(NaN))
336
+ * //=> true
337
+ *
338
+ * @example
339
+ * // For some value:
340
+ * const result = isDate('2014-02-31')
341
+ * //=> false
342
+ *
343
+ * @example
344
+ * // For an object:
345
+ * const result = isDate({})
346
+ * //=> false
347
+ */
348
+ function isDate(value) {
349
+ requiredArgs(1, arguments);
350
+ return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
351
+ }
352
+
353
+ /**
354
+ * @name isValid
355
+ * @category Common Helpers
356
+ * @summary Is the given date valid?
357
+ *
358
+ * @description
359
+ * Returns false if argument is Invalid Date and true otherwise.
360
+ * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
361
+ * Invalid Date is a Date, whose time value is NaN.
362
+ *
363
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
364
+ *
365
+ * @param {*} date - the date to check
366
+ * @returns {Boolean} the date is valid
367
+ * @throws {TypeError} 1 argument required
368
+ *
369
+ * @example
370
+ * // For the valid date:
371
+ * const result = isValid(new Date(2014, 1, 31))
372
+ * //=> true
373
+ *
374
+ * @example
375
+ * // For the value, convertable into a date:
376
+ * const result = isValid(1393804800000)
377
+ * //=> true
378
+ *
379
+ * @example
380
+ * // For the invalid date:
381
+ * const result = isValid(new Date(''))
382
+ * //=> false
383
+ */
384
+ function isValid(dirtyDate) {
385
+ requiredArgs(1, arguments);
386
+ if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
387
+ return false;
388
+ }
389
+ var date = toDate(dirtyDate);
390
+ return !isNaN(Number(date));
391
+ }
392
+
393
+ /**
394
+ * @name subMilliseconds
395
+ * @category Millisecond Helpers
396
+ * @summary Subtract the specified number of milliseconds from the given date.
397
+ *
398
+ * @description
399
+ * Subtract the specified number of milliseconds from the given date.
400
+ *
401
+ * @param {Date|Number} date - the date to be changed
402
+ * @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`.
403
+ * @returns {Date} the new date with the milliseconds subtracted
404
+ * @throws {TypeError} 2 arguments required
405
+ *
406
+ * @example
407
+ * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
408
+ * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
409
+ * //=> Thu Jul 10 2014 12:45:29.250
410
+ */
411
+ function subMilliseconds(dirtyDate, dirtyAmount) {
412
+ requiredArgs(2, arguments);
413
+ var amount = toInteger(dirtyAmount);
414
+ return addMilliseconds(dirtyDate, -amount);
415
+ }
416
+
417
+ var MILLISECONDS_IN_DAY = 86400000;
418
+ function getUTCDayOfYear(dirtyDate) {
419
+ requiredArgs(1, arguments);
420
+ var date = toDate(dirtyDate);
421
+ var timestamp = date.getTime();
422
+ date.setUTCMonth(0, 1);
423
+ date.setUTCHours(0, 0, 0, 0);
424
+ var startOfYearTimestamp = date.getTime();
425
+ var difference = timestamp - startOfYearTimestamp;
426
+ return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
427
+ }
428
+
429
+ function startOfUTCISOWeek(dirtyDate) {
430
+ requiredArgs(1, arguments);
431
+ var weekStartsOn = 1;
432
+ var date = toDate(dirtyDate);
433
+ var day = date.getUTCDay();
434
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
435
+ date.setUTCDate(date.getUTCDate() - diff);
436
+ date.setUTCHours(0, 0, 0, 0);
437
+ return date;
438
+ }
439
+
440
+ function getUTCISOWeekYear(dirtyDate) {
441
+ requiredArgs(1, arguments);
442
+ var date = toDate(dirtyDate);
443
+ var year = date.getUTCFullYear();
444
+ var fourthOfJanuaryOfNextYear = new Date(0);
445
+ fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
446
+ fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
447
+ var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
448
+ var fourthOfJanuaryOfThisYear = new Date(0);
449
+ fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
450
+ fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
451
+ var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
452
+ if (date.getTime() >= startOfNextYear.getTime()) {
453
+ return year + 1;
454
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
455
+ return year;
456
+ } else {
457
+ return year - 1;
458
+ }
459
+ }
460
+
461
+ function startOfUTCISOWeekYear(dirtyDate) {
462
+ requiredArgs(1, arguments);
463
+ var year = getUTCISOWeekYear(dirtyDate);
464
+ var fourthOfJanuary = new Date(0);
465
+ fourthOfJanuary.setUTCFullYear(year, 0, 4);
466
+ fourthOfJanuary.setUTCHours(0, 0, 0, 0);
467
+ var date = startOfUTCISOWeek(fourthOfJanuary);
468
+ return date;
469
+ }
470
+
471
+ var MILLISECONDS_IN_WEEK$1 = 604800000;
472
+ function getUTCISOWeek(dirtyDate) {
473
+ requiredArgs(1, arguments);
474
+ var date = toDate(dirtyDate);
475
+ var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
476
+
477
+ // Round the number of days to the nearest integer
478
+ // because the number of milliseconds in a week is not constant
479
+ // (e.g. it's different in the week of the daylight saving time clock shift)
480
+ return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
481
+ }
482
+
483
+ function startOfUTCWeek(dirtyDate, options) {
484
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
485
+ requiredArgs(1, arguments);
486
+ var defaultOptions = getDefaultOptions();
487
+ 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);
488
+
489
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
490
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
491
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
492
+ }
493
+ var date = toDate(dirtyDate);
494
+ var day = date.getUTCDay();
495
+ var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
496
+ date.setUTCDate(date.getUTCDate() - diff);
497
+ date.setUTCHours(0, 0, 0, 0);
498
+ return date;
499
+ }
500
+
501
+ function getUTCWeekYear(dirtyDate, options) {
502
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
503
+ requiredArgs(1, arguments);
504
+ var date = toDate(dirtyDate);
505
+ var year = date.getUTCFullYear();
506
+ var defaultOptions = getDefaultOptions();
507
+ 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);
508
+
509
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
510
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
511
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
512
+ }
513
+ var firstWeekOfNextYear = new Date(0);
514
+ firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
515
+ firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
516
+ var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
517
+ var firstWeekOfThisYear = new Date(0);
518
+ firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
519
+ firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
520
+ var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
521
+ if (date.getTime() >= startOfNextYear.getTime()) {
522
+ return year + 1;
523
+ } else if (date.getTime() >= startOfThisYear.getTime()) {
524
+ return year;
525
+ } else {
526
+ return year - 1;
527
+ }
528
+ }
529
+
530
+ function startOfUTCWeekYear(dirtyDate, options) {
531
+ var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
532
+ requiredArgs(1, arguments);
533
+ var defaultOptions = getDefaultOptions();
534
+ 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);
535
+ var year = getUTCWeekYear(dirtyDate, options);
536
+ var firstWeek = new Date(0);
537
+ firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
538
+ firstWeek.setUTCHours(0, 0, 0, 0);
539
+ var date = startOfUTCWeek(firstWeek, options);
540
+ return date;
541
+ }
542
+
543
+ var MILLISECONDS_IN_WEEK = 604800000;
544
+ function getUTCWeek(dirtyDate, options) {
545
+ requiredArgs(1, arguments);
546
+ var date = toDate(dirtyDate);
547
+ var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
548
+
549
+ // Round the number of days to the nearest integer
550
+ // because the number of milliseconds in a week is not constant
551
+ // (e.g. it's different in the week of the daylight saving time clock shift)
552
+ return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
553
+ }
554
+
555
+ function addLeadingZeros(number, targetLength) {
556
+ var sign = number < 0 ? '-' : '';
557
+ var output = Math.abs(number).toString();
558
+ while (output.length < targetLength) {
559
+ output = '0' + output;
560
+ }
561
+ return sign + output;
562
+ }
563
+
564
+ /*
565
+ * | | Unit | | Unit |
566
+ * |-----|--------------------------------|-----|--------------------------------|
567
+ * | a | AM, PM | A* | |
568
+ * | d | Day of month | D | |
569
+ * | h | Hour [1-12] | H | Hour [0-23] |
570
+ * | m | Minute | M | Month |
571
+ * | s | Second | S | Fraction of second |
572
+ * | y | Year (abs) | Y | |
573
+ *
574
+ * Letters marked by * are not implemented but reserved by Unicode standard.
575
+ */
576
+ var formatters$2 = {
577
+ // Year
578
+ y: function y(date, token) {
579
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
580
+ // | Year | y | yy | yyy | yyyy | yyyyy |
581
+ // |----------|-------|----|-------|-------|-------|
582
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
583
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
584
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
585
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
586
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
587
+
588
+ var signedYear = date.getUTCFullYear();
589
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
590
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
591
+ return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
592
+ },
593
+ // Month
594
+ M: function M(date, token) {
595
+ var month = date.getUTCMonth();
596
+ return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
597
+ },
598
+ // Day of the month
599
+ d: function d(date, token) {
600
+ return addLeadingZeros(date.getUTCDate(), token.length);
601
+ },
602
+ // AM or PM
603
+ a: function a(date, token) {
604
+ var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
605
+ switch (token) {
606
+ case 'a':
607
+ case 'aa':
608
+ return dayPeriodEnumValue.toUpperCase();
609
+ case 'aaa':
610
+ return dayPeriodEnumValue;
611
+ case 'aaaaa':
612
+ return dayPeriodEnumValue[0];
613
+ case 'aaaa':
614
+ default:
615
+ return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
616
+ }
617
+ },
618
+ // Hour [1-12]
619
+ h: function h(date, token) {
620
+ return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
621
+ },
622
+ // Hour [0-23]
623
+ H: function H(date, token) {
624
+ return addLeadingZeros(date.getUTCHours(), token.length);
625
+ },
626
+ // Minute
627
+ m: function m(date, token) {
628
+ return addLeadingZeros(date.getUTCMinutes(), token.length);
629
+ },
630
+ // Second
631
+ s: function s(date, token) {
632
+ return addLeadingZeros(date.getUTCSeconds(), token.length);
633
+ },
634
+ // Fraction of second
635
+ S: function S(date, token) {
636
+ var numberOfDigits = token.length;
637
+ var milliseconds = date.getUTCMilliseconds();
638
+ var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
639
+ return addLeadingZeros(fractionalSeconds, token.length);
640
+ }
641
+ };
642
+ const formatters$3 = formatters$2;
643
+
644
+ var dayPeriodEnum = {
645
+ am: 'am',
646
+ pm: 'pm',
647
+ midnight: 'midnight',
648
+ noon: 'noon',
649
+ morning: 'morning',
650
+ afternoon: 'afternoon',
651
+ evening: 'evening',
652
+ night: 'night'
653
+ };
654
+ /*
655
+ * | | Unit | | Unit |
656
+ * |-----|--------------------------------|-----|--------------------------------|
657
+ * | a | AM, PM | A* | Milliseconds in day |
658
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
659
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
660
+ * | d | Day of month | D | Day of year |
661
+ * | e | Local day of week | E | Day of week |
662
+ * | f | | F* | Day of week in month |
663
+ * | g* | Modified Julian day | G | Era |
664
+ * | h | Hour [1-12] | H | Hour [0-23] |
665
+ * | i! | ISO day of week | I! | ISO week of year |
666
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
667
+ * | k | Hour [1-24] | K | Hour [0-11] |
668
+ * | l* | (deprecated) | L | Stand-alone month |
669
+ * | m | Minute | M | Month |
670
+ * | n | | N | |
671
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
672
+ * | p! | Long localized time | P! | Long localized date |
673
+ * | q | Stand-alone quarter | Q | Quarter |
674
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
675
+ * | s | Second | S | Fraction of second |
676
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
677
+ * | u | Extended year | U* | Cyclic year |
678
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
679
+ * | w | Local week of year | W* | Week of month |
680
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
681
+ * | y | Year (abs) | Y | Local week-numbering year |
682
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
683
+ *
684
+ * Letters marked by * are not implemented but reserved by Unicode standard.
685
+ *
686
+ * Letters marked by ! are non-standard, but implemented by date-fns:
687
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
688
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
689
+ * i.e. 7 for Sunday, 1 for Monday, etc.
690
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
691
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
692
+ * `R` is supposed to be used in conjunction with `I` and `i`
693
+ * for universal ISO week-numbering date, whereas
694
+ * `Y` is supposed to be used in conjunction with `w` and `e`
695
+ * for week-numbering date specific to the locale.
696
+ * - `P` is long localized date format
697
+ * - `p` is long localized time format
698
+ */
699
+
700
+ var formatters = {
701
+ // Era
702
+ G: function G(date, token, localize) {
703
+ var era = date.getUTCFullYear() > 0 ? 1 : 0;
704
+ switch (token) {
705
+ // AD, BC
706
+ case 'G':
707
+ case 'GG':
708
+ case 'GGG':
709
+ return localize.era(era, {
710
+ width: 'abbreviated'
711
+ });
712
+ // A, B
713
+ case 'GGGGG':
714
+ return localize.era(era, {
715
+ width: 'narrow'
716
+ });
717
+ // Anno Domini, Before Christ
718
+ case 'GGGG':
719
+ default:
720
+ return localize.era(era, {
721
+ width: 'wide'
722
+ });
723
+ }
724
+ },
725
+ // Year
726
+ y: function y(date, token, localize) {
727
+ // Ordinal number
728
+ if (token === 'yo') {
729
+ var signedYear = date.getUTCFullYear();
730
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
731
+ var year = signedYear > 0 ? signedYear : 1 - signedYear;
732
+ return localize.ordinalNumber(year, {
733
+ unit: 'year'
734
+ });
735
+ }
736
+ return formatters$3.y(date, token);
737
+ },
738
+ // Local week-numbering year
739
+ Y: function Y(date, token, localize, options) {
740
+ var signedWeekYear = getUTCWeekYear(date, options);
741
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
742
+ var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
743
+
744
+ // Two digit year
745
+ if (token === 'YY') {
746
+ var twoDigitYear = weekYear % 100;
747
+ return addLeadingZeros(twoDigitYear, 2);
748
+ }
749
+
750
+ // Ordinal number
751
+ if (token === 'Yo') {
752
+ return localize.ordinalNumber(weekYear, {
753
+ unit: 'year'
754
+ });
755
+ }
756
+
757
+ // Padding
758
+ return addLeadingZeros(weekYear, token.length);
759
+ },
760
+ // ISO week-numbering year
761
+ R: function R(date, token) {
762
+ var isoWeekYear = getUTCISOWeekYear(date);
763
+
764
+ // Padding
765
+ return addLeadingZeros(isoWeekYear, token.length);
766
+ },
767
+ // Extended year. This is a single number designating the year of this calendar system.
768
+ // The main difference between `y` and `u` localizers are B.C. years:
769
+ // | Year | `y` | `u` |
770
+ // |------|-----|-----|
771
+ // | AC 1 | 1 | 1 |
772
+ // | BC 1 | 1 | 0 |
773
+ // | BC 2 | 2 | -1 |
774
+ // Also `yy` always returns the last two digits of a year,
775
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
776
+ u: function u(date, token) {
777
+ var year = date.getUTCFullYear();
778
+ return addLeadingZeros(year, token.length);
779
+ },
780
+ // Quarter
781
+ Q: function Q(date, token, localize) {
782
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
783
+ switch (token) {
784
+ // 1, 2, 3, 4
785
+ case 'Q':
786
+ return String(quarter);
787
+ // 01, 02, 03, 04
788
+ case 'QQ':
789
+ return addLeadingZeros(quarter, 2);
790
+ // 1st, 2nd, 3rd, 4th
791
+ case 'Qo':
792
+ return localize.ordinalNumber(quarter, {
793
+ unit: 'quarter'
794
+ });
795
+ // Q1, Q2, Q3, Q4
796
+ case 'QQQ':
797
+ return localize.quarter(quarter, {
798
+ width: 'abbreviated',
799
+ context: 'formatting'
800
+ });
801
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
802
+ case 'QQQQQ':
803
+ return localize.quarter(quarter, {
804
+ width: 'narrow',
805
+ context: 'formatting'
806
+ });
807
+ // 1st quarter, 2nd quarter, ...
808
+ case 'QQQQ':
809
+ default:
810
+ return localize.quarter(quarter, {
811
+ width: 'wide',
812
+ context: 'formatting'
813
+ });
814
+ }
815
+ },
816
+ // Stand-alone quarter
817
+ q: function q(date, token, localize) {
818
+ var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
819
+ switch (token) {
820
+ // 1, 2, 3, 4
821
+ case 'q':
822
+ return String(quarter);
823
+ // 01, 02, 03, 04
824
+ case 'qq':
825
+ return addLeadingZeros(quarter, 2);
826
+ // 1st, 2nd, 3rd, 4th
827
+ case 'qo':
828
+ return localize.ordinalNumber(quarter, {
829
+ unit: 'quarter'
830
+ });
831
+ // Q1, Q2, Q3, Q4
832
+ case 'qqq':
833
+ return localize.quarter(quarter, {
834
+ width: 'abbreviated',
835
+ context: 'standalone'
836
+ });
837
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
838
+ case 'qqqqq':
839
+ return localize.quarter(quarter, {
840
+ width: 'narrow',
841
+ context: 'standalone'
842
+ });
843
+ // 1st quarter, 2nd quarter, ...
844
+ case 'qqqq':
845
+ default:
846
+ return localize.quarter(quarter, {
847
+ width: 'wide',
848
+ context: 'standalone'
849
+ });
850
+ }
851
+ },
852
+ // Month
853
+ M: function M(date, token, localize) {
854
+ var month = date.getUTCMonth();
855
+ switch (token) {
856
+ case 'M':
857
+ case 'MM':
858
+ return formatters$3.M(date, token);
859
+ // 1st, 2nd, ..., 12th
860
+ case 'Mo':
861
+ return localize.ordinalNumber(month + 1, {
862
+ unit: 'month'
863
+ });
864
+ // Jan, Feb, ..., Dec
865
+ case 'MMM':
866
+ return localize.month(month, {
867
+ width: 'abbreviated',
868
+ context: 'formatting'
869
+ });
870
+ // J, F, ..., D
871
+ case 'MMMMM':
872
+ return localize.month(month, {
873
+ width: 'narrow',
874
+ context: 'formatting'
875
+ });
876
+ // January, February, ..., December
877
+ case 'MMMM':
878
+ default:
879
+ return localize.month(month, {
880
+ width: 'wide',
881
+ context: 'formatting'
882
+ });
883
+ }
884
+ },
885
+ // Stand-alone month
886
+ L: function L(date, token, localize) {
887
+ var month = date.getUTCMonth();
888
+ switch (token) {
889
+ // 1, 2, ..., 12
890
+ case 'L':
891
+ return String(month + 1);
892
+ // 01, 02, ..., 12
893
+ case 'LL':
894
+ return addLeadingZeros(month + 1, 2);
895
+ // 1st, 2nd, ..., 12th
896
+ case 'Lo':
897
+ return localize.ordinalNumber(month + 1, {
898
+ unit: 'month'
899
+ });
900
+ // Jan, Feb, ..., Dec
901
+ case 'LLL':
902
+ return localize.month(month, {
903
+ width: 'abbreviated',
904
+ context: 'standalone'
905
+ });
906
+ // J, F, ..., D
907
+ case 'LLLLL':
908
+ return localize.month(month, {
909
+ width: 'narrow',
910
+ context: 'standalone'
911
+ });
912
+ // January, February, ..., December
913
+ case 'LLLL':
914
+ default:
915
+ return localize.month(month, {
916
+ width: 'wide',
917
+ context: 'standalone'
918
+ });
919
+ }
920
+ },
921
+ // Local week of year
922
+ w: function w(date, token, localize, options) {
923
+ var week = getUTCWeek(date, options);
924
+ if (token === 'wo') {
925
+ return localize.ordinalNumber(week, {
926
+ unit: 'week'
927
+ });
928
+ }
929
+ return addLeadingZeros(week, token.length);
930
+ },
931
+ // ISO week of year
932
+ I: function I(date, token, localize) {
933
+ var isoWeek = getUTCISOWeek(date);
934
+ if (token === 'Io') {
935
+ return localize.ordinalNumber(isoWeek, {
936
+ unit: 'week'
937
+ });
938
+ }
939
+ return addLeadingZeros(isoWeek, token.length);
940
+ },
941
+ // Day of the month
942
+ d: function d(date, token, localize) {
943
+ if (token === 'do') {
944
+ return localize.ordinalNumber(date.getUTCDate(), {
945
+ unit: 'date'
946
+ });
947
+ }
948
+ return formatters$3.d(date, token);
949
+ },
950
+ // Day of year
951
+ D: function D(date, token, localize) {
952
+ var dayOfYear = getUTCDayOfYear(date);
953
+ if (token === 'Do') {
954
+ return localize.ordinalNumber(dayOfYear, {
955
+ unit: 'dayOfYear'
956
+ });
957
+ }
958
+ return addLeadingZeros(dayOfYear, token.length);
959
+ },
960
+ // Day of week
961
+ E: function E(date, token, localize) {
962
+ var dayOfWeek = date.getUTCDay();
963
+ switch (token) {
964
+ // Tue
965
+ case 'E':
966
+ case 'EE':
967
+ case 'EEE':
968
+ return localize.day(dayOfWeek, {
969
+ width: 'abbreviated',
970
+ context: 'formatting'
971
+ });
972
+ // T
973
+ case 'EEEEE':
974
+ return localize.day(dayOfWeek, {
975
+ width: 'narrow',
976
+ context: 'formatting'
977
+ });
978
+ // Tu
979
+ case 'EEEEEE':
980
+ return localize.day(dayOfWeek, {
981
+ width: 'short',
982
+ context: 'formatting'
983
+ });
984
+ // Tuesday
985
+ case 'EEEE':
986
+ default:
987
+ return localize.day(dayOfWeek, {
988
+ width: 'wide',
989
+ context: 'formatting'
990
+ });
991
+ }
992
+ },
993
+ // Local day of week
994
+ e: function e(date, token, localize, options) {
995
+ var dayOfWeek = date.getUTCDay();
996
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
997
+ switch (token) {
998
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
999
+ case 'e':
1000
+ return String(localDayOfWeek);
1001
+ // Padded numerical value
1002
+ case 'ee':
1003
+ return addLeadingZeros(localDayOfWeek, 2);
1004
+ // 1st, 2nd, ..., 7th
1005
+ case 'eo':
1006
+ return localize.ordinalNumber(localDayOfWeek, {
1007
+ unit: 'day'
1008
+ });
1009
+ case 'eee':
1010
+ return localize.day(dayOfWeek, {
1011
+ width: 'abbreviated',
1012
+ context: 'formatting'
1013
+ });
1014
+ // T
1015
+ case 'eeeee':
1016
+ return localize.day(dayOfWeek, {
1017
+ width: 'narrow',
1018
+ context: 'formatting'
1019
+ });
1020
+ // Tu
1021
+ case 'eeeeee':
1022
+ return localize.day(dayOfWeek, {
1023
+ width: 'short',
1024
+ context: 'formatting'
1025
+ });
1026
+ // Tuesday
1027
+ case 'eeee':
1028
+ default:
1029
+ return localize.day(dayOfWeek, {
1030
+ width: 'wide',
1031
+ context: 'formatting'
1032
+ });
1033
+ }
1034
+ },
1035
+ // Stand-alone local day of week
1036
+ c: function c(date, token, localize, options) {
1037
+ var dayOfWeek = date.getUTCDay();
1038
+ var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1039
+ switch (token) {
1040
+ // Numerical value (same as in `e`)
1041
+ case 'c':
1042
+ return String(localDayOfWeek);
1043
+ // Padded numerical value
1044
+ case 'cc':
1045
+ return addLeadingZeros(localDayOfWeek, token.length);
1046
+ // 1st, 2nd, ..., 7th
1047
+ case 'co':
1048
+ return localize.ordinalNumber(localDayOfWeek, {
1049
+ unit: 'day'
1050
+ });
1051
+ case 'ccc':
1052
+ return localize.day(dayOfWeek, {
1053
+ width: 'abbreviated',
1054
+ context: 'standalone'
1055
+ });
1056
+ // T
1057
+ case 'ccccc':
1058
+ return localize.day(dayOfWeek, {
1059
+ width: 'narrow',
1060
+ context: 'standalone'
1061
+ });
1062
+ // Tu
1063
+ case 'cccccc':
1064
+ return localize.day(dayOfWeek, {
1065
+ width: 'short',
1066
+ context: 'standalone'
1067
+ });
1068
+ // Tuesday
1069
+ case 'cccc':
1070
+ default:
1071
+ return localize.day(dayOfWeek, {
1072
+ width: 'wide',
1073
+ context: 'standalone'
1074
+ });
1075
+ }
1076
+ },
1077
+ // ISO day of week
1078
+ i: function i(date, token, localize) {
1079
+ var dayOfWeek = date.getUTCDay();
1080
+ var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1081
+ switch (token) {
1082
+ // 2
1083
+ case 'i':
1084
+ return String(isoDayOfWeek);
1085
+ // 02
1086
+ case 'ii':
1087
+ return addLeadingZeros(isoDayOfWeek, token.length);
1088
+ // 2nd
1089
+ case 'io':
1090
+ return localize.ordinalNumber(isoDayOfWeek, {
1091
+ unit: 'day'
1092
+ });
1093
+ // Tue
1094
+ case 'iii':
1095
+ return localize.day(dayOfWeek, {
1096
+ width: 'abbreviated',
1097
+ context: 'formatting'
1098
+ });
1099
+ // T
1100
+ case 'iiiii':
1101
+ return localize.day(dayOfWeek, {
1102
+ width: 'narrow',
1103
+ context: 'formatting'
1104
+ });
1105
+ // Tu
1106
+ case 'iiiiii':
1107
+ return localize.day(dayOfWeek, {
1108
+ width: 'short',
1109
+ context: 'formatting'
1110
+ });
1111
+ // Tuesday
1112
+ case 'iiii':
1113
+ default:
1114
+ return localize.day(dayOfWeek, {
1115
+ width: 'wide',
1116
+ context: 'formatting'
1117
+ });
1118
+ }
1119
+ },
1120
+ // AM or PM
1121
+ a: function a(date, token, localize) {
1122
+ var hours = date.getUTCHours();
1123
+ var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1124
+ switch (token) {
1125
+ case 'a':
1126
+ case 'aa':
1127
+ return localize.dayPeriod(dayPeriodEnumValue, {
1128
+ width: 'abbreviated',
1129
+ context: 'formatting'
1130
+ });
1131
+ case 'aaa':
1132
+ return localize.dayPeriod(dayPeriodEnumValue, {
1133
+ width: 'abbreviated',
1134
+ context: 'formatting'
1135
+ }).toLowerCase();
1136
+ case 'aaaaa':
1137
+ return localize.dayPeriod(dayPeriodEnumValue, {
1138
+ width: 'narrow',
1139
+ context: 'formatting'
1140
+ });
1141
+ case 'aaaa':
1142
+ default:
1143
+ return localize.dayPeriod(dayPeriodEnumValue, {
1144
+ width: 'wide',
1145
+ context: 'formatting'
1146
+ });
1147
+ }
1148
+ },
1149
+ // AM, PM, midnight, noon
1150
+ b: function b(date, token, localize) {
1151
+ var hours = date.getUTCHours();
1152
+ var dayPeriodEnumValue;
1153
+ if (hours === 12) {
1154
+ dayPeriodEnumValue = dayPeriodEnum.noon;
1155
+ } else if (hours === 0) {
1156
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
1157
+ } else {
1158
+ dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1159
+ }
1160
+ switch (token) {
1161
+ case 'b':
1162
+ case 'bb':
1163
+ return localize.dayPeriod(dayPeriodEnumValue, {
1164
+ width: 'abbreviated',
1165
+ context: 'formatting'
1166
+ });
1167
+ case 'bbb':
1168
+ return localize.dayPeriod(dayPeriodEnumValue, {
1169
+ width: 'abbreviated',
1170
+ context: 'formatting'
1171
+ }).toLowerCase();
1172
+ case 'bbbbb':
1173
+ return localize.dayPeriod(dayPeriodEnumValue, {
1174
+ width: 'narrow',
1175
+ context: 'formatting'
1176
+ });
1177
+ case 'bbbb':
1178
+ default:
1179
+ return localize.dayPeriod(dayPeriodEnumValue, {
1180
+ width: 'wide',
1181
+ context: 'formatting'
1182
+ });
1183
+ }
1184
+ },
1185
+ // in the morning, in the afternoon, in the evening, at night
1186
+ B: function B(date, token, localize) {
1187
+ var hours = date.getUTCHours();
1188
+ var dayPeriodEnumValue;
1189
+ if (hours >= 17) {
1190
+ dayPeriodEnumValue = dayPeriodEnum.evening;
1191
+ } else if (hours >= 12) {
1192
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
1193
+ } else if (hours >= 4) {
1194
+ dayPeriodEnumValue = dayPeriodEnum.morning;
1195
+ } else {
1196
+ dayPeriodEnumValue = dayPeriodEnum.night;
1197
+ }
1198
+ switch (token) {
1199
+ case 'B':
1200
+ case 'BB':
1201
+ case 'BBB':
1202
+ return localize.dayPeriod(dayPeriodEnumValue, {
1203
+ width: 'abbreviated',
1204
+ context: 'formatting'
1205
+ });
1206
+ case 'BBBBB':
1207
+ return localize.dayPeriod(dayPeriodEnumValue, {
1208
+ width: 'narrow',
1209
+ context: 'formatting'
1210
+ });
1211
+ case 'BBBB':
1212
+ default:
1213
+ return localize.dayPeriod(dayPeriodEnumValue, {
1214
+ width: 'wide',
1215
+ context: 'formatting'
1216
+ });
1217
+ }
1218
+ },
1219
+ // Hour [1-12]
1220
+ h: function h(date, token, localize) {
1221
+ if (token === 'ho') {
1222
+ var hours = date.getUTCHours() % 12;
1223
+ if (hours === 0) hours = 12;
1224
+ return localize.ordinalNumber(hours, {
1225
+ unit: 'hour'
1226
+ });
1227
+ }
1228
+ return formatters$3.h(date, token);
1229
+ },
1230
+ // Hour [0-23]
1231
+ H: function H(date, token, localize) {
1232
+ if (token === 'Ho') {
1233
+ return localize.ordinalNumber(date.getUTCHours(), {
1234
+ unit: 'hour'
1235
+ });
1236
+ }
1237
+ return formatters$3.H(date, token);
1238
+ },
1239
+ // Hour [0-11]
1240
+ K: function K(date, token, localize) {
1241
+ var hours = date.getUTCHours() % 12;
1242
+ if (token === 'Ko') {
1243
+ return localize.ordinalNumber(hours, {
1244
+ unit: 'hour'
1245
+ });
1246
+ }
1247
+ return addLeadingZeros(hours, token.length);
1248
+ },
1249
+ // Hour [1-24]
1250
+ k: function k(date, token, localize) {
1251
+ var hours = date.getUTCHours();
1252
+ if (hours === 0) hours = 24;
1253
+ if (token === 'ko') {
1254
+ return localize.ordinalNumber(hours, {
1255
+ unit: 'hour'
1256
+ });
1257
+ }
1258
+ return addLeadingZeros(hours, token.length);
1259
+ },
1260
+ // Minute
1261
+ m: function m(date, token, localize) {
1262
+ if (token === 'mo') {
1263
+ return localize.ordinalNumber(date.getUTCMinutes(), {
1264
+ unit: 'minute'
1265
+ });
1266
+ }
1267
+ return formatters$3.m(date, token);
1268
+ },
1269
+ // Second
1270
+ s: function s(date, token, localize) {
1271
+ if (token === 'so') {
1272
+ return localize.ordinalNumber(date.getUTCSeconds(), {
1273
+ unit: 'second'
1274
+ });
1275
+ }
1276
+ return formatters$3.s(date, token);
1277
+ },
1278
+ // Fraction of second
1279
+ S: function S(date, token) {
1280
+ return formatters$3.S(date, token);
1281
+ },
1282
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1283
+ X: function X(date, token, _localize, options) {
1284
+ var originalDate = options._originalDate || date;
1285
+ var timezoneOffset = originalDate.getTimezoneOffset();
1286
+ if (timezoneOffset === 0) {
1287
+ return 'Z';
1288
+ }
1289
+ switch (token) {
1290
+ // Hours and optional minutes
1291
+ case 'X':
1292
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1293
+
1294
+ // Hours, minutes and optional seconds without `:` delimiter
1295
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1296
+ // so this token always has the same output as `XX`
1297
+ case 'XXXX':
1298
+ case 'XX':
1299
+ // Hours and minutes without `:` delimiter
1300
+ return formatTimezone(timezoneOffset);
1301
+
1302
+ // Hours, minutes and optional seconds with `:` delimiter
1303
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1304
+ // so this token always has the same output as `XXX`
1305
+ case 'XXXXX':
1306
+ case 'XXX': // Hours and minutes with `:` delimiter
1307
+ default:
1308
+ return formatTimezone(timezoneOffset, ':');
1309
+ }
1310
+ },
1311
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1312
+ x: function x(date, token, _localize, options) {
1313
+ var originalDate = options._originalDate || date;
1314
+ var timezoneOffset = originalDate.getTimezoneOffset();
1315
+ switch (token) {
1316
+ // Hours and optional minutes
1317
+ case 'x':
1318
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
1319
+
1320
+ // Hours, minutes and optional seconds without `:` delimiter
1321
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1322
+ // so this token always has the same output as `xx`
1323
+ case 'xxxx':
1324
+ case 'xx':
1325
+ // Hours and minutes without `:` delimiter
1326
+ return formatTimezone(timezoneOffset);
1327
+
1328
+ // Hours, minutes and optional seconds with `:` delimiter
1329
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1330
+ // so this token always has the same output as `xxx`
1331
+ case 'xxxxx':
1332
+ case 'xxx': // Hours and minutes with `:` delimiter
1333
+ default:
1334
+ return formatTimezone(timezoneOffset, ':');
1335
+ }
1336
+ },
1337
+ // Timezone (GMT)
1338
+ O: function O(date, token, _localize, options) {
1339
+ var originalDate = options._originalDate || date;
1340
+ var timezoneOffset = originalDate.getTimezoneOffset();
1341
+ switch (token) {
1342
+ // Short
1343
+ case 'O':
1344
+ case 'OO':
1345
+ case 'OOO':
1346
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1347
+ // Long
1348
+ case 'OOOO':
1349
+ default:
1350
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1351
+ }
1352
+ },
1353
+ // Timezone (specific non-location)
1354
+ z: function z(date, token, _localize, options) {
1355
+ var originalDate = options._originalDate || date;
1356
+ var timezoneOffset = originalDate.getTimezoneOffset();
1357
+ switch (token) {
1358
+ // Short
1359
+ case 'z':
1360
+ case 'zz':
1361
+ case 'zzz':
1362
+ return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1363
+ // Long
1364
+ case 'zzzz':
1365
+ default:
1366
+ return 'GMT' + formatTimezone(timezoneOffset, ':');
1367
+ }
1368
+ },
1369
+ // Seconds timestamp
1370
+ t: function t(date, token, _localize, options) {
1371
+ var originalDate = options._originalDate || date;
1372
+ var timestamp = Math.floor(originalDate.getTime() / 1000);
1373
+ return addLeadingZeros(timestamp, token.length);
1374
+ },
1375
+ // Milliseconds timestamp
1376
+ T: function T(date, token, _localize, options) {
1377
+ var originalDate = options._originalDate || date;
1378
+ var timestamp = originalDate.getTime();
1379
+ return addLeadingZeros(timestamp, token.length);
1380
+ }
1381
+ };
1382
+ function formatTimezoneShort(offset, dirtyDelimiter) {
1383
+ var sign = offset > 0 ? '-' : '+';
1384
+ var absOffset = Math.abs(offset);
1385
+ var hours = Math.floor(absOffset / 60);
1386
+ var minutes = absOffset % 60;
1387
+ if (minutes === 0) {
1388
+ return sign + String(hours);
1389
+ }
1390
+ var delimiter = dirtyDelimiter || '';
1391
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1392
+ }
1393
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1394
+ if (offset % 60 === 0) {
1395
+ var sign = offset > 0 ? '-' : '+';
1396
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1397
+ }
1398
+ return formatTimezone(offset, dirtyDelimiter);
1399
+ }
1400
+ function formatTimezone(offset, dirtyDelimiter) {
1401
+ var delimiter = dirtyDelimiter || '';
1402
+ var sign = offset > 0 ? '-' : '+';
1403
+ var absOffset = Math.abs(offset);
1404
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1405
+ var minutes = addLeadingZeros(absOffset % 60, 2);
1406
+ return sign + hours + delimiter + minutes;
1407
+ }
1408
+ const formatters$1 = formatters;
1409
+
1410
+ var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1411
+ switch (pattern) {
1412
+ case 'P':
1413
+ return formatLong.date({
1414
+ width: 'short'
1415
+ });
1416
+ case 'PP':
1417
+ return formatLong.date({
1418
+ width: 'medium'
1419
+ });
1420
+ case 'PPP':
1421
+ return formatLong.date({
1422
+ width: 'long'
1423
+ });
1424
+ case 'PPPP':
1425
+ default:
1426
+ return formatLong.date({
1427
+ width: 'full'
1428
+ });
1429
+ }
1430
+ };
1431
+ var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1432
+ switch (pattern) {
1433
+ case 'p':
1434
+ return formatLong.time({
1435
+ width: 'short'
1436
+ });
1437
+ case 'pp':
1438
+ return formatLong.time({
1439
+ width: 'medium'
1440
+ });
1441
+ case 'ppp':
1442
+ return formatLong.time({
1443
+ width: 'long'
1444
+ });
1445
+ case 'pppp':
1446
+ default:
1447
+ return formatLong.time({
1448
+ width: 'full'
1449
+ });
1450
+ }
1451
+ };
1452
+ var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1453
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
1454
+ var datePattern = matchResult[1];
1455
+ var timePattern = matchResult[2];
1456
+ if (!timePattern) {
1457
+ return dateLongFormatter(pattern, formatLong);
1458
+ }
1459
+ var dateTimeFormat;
1460
+ switch (datePattern) {
1461
+ case 'P':
1462
+ dateTimeFormat = formatLong.dateTime({
1463
+ width: 'short'
1464
+ });
1465
+ break;
1466
+ case 'PP':
1467
+ dateTimeFormat = formatLong.dateTime({
1468
+ width: 'medium'
1469
+ });
1470
+ break;
1471
+ case 'PPP':
1472
+ dateTimeFormat = formatLong.dateTime({
1473
+ width: 'long'
1474
+ });
1475
+ break;
1476
+ case 'PPPP':
1477
+ default:
1478
+ dateTimeFormat = formatLong.dateTime({
1479
+ width: 'full'
1480
+ });
1481
+ break;
1482
+ }
1483
+ return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1484
+ };
1485
+ var longFormatters = {
1486
+ p: timeLongFormatter,
1487
+ P: dateTimeLongFormatter
1488
+ };
1489
+ const longFormatters$1 = longFormatters;
1490
+
1491
+ var protectedDayOfYearTokens = ['D', 'DD'];
1492
+ var protectedWeekYearTokens = ['YY', 'YYYY'];
1493
+ function isProtectedDayOfYearToken(token) {
1494
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
1495
+ }
1496
+ function isProtectedWeekYearToken(token) {
1497
+ return protectedWeekYearTokens.indexOf(token) !== -1;
1498
+ }
1499
+ function throwProtectedError(token, format, input) {
1500
+ if (token === 'YYYY') {
1501
+ 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"));
1502
+ } else if (token === 'YY') {
1503
+ 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"));
1504
+ } else if (token === 'D') {
1505
+ 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"));
1506
+ } else if (token === 'DD') {
1507
+ 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"));
1508
+ }
1509
+ }
1510
+
1511
+ var formatDistanceLocale = {
1512
+ lessThanXSeconds: {
1513
+ one: 'less than a second',
1514
+ other: 'less than {{count}} seconds'
1515
+ },
1516
+ xSeconds: {
1517
+ one: '1 second',
1518
+ other: '{{count}} seconds'
1519
+ },
1520
+ halfAMinute: 'half a minute',
1521
+ lessThanXMinutes: {
1522
+ one: 'less than a minute',
1523
+ other: 'less than {{count}} minutes'
1524
+ },
1525
+ xMinutes: {
1526
+ one: '1 minute',
1527
+ other: '{{count}} minutes'
1528
+ },
1529
+ aboutXHours: {
1530
+ one: 'about 1 hour',
1531
+ other: 'about {{count}} hours'
1532
+ },
1533
+ xHours: {
1534
+ one: '1 hour',
1535
+ other: '{{count}} hours'
1536
+ },
1537
+ xDays: {
1538
+ one: '1 day',
1539
+ other: '{{count}} days'
1540
+ },
1541
+ aboutXWeeks: {
1542
+ one: 'about 1 week',
1543
+ other: 'about {{count}} weeks'
1544
+ },
1545
+ xWeeks: {
1546
+ one: '1 week',
1547
+ other: '{{count}} weeks'
1548
+ },
1549
+ aboutXMonths: {
1550
+ one: 'about 1 month',
1551
+ other: 'about {{count}} months'
1552
+ },
1553
+ xMonths: {
1554
+ one: '1 month',
1555
+ other: '{{count}} months'
1556
+ },
1557
+ aboutXYears: {
1558
+ one: 'about 1 year',
1559
+ other: 'about {{count}} years'
1560
+ },
1561
+ xYears: {
1562
+ one: '1 year',
1563
+ other: '{{count}} years'
1564
+ },
1565
+ overXYears: {
1566
+ one: 'over 1 year',
1567
+ other: 'over {{count}} years'
1568
+ },
1569
+ almostXYears: {
1570
+ one: 'almost 1 year',
1571
+ other: 'almost {{count}} years'
1572
+ }
1573
+ };
1574
+ var formatDistance = function formatDistance(token, count, options) {
1575
+ var result;
1576
+ var tokenValue = formatDistanceLocale[token];
1577
+ if (typeof tokenValue === 'string') {
1578
+ result = tokenValue;
1579
+ } else if (count === 1) {
1580
+ result = tokenValue.one;
1581
+ } else {
1582
+ result = tokenValue.other.replace('{{count}}', count.toString());
1583
+ }
1584
+ if (options !== null && options !== void 0 && options.addSuffix) {
1585
+ if (options.comparison && options.comparison > 0) {
1586
+ return 'in ' + result;
1587
+ } else {
1588
+ return result + ' ago';
1589
+ }
1590
+ }
1591
+ return result;
1592
+ };
1593
+ const formatDistance$1 = formatDistance;
1594
+
1595
+ function buildFormatLongFn(args) {
1596
+ return function () {
1597
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1598
+ // TODO: Remove String()
1599
+ var width = options.width ? String(options.width) : args.defaultWidth;
1600
+ var format = args.formats[width] || args.formats[args.defaultWidth];
1601
+ return format;
1602
+ };
1603
+ }
1604
+
1605
+ var dateFormats = {
1606
+ full: 'EEEE, MMMM do, y',
1607
+ long: 'MMMM do, y',
1608
+ medium: 'MMM d, y',
1609
+ short: 'MM/dd/yyyy'
1610
+ };
1611
+ var timeFormats = {
1612
+ full: 'h:mm:ss a zzzz',
1613
+ long: 'h:mm:ss a z',
1614
+ medium: 'h:mm:ss a',
1615
+ short: 'h:mm a'
1616
+ };
1617
+ var dateTimeFormats = {
1618
+ full: "{{date}} 'at' {{time}}",
1619
+ long: "{{date}} 'at' {{time}}",
1620
+ medium: '{{date}}, {{time}}',
1621
+ short: '{{date}}, {{time}}'
1622
+ };
1623
+ var formatLong = {
1624
+ date: buildFormatLongFn({
1625
+ formats: dateFormats,
1626
+ defaultWidth: 'full'
1627
+ }),
1628
+ time: buildFormatLongFn({
1629
+ formats: timeFormats,
1630
+ defaultWidth: 'full'
1631
+ }),
1632
+ dateTime: buildFormatLongFn({
1633
+ formats: dateTimeFormats,
1634
+ defaultWidth: 'full'
1635
+ })
1636
+ };
1637
+ const formatLong$1 = formatLong;
1638
+
1639
+ var formatRelativeLocale = {
1640
+ lastWeek: "'last' eeee 'at' p",
1641
+ yesterday: "'yesterday at' p",
1642
+ today: "'today at' p",
1643
+ tomorrow: "'tomorrow at' p",
1644
+ nextWeek: "eeee 'at' p",
1645
+ other: 'P'
1646
+ };
1647
+ var formatRelative = function formatRelative(token, _date, _baseDate, _options) {
1648
+ return formatRelativeLocale[token];
1649
+ };
1650
+ const formatRelative$1 = formatRelative;
1651
+
1652
+ function buildLocalizeFn(args) {
1653
+ return function (dirtyIndex, options) {
1654
+ var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1655
+ var valuesArray;
1656
+ if (context === 'formatting' && args.formattingValues) {
1657
+ var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1658
+ var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1659
+ valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1660
+ } else {
1661
+ var _defaultWidth = args.defaultWidth;
1662
+ var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1663
+ valuesArray = args.values[_width] || args.values[_defaultWidth];
1664
+ }
1665
+ var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1666
+ // @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!
1667
+ return valuesArray[index];
1668
+ };
1669
+ }
1670
+
1671
+ var eraValues = {
1672
+ narrow: ['B', 'A'],
1673
+ abbreviated: ['BC', 'AD'],
1674
+ wide: ['Before Christ', 'Anno Domini']
1675
+ };
1676
+ var quarterValues = {
1677
+ narrow: ['1', '2', '3', '4'],
1678
+ abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1679
+ wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1680
+ };
1681
+
1682
+ // Note: in English, the names of days of the week and months are capitalized.
1683
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1684
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1685
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1686
+ var monthValues = {
1687
+ narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1688
+ abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1689
+ wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1690
+ };
1691
+ var dayValues = {
1692
+ narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1693
+ short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1694
+ abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1695
+ wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1696
+ };
1697
+ var dayPeriodValues = {
1698
+ narrow: {
1699
+ am: 'a',
1700
+ pm: 'p',
1701
+ midnight: 'mi',
1702
+ noon: 'n',
1703
+ morning: 'morning',
1704
+ afternoon: 'afternoon',
1705
+ evening: 'evening',
1706
+ night: 'night'
1707
+ },
1708
+ abbreviated: {
1709
+ am: 'AM',
1710
+ pm: 'PM',
1711
+ midnight: 'midnight',
1712
+ noon: 'noon',
1713
+ morning: 'morning',
1714
+ afternoon: 'afternoon',
1715
+ evening: 'evening',
1716
+ night: 'night'
1717
+ },
1718
+ wide: {
1719
+ am: 'a.m.',
1720
+ pm: 'p.m.',
1721
+ midnight: 'midnight',
1722
+ noon: 'noon',
1723
+ morning: 'morning',
1724
+ afternoon: 'afternoon',
1725
+ evening: 'evening',
1726
+ night: 'night'
1727
+ }
1728
+ };
1729
+ var formattingDayPeriodValues = {
1730
+ narrow: {
1731
+ am: 'a',
1732
+ pm: 'p',
1733
+ midnight: 'mi',
1734
+ noon: 'n',
1735
+ morning: 'in the morning',
1736
+ afternoon: 'in the afternoon',
1737
+ evening: 'in the evening',
1738
+ night: 'at night'
1739
+ },
1740
+ abbreviated: {
1741
+ am: 'AM',
1742
+ pm: 'PM',
1743
+ midnight: 'midnight',
1744
+ noon: 'noon',
1745
+ morning: 'in the morning',
1746
+ afternoon: 'in the afternoon',
1747
+ evening: 'in the evening',
1748
+ night: 'at night'
1749
+ },
1750
+ wide: {
1751
+ am: 'a.m.',
1752
+ pm: 'p.m.',
1753
+ midnight: 'midnight',
1754
+ noon: 'noon',
1755
+ morning: 'in the morning',
1756
+ afternoon: 'in the afternoon',
1757
+ evening: 'in the evening',
1758
+ night: 'at night'
1759
+ }
1760
+ };
1761
+ var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {
1762
+ var number = Number(dirtyNumber);
1763
+
1764
+ // If ordinal numbers depend on context, for example,
1765
+ // if they are different for different grammatical genders,
1766
+ // use `options.unit`.
1767
+ //
1768
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1769
+ // 'day', 'hour', 'minute', 'second'.
1770
+
1771
+ var rem100 = number % 100;
1772
+ if (rem100 > 20 || rem100 < 10) {
1773
+ switch (rem100 % 10) {
1774
+ case 1:
1775
+ return number + 'st';
1776
+ case 2:
1777
+ return number + 'nd';
1778
+ case 3:
1779
+ return number + 'rd';
1780
+ }
1781
+ }
1782
+ return number + 'th';
1783
+ };
1784
+ var localize = {
1785
+ ordinalNumber: ordinalNumber,
1786
+ era: buildLocalizeFn({
1787
+ values: eraValues,
1788
+ defaultWidth: 'wide'
1789
+ }),
1790
+ quarter: buildLocalizeFn({
1791
+ values: quarterValues,
1792
+ defaultWidth: 'wide',
1793
+ argumentCallback: function argumentCallback(quarter) {
1794
+ return quarter - 1;
1795
+ }
1796
+ }),
1797
+ month: buildLocalizeFn({
1798
+ values: monthValues,
1799
+ defaultWidth: 'wide'
1800
+ }),
1801
+ day: buildLocalizeFn({
1802
+ values: dayValues,
1803
+ defaultWidth: 'wide'
1804
+ }),
1805
+ dayPeriod: buildLocalizeFn({
1806
+ values: dayPeriodValues,
1807
+ defaultWidth: 'wide',
1808
+ formattingValues: formattingDayPeriodValues,
1809
+ defaultFormattingWidth: 'wide'
1810
+ })
1811
+ };
1812
+ const localize$1 = localize;
1813
+
1814
+ function buildMatchFn(args) {
1815
+ return function (string) {
1816
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1817
+ var width = options.width;
1818
+ var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
1819
+ var matchResult = string.match(matchPattern);
1820
+ if (!matchResult) {
1821
+ return null;
1822
+ }
1823
+ var matchedString = matchResult[0];
1824
+ var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
1825
+ var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
1826
+ return pattern.test(matchedString);
1827
+ }) : findKey(parsePatterns, function (pattern) {
1828
+ return pattern.test(matchedString);
1829
+ });
1830
+ var value;
1831
+ value = args.valueCallback ? args.valueCallback(key) : key;
1832
+ value = options.valueCallback ? options.valueCallback(value) : value;
1833
+ var rest = string.slice(matchedString.length);
1834
+ return {
1835
+ value: value,
1836
+ rest: rest
1837
+ };
1838
+ };
1839
+ }
1840
+ function findKey(object, predicate) {
1841
+ for (var key in object) {
1842
+ if (object.hasOwnProperty(key) && predicate(object[key])) {
1843
+ return key;
1844
+ }
1845
+ }
1846
+ return undefined;
1847
+ }
1848
+ function findIndex(array, predicate) {
1849
+ for (var key = 0; key < array.length; key++) {
1850
+ if (predicate(array[key])) {
1851
+ return key;
1852
+ }
1853
+ }
1854
+ return undefined;
1855
+ }
1856
+
1857
+ function buildMatchPatternFn(args) {
1858
+ return function (string) {
1859
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1860
+ var matchResult = string.match(args.matchPattern);
1861
+ if (!matchResult) return null;
1862
+ var matchedString = matchResult[0];
1863
+ var parseResult = string.match(args.parsePattern);
1864
+ if (!parseResult) return null;
1865
+ var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
1866
+ value = options.valueCallback ? options.valueCallback(value) : value;
1867
+ var rest = string.slice(matchedString.length);
1868
+ return {
1869
+ value: value,
1870
+ rest: rest
1871
+ };
1872
+ };
1873
+ }
1874
+
1875
+ var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1876
+ var parseOrdinalNumberPattern = /\d+/i;
1877
+ var matchEraPatterns = {
1878
+ narrow: /^(b|a)/i,
1879
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1880
+ wide: /^(before christ|before common era|anno domini|common era)/i
1881
+ };
1882
+ var parseEraPatterns = {
1883
+ any: [/^b/i, /^(a|c)/i]
1884
+ };
1885
+ var matchQuarterPatterns = {
1886
+ narrow: /^[1234]/i,
1887
+ abbreviated: /^q[1234]/i,
1888
+ wide: /^[1234](th|st|nd|rd)? quarter/i
1889
+ };
1890
+ var parseQuarterPatterns = {
1891
+ any: [/1/i, /2/i, /3/i, /4/i]
1892
+ };
1893
+ var matchMonthPatterns = {
1894
+ narrow: /^[jfmasond]/i,
1895
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1896
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
1897
+ };
1898
+ var parseMonthPatterns = {
1899
+ 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],
1900
+ 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]
1901
+ };
1902
+ var matchDayPatterns = {
1903
+ narrow: /^[smtwf]/i,
1904
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1905
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1906
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
1907
+ };
1908
+ var parseDayPatterns = {
1909
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1910
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
1911
+ };
1912
+ var matchDayPeriodPatterns = {
1913
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1914
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
1915
+ };
1916
+ var parseDayPeriodPatterns = {
1917
+ any: {
1918
+ am: /^a/i,
1919
+ pm: /^p/i,
1920
+ midnight: /^mi/i,
1921
+ noon: /^no/i,
1922
+ morning: /morning/i,
1923
+ afternoon: /afternoon/i,
1924
+ evening: /evening/i,
1925
+ night: /night/i
1926
+ }
1927
+ };
1928
+ var match = {
1929
+ ordinalNumber: buildMatchPatternFn({
1930
+ matchPattern: matchOrdinalNumberPattern,
1931
+ parsePattern: parseOrdinalNumberPattern,
1932
+ valueCallback: function valueCallback(value) {
1933
+ return parseInt(value, 10);
1934
+ }
1935
+ }),
1936
+ era: buildMatchFn({
1937
+ matchPatterns: matchEraPatterns,
1938
+ defaultMatchWidth: 'wide',
1939
+ parsePatterns: parseEraPatterns,
1940
+ defaultParseWidth: 'any'
1941
+ }),
1942
+ quarter: buildMatchFn({
1943
+ matchPatterns: matchQuarterPatterns,
1944
+ defaultMatchWidth: 'wide',
1945
+ parsePatterns: parseQuarterPatterns,
1946
+ defaultParseWidth: 'any',
1947
+ valueCallback: function valueCallback(index) {
1948
+ return index + 1;
1949
+ }
1950
+ }),
1951
+ month: buildMatchFn({
1952
+ matchPatterns: matchMonthPatterns,
1953
+ defaultMatchWidth: 'wide',
1954
+ parsePatterns: parseMonthPatterns,
1955
+ defaultParseWidth: 'any'
1956
+ }),
1957
+ day: buildMatchFn({
1958
+ matchPatterns: matchDayPatterns,
1959
+ defaultMatchWidth: 'wide',
1960
+ parsePatterns: parseDayPatterns,
1961
+ defaultParseWidth: 'any'
1962
+ }),
1963
+ dayPeriod: buildMatchFn({
1964
+ matchPatterns: matchDayPeriodPatterns,
1965
+ defaultMatchWidth: 'any',
1966
+ parsePatterns: parseDayPeriodPatterns,
1967
+ defaultParseWidth: 'any'
1968
+ })
1969
+ };
1970
+ const match$1 = match;
1971
+
1972
+ /**
1973
+ * @type {Locale}
1974
+ * @category Locales
1975
+ * @summary English locale (United States).
1976
+ * @language English
1977
+ * @iso-639-2 eng
1978
+ * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
1979
+ * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
1980
+ */
1981
+ var locale = {
1982
+ code: 'en-US',
1983
+ formatDistance: formatDistance$1,
1984
+ formatLong: formatLong$1,
1985
+ formatRelative: formatRelative$1,
1986
+ localize: localize$1,
1987
+ match: match$1,
1988
+ options: {
1989
+ weekStartsOn: 0 /* Sunday */,
1990
+ firstWeekContainsDate: 1
1991
+ }
1992
+ };
1993
+ const defaultLocale = locale;
1994
+
1995
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
1996
+ // (one of the certain letters followed by `o`)
1997
+ // - (\w)\1* matches any sequences of the same letter
1998
+ // - '' matches two quote characters in a row
1999
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2000
+ // except a single quote symbol, which ends the sequence.
2001
+ // Two quote characters do not end the sequence.
2002
+ // If there is no matching single quote
2003
+ // then the sequence will continue until the end of the string.
2004
+ // - . matches any single character unmatched by previous parts of the RegExps
2005
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2006
+
2007
+ // This RegExp catches symbols escaped by quotes, and also
2008
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2009
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2010
+ var escapedStringRegExp = /^'([^]*?)'?$/;
2011
+ var doubleQuoteRegExp = /''/g;
2012
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2013
+
2014
+ /**
2015
+ * @name format
2016
+ * @category Common Helpers
2017
+ * @summary Format the date.
2018
+ *
2019
+ * @description
2020
+ * Return the formatted date string in the given format. The result may vary by locale.
2021
+ *
2022
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2023
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2024
+ *
2025
+ * The characters wrapped between two single quotes characters (') are escaped.
2026
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2027
+ * (see the last example)
2028
+ *
2029
+ * Format of the string is based on Unicode Technical Standard #35:
2030
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2031
+ * with a few additions (see note 7 below the table).
2032
+ *
2033
+ * Accepted patterns:
2034
+ * | Unit | Pattern | Result examples | Notes |
2035
+ * |---------------------------------|---------|-----------------------------------|-------|
2036
+ * | Era | G..GGG | AD, BC | |
2037
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2038
+ * | | GGGGG | A, B | |
2039
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2040
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2041
+ * | | yy | 44, 01, 00, 17 | 5 |
2042
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2043
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2044
+ * | | yyyyy | ... | 3,5 |
2045
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2046
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2047
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2048
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2049
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2050
+ * | | YYYYY | ... | 3,5 |
2051
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2052
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2053
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2054
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2055
+ * | | RRRRR | ... | 3,5,7 |
2056
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2057
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2058
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2059
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2060
+ * | | uuuuu | ... | 3,5 |
2061
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2062
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2063
+ * | | QQ | 01, 02, 03, 04 | |
2064
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2065
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2066
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2067
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2068
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2069
+ * | | qq | 01, 02, 03, 04 | |
2070
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2071
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2072
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2073
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2074
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2075
+ * | | MM | 01, 02, ..., 12 | |
2076
+ * | | MMM | Jan, Feb, ..., Dec | |
2077
+ * | | MMMM | January, February, ..., December | 2 |
2078
+ * | | MMMMM | J, F, ..., D | |
2079
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2080
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2081
+ * | | LL | 01, 02, ..., 12 | |
2082
+ * | | LLL | Jan, Feb, ..., Dec | |
2083
+ * | | LLLL | January, February, ..., December | 2 |
2084
+ * | | LLLLL | J, F, ..., D | |
2085
+ * | Local week of year | w | 1, 2, ..., 53 | |
2086
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2087
+ * | | ww | 01, 02, ..., 53 | |
2088
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2089
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2090
+ * | | II | 01, 02, ..., 53 | 7 |
2091
+ * | Day of month | d | 1, 2, ..., 31 | |
2092
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2093
+ * | | dd | 01, 02, ..., 31 | |
2094
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2095
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2096
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2097
+ * | | DDD | 001, 002, ..., 365, 366 | |
2098
+ * | | DDDD | ... | 3 |
2099
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2100
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2101
+ * | | EEEEE | M, T, W, T, F, S, S | |
2102
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2103
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2104
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2105
+ * | | ii | 01, 02, ..., 07 | 7 |
2106
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2107
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2108
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2109
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2110
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2111
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2112
+ * | | ee | 02, 03, ..., 01 | |
2113
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2114
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2115
+ * | | eeeee | M, T, W, T, F, S, S | |
2116
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2117
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2118
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2119
+ * | | cc | 02, 03, ..., 01 | |
2120
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2121
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2122
+ * | | ccccc | M, T, W, T, F, S, S | |
2123
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2124
+ * | AM, PM | a..aa | AM, PM | |
2125
+ * | | aaa | am, pm | |
2126
+ * | | aaaa | a.m., p.m. | 2 |
2127
+ * | | aaaaa | a, p | |
2128
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2129
+ * | | bbb | am, pm, noon, midnight | |
2130
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2131
+ * | | bbbbb | a, p, n, mi | |
2132
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2133
+ * | | BBBB | at night, in the morning, ... | 2 |
2134
+ * | | BBBBB | at night, in the morning, ... | |
2135
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2136
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2137
+ * | | hh | 01, 02, ..., 11, 12 | |
2138
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2139
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2140
+ * | | HH | 00, 01, 02, ..., 23 | |
2141
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2142
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2143
+ * | | KK | 01, 02, ..., 11, 00 | |
2144
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2145
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2146
+ * | | kk | 24, 01, 02, ..., 23 | |
2147
+ * | Minute | m | 0, 1, ..., 59 | |
2148
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2149
+ * | | mm | 00, 01, ..., 59 | |
2150
+ * | Second | s | 0, 1, ..., 59 | |
2151
+ * | | so | 0th, 1st, ..., 59th | 7 |
2152
+ * | | ss | 00, 01, ..., 59 | |
2153
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2154
+ * | | SS | 00, 01, ..., 99 | |
2155
+ * | | SSS | 000, 001, ..., 999 | |
2156
+ * | | SSSS | ... | 3 |
2157
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2158
+ * | | XX | -0800, +0530, Z | |
2159
+ * | | XXX | -08:00, +05:30, Z | |
2160
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2161
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2162
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2163
+ * | | xx | -0800, +0530, +0000 | |
2164
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2165
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2166
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2167
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2168
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2169
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2170
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2171
+ * | Seconds timestamp | t | 512969520 | 7 |
2172
+ * | | tt | ... | 3,7 |
2173
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2174
+ * | | TT | ... | 3,7 |
2175
+ * | Long localized date | P | 04/29/1453 | 7 |
2176
+ * | | PP | Apr 29, 1453 | 7 |
2177
+ * | | PPP | April 29th, 1453 | 7 |
2178
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2179
+ * | Long localized time | p | 12:00 AM | 7 |
2180
+ * | | pp | 12:00:00 AM | 7 |
2181
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2182
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2183
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2184
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2185
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2186
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2187
+ * Notes:
2188
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2189
+ * are the same as "stand-alone" units, but are different in some languages.
2190
+ * "Formatting" units are declined according to the rules of the language
2191
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2192
+ *
2193
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2194
+ *
2195
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2196
+ *
2197
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2198
+ * the single quote characters (see below).
2199
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2200
+ * the output will be the same as default pattern for this unit, usually
2201
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2202
+ * are marked with "2" in the last column of the table.
2203
+ *
2204
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2205
+ *
2206
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2207
+ *
2208
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2209
+ *
2210
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2211
+ *
2212
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2213
+ *
2214
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2215
+ * The output will be padded with zeros to match the length of the pattern.
2216
+ *
2217
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2218
+ *
2219
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2220
+ * These tokens represent the shortest form of the quarter.
2221
+ *
2222
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2223
+ *
2224
+ * | Year | `y` | `u` |
2225
+ * |------|-----|-----|
2226
+ * | AC 1 | 1 | 1 |
2227
+ * | BC 1 | 1 | 0 |
2228
+ * | BC 2 | 2 | -1 |
2229
+ *
2230
+ * Also `yy` always returns the last two digits of a year,
2231
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2232
+ *
2233
+ * | Year | `yy` | `uu` |
2234
+ * |------|------|------|
2235
+ * | 1 | 01 | 01 |
2236
+ * | 14 | 14 | 14 |
2237
+ * | 376 | 76 | 376 |
2238
+ * | 1453 | 53 | 1453 |
2239
+ *
2240
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2241
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2242
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2243
+ * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2244
+ *
2245
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2246
+ * so right now these tokens fall back to GMT timezones.
2247
+ *
2248
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2249
+ * - `i`: ISO day of week
2250
+ * - `I`: ISO week of year
2251
+ * - `R`: ISO week-numbering year
2252
+ * - `t`: seconds timestamp
2253
+ * - `T`: milliseconds timestamp
2254
+ * - `o`: ordinal number modifier
2255
+ * - `P`: long localized date
2256
+ * - `p`: long localized time
2257
+ *
2258
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2259
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2260
+ *
2261
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2262
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2263
+ *
2264
+ * @param {Date|Number} date - the original date
2265
+ * @param {String} format - the string of tokens
2266
+ * @param {Object} [options] - an object with options.
2267
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2268
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2269
+ * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2270
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2271
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2272
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2273
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2274
+ * @returns {String} the formatted date string
2275
+ * @throws {TypeError} 2 arguments required
2276
+ * @throws {RangeError} `date` must not be Invalid Date
2277
+ * @throws {RangeError} `options.locale` must contain `localize` property
2278
+ * @throws {RangeError} `options.locale` must contain `formatLong` property
2279
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2280
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2281
+ * @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
2282
+ * @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
2283
+ * @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
2284
+ * @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
2285
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
2286
+ *
2287
+ * @example
2288
+ * // Represent 11 February 2014 in middle-endian format:
2289
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2290
+ * //=> '02/11/2014'
2291
+ *
2292
+ * @example
2293
+ * // Represent 2 July 2014 in Esperanto:
2294
+ * import { eoLocale } from 'date-fns/locale/eo'
2295
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2296
+ * locale: eoLocale
2297
+ * })
2298
+ * //=> '2-a de julio 2014'
2299
+ *
2300
+ * @example
2301
+ * // Escape string by single quote characters:
2302
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2303
+ * //=> "3 o'clock"
2304
+ */
2305
+
2306
+ function format(dirtyDate, dirtyFormatStr, options) {
2307
+ 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;
2308
+ requiredArgs(2, arguments);
2309
+ var formatStr = String(dirtyFormatStr);
2310
+ var defaultOptions = getDefaultOptions();
2311
+ 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;
2312
+ 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);
2313
+
2314
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2315
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2316
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2317
+ }
2318
+ 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);
2319
+
2320
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2321
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2322
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2323
+ }
2324
+ if (!locale.localize) {
2325
+ throw new RangeError('locale must contain localize property');
2326
+ }
2327
+ if (!locale.formatLong) {
2328
+ throw new RangeError('locale must contain formatLong property');
2329
+ }
2330
+ var originalDate = toDate(dirtyDate);
2331
+ if (!isValid(originalDate)) {
2332
+ throw new RangeError('Invalid time value');
2333
+ }
2334
+
2335
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2336
+ // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2337
+ // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2338
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2339
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
2340
+ var formatterOptions = {
2341
+ firstWeekContainsDate: firstWeekContainsDate,
2342
+ weekStartsOn: weekStartsOn,
2343
+ locale: locale,
2344
+ _originalDate: originalDate
2345
+ };
2346
+ var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2347
+ var firstCharacter = substring[0];
2348
+ if (firstCharacter === 'p' || firstCharacter === 'P') {
2349
+ var longFormatter = longFormatters$1[firstCharacter];
2350
+ return longFormatter(substring, locale.formatLong);
2351
+ }
2352
+ return substring;
2353
+ }).join('').match(formattingTokensRegExp).map(function (substring) {
2354
+ // Replace two single quote characters with one single quote character
2355
+ if (substring === "''") {
2356
+ return "'";
2357
+ }
2358
+ var firstCharacter = substring[0];
2359
+ if (firstCharacter === "'") {
2360
+ return cleanEscapedString(substring);
2361
+ }
2362
+ var formatter = formatters$1[firstCharacter];
2363
+ if (formatter) {
2364
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2365
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2366
+ }
2367
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2368
+ throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2369
+ }
2370
+ return formatter(utcDate, substring, locale.localize, formatterOptions);
2371
+ }
2372
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2373
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2374
+ }
2375
+ return substring;
2376
+ }).join('');
2377
+ return result;
2378
+ }
2379
+ function cleanEscapedString(input) {
2380
+ var matched = input.match(escapedStringRegExp);
2381
+ if (!matched) {
2382
+ return input;
2383
+ }
2384
+ return matched[1].replace(doubleQuoteRegExp, "'");
2385
+ }
2386
+
2387
+ /**
2388
+ * @name isToday
2389
+ * @category Day Helpers
2390
+ * @summary Is the given date today?
2391
+ * @pure false
2392
+ *
2393
+ * @description
2394
+ * Is the given date today?
2395
+ *
2396
+ * > ⚠️ Please note that this function is not present in the FP submodule as
2397
+ * > it uses `Date.now()` internally hence impure and can't be safely curried.
2398
+ *
2399
+ * @param {Date|Number} date - the date to check
2400
+ * @returns {Boolean} the date is today
2401
+ * @throws {TypeError} 1 argument required
2402
+ *
2403
+ * @example
2404
+ * // If today is 6 October 2014, is 6 October 14:00:00 today?
2405
+ * const result = isToday(new Date(2014, 9, 6, 14, 0))
2406
+ * //=> true
2407
+ */
2408
+ function isToday(dirtyDate) {
2409
+ requiredArgs(1, arguments);
2410
+ return isSameDay(dirtyDate, Date.now());
2411
+ }
2412
+
2413
+ /**
2414
+ * @name isTomorrow
2415
+ * @category Day Helpers
2416
+ * @summary Is the given date tomorrow?
2417
+ * @pure false
2418
+ *
2419
+ * @description
2420
+ * Is the given date tomorrow?
2421
+ *
2422
+ * > ⚠️ Please note that this function is not present in the FP submodule as
2423
+ * > it uses `Date.now()` internally hence impure and can't be safely curried.
2424
+ *
2425
+ * @param {Date|Number} date - the date to check
2426
+ * @returns {Boolean} the date is tomorrow
2427
+ * @throws {TypeError} 1 argument required
2428
+ *
2429
+ * @example
2430
+ * // If today is 6 October 2014, is 7 October 14:00:00 tomorrow?
2431
+ * const result = isTomorrow(new Date(2014, 9, 7, 14, 0))
2432
+ * //=> true
2433
+ */
2434
+ function isTomorrow(dirtyDate) {
2435
+ requiredArgs(1, arguments);
2436
+ return isSameDay(dirtyDate, addDays(Date.now(), 1));
2437
+ }
2438
+
2439
+ /**
2440
+ * @name parseISO
2441
+ * @category Common Helpers
2442
+ * @summary Parse ISO string
2443
+ *
2444
+ * @description
2445
+ * Parse the given string in ISO 8601 format and return an instance of Date.
2446
+ *
2447
+ * Function accepts complete ISO 8601 formats as well as partial implementations.
2448
+ * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
2449
+ *
2450
+ * If the argument isn't a string, the function cannot parse the string or
2451
+ * the values are invalid, it returns Invalid Date.
2452
+ *
2453
+ * @param {String} argument - the value to convert
2454
+ * @param {Object} [options] - an object with options.
2455
+ * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
2456
+ * @returns {Date} the parsed date in the local time zone
2457
+ * @throws {TypeError} 1 argument required
2458
+ * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
2459
+ *
2460
+ * @example
2461
+ * // Convert string '2014-02-11T11:30:30' to date:
2462
+ * const result = parseISO('2014-02-11T11:30:30')
2463
+ * //=> Tue Feb 11 2014 11:30:30
2464
+ *
2465
+ * @example
2466
+ * // Convert string '+02014101' to date,
2467
+ * // if the additional number of digits in the extended year format is 1:
2468
+ * const result = parseISO('+02014101', { additionalDigits: 1 })
2469
+ * //=> Fri Apr 11 2014 00:00:00
2470
+ */
2471
+ function parseISO(argument, options) {
2472
+ var _options$additionalDi;
2473
+ requiredArgs(1, arguments);
2474
+ var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);
2475
+ if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
2476
+ throw new RangeError('additionalDigits must be 0, 1 or 2');
2477
+ }
2478
+ if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
2479
+ return new Date(NaN);
2480
+ }
2481
+ var dateStrings = splitDateString(argument);
2482
+ var date;
2483
+ if (dateStrings.date) {
2484
+ var parseYearResult = parseYear(dateStrings.date, additionalDigits);
2485
+ date = parseDate(parseYearResult.restDateString, parseYearResult.year);
2486
+ }
2487
+ if (!date || isNaN(date.getTime())) {
2488
+ return new Date(NaN);
2489
+ }
2490
+ var timestamp = date.getTime();
2491
+ var time = 0;
2492
+ var offset;
2493
+ if (dateStrings.time) {
2494
+ time = parseTime(dateStrings.time);
2495
+ if (isNaN(time)) {
2496
+ return new Date(NaN);
2497
+ }
2498
+ }
2499
+ if (dateStrings.timezone) {
2500
+ offset = parseTimezone(dateStrings.timezone);
2501
+ if (isNaN(offset)) {
2502
+ return new Date(NaN);
2503
+ }
2504
+ } else {
2505
+ var dirtyDate = new Date(timestamp + time);
2506
+ // js parsed string assuming it's in UTC timezone
2507
+ // but we need it to be parsed in our timezone
2508
+ // so we use utc values to build date in our timezone.
2509
+ // Year values from 0 to 99 map to the years 1900 to 1999
2510
+ // so set year explicitly with setFullYear.
2511
+ var result = new Date(0);
2512
+ result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());
2513
+ result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());
2514
+ return result;
2515
+ }
2516
+ return new Date(timestamp + time + offset);
2517
+ }
2518
+ var patterns = {
2519
+ dateTimeDelimiter: /[T ]/,
2520
+ timeZoneDelimiter: /[Z ]/i,
2521
+ timezone: /([Z+-].*)$/
2522
+ };
2523
+ var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
2524
+ var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
2525
+ var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
2526
+ function splitDateString(dateString) {
2527
+ var dateStrings = {};
2528
+ var array = dateString.split(patterns.dateTimeDelimiter);
2529
+ var timeString;
2530
+
2531
+ // The regex match should only return at maximum two array elements.
2532
+ // [date], [time], or [date, time].
2533
+ if (array.length > 2) {
2534
+ return dateStrings;
2535
+ }
2536
+ if (/:/.test(array[0])) {
2537
+ timeString = array[0];
2538
+ } else {
2539
+ dateStrings.date = array[0];
2540
+ timeString = array[1];
2541
+ if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
2542
+ dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
2543
+ timeString = dateString.substr(dateStrings.date.length, dateString.length);
2544
+ }
2545
+ }
2546
+ if (timeString) {
2547
+ var token = patterns.timezone.exec(timeString);
2548
+ if (token) {
2549
+ dateStrings.time = timeString.replace(token[1], '');
2550
+ dateStrings.timezone = token[1];
2551
+ } else {
2552
+ dateStrings.time = timeString;
2553
+ }
2554
+ }
2555
+ return dateStrings;
2556
+ }
2557
+ function parseYear(dateString, additionalDigits) {
2558
+ var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)');
2559
+ var captures = dateString.match(regex);
2560
+ // Invalid ISO-formatted year
2561
+ if (!captures) return {
2562
+ year: NaN,
2563
+ restDateString: ''
2564
+ };
2565
+ var year = captures[1] ? parseInt(captures[1]) : null;
2566
+ var century = captures[2] ? parseInt(captures[2]) : null;
2567
+
2568
+ // either year or century is null, not both
2569
+ return {
2570
+ year: century === null ? year : century * 100,
2571
+ restDateString: dateString.slice((captures[1] || captures[2]).length)
2572
+ };
2573
+ }
2574
+ function parseDate(dateString, year) {
2575
+ // Invalid ISO-formatted year
2576
+ if (year === null) return new Date(NaN);
2577
+ var captures = dateString.match(dateRegex);
2578
+ // Invalid ISO-formatted string
2579
+ if (!captures) return new Date(NaN);
2580
+ var isWeekDate = !!captures[4];
2581
+ var dayOfYear = parseDateUnit(captures[1]);
2582
+ var month = parseDateUnit(captures[2]) - 1;
2583
+ var day = parseDateUnit(captures[3]);
2584
+ var week = parseDateUnit(captures[4]);
2585
+ var dayOfWeek = parseDateUnit(captures[5]) - 1;
2586
+ if (isWeekDate) {
2587
+ if (!validateWeekDate(year, week, dayOfWeek)) {
2588
+ return new Date(NaN);
2589
+ }
2590
+ return dayOfISOWeekYear(year, week, dayOfWeek);
2591
+ } else {
2592
+ var date = new Date(0);
2593
+ if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
2594
+ return new Date(NaN);
2595
+ }
2596
+ date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
2597
+ return date;
2598
+ }
2599
+ }
2600
+ function parseDateUnit(value) {
2601
+ return value ? parseInt(value) : 1;
2602
+ }
2603
+ function parseTime(timeString) {
2604
+ var captures = timeString.match(timeRegex);
2605
+ if (!captures) return NaN; // Invalid ISO-formatted time
2606
+
2607
+ var hours = parseTimeUnit(captures[1]);
2608
+ var minutes = parseTimeUnit(captures[2]);
2609
+ var seconds = parseTimeUnit(captures[3]);
2610
+ if (!validateTime(hours, minutes, seconds)) {
2611
+ return NaN;
2612
+ }
2613
+ return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000;
2614
+ }
2615
+ function parseTimeUnit(value) {
2616
+ return value && parseFloat(value.replace(',', '.')) || 0;
2617
+ }
2618
+ function parseTimezone(timezoneString) {
2619
+ if (timezoneString === 'Z') return 0;
2620
+ var captures = timezoneString.match(timezoneRegex);
2621
+ if (!captures) return 0;
2622
+ var sign = captures[1] === '+' ? -1 : 1;
2623
+ var hours = parseInt(captures[2]);
2624
+ var minutes = captures[3] && parseInt(captures[3]) || 0;
2625
+ if (!validateTimezone(hours, minutes)) {
2626
+ return NaN;
2627
+ }
2628
+ return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
2629
+ }
2630
+ function dayOfISOWeekYear(isoWeekYear, week, day) {
2631
+ var date = new Date(0);
2632
+ date.setUTCFullYear(isoWeekYear, 0, 4);
2633
+ var fourthOfJanuaryDay = date.getUTCDay() || 7;
2634
+ var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
2635
+ date.setUTCDate(date.getUTCDate() + diff);
2636
+ return date;
2637
+ }
2638
+
2639
+ // Validation functions
2640
+
2641
+ // February is null to handle the leap year (using ||)
2642
+ var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2643
+ function isLeapYearIndex(year) {
2644
+ return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
2645
+ }
2646
+ function validateDate(year, month, date) {
2647
+ return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
2648
+ }
2649
+ function validateDayOfYearDate(year, dayOfYear) {
2650
+ return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
2651
+ }
2652
+ function validateWeekDate(_year, week, day) {
2653
+ return week >= 1 && week <= 53 && day >= 0 && day <= 6;
2654
+ }
2655
+ function validateTime(hours, minutes, seconds) {
2656
+ if (hours === 24) {
2657
+ return minutes === 0 && seconds === 0;
2658
+ }
2659
+ return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
2660
+ }
2661
+ function validateTimezone(_hours, minutes) {
2662
+ return minutes >= 0 && minutes <= 59;
2663
+ }
2664
+
2665
+ function fetchRequest(url, method = 'GET', body = null, headers = {}) {
2666
+ return new Promise((resolve, reject) => {
2667
+ const headersOrigin = Object.assign({ 'Content-Type': 'application/json' }, headers);
2668
+ const options = {
2669
+ method,
2670
+ headers: headersOrigin,
2671
+ body: null
2672
+ };
2673
+ if (body && method !== 'GET' && method !== 'HEAD') {
2674
+ options.body = JSON.stringify(body);
2675
+ }
2676
+ else {
2677
+ delete options.body;
2678
+ }
2679
+ fetch(url, options)
2680
+ .then((response) => {
2681
+ if (!response.ok) {
2682
+ return response.json().then((errorData) => {
2683
+ const error = {
2684
+ status: response.status,
2685
+ statusText: response.statusText,
2686
+ code: errorData.code || 'UNKNOWN_ERROR',
2687
+ message: errorData.message || 'An unknown error occurred',
2688
+ data: errorData.data || null
2689
+ };
2690
+ reject(error);
2691
+ }, () => reject({
2692
+ status: response.status,
2693
+ statusText: response.statusText,
2694
+ code: 'PARSE_ERROR',
2695
+ message: 'Failed to parse error response'
2696
+ }));
2697
+ }
2698
+ else {
2699
+ return response.json();
2700
+ }
2701
+ })
2702
+ .then((data) => resolve(data), (error) => reject(error));
2703
+ });
2704
+ }
2705
+ function formattedTime(date) {
2706
+ if (!date) {
2707
+ return '';
2708
+ }
2709
+ const parsedDate = parseISO(date);
2710
+ if (isNaN(parsedDate.getTime())) {
2711
+ return '';
2712
+ }
2713
+ const hhmm = format(parsedDate, 'HH:mm');
2714
+ if (isToday(parsedDate))
2715
+ return `Today at ${hhmm}`;
2716
+ if (isTomorrow(parsedDate))
2717
+ return `Tomorrow at ${hhmm}`;
2718
+ const weekday = format(parsedDate, 'EEEE');
2719
+ return `${weekday} at ${hhmm}`;
2720
+ }
2721
+ function toQueryParams(params) {
2722
+ const finalParams = {};
2723
+ Object.entries(params).forEach(([key, value]) => {
2724
+ if (!isEmptyValue(value, true)) {
2725
+ finalParams[key] = value;
2726
+ }
2727
+ });
2728
+ const queryString = Object.entries(finalParams)
2729
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
2730
+ .join('&');
2731
+ return queryString ? `?${queryString}` : '';
2732
+ }
2733
+ function isEmptyValue(value, allowZero) {
2734
+ if (value === null || value === undefined || value === '') {
2735
+ return true;
2736
+ }
2737
+ else if (value === 0 && allowZero) {
2738
+ return false;
2739
+ }
2740
+ else if (Array.isArray(value)) {
2741
+ return isEmptyValueOfArray(value);
2742
+ }
2743
+ else if (Object.prototype.toString.call(value) === '[object Object]') {
2744
+ return isEmptyValueOfObject(value);
2745
+ }
2746
+ else {
2747
+ return !value;
2748
+ }
2749
+ }
2750
+ function isEmptyValueOfArray(arr) {
2751
+ if (arr.length === 0) {
2752
+ return true;
2753
+ }
2754
+ const len = arr.length;
2755
+ let count = 0;
2756
+ for (let i = 0; i < len; i++) {
2757
+ if (isEmptyValue(arr[i])) {
2758
+ count++;
2759
+ }
2760
+ else {
2761
+ return false;
2762
+ }
2763
+ }
2764
+ if (count === len) {
2765
+ return true;
2766
+ }
2767
+ return false;
2768
+ }
2769
+ function isEmptyValueOfObject(obj) {
2770
+ if (Object.keys(obj).length === 0) {
2771
+ return true;
2772
+ }
2773
+ const len = Object.keys(obj).length;
2774
+ let count = 0;
2775
+ for (const val of Object.values(obj)) {
2776
+ if (isEmptyValue(val)) {
2777
+ count++;
2778
+ }
2779
+ else {
2780
+ return false;
2781
+ }
2782
+ }
2783
+ if (count === len) {
2784
+ return true;
2785
+ }
2786
+ return false;
2787
+ }
2788
+ const DEFAULT_ALL_BOMB = { name: 'All', code: 'All' };
2789
+ function thousandSeparator(value) {
2790
+ if (value === 0) {
2791
+ return '0';
2792
+ }
2793
+ if (!value) {
2794
+ return '';
2795
+ }
2796
+ value = value.toString();
2797
+ const parts = value.split('.');
2798
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
2799
+ return parts.join('.');
2800
+ }
2801
+
2802
+ async function fetchLiveDrawsByGroupId({ endpoint, groupId, params = {} }) {
2803
+ try {
2804
+ const res = await fetchRequest(`${endpoint}/groups/${groupId}/liveDraws${toQueryParams(params)}`);
2805
+ return res;
2806
+ }
2807
+ catch (error) {
2808
+ console.error('Failed to fetch game info:', error);
2809
+ return {};
2810
+ }
2811
+ }
2812
+ async function fetchSaleStatistics({ endpoint, gameId, drawId }) {
2813
+ try {
2814
+ const res = await fetchRequest(`${endpoint}/games/${gameId}/draws/${drawId}/saleStatistics`);
2815
+ return res;
2816
+ }
2817
+ catch (error) {
2818
+ return Promise.reject(error);
2819
+ }
2820
+ }
2821
+ async function fetchData({ endpoint, groupId, params }) {
2822
+ try {
2823
+ const { sportTags = [], liveDraws = [] } = await fetchLiveDrawsByGroupId({
2824
+ endpoint,
2825
+ groupId,
2826
+ params
2827
+ });
2828
+ return {
2829
+ sportTags: sportTags.map((i) => ({ name: i, code: i })),
2830
+ liveDraws: liveDraws.map((i) => ({
2831
+ title: i.gameName,
2832
+ subTitle: i.sportTag,
2833
+ icon: i.sportTag,
2834
+ date: formattedTime(i.drawCloseTime),
2835
+ turnover: formattedTurnover(null),
2836
+ matchList: i.matchs.map((i) => i.eventName),
2837
+ drawId: i.drawId,
2838
+ gameId: i.gameId
2839
+ }))
2840
+ };
2841
+ }
2842
+ catch (_a) {
2843
+ return {
2844
+ sportTags: [],
2845
+ liveDraws: []
2846
+ };
2847
+ }
2848
+ }
2849
+ async function getTurnoverForAll({ endpoint, configs }) {
2850
+ const fallback = { turnover: formattedTurnover(null) };
2851
+ const promises = configs.map(async ({ gameId, drawId }) => {
2852
+ var _a;
2853
+ const res = await fetchSaleStatistics({
2854
+ endpoint: endpoint,
2855
+ gameId,
2856
+ drawId
2857
+ });
2858
+ return { turnover: formattedTurnover((_a = res === null || res === void 0 ? void 0 : res.wagerSegment) === null || _a === void 0 ? void 0 : _a.totalSalesCrossDraw) };
2859
+ });
2860
+ const results = await Promise.allSettled(promises);
2861
+ return results.map((r) => (r.status === 'fulfilled' ? r.value : fallback));
2862
+ }
2863
+ function formattedTurnover(turnover) {
2864
+ if (turnover === null)
2865
+ return '';
2866
+ const unit = '€';
2867
+ return `${unit}${turnover ? thousandSeparator(turnover) : 0}`;
2868
+ }
2869
+
2870
+ const DEFAULT_LANGUAGE = 'en';
2871
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
2872
+ const TRANSLATIONS = {
2873
+ en: {
2874
+ logout: 'Log out',
2875
+ draws: 'DRAWS',
2876
+ latestResults: 'LATEST RESULTS',
2877
+ instruction: 'INSTRUCTION',
2878
+ howToWin: 'HOW TO WIN',
2879
+ selectDraws: 'Select Draws from the following bars:',
2880
+ gameNotAvailable: 'Sorry. The Game is not available now.',
2881
+ instructionContent: 'Instruction content goes here.',
2882
+ turnover: 'Turnover: '
2883
+ },
2884
+ ro: {
2885
+ logout: 'Deconectare',
2886
+ draws: 'EXTRAGERI',
2887
+ latestResults: 'ULTIMELE REZULTATE',
2888
+ instruction: 'INSTRUCȚIUNI',
2889
+ howToWin: 'CUM SĂ CÂȘTIGI',
2890
+ selectDraws: 'Selectați extrageri din barele următoare:',
2891
+ gameNotAvailable: 'Ne pare rău. Jocul nu este disponibil acum.',
2892
+ instructionContent: 'Conținutul instrucțiunilor se afișează aici.'
2893
+ },
2894
+ fr: {
2895
+ logout: 'Se déconnecter',
2896
+ draws: 'TIRAGES',
2897
+ latestResults: 'DERNIERS RÉSULTATS',
2898
+ instruction: 'INSTRUCTION',
2899
+ howToWin: 'COMMENT GAGNER',
2900
+ selectDraws: 'Sélectionnez les tirages dans les barres suivantes:',
2901
+ gameNotAvailable: 'Désolé. Le jeu nest pas disponible pour le moment.',
2902
+ instructionContent: 'Le contenu des instructions va ici.'
2903
+ },
2904
+ ar: {
2905
+ logout: 'تسجيل الخروج',
2906
+ draws: 'السحوبات',
2907
+ latestResults: 'أحدث النتائج',
2908
+ instruction: 'التعليمات',
2909
+ howToWin: 'كيفية الفوز',
2910
+ selectDraws: 'حدد السحوبات من الأشرطة التالية:',
2911
+ gameNotAvailable: 'آسف. اللعبة غير متوفرة الآن.',
2912
+ instructionContent: 'محتوى التعليمات يذهب هنا.'
2913
+ },
2914
+ hr: {
2915
+ logout: 'Odjava',
2916
+ draws: 'IZVLAČENJA',
2917
+ latestResults: 'NAJNOVIJI REZULTATI',
2918
+ instruction: 'UPUTE',
2919
+ howToWin: 'KAKO POBIJEDITI',
2920
+ selectDraws: 'Odaberite izvlačenja sa sljedećih traka:',
2921
+ gameNotAvailable: 'Žao nam je. Igra trenutno nije dostupna.',
2922
+ instructionContent: 'Sadržaj uputa ide ovdje.'
2923
+ }
2924
+ };
2925
+ const translate = (key, customLang) => {
2926
+ const lang = customLang;
2927
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
2928
+ };
2929
+
2930
+ const lotteryOddsbomBombCss = "/* --- Component: Bomb Card Grid --- */\n.lottery-oddsbom-bomb-wrapper {\n background: var(--emw--color-background, #fff);\n color: var(--emw--color-typography, #000);\n height: 100%;\n}\n\n.bomb-grid-container {\n width: 100%;\n display: flex;\n justify-content: center;\n container-type: inline-size;\n container-name: bomb-grid;\n background: var(--emw--color-background, #fff);\n color: var(--emw--color-typography, #000);\n /* --- Component: Bomb Card --- */\n}\n.bomb-grid-container .bomb-grid {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 0.75rem;\n place-items: center;\n}\n.bomb-grid-container .bomb-card-wrapper {\n width: 100%;\n max-width: 30rem;\n height: 100%;\n box-sizing: border-box;\n border-radius: 8px;\n padding: 1rem;\n border: 1px solid var(--emw--color-gray-100, #e6e6e6);\n}\n.bomb-grid-container .bomb-card {\n height: 100%;\n min-width: 24rem;\n transition: transform 0.3s;\n}\n.bomb-grid-container .bomb-card:hover {\n transform: scale(1.02);\n cursor: pointer;\n}\n.bomb-grid-container .card-header {\n display: flex;\n align-items: center;\n gap: 1rem;\n margin-bottom: 0.8rem;\n}\n.bomb-grid-container .card-icon {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.bomb-grid-container .card-icon svg {\n width: 28px;\n height: 28px;\n}\n.bomb-grid-container .card-title {\n flex-grow: 1;\n word-break: break-all;\n}\n.bomb-grid-container .card-title h2 {\n margin: 0;\n font-size: 1.25rem;\n font-weight: 700;\n word-wrap: break-word;\n}\n.bomb-grid-container .card-title p {\n margin: 0;\n color: var(--emw--color-typography-secondary, #333);\n font-size: 0.9rem;\n word-wrap: break-word;\n}\n.bomb-grid-container .card-info {\n display: flex;\n gap: 0.75rem;\n margin-bottom: 0.8rem;\n flex-wrap: wrap;\n}\n.bomb-grid-container .card-tag {\n background-color: var(--emw--color-tertiary, #e3f2fd);\n padding: 0.3rem 0.75rem;\n border-radius: 4px;\n font-size: 0.85rem;\n font-weight: 500;\n max-width: 120px;\n}\n.bomb-grid-container .card-matches {\n max-height: 6.8rem;\n overflow-y: auto;\n}\n.bomb-grid-container .card-matches ol {\n margin: 0;\n padding-left: 1.25rem;\n font-size: 0.85rem;\n line-height: 1.6;\n}\n.bomb-grid-container .card-matches li {\n padding-left: 0.2rem;\n word-wrap: break-word;\n}\n\n/* --- CONTAINER QUERIES FOR RESPONSIVENESS --- */\n@container bomb-grid (max-width: 768px) {\n .bomb-grid-container .bomb-grid {\n /* On smaller containers, switch to a single column */\n grid-template-columns: 1fr;\n }\n .bomb-card-wrapper .bomb-card {\n min-width: 200px;\n }\n}\n/* --- Component: Filter Controls --- */\n.OddsbomEntranceController__section {\n margin: 1.5rem 0;\n display: flex;\n gap: 12px;\n color: var(--emw--color-typography, #000);\n container-type: inline-size;\n container-name: controller;\n justify-content: center;\n}\n.OddsbomEntranceController__label {\n font-weight: 500;\n white-space: nowrap;\n width: 6rem;\n line-height: 2.2rem;\n}\n.OddsbomEntranceController__segmented-control {\n display: inline-flex;\n gap: 1rem;\n flex-wrap: wrap;\n}\n.OddsbomEntranceController__segment {\n height: 2.2rem;\n border: none;\n padding: 0.3rem 0.8rem;\n cursor: pointer;\n font-weight: 500;\n border-radius: 2rem;\n outline: none;\n white-space: nowrap;\n background-color: var(--emw--color-background, #ffffff);\n color: var(--emw--color-typography, #000);\n}\n.OddsbomEntranceController__segment--active {\n background-color: var(--emw--color-primary-variant, #1367e7);\n color: var(--emw--color-typography-reverse, #fff);\n font-weight: 600;\n}\n.OddsbomEntranceController__segment--disabled:hover {\n cursor: not-allowed !important;\n}\n.OddsbomEntranceController__segment:not(.OddsbomEntranceController__segment--active):hover {\n background-color: var(--emw--color-background-tertiary, #ccc);\n}\n\n.skeleton-content {\n display: flex;\n flex-direction: column;\n gap: 29px;\n align-items: center;\n}\n\n.skeleton-item {\n background: var(--emw--color-background-secondary, #f5f5f5);\n border-radius: 4px;\n height: 40px;\n width: 200px;\n}\n\n.skeleton-animated {\n animation: skeleton-shimmer 1.5s infinite linear;\n background: linear-gradient(90deg, var(--emw--color-background-secondary, #f5f5f5) 25%, var(--emw--color-background-tertiary, #ccc) 37%, var(--emw--color-background-secondary, #f5f5f5) 63%);\n background-size: 200% 100%;\n}\n\n@keyframes skeleton-shimmer {\n to {\n background-position: 100% 0;\n }\n}\n.loading-icon.scale {\n animation: scale 1s infinite ease-in-out;\n}\n\n@keyframes scale {\n 0%, 100% {\n transform: scale(1);\n }\n 50% {\n transform: scale(1.2);\n }\n}\n@container controller (max-width: 500px) {\n .OddsbomEntranceController__segmented-control {\n gap: 0rem;\n }\n .OddsbomEntranceController__segment {\n padding: 0.2rem 0.6rem;\n }\n .OddsbomEntranceController__label,\n .OddsbomEntranceController____segment {\n line-height: 1.8rem;\n }\n}\n.loading-wrap {\n margin: 20px 0;\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100px;\n}\n.loading-wrap .dots-container {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n width: 100%;\n}\n.loading-wrap .dot {\n height: 14px;\n width: 14px;\n margin-right: 14px;\n border-radius: 14px;\n background-color: var(--emw--color-gray-300, #333);\n animation: pulse 1.5s infinite ease-in-out;\n}\n.loading-wrap .dot:last-child {\n margin-right: 0;\n}\n.loading-wrap .dot:nth-child(1) {\n animation-delay: -0.3s;\n}\n.loading-wrap .dot:nth-child(2) {\n animation-delay: -0.1s;\n}\n.loading-wrap .dot:nth-child(3) {\n animation-delay: 0.1s;\n}\n@keyframes pulse {\n 0% {\n transform: scale(0.8);\n background-color: var(--emw--color-gray-300, #333);\n }\n 50% {\n transform: scale(1.2);\n background-color: var(--emw--color-gray-100, #e6e6e6);\n }\n 100% {\n transform: scale(0.8);\n background-color: var(--emw--color-gray-150, #6f6f6f);\n }\n}\n\n.empty-draw-wrap {\n padding-top: 100px;\n}\n.empty-draw-wrap .empty-draw {\n width: 240px;\n height: 160px;\n padding: 18px 12px 12px 12px;\n background: var(--emw--color-secondary-variant, #e3f2fd);\n position: relative;\n margin: 0 auto;\n display: flex;\n justify-content: center;\n align-items: center;\n text-align: center;\n border-radius: 12px;\n}\n.empty-draw-wrap .empty-draw img {\n position: absolute;\n top: -64%;\n left: 50%;\n transform: translateX(-50%);\n width: 200px;\n}\n.empty-draw-wrap .empty-draw-content {\n display: flex;\n gap: 4px;\n}\n.empty-draw-wrap .empty-draw-text {\n font-size: 14px;\n font-weight: bold;\n line-height: 20px;\n}";
2931
+ const LotteryOddsbomBombStyle0 = lotteryOddsbomBombCss;
2932
+
2933
+ const BombIcons = {
2934
+ [Bomb.Football]: (h("svg", { height: "18px", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", class: "text-sm" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M19.063 19.072l-.81-.97-.117.083.385-2.43.136-.211 2.23-3.464.037-.057h1.075a9.964 9.964 0 01-2.936 7.049zM4.769 5.112l2.8.877-.072 3.246-2.427 2.95-1.561-.153L2.39 9.26a9.977 9.977 0 012.378-4.148zm7.745-3.086l-.72 1.645-3.798 1.404-2.395-.75A9.953 9.953 0 0112 2c.174 0 .343.017.514.026zm7.346 3.812l-1.128 1.29-3.402-.755-.033-.008-2.446-2.241.057.016.862-1.973a9.996 9.996 0 016.09 3.67zm-1.87 8.894l-3.385-.493-1.358-4.067 2.173-2.755 3.144.698 1.347 3.634-1.921 2.983zm-4.64 5.787l4.304-1.486.62.742a9.945 9.945 0 01-5.878 2.205l.954-1.461zm-6.314-2.84l3.91.873-.001.003 1.509 1.507-1.24 1.898a9.946 9.946 0 01-5.908-2.553l1.73-1.728zm1.16-7.72l4.168.725 1.302 3.9-2.552 2.98-3.97-.885-1.412-3.724L8.196 9.96zM2 12c0-.31.019-.615.047-.92l.485 1.203-.454.907A9.934 9.934 0 012 11.999zM12 1C5.934 1 1 5.935 1 12c0 6.067 4.935 11 11 11 6.066 0 11-4.933 11-11 0-6.065-4.934-11-11-11z", fill: "currentColor" })))
2935
+ };
2936
+ const LotteryOddsbomBomb = class {
2937
+ constructor(hostRef) {
2938
+ registerInstance(this, hostRef);
2939
+ this.handleBombItemClick = createEvent(this, "handleBombItemClick", 7);
2940
+ this.mbSource = undefined;
2941
+ this.clientStyling = undefined;
2942
+ this.clientStylingUrl = undefined;
2943
+ this.translationUrl = '';
2944
+ this.language = 'en';
2945
+ this.endpoint = undefined;
2946
+ this.groupId = undefined;
2947
+ this.activeBomb = 'All';
2948
+ this.bombList = [];
2949
+ this.gameList = [];
2950
+ this.liveDrawsInfoByGroupId = {};
2951
+ this.isLoading = false;
2952
+ }
2953
+ handleClientStylingChange(newValue, oldValue) {
2954
+ if (newValue != oldValue) {
2955
+ setClientStyling(this.stylingContainer, this.clientStyling);
2956
+ }
2957
+ }
2958
+ handleClientStylingUrlChange(newValue, oldValue) {
2959
+ if (newValue != oldValue) {
2960
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
2961
+ }
2962
+ }
2963
+ handleMbSourceChange(newValue, oldValue) {
2964
+ if (newValue != oldValue) {
2965
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
2966
+ }
2967
+ }
2968
+ componentDidLoad() {
2969
+ if (this.stylingContainer) {
2970
+ if (this.mbSource)
2971
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`);
2972
+ if (this.clientStyling)
2973
+ setClientStyling(this.stylingContainer, this.clientStyling);
2974
+ if (this.clientStylingUrl)
2975
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
2976
+ }
2977
+ }
2978
+ disconnectedCallback() {
2979
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
2980
+ }
2981
+ connectedCallback() {
2982
+ this.doFetchData();
2983
+ }
2984
+ async doFetchData(params = {}) {
2985
+ try {
2986
+ this.isLoading = true;
2987
+ this.liveDrawsInfoByGroupId = await fetchData({
2988
+ endpoint: this.endpoint,
2989
+ groupId: this.groupId,
2990
+ params
2991
+ });
2992
+ this.gameList = this.liveDrawsInfoByGroupId.liveDraws;
2993
+ this.bombList = [DEFAULT_ALL_BOMB, ...this.liveDrawsInfoByGroupId.sportTags];
2994
+ this.isLoading = false;
2995
+ this.updateTurnoverForAll();
2996
+ }
2997
+ finally {
2998
+ this.isLoading = false;
2999
+ }
3000
+ }
3001
+ async updateTurnoverForAll() {
3002
+ const turnovers = getTurnoverForAll({
3003
+ endpoint: this.endpoint,
3004
+ configs: this.gameList.map((item) => ({ gameId: item.gameId, drawId: item.drawId }))
3005
+ });
3006
+ for (let i = 0; i < this.gameList.length; i++) {
3007
+ this.gameList[i].turnover = (await turnovers)[i].turnover;
3008
+ }
3009
+ this.gameList = [...this.gameList];
3010
+ }
3011
+ handleBombChange(code) {
3012
+ this.activeBomb = code;
3013
+ if (code === DEFAULT_ALL_BOMB.code) {
3014
+ this.doFetchData();
3015
+ }
3016
+ else {
3017
+ this.doFetchData({ sportTag: code });
3018
+ }
3019
+ }
3020
+ renderLoading() {
3021
+ return (h("div", { class: "loading-wrap" }, h("section", { class: "dots-container" }, h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }))));
3022
+ }
3023
+ renderEmpty() {
3024
+ const infoImagePath = getAssetPath('../static/empty-info.svg');
3025
+ return (h("div", { class: "empty-draw-wrap" }, h("div", { class: "empty-draw" }, h("img", { src: infoImagePath, class: "empty-draw-logo" }), h("div", { class: "empty-draw-content" }, h("div", { class: "empty-draw-text" }, "\u24D8 Sorry. The game is not available now.")))));
3026
+ }
3027
+ renderFilter() {
3028
+ return (h("div", { class: "OddsbomEntranceController__section" }, h("span", { class: "OddsbomEntranceController__label" }, "Select Bomb:"), !!this.bombList.length ? (h("div", { class: "OddsbomEntranceController__segmented-control" }, this.bombList.map(({ name, code }) => (h("button", { class: {
3029
+ OddsbomEntranceController__segment: true,
3030
+ 'OddsbomEntranceController__segment--active': this.activeBomb === code
3031
+ }, onClick: this.handleBombChange.bind(this, code) }, name))))) : (h("div", { class: "skeleton-content" }, h("div", { class: "skeleton-item skeleton-animated" })))));
3032
+ }
3033
+ renderMain() {
3034
+ if (!this.gameList.length)
3035
+ return this.renderEmpty();
3036
+ return (h("div", { class: "bomb-grid" }, this.gameList.map(({ title, subTitle, icon, date, turnover, matchList, drawId, gameId }) => (h("div", { class: "bomb-card-wrapper" }, h("div", { class: "bomb-card", onClick: () => {
3037
+ this.handleBombItemClick.emit({ drawId, gameId });
3038
+ } }, h("div", { class: "card-header" }, BombIcons[icon] && h("div", { class: "card-icon football" }, BombIcons[icon]), h("div", { class: "card-title" }, h("h2", null, title), h("p", null, subTitle)), h("div", { class: "card-jackpot" })), h("div", { class: "card-info" }, h("span", { class: "card-tag" }, date), h("span", { class: "card-tag" }, translate('turnover', this.language) + turnover)), h("div", { class: "card-matches" }, h("ol", null, matchList.map((item) => (h("li", null, item)))))))))));
3039
+ }
3040
+ render() {
3041
+ return (h("div", { key: 'ae8252d8cb1374af9bb8189bcd9edac313c7bc6a', ref: (el) => (this.stylingContainer = el), class: "lottery-oddsbom-bomb-wrapper" }, this.renderFilter(), h("div", { key: '3f673f335248057370e7e57076cc387a86dc4099', class: "bomb-grid-container" }, this.isLoading ? this.renderLoading() : this.renderMain())));
3042
+ }
3043
+ static get assetsDirs() { return ["../static"]; }
3044
+ static get watchers() { return {
3045
+ "clientStyling": ["handleClientStylingChange"],
3046
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
3047
+ "mbSource": ["handleMbSourceChange"]
3048
+ }; }
3049
+ };
3050
+ LotteryOddsbomBomb.style = LotteryOddsbomBombStyle0;
3051
+
3052
+ export { LotteryOddsbomBomb as L };