@paperless/core 0.1.0-alpha.303 → 0.1.0-alpha.304

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