"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _datePicker = _interopRequireDefault(require("@alifd/next/lib/date-picker2"));
var React = _interopRequireWildcard(require("react"));
var _dayjs = _interopRequireDefault(require("dayjs"));
var _excluded = ["style", "disabled", "placeholder", "defaultValue", "value", "size", "label", "hasClear", "followTrigger"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var RangePicker = _datePicker["default"].RangePicker;
var RangePreset = {
  '今天': [(0, _dayjs["default"])(), (0, _dayjs["default"])()],
  '本月': [(0, _dayjs["default"])().startOf('month'), (0, _dayjs["default"])().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 = (0, _objectWithoutPropertiesLoose2["default"])(_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, (0, _extends2["default"])({
    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';
var _default = RangePicker2Name;
exports["default"] = _default;