import { defineComponent, useModel, openBlock, createElementBlock, createVNode, unref, mergeProps, renderSlot, createElementVNode, toDisplayString, mergeModels } from 'vue';
import { ElDatePicker } from 'element-plus';
import dayjs from 'dayjs';

"use strict";
const _hoisted_1 = { class: "me-input-range-date" };
const _hoisted_2 = { style: { "width": "20px", "margin": "0 10px", "text-align": "center" } };
const __default__ = defineComponent({
  name: "me-input-range-date"
});
var script = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: /* @__PURE__ */ mergeModels({
    connector: { type: String, required: false, default: "-" },
    disabledData: { type: Boolean, required: false, default: false },
    disabledStartDateFn: { type: Function, required: false },
    disabledEndDateFn: { type: Function, required: false }
  }, {
    "start": {},
    "startModifiers": {},
    "end": {},
    "endModifiers": {}
  }),
  emits: ["update:start", "update:end"],
  setup(__props) {
    const props = __props;
    const start = useModel(__props, "start");
    const end = useModel(__props, "end");
    const disabledStartDate = (time) => {
      if (props.disabledStartDateFn) {
        return props.disabledStartDateFn(time);
      }
      if (!props.disabledData) {
        if (end.value) {
          if (time.getTime() <= dayjs(end.value).valueOf()) {
            return false;
          } else {
            return true;
          }
        }
        return;
      }
      if (end.value) {
        if (time.getTime() >= Date.now() - 3600 * 1e3 * 24 && time.getTime() <= dayjs(end.value).valueOf()) {
          return false;
        } else {
          return true;
        }
      }
      return time.getTime() < Date.now() - 3600 * 1e3 * 24;
    };
    const disabledEndDate = (time) => {
      if (props.disabledEndDateFn) return props.disabledEndDateFn(time);
      if (!props.disabledData) {
        if (start.value) return time.getTime() < dayjs(start.value).valueOf();
        return true;
      }
      if (end.value) return time.getTime() < dayjs(start.value).valueOf();
      return time.getTime() < Date.now() - 3600 * 1e3 * 24;
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(ElDatePicker), mergeProps({
          "disabled-date": disabledStartDate,
          modelValue: start.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => start.value = $event),
          type: "date",
          placeholder: "\u5F00\u59CB\u65F6\u95F4"
        }, _ctx.$attrs), null, 16, ["modelValue"]),
        renderSlot(_ctx.$slots, "connector", {}, () => [
          createElementVNode(
            "span",
            _hoisted_2,
            toDisplayString(__props.connector),
            1
            /* TEXT */
          )
        ]),
        createVNode(unref(ElDatePicker), mergeProps({
          "disabled-date": disabledEndDate,
          modelValue: end.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => end.value = $event),
          type: "date",
          placeholder: "\u7ED3\u675F\u65F6\u95F4"
        }, _ctx.$attrs), null, 16, ["modelValue"])
      ]);
    };
  }
});

export { script as default };
//# sourceMappingURL=input-range-date.vue2.mjs.map
