@rededor/cura 1.6.0 → 1.6.1-alpha.0

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 (32) hide show
  1. package/dist/cjs/cura-calendar.cjs.entry.js +2997 -198
  2. package/dist/cjs/cura-calendar.cjs.entry.js.map +1 -1
  3. package/dist/cjs/cura.cjs.js +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/collection/components/accordion/cura-accordion-item/cura-accordion-item.css +6 -2
  6. package/dist/collection/components/cura-calendar/cura-calendar.css +35 -4
  7. package/dist/collection/components/cura-calendar/cura-calendar.js +17 -9
  8. package/dist/collection/components/cura-calendar/cura-calendar.js.map +1 -1
  9. package/dist/collection/components/cura-calendar/cura-calendar.stories.js +0 -1
  10. package/dist/collection/components/cura-calendar/cura-calendar.stories.js.map +1 -1
  11. package/dist/collection/components/cura-modal/cura-modal.css +6 -2
  12. package/dist/collection/components/cura-page-template/cura-page-template.css +6 -2
  13. package/dist/collection/components/cura-toast/cura-toast.css +6 -2
  14. package/dist/collection/components/cura-tooltip/cura-tooltip.css +6 -2
  15. package/dist/collection/components/forms/cura-label/cura-label.css +6 -2
  16. package/dist/collection/components/text/cura-display/cura-display.css +6 -2
  17. package/dist/collection/components/text/cura-heading/cura-heading.css +6 -2
  18. package/dist/collection/components/text/cura-paragraph/cura-paragraph.css +6 -2
  19. package/dist/components/cura-calendar2.js +2999 -200
  20. package/dist/components/cura-calendar2.js.map +1 -1
  21. package/dist/cura/cura.esm.js +1 -1
  22. package/dist/cura/cura.esm.js.map +1 -1
  23. package/dist/cura/p-2090e71a.entry.js +2 -0
  24. package/dist/cura/p-2090e71a.entry.js.map +1 -0
  25. package/dist/esm/cura-calendar.entry.js +2997 -198
  26. package/dist/esm/cura-calendar.entry.js.map +1 -1
  27. package/dist/esm/cura.js +1 -1
  28. package/dist/esm/loader.js +1 -1
  29. package/dist/types/components/cura-calendar/cura-calendar.stories.d.ts +0 -1
  30. package/package.json +2 -2
  31. package/dist/cura/p-62c1b0f4.entry.js +0 -2
  32. package/dist/cura/p-62c1b0f4.entry.js.map +0 -1
@@ -279,6 +279,16 @@ var millisecondsInMinute = 60000;
279
279
  */
280
280
  var millisecondsInHour = 3600000;
281
281
 
