import { needFullMonth } from './dateHelper.js';
import { getOriginalDates } from './getOriginalDates.js';
import { normalizeDates } from './normalizeDates.js';

var getFormattedDates = function getFormattedDates(_ref) {
  var value = _ref.value,
    lang = _ref.lang,
    format = _ref.format,
    includeEdgeDates = _ref.includeEdgeDates,
    min = _ref.min,
    max = _ref.max;
  var _getOriginalDates = getOriginalDates(value, lang, format),
    formattedDate = _getOriginalDates.formattedDate,
    isoDate = _getOriginalDates.isoDate,
    originalDate = _getOriginalDates.originalDate;
  if (!originalDate) {
    var innerValue = format && (needFullMonth(format) ? formattedDate : formattedDate.slice(0, format.length));
    return {
      formattedDate: innerValue || '',
      isoDate: isoDate,
      originalDate: originalDate
    };
  }
  var _normalizeDates = normalizeDates({
      originalDate: originalDate,
      lang: lang,
      format: format,
      includeEdgeDates: includeEdgeDates,
      min: min,
      max: max
    }),
    normalizedDate = _normalizeDates.normalizedDate,
    formattedNormalizedDate = _normalizeDates.formattedNormalizedDate;
  return {
    formattedDate: formattedNormalizedDate,
    isoDate: normalizedDate.toISOString(),
    originalDate: normalizedDate
  };
};

export { getFormattedDates };
