import { ElDatePicker as v, ElRadioGroup as P, ElRadioButton as D } from "element-plus/es";
import { defineComponent as S, ref as c, watch as y, createElementBlock as i, openBlock as d, createVNode as p, createElementVNode as C, mergeProps as E, withCtx as B, Fragment as b, renderList as U, createBlock as N } from "vue";
import { shortcutsData as R } from "./model/index.js";
const w = { class: "CiElDatePickerDaterange" }, $ = { class: "date-shortcuts" }, z = {
  name: "CiElDatePickerDaterange",
  inheritAttrs: !1
}, L = /* @__PURE__ */ S({
  ...z,
  props: {
    datePickerValue: { default: "" },
    dateShortcutsValue: { type: [String, Number, Boolean], default: "" },
    shortcuts: { default: () => R },
    type: { default: "daterange" },
    startPlaceholder: { default: "开始日期" },
    endPlaceholder: { default: "结束日期" },
    rangeSeparator: { default: "-" }
  },
  emits: [
    "update:date-picker-value",
    "update:date-shortcuts-value",
    "change",
    "date-shortcuts-change"
  ],
  setup(h, { emit: m }) {
    const r = m, t = h, u = c(t.datePickerValue), o = c(t.dateShortcutsValue), f = (e) => {
      const l = t.shortcuts.filter((n) => n.text === e)[0];
      let a;
      typeof l.value == "function" ? a = l.value() : a = l.value, u.value = a, r("update:date-picker-value", a), r("date-shortcuts-change", e);
    }, V = (e) => {
      o.value = "", r("change", e || []);
    }, g = (e) => {
      u.value = e, r("update:date-picker-value", e);
    }, _ = (e) => {
      o.value = e, r("update:date-shortcuts-value", e);
    };
    return y(
      () => t.dateShortcutsValue,
      () => {
        o.value = t.dateShortcutsValue, t.dateShortcutsValue && f(t.dateShortcutsValue);
      },
      { immediate: !0 }
    ), (e, l) => {
      const a = v, n = D, k = P;
      return d(), i("div", w, [
        p(a, E(e.$attrs, {
          modelValue: u.value,
          "onUpdate:modelValue": g,
          shortcuts: e.shortcuts,
          type: e.type,
          "range-separator": e.rangeSeparator,
          "start-placeholder": e.startPlaceholder,
          "end-placeholder": e.endPlaceholder,
          onChange: V
        }), null, 16, ["modelValue", "shortcuts", "type", "range-separator", "start-placeholder", "end-placeholder"]),
        C("div", $, [
          p(k, {
            modelValue: o.value,
            "onUpdate:modelValue": _,
            size: "small"
          }, {
            default: B(() => [
              (d(!0), i(b, null, U(e.shortcuts, (s) => (d(), N(n, {
                label: s.text,
                value: s.text,
                key: s.text
              }, null, 8, ["label", "value"]))), 128))
            ]),
            _: 1
          }, 8, ["modelValue"])
        ])
      ]);
    };
  }
});
export {
  L as default
};
