import _extends from "@babel/runtime/helpers/extends";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import _ from 'lodash';
import 'react-dates/initialize';
import { FormGroup } from '../FormGroup';
import { DayRangePickerControl } from '../DateTimePicker/DayRangePickerControl';
import PropTypes from 'prop-types';
import { dateRangePickerValueFormatter } from './datePickerHelpers';
export var DayRangePicker =
/*#__PURE__*/
function (_FormGroup) {
  _inheritsLoose(DayRangePicker, _FormGroup);

  function DayRangePicker() {
    return _FormGroup.apply(this, arguments) || this;
  }

  var _proto = DayRangePicker.prototype;

  _proto.filterGroupProps = function filterGroupProps(props) {
    return _.omit(props, ['ranges', 'startDate', 'endDate', 'valueFormatter', 'maxDate', 'dayPickerProps', 'numberOfMonths', 'inputProps', 'minDate', 'locale']);
  };

  _proto.renderInput = function renderInput(hasError) {
    var ariaDescProps = this.getAriaDescProps(hasError);
    var _this$props = this.props,
        startDate = _this$props.startDate,
        endDate = _this$props.endDate;
    return React.createElement(DayRangePickerControl, _extends({
      startDate: startDate,
      endDate: endDate
    }, this.getSafeProps(this.props), {
      ref: "control",
      hasFormGroupContainer: true
    }, ariaDescProps));
  };

  return DayRangePicker;
}(FormGroup);

_defineProperty(DayRangePicker, "propTypes", Object.assign({}, FormGroup.propTypes, {
  startDate: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
  endDate: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
  valueFormatter: PropTypes.func,
  onChange: PropTypes.func,
  numberOfMonths: PropTypes.number,
  dayPickerProps: PropTypes.object,
  inputProps: PropTypes.object,
  ranges: PropTypes.object,
  maxDate: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
  minDate: PropTypes.oneOfType([PropTypes.number, PropTypes.object])
}));

_defineProperty(DayRangePicker, "defaultProps", Object.assign({}, FormGroup.defaultProps, {
  startDate: null,
  endDate: null,
  testAutomationId: 'datePicker',
  valueFormatter: dateRangePickerValueFormatter,
  dayPickerProps: {},
  numberOfMonths: 2,
  inputProps: {},
  ranges: null,
  maxDate: null,
  minDate: null
}));