import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _DatePicker from "@alifd/next/es/date-picker2";
var _excluded = ["style", "disabled", "placeholder", "defaultValue", "value", "size", "label", "hasClear", "followTrigger"];
import * as React from 'react';
import dayjs from 'dayjs';
var RangePicker = _DatePicker.RangePicker;
var RangePreset = {
  '今天': [dayjs(), dayjs()],
  '本月': [dayjs().startOf('month'), dayjs().endOf('month')]
};
function extraFooterRender(str) {
  if (str) {
    return /*#__PURE__*/React.createElement("div", {
      className: "extra-footer"
    }, str, "\u5929");
  }
}
var RangePicker2Name = function RangePicker2Name(_ref) {
  var _ref$style = _ref.style,
    style = _ref$style === void 0 ? {} : _ref$style,
    disabled = _ref.disabled,
    placeholder = _ref.placeholder,
    defaultValue = _ref.defaultValue,
    value = _ref.value,
    size = _ref.size,
    label = _ref.label,
    hasClear = _ref.hasClear,
    followTrigger = _ref.followTrigger,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _style = style || {};
  var _otherProps = otherProps || {};
  _otherProps.style = _style;
  function getDaysBetween(startDate, enDate) {
    var sDate = Date.parse(startDate);
    var eDate = Date.parse(enDate);
    if (sDate > eDate) {
      return 0;
    }
    // 这个判断可以根据需求来确定是否需要加上
    if (sDate === eDate) {
      return 1;
    }
    var days = (eDate - sDate) / (1 * 24 * 60 * 60 * 1000);
    return days;
  }
  var strdate;
  if (value) {
    strdate = Math.ceil(getDaysBetween(value[0], value[1]));
  }

  // 
  return /*#__PURE__*/React.createElement(RangePicker, _extends({
    className: style.RangePicker,
    showTime: true,
    size: size,
    label: label,
    popupClassName: "datesty1",
    disabled: disabled,
    placeholder: placeholder,
    timePanelProps: {
      defaultValue: ['09:00', '23:59'],
      format: 'HH:mm',
      minuteStep: 15
    },
    preset: RangePreset,
    extraFooterRender: extraFooterRender(strdate),
    value: value,
    hasClear: hasClear
  }, otherProps));
};
RangePicker2Name.displayName = 'RangePicker2Name';
export default RangePicker2Name;