function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import moment from 'moment';
export var DAYS_OF_WEEK = 7;
export var CALENDAR_TABLE_COL_COUNT = 7;
export var CALENDAR_TABLE_ROW_COUNT = 6;
export var MONTH_TABLE_ROW_COUNT = 4;
export var MONTH_TABLE_COL_COUNT = 3;
export var YEAR_TABLE_ROW_COUNT = 4;
export var YEAR_TABLE_COL_COUNT = 3;
export var CALENDAR_MODE_YEAR = 'year';
export var CALENDAR_MODE_MONTH = 'month';
export var CALENDAR_MODE_DATE = 'date';
export var CALENDAR_MODES = [CALENDAR_MODE_DATE, CALENDAR_MODE_MONTH, CALENDAR_MODE_YEAR];
export function isDisabledDate(date, fn, view) {
  if (typeof fn === 'function' && fn(date, view)) {
    return true;
  }

  return false;
}
export function checkMomentObj(props, propName, componentName) {
  if (props[propName] && !moment.isMoment(props[propName])) {
    return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Required a moment object"));
  }
}
export function formatDateValue(value) {
  var reservedValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

  if (value && moment.isMoment(value)) {
    return value;
  }

  return reservedValue;
}
export function getVisibleMonth(defaultVisibleMonth, value) {
  var getVM = defaultVisibleMonth;

  if (typeof getVM !== 'function' || !moment.isMoment(getVM())) {
    getVM = function getVM() {
      if (value) {
        return value;
      }

      return moment();
    };
  }

  return getVM();
}
export function isSameYearMonth(dateA, dateB) {
  return dateA.month() === dateB.month() && dateA.year() === dateB.year();
}
export function preFormatDateValue(value, format) {
  var val = typeof value === 'string' ? moment(value, format, false) : value;

  if (val && moment.isMoment(val) && val.isValid()) {
    return val;
  }

  return null;
}
export function getLocaleData(_ref, localeData) {
  var _months = _ref.months,
      shortMonths = _ref.shortMonths,
      _firstDayOfWeek = _ref.firstDayOfWeek,
      _weekdays = _ref.weekdays,
      shortWeekdays = _ref.shortWeekdays,
      veryShortWeekdays = _ref.veryShortWeekdays;
  return _objectSpread({}, localeData, {
    monthsShort: function monthsShort() {
      return shortMonths || localeData.monthsShort();
    },
    months: function months() {
      return _months || localeData.months();
    },
    firstDayOfWeek: function firstDayOfWeek() {
      return _firstDayOfWeek || localeData.firstDayOfWeek();
    },
    weekdays: function weekdays() {
      return _weekdays || localeData.weekdays;
    },
    weekdaysShort: function weekdaysShort() {
      return shortWeekdays || localeData.weekdaysShort();
    },
    weekdaysMin: function weekdaysMin() {
      return veryShortWeekdays || localeData.weekdaysMin();
    }
  });
}