import { defineComponent, ref, watchEffect, openBlock, createElementBlock, createElementVNode, toDisplayString, createVNode, unref } from "vue";
import { i as formatMoment, t as _sfc_main$1 } from "./index2.js";
import "vant";
import "@wltech/svg";
import "dayjs";
import "qs";
import "vuedraggable";
import "vue-router";
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = {
  class: "rf-date-select-wrap",
  "data-weiling-mobile-ui-rf-date-select-wrap": ""
};
const __default__ = {
  name: "RfDateSelect"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    modelValue: { default: "" },
    format: { default: "YYYY-MM-DD" }
  },
  emits: ["onSelect", "update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    const popUpVisible = ref(false);
    const valueText = ref("");
    const defaultSelectTime = ref(new Date());
    const minDate = new Date(1901, 1, 1);
    const maxDate = new Date(new Date().getFullYear() + 10, 12, 31);
    const onClose = () => {
      popUpVisible.value = false;
    };
    const onShow = () => popUpVisible.value = true;
    const onSelect = (date) => {
      emit("onSelect", new Date(date).getTime());
      emit("update:modelValue", new Date(date).getTime());
      onClose();
    };
    watchEffect(() => {
      defaultSelectTime.value = props.modelValue ? new Date(parseInt(props.modelValue + "")) : new Date();
      valueText.value = props.modelValue ? formatMoment(props.modelValue, props.format) : "";
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", {
          class: "rf-date-select",
          onClick: onShow
        }, toDisplayString(valueText.value), 1),
        createVNode(_sfc_main$1, {
          modelValue: popUpVisible.value,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => popUpVisible.value = $event),
          color: "var(--wl-primary-color)",
          type: "date",
          "min-date": unref(minDate),
          "max-date": unref(maxDate),
          onOnConfrim: onSelect
        }, null, 8, ["modelValue", "min-date", "max-date"])
      ]);
    };
  }
});
export { _sfc_main as default };
