/**
 * tdesign v0.46.4
 * (c) 2022 tdesign
 * @license MIT
 */

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed } from '@vue/composition-api';
import { usePrefixClass } from '../../hooks/useConfig.js';
import TPanelContent from './PanelContent.js';
import TExtraContent from './ExtraContent.js';
import { getDefaultFormat, parseToDayjs } from '../../_common/js/date-picker/format.js';
import useTableData from '../hooks/useTableData.js';
import useDisableDate from '../hooks/useDisableDate.js';
import { useConfig } from '../../config-provider/useConfig.js';
import '../../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../../_common/js/global-config/default-config.js';
import '../../_common/js/global-config/locale/zh_CN.js';
import '../../config-provider/type.js';
import '../../_chunks/dep-a4bd011a.js';
import '../base/Header.js';
import '@babel/runtime/helpers/toConsumableArray';
import '../../jumper/jumper.js';
import 'lodash/isObject';
import 'tdesign-icons-vue';
import '../../jumper/props.js';
import '../../hooks/useGlobalIcon.js';
import '../../button/index.js';
import '../../button/button.js';
import '../../loading/index.js';
import '../../loading/loading.js';
import '../../loading/icon/gradient.js';
import '../../_common/js/loading/circle-adapter.js';
import '../../_common/js/utils/set-style.js';
import '../../_common/js/utils/helper.js';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import '../../config-provider/config-receiver.js';
import 'vue';
import '../../utils/mixins.js';
import '../../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-tnode.js';
import '@babel/runtime/helpers/typeof';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../../utils/transfer-dom.js';
import '../../loading/props.js';
import '../../utils/withInstall.js';
import 'lodash/capitalize';
import './style/css.js';
import '../../loading/type.js';
import '../../loading/plugin.js';
import '../../config.js';
import '../../button/props.js';
import '../../utils/ripple.js';
import '../../button/type.js';
import '../../select/select.js';
import 'lodash/isFunction';
import 'lodash/debounce';
import 'lodash/get';
import 'lodash/cloneDeep';
import 'lodash/isArray';
import '../../hooks/useDefaultValue.js';
import '../../hooks/useVModel.js';
import '../../hooks/tnode.js';
import 'lodash/isEmpty';
import '../../hooks/render-tnode.js';
import '../../select/props.js';
import '../../popup/index.js';
import '../../popup/popup.js';
import '@popperjs/core';
import '../../utils/helper.js';
import '../../popup/props.js';
import '../../popup/container.js';
import '../../utils/map-props.js';
import '../../popup/type.js';
import '../../input/index.js';
import '../../input/input.js';
import '../../utils/event.js';
import '../../input/props.js';
import '../../input/input-group.js';
import '../../input/type.js';
import '../../tag/index.js';
import '../../tag/tag.js';
import '../../tag/props.js';
import '../../tag/check-tag.js';
import '../../tag/check-tag-props.js';
import '../../tag/type.js';
import '../../select-input/index.js';
import '../../select-input/select-input.js';
import '../../select-input/props.js';
import '../../select-input/useSingle.js';
import 'lodash/pick';
import '../../select-input/useMultiple.js';
import '../../tag-input/index.js';
import '../../tag-input/tag-input.js';
import '../../tag-input/props.js';
import '../../tag-input/hooks/useTagScroll.js';
import '../../tag-input/useTagList.js';
import '../../tag-input/hooks/useHover.js';
import '../../tag-input/hooks/useDragSorter.js';
import '../../tag-input/type.js';
import '../../select-input/useOverlayInnerStyle.js';
import '../../select-input/type.js';
import '../../common-components/fake-arrow.js';
import '../../select/option.js';
import '../../select/option-props.js';
import '../../checkbox/index.js';
import '../../checkbox/group.js';
import 'lodash/intersection';
import '../../checkbox/checkbox.js';
import '../../checkbox/props.js';
import '../../checkbox/checkbox-group-props.js';
import '../../checkbox/type.js';
import '../../hooks/useLazyLoad.js';
import '../../_common/js/utils/observe.js';
import '../../select/util.js';
import '../../hooks/useCommonClassName.js';
import '../../select/select-panel.js';
import '../../hooks/useVirtualScroll.js';
import '../../select/hooks/useSelectOptions.js';
import '../base/Table.js';
import '../base/Cell.js';
import '../../_common/js/date-picker/utils.js';
import '@babel/runtime/helpers/extends';
import 'dayjs';
import '../../_chunks/dep-a0d91f92.js';
import '../../_chunks/dep-b98966c0.js';
import 'lodash/chunk';
import '../../time-picker/panel/time-picker-panel.js';
import '../../_common/js/time-picker/const.js';
import '../../time-picker/panel/props.js';
import '../../time-picker/props.js';
import '../../time-picker/panel/single-panel.js';
import 'lodash/range';
import 'lodash/padStart';
import '../../_common/js/time-picker/utils.js';
import '../../_common/js/log/index.js';
import '../../_common/js/log/log.js';
import '../base/Footer.js';

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(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 = 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,
    enableTimePicker: Boolean,
    firstDayOfWeek: Number,
    panelPreselection: Boolean,
    hidePreselection: {
      type: Boolean,
      defaultValue: true
    },
    popupVisible: Boolean,
    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 = usePrefixClass("date-range-picker__panel");

    var _useConfig = useConfig("datePicker"),
        global = _useConfig.global;

    var _getDefaultFormat = getDefaultFormat({
      mode: props.mode,
      format: props.format,
      enableTimePicker: props.enableTimePicker
    }),
        format = _getDefaultFormat.format;

    var hidePreselection = !props.panelPreselection && props.value.length === 2;
    var disableDateOptions = computed(function () {
      return useDisableDate({
        format: format,
        mode: props.mode,
        disableDate: props.disableDate,
        start: props.isFirstValueSelected && props.activeIndex === 1 ? new Date(parseToDayjs(props.value[0], format, "start").toDate().setHours(0, 0, 0)) : void 0,
        end: props.isFirstValueSelected && props.activeIndex === 0 ? new Date(parseToDayjs(props.value[1], format).toDate().setHours(23, 59, 59)) : void 0
      });
    });
    var startTableData = computed(function () {
      return useTableData(_objectSpread({
        isRange: true,
        start: props.value[0] ? parseToDayjs(props.value[0], format).toDate() : void 0,
        end: props.value[1] ? parseToDayjs(props.value[1], format).toDate() : void 0,
        hoverStart: !hidePreselection && props.hoverValue[0] ? parseToDayjs(props.hoverValue[0], format).toDate() : void 0,
        hoverEnd: !hidePreselection && props.hoverValue[1] ? parseToDayjs(props.hoverValue[1], format).toDate() : void 0,
        year: props.year[0],
        month: props.month[0],
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || global.value.firstDayOfWeek
      }, disableDateOptions.value));
    });
    var endTableData = computed(function () {
      return useTableData(_objectSpread({
        isRange: true,
        start: props.value[0] ? parseToDayjs(props.value[0], format).toDate() : void 0,
        end: props.value[1] ? parseToDayjs(props.value[1], format).toDate() : void 0,
        hoverStart: !hidePreselection && props.hoverValue[0] ? parseToDayjs(props.hoverValue[0], format).toDate() : void 0,
        hoverEnd: !hidePreselection && props.hoverValue[1] ? parseToDayjs(props.hoverValue[1], format).toDate() : void 0,
        year: props.year[1],
        month: props.month[1],
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || global.value.firstDayOfWeek
      }, disableDateOptions.value));
    });
    var panelContentProps = computed(function () {
      return {
        format: format,
        mode: props.mode,
        firstDayOfWeek: props.firstDayOfWeek || global.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 {
      COMPONENT_NAME: COMPONENT_NAME,
      startTableData: startTableData,
      endTableData: endTableData,
      panelContentProps: panelContentProps
    };
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    var COMPONENT_NAME = this.COMPONENT_NAME,
        startTableData = this.startTableData,
        endTableData = this.endTableData,
        panelContentProps = this.panelContentProps;
    return h("div", {
      "class": [COMPONENT_NAME, _defineProperty({}, "".concat(COMPONENT_NAME, "--direction-row"), ["left", "right"].includes(this.presetsPlacement))],
      "on": {
        "click": function click(e) {
          var _this$onClick;

          return (_this$onClick = _this.onClick) === null || _this$onClick === void 0 ? void 0 : _this$onClick.call(_this, {
            e: e
          });
        }
      }
    }, [["top", "left"].includes(this.presetsPlacement) ? h(TExtraContent, {
      "props": _objectSpread({}, {
        presets: this.presets,
        selectedValue: this.value[this.activeIndex],
        enableTimePicker: this.enableTimePicker,
        onPresetClick: this.onPresetClick,
        onConfirmClick: this.onConfirmClick,
        presetsPlacement: this.presetsPlacement
      })
    }) : null, h("div", {
      "class": "".concat(COMPONENT_NAME, "-content-wrapper")
    }, [!this.enableTimePicker ? [h(TPanelContent, {
      "key": "startPanel",
      "props": _objectSpread({}, _objectSpread({
        partial: "start",
        year: this.year[0],
        month: this.month[0],
        time: this.time[0],
        value: this.value,
        tableData: startTableData
      }, panelContentProps))
    }), h(TPanelContent, {
      "key": "endPanel",
      "props": _objectSpread({}, _objectSpread({
        partial: "end",
        year: this.year[1],
        month: this.month[1],
        time: this.time[1],
        value: this.value,
        tableData: endTableData
      }, panelContentProps))
    })] : h(TPanelContent, {
      "key": "start",
      "props": _objectSpread({}, _objectSpread({
        partial: this.activeIndex ? "end" : "start",
        year: this.activeIndex ? this.year[1] : this.year[0],
        month: this.activeIndex ? this.month[1] : this.month[0],
        time: this.activeIndex ? this.time[1] : this.time[0],
        value: this.value,
        tableData: this.activeIndex ? endTableData : startTableData
      }, panelContentProps))
    })]), ["bottom", "right"].includes(this.presetsPlacement) ? h(TExtraContent, {
      "props": _objectSpread({}, {
        presets: this.presets,
        selectedValue: this.value[this.activeIndex],
        enableTimePicker: this.enableTimePicker,
        onPresetClick: this.onPresetClick,
        onConfirmClick: this.onConfirmClick,
        presetsPlacement: this.presetsPlacement
      })
    }) : null]);
  }
});

export { TRangePanel as default };
//# sourceMappingURL=RangePanel.js.map
