"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _timePicker = _interopRequireDefault(require("@alifd/next/lib/time-picker2"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _dayjs = _interopRequireDefault(require("dayjs"));
var _excluded = ["style", "defaultValue", "hasClear", "label", "popupTriggerType", "format", "hourStep", "minuteStep", "secondStep", "type", "size", "placeholder", "ranges", "disabled"];
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 TimePickerName = function TimePickerName(_ref) {
  var _ref$style = _ref.style,
    style = _ref$style === void 0 ? {} : _ref$style,
    defaultValue = _ref.defaultValue,
    hasClear = _ref.hasClear,
    label = _ref.label,
    popupTriggerType = _ref.popupTriggerType,
    format = _ref.format,
    hourStep = _ref.hourStep,
    minuteStep = _ref.minuteStep,
    secondStep = _ref.secondStep,
    type = _ref.type,
    size = _ref.size,
    placeholder = _ref.placeholder,
    ranges = _ref.ranges,
    disabled = _ref.disabled,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var nowTime = (0, _dayjs["default"])(new Date());
  var currentHour = (0, _dayjs["default"])().hour(nowTime.hour()).minute(0).second(0);
  var nextHour = currentHour.hour(currentHour.hour() + 1);
  var preset = [{
    label: '此刻',
    value: function value() {
      return nowTime;
    }
  }];
  var presetRange = [{
    label: '此刻',
    value: [currentHour, nextHour]
  }];
  var _useState = (0, React.useState)((0, _dayjs["default"])('12:00:00', 'HH:mm:ss', true)),
    value = _useState[0],
    onChange = _useState[1];
  var _style = style || {};
  var _otherProps = otherProps || {};
  _otherProps.style = _style;
  if (type == '基础用法') {
    return /*#__PURE__*/React.createElement(_timePicker["default"], (0, _extends2["default"])({
      prefix: "next-",
      defaultValue: defaultValue,
      size: size,
      hasClear: hasClear,
      minuteStep: minuteStep,
      secondStep: secondStep,
      value: value,
      format: format,
      hourStep: hourStep,
      placeholder: placeholder,
      disabled: disabled,
      popupAlign: "tl tl",
      popupTriggerType: popupTriggerType,
      preset: preset,
      onChange: onChange
    }, otherProps));
  }
  if (type == '时间区间') {
    return /*#__PURE__*/React.createElement(_timePicker["default"].RangePicker, (0, _extends2["default"])({
      className: style.TimePickerName,
      prefix: "next-",
      defaultValue: defaultValue,
      size: size,
      hasClear: hasClear,
      minuteStep: minuteStep,
      secondStep: secondStep,
      value: value,
      format: format,
      hourStep: hourStep,
      placeholder: placeholder,
      disabled: disabled,
      popupAlign: "tl tl",
      popupTriggerType: popupTriggerType,
      onChange: console.log,
      preset: presetRange
    }, otherProps));
  }
};
TimePickerName.displayName = 'TimePickerName';
var _default = TimePickerName;
exports["default"] = _default;