/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var hooks_useConfig = require('../../hooks/useConfig.js');
var _common_js_datePicker_format = require('../../_common/js/date-picker/format.js');
var datePicker_hooks_useTableData = require('../hooks/useTableData.js');
var datePicker_hooks_useDisableDate = require('../hooks/useDisableDate.js');
var datePicker_panel_ExtraContent = require('./ExtraContent.js');
var datePicker_panel_PanelContent = require('./PanelContent.js');
var configProvider_useConfig = require('../../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('lodash/isString');
require('../../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../../_common/js/global-config/default-config.js');
require('../../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../../_chunks/dep-7f0559c3.js');
require('dayjs');
require('../../_common/js/log/log.js');
require('../../_common/js/date-picker/utils.js');
require('@babel/runtime/helpers/slicedToArray');
require('@babel/runtime/helpers/objectDestructuringEmpty');
require('@babel/runtime/helpers/extends');
require('../../_chunks/dep-69993bc1.js');
require('lodash/chunk');
require('lodash/isObject');
require('../base/Footer.js');
require('../../button/index.js');
require('../../utils/withInstall.js');
require('../../button/button.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../../loading/index.js');
require('../../loading/directive.js');
require('../../loading/plugin.js');
require('../../utils/dom.js');
require('../../utils/easing.js');
require('../../loading/loading.js');
require('../../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../../hooks/useTeleport.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../_common/js/loading/circle-adapter.js');
require('../../_common/js/utils/set-style.js');
require('../../_common/js/utils/helper.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('../../hooks/useRipple.js');
require('../../utils/set-style.js');
require('../../hooks/useKeepAnimation.js');
require('../../form/hooks.js');
require('../../hooks/tnode.js');
require('../../button/props.js');
require('../base/Header.js');
require('../../pagination/index.js');
require('../../pagination/pagination.js');
require('lodash/isNaN');
require('@ldesign/icons-vue-next');
require('../../hooks/useGlobalIcon.js');
require('../../input-number/index.js');
require('../../input-number/input-number.js');
require('../../input/index.js');
require('../../input/input.js');
require('../../input/props.js');
require('../../input/useInput.js');
require('../../form/const.js');
require('../../hooks/useVModel.js');
require('../../input/useLengthLimit.js');
require('../../input/useInputEventHandler.js');
require('../../input/useInputWidth.js');
require('../../input/input-group.js');
require('../../input/input-group-props.js');
require('../../input-number/props.js');
require('../../input-number/useInputNumber.js');
require('../../hooks/useCommonClassName.js');
require('../../_common/js/input-number/number.js');
require('lodash/isNil');
require('../../_common/js/input-number/large-number.js');
require('../../select/index.js');
require('../../select/select.js');
require('lodash/pick');
require('lodash/debounce');
require('lodash/get');
require('lodash/intersection');
require('../../common-components/fake-arrow.js');
require('../../select-input/index.js');
require('../../select-input/select-input.js');
require('../../popup/index.js');
require('../../popup/popup.js');
require('@popperjs/core');
require('../../popup/container.js');
require('../../hooks/useResizeObserver.js');
require('../../popup/props.js');
require('../../select-input/props.js');
require('../../select-input/useSingle.js');
require('../../hooks/useDefaultValue.js');
require('../../select-input/useMultiple.js');
require('../../tag-input/index.js');
require('../../tag-input/tag-input.js');
require('../../tag-input/props.js');
require('../../tag-input/hooks/useTagScroll.js');
require('../../tag-input/useTagList.js');
require('../../tag/index.js');
require('../../tag/tag.js');
require('../../tag/props.js');
require('../../tag/check-tag.js');
require('../../tag/check-tag-props.js');
require('../../tag-input/hooks/useHover.js');
require('../../tag-input/hooks/useDragSorter.js');
require('../../select-input/useOverlayInnerStyle.js');
require('../../select/props.js');
require('../../select/select-panel.js');
require('lodash/omit');
require('../../select/option.js');
require('../../checkbox/index.js');
require('../../checkbox/checkbox.js');
require('../../checkbox/props.js');
require('../../checkbox/constants.js');
require('../../checkbox/group.js');
require('../../hooks/slot.js');
require('../../checkbox/checkbox-group-props.js');
require('../../select/option-props.js');
require('../../select/helper.js');
require('../../select/optionGroup.js');
require('../../select/option-group-props.js');
require('../../select/hooks/usePanelVirtualScroll.js');
require('../../hooks/useVirtualScroll.js');
require('../../select/hooks/useSelectOptions.js');
require('../../input-adornment/index.js');
require('../../input-adornment/input-adornment.js');
require('../../input-adornment/props.js');
require('../../pagination/props.js');
require('../../pagination/usePaginationClasses.js');
require('../../pagination/useMoreAction.js');
require('../../pagination/pagination-mini.js');
require('../../pagination/pagination-mini-props.js');
require('../base/Table.js');
require('../base/Cell.js');
require('../../time-picker/panel/time-picker-panel.js');
require('../../_common/js/time-picker/const.js');
require('../../time-picker/panel/props.js');
require('lodash/isBoolean');
require('../../time-picker/props.js');
require('../../time-picker/panel/single-panel.js');
require('lodash/range');
require('lodash/padStart');
require('../../_common/js/time-picker/utils.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var TRangePanel = vue.defineComponent({
  name: "TRangePanel",
  props: {
    hoverValue: Array,
    activeIndex: Number,
    isFirstValueSelected: Boolean,
    disableDate: [Object, Array, Function],
    mode: {
      type: String,
      "default": "date"
    },
    format: String,
    presetsPlacement: {
      type: String,
      "default": "bottom"
    },
    value: Array,
    timePickerProps: Object,
    presets: Object,
    popupVisible: Boolean,
    enableTimePicker: Boolean,
    panelPreselection: Boolean,
    firstDayOfWeek: Number,
    year: Array,
    month: Array,
    time: Array,
    onClick: Function,
    onCellClick: Function,
    onCellMouseEnter: Function,
    onCellMouseLeave: Function,
    onJumperClick: Function,
    onConfirmClick: Function,
    onPresetClick: Function,
    onYearChange: Function,
    onMonthChange: Function,
    onTimePickerChange: Function
  },
  setup: function setup(props) {
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("date-range-picker__panel");
    var _useConfig = configProvider_useConfig.useConfig("datePicker"),
      globalConfig = _useConfig.globalConfig;
    var _getDefaultFormat = _common_js_datePicker_format.getDefaultFormat({
        mode: props.mode,
        format: props.format,
        enableTimePicker: props.enableTimePicker
      }),
      format = _getDefaultFormat.format;
    var hidePreselection = !props.panelPreselection && props.value.length === 2;
    var disableDateOptions = vue.computed(function () {
      return datePicker_hooks_useDisableDate["default"]({
        format: format,
        mode: props.mode,
        disableDate: props.disableDate,
        start: props.isFirstValueSelected && props.activeIndex === 1 ? new Date(_common_js_datePicker_format.parseToDayjs(props.value[0], format, "start").toDate().setHours(0, 0, 0)) : void 0,
        end: props.isFirstValueSelected && props.activeIndex === 0 ? new Date(_common_js_datePicker_format.parseToDayjs(props.value[1], format).toDate().setHours(23, 59, 59)) : void 0
      });
    });
    var startTableData = vue.computed(function () {
      return datePicker_hooks_useTableData["default"](_objectSpread({
        isRange: true,
        start: props.value[0] ? _common_js_datePicker_format.parseToDayjs(props.value[0], format).toDate() : void 0,
        end: props.value[1] ? _common_js_datePicker_format.parseToDayjs(props.value[1], format).toDate() : void 0,
        hoverStart: !hidePreselection && props.hoverValue[0] ? _common_js_datePicker_format.parseToDayjs(props.hoverValue[0], format).toDate() : void 0,
        hoverEnd: !hidePreselection && props.hoverValue[1] ? _common_js_datePicker_format.parseToDayjs(props.hoverValue[1], format).toDate() : void 0,
        year: props.year[0],
        month: props.month[0],
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || globalConfig.value.firstDayOfWeek
      }, disableDateOptions.value));
    });
    var endTableData = vue.computed(function () {
      return datePicker_hooks_useTableData["default"](_objectSpread({
        isRange: true,
        start: props.value[0] ? _common_js_datePicker_format.parseToDayjs(props.value[0], format).toDate() : void 0,
        end: props.value[1] ? _common_js_datePicker_format.parseToDayjs(props.value[1], format).toDate() : void 0,
        hoverStart: !hidePreselection && props.hoverValue[0] ? _common_js_datePicker_format.parseToDayjs(props.hoverValue[0], format).toDate() : void 0,
        hoverEnd: !hidePreselection && props.hoverValue[1] ? _common_js_datePicker_format.parseToDayjs(props.hoverValue[1], format).toDate() : void 0,
        year: props.year[1],
        month: props.month[1],
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || globalConfig.value.firstDayOfWeek
      }, disableDateOptions.value));
    });
    var panelContentProps = vue.computed(function () {
      return {
        format: format,
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || globalConfig.value.firstDayOfWeek,
        popupVisible: props.popupVisible,
        enableTimePicker: props.enableTimePicker,
        timePickerProps: props.timePickerProps,
        onMonthChange: props.onMonthChange,
        onYearChange: props.onYearChange,
        onJumperClick: props.onJumperClick,
        onCellClick: props.onCellClick,
        onCellMouseEnter: props.onCellMouseEnter,
        onCellMouseLeave: props.onCellMouseLeave,
        onTimePickerChange: props.onTimePickerChange
      };
    });
    return function () {
      return vue.createVNode("div", {
        "class": [COMPONENT_NAME.value, _defineProperty__default["default"]({}, "".concat(COMPONENT_NAME.value, "--direction-row"), ["left", "right"].includes(props.presetsPlacement))],
        "onClick": function onClick(e) {
          var _props$onClick;
          return (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, {
            e: e
          });
        }
      }, [["top", "left"].includes(props.presetsPlacement) ? vue.createVNode(datePicker_panel_ExtraContent["default"], {
        "presets": props.presets,
        "selectedValue": props.value[props.activeIndex],
        "enableTimePicker": props.enableTimePicker,
        "onPresetClick": props.onPresetClick,
        "onConfirmClick": props.onConfirmClick,
        "presetsPlacement": props.presetsPlacement
      }, null) : null, vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "-content-wrapper")
      }, [!props.enableTimePicker ? [vue.createVNode(datePicker_panel_PanelContent["default"], vue.mergeProps({
        "key": "startPanel",
        "partial": "start",
        "year": props.year[0],
        "month": props.month[0],
        "time": props.time[0],
        "value": props.value,
        "tableData": startTableData.value
      }, panelContentProps.value), null), vue.createVNode(datePicker_panel_PanelContent["default"], vue.mergeProps({
        "key": "endPanel",
        "partial": "end",
        "year": props.year[1],
        "month": props.month[1],
        "time": props.time[1],
        "value": props.value,
        "tableData": endTableData.value
      }, panelContentProps.value), null)] : vue.createVNode(datePicker_panel_PanelContent["default"], vue.mergeProps({
        "key": "start",
        "partial": props.activeIndex ? "end" : "start",
        "year": props.activeIndex ? props.year[1] : props.year[0],
        "month": props.activeIndex ? props.month[1] : props.month[0],
        "time": props.activeIndex ? props.time[1] : props.time[0],
        "value": props.value,
        "tableData": props.activeIndex ? endTableData.value : startTableData.value
      }, panelContentProps.value), null)]), ["bottom", "right"].includes(props.presetsPlacement) ? vue.createVNode(datePicker_panel_ExtraContent["default"], {
        "presets": props.presets,
        "selectedValue": props.value[props.activeIndex],
        "enableTimePicker": props.enableTimePicker,
        "onPresetClick": props.onPresetClick,
        "onConfirmClick": props.onConfirmClick,
        "presetsPlacement": props.presetsPlacement
      }, null) : null]);
    };
  }
});

exports["default"] = TRangePanel;
//# sourceMappingURL=RangePanel.js.map
