import { defineComponent as P, shallowRef as _, ref as R, computed as h, h as w, openBlock as T, createElementBlock as U, createVNode as t, unref as l, withCtx as n, createElementVNode as s, normalizeClass as p, createTextVNode as c, toDisplayString as y } from "vue";
import { useNamespace as E, ElPopover as $, ElInput as D, ElForm as j, ElFormItem as x, ElInputNumber as b, ElButton as k } from "element-plus";
import "../../../confirm-button/index.mjs";
import "../../../count-down-button/index.mjs";
import { TextEllipsis as C } from "../../../ellipsis/index.mjs";
import "../../../rich-text-editor/index.mjs";
import "../../index.mjs";
import "../../../pro-form/index.mjs";
import "../../../pro-table/index.mjs";
import "../../../pro-descriptions/index.mjs";
import "../../../layout/index.mjs";
import "../../../page/index.mjs";
import "../../../guide/index.mjs";
import { digitRangeProps as A } from "./types.mjs";
const G = /* @__PURE__ */ s("div", null, "-", -1), H = /* @__PURE__ */ s("div", { style: { padding: "0 8px" } }, "-", -1), J = { style: { "text-align": "right" } }, re = /* @__PURE__ */ P({
  __name: "index",
  props: A,
  emits: ["update:modelValue", "change"],
  setup(N, { emit: z }) {
    const V = z, u = E("digitrange"), g = E("input"), o = N, f = _(), m = _(), v = _(!1), a = R([]), B = h(() => typeof o.suffixIcon == "string" ? w("span", {}, {
      default: () => o.suffixIcon
    }) : o.suffixIcon), S = h(() => typeof o.prefixIcon == "string" ? w("span", {}, {
      default: () => o.prefixIcon
    }) : o.prefixIcon), q = {
      0: [{
        validator(r, e, i) {
          var d;
          a.value[1] !== void 0 && (e > a.value[1] && i(new Error("数值起点不能高于或等于数值终点")), (e === "" || e === void 0) && i(new Error("当前输入不能为空"))), e === "" && ((d = f.value) == null || d.clearValidate()), i();
        }
      }],
      1: [{
        validator(r, e, i) {
          var d;
          a.value[0] !== void 0 && (e <= a.value[0] && i(new Error("数值终点不能低于或等于数值起点")), (e === "" || e === void 0) && i(new Error("当前输入不能为空"))), e === "" && ((d = f.value) == null || d.clearValidate()), i();
        }
      }]
    }, F = () => {
      var e;
      if (o.disabled)
        return;
      v.value = !0;
      const r = (e = m.value) == null ? void 0 : e.querySelector(`.${g.e("wrapper")}`);
      r && r.classList.add("is-focus");
    }, I = () => {
      var e;
      v.value = !1;
      const r = (e = m.value) == null ? void 0 : e.querySelector(`.${g.e("wrapper")}`);
      r && r.classList.remove("is-focus");
    }, L = async () => {
      var r;
      await ((r = f.value) == null ? void 0 : r.validate()), V("update:modelValue", a.value), V("change", a.value), I();
    };
    return (r, e) => (T(), U("div", null, [
      t(l($), {
        visible: v.value,
        width: 350
      }, {
        reference: n(() => [
          s("div", {
            class: p([l(u).b(), l(u).is("disabled", o.disabled)]),
            onClick: F,
            ref_key: "inputdiv",
            ref: m
          }, [
            s("div", {
              class: p([l(u).e("inner")])
            }, [
              s("div", {
                class: p([l(u).e("inner-value"), "is-left"])
              }, [
                t(l(C), null, {
                  default: n(() => {
                    var i;
                    return [
                      c(y((i = o.modelValue) == null ? void 0 : i[0]), 1)
                    ];
                  }),
                  _: 1
                })
              ], 2),
              G,
              s("div", {
                class: p([l(u).e("inner-value"), "is-right"])
              }, [
                t(l(C), null, {
                  default: n(() => {
                    var i;
                    return [
                      c(y((i = o.modelValue) == null ? void 0 : i[1]), 1)
                    ];
                  }),
                  _: 1
                })
              ], 2)
            ], 2),
            t(l(D), {
              disabled: o.disabled,
              style: { width: "100%" },
              placeholder: o.placeholder,
              "model-value": o.modelValue && o.modelValue.length !== 0 ? " " : "",
              "suffix-icon": B.value,
              "prefix-icon": S.value,
              size: o.size
            }, null, 8, ["disabled", "placeholder", "model-value", "suffix-icon", "prefix-icon", "size"])
          ], 2)
        ]),
        default: n(() => [
          t(l(j), {
            ref_key: "formIns",
            ref: f,
            model: a.value,
            rules: q,
            class: p([l(u).e("popover-panel")])
          }, {
            default: n(() => [
              t(l(x), { prop: "0" }, {
                default: n(() => [
                  t(l(b), {
                    modelValue: a.value[0],
                    "onUpdate:modelValue": e[0] || (e[0] = (i) => a.value[0] = i)
                  }, null, 8, ["modelValue"])
                ]),
                _: 1
              }),
              t(l(x), null, {
                default: n(() => [
                  H
                ]),
                _: 1
              }),
              t(l(x), { prop: "1" }, {
                default: n(() => [
                  t(l(b), {
                    modelValue: a.value[1],
                    "onUpdate:modelValue": e[1] || (e[1] = (i) => a.value[1] = i)
                  }, null, 8, ["modelValue"])
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["model", "class"]),
          s("div", J, [
            t(l(k), { onClick: I }, {
              default: n(() => [
                c("取消")
              ]),
              _: 1
            }),
            t(l(k), {
              type: "primary",
              onClick: L
            }, {
              default: n(() => [
                c("确认")
              ]),
              _: 1
            })
          ])
        ]),
        _: 1
      }, 8, ["visible"])
    ]));
  }
});
export {
  re as default
};
