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