import { o as c } from "./rolldown-runtime.js";
import { i as b, t as y } from "./vendor/react.js";
var A = (r, n) => Object.is(r, n);
function a(r, n, t) {
  return r == null || n == null ? Object.is(r, n) : t(r, n);
}
function _(r, n, t) {
  return !r || r.length === 0 ? !1 : r.some((l) => l === void 0 ? !1 : a(n, l, t));
}
function x(r, n, t) {
  return !r || r.length === 0 ? -1 : r.findIndex((l) => l === void 0 ? !1 : a(l, n, t));
}
function q(r, n, t) {
  return r.filter((l) => !a(n, l, t));
}
var p = /* @__PURE__ */ c(b());
function i(r) {
  if (r == null) return "";
  if (typeof r == "string") return r;
  try {
    return JSON.stringify(r);
  } catch {
    return String(r);
  }
}
var I = y();
function s(r) {
  return r != null && r.length > 0 && typeof r[0] == "object" && r[0] != null && "items" in r[0];
}
function E(r) {
  if (!Array.isArray(r)) return r != null && "null" in r;
  const n = r;
  if (s(n)) {
    for (const t of n) for (const l of t.items) if (l && l.value == null && l.label != null) return !0;
    return !1;
  }
  for (const t of n) if (t && t.value == null && t.label != null) return !0;
  return !1;
}
function d(r, n) {
  if (n && r != null) return n(r) ?? "";
  if (r && typeof r == "object") {
    if ("label" in r && r.label != null) return String(r.label);
    if ("value" in r) return String(r.value);
  }
  return i(r);
}
function M(r, n) {
  return n && r != null ? n(r) ?? "" : r && typeof r == "object" && "value" in r && "label" in r ? i(r.value) : i(r);
}
function h(r, n, t) {
  function l() {
    return d(r, t);
  }
  if (t && r != null) return t(r);
  if (r && typeof r == "object" && "label" in r && r.label != null) return r.label;
  if (n && !Array.isArray(n)) return n[r] ?? l();
  if (Array.isArray(n)) {
    const f = n, e = s(f) ? f.flatMap((u) => u.items) : f;
    if (r == null || typeof r != "object") {
      const u = e.find((o) => o.value === r);
      return u && u.label != null ? u.label : l();
    }
    if ("value" in r) {
      const u = e.find((o) => o && o.value === r.value);
      if (u && u.label != null) return u.label;
    }
  }
  return l();
}
function O(r, n, t) {
  return r.reduce((l, f, e) => (e > 0 && l.push(", "), l.push(/* @__PURE__ */ (0, I.jsx)(p.Fragment, { children: h(f, n, t) }, e)), l), []);
}
export {
  d as a,
  A as c,
  _ as d,
  h as i,
  x as l,
  s as n,
  M as o,
  O as r,
  a as s,
  E as t,
  q as u
};

//# sourceMappingURL=resolveValueLabel.js.map