import { bv as C, c0 as I, c9 as V, a0 as c, bX as o, P as R, bi as b, bj as g, bV as x, cG as y } from "./684d2f28.js";
import { useState as p, useRef as f, useEffect as m } from "react";
import { focusWithOptions as q, blurMethod as D } from "./d6402597.js";
import "react-dom";
const L = {
  required: C,
  customRule: I
}, h = (e) => {
  if (e.customRule)
    return {
      validateStatus: "error",
      help: e.customRule
    };
  const t = e.value.value;
  return e.required && V.isEmpty(t) ? {
    validateStatus: "error",
    help: c("prop.required")
  } : {
    validateStatus: "success"
  };
}, P = (e) => {
  var r;
  const [t, l] = p({}), n = f(!1), s = f(e);
  s.current = e;
  const i = e.value.value, d = (r = e.defaultValue) == null ? void 0 : r.value, S = (a) => {
    l(h({
      ...s.current,
      value: {
        value: a
      }
    }));
  };
  return m(() => {
    var a, u;
    (u = (a = e.value).onChange) == null || u.call(a, d);
  }, [d]), m(() => {
    var a;
    n.current && (S(i), (a = e.onEvent) == null || a.call(e, "change"), n.current = !1);
  }, [i]), [
    t,
    (a) => {
      var u, v;
      (v = (u = e.value).onChange) == null || v.call(u, a), n.current = !0;
    }
  ];
}, B = o({
  name: "invalid",
  desc: c("export.invalidDesc"),
  depKeys: ["value", "required", "customRule"],
  func: (e) => h({
    ...e,
    value: {
      value: e.value
    }
  }).validateStatus !== "success"
}), G = (e) => /* @__PURE__ */ R(b, {
  name: g.validation,
  children: [x(e), e.customRule.propertyView({})]
}), N = [o({
  name: "selectedIndex",
  desc: c("selectInput.selectedIndexDesc"),
  depKeys: ["value", "options"],
  func: (e) => {
    var t, l;
    return (l = (t = e.options).findIndex) == null ? void 0 : l.call(t, (n) => n.value === e.value);
  }
}), o({
  name: "selectedLabel",
  desc: c("selectInput.selectedLabelDesc"),
  depKeys: ["value", "options"],
  func: (e) => {
    var t, l, n;
    return (n = (l = (t = e.options).find) == null ? void 0 : l.call(t, (s) => s.value === e.value)) == null ? void 0 : n.label;
  }
})], O = y([q, D]);
export {
  N as SelectInputCommonConfig,
  B as SelectInputInvalidConfig,
  L as SelectInputValidationChildren,
  G as SelectInputValidationSection,
  O as selectDivRefMethods,
  h as selectInputValidate,
  P as useSelectInputValidate
};