282
+ /**
283
+ * Milliseconds in 1 second
284
+ *
285
+ * @name millisecondsInSecond
286
+ * @constant
287
+ * @type {number}
288
+ * @default
289
+ */
290
+ var millisecondsInSecond = 1000;
291
+
282
292
  /**
283
293
  * @name isSameDay
284
294
  * @category Day Helpers
@@ -2236,14 +2246,14 @@ const defaultLocale = locale$2;
2236
2246
  // If there is no matching single quote
2237
2247
  // then the sequence will continue until the end of the string.
2238
2248
  // - . matches any single character unmatched by previous parts of the RegExps
2239
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2249
+ var formattingTokensRegExp$1 = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2240
2250
 
2241
2251
  // This RegExp catches symbols escaped by quotes, and also
2242
2252
  // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2243
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2244
- var escapedStringRegExp = /^'([^]*?)'?$/;
2245
- var doubleQuoteRegExp = /''/g;
2246
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2253
+ var longFormattingTokensRegExp$1 = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2254
+ var escapedStringRegExp$1 = /^'([^]*?)'?$/;
2255
+ var doubleQuoteRegExp$1 = /''/g;
2256
+ var unescapedLatinCharacterRegExp$1 = /[a-zA-Z]/;
2247
2257
 
2248
2258
  /**
2249
2259
  * @name format
@@ -2577,21 +2587,21 @@ function format(dirtyDate, dirtyFormatStr, options) {
2577
2587
  locale: locale,
2578
2588
  _originalDate: originalDate
2579
2589
  };
2580
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2590
+ var result = formatStr.match(longFormattingTokensRegExp$1).map(function (substring) {
2581
2591
  var firstCharacter = substring[0];
2582
2592
  if (firstCharacter === 'p' || firstCharacter === 'P') {
2583
2593
  var longFormatter = longFormatters$1[firstCharacter];
2584
2594
  return longFormatter(substring, locale.formatLong);
2585
2595
  }
2586
2596
  return substring;
2587
- }).join('').match(formattingTokensRegExp).map(function (substring) {
2597
+ }).join('').match(formattingTokensRegExp$1).map(function (substring) {
2588
2598
  // Replace two single quote characters with one single quote character
2589
2599
  if (substring === "''") {
2590
2600
  return "'";
2591
2601
  }
2592
2602
  var firstCharacter = substring[0];
2593
2603
  if (firstCharacter === "'") {
2594
- return cleanEscapedString(substring);
2604
+ return cleanEscapedString$1(substring);
2595
2605
  }
2596
2606
  var formatter = formatters$1[firstCharacter];
2597
2607
  if (formatter) {
@@ -2603,19 +2613,31 @@ function format(dirtyDate, dirtyFormatStr, options) {
2603
2613
  }
2604
2614
  return formatter(utcDate, substring, locale.localize, formatterOptions);
2605
2615
  }
2606
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2616
+ if (firstCharacter.match(unescapedLatinCharacterRegExp$1)) {
2607
2617
  throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2608
2618
  }
2609
2619
  return substring;
2610
2620
  }).join('');
2611
2621
  return result;
2612
2622
  }
2613
- function cleanEscapedString(input) {
2614
- var matched = input.match(escapedStringRegExp);
2623
+ function cleanEscapedString$1(input) {
2624
+ var matched = input.match(escapedStringRegExp$1);
2615
2625
  if (!matched) {
2616
2626
  return input;
2617
2627
  }
2618
- return matched[1].replace(doubleQuoteRegExp, "'");
2628
+ return matched[1].replace(doubleQuoteRegExp$1, "'");
2629
+ }
2630
+
2631
+ function assign(target, object) {
2632
+ if (target == null) {
2633
+ throw new TypeError('assign requires that input parameter not be null or undefined');
2634
+ }
2635
+ for (var property in object) {
2636
+ if (Object.prototype.hasOwnProperty.call(object, property)) {
2637
+ target[property] = object[property];
2638
+ }
2639
+ }
2640
+ return target;
2619
2641
  }
2620
2642
 
2621
2643
  /**
@@ -2688,205 +2710,2977 @@ function getYear(dirtyDate) {
2688
2710
  return index.toDate(dirtyDate).getFullYear();
2689
2711
  }
2690
2712
 
2691
- /**
2692
- * @name isToday
2693
- * @category Day Helpers
2694
- * @summary Is the given date today?
2695
- * @pure false
2696
- *
2697
- * @description
2698
- * Is the given date today?
2699
- *
2700
- * > ⚠️ Please note that this function is not present in the FP submodule as
2701
- * > it uses `Date.now()` internally hence impure and can't be safely curried.
2702
- *
2703
- * @param {Date|Number} date - the date to check
2704
- * @returns {Boolean} the date is today
2705
- * @throws {TypeError} 1 argument required
2706
- *
2707
- * @example
2708
- * // If today is 6 October 2014, is 6 October 14:00:00 today?
2709
- * const result = isToday(new Date(2014, 9, 6, 14, 0))
2710
- * //=> true
2711
- */
2712
- function isToday(dirtyDate) {
2713
- index.requiredArgs(1, arguments);
2714
- return isSameDay(dirtyDate, Date.now());
2713
+ function _arrayLikeToArray(r, a) {
2714
+ (null == a || a > r.length) && (a = r.length);
2715
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
2716
+ return n;
2715
2717
  }
2716
2718
 
2717
- /**
2718
- * @name subDays
2719
- * @category Day Helpers
2720
- * @summary Subtract the specified number of days from the given date.
2721
- *
2722
- * @description
2723
- * Subtract the specified number of days from the given date.
2724
- *
2725
- * @param {Date|Number} date - the date to be changed
2726
- * @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
2727
- * @returns {Date} the new date with the days subtracted
2728
- * @throws {TypeError} 2 arguments required
2729
- *
2730
- * @example
2731
- * // Subtract 10 days from 1 September 2014:
2732
- * const result = subDays(new Date(2014, 8, 1), 10)
2733
- * //=> Fri Aug 22 2014 00:00:00
2734
- */
2735
- function subDays(dirtyDate, dirtyAmount) {
2736
- index.requiredArgs(2, arguments);
2737
- var amount = toInteger(dirtyAmount);
2738
- return addDays(dirtyDate, -amount);
2719
+ function _unsupportedIterableToArray(r, a) {
2720
+ if (r) {
2721
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2722
+ var t = {}.toString.call(r).slice(8, -1);
2723
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
2724
+ }
2739
2725
  }
2740
2726
 
2741
- /**
2742
- * @name parseISO
2743
- * @category Common Helpers
2744
- * @summary Parse ISO string
2745
- *
2746
- * @description
2747
- * Parse the given string in ISO 8601 format and return an instance of Date.
2748
- *
2749
- * Function accepts complete ISO 8601 formats as well as partial implementations.
2750
- * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
2751
- *
2752
- * If the argument isn't a string, the function cannot parse the string or
2753
- * the values are invalid, it returns Invalid Date.
2754
- *
2755
- * @param {String} argument - the value to convert
2756
- * @param {Object} [options] - an object with options.
2757
- * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
2758
- * @returns {Date} the parsed date in the local time zone
2759
- * @throws {TypeError} 1 argument required
2760
- * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
2761
- *
2762
- * @example
2763
- * // Convert string '2014-02-11T11:30:30' to date:
2764
- * const result = parseISO('2014-02-11T11:30:30')
2765
- * //=> Tue Feb 11 2014 11:30:30
2766
- *
2767
- * @example
2768
- * // Convert string '+02014101' to date,
2769
- * // if the additional number of digits in the extended year format is 1:
2770
- * const result = parseISO('+02014101', { additionalDigits: 1 })
2771
- * //=> Fri Apr 11 2014 00:00:00
2772
- */
2773
- function parseISO(argument, options) {
2774
- var _options$additionalDi;
2775
- index.requiredArgs(1, arguments);
2776
- var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);
2777
- if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
2778
- throw new RangeError('additionalDigits must be 0, 1 or 2');
2727
+ function _createForOfIteratorHelper(r, e) {
2728
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2729
+ if (!t) {
2730
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
2731
+ t && (r = t);
2732
+ var _n = 0,
2733
+ F = function F() {};
2734
+ return {
2735
+ s: F,
2736
+ n: function n() {
2737
+ return _n >= r.length ? {
2738
+ done: !0
2739
+ } : {
2740
+ done: !1,
2741
+ value: r[_n++]
2742
+ };
2743
+ },
2744
+ e: function e(r) {
2745
+ throw r;
2746
+ },
2747
+ f: F
2748
+ };
2749
+ }
2750
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2779
2751
  }
2780
- if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
2781
- return new Date(NaN);
2752
+ var o,
2753
+ a = !0,
2754
+ u = !1;
2755
+ return {
2756
+ s: function s() {
2757
+ t = t.call(r);
2758
+ },
2759
+ n: function n() {
2760
+ var r = t.next();
2761
+ return a = r.done, r;
2762
+ },
2763
+ e: function e(r) {
2764
+ u = !0, o = r;
2765
+ },
2766
+ f: function f() {
2767
+ try {
2768
+ a || null == t["return"] || t["return"]();
2769
+ } finally {
2770
+ if (u) throw o;
2771
+ }
2772
+ }
2773
+ };
2774
+ }
2775
+
2776
+ function _assertThisInitialized(e) {
2777
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2778
+ return e;
2779
+ }
2780
+
2781
+ function _setPrototypeOf(t, e) {
2782
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
2783
+ return t.__proto__ = e, t;
2784
+ }, _setPrototypeOf(t, e);
2785
+ }
2786
+
2787
+ function _inherits(t, e) {
2788
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
2789
+ t.prototype = Object.create(e && e.prototype, {
2790
+ constructor: {
2791
+ value: t,
2792
+ writable: !0,
2793
+ configurable: !0
2794
+ }
2795
+ }), Object.defineProperty(t, "prototype", {
2796
+ writable: !1
2797
+ }), e && _setPrototypeOf(t, e);
2798
+ }
2799
+
2800
+ function _getPrototypeOf(t) {
2801
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
2802
+ return t.__proto__ || Object.getPrototypeOf(t);
2803
+ }, _getPrototypeOf(t);
2804
+ }
2805
+
2806
+ function _isNativeReflectConstruct() {
2807
+ try {
2808
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
2809
+ } catch (t) {}
2810
+ return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
2811
+ return !!t;
2812
+ })();
2813
+ }
2814
+
2815
+ function _possibleConstructorReturn(t, e) {
2816
+ if (e && ("object" == index._typeof(e) || "function" == typeof e)) return e;
2817
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
2818
+ return _assertThisInitialized(t);
2819
+ }
2820
+
2821
+ function _createSuper(t) {
2822
+ var r = _isNativeReflectConstruct();
2823
+ return function () {
2824
+ var e,
2825
+ o = _getPrototypeOf(t);
2826
+ if (r) {
2827
+ var s = _getPrototypeOf(this).constructor;
2828
+ e = Reflect.construct(o, arguments, s);
2829
+ } else e = o.apply(this, arguments);
2830
+ return _possibleConstructorReturn(this, e);
2831
+ };
2832
+ }
2833
+
2834
+ function _classCallCheck(a, n) {
2835
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
2836
+ }
2837
+
2838
+ function toPrimitive(t, r) {
2839
+ if ("object" != index._typeof(t) || !t) return t;
2840
+ var e = t[Symbol.toPrimitive];
2841
+ if (void 0 !== e) {
2842
+ var i = e.call(t, r || "default");
2843
+ if ("object" != index._typeof(i)) return i;
2844
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2782
2845
  }
2783
- var dateStrings = splitDateString(argument);
2784
- var date;
2785
- if (dateStrings.date) {
2786
- var parseYearResult = parseYear(dateStrings.date, additionalDigits);
2787
- date = parseDate(parseYearResult.restDateString, parseYearResult.year);
2846
+ return ("string" === r ? String : Number)(t);
2847
+ }
2848
+
2849
+ function toPropertyKey(t) {
2850
+ var i = toPrimitive(t, "string");
2851
+ return "symbol" == index._typeof(i) ? i : i + "";
2852
+ }
2853
+
2854
+ function _defineProperties(e, r) {
2855
+ for (var t = 0; t < r.length; t++) {
2856
+ var o = r[t];
2857
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
2788
2858
  }
2789
- if (!date || isNaN(date.getTime())) {
2790
- return new Date(NaN);
2859
+ }
2860
+ function _createClass(e, r, t) {
2861
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
2862
+ writable: !1
2863
+ }), e;
2864
+ }
2865
+
2866
+ function _defineProperty(e, r, t) {
2867
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
2868
+ value: t,
2869
+ enumerable: !0,
2870
+ configurable: !0,
2871
+ writable: !0
2872
+ }) : e[r] = t, e;
2873
+ }
2874
+
2875
+ var TIMEZONE_UNIT_PRIORITY = 10;
2876
+ var Setter = /*#__PURE__*/function () {
2877
+ function Setter() {
2878
+ _classCallCheck(this, Setter);
2879
+ _defineProperty(this, "priority", void 0);
2880
+ _defineProperty(this, "subPriority", 0);
2791
2881
  }
2792
- var timestamp = date.getTime();
2793
- var time = 0;
2794
- var offset;
2795
- if (dateStrings.time) {
2796
- time = parseTime(dateStrings.time);
2797
- if (isNaN(time)) {
2798
- return new Date(NaN);
2882
+ _createClass(Setter, [{
2883
+ key: "validate",
2884
+ value: function validate(_utcDate, _options) {
2885
+ return true;
2799
2886
  }
2887
+ }]);
2888
+ return Setter;
2889
+ }();
2890
+ var ValueSetter = /*#__PURE__*/function (_Setter) {
2891
+ _inherits(ValueSetter, _Setter);
2892
+ var _super = _createSuper(ValueSetter);
2893
+ function ValueSetter(value, validateValue, setValue, priority, subPriority) {
2894
+ var _this;
2895
+ _classCallCheck(this, ValueSetter);
2896
+ _this = _super.call(this);
2897
+ _this.value = value;
2898
+ _this.validateValue = validateValue;
2899
+ _this.setValue = setValue;
2900
+ _this.priority = priority;
2901
+ if (subPriority) {
2902
+ _this.subPriority = subPriority;
2903
+ }
2904
+ return _this;
2800
2905
  }
2801
- if (dateStrings.timezone) {
2802
- offset = parseTimezone(dateStrings.timezone);
2803
- if (isNaN(offset)) {
2804
- return new Date(NaN);
2906
+ _createClass(ValueSetter, [{
2907
+ key: "validate",
2908
+ value: function validate(utcDate, options) {
2909
+ return this.validateValue(utcDate, this.value, options);
2805
2910
  }
2806
- } else {
2807
- var dirtyDate = new Date(timestamp + time);
2808
- // js parsed string assuming it's in UTC timezone
2809
- // but we need it to be parsed in our timezone
2810
- // so we use utc values to build date in our timezone.
2811
- // Year values from 0 to 99 map to the years 1900 to 1999
2812
- // so set year explicitly with setFullYear.
2813
- var result = new Date(0);
2814
- result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());
2815
- result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());
2816
- return result;
2911
+ }, {
2912
+ key: "set",
2913
+ value: function set(utcDate, flags, options) {
2914
+ return this.setValue(utcDate, flags, this.value, options);
2915
+ }
2916
+ }]);
2917
+ return ValueSetter;
2918
+ }(Setter);
2919
+ var DateToSystemTimezoneSetter = /*#__PURE__*/function (_Setter2) {
2920
+ _inherits(DateToSystemTimezoneSetter, _Setter2);
2921
+ var _super2 = _createSuper(DateToSystemTimezoneSetter);
2922
+ function DateToSystemTimezoneSetter() {
2923
+ var _this2;
2924
+ _classCallCheck(this, DateToSystemTimezoneSetter);
2925
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2926
+ args[_key] = arguments[_key];
2927
+ }
2928
+ _this2 = _super2.call.apply(_super2, [this].concat(args));
2929
+ _defineProperty(_assertThisInitialized(_this2), "priority", TIMEZONE_UNIT_PRIORITY);
2930
+ _defineProperty(_assertThisInitialized(_this2), "subPriority", -1);
2931
+ return _this2;
2817
2932
  }
2818
- return new Date(timestamp + time + offset);
2819
- }
2820
- var patterns = {
2821
- dateTimeDelimiter: /[T ]/,
2822
- timeZoneDelimiter: /[Z ]/i,
2823
- timezone: /([Z+-].*)$/
2824
- };
2825
- var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
2826
- var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
2827
- var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
2828
- function splitDateString(dateString) {
2829
- var dateStrings = {};
2830
- var array = dateString.split(patterns.dateTimeDelimiter);
2831
- var timeString;
2933
+ _createClass(DateToSystemTimezoneSetter, [{
2934
+ key: "set",
2935
+ value: function set(date, flags) {
2936
+ if (flags.timestampIsSet) {
2937
+ return date;
2938
+ }
2939
+ var convertedDate = new Date(0);
2940
+ convertedDate.setFullYear(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
2941
+ convertedDate.setHours(date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());
2942
+ return convertedDate;
2943
+ }
2944
+ }]);
2945
+ return DateToSystemTimezoneSetter;
2946
+ }(Setter);
2832
2947
 
2833
- // The regex match should only return at maximum two array elements.
2834
- // [date], [time], or [date, time].
2835
- if (array.length > 2) {
2836
- return dateStrings;
2948
+ var Parser = /*#__PURE__*/function () {
2949
+ function Parser() {
2950
+ _classCallCheck(this, Parser);
2951
+ _defineProperty(this, "incompatibleTokens", void 0);
2952
+ _defineProperty(this, "priority", void 0);
2953
+ _defineProperty(this, "subPriority", void 0);
2837
2954
  }
2838
- if (/:/.test(array[0])) {
2839
- timeString = array[0];
2840
- } else {
2841
- dateStrings.date = array[0];
2842
- timeString = array[1];
2843
- if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
2844
- dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
2845
- timeString = dateString.substr(dateStrings.date.length, dateString.length);
2955
+ _createClass(Parser, [{
2956
+ key: "run",
2957
+ value: function run(dateString, token, match, options) {
2958
+ var result = this.parse(dateString, token, match, options);
2959
+ if (!result) {
2960
+ return null;
2961
+ }
2962
+ return {
2963
+ setter: new ValueSetter(result.value, this.validate, this.set, this.priority, this.subPriority),
2964
+ rest: result.rest
2965
+ };
2966
+ }
2967
+ }, {
2968
+ key: "validate",
2969
+ value: function validate(_utcDate, _value, _options) {
2970
+ return true;
2971
+ }
2972
+ }]);
2973
+ return Parser;
2974
+ }();
2975
+
2976
+ var EraParser = /*#__PURE__*/function (_Parser) {
2977
+ _inherits(EraParser, _Parser);
2978
+ var _super = _createSuper(EraParser);
2979
+ function EraParser() {
2980
+ var _this;
2981
+ _classCallCheck(this, EraParser);
2982
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2983
+ args[_key] = arguments[_key];
2846
2984
  }
2985
+ _this = _super.call.apply(_super, [this].concat(args));
2986
+ _defineProperty(_assertThisInitialized(_this), "priority", 140);
2987
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['R', 'u', 't', 'T']);
2988
+ return _this;
2847
2989
  }
2848
- if (timeString) {
2849
- var token = patterns.timezone.exec(timeString);
2850
- if (token) {
2851
- dateStrings.time = timeString.replace(token[1], '');
2852
- dateStrings.timezone = token[1];
2853
- } else {
2854
- dateStrings.time = timeString;
2990
+ _createClass(EraParser, [{
2991
+ key: "parse",
2992
+ value: function parse(dateString, token, match) {
2993
+ switch (token) {
2994
+ // AD, BC
2995
+ case 'G':
2996
+ case 'GG':
2997
+ case 'GGG':
2998
+ return match.era(dateString, {
2999
+ width: 'abbreviated'
3000
+ }) || match.era(dateString, {
3001
+ width: 'narrow'
3002
+ });
3003
+ // A, B
3004
+ case 'GGGGG':
3005
+ return match.era(dateString, {
3006
+ width: 'narrow'
3007
+ });
3008
+ // Anno Domini, Before Christ
3009
+ case 'GGGG':
3010
+ default:
3011
+ return match.era(dateString, {
3012
+ width: 'wide'
3013
+ }) || match.era(dateString, {
3014
+ width: 'abbreviated'
3015
+ }) || match.era(dateString, {
3016
+ width: 'narrow'
3017
+ });
3018
+ }
2855
3019
  }
3020
+ }, {
3021
+ key: "set",
3022
+ value: function set(date, flags, value) {
3023
+ flags.era = value;
3024
+ date.setUTCFullYear(value, 0, 1);
3025
+ date.setUTCHours(0, 0, 0, 0);
3026
+ return date;
3027
+ }
3028
+ }]);
3029
+ return EraParser;
3030
+ }(Parser);
3031
+
3032
+ var numericPatterns = {
3033
+ month: /^(1[0-2]|0?\d)/,
3034
+ // 0 to 12
3035
+ date: /^(3[0-1]|[0-2]?\d)/,
3036
+ // 0 to 31
3037
+ dayOfYear: /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,
3038
+ // 0 to 366
3039
+ week: /^(5[0-3]|[0-4]?\d)/,
3040
+ // 0 to 53
3041
+ hour23h: /^(2[0-3]|[0-1]?\d)/,
3042
+ // 0 to 23
3043
+ hour24h: /^(2[0-4]|[0-1]?\d)/,
3044
+ // 0 to 24
3045
+ hour11h: /^(1[0-1]|0?\d)/,
3046
+ // 0 to 11
3047
+ hour12h: /^(1[0-2]|0?\d)/,
3048
+ // 0 to 12
3049
+ minute: /^[0-5]?\d/,
3050
+ // 0 to 59
3051
+ second: /^[0-5]?\d/,
3052
+ // 0 to 59
3053
+
3054
+ singleDigit: /^\d/,
3055
+ // 0 to 9
3056
+ twoDigits: /^\d{1,2}/,
3057
+ // 0 to 99
3058
+ threeDigits: /^\d{1,3}/,
3059
+ // 0 to 999
3060
+ fourDigits: /^\d{1,4}/,
3061
+ // 0 to 9999
3062
+
3063
+ anyDigitsSigned: /^-?\d+/,
3064
+ singleDigitSigned: /^-?\d/,
3065
+ // 0 to 9, -0 to -9
3066
+ twoDigitsSigned: /^-?\d{1,2}/,
3067
+ // 0 to 99, -0 to -99
3068
+ threeDigitsSigned: /^-?\d{1,3}/,
3069
+ // 0 to 999, -0 to -999
3070
+ fourDigitsSigned: /^-?\d{1,4}/ // 0 to 9999, -0 to -9999
3071
+ };
3072
+
3073
+ var timezonePatterns = {
3074
+ basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/,
3075
+ basic: /^([+-])(\d{2})(\d{2})|Z/,
3076
+ basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,
3077
+ extended: /^([+-])(\d{2}):(\d{2})|Z/,
3078
+ extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/
3079
+ };
3080
+
3081
+ function mapValue(parseFnResult, mapFn) {
3082
+ if (!parseFnResult) {
3083
+ return parseFnResult;
2856
3084
  }
2857
- return dateStrings;
3085
+ return {
3086
+ value: mapFn(parseFnResult.value),
3087
+ rest: parseFnResult.rest
3088
+ };
2858
3089
  }
2859
- function parseYear(dateString, additionalDigits) {
2860
- var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)');
2861
- var captures = dateString.match(regex);
2862
- // Invalid ISO-formatted year
2863
- if (!captures) return {
2864
- year: NaN,
2865
- restDateString: ''
3090
+ function parseNumericPattern(pattern, dateString) {
3091
+ var matchResult = dateString.match(pattern);
3092
+ if (!matchResult) {
3093
+ return null;
3094
+ }
3095
+ return {
3096
+ value: parseInt(matchResult[0], 10),
3097
+ rest: dateString.slice(matchResult[0].length)
2866
3098
  };
2867
- var year = captures[1] ? parseInt(captures[1]) : null;
2868
- var century = captures[2] ? parseInt(captures[2]) : null;
3099
+ }
3100
+ function parseTimezonePattern(pattern, dateString) {
3101
+ var matchResult = dateString.match(pattern);
3102
+ if (!matchResult) {
3103
+ return null;
3104
+ }
2869
3105
 
2870
- // either year or century is null, not both
3106
+ // Input is 'Z'
3107
+ if (matchResult[0] === 'Z') {
3108
+ return {
3109
+ value: 0,
3110
+ rest: dateString.slice(1)
3111
+ };
3112
+ }
3113
+ var sign = matchResult[1] === '+' ? 1 : -1;
3114
+ var hours = matchResult[2] ? parseInt(matchResult[2], 10) : 0;
3115
+ var minutes = matchResult[3] ? parseInt(matchResult[3], 10) : 0;
3116
+ var seconds = matchResult[5] ? parseInt(matchResult[5], 10) : 0;
2871
3117
  return {
2872
- year: century === null ? year : century * 100,
2873
- restDateString: dateString.slice((captures[1] || captures[2]).length)
3118
+ value: sign * (hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * millisecondsInSecond),
3119
+ rest: dateString.slice(matchResult[0].length)
2874
3120
  };
2875
3121
  }
2876
- function parseDate(dateString, year) {
2877
- // Invalid ISO-formatted year
2878
- if (year === null) return new Date(NaN);
2879
- var captures = dateString.match(dateRegex);
2880
- // Invalid ISO-formatted string
2881
- if (!captures) return new Date(NaN);
2882
- var isWeekDate = !!captures[4];
2883
- var dayOfYear = parseDateUnit(captures[1]);
2884
- var month = parseDateUnit(captures[2]) - 1;
2885
- var day = parseDateUnit(captures[3]);
2886
- var week = parseDateUnit(captures[4]);
2887
- var dayOfWeek = parseDateUnit(captures[5]) - 1;
2888
- if (isWeekDate) {
2889
- if (!validateWeekDate(year, week, dayOfWeek)) {
3122
+ function parseAnyDigitsSigned(dateString) {
3123
+ return parseNumericPattern(numericPatterns.anyDigitsSigned, dateString);
3124
+ }
3125
+ function parseNDigits(n, dateString) {
3126
+ switch (n) {
3127
+ case 1:
3128
+ return parseNumericPattern(numericPatterns.singleDigit, dateString);
3129
+ case 2:
3130
+ return parseNumericPattern(numericPatterns.twoDigits, dateString);
3131
+ case 3:
3132
+ return parseNumericPattern(numericPatterns.threeDigits, dateString);
3133
+ case 4:
3134
+ return parseNumericPattern(numericPatterns.fourDigits, dateString);
3135
+ default:
3136
+ return parseNumericPattern(new RegExp('^\\d{1,' + n + '}'), dateString);
3137
+ }
3138
+ }
3139
+ function parseNDigitsSigned(n, dateString) {
3140
+ switch (n) {
3141
+ case 1:
3142
+ return parseNumericPattern(numericPatterns.singleDigitSigned, dateString);
3143
+ case 2:
3144
+ return parseNumericPattern(numericPatterns.twoDigitsSigned, dateString);
3145
+ case 3:
3146
+ return parseNumericPattern(numericPatterns.threeDigitsSigned, dateString);
3147
+ case 4:
3148
+ return parseNumericPattern(numericPatterns.fourDigitsSigned, dateString);
3149
+ default:
3150
+ return parseNumericPattern(new RegExp('^-?\\d{1,' + n + '}'), dateString);
3151
+ }
3152
+ }
3153
+ function dayPeriodEnumToHours(dayPeriod) {
3154
+ switch (dayPeriod) {
3155
+ case 'morning':
3156
+ return 4;
3157
+ case 'evening':
3158
+ return 17;
3159
+ case 'pm':
3160
+ case 'noon':
3161
+ case 'afternoon':
3162
+ return 12;
3163
+ case 'am':
3164
+ case 'midnight':
3165
+ case 'night':
3166
+ default:
3167
+ return 0;
3168
+ }
3169
+ }
3170
+ function normalizeTwoDigitYear(twoDigitYear, currentYear) {
3171
+ var isCommonEra = currentYear > 0;
3172
+ // Absolute number of the current year:
3173
+ // 1 -> 1 AC
3174
+ // 0 -> 1 BC
3175
+ // -1 -> 2 BC
3176
+ var absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;
3177
+ var result;
3178
+ if (absCurrentYear <= 50) {
3179
+ result = twoDigitYear || 100;
3180
+ } else {
3181
+ var rangeEnd = absCurrentYear + 50;
3182
+ var rangeEndCentury = Math.floor(rangeEnd / 100) * 100;
3183
+ var isPreviousCentury = twoDigitYear >= rangeEnd % 100;
3184
+ result = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);
3185
+ }
3186
+ return isCommonEra ? result : 1 - result;
3187
+ }
3188
+ function isLeapYearIndex$1(year) {
3189
+ return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
3190
+ }
3191
+
3192
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
3193
+ // | Year | y | yy | yyy | yyyy | yyyyy |
3194
+ // |----------|-------|----|-------|-------|-------|
3195
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
3196
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
3197
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
3198
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
3199
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
3200
+ var YearParser = /*#__PURE__*/function (_Parser) {
3201
+ _inherits(YearParser, _Parser);
3202
+ var _super = _createSuper(YearParser);
3203
+ function YearParser() {
3204
+ var _this;
3205
+ _classCallCheck(this, YearParser);
3206
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3207
+ args[_key] = arguments[_key];
3208
+ }
3209
+ _this = _super.call.apply(_super, [this].concat(args));
3210
+ _defineProperty(_assertThisInitialized(_this), "priority", 130);
3211
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'u', 'w', 'I', 'i', 'e', 'c', 't', 'T']);
3212
+ return _this;
3213
+ }
3214
+ _createClass(YearParser, [{
3215
+ key: "parse",
3216
+ value: function parse(dateString, token, match) {
3217
+ var valueCallback = function valueCallback(year) {
3218
+ return {
3219
+ year: year,
3220
+ isTwoDigitYear: token === 'yy'
3221
+ };
3222
+ };
3223
+ switch (token) {
3224
+ case 'y':
3225
+ return mapValue(parseNDigits(4, dateString), valueCallback);
3226
+ case 'yo':
3227
+ return mapValue(match.ordinalNumber(dateString, {
3228
+ unit: 'year'
3229
+ }), valueCallback);
3230
+ default:
3231
+ return mapValue(parseNDigits(token.length, dateString), valueCallback);
3232
+ }
3233
+ }
3234
+ }, {
3235
+ key: "validate",
3236
+ value: function validate(_date, value) {
3237
+ return value.isTwoDigitYear || value.year > 0;
3238
+ }
3239
+ }, {
3240
+ key: "set",
3241
+ value: function set(date, flags, value) {
3242
+ var currentYear = date.getUTCFullYear();
3243
+ if (value.isTwoDigitYear) {
3244
+ var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear);
3245
+ date.setUTCFullYear(normalizedTwoDigitYear, 0, 1);
3246
+ date.setUTCHours(0, 0, 0, 0);
3247
+ return date;
3248
+ }
3249
+ var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year;
3250
+ date.setUTCFullYear(year, 0, 1);
3251
+ date.setUTCHours(0, 0, 0, 0);
3252
+ return date;
3253
+ }
3254
+ }]);
3255
+ return YearParser;
3256
+ }(Parser);
3257
+
3258
+ // Local week-numbering year
3259
+ var LocalWeekYearParser = /*#__PURE__*/function (_Parser) {
3260
+ _inherits(LocalWeekYearParser, _Parser);
3261
+ var _super = _createSuper(LocalWeekYearParser);
3262
+ function LocalWeekYearParser() {
3263
+ var _this;
3264
+ _classCallCheck(this, LocalWeekYearParser);
3265
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3266
+ args[_key] = arguments[_key];
3267
+ }
3268
+ _this = _super.call.apply(_super, [this].concat(args));
3269
+ _defineProperty(_assertThisInitialized(_this), "priority", 130);
3270
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'Q', 'q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);
3271
+ return _this;
3272
+ }
3273
+ _createClass(LocalWeekYearParser, [{
3274
+ key: "parse",
3275
+ value: function parse(dateString, token, match) {
3276
+ var valueCallback = function valueCallback(year) {
3277
+ return {
3278
+ year: year,
3279
+ isTwoDigitYear: token === 'YY'
3280
+ };
3281
+ };
3282
+ switch (token) {
3283
+ case 'Y':
3284
+ return mapValue(parseNDigits(4, dateString), valueCallback);
3285
+ case 'Yo':
3286
+ return mapValue(match.ordinalNumber(dateString, {
3287
+ unit: 'year'
3288
+ }), valueCallback);
3289
+ default:
3290
+ return mapValue(parseNDigits(token.length, dateString), valueCallback);
3291
+ }
3292
+ }
3293
+ }, {
3294
+ key: "validate",
3295
+ value: function validate(_date, value) {
3296
+ return value.isTwoDigitYear || value.year > 0;
3297
+ }
3298
+ }, {
3299
+ key: "set",
3300
+ value: function set(date, flags, value, options) {
3301
+ var currentYear = getUTCWeekYear(date, options);
3302
+ if (value.isTwoDigitYear) {
3303
+ var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear);
3304
+ date.setUTCFullYear(normalizedTwoDigitYear, 0, options.firstWeekContainsDate);
3305
+ date.setUTCHours(0, 0, 0, 0);
3306
+ return startOfUTCWeek(date, options);
3307
+ }
3308
+ var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year;
3309
+ date.setUTCFullYear(year, 0, options.firstWeekContainsDate);
3310
+ date.setUTCHours(0, 0, 0, 0);
3311
+ return startOfUTCWeek(date, options);
3312
+ }
3313
+ }]);
3314
+ return LocalWeekYearParser;
3315
+ }(Parser);
3316
+
3317
+ var ISOWeekYearParser = /*#__PURE__*/function (_Parser) {
3318
+ _inherits(ISOWeekYearParser, _Parser);
3319
+ var _super = _createSuper(ISOWeekYearParser);
3320
+ function ISOWeekYearParser() {
3321
+ var _this;
3322
+ _classCallCheck(this, ISOWeekYearParser);
3323
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3324
+ args[_key] = arguments[_key];
3325
+ }
3326
+ _this = _super.call.apply(_super, [this].concat(args));
3327
+ _defineProperty(_assertThisInitialized(_this), "priority", 130);
3328
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['G', 'y', 'Y', 'u', 'Q', 'q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);
3329
+ return _this;
3330
+ }
3331
+ _createClass(ISOWeekYearParser, [{
3332
+ key: "parse",
3333
+ value: function parse(dateString, token) {
3334
+ if (token === 'R') {
3335
+ return parseNDigitsSigned(4, dateString);
3336
+ }
3337
+ return parseNDigitsSigned(token.length, dateString);
3338
+ }
3339
+ }, {
3340
+ key: "set",
3341
+ value: function set(_date, _flags, value) {
3342
+ var firstWeekOfYear = new Date(0);
3343
+ firstWeekOfYear.setUTCFullYear(value, 0, 4);
3344
+ firstWeekOfYear.setUTCHours(0, 0, 0, 0);
3345
+ return startOfUTCISOWeek(firstWeekOfYear);
3346
+ }
3347
+ }]);
3348
+ return ISOWeekYearParser;
3349
+ }(Parser);
3350
+
3351
+ var ExtendedYearParser = /*#__PURE__*/function (_Parser) {
3352
+ _inherits(ExtendedYearParser, _Parser);
3353
+ var _super = _createSuper(ExtendedYearParser);
3354
+ function ExtendedYearParser() {
3355
+ var _this;
3356
+ _classCallCheck(this, ExtendedYearParser);
3357
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3358
+ args[_key] = arguments[_key];
3359
+ }
3360
+ _this = _super.call.apply(_super, [this].concat(args));
3361
+ _defineProperty(_assertThisInitialized(_this), "priority", 130);
3362
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['G', 'y', 'Y', 'R', 'w', 'I', 'i', 'e', 'c', 't', 'T']);
3363
+ return _this;
3364
+ }
3365
+ _createClass(ExtendedYearParser, [{
3366
+ key: "parse",
3367
+ value: function parse(dateString, token) {
3368
+ if (token === 'u') {
3369
+ return parseNDigitsSigned(4, dateString);
3370
+ }
3371
+ return parseNDigitsSigned(token.length, dateString);
3372
+ }
3373
+ }, {
3374
+ key: "set",
3375
+ value: function set(date, _flags, value) {
3376
+ date.setUTCFullYear(value, 0, 1);
3377
+ date.setUTCHours(0, 0, 0, 0);
3378
+ return date;
3379
+ }
3380
+ }]);
3381
+ return ExtendedYearParser;
3382
+ }(Parser);
3383
+
3384
+ var QuarterParser = /*#__PURE__*/function (_Parser) {
3385
+ _inherits(QuarterParser, _Parser);
3386
+ var _super = _createSuper(QuarterParser);
3387
+ function QuarterParser() {
3388
+ var _this;
3389
+ _classCallCheck(this, QuarterParser);
3390
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3391
+ args[_key] = arguments[_key];
3392
+ }
3393
+ _this = _super.call.apply(_super, [this].concat(args));
3394
+ _defineProperty(_assertThisInitialized(_this), "priority", 120);
3395
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);
3396
+ return _this;
3397
+ }
3398
+ _createClass(QuarterParser, [{
3399
+ key: "parse",
3400
+ value: function parse(dateString, token, match) {
3401
+ switch (token) {
3402
+ // 1, 2, 3, 4
3403
+ case 'Q':
3404
+ case 'QQ':
3405
+ // 01, 02, 03, 04
3406
+ return parseNDigits(token.length, dateString);
3407
+ // 1st, 2nd, 3rd, 4th
3408
+ case 'Qo':
3409
+ return match.ordinalNumber(dateString, {
3410
+ unit: 'quarter'
3411
+ });
3412
+ // Q1, Q2, Q3, Q4
3413
+ case 'QQQ':
3414
+ return match.quarter(dateString, {
3415
+ width: 'abbreviated',
3416
+ context: 'formatting'
3417
+ }) || match.quarter(dateString, {
3418
+ width: 'narrow',
3419
+ context: 'formatting'
3420
+ });
3421
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
3422
+ case 'QQQQQ':
3423
+ return match.quarter(dateString, {
3424
+ width: 'narrow',
3425
+ context: 'formatting'
3426
+ });
3427
+ // 1st quarter, 2nd quarter, ...
3428
+ case 'QQQQ':
3429
+ default:
3430
+ return match.quarter(dateString, {
3431
+ width: 'wide',
3432
+ context: 'formatting'
3433
+ }) || match.quarter(dateString, {
3434
+ width: 'abbreviated',
3435
+ context: 'formatting'
3436
+ }) || match.quarter(dateString, {
3437
+ width: 'narrow',
3438
+ context: 'formatting'
3439
+ });
3440
+ }
3441
+ }
3442
+ }, {
3443
+ key: "validate",
3444
+ value: function validate(_date, value) {
3445
+ return value >= 1 && value <= 4;
3446
+ }
3447
+ }, {
3448
+ key: "set",
3449
+ value: function set(date, _flags, value) {
3450
+ date.setUTCMonth((value - 1) * 3, 1);
3451
+ date.setUTCHours(0, 0, 0, 0);
3452
+ return date;
3453
+ }
3454
+ }]);
3455
+ return QuarterParser;
3456
+ }(Parser);
3457
+
3458
+ var StandAloneQuarterParser = /*#__PURE__*/function (_Parser) {
3459
+ _inherits(StandAloneQuarterParser, _Parser);
3460
+ var _super = _createSuper(StandAloneQuarterParser);
3461
+ function StandAloneQuarterParser() {
3462
+ var _this;
3463
+ _classCallCheck(this, StandAloneQuarterParser);
3464
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3465
+ args[_key] = arguments[_key];
3466
+ }
3467
+ _this = _super.call.apply(_super, [this].concat(args));
3468
+ _defineProperty(_assertThisInitialized(_this), "priority", 120);
3469
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'Q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);
3470
+ return _this;
3471
+ }
3472
+ _createClass(StandAloneQuarterParser, [{
3473
+ key: "parse",
3474
+ value: function parse(dateString, token, match) {
3475
+ switch (token) {
3476
+ // 1, 2, 3, 4
3477
+ case 'q':
3478
+ case 'qq':
3479
+ // 01, 02, 03, 04
3480
+ return parseNDigits(token.length, dateString);
3481
+ // 1st, 2nd, 3rd, 4th
3482
+ case 'qo':
3483
+ return match.ordinalNumber(dateString, {
3484
+ unit: 'quarter'
3485
+ });
3486
+ // Q1, Q2, Q3, Q4
3487
+ case 'qqq':
3488
+ return match.quarter(dateString, {
3489
+ width: 'abbreviated',
3490
+ context: 'standalone'
3491
+ }) || match.quarter(dateString, {
3492
+ width: 'narrow',
3493
+ context: 'standalone'
3494
+ });
3495
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
3496
+ case 'qqqqq':
3497
+ return match.quarter(dateString, {
3498
+ width: 'narrow',
3499
+ context: 'standalone'
3500
+ });
3501
+ // 1st quarter, 2nd quarter, ...
3502
+ case 'qqqq':
3503
+ default:
3504
+ return match.quarter(dateString, {
3505
+ width: 'wide',
3506
+ context: 'standalone'
3507
+ }) || match.quarter(dateString, {
3508
+ width: 'abbreviated',
3509
+ context: 'standalone'
3510
+ }) || match.quarter(dateString, {
3511
+ width: 'narrow',
3512
+ context: 'standalone'
3513
+ });
3514
+ }
3515
+ }
3516
+ }, {
3517
+ key: "validate",
3518
+ value: function validate(_date, value) {
3519
+ return value >= 1 && value <= 4;
3520
+ }
3521
+ }, {
3522
+ key: "set",
3523
+ value: function set(date, _flags, value) {
3524
+ date.setUTCMonth((value - 1) * 3, 1);
3525
+ date.setUTCHours(0, 0, 0, 0);
3526
+ return date;
3527
+ }
3528
+ }]);
3529
+ return StandAloneQuarterParser;
3530
+ }(Parser);
3531
+
3532
+ var MonthParser = /*#__PURE__*/function (_Parser) {
3533
+ _inherits(MonthParser, _Parser);
3534
+ var _super = _createSuper(MonthParser);
3535
+ function MonthParser() {
3536
+ var _this;
3537
+ _classCallCheck(this, MonthParser);
3538
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3539
+ args[_key] = arguments[_key];
3540
+ }
3541
+ _this = _super.call.apply(_super, [this].concat(args));
3542
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'L', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);
3543
+ _defineProperty(_assertThisInitialized(_this), "priority", 110);
3544
+ return _this;
3545
+ }
3546
+ _createClass(MonthParser, [{
3547
+ key: "parse",
3548
+ value: function parse(dateString, token, match) {
3549
+ var valueCallback = function valueCallback(value) {
3550
+ return value - 1;
3551
+ };
3552
+ switch (token) {
3553
+ // 1, 2, ..., 12
3554
+ case 'M':
3555
+ return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback);
3556
+ // 01, 02, ..., 12
3557
+ case 'MM':
3558
+ return mapValue(parseNDigits(2, dateString), valueCallback);
3559
+ // 1st, 2nd, ..., 12th
3560
+ case 'Mo':
3561
+ return mapValue(match.ordinalNumber(dateString, {
3562
+ unit: 'month'
3563
+ }), valueCallback);
3564
+ // Jan, Feb, ..., Dec
3565
+ case 'MMM':
3566
+ return match.month(dateString, {
3567
+ width: 'abbreviated',
3568
+ context: 'formatting'
3569
+ }) || match.month(dateString, {
3570
+ width: 'narrow',
3571
+ context: 'formatting'
3572
+ });
3573
+ // J, F, ..., D
3574
+ case 'MMMMM':
3575
+ return match.month(dateString, {
3576
+ width: 'narrow',
3577
+ context: 'formatting'
3578
+ });
3579
+ // January, February, ..., December
3580
+ case 'MMMM':
3581
+ default:
3582
+ return match.month(dateString, {
3583
+ width: 'wide',
3584
+ context: 'formatting'
3585
+ }) || match.month(dateString, {
3586
+ width: 'abbreviated',
3587
+ context: 'formatting'
3588
+ }) || match.month(dateString, {
3589
+ width: 'narrow',
3590
+ context: 'formatting'
3591
+ });
3592
+ }
3593
+ }
3594
+ }, {
3595
+ key: "validate",
3596
+ value: function validate(_date, value) {
3597
+ return value >= 0 && value <= 11;
3598
+ }
3599
+ }, {
3600
+ key: "set",
3601
+ value: function set(date, _flags, value) {
3602
+ date.setUTCMonth(value, 1);
3603
+ date.setUTCHours(0, 0, 0, 0);
3604
+ return date;
3605
+ }
3606
+ }]);
3607
+ return MonthParser;
3608
+ }(Parser);
3609
+
3610
+ var StandAloneMonthParser = /*#__PURE__*/function (_Parser) {
3611
+ _inherits(StandAloneMonthParser, _Parser);
3612
+ var _super = _createSuper(StandAloneMonthParser);
3613
+ function StandAloneMonthParser() {
3614
+ var _this;
3615
+ _classCallCheck(this, StandAloneMonthParser);
3616
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3617
+ args[_key] = arguments[_key];
3618
+ }
3619
+ _this = _super.call.apply(_super, [this].concat(args));
3620
+ _defineProperty(_assertThisInitialized(_this), "priority", 110);
3621
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'M', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);
3622
+ return _this;
3623
+ }
3624
+ _createClass(StandAloneMonthParser, [{
3625
+ key: "parse",
3626
+ value: function parse(dateString, token, match) {
3627
+ var valueCallback = function valueCallback(value) {
3628
+ return value - 1;
3629
+ };
3630
+ switch (token) {
3631
+ // 1, 2, ..., 12
3632
+ case 'L':
3633
+ return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback);
3634
+ // 01, 02, ..., 12
3635
+ case 'LL':
3636
+ return mapValue(parseNDigits(2, dateString), valueCallback);
3637
+ // 1st, 2nd, ..., 12th
3638
+ case 'Lo':
3639
+ return mapValue(match.ordinalNumber(dateString, {
3640
+ unit: 'month'
3641
+ }), valueCallback);
3642
+ // Jan, Feb, ..., Dec
3643
+ case 'LLL':
3644
+ return match.month(dateString, {
3645
+ width: 'abbreviated',
3646
+ context: 'standalone'
3647
+ }) || match.month(dateString, {
3648
+ width: 'narrow',
3649
+ context: 'standalone'
3650
+ });
3651
+ // J, F, ..., D
3652
+ case 'LLLLL':
3653
+ return match.month(dateString, {
3654
+ width: 'narrow',
3655
+ context: 'standalone'
3656
+ });
3657
+ // January, February, ..., December
3658
+ case 'LLLL':
3659
+ default:
3660
+ return match.month(dateString, {
3661
+ width: 'wide',
3662
+ context: 'standalone'
3663
+ }) || match.month(dateString, {
3664
+ width: 'abbreviated',
3665
+ context: 'standalone'
3666
+ }) || match.month(dateString, {
3667
+ width: 'narrow',
3668
+ context: 'standalone'
3669
+ });
3670
+ }
3671
+ }
3672
+ }, {
3673
+ key: "validate",
3674
+ value: function validate(_date, value) {
3675
+ return value >= 0 && value <= 11;
3676
+ }
3677
+ }, {
3678
+ key: "set",
3679
+ value: function set(date, _flags, value) {
3680
+ date.setUTCMonth(value, 1);
3681
+ date.setUTCHours(0, 0, 0, 0);
3682
+ return date;
3683
+ }
3684
+ }]);
3685
+ return StandAloneMonthParser;
3686
+ }(Parser);
3687
+
3688
+ function setUTCWeek(dirtyDate, dirtyWeek, options) {
3689
+ index.requiredArgs(2, arguments);
3690
+ var date = index.toDate(dirtyDate);
3691
+ var week = toInteger(dirtyWeek);
3692
+ var diff = getUTCWeek(date, options) - week;
3693
+ date.setUTCDate(date.getUTCDate() - diff * 7);
3694
+ return date;
3695
+ }
3696
+
3697
+ var LocalWeekParser = /*#__PURE__*/function (_Parser) {
3698
+ _inherits(LocalWeekParser, _Parser);
3699
+ var _super = _createSuper(LocalWeekParser);
3700
+ function LocalWeekParser() {
3701
+ var _this;
3702
+ _classCallCheck(this, LocalWeekParser);
3703
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3704
+ args[_key] = arguments[_key];
3705
+ }
3706
+ _this = _super.call.apply(_super, [this].concat(args));
3707
+ _defineProperty(_assertThisInitialized(_this), "priority", 100);
3708
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);
3709
+ return _this;
3710
+ }
3711
+ _createClass(LocalWeekParser, [{
3712
+ key: "parse",
3713
+ value: function parse(dateString, token, match) {
3714
+ switch (token) {
3715
+ case 'w':
3716
+ return parseNumericPattern(numericPatterns.week, dateString);
3717
+ case 'wo':
3718
+ return match.ordinalNumber(dateString, {
3719
+ unit: 'week'
3720
+ });
3721
+ default:
3722
+ return parseNDigits(token.length, dateString);
3723
+ }
3724
+ }
3725
+ }, {
3726
+ key: "validate",
3727
+ value: function validate(_date, value) {
3728
+ return value >= 1 && value <= 53;
3729
+ }
3730
+ }, {
3731
+ key: "set",
3732
+ value: function set(date, _flags, value, options) {
3733
+ return startOfUTCWeek(setUTCWeek(date, value, options), options);
3734
+ }
3735
+ }]);
3736
+ return LocalWeekParser;
3737
+ }(Parser);
3738
+
3739
+ function setUTCISOWeek(dirtyDate, dirtyISOWeek) {
3740
+ index.requiredArgs(2, arguments);
3741
+ var date = index.toDate(dirtyDate);
3742
+ var isoWeek = toInteger(dirtyISOWeek);
3743
+ var diff = getUTCISOWeek(date) - isoWeek;
3744
+ date.setUTCDate(date.getUTCDate() - diff * 7);
3745
+ return date;
3746
+ }
3747
+
3748
+ var ISOWeekParser = /*#__PURE__*/function (_Parser) {
3749
+ _inherits(ISOWeekParser, _Parser);
3750
+ var _super = _createSuper(ISOWeekParser);
3751
+ function ISOWeekParser() {
3752
+ var _this;
3753
+ _classCallCheck(this, ISOWeekParser);
3754
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3755
+ args[_key] = arguments[_key];
3756
+ }
3757
+ _this = _super.call.apply(_super, [this].concat(args));
3758
+ _defineProperty(_assertThisInitialized(_this), "priority", 100);
3759
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);
3760
+ return _this;
3761
+ }
3762
+ _createClass(ISOWeekParser, [{
3763
+ key: "parse",
3764
+ value: function parse(dateString, token, match) {
3765
+ switch (token) {
3766
+ case 'I':
3767
+ return parseNumericPattern(numericPatterns.week, dateString);
3768
+ case 'Io':
3769
+ return match.ordinalNumber(dateString, {
3770
+ unit: 'week'
3771
+ });
3772
+ default:
3773
+ return parseNDigits(token.length, dateString);
3774
+ }
3775
+ }
3776
+ }, {
3777
+ key: "validate",
3778
+ value: function validate(_date, value) {
3779
+ return value >= 1 && value <= 53;
3780
+ }
3781
+ }, {
3782
+ key: "set",
3783
+ value: function set(date, _flags, value) {
3784
+ return startOfUTCISOWeek(setUTCISOWeek(date, value));
3785
+ }
3786
+ }]);
3787
+ return ISOWeekParser;
3788
+ }(Parser);
3789
+
3790
+ var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
3791
+ var DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
3792
+
3793
+ // Day of the month
3794
+ var DateParser = /*#__PURE__*/function (_Parser) {
3795
+ _inherits(DateParser, _Parser);
3796
+ var _super = _createSuper(DateParser);
3797
+ function DateParser() {
3798
+ var _this;
3799
+ _classCallCheck(this, DateParser);
3800
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3801
+ args[_key] = arguments[_key];
3802
+ }
3803
+ _this = _super.call.apply(_super, [this].concat(args));
3804
+ _defineProperty(_assertThisInitialized(_this), "priority", 90);
3805
+ _defineProperty(_assertThisInitialized(_this), "subPriority", 1);
3806
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);
3807
+ return _this;
3808
+ }
3809
+ _createClass(DateParser, [{
3810
+ key: "parse",
3811
+ value: function parse(dateString, token, match) {
3812
+ switch (token) {
3813
+ case 'd':
3814
+ return parseNumericPattern(numericPatterns.date, dateString);
3815
+ case 'do':
3816
+ return match.ordinalNumber(dateString, {
3817
+ unit: 'date'
3818
+ });
3819
+ default:
3820
+ return parseNDigits(token.length, dateString);
3821
+ }
3822
+ }
3823
+ }, {
3824
+ key: "validate",
3825
+ value: function validate(date, value) {
3826
+ var year = date.getUTCFullYear();
3827
+ var isLeapYear = isLeapYearIndex$1(year);
3828
+ var month = date.getUTCMonth();
3829
+ if (isLeapYear) {
3830
+ return value >= 1 && value <= DAYS_IN_MONTH_LEAP_YEAR[month];
3831
+ } else {
3832
+ return value >= 1 && value <= DAYS_IN_MONTH[month];
3833
+ }
3834
+ }
3835
+ }, {
3836
+ key: "set",
3837
+ value: function set(date, _flags, value) {
3838
+ date.setUTCDate(value);
3839
+ date.setUTCHours(0, 0, 0, 0);
3840
+ return date;
3841
+ }
3842
+ }]);
3843
+ return DateParser;
3844
+ }(Parser);
3845
+
3846
+ var DayOfYearParser = /*#__PURE__*/function (_Parser) {
3847
+ _inherits(DayOfYearParser, _Parser);
3848
+ var _super = _createSuper(DayOfYearParser);
3849
+ function DayOfYearParser() {
3850
+ var _this;
3851
+ _classCallCheck(this, DayOfYearParser);
3852
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3853
+ args[_key] = arguments[_key];
3854
+ }
3855
+ _this = _super.call.apply(_super, [this].concat(args));
3856
+ _defineProperty(_assertThisInitialized(_this), "priority", 90);
3857
+ _defineProperty(_assertThisInitialized(_this), "subpriority", 1);
3858
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'M', 'L', 'w', 'I', 'd', 'E', 'i', 'e', 'c', 't', 'T']);
3859
+ return _this;
3860
+ }
3861
+ _createClass(DayOfYearParser, [{
3862
+ key: "parse",
3863
+ value: function parse(dateString, token, match) {
3864
+ switch (token) {
3865
+ case 'D':
3866
+ case 'DD':
3867
+ return parseNumericPattern(numericPatterns.dayOfYear, dateString);
3868
+ case 'Do':
3869
+ return match.ordinalNumber(dateString, {
3870
+ unit: 'date'
3871
+ });
3872
+ default:
3873
+ return parseNDigits(token.length, dateString);
3874
+ }
3875
+ }
3876
+ }, {
3877
+ key: "validate",
3878
+ value: function validate(date, value) {
3879
+ var year = date.getUTCFullYear();
3880
+ var isLeapYear = isLeapYearIndex$1(year);
3881
+ if (isLeapYear) {
3882
+ return value >= 1 && value <= 366;
3883
+ } else {
3884
+ return value >= 1 && value <= 365;
3885
+ }
3886
+ }
3887
+ }, {
3888
+ key: "set",
3889
+ value: function set(date, _flags, value) {
3890
+ date.setUTCMonth(0, value);
3891
+ date.setUTCHours(0, 0, 0, 0);
3892
+ return date;
3893
+ }
3894
+ }]);
3895
+ return DayOfYearParser;
3896
+ }(Parser);
3897
+
3898
+ function setUTCDay(dirtyDate, dirtyDay, options) {
3899
+ var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
3900
+ index.requiredArgs(2, arguments);
3901
+ var defaultOptions = getDefaultOptions();
3902
+ 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);
3903
+
3904
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
3905
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
3906
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
3907
+ }
3908
+ var date = index.toDate(dirtyDate);
3909
+ var day = toInteger(dirtyDay);
3910
+ var currentDay = date.getUTCDay();
3911
+ var remainder = day % 7;
3912
+ var dayIndex = (remainder + 7) % 7;
3913
+ var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;
3914
+ date.setUTCDate(date.getUTCDate() + diff);
3915
+ return date;
3916
+ }
3917
+
3918
+ var DayParser = /*#__PURE__*/function (_Parser) {
3919
+ _inherits(DayParser, _Parser);
3920
+ var _super = _createSuper(DayParser);
3921
+ function DayParser() {
3922
+ var _this;
3923
+ _classCallCheck(this, DayParser);
3924
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3925
+ args[_key] = arguments[_key];
3926
+ }
3927
+ _this = _super.call.apply(_super, [this].concat(args));
3928
+ _defineProperty(_assertThisInitialized(_this), "priority", 90);
3929
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['D', 'i', 'e', 'c', 't', 'T']);
3930
+ return _this;
3931
+ }
3932
+ _createClass(DayParser, [{
3933
+ key: "parse",
3934
+ value: function parse(dateString, token, match) {
3935
+ switch (token) {
3936
+ // Tue
3937
+ case 'E':
3938
+ case 'EE':
3939
+ case 'EEE':
3940
+ return match.day(dateString, {
3941
+ width: 'abbreviated',
3942
+ context: 'formatting'
3943
+ }) || match.day(dateString, {
3944
+ width: 'short',
3945
+ context: 'formatting'
3946
+ }) || match.day(dateString, {
3947
+ width: 'narrow',
3948
+ context: 'formatting'
3949
+ });
3950
+ // T
3951
+ case 'EEEEE':
3952
+ return match.day(dateString, {
3953
+ width: 'narrow',
3954
+ context: 'formatting'
3955
+ });
3956
+ // Tu
3957
+ case 'EEEEEE':
3958
+ return match.day(dateString, {
3959
+ width: 'short',
3960
+ context: 'formatting'
3961
+ }) || match.day(dateString, {
3962
+ width: 'narrow',
3963
+ context: 'formatting'
3964
+ });
3965
+ // Tuesday
3966
+ case 'EEEE':
3967
+ default:
3968
+ return match.day(dateString, {
3969
+ width: 'wide',
3970
+ context: 'formatting'
3971
+ }) || match.day(dateString, {
3972
+ width: 'abbreviated',
3973
+ context: 'formatting'
3974
+ }) || match.day(dateString, {
3975
+ width: 'short',
3976
+ context: 'formatting'
3977
+ }) || match.day(dateString, {
3978
+ width: 'narrow',
3979
+ context: 'formatting'
3980
+ });
3981
+ }
3982
+ }
3983
+ }, {
3984
+ key: "validate",
3985
+ value: function validate(_date, value) {
3986
+ return value >= 0 && value <= 6;
3987
+ }
3988
+ }, {
3989
+ key: "set",
3990
+ value: function set(date, _flags, value, options) {
3991
+ date = setUTCDay(date, value, options);
3992
+ date.setUTCHours(0, 0, 0, 0);
3993
+ return date;
3994
+ }
3995
+ }]);
3996
+ return DayParser;
3997
+ }(Parser);
3998
+
3999
+ var LocalDayParser = /*#__PURE__*/function (_Parser) {
4000
+ _inherits(LocalDayParser, _Parser);
4001
+ var _super = _createSuper(LocalDayParser);
4002
+ function LocalDayParser() {
4003
+ var _this;
4004
+ _classCallCheck(this, LocalDayParser);
4005
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4006
+ args[_key] = arguments[_key];
4007
+ }
4008
+ _this = _super.call.apply(_super, [this].concat(args));
4009
+ _defineProperty(_assertThisInitialized(_this), "priority", 90);
4010
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'c', 't', 'T']);
4011
+ return _this;
4012
+ }
4013
+ _createClass(LocalDayParser, [{
4014
+ key: "parse",
4015
+ value: function parse(dateString, token, match, options) {
4016
+ var valueCallback = function valueCallback(value) {
4017
+ var wholeWeekDays = Math.floor((value - 1) / 7) * 7;
4018
+ return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;
4019
+ };
4020
+ switch (token) {
4021
+ // 3
4022
+ case 'e':
4023
+ case 'ee':
4024
+ // 03
4025
+ return mapValue(parseNDigits(token.length, dateString), valueCallback);
4026
+ // 3rd
4027
+ case 'eo':
4028
+ return mapValue(match.ordinalNumber(dateString, {
4029
+ unit: 'day'
4030
+ }), valueCallback);
4031
+ // Tue
4032
+ case 'eee':
4033
+ return match.day(dateString, {
4034
+ width: 'abbreviated',
4035
+ context: 'formatting'
4036
+ }) || match.day(dateString, {
4037
+ width: 'short',
4038
+ context: 'formatting'
4039
+ }) || match.day(dateString, {
4040
+ width: 'narrow',
4041
+ context: 'formatting'
4042
+ });
4043
+ // T
4044
+ case 'eeeee':
4045
+ return match.day(dateString, {
4046
+ width: 'narrow',
4047
+ context: 'formatting'
4048
+ });
4049
+ // Tu
4050
+ case 'eeeeee':
4051
+ return match.day(dateString, {
4052
+ width: 'short',
4053
+ context: 'formatting'
4054
+ }) || match.day(dateString, {
4055
+ width: 'narrow',
4056
+ context: 'formatting'
4057
+ });
4058
+ // Tuesday
4059
+ case 'eeee':
4060
+ default:
4061
+ return match.day(dateString, {
4062
+ width: 'wide',
4063
+ context: 'formatting'
4064
+ }) || match.day(dateString, {
4065
+ width: 'abbreviated',
4066
+ context: 'formatting'
4067
+ }) || match.day(dateString, {
4068
+ width: 'short',
4069
+ context: 'formatting'
4070
+ }) || match.day(dateString, {
4071
+ width: 'narrow',
4072
+ context: 'formatting'
4073
+ });
4074
+ }
4075
+ }
4076
+ }, {
4077
+ key: "validate",
4078
+ value: function validate(_date, value) {
4079
+ return value >= 0 && value <= 6;
4080
+ }
4081
+ }, {
4082
+ key: "set",
4083
+ value: function set(date, _flags, value, options) {
4084
+ date = setUTCDay(date, value, options);
4085
+ date.setUTCHours(0, 0, 0, 0);
4086
+ return date;
4087
+ }
4088
+ }]);
4089
+ return LocalDayParser;
4090
+ }(Parser);
4091
+
4092
+ var StandAloneLocalDayParser = /*#__PURE__*/function (_Parser) {
4093
+ _inherits(StandAloneLocalDayParser, _Parser);
4094
+ var _super = _createSuper(StandAloneLocalDayParser);
4095
+ function StandAloneLocalDayParser() {
4096
+ var _this;
4097
+ _classCallCheck(this, StandAloneLocalDayParser);
4098
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4099
+ args[_key] = arguments[_key];
4100
+ }
4101
+ _this = _super.call.apply(_super, [this].concat(args));
4102
+ _defineProperty(_assertThisInitialized(_this), "priority", 90);
4103
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'e', 't', 'T']);
4104
+ return _this;
4105
+ }
4106
+ _createClass(StandAloneLocalDayParser, [{
4107
+ key: "parse",
4108
+ value: function parse(dateString, token, match, options) {
4109
+ var valueCallback = function valueCallback(value) {
4110
+ var wholeWeekDays = Math.floor((value - 1) / 7) * 7;
4111
+ return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;
4112
+ };
4113
+ switch (token) {
4114
+ // 3
4115
+ case 'c':
4116
+ case 'cc':
4117
+ // 03
4118
+ return mapValue(parseNDigits(token.length, dateString), valueCallback);
4119
+ // 3rd
4120
+ case 'co':
4121
+ return mapValue(match.ordinalNumber(dateString, {
4122
+ unit: 'day'
4123
+ }), valueCallback);
4124
+ // Tue
4125
+ case 'ccc':
4126
+ return match.day(dateString, {
4127
+ width: 'abbreviated',
4128
+ context: 'standalone'
4129
+ }) || match.day(dateString, {
4130
+ width: 'short',
4131
+ context: 'standalone'
4132
+ }) || match.day(dateString, {
4133
+ width: 'narrow',
4134
+ context: 'standalone'
4135
+ });
4136
+ // T
4137
+ case 'ccccc':
4138
+ return match.day(dateString, {
4139
+ width: 'narrow',
4140
+ context: 'standalone'
4141
+ });
4142
+ // Tu
4143
+ case 'cccccc':
4144
+ return match.day(dateString, {
4145
+ width: 'short',
4146
+ context: 'standalone'
4147
+ }) || match.day(dateString, {
4148
+ width: 'narrow',
4149
+ context: 'standalone'
4150
+ });
4151
+ // Tuesday
4152
+ case 'cccc':
4153
+ default:
4154
+ return match.day(dateString, {
4155
+ width: 'wide',
4156
+ context: 'standalone'
4157
+ }) || match.day(dateString, {
4158
+ width: 'abbreviated',
4159
+ context: 'standalone'
4160
+ }) || match.day(dateString, {
4161
+ width: 'short',
4162
+ context: 'standalone'
4163
+ }) || match.day(dateString, {
4164
+ width: 'narrow',
4165
+ context: 'standalone'
4166
+ });
4167
+ }
4168
+ }
4169
+ }, {
4170
+ key: "validate",
4171
+ value: function validate(_date, value) {
4172
+ return value >= 0 && value <= 6;
4173
+ }
4174
+ }, {
4175
+ key: "set",
4176
+ value: function set(date, _flags, value, options) {
4177
+ date = setUTCDay(date, value, options);
4178
+ date.setUTCHours(0, 0, 0, 0);
4179
+ return date;
4180
+ }
4181
+ }]);
4182
+ return StandAloneLocalDayParser;
4183
+ }(Parser);
4184
+
4185
+ function setUTCISODay(dirtyDate, dirtyDay) {
4186
+ index.requiredArgs(2, arguments);
4187
+ var day = toInteger(dirtyDay);
4188
+ if (day % 7 === 0) {
4189
+ day = day - 7;
4190
+ }
4191
+ var weekStartsOn = 1;
4192
+ var date = index.toDate(dirtyDate);
4193
+ var currentDay = date.getUTCDay();
4194
+ var remainder = day % 7;
4195
+ var dayIndex = (remainder + 7) % 7;
4196
+ var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;
4197
+ date.setUTCDate(date.getUTCDate() + diff);
4198
+ return date;
4199
+ }
4200
+
4201
+ var ISODayParser = /*#__PURE__*/function (_Parser) {
4202
+ _inherits(ISODayParser, _Parser);
4203
+ var _super = _createSuper(ISODayParser);
4204
+ function ISODayParser() {
4205
+ var _this;
4206
+ _classCallCheck(this, ISODayParser);
4207
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4208
+ args[_key] = arguments[_key];
4209
+ }
4210
+ _this = _super.call.apply(_super, [this].concat(args));
4211
+ _defineProperty(_assertThisInitialized(_this), "priority", 90);
4212
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'E', 'e', 'c', 't', 'T']);
4213
+ return _this;
4214
+ }
4215
+ _createClass(ISODayParser, [{
4216
+ key: "parse",
4217
+ value: function parse(dateString, token, match) {
4218
+ var valueCallback = function valueCallback(value) {
4219
+ if (value === 0) {
4220
+ return 7;
4221
+ }
4222
+ return value;
4223
+ };
4224
+ switch (token) {
4225
+ // 2
4226
+ case 'i':
4227
+ case 'ii':
4228
+ // 02
4229
+ return parseNDigits(token.length, dateString);
4230
+ // 2nd
4231
+ case 'io':
4232
+ return match.ordinalNumber(dateString, {
4233
+ unit: 'day'
4234
+ });
4235
+ // Tue
4236
+ case 'iii':
4237
+ return mapValue(match.day(dateString, {
4238
+ width: 'abbreviated',
4239
+ context: 'formatting'
4240
+ }) || match.day(dateString, {
4241
+ width: 'short',
4242
+ context: 'formatting'
4243
+ }) || match.day(dateString, {
4244
+ width: 'narrow',
4245
+ context: 'formatting'
4246
+ }), valueCallback);
4247
+ // T
4248
+ case 'iiiii':
4249
+ return mapValue(match.day(dateString, {
4250
+ width: 'narrow',
4251
+ context: 'formatting'
4252
+ }), valueCallback);
4253
+ // Tu
4254
+ case 'iiiiii':
4255
+ return mapValue(match.day(dateString, {
4256
+ width: 'short',
4257
+ context: 'formatting'
4258
+ }) || match.day(dateString, {
4259
+ width: 'narrow',
4260
+ context: 'formatting'
4261
+ }), valueCallback);
4262
+ // Tuesday
4263
+ case 'iiii':
4264
+ default:
4265
+ return mapValue(match.day(dateString, {
4266
+ width: 'wide',
4267
+ context: 'formatting'
4268
+ }) || match.day(dateString, {
4269
+ width: 'abbreviated',
4270
+ context: 'formatting'
4271
+ }) || match.day(dateString, {
4272
+ width: 'short',
4273
+ context: 'formatting'
4274
+ }) || match.day(dateString, {
4275
+ width: 'narrow',
4276
+ context: 'formatting'
4277
+ }), valueCallback);
4278
+ }
4279
+ }
4280
+ }, {
4281
+ key: "validate",
4282
+ value: function validate(_date, value) {
4283
+ return value >= 1 && value <= 7;
4284
+ }
4285
+ }, {
4286
+ key: "set",
4287
+ value: function set(date, _flags, value) {
4288
+ date = setUTCISODay(date, value);
4289
+ date.setUTCHours(0, 0, 0, 0);
4290
+ return date;
4291
+ }
4292
+ }]);
4293
+ return ISODayParser;
4294
+ }(Parser);
4295
+
4296
+ var AMPMParser = /*#__PURE__*/function (_Parser) {
4297
+ _inherits(AMPMParser, _Parser);
4298
+ var _super = _createSuper(AMPMParser);
4299
+ function AMPMParser() {
4300
+ var _this;
4301
+ _classCallCheck(this, AMPMParser);
4302
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4303
+ args[_key] = arguments[_key];
4304
+ }
4305
+ _this = _super.call.apply(_super, [this].concat(args));
4306
+ _defineProperty(_assertThisInitialized(_this), "priority", 80);
4307
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['b', 'B', 'H', 'k', 't', 'T']);
4308
+ return _this;
4309
+ }
4310
+ _createClass(AMPMParser, [{
4311
+ key: "parse",
4312
+ value: function parse(dateString, token, match) {
4313
+ switch (token) {
4314
+ case 'a':
4315
+ case 'aa':
4316
+ case 'aaa':
4317
+ return match.dayPeriod(dateString, {
4318
+ width: 'abbreviated',
4319
+ context: 'formatting'
4320
+ }) || match.dayPeriod(dateString, {
4321
+ width: 'narrow',
4322
+ context: 'formatting'
4323
+ });
4324
+ case 'aaaaa':
4325
+ return match.dayPeriod(dateString, {
4326
+ width: 'narrow',
4327
+ context: 'formatting'
4328
+ });
4329
+ case 'aaaa':
4330
+ default:
4331
+ return match.dayPeriod(dateString, {
4332
+ width: 'wide',
4333
+ context: 'formatting'
4334
+ }) || match.dayPeriod(dateString, {
4335
+ width: 'abbreviated',
4336
+ context: 'formatting'
4337
+ }) || match.dayPeriod(dateString, {
4338
+ width: 'narrow',
4339
+ context: 'formatting'
4340
+ });
4341
+ }
4342
+ }
4343
+ }, {
4344
+ key: "set",
4345
+ value: function set(date, _flags, value) {
4346
+ date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);
4347
+ return date;
4348
+ }
4349
+ }]);
4350
+ return AMPMParser;
4351
+ }(Parser);
4352
+
4353
+ var AMPMMidnightParser = /*#__PURE__*/function (_Parser) {
4354
+ _inherits(AMPMMidnightParser, _Parser);
4355
+ var _super = _createSuper(AMPMMidnightParser);
4356
+ function AMPMMidnightParser() {
4357
+ var _this;
4358
+ _classCallCheck(this, AMPMMidnightParser);
4359
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4360
+ args[_key] = arguments[_key];
4361
+ }
4362
+ _this = _super.call.apply(_super, [this].concat(args));
4363
+ _defineProperty(_assertThisInitialized(_this), "priority", 80);
4364
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'B', 'H', 'k', 't', 'T']);
4365
+ return _this;
4366
+ }
4367
+ _createClass(AMPMMidnightParser, [{
4368
+ key: "parse",
4369
+ value: function parse(dateString, token, match) {
4370
+ switch (token) {
4371
+ case 'b':
4372
+ case 'bb':
4373
+ case 'bbb':
4374
+ return match.dayPeriod(dateString, {
4375
+ width: 'abbreviated',
4376
+ context: 'formatting'
4377
+ }) || match.dayPeriod(dateString, {
4378
+ width: 'narrow',
4379
+ context: 'formatting'
4380
+ });
4381
+ case 'bbbbb':
4382
+ return match.dayPeriod(dateString, {
4383
+ width: 'narrow',
4384
+ context: 'formatting'
4385
+ });
4386
+ case 'bbbb':
4387
+ default:
4388
+ return match.dayPeriod(dateString, {
4389
+ width: 'wide',
4390
+ context: 'formatting'
4391
+ }) || match.dayPeriod(dateString, {
4392
+ width: 'abbreviated',
4393
+ context: 'formatting'
4394
+ }) || match.dayPeriod(dateString, {
4395
+ width: 'narrow',
4396
+ context: 'formatting'
4397
+ });
4398
+ }
4399
+ }
4400
+ }, {
4401
+ key: "set",
4402
+ value: function set(date, _flags, value) {
4403
+ date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);
4404
+ return date;
4405
+ }
4406
+ }]);
4407
+ return AMPMMidnightParser;
4408
+ }(Parser);
4409
+
4410
+ var DayPeriodParser = /*#__PURE__*/function (_Parser) {
4411
+ _inherits(DayPeriodParser, _Parser);
4412
+ var _super = _createSuper(DayPeriodParser);
4413
+ function DayPeriodParser() {
4414
+ var _this;
4415
+ _classCallCheck(this, DayPeriodParser);
4416
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4417
+ args[_key] = arguments[_key];
4418
+ }
4419
+ _this = _super.call.apply(_super, [this].concat(args));
4420
+ _defineProperty(_assertThisInitialized(_this), "priority", 80);
4421
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'b', 't', 'T']);
4422
+ return _this;
4423
+ }
4424
+ _createClass(DayPeriodParser, [{
4425
+ key: "parse",
4426
+ value: function parse(dateString, token, match) {
4427
+ switch (token) {
4428
+ case 'B':
4429
+ case 'BB':
4430
+ case 'BBB':
4431
+ return match.dayPeriod(dateString, {
4432
+ width: 'abbreviated',
4433
+ context: 'formatting'
4434
+ }) || match.dayPeriod(dateString, {
4435
+ width: 'narrow',
4436
+ context: 'formatting'
4437
+ });
4438
+ case 'BBBBB':
4439
+ return match.dayPeriod(dateString, {
4440
+ width: 'narrow',
4441
+ context: 'formatting'
4442
+ });
4443
+ case 'BBBB':
4444
+ default:
4445
+ return match.dayPeriod(dateString, {
4446
+ width: 'wide',
4447
+ context: 'formatting'
4448
+ }) || match.dayPeriod(dateString, {
4449
+ width: 'abbreviated',
4450
+ context: 'formatting'
4451
+ }) || match.dayPeriod(dateString, {
4452
+ width: 'narrow',
4453
+ context: 'formatting'
4454
+ });
4455
+ }
4456
+ }
4457
+ }, {
4458
+ key: "set",
4459
+ value: function set(date, _flags, value) {
4460
+ date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);
4461
+ return date;
4462
+ }
4463
+ }]);
4464
+ return DayPeriodParser;
4465
+ }(Parser);
4466
+
4467
+ var Hour1to12Parser = /*#__PURE__*/function (_Parser) {
4468
+ _inherits(Hour1to12Parser, _Parser);
4469
+ var _super = _createSuper(Hour1to12Parser);
4470
+ function Hour1to12Parser() {
4471
+ var _this;
4472
+ _classCallCheck(this, Hour1to12Parser);
4473
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4474
+ args[_key] = arguments[_key];
4475
+ }
4476
+ _this = _super.call.apply(_super, [this].concat(args));
4477
+ _defineProperty(_assertThisInitialized(_this), "priority", 70);
4478
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['H', 'K', 'k', 't', 'T']);
4479
+ return _this;
4480
+ }
4481
+ _createClass(Hour1to12Parser, [{
4482
+ key: "parse",
4483
+ value: function parse(dateString, token, match) {
4484
+ switch (token) {
4485
+ case 'h':
4486
+ return parseNumericPattern(numericPatterns.hour12h, dateString);
4487
+ case 'ho':
4488
+ return match.ordinalNumber(dateString, {
4489
+ unit: 'hour'
4490
+ });
4491
+ default:
4492
+ return parseNDigits(token.length, dateString);
4493
+ }
4494
+ }
4495
+ }, {
4496
+ key: "validate",
4497
+ value: function validate(_date, value) {
4498
+ return value >= 1 && value <= 12;
4499
+ }
4500
+ }, {
4501
+ key: "set",
4502
+ value: function set(date, _flags, value) {
4503
+ var isPM = date.getUTCHours() >= 12;
4504
+ if (isPM && value < 12) {
4505
+ date.setUTCHours(value + 12, 0, 0, 0);
4506
+ } else if (!isPM && value === 12) {
4507
+ date.setUTCHours(0, 0, 0, 0);
4508
+ } else {
4509
+ date.setUTCHours(value, 0, 0, 0);
4510
+ }
4511
+ return date;
4512
+ }
4513
+ }]);
4514
+ return Hour1to12Parser;
4515
+ }(Parser);
4516
+
4517
+ var Hour0to23Parser = /*#__PURE__*/function (_Parser) {
4518
+ _inherits(Hour0to23Parser, _Parser);
4519
+ var _super = _createSuper(Hour0to23Parser);
4520
+ function Hour0to23Parser() {
4521
+ var _this;
4522
+ _classCallCheck(this, Hour0to23Parser);
4523
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4524
+ args[_key] = arguments[_key];
4525
+ }
4526
+ _this = _super.call.apply(_super, [this].concat(args));
4527
+ _defineProperty(_assertThisInitialized(_this), "priority", 70);
4528
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'b', 'h', 'K', 'k', 't', 'T']);
4529
+ return _this;
4530
+ }
4531
+ _createClass(Hour0to23Parser, [{
4532
+ key: "parse",
4533
+ value: function parse(dateString, token, match) {
4534
+ switch (token) {
4535
+ case 'H':
4536
+ return parseNumericPattern(numericPatterns.hour23h, dateString);
4537
+ case 'Ho':
4538
+ return match.ordinalNumber(dateString, {
4539
+ unit: 'hour'
4540
+ });
4541
+ default:
4542
+ return parseNDigits(token.length, dateString);
4543
+ }
4544
+ }
4545
+ }, {
4546
+ key: "validate",
4547
+ value: function validate(_date, value) {
4548
+ return value >= 0 && value <= 23;
4549
+ }
4550
+ }, {
4551
+ key: "set",
4552
+ value: function set(date, _flags, value) {
4553
+ date.setUTCHours(value, 0, 0, 0);
4554
+ return date;
4555
+ }
4556
+ }]);
4557
+ return Hour0to23Parser;
4558
+ }(Parser);
4559
+
4560
+ var Hour0To11Parser = /*#__PURE__*/function (_Parser) {
4561
+ _inherits(Hour0To11Parser, _Parser);
4562
+ var _super = _createSuper(Hour0To11Parser);
4563
+ function Hour0To11Parser() {
4564
+ var _this;
4565
+ _classCallCheck(this, Hour0To11Parser);
4566
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4567
+ args[_key] = arguments[_key];
4568
+ }
4569
+ _this = _super.call.apply(_super, [this].concat(args));
4570
+ _defineProperty(_assertThisInitialized(_this), "priority", 70);
4571
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['h', 'H', 'k', 't', 'T']);
4572
+ return _this;
4573
+ }
4574
+ _createClass(Hour0To11Parser, [{
4575
+ key: "parse",
4576
+ value: function parse(dateString, token, match) {
4577
+ switch (token) {
4578
+ case 'K':
4579
+ return parseNumericPattern(numericPatterns.hour11h, dateString);
4580
+ case 'Ko':
4581
+ return match.ordinalNumber(dateString, {
4582
+ unit: 'hour'
4583
+ });
4584
+ default:
4585
+ return parseNDigits(token.length, dateString);
4586
+ }
4587
+ }
4588
+ }, {
4589
+ key: "validate",
4590
+ value: function validate(_date, value) {
4591
+ return value >= 0 && value <= 11;
4592
+ }
4593
+ }, {
4594
+ key: "set",
4595
+ value: function set(date, _flags, value) {
4596
+ var isPM = date.getUTCHours() >= 12;
4597
+ if (isPM && value < 12) {
4598
+ date.setUTCHours(value + 12, 0, 0, 0);
4599
+ } else {
4600
+ date.setUTCHours(value, 0, 0, 0);
4601
+ }
4602
+ return date;
4603
+ }
4604
+ }]);
4605
+ return Hour0To11Parser;
4606
+ }(Parser);
4607
+
4608
+ var Hour1To24Parser = /*#__PURE__*/function (_Parser) {
4609
+ _inherits(Hour1To24Parser, _Parser);
4610
+ var _super = _createSuper(Hour1To24Parser);
4611
+ function Hour1To24Parser() {
4612
+ var _this;
4613
+ _classCallCheck(this, Hour1To24Parser);
4614
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4615
+ args[_key] = arguments[_key];
4616
+ }
4617
+ _this = _super.call.apply(_super, [this].concat(args));
4618
+ _defineProperty(_assertThisInitialized(_this), "priority", 70);
4619
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['a', 'b', 'h', 'H', 'K', 't', 'T']);
4620
+ return _this;
4621
+ }
4622
+ _createClass(Hour1To24Parser, [{
4623
+ key: "parse",
4624
+ value: function parse(dateString, token, match) {
4625
+ switch (token) {
4626
+ case 'k':
4627
+ return parseNumericPattern(numericPatterns.hour24h, dateString);
4628
+ case 'ko':
4629
+ return match.ordinalNumber(dateString, {
4630
+ unit: 'hour'
4631
+ });
4632
+ default:
4633
+ return parseNDigits(token.length, dateString);
4634
+ }
4635
+ }
4636
+ }, {
4637
+ key: "validate",
4638
+ value: function validate(_date, value) {
4639
+ return value >= 1 && value <= 24;
4640
+ }
4641
+ }, {
4642
+ key: "set",
4643
+ value: function set(date, _flags, value) {
4644
+ var hours = value <= 24 ? value % 24 : value;
4645
+ date.setUTCHours(hours, 0, 0, 0);
4646
+ return date;
4647
+ }
4648
+ }]);
4649
+ return Hour1To24Parser;
4650
+ }(Parser);
4651
+
4652
+ var MinuteParser = /*#__PURE__*/function (_Parser) {
4653
+ _inherits(MinuteParser, _Parser);
4654
+ var _super = _createSuper(MinuteParser);
4655
+ function MinuteParser() {
4656
+ var _this;
4657
+ _classCallCheck(this, MinuteParser);
4658
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4659
+ args[_key] = arguments[_key];
4660
+ }
4661
+ _this = _super.call.apply(_super, [this].concat(args));
4662
+ _defineProperty(_assertThisInitialized(_this), "priority", 60);
4663
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T']);
4664
+ return _this;
4665
+ }
4666
+ _createClass(MinuteParser, [{
4667
+ key: "parse",
4668
+ value: function parse(dateString, token, match) {
4669
+ switch (token) {
4670
+ case 'm':
4671
+ return parseNumericPattern(numericPatterns.minute, dateString);
4672
+ case 'mo':
4673
+ return match.ordinalNumber(dateString, {
4674
+ unit: 'minute'
4675
+ });
4676
+ default:
4677
+ return parseNDigits(token.length, dateString);
4678
+ }
4679
+ }
4680
+ }, {
4681
+ key: "validate",
4682
+ value: function validate(_date, value) {
4683
+ return value >= 0 && value <= 59;
4684
+ }
4685
+ }, {
4686
+ key: "set",
4687
+ value: function set(date, _flags, value) {
4688
+ date.setUTCMinutes(value, 0, 0);
4689
+ return date;
4690
+ }
4691
+ }]);
4692
+ return MinuteParser;
4693
+ }(Parser);
4694
+
4695
+ var SecondParser = /*#__PURE__*/function (_Parser) {
4696
+ _inherits(SecondParser, _Parser);
4697
+ var _super = _createSuper(SecondParser);
4698
+ function SecondParser() {
4699
+ var _this;
4700
+ _classCallCheck(this, SecondParser);
4701
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4702
+ args[_key] = arguments[_key];
4703
+ }
4704
+ _this = _super.call.apply(_super, [this].concat(args));
4705
+ _defineProperty(_assertThisInitialized(_this), "priority", 50);
4706
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T']);
4707
+ return _this;
4708
+ }
4709
+ _createClass(SecondParser, [{
4710
+ key: "parse",
4711
+ value: function parse(dateString, token, match) {
4712
+ switch (token) {
4713
+ case 's':
4714
+ return parseNumericPattern(numericPatterns.second, dateString);
4715
+ case 'so':
4716
+ return match.ordinalNumber(dateString, {
4717
+ unit: 'second'
4718
+ });
4719
+ default:
4720
+ return parseNDigits(token.length, dateString);
4721
+ }
4722
+ }
4723
+ }, {
4724
+ key: "validate",
4725
+ value: function validate(_date, value) {
4726
+ return value >= 0 && value <= 59;
4727
+ }
4728
+ }, {
4729
+ key: "set",
4730
+ value: function set(date, _flags, value) {
4731
+ date.setUTCSeconds(value, 0);
4732
+ return date;
4733
+ }
4734
+ }]);
4735
+ return SecondParser;
4736
+ }(Parser);
4737
+
4738
+ var FractionOfSecondParser = /*#__PURE__*/function (_Parser) {
4739
+ _inherits(FractionOfSecondParser, _Parser);
4740
+ var _super = _createSuper(FractionOfSecondParser);
4741
+ function FractionOfSecondParser() {
4742
+ var _this;
4743
+ _classCallCheck(this, FractionOfSecondParser);
4744
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4745
+ args[_key] = arguments[_key];
4746
+ }
4747
+ _this = _super.call.apply(_super, [this].concat(args));
4748
+ _defineProperty(_assertThisInitialized(_this), "priority", 30);
4749
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T']);
4750
+ return _this;
4751
+ }
4752
+ _createClass(FractionOfSecondParser, [{
4753
+ key: "parse",
4754
+ value: function parse(dateString, token) {
4755
+ var valueCallback = function valueCallback(value) {
4756
+ return Math.floor(value * Math.pow(10, -token.length + 3));
4757
+ };
4758
+ return mapValue(parseNDigits(token.length, dateString), valueCallback);
4759
+ }
4760
+ }, {
4761
+ key: "set",
4762
+ value: function set(date, _flags, value) {
4763
+ date.setUTCMilliseconds(value);
4764
+ return date;
4765
+ }
4766
+ }]);
4767
+ return FractionOfSecondParser;
4768
+ }(Parser);
4769
+
4770
+ var ISOTimezoneWithZParser = /*#__PURE__*/function (_Parser) {
4771
+ _inherits(ISOTimezoneWithZParser, _Parser);
4772
+ var _super = _createSuper(ISOTimezoneWithZParser);
4773
+ function ISOTimezoneWithZParser() {
4774
+ var _this;
4775
+ _classCallCheck(this, ISOTimezoneWithZParser);
4776
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4777
+ args[_key] = arguments[_key];
4778
+ }
4779
+ _this = _super.call.apply(_super, [this].concat(args));
4780
+ _defineProperty(_assertThisInitialized(_this), "priority", 10);
4781
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T', 'x']);
4782
+ return _this;
4783
+ }
4784
+ _createClass(ISOTimezoneWithZParser, [{
4785
+ key: "parse",
4786
+ value: function parse(dateString, token) {
4787
+ switch (token) {
4788
+ case 'X':
4789
+ return parseTimezonePattern(timezonePatterns.basicOptionalMinutes, dateString);
4790
+ case 'XX':
4791
+ return parseTimezonePattern(timezonePatterns.basic, dateString);
4792
+ case 'XXXX':
4793
+ return parseTimezonePattern(timezonePatterns.basicOptionalSeconds, dateString);
4794
+ case 'XXXXX':
4795
+ return parseTimezonePattern(timezonePatterns.extendedOptionalSeconds, dateString);
4796
+ case 'XXX':
4797
+ default:
4798
+ return parseTimezonePattern(timezonePatterns.extended, dateString);
4799
+ }
4800
+ }
4801
+ }, {
4802
+ key: "set",
4803
+ value: function set(date, flags, value) {
4804
+ if (flags.timestampIsSet) {
4805
+ return date;
4806
+ }
4807
+ return new Date(date.getTime() - value);
4808
+ }
4809
+ }]);
4810
+ return ISOTimezoneWithZParser;
4811
+ }(Parser);
4812
+
4813
+ var ISOTimezoneParser = /*#__PURE__*/function (_Parser) {
4814
+ _inherits(ISOTimezoneParser, _Parser);
4815
+ var _super = _createSuper(ISOTimezoneParser);
4816
+ function ISOTimezoneParser() {
4817
+ var _this;
4818
+ _classCallCheck(this, ISOTimezoneParser);
4819
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4820
+ args[_key] = arguments[_key];
4821
+ }
4822
+ _this = _super.call.apply(_super, [this].concat(args));
4823
+ _defineProperty(_assertThisInitialized(_this), "priority", 10);
4824
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", ['t', 'T', 'X']);
4825
+ return _this;
4826
+ }
4827
+ _createClass(ISOTimezoneParser, [{
4828
+ key: "parse",
4829
+ value: function parse(dateString, token) {
4830
+ switch (token) {
4831
+ case 'x':
4832
+ return parseTimezonePattern(timezonePatterns.basicOptionalMinutes, dateString);
4833
+ case 'xx':
4834
+ return parseTimezonePattern(timezonePatterns.basic, dateString);
4835
+ case 'xxxx':
4836
+ return parseTimezonePattern(timezonePatterns.basicOptionalSeconds, dateString);
4837
+ case 'xxxxx':
4838
+ return parseTimezonePattern(timezonePatterns.extendedOptionalSeconds, dateString);
4839
+ case 'xxx':
4840
+ default:
4841
+ return parseTimezonePattern(timezonePatterns.extended, dateString);
4842
+ }
4843
+ }
4844
+ }, {
4845
+ key: "set",
4846
+ value: function set(date, flags, value) {
4847
+ if (flags.timestampIsSet) {
4848
+ return date;
4849
+ }
4850
+ return new Date(date.getTime() - value);
4851
+ }
4852
+ }]);
4853
+ return ISOTimezoneParser;
4854
+ }(Parser);
4855
+
4856
+ var TimestampSecondsParser = /*#__PURE__*/function (_Parser) {
4857
+ _inherits(TimestampSecondsParser, _Parser);
4858
+ var _super = _createSuper(TimestampSecondsParser);
4859
+ function TimestampSecondsParser() {
4860
+ var _this;
4861
+ _classCallCheck(this, TimestampSecondsParser);
4862
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4863
+ args[_key] = arguments[_key];
4864
+ }
4865
+ _this = _super.call.apply(_super, [this].concat(args));
4866
+ _defineProperty(_assertThisInitialized(_this), "priority", 40);
4867
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", '*');
4868
+ return _this;
4869
+ }
4870
+ _createClass(TimestampSecondsParser, [{
4871
+ key: "parse",
4872
+ value: function parse(dateString) {
4873
+ return parseAnyDigitsSigned(dateString);
4874
+ }
4875
+ }, {
4876
+ key: "set",
4877
+ value: function set(_date, _flags, value) {
4878
+ return [new Date(value * 1000), {
4879
+ timestampIsSet: true
4880
+ }];
4881
+ }
4882
+ }]);
4883
+ return TimestampSecondsParser;
4884
+ }(Parser);
4885
+
4886
+ var TimestampMillisecondsParser = /*#__PURE__*/function (_Parser) {
4887
+ _inherits(TimestampMillisecondsParser, _Parser);
4888
+ var _super = _createSuper(TimestampMillisecondsParser);
4889
+ function TimestampMillisecondsParser() {
4890
+ var _this;
4891
+ _classCallCheck(this, TimestampMillisecondsParser);
4892
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4893
+ args[_key] = arguments[_key];
4894
+ }
4895
+ _this = _super.call.apply(_super, [this].concat(args));
4896
+ _defineProperty(_assertThisInitialized(_this), "priority", 20);
4897
+ _defineProperty(_assertThisInitialized(_this), "incompatibleTokens", '*');
4898
+ return _this;
4899
+ }
4900
+ _createClass(TimestampMillisecondsParser, [{
4901
+ key: "parse",
4902
+ value: function parse(dateString) {
4903
+ return parseAnyDigitsSigned(dateString);
4904
+ }
4905
+ }, {
4906
+ key: "set",
4907
+ value: function set(_date, _flags, value) {
4908
+ return [new Date(value), {
4909
+ timestampIsSet: true
4910
+ }];
4911
+ }
4912
+ }]);
4913
+ return TimestampMillisecondsParser;
4914
+ }(Parser);
4915
+
4916
+ /*
4917
+ * | | Unit | | Unit |
4918
+ * |-----|--------------------------------|-----|--------------------------------|
4919
+ * | a | AM, PM | A* | Milliseconds in day |
4920
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
4921
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
4922
+ * | d | Day of month | D | Day of year |
4923
+ * | e | Local day of week | E | Day of week |
4924
+ * | f | | F* | Day of week in month |
4925
+ * | g* | Modified Julian day | G | Era |
4926
+ * | h | Hour [1-12] | H | Hour [0-23] |
4927
+ * | i! | ISO day of week | I! | ISO week of year |
4928
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
4929
+ * | k | Hour [1-24] | K | Hour [0-11] |
4930
+ * | l* | (deprecated) | L | Stand-alone month |
4931
+ * | m | Minute | M | Month |
4932
+ * | n | | N | |
4933
+ * | o! | Ordinal number modifier | O* | Timezone (GMT) |
4934
+ * | p | | P | |
4935
+ * | q | Stand-alone quarter | Q | Quarter |
4936
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
4937
+ * | s | Second | S | Fraction of second |
4938
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
4939
+ * | u | Extended year | U* | Cyclic year |
4940
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
4941
+ * | w | Local week of year | W* | Week of month |
4942
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
4943
+ * | y | Year (abs) | Y | Local week-numbering year |
4944
+ * | z* | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
4945
+ *
4946
+ * Letters marked by * are not implemented but reserved by Unicode standard.
4947
+ *
4948
+ * Letters marked by ! are non-standard, but implemented by date-fns:
4949
+ * - `o` modifies the previous token to turn it into an ordinal (see `parse` docs)
4950
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
4951
+ * i.e. 7 for Sunday, 1 for Monday, etc.
4952
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
4953
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
4954
+ * `R` is supposed to be used in conjunction with `I` and `i`
4955
+ * for universal ISO week-numbering date, whereas
4956
+ * `Y` is supposed to be used in conjunction with `w` and `e`
4957
+ * for week-numbering date specific to the locale.
4958
+ */
4959
+ var parsers = {
4960
+ G: new EraParser(),
4961
+ y: new YearParser(),
4962
+ Y: new LocalWeekYearParser(),
4963
+ R: new ISOWeekYearParser(),
4964
+ u: new ExtendedYearParser(),
4965
+ Q: new QuarterParser(),
4966
+ q: new StandAloneQuarterParser(),
4967
+ M: new MonthParser(),
4968
+ L: new StandAloneMonthParser(),
4969
+ w: new LocalWeekParser(),
4970
+ I: new ISOWeekParser(),
4971
+ d: new DateParser(),
4972
+ D: new DayOfYearParser(),
4973
+ E: new DayParser(),
4974
+ e: new LocalDayParser(),
4975
+ c: new StandAloneLocalDayParser(),
4976
+ i: new ISODayParser(),
4977
+ a: new AMPMParser(),
4978
+ b: new AMPMMidnightParser(),
4979
+ B: new DayPeriodParser(),
4980
+ h: new Hour1to12Parser(),
4981
+ H: new Hour0to23Parser(),
4982
+ K: new Hour0To11Parser(),
4983
+ k: new Hour1To24Parser(),
4984
+ m: new MinuteParser(),
4985
+ s: new SecondParser(),
4986
+ S: new FractionOfSecondParser(),
4987
+ X: new ISOTimezoneWithZParser(),
4988
+ x: new ISOTimezoneParser(),
4989
+ t: new TimestampSecondsParser(),
4990
+ T: new TimestampMillisecondsParser()
4991
+ };
4992
+
4993
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
4994
+ // (one of the certain letters followed by `o`)
4995
+ // - (\w)\1* matches any sequences of the same letter
4996
+ // - '' matches two quote characters in a row
4997
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
4998
+ // except a single quote symbol, which ends the sequence.
4999
+ // Two quote characters do not end the sequence.
5000
+ // If there is no matching single quote
5001
+ // then the sequence will continue until the end of the string.
5002
+ // - . matches any single character unmatched by previous parts of the RegExps
5003
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
5004
+
5005
+ // This RegExp catches symbols escaped by quotes, and also
5006
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
5007
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
5008
+ var escapedStringRegExp = /^'([^]*?)'?$/;
5009
+ var doubleQuoteRegExp = /''/g;
5010
+ var notWhitespaceRegExp = /\S/;
5011
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
5012
+
5013
+ /**
5014
+ * @name parse
5015
+ * @category Common Helpers
5016
+ * @summary Parse the date.
5017
+ *
5018
+ * @description
5019
+ * Return the date parsed from string using the given format string.
5020
+ *
5021
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
5022
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
5023
+ *
5024
+ * The characters in the format string wrapped between two single quotes characters (') are escaped.
5025
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
5026
+ *
5027
+ * Format of the format string is based on Unicode Technical Standard #35:
5028
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
5029
+ * with a few additions (see note 5 below the table).
5030
+ *
5031
+ * Not all tokens are compatible. Combinations that don't make sense or could lead to bugs are prohibited
5032
+ * and will throw `RangeError`. For example usage of 24-hour format token with AM/PM token will throw an exception:
5033
+ *
5034
+ * ```javascript
5035
+ * parse('23 AM', 'HH a', new Date())
5036
+ * //=> RangeError: The format string mustn't contain `HH` and `a` at the same time
5037
+ * ```
5038
+ *
5039
+ * See the compatibility table: https://docs.google.com/spreadsheets/d/e/2PACX-1vQOPU3xUhplll6dyoMmVUXHKl_8CRDs6_ueLmex3SoqwhuolkuN3O05l4rqx5h1dKX8eb46Ul-CCSrq/pubhtml?gid=0&single=true
5040
+ *
5041
+ * Accepted format string patterns:
5042
+ * | Unit |Prior| Pattern | Result examples | Notes |
5043
+ * |---------------------------------|-----|---------|-----------------------------------|-------|
5044
+ * | Era | 140 | G..GGG | AD, BC | |
5045
+ * | | | GGGG | Anno Domini, Before Christ | 2 |
5046
+ * | | | GGGGG | A, B | |
5047
+ * | Calendar year | 130 | y | 44, 1, 1900, 2017, 9999 | 4 |
5048
+ * | | | yo | 44th, 1st, 1900th, 9999999th | 4,5 |
5049
+ * | | | yy | 44, 01, 00, 17 | 4 |
5050
+ * | | | yyy | 044, 001, 123, 999 | 4 |
5051
+ * | | | yyyy | 0044, 0001, 1900, 2017 | 4 |
5052
+ * | | | yyyyy | ... | 2,4 |
5053
+ * | Local week-numbering year | 130 | Y | 44, 1, 1900, 2017, 9000 | 4 |
5054
+ * | | | Yo | 44th, 1st, 1900th, 9999999th | 4,5 |
5055
+ * | | | YY | 44, 01, 00, 17 | 4,6 |
5056
+ * | | | YYY | 044, 001, 123, 999 | 4 |
5057
+ * | | | YYYY | 0044, 0001, 1900, 2017 | 4,6 |
5058
+ * | | | YYYYY | ... | 2,4 |
5059
+ * | ISO week-numbering year | 130 | R | -43, 1, 1900, 2017, 9999, -9999 | 4,5 |
5060
+ * | | | RR | -43, 01, 00, 17 | 4,5 |
5061
+ * | | | RRR | -043, 001, 123, 999, -999 | 4,5 |
5062
+ * | | | RRRR | -0043, 0001, 2017, 9999, -9999 | 4,5 |
5063
+ * | | | RRRRR | ... | 2,4,5 |
5064
+ * | Extended year | 130 | u | -43, 1, 1900, 2017, 9999, -999 | 4 |
5065
+ * | | | uu | -43, 01, 99, -99 | 4 |
5066
+ * | | | uuu | -043, 001, 123, 999, -999 | 4 |
5067
+ * | | | uuuu | -0043, 0001, 2017, 9999, -9999 | 4 |
5068
+ * | | | uuuuu | ... | 2,4 |
5069
+ * | Quarter (formatting) | 120 | Q | 1, 2, 3, 4 | |
5070
+ * | | | Qo | 1st, 2nd, 3rd, 4th | 5 |
5071
+ * | | | QQ | 01, 02, 03, 04 | |
5072
+ * | | | QQQ | Q1, Q2, Q3, Q4 | |
5073
+ * | | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
5074
+ * | | | QQQQQ | 1, 2, 3, 4 | 4 |
5075
+ * | Quarter (stand-alone) | 120 | q | 1, 2, 3, 4 | |
5076
+ * | | | qo | 1st, 2nd, 3rd, 4th | 5 |
5077
+ * | | | qq | 01, 02, 03, 04 | |
5078
+ * | | | qqq | Q1, Q2, Q3, Q4 | |
5079
+ * | | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
5080
+ * | | | qqqqq | 1, 2, 3, 4 | 3 |
5081
+ * | Month (formatting) | 110 | M | 1, 2, ..., 12 | |
5082
+ * | | | Mo | 1st, 2nd, ..., 12th | 5 |
5083
+ * | | | MM | 01, 02, ..., 12 | |
5084
+ * | | | MMM | Jan, Feb, ..., Dec | |
5085
+ * | | | MMMM | January, February, ..., December | 2 |
5086
+ * | | | MMMMM | J, F, ..., D | |
5087
+ * | Month (stand-alone) | 110 | L | 1, 2, ..., 12 | |
5088
+ * | | | Lo | 1st, 2nd, ..., 12th | 5 |
5089
+ * | | | LL | 01, 02, ..., 12 | |
5090
+ * | | | LLL | Jan, Feb, ..., Dec | |
5091
+ * | | | LLLL | January, February, ..., December | 2 |
5092
+ * | | | LLLLL | J, F, ..., D | |
5093
+ * | Local week of year | 100 | w | 1, 2, ..., 53 | |
5094
+ * | | | wo | 1st, 2nd, ..., 53th | 5 |
5095
+ * | | | ww | 01, 02, ..., 53 | |
5096
+ * | ISO week of year | 100 | I | 1, 2, ..., 53 | 5 |
5097
+ * | | | Io | 1st, 2nd, ..., 53th | 5 |
5098
+ * | | | II | 01, 02, ..., 53 | 5 |
5099
+ * | Day of month | 90 | d | 1, 2, ..., 31 | |
5100
+ * | | | do | 1st, 2nd, ..., 31st | 5 |
5101
+ * | | | dd | 01, 02, ..., 31 | |
5102
+ * | Day of year | 90 | D | 1, 2, ..., 365, 366 | 7 |
5103
+ * | | | Do | 1st, 2nd, ..., 365th, 366th | 5 |
5104
+ * | | | DD | 01, 02, ..., 365, 366 | 7 |
5105
+ * | | | DDD | 001, 002, ..., 365, 366 | |
5106
+ * | | | DDDD | ... | 2 |
5107
+ * | Day of week (formatting) | 90 | E..EEE | Mon, Tue, Wed, ..., Sun | |
5108
+ * | | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
5109
+ * | | | EEEEE | M, T, W, T, F, S, S | |
5110
+ * | | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
5111
+ * | ISO day of week (formatting) | 90 | i | 1, 2, 3, ..., 7 | 5 |
5112
+ * | | | io | 1st, 2nd, ..., 7th | 5 |
5113
+ * | | | ii | 01, 02, ..., 07 | 5 |
5114
+ * | | | iii | Mon, Tue, Wed, ..., Sun | 5 |
5115
+ * | | | iiii | Monday, Tuesday, ..., Sunday | 2,5 |
5116
+ * | | | iiiii | M, T, W, T, F, S, S | 5 |
5117
+ * | | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 5 |
5118
+ * | Local day of week (formatting) | 90 | e | 2, 3, 4, ..., 1 | |
5119
+ * | | | eo | 2nd, 3rd, ..., 1st | 5 |
5120
+ * | | | ee | 02, 03, ..., 01 | |
5121
+ * | | | eee | Mon, Tue, Wed, ..., Sun | |
5122
+ * | | | eeee | Monday, Tuesday, ..., Sunday | 2 |
5123
+ * | | | eeeee | M, T, W, T, F, S, S | |
5124
+ * | | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
5125
+ * | Local day of week (stand-alone) | 90 | c | 2, 3, 4, ..., 1 | |
5126
+ * | | | co | 2nd, 3rd, ..., 1st | 5 |
5127
+ * | | | cc | 02, 03, ..., 01 | |
5128
+ * | | | ccc | Mon, Tue, Wed, ..., Sun | |
5129
+ * | | | cccc | Monday, Tuesday, ..., Sunday | 2 |
5130
+ * | | | ccccc | M, T, W, T, F, S, S | |
5131
+ * | | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
5132
+ * | AM, PM | 80 | a..aaa | AM, PM | |
5133
+ * | | | aaaa | a.m., p.m. | 2 |
5134
+ * | | | aaaaa | a, p | |
5135
+ * | AM, PM, noon, midnight | 80 | b..bbb | AM, PM, noon, midnight | |
5136
+ * | | | bbbb | a.m., p.m., noon, midnight | 2 |
5137
+ * | | | bbbbb | a, p, n, mi | |
5138
+ * | Flexible day period | 80 | B..BBB | at night, in the morning, ... | |
5139
+ * | | | BBBB | at night, in the morning, ... | 2 |
5140
+ * | | | BBBBB | at night, in the morning, ... | |
5141
+ * | Hour [1-12] | 70 | h | 1, 2, ..., 11, 12 | |
5142
+ * | | | ho | 1st, 2nd, ..., 11th, 12th | 5 |
5143
+ * | | | hh | 01, 02, ..., 11, 12 | |
5144
+ * | Hour [0-23] | 70 | H | 0, 1, 2, ..., 23 | |
5145
+ * | | | Ho | 0th, 1st, 2nd, ..., 23rd | 5 |
5146
+ * | | | HH | 00, 01, 02, ..., 23 | |
5147
+ * | Hour [0-11] | 70 | K | 1, 2, ..., 11, 0 | |
5148
+ * | | | Ko | 1st, 2nd, ..., 11th, 0th | 5 |
5149
+ * | | | KK | 01, 02, ..., 11, 00 | |
5150
+ * | Hour [1-24] | 70 | k | 24, 1, 2, ..., 23 | |
5151
+ * | | | ko | 24th, 1st, 2nd, ..., 23rd | 5 |
5152
+ * | | | kk | 24, 01, 02, ..., 23 | |
5153
+ * | Minute | 60 | m | 0, 1, ..., 59 | |
5154
+ * | | | mo | 0th, 1st, ..., 59th | 5 |
5155
+ * | | | mm | 00, 01, ..., 59 | |
5156
+ * | Second | 50 | s | 0, 1, ..., 59 | |
5157
+ * | | | so | 0th, 1st, ..., 59th | 5 |
5158
+ * | | | ss | 00, 01, ..., 59 | |
5159
+ * | Seconds timestamp | 40 | t | 512969520 | |
5160
+ * | | | tt | ... | 2 |
5161
+ * | Fraction of second | 30 | S | 0, 1, ..., 9 | |
5162
+ * | | | SS | 00, 01, ..., 99 | |
5163
+ * | | | SSS | 000, 001, ..., 999 | |
5164
+ * | | | SSSS | ... | 2 |
5165
+ * | Milliseconds timestamp | 20 | T | 512969520900 | |
5166
+ * | | | TT | ... | 2 |
5167
+ * | Timezone (ISO-8601 w/ Z) | 10 | X | -08, +0530, Z | |
5168
+ * | | | XX | -0800, +0530, Z | |
5169
+ * | | | XXX | -08:00, +05:30, Z | |
5170
+ * | | | XXXX | -0800, +0530, Z, +123456 | 2 |
5171
+ * | | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
5172
+ * | Timezone (ISO-8601 w/o Z) | 10 | x | -08, +0530, +00 | |
5173
+ * | | | xx | -0800, +0530, +0000 | |
5174
+ * | | | xxx | -08:00, +05:30, +00:00 | 2 |
5175
+ * | | | xxxx | -0800, +0530, +0000, +123456 | |
5176
+ * | | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
5177
+ * | Long localized date | NA | P | 05/29/1453 | 5,8 |
5178
+ * | | | PP | May 29, 1453 | |
5179
+ * | | | PPP | May 29th, 1453 | |
5180
+ * | | | PPPP | Sunday, May 29th, 1453 | 2,5,8 |
5181
+ * | Long localized time | NA | p | 12:00 AM | 5,8 |
5182
+ * | | | pp | 12:00:00 AM | |
5183
+ * | Combination of date and time | NA | Pp | 05/29/1453, 12:00 AM | |
5184
+ * | | | PPpp | May 29, 1453, 12:00:00 AM | |
5185
+ * | | | PPPpp | May 29th, 1453 at ... | |
5186
+ * | | | PPPPpp | Sunday, May 29th, 1453 at ... | 2,5,8 |
5187
+ * Notes:
5188
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
5189
+ * are the same as "stand-alone" units, but are different in some languages.
5190
+ * "Formatting" units are declined according to the rules of the language
5191
+ * in the context of a date. "Stand-alone" units are always nominative singular.
5192
+ * In `format` function, they will produce different result:
5193
+ *
5194
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
5195
+ *
5196
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
5197
+ *
5198
+ * `parse` will try to match both formatting and stand-alone units interchangably.
5199
+ *
5200
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
5201
+ * the single quote characters (see below).
5202
+ * If the sequence is longer than listed in table:
5203
+ * - for numerical units (`yyyyyyyy`) `parse` will try to match a number
5204
+ * as wide as the sequence
5205
+ * - for text units (`MMMMMMMM`) `parse` will try to match the widest variation of the unit.
5206
+ * These variations are marked with "2" in the last column of the table.
5207
+ *
5208
+ * 3. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
5209
+ * These tokens represent the shortest form of the quarter.
5210
+ *
5211
+ * 4. The main difference between `y` and `u` patterns are B.C. years:
5212
+ *
5213
+ * | Year | `y` | `u` |
5214
+ * |------|-----|-----|
5215
+ * | AC 1 | 1 | 1 |
5216
+ * | BC 1 | 1 | 0 |
5217
+ * | BC 2 | 2 | -1 |
5218
+ *
5219
+ * Also `yy` will try to guess the century of two digit year by proximity with `referenceDate`:
5220
+ *
5221
+ * `parse('50', 'yy', new Date(2018, 0, 1)) //=> Sat Jan 01 2050 00:00:00`
5222
+ *
5223
+ * `parse('75', 'yy', new Date(2018, 0, 1)) //=> Wed Jan 01 1975 00:00:00`
5224
+ *
5225
+ * while `uu` will just assign the year as is:
5226
+ *
5227
+ * `parse('50', 'uu', new Date(2018, 0, 1)) //=> Sat Jan 01 0050 00:00:00`
5228
+ *
5229
+ * `parse('75', 'uu', new Date(2018, 0, 1)) //=> Tue Jan 01 0075 00:00:00`
5230
+ *
5231
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
5232
+ * except local week-numbering years are dependent on `options.weekStartsOn`
5233
+ * and `options.firstWeekContainsDate` (compare [setISOWeekYear]{@link https://date-fns.org/docs/setISOWeekYear}
5234
+ * and [setWeekYear]{@link https://date-fns.org/docs/setWeekYear}).
5235
+ *
5236
+ * 5. These patterns are not in the Unicode Technical Standard #35:
5237
+ * - `i`: ISO day of week
5238
+ * - `I`: ISO week of year
5239
+ * - `R`: ISO week-numbering year
5240
+ * - `o`: ordinal number modifier
5241
+ * - `P`: long localized date
5242
+ * - `p`: long localized time
5243
+ *
5244
+ * 6. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
5245
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
5246
+ *
5247
+ * 7. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.
5248
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
5249
+ *
5250
+ * 8. `P+` tokens do not have a defined priority since they are merely aliases to other tokens based
5251
+ * on the given locale.
5252
+ *
5253
+ * using `en-US` locale: `P` => `MM/dd/yyyy`
5254
+ * using `en-US` locale: `p` => `hh:mm a`
5255
+ * using `pt-BR` locale: `P` => `dd/MM/yyyy`
5256
+ * using `pt-BR` locale: `p` => `HH:mm`
5257
+ *
5258
+ * Values will be assigned to the date in the descending order of its unit's priority.
5259
+ * Units of an equal priority overwrite each other in the order of appearance.
5260
+ *
5261
+ * If no values of higher priority are parsed (e.g. when parsing string 'January 1st' without a year),
5262
+ * the values will be taken from 3rd argument `referenceDate` which works as a context of parsing.
5263
+ *
5264
+ * `referenceDate` must be passed for correct work of the function.
5265
+ * If you're not sure which `referenceDate` to supply, create a new instance of Date:
5266
+ * `parse('02/11/2014', 'MM/dd/yyyy', new Date())`
5267
+ * In this case parsing will be done in the context of the current date.
5268
+ * If `referenceDate` is `Invalid Date` or a value not convertible to valid `Date`,
5269
+ * then `Invalid Date` will be returned.
5270
+ *
5271
+ * The result may vary by locale.
5272
+ *
5273
+ * If `formatString` matches with `dateString` but does not provides tokens, `referenceDate` will be returned.
5274
+ *
5275
+ * If parsing failed, `Invalid Date` will be returned.
5276
+ * Invalid Date is a Date, whose time value is NaN.
5277
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
5278
+ *
5279
+ * @param {String} dateString - the string to parse
5280
+ * @param {String} formatString - the string of tokens
5281
+ * @param {Date|Number} referenceDate - defines values missing from the parsed dateString
5282
+ * @param {Object} [options] - an object with options.
5283
+ * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
5284
+ * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
5285
+ * @param {1|2|3|4|5|6|7} [options.firstWeekContainsDate=1] - the day of January, which is always in the first week of the year
5286
+ * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
5287
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
5288
+ * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
5289
+ * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
5290
+ * @returns {Date} the parsed date
5291
+ * @throws {TypeError} 3 arguments required
5292
+ * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
5293
+ * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
5294
+ * @throws {RangeError} `options.locale` must contain `match` property
5295
+ * @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
5296
+ * @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
5297
+ * @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
5298
+ * @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
5299
+ * @throws {RangeError} format string contains an unescaped latin alphabet character
5300
+ *
5301
+ * @example
5302
+ * // Parse 11 February 2014 from middle-endian format:
5303
+ * var result = parse('02/11/2014', 'MM/dd/yyyy', new Date())
5304
+ * //=> Tue Feb 11 2014 00:00:00
5305
+ *
5306
+ * @example
5307
+ * // Parse 28th of February in Esperanto locale in the context of 2010 year:
5308
+ * import eo from 'date-fns/locale/eo'
5309
+ * var result = parse('28-a de februaro', "do 'de' MMMM", new Date(2010, 0, 1), {
5310
+ * locale: eo
5311
+ * })
5312
+ * //=> Sun Feb 28 2010 00:00:00
5313
+ */
5314
+ function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, options) {
5315
+ 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;
5316
+ index.requiredArgs(3, arguments);
5317
+ var dateString = String(dirtyDateString);
5318
+ var formatString = String(dirtyFormatString);
5319
+ var defaultOptions = getDefaultOptions();
5320
+ var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;
5321
+ if (!locale.match) {
5322
+ throw new RangeError('locale must contain match property');
5323
+ }
5324
+ 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);
5325
+
5326
+ // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
5327
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
5328
+ throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
5329
+ }
5330
+ 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);
5331
+
5332
+ // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
5333
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
5334
+ throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
5335
+ }
5336
+ if (formatString === '') {
5337
+ if (dateString === '') {
5338
+ return index.toDate(dirtyReferenceDate);
5339
+ } else {
5340
+ return new Date(NaN);
5341
+ }
5342
+ }
5343
+ var subFnOptions = {
5344
+ firstWeekContainsDate: firstWeekContainsDate,
5345
+ weekStartsOn: weekStartsOn,
5346
+ locale: locale
5347
+ };
5348
+
5349
+ // If timezone isn't specified, it will be set to the system timezone
5350
+ var setters = [new DateToSystemTimezoneSetter()];
5351
+ var tokens = formatString.match(longFormattingTokensRegExp).map(function (substring) {
5352
+ var firstCharacter = substring[0];
5353
+ if (firstCharacter in longFormatters$1) {
5354
+ var longFormatter = longFormatters$1[firstCharacter];
5355
+ return longFormatter(substring, locale.formatLong);
5356
+ }
5357
+ return substring;
5358
+ }).join('').match(formattingTokensRegExp);
5359
+ var usedTokens = [];
5360
+ var _iterator = _createForOfIteratorHelper(tokens),
5361
+ _step;
5362
+ try {
5363
+ var _loop = function _loop() {
5364
+ var token = _step.value;
5365
+ if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(token)) {
5366
+ throwProtectedError(token, formatString, dirtyDateString);
5367
+ }
5368
+ if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(token)) {
5369
+ throwProtectedError(token, formatString, dirtyDateString);
5370
+ }
5371
+ var firstCharacter = token[0];
5372
+ var parser = parsers[firstCharacter];
5373
+ if (parser) {
5374
+ var incompatibleTokens = parser.incompatibleTokens;
5375
+ if (Array.isArray(incompatibleTokens)) {
5376
+ var incompatibleToken = usedTokens.find(function (usedToken) {
5377
+ return incompatibleTokens.includes(usedToken.token) || usedToken.token === firstCharacter;
5378
+ });
5379
+ if (incompatibleToken) {
5380
+ throw new RangeError("The format string mustn't contain `".concat(incompatibleToken.fullToken, "` and `").concat(token, "` at the same time"));
5381
+ }
5382
+ } else if (parser.incompatibleTokens === '*' && usedTokens.length > 0) {
5383
+ throw new RangeError("The format string mustn't contain `".concat(token, "` and any other token at the same time"));
5384
+ }
5385
+ usedTokens.push({
5386
+ token: firstCharacter,
5387
+ fullToken: token
5388
+ });
5389
+ var parseResult = parser.run(dateString, token, locale.match, subFnOptions);
5390
+ if (!parseResult) {
5391
+ return {
5392
+ v: new Date(NaN)
5393
+ };
5394
+ }
5395
+ setters.push(parseResult.setter);
5396
+ dateString = parseResult.rest;
5397
+ } else {
5398
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
5399
+ throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
5400
+ }
5401
+
5402
+ // Replace two single quote characters with one single quote character
5403
+ if (token === "''") {
5404
+ token = "'";
5405
+ } else if (firstCharacter === "'") {
5406
+ token = cleanEscapedString(token);
5407
+ }
5408
+
5409
+ // Cut token from string, or, if string doesn't match the token, return Invalid Date
5410
+ if (dateString.indexOf(token) === 0) {
5411
+ dateString = dateString.slice(token.length);
5412
+ } else {
5413
+ return {
5414
+ v: new Date(NaN)
5415
+ };
5416
+ }
5417
+ }
5418
+ };
5419
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
5420
+ var _ret = _loop();
5421
+ if (index._typeof(_ret) === "object") return _ret.v;
5422
+ }
5423
+
5424
+ // Check if the remaining input contains something other than whitespace
5425
+ } catch (err) {
5426
+ _iterator.e(err);
5427
+ } finally {
5428
+ _iterator.f();
5429
+ }
5430
+ if (dateString.length > 0 && notWhitespaceRegExp.test(dateString)) {
5431
+ return new Date(NaN);
5432
+ }
5433
+ var uniquePrioritySetters = setters.map(function (setter) {
5434
+ return setter.priority;
5435
+ }).sort(function (a, b) {
5436
+ return b - a;
5437
+ }).filter(function (priority, index, array) {
5438
+ return array.indexOf(priority) === index;
5439
+ }).map(function (priority) {
5440
+ return setters.filter(function (setter) {
5441
+ return setter.priority === priority;
5442
+ }).sort(function (a, b) {
5443
+ return b.subPriority - a.subPriority;
5444
+ });
5445
+ }).map(function (setterArray) {
5446
+ return setterArray[0];
5447
+ });
5448
+ var date = index.toDate(dirtyReferenceDate);
5449
+ if (isNaN(date.getTime())) {
5450
+ return new Date(NaN);
5451
+ }
5452
+
5453
+ // Convert the date in system timezone to the same date in UTC+00:00 timezone.
5454
+ var utcDate = subMilliseconds(date, getTimezoneOffsetInMilliseconds(date));
5455
+ var flags = {};
5456
+ var _iterator2 = _createForOfIteratorHelper(uniquePrioritySetters),
5457
+ _step2;
5458
+ try {
5459
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
5460
+ var setter = _step2.value;
5461
+ if (!setter.validate(utcDate, subFnOptions)) {
5462
+ return new Date(NaN);
5463
+ }
5464
+ var result = setter.set(utcDate, flags, subFnOptions);
5465
+ // Result is tuple (date, flags)
5466
+ if (Array.isArray(result)) {
5467
+ utcDate = result[0];
5468
+ assign(flags, result[1]);
5469
+ // Result is date
5470
+ } else {
5471
+ utcDate = result;
5472
+ }
5473
+ }
5474
+ } catch (err) {
5475
+ _iterator2.e(err);
5476
+ } finally {
5477
+ _iterator2.f();
5478
+ }
5479
+ return utcDate;
5480
+ }
5481
+ function cleanEscapedString(input) {
5482
+ return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
5483
+ }
5484
+
5485
+ /**
5486
+ * @name isToday
5487
+ * @category Day Helpers
5488
+ * @summary Is the given date today?
5489
+ * @pure false
5490
+ *
5491
+ * @description
5492
+ * Is the given date today?
5493
+ *
5494
+ * > ⚠️ Please note that this function is not present in the FP submodule as
5495
+ * > it uses `Date.now()` internally hence impure and can't be safely curried.
5496
+ *
5497
+ * @param {Date|Number} date - the date to check
5498
+ * @returns {Boolean} the date is today
5499
+ * @throws {TypeError} 1 argument required
5500
+ *
5501
+ * @example
5502
+ * // If today is 6 October 2014, is 6 October 14:00:00 today?
5503
+ * const result = isToday(new Date(2014, 9, 6, 14, 0))
5504
+ * //=> true
5505
+ */
5506
+ function isToday(dirtyDate) {
5507
+ index.requiredArgs(1, arguments);
5508
+ return isSameDay(dirtyDate, Date.now());
5509
+ }
5510
+
5511
+ /**
5512
+ * @name subDays
5513
+ * @category Day Helpers
5514
+ * @summary Subtract the specified number of days from the given date.
5515
+ *
5516
+ * @description
5517
+ * Subtract the specified number of days from the given date.
5518
+ *
5519
+ * @param {Date|Number} date - the date to be changed
5520
+ * @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
5521
+ * @returns {Date} the new date with the days subtracted
5522
+ * @throws {TypeError} 2 arguments required
5523
+ *
5524
+ * @example
5525
+ * // Subtract 10 days from 1 September 2014:
5526
+ * const result = subDays(new Date(2014, 8, 1), 10)
5527
+ * //=> Fri Aug 22 2014 00:00:00
5528
+ */
5529
+ function subDays(dirtyDate, dirtyAmount) {
5530
+ index.requiredArgs(2, arguments);
5531
+ var amount = toInteger(dirtyAmount);
5532
+ return addDays(dirtyDate, -amount);
5533
+ }
5534
+
5535
+ /**
5536
+ * @name parseISO
5537
+ * @category Common Helpers
5538
+ * @summary Parse ISO string
5539
+ *
5540
+ * @description
5541
+ * Parse the given string in ISO 8601 format and return an instance of Date.
5542
+ *
5543
+ * Function accepts complete ISO 8601 formats as well as partial implementations.
5544
+ * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
5545
+ *
5546
+ * If the argument isn't a string, the function cannot parse the string or
5547
+ * the values are invalid, it returns Invalid Date.
5548
+ *
5549
+ * @param {String} argument - the value to convert
5550
+ * @param {Object} [options] - an object with options.
5551
+ * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
5552
+ * @returns {Date} the parsed date in the local time zone
5553
+ * @throws {TypeError} 1 argument required
5554
+ * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
5555
+ *
5556
+ * @example
5557
+ * // Convert string '2014-02-11T11:30:30' to date:
5558
+ * const result = parseISO('2014-02-11T11:30:30')
5559
+ * //=> Tue Feb 11 2014 11:30:30
5560
+ *
5561
+ * @example
5562
+ * // Convert string '+02014101' to date,
5563
+ * // if the additional number of digits in the extended year format is 1:
5564
+ * const result = parseISO('+02014101', { additionalDigits: 1 })
5565
+ * //=> Fri Apr 11 2014 00:00:00
5566
+ */
5567
+ function parseISO(argument, options) {
5568
+ var _options$additionalDi;
5569
+ index.requiredArgs(1, arguments);
5570
+ var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);
5571
+ if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
5572
+ throw new RangeError('additionalDigits must be 0, 1 or 2');
5573
+ }
5574
+ if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
5575
+ return new Date(NaN);
5576
+ }
5577
+ var dateStrings = splitDateString(argument);
5578
+ var date;
5579
+ if (dateStrings.date) {
5580
+ var parseYearResult = parseYear(dateStrings.date, additionalDigits);
5581
+ date = parseDate(parseYearResult.restDateString, parseYearResult.year);
5582
+ }
5583
+ if (!date || isNaN(date.getTime())) {
5584
+ return new Date(NaN);
5585
+ }
5586
+ var timestamp = date.getTime();
5587
+ var time = 0;
5588
+ var offset;
5589
+ if (dateStrings.time) {
5590
+ time = parseTime(dateStrings.time);
5591
+ if (isNaN(time)) {
5592
+ return new Date(NaN);
5593
+ }
5594
+ }
5595
+ if (dateStrings.timezone) {
5596
+ offset = parseTimezone(dateStrings.timezone);
5597
+ if (isNaN(offset)) {
5598
+ return new Date(NaN);
5599
+ }
5600
+ } else {
5601
+ var dirtyDate = new Date(timestamp + time);
5602
+ // js parsed string assuming it's in UTC timezone
5603
+ // but we need it to be parsed in our timezone
5604
+ // so we use utc values to build date in our timezone.
5605
+ // Year values from 0 to 99 map to the years 1900 to 1999
5606
+ // so set year explicitly with setFullYear.
5607
+ var result = new Date(0);
5608
+ result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());
5609
+ result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());
5610
+ return result;
5611
+ }
5612
+ return new Date(timestamp + time + offset);
5613
+ }
5614
+ var patterns = {
5615
+ dateTimeDelimiter: /[T ]/,
5616
+ timeZoneDelimiter: /[Z ]/i,
5617
+ timezone: /([Z+-].*)$/
5618
+ };
5619
+ var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
5620
+ var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
5621
+ var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
5622
+ function splitDateString(dateString) {
5623
+ var dateStrings = {};
5624
+ var array = dateString.split(patterns.dateTimeDelimiter);
5625
+ var timeString;
5626
+
5627
+ // The regex match should only return at maximum two array elements.
5628
+ // [date], [time], or [date, time].
5629
+ if (array.length > 2) {
5630
+ return dateStrings;
5631
+ }
5632
+ if (/:/.test(array[0])) {
5633
+ timeString = array[0];
5634
+ } else {
5635
+ dateStrings.date = array[0];
5636
+ timeString = array[1];
5637
+ if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
5638
+ dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
5639
+ timeString = dateString.substr(dateStrings.date.length, dateString.length);
5640
+ }
5641
+ }
5642
+ if (timeString) {
5643
+ var token = patterns.timezone.exec(timeString);
5644
+ if (token) {
5645
+ dateStrings.time = timeString.replace(token[1], '');
5646
+ dateStrings.timezone = token[1];
5647
+ } else {
5648
+ dateStrings.time = timeString;
5649
+ }
5650
+ }
5651
+ return dateStrings;
5652
+ }
5653
+ function parseYear(dateString, additionalDigits) {
5654
+ var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)');
5655
+ var captures = dateString.match(regex);
5656
+ // Invalid ISO-formatted year
5657
+ if (!captures) return {
5658
+ year: NaN,
5659
+ restDateString: ''
5660
+ };
5661
+ var year = captures[1] ? parseInt(captures[1]) : null;
5662
+ var century = captures[2] ? parseInt(captures[2]) : null;
5663
+
5664
+ // either year or century is null, not both
5665
+ return {
5666
+ year: century === null ? year : century * 100,
5667
+ restDateString: dateString.slice((captures[1] || captures[2]).length)
5668
+ };
5669
+ }
5670
+ function parseDate(dateString, year) {
5671
+ // Invalid ISO-formatted year
5672
+ if (year === null) return new Date(NaN);
5673
+ var captures = dateString.match(dateRegex);
5674
+ // Invalid ISO-formatted string
5675
+ if (!captures) return new Date(NaN);
5676
+ var isWeekDate = !!captures[4];
5677
+ var dayOfYear = parseDateUnit(captures[1]);
5678
+ var month = parseDateUnit(captures[2]) - 1;
5679
+ var day = parseDateUnit(captures[3]);
5680
+ var week = parseDateUnit(captures[4]);
5681
+ var dayOfWeek = parseDateUnit(captures[5]) - 1;
5682
+ if (isWeekDate) {
5683
+ if (!validateWeekDate(year, week, dayOfWeek)) {
2890
5684
  return new Date(NaN);
2891
5685
  }
2892
5686
  return dayOfISOWeekYear(year, week, dayOfWeek);
@@ -3451,7 +6245,7 @@ var locale = {
3451
6245
  };
3452
6246
  const ptBR = locale;
3453
6247
 
3454
- const curaCalendarCss = ":host{display:block;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);margin:0 auto}:host .calendar{display:flex;flex-direction:column;gap:5px;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);border-radius:4px;overflow:hidden;background:#fff;font-family:var(--font-family)}:host .calendar.embedded{border:2px solid var(--neutral-light);padding:0px 12px 12px 12px}:host .calendar.floating{box-shadow:0 4px 8px var(--neutral-light)}:host .header{position:relative;padding:12px 0}:host .header::after{content:\"\";position:absolute;bottom:0;left:2px;right:2px;border-bottom:2px dotted var(--neutral-light)}:host .month-year{display:flex;padding:12px 8px;justify-content:space-between;align-self:stretch}:host .month-year.dropdown{padding:0%}:host .select{display:flex;padding:7px 10px 0px;justify-content:center;align-items:center;gap:6px;flex:1 0 0}:host .drop-month{display:flex;max-width:118px;padding:0px;align-items:flex-start;gap:0px;flex:1 0 0}:host .drop-year{display:flex;min-width:80px;max-width:85px;padding:0px;align-items:flex-start;gap:0px;flex:1 0 0}:host .days-of-week{display:flex;height:30px;padding:4px;justify-content:center;align-items:center;gap:4px;flex-shrink:0}:host .day{flex:1;text-align:center}:host .dates{display:flex;flex-wrap:wrap;align-items:center;align-self:stretch;gap:0}:host .icon{cursor:pointer;position:relative;overflow:hidden;border-radius:50%}:host .icon.dropdown{margin-top:10px}:host .icon::before{content:\"\";position:absolute;border-radius:50%;top:50%;left:50%;width:20px;height:20px;background:var(--primary-base);transform:translate(-50%, -50%) scale(0);transition:transform 0.2s ease}:host .icon:active::before{transform:translate(-50%, -50%) scale(1)}:host .icon:active{transform:scale(1)}:host .collapsed-container{text-align:center;position:relative;display:flex;align-items:center;justify-content:center;padding-top:10px}:host .collapsed-container::before{content:\"\";position:absolute;bottom:0;top:0;left:2px;right:2px;border-top:2px dotted var(--neutral-light)}:host .date{display:flex;justify-content:center;align-items:center;height:auto;width:14.2857142857%;aspect-ratio:1;font-size:14px;cursor:pointer;position:relative;box-sizing:border-box;text-align:center;flex-shrink:0}:host .date.today{border:2px solid var(--primary-darker);border-radius:50%;color:var(--primary-darker)}:host .date.selected{color:var(--select-label) !important;background:var(--primary-base);border-radius:50%}:host .date.default-dates{color:var(--select-label) !important;background:var(--primary-base);border-radius:50%;border:none}:host .date.invalid{color:var(--neutral-dark) !important;cursor:not-allowed}:host .date.invalid:hover{background:none;box-shadow:none}:host .date.valid{color:var(--primary-darker);font-weight:var(--font-weight-bold)}:host .date.range.start{border-radius:50% 0 0 50%;color:var(--select-label) !important;background:var(--primary-base)}:host .date.range.interval{border-radius:0;background:var(--primary-lighter);color:var(--neutral-black) !important}:host .date.range.interval.today{border:none}:host .date.range.end{border-radius:0 50% 50% 0;color:var(--select-label) !important;background:var(--primary-base)}:host .date:hover{background:var(--primary-lighter);border-radius:50%;color:var(--neutral-white)}:host select,:host input{width:60px;font-size:16px;box-shadow:0 2px 2px var(--neutral-black);padding:5px;border-radius:4px;border:1px solid #ccc;background:#f7f7f7}";
6248
+ const curaCalendarCss = ":host{display:block;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);margin:0 auto}:host .calendar{display:flex;flex-direction:column;gap:5px;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);border-radius:4px;overflow:hidden;background:#fff;font-family:var(--font-family)}:host .calendar.embedded{border:2px solid var(--neutral-light);padding:0px 12px 12px 12px}:host .calendar.floating{box-shadow:0 4px 8px var(--neutral-light)}:host .header{position:relative;padding:12px 0}:host .header::after{content:\"\";position:absolute;bottom:0;left:2px;right:2px;border-bottom:2px dotted var(--neutral-light)}:host .month-year{display:flex;padding:12px 8px;justify-content:space-between;align-self:stretch}:host .month-year.dropdown{padding:0%}:host .select{display:flex;padding:7px 10px 0px;justify-content:center;align-items:center;gap:6px;flex:1 0 0}:host .drop-month{display:flex;max-width:118px;padding:0px;align-items:flex-start;gap:0px;flex:1 0 0}:host .drop-year{display:flex;min-width:80px;max-width:85px;padding:0px;align-items:flex-start;gap:0px;flex:1 0 0}:host .days-of-week{display:flex;height:30px;padding:4px;justify-content:center;align-items:center;gap:4px;flex-shrink:0}:host .day{flex:1;text-align:center}:host .dates{display:flex;flex-wrap:wrap;align-items:center;align-self:stretch;gap:0}:host .icon{cursor:pointer;position:relative;overflow:hidden;border-radius:50%}:host .icon.dropdown{margin-top:10px}:host .icon::before{content:\"\";position:absolute;border-radius:50%;top:50%;left:50%;width:20px;height:20px;background:var(--primary-base);transform:translate(-50%, -50%) scale(0);transition:transform 0.2s ease}:host .icon:active::before{transform:translate(-50%, -50%) scale(1)}:host .icon:active{transform:scale(1)}:host .collapsed-container{text-align:center;position:relative;display:flex;align-items:center;justify-content:center;padding-top:10px}:host .collapsed-container::before{content:\"\";position:absolute;bottom:0;top:0;left:2px;right:2px;border-top:2px dotted var(--neutral-light)}:host .date{display:flex;justify-content:center;align-items:center;height:auto;width:14.2857142857%;aspect-ratio:1;font-size:14px;cursor:pointer;position:relative;box-sizing:border-box;text-align:center;flex-shrink:0}:host .date.today{border:2px solid var(--primary-darker);border-radius:50%;color:var(--primary-darker)}:host .date.selected{color:var(--select-label) !important;background:var(--primary-base);border-radius:50%}:host .date.default-dates{color:var(--select-label) !important;background:var(--primary-base);border-radius:50%;border:none}:host .date.invalid{color:var(--neutral-dark) !important;cursor:not-allowed}:host .date.invalid:hover{background:none;box-shadow:none}:host .date.valid{color:var(--primary-darker);font-weight:var(--font-weight-bold)}:host .date.range.start{border-radius:50% 0 0 50%;color:var(--select-label) !important;background:var(--primary-base)}:host .date.range.interval{border-radius:0;background:var(--primary-lighter);color:var(--neutral-black) !important}:host .date.range.interval.today{border:none}:host .date.range.end{border-radius:0 50% 50% 0;color:var(--select-label) !important;background:var(--primary-base)}@media (min-width: 992px){:host .date:hover{background:var(--primary-lighter);border-radius:50%;color:var(--neutral-white)}}:host select,:host input{width:60px;font-size:16px;box-shadow:0 2px 2px var(--neutral-black);padding:5px;border-radius:4px;border:1px solid #ccc;background:#f7f7f7}";
3455
6249
  const CuraCalendarStyle0 = curaCalendarCss;
3456
6250
 
3457
6251
  const CuraCalendar = class {
@@ -3526,7 +6320,9 @@ const CuraCalendar = class {
3526
6320
  }
3527
6321
  }
3528
6322
  this.defaultDates = this.expandDateRanges(this.defaultDate);
3529
- this.currentDate = this.defaultDates[0] ? this.defaultDates[0] : this.currentDate;
6323
+ if (this.defaultDate[0]) {
6324
+ this.currentDate = parse(this.defaultDate[0], this.dateFormat, new Date());
6325
+ }
3530
6326
  }
3531
6327
  /**
3532
6328
  * Get the locale for the calendar.
@@ -3673,7 +6469,7 @@ const CuraCalendar = class {
3673
6469
  * @param {Date} date - The date to select.
3674
6470
  */
3675
6471
  selectSingleDate(date) {
3676
- this.defaultDates = [];
6472
+ this.defaultDate = [];
3677
6473
  this.selectedDates = [date];
3678
6474
  }
3679
6475
  /**
@@ -3773,10 +6569,12 @@ const CuraCalendar = class {
3773
6569
  const daysIncurrentDate = eachDayOfInterval({ start, end });
3774
6570
  const prevMonthStart = startOfMonth(addMonths(start, -1));
3775
6571
  const prevMonthEnd = endOfMonth(prevMonthStart);
3776
- const daysInPrevMonth = eachDayOfInterval({
3777
- start: subDays(prevMonthEnd, getDay(start)),
3778
- end: prevMonthEnd,
3779
- });
6572
+ const daysInPrevMonth = getDay(start) > 0
6573
+ ? eachDayOfInterval({
6574
+ start: subDays(prevMonthEnd, getDay(start) - 1),
6575
+ end: prevMonthEnd,
6576
+ })
6577
+ : [];
3780
6578
  const nextMonthStart = startOfMonth(addMonths(end, 1));
3781
6579
  const nextMonthEnd = endOfMonth(nextMonthStart);
3782
6580
  const remainingDays = WEEKS_IN_CALENDAR_VIEW - getDay(end);
@@ -3784,7 +6582,7 @@ const CuraCalendar = class {
3784
6582
  start: nextMonthStart,
3785
6583
  end: addDays(nextMonthEnd, remainingDays),
3786
6584
  });
3787
- const totalDays = [...daysInPrevMonth.slice(-getDay(start)), ...daysIncurrentDate, ...daysInNextMonth];
6585
+ const totalDays = [...daysInPrevMonth, ...daysIncurrentDate, ...daysInNextMonth];
3788
6586
  return totalDays.slice(0, DAYS_IN_CALENDAR_VIEW);
3789
6587
  }
3790
6588
  /**
@@ -3898,6 +6696,7 @@ const CuraCalendar = class {
3898
6696
  this.selectedDates = this.customDates;
3899
6697
  }
3900
6698
  handleDefaultDateChange(newValue) {
6699
+ this.selectedDates = [];
3901
6700
  if (typeof newValue === 'string') {
3902
6701
  const parsedDefaultDate = JSON.parse(newValue || '[]');
3903
6702
  if (typeof parsedDefaultDate === 'string') {
@@ -3911,13 +6710,13 @@ const CuraCalendar = class {
3911
6710
  }
3912
6711
  render() {
3913
6712
  const { months } = this.fetchMonthNames();
3914
- return (index$1.h(index$1.Host, { key: 'a27b858fff12fe2d19898dbb0be8080a0175c465', style: this.getHostCSSProperties() }, index$1.h("div", { key: 'e2fe9991e3ef03d11b0e58b412d31020ead1b344', class: `calendar ${this.floating ? 'floating' : ''} ${this.embedded ? 'embedded' : ''}`, style: this.styles }, index$1.h("header", { key: '8bf8a4f703043d907d8bc81ed22061380cd67ade', class: "header" }, index$1.h("div", { key: '66c2b27693f188929065972828c2ce4a672f1e74', class: `month-year ${this.type === 'dropdown' && 'dropdown'}` }, index$1.h("cura-icon", { key: '0e6841eb77061f404e23fbfc28be40600255767a', class: `icon ${this.type === 'dropdown' && 'dropdown'}`, name: "left", color: this.determinePrevButtonColor(), onClick: !this.collapsed ? () => this.updateCurrentMonth('prev') : () => this.updateCurrentWeek('prev') }), this.type === 'dropdown' ? (index$1.h("div", { class: "select" }, index$1.h("cura-select", { size: "small", class: "drop-month", mode: "transparent", value: months[getMonth(this.currentDate)], onSelected: e => this.onMonthDropdownChange(e) }, months.map((month, index) => (index$1.h("cura-select-option", { size: "xsmall", key: index, value: month }, month)))), index$1.h("cura-select", { size: "small", class: "drop-year", mode: "transparent", value: getYear(this.currentDate).toString(), onSelected: e => this.onYearDropdownChange(e) }, this.fetchYearList().map((year, index) => (index$1.h("cura-select-option", { key: index, value: year.toString() }, year.toString())))))) : (index$1.h("cura-label", { color: "neutral-black", size: "large" }, months[getMonth(this.currentDate)].slice(0, 3), ", ", getYear(this.currentDate))), index$1.h("cura-icon", { key: 'cdc62d8666dc7b890daadf63d2ffe0d0000ec545', class: `icon ${this.type === 'dropdown' && 'dropdown'}`, name: "right", color: "primary-base", onClick: !this.collapsed ? () => this.updateCurrentMonth('next') : () => this.updateCurrentWeek('next') }))), index$1.h("span", { key: 'fa0d8c6ff291f343da594799b3ba366d3e020e74', class: "days-of-week" }, this.fetchWeekDays().map((day, index) => (index$1.h("cura-label", { class: "day", size: "xsmall", color: "neutral-black", weight: "bold", key: index }, day === 'sab' ? 'SÁB' : day.toLocaleUpperCase())))), index$1.h("div", { key: 'dc072663767251cc694d51612cacd94f1fe31a84', class: "dates" }, !this.collapsed
6713
+ return (index$1.h(index$1.Host, { key: '622035565961e1a2a1917f402e853e29ed01b1fe', style: this.getHostCSSProperties() }, index$1.h("div", { key: '7d41f8769f65218c130751e25e0a9ee7126b930c', class: `calendar ${this.floating ? 'floating' : ''} ${this.embedded ? 'embedded' : ''}`, style: this.styles }, index$1.h("header", { key: '796f3f0d0fa3972151803f8b37707d7f33349c41', class: "header" }, index$1.h("div", { key: 'aa1d4dc49765ccbef9181f58696eeac4eb2336b3', class: `month-year ${this.type === 'dropdown' && 'dropdown'}` }, index$1.h("cura-icon", { key: '9003a5aa57d9bf0217eef70452ffac20c434e1b2', class: `icon ${this.type === 'dropdown' && 'dropdown'}`, name: "left", color: this.determinePrevButtonColor(), onClick: !this.collapsed ? () => this.updateCurrentMonth('prev') : () => this.updateCurrentWeek('prev') }), this.type === 'dropdown' ? (index$1.h("div", { class: "select" }, index$1.h("cura-select", { size: "small", class: "drop-month", mode: "transparent", value: months[getMonth(this.currentDate)], onSelected: e => this.onMonthDropdownChange(e) }, months.map((month, index) => (index$1.h("cura-select-option", { size: "xsmall", key: index, value: month }, month)))), index$1.h("cura-select", { size: "small", class: "drop-year", mode: "transparent", value: getYear(this.currentDate).toString(), onSelected: e => this.onYearDropdownChange(e) }, this.fetchYearList().map((year, index) => (index$1.h("cura-select-option", { key: index, value: year.toString() }, year.toString())))))) : (index$1.h("cura-label", { color: "neutral-black", size: "large" }, months[getMonth(this.currentDate)].slice(0, 3), ", ", getYear(this.currentDate))), index$1.h("cura-icon", { key: '331511ce7960285c1245fcc23179cc7d4837869d', class: `icon ${this.type === 'dropdown' && 'dropdown'}`, name: "right", color: "primary-base", onClick: !this.collapsed ? () => this.updateCurrentMonth('next') : () => this.updateCurrentWeek('next') }))), index$1.h("span", { key: '4fc77ed5e8a40b95a88a6879299e78b8dfcf3ce6', class: "days-of-week" }, this.fetchWeekDays().map((day, index) => (index$1.h("cura-label", { class: "day", size: "xsmall", color: "neutral-black", weight: "bold", key: index }, day === 'sab' ? 'SÁB' : day.toLocaleUpperCase())))), index$1.h("div", { key: '311a707add171474195d075a7694eb10197c6263', class: "dates" }, !this.collapsed
3915
6714
  ? this.fetchDaysOfMonth().map((day, index) => (index$1.h("div", { key: index, class: this.getClasses(day), onClick: () => this.onDateClick(day) }, day ? format(day, 'd') : '')))
3916
6715
  : this.fetchDaysOfWeek().map((day, index) => (index$1.h("div", { key: index, class: this.getClasses(day), onClick: () => this.onDateClick(day) }, day ? format(day, 'd') : '')))), this.collapsed !== null ? (this.collapsed ? (index$1.h("div", { class: "collapsed-container" }, index$1.h("cura-button-transparent", { onClick: () => this.showNotColapsedCalendar(), size: "small", color: "primary", fontColor: "dark", iconName: "plusCircle" }, "Veja mais datas"))) : (index$1.h("div", { class: "collapsed-container" }, index$1.h("cura-button-transparent", { onClick: () => this.showColapsedCalendar(), size: "small", color: "primary", fontColor: "dark", iconName: "minusCircle" }, "Veja menos datas")))) : null)));
3917
6716
  }
3918
6717
  static get watchers() { return {
3919
- "customDates": ["watchDefaultDatesArray"],
3920
- "defaultDate": ["handleDefaultDateChange"]
6718
+ "defaultDate": ["initializeDefaultDates", "handleDefaultDateChange"],
6719
+ "customDates": ["watchDefaultDatesArray"]
3921
6720
  }; }
3922
6721
  };
3923
6722
  CuraCalendar.style = CuraCalendarStyle0;