"use strict";
const React = require("react");
const index$2 = require("../date/index.js");
const index$1 = require("../week/index.js");
const index$3 = require("../month/index.js");
const index$4 = require("../year/index.js");
const index$5 = require("../quarter/index.js");
const index = require("../../../ConfigProvider/index.js");
const dayjs = require("../../../_util/dayjs.js");
const is = require("../../../_util/is.js");
const context = require("../../context.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
function range(start, end) {
  var result = [];
  for (var i = start; i < end; i++) {
    result.push(i);
  }
  return result;
}
function RangePicker(props) {
  var _a = props.mode, mode = _a === void 0 ? "date" : _a, showTime = props.showTime, disabledDate = props.disabledDate, disabledTime = props.disabledTime, format = props.format, dateRender = props.dateRender, propsValue = props.value, timeValues = props.timeValues, icons = props.icons, locale = props.locale, pageShowDates = props.pageShowDates, onMouseEnterCell = props.onMouseEnterCell, onMouseLeaveCell = props.onMouseLeaveCell, onSelectTime = props.onTimePickerSelect, onSelectPanel = props.onSelectPanel, onPrev = props.onPrev, onSuperPrev = props.onSuperPrev, onNext = props.onNext, onSuperNext = props.onSuperNext, localeName = props.localeName, popupVisible = props.popupVisible, timepickerProps = props.timepickerProps, getHeaderOperations = props.getHeaderOperations, setRangePageShowDates = props.setRangePageShowDates, disabledTimePickerIndex = props.disabledTimePickerIndex, hideNotInViewDates = props.hideNotInViewDates, isTimePanel = props.isTimePanel, valueShowHover = props.valueShowHover, panelModes = props.panelModes, setPanelModes = props.setPanelModes;
  var getPrefixCls = React.useContext(index.ConfigContext).getPrefixCls;
  var prefixCls = getPrefixCls("picker-range");
  var _b = React.useContext(context), utcOffset = _b.utcOffset, timezone = _b.timezone;
  var startShowDate = pageShowDates[0] || dayjs.getNow(utcOffset, timezone);
  var endShowDate = pageShowDates[1] || dayjs.getNow(utcOffset, timezone);
  var value = dayjs.getDayjsValue(propsValue, format);
  var basePickerProps = {
    isRangePicker: true,
    rangeValues: value,
    onMouseEnterCell,
    onMouseLeaveCell,
    format,
    locale,
    disabledDate,
    onSelect: onSelectPanel,
    dateRender,
    getHeaderOperations,
    icons,
    valueShowHover
  };
  var startPickerProps = {
    pageShowDate: startShowDate,
    panelMode: panelModes[0],
    setPanelMode: function(m) {
      return setPanelModes([m, panelModes[1]]);
    }
  };
  var endPickerProps = {
    pageShowDate: endShowDate,
    panelMode: panelModes[1],
    setPanelMode: function(m) {
      return setPanelModes([panelModes[0], m]);
    }
  };
  function renderDate() {
    var startOperations = {
      onPrev,
      onSuperPrev
    };
    var endOperations = {
      onNext,
      onSuperNext
    };
    var pickerProps = __assign(__assign({}, basePickerProps), {
      localeName,
      popupVisible,
      timepickerProps,
      getHeaderOperations,
      hideNotInViewDates,
      isTimePanel
    });
    if (mode === "week") {
      return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(emotionReactJsxRuntime_browser_esm.Fragment, {
        children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {
          ...__assign({
            setPageShowDate: function(d) {
              return setRangePageShowDates([d, d], 0);
            }
          }, startOperations, pickerProps, startPickerProps)
        }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {
          ...__assign({
            setPageShowDate: function(d) {
              return setRangePageShowDates([d, d], 1);
            }
          }, endOperations, pickerProps, endPickerProps)
        })]
      });
    }
    var showTimeProps = {
      disabledTime,
      showTime
    };
    var disabledTimePickerProps = {};
    if (typeof disabledTimePickerIndex === "number") {
      disabledTimePickerProps.disabledTime = function() {
        return {
          disabledHours: function() {
            return range(0, 24);
          },
          disabledMinutes: function() {
            return range(0, 60);
          },
          disabledSeconds: function() {
            return range(0, 60);
          }
        };
      };
      if (is.isObject(showTime)) {
        var st = __assign(__assign({}, showTime), {
          defaultValue: void 0
        });
        disabledTimePickerProps.showTime = __assign(__assign({}, st), {
          hideDisabledOptions: false
        });
      }
    }
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(emotionReactJsxRuntime_browser_esm.Fragment, {
      children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {
        ...__assign({}, startOperations, pickerProps, showTimeProps, disabledTimePickerIndex === 0 ? disabledTimePickerProps : {}, {
          onTimePickerSelect: function(timeString, time) {
            onSelectTime(0, timeString, time);
          },
          index: 0,
          setPageShowDate: function(d) {
            return setRangePageShowDates([d, d], 0);
          },
          timeValue: timeValues[0]
        }, startPickerProps)
      }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$2, {
        ...__assign({}, endOperations, pickerProps, showTimeProps, disabledTimePickerIndex === 1 ? disabledTimePickerProps : {}, {
          onTimePickerSelect: function(timeString, time) {
            onSelectTime(1, timeString, time);
          },
          index: 1,
          setPageShowDate: function(d) {
            return setRangePageShowDates([d, d], 1);
          },
          timeValue: timeValues[1]
        }, endPickerProps)
      })]
    });
  }
  function renderMonth() {
    var startOperations = {
      onSuperPrev
    };
    var endOperations = {
      onSuperNext
    };
    var pickerProps = basePickerProps;
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(emotionReactJsxRuntime_browser_esm.Fragment, {
      children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {
        ...__assign({
          setPageShowDate: function(d) {
            return setRangePageShowDates([d, d], 0);
          }
        }, startOperations, pickerProps, startPickerProps)
      }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$3, {
        ...__assign({
          setPageShowDate: function(d) {
            return setRangePageShowDates([d, d], 1);
          }
        }, endOperations, pickerProps, endPickerProps)
      })]
    });
  }
  function renderYear() {
    var startOperations = {
      onSuperPrev
    };
    var endOperations = {
      onSuperNext
    };
    var pickerProps = basePickerProps;
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(emotionReactJsxRuntime_browser_esm.Fragment, {
      children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$4, {
        ...__assign({}, startOperations, pickerProps, {
          pageShowDate: startShowDate
        })
      }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$4, {
        ...__assign({}, endOperations, pickerProps, {
          pageShowDate: endShowDate
        })
      })]
    });
  }
  function renderQuarter() {
    var startOperations = {
      onSuperPrev
    };
    var endOperations = {
      onSuperNext
    };
    var pickerProps = basePickerProps;
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(emotionReactJsxRuntime_browser_esm.Fragment, {
      children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$5, {
        ...__assign({
          setPageShowDate: function(d) {
            return setRangePageShowDates([d, d], 0);
          }
        }, startOperations, pickerProps, startPickerProps)
      }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$5, {
        ...__assign({
          setPageShowDate: function(d) {
            return setRangePageShowDates([d, d], 1);
          }
        }, endOperations, pickerProps, endPickerProps)
      })]
    });
  }
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
    className: prefixCls,
    children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
      className: prefixCls + "-wrapper",
      children: [(mode === "date" || mode === "week") && renderDate(), mode === "month" && renderMonth(), mode === "year" && renderYear(), mode === "quarter" && renderQuarter()]
    })
  });
}
RangePicker.defaultProps = {
  pickerType: "range"
};
module.exports = RangePicker;
//# sourceMappingURL=index.js.map
