import { isRecord as u } from "../../../isRecord.js";
import { resolveSelectOptionIconSrc as c } from "./helpers/resolveSelectOptionIconSrc/resolveSelectOptionIconSrc.js";
function d(t) {
  if (typeof t.startAdornment == "string" && t.startAdornment.trim() !== "")
    return t.startAdornment;
  if (typeof t.startAdormentPath == "string" && t.startAdormentPath.trim() !== "")
    return t.startAdormentPath;
}
function a(t, o) {
  if (!u(t))
    return null;
  const e = t.id;
  if (typeof e != "string" && typeof e != "number")
    return null;
  const r = e;
  let n;
  if (typeof t.label == "string")
    n = t.label.trim() !== "" ? t.label : String(r);
  else {
    const s = t.name, f = t.value;
    typeof s == "string" && s.trim() !== "" ? n = s : typeof f == "string" && f.trim() !== "" && (n = f);
  }
  if (n === void 0)
    return null;
  const i = { id: r, label: n }, l = d(t);
  if (l === void 0)
    return i;
  const m = c(o, l);
  return m === "" ? i : { ...i, startAdornment: m };
}
function A(t, o) {
  if (!Array.isArray(t))
    return [];
  const e = [];
  for (const r of t) {
    const n = a(r, o);
    n && e.push(n);
  }
  return e;
}
export {
  A as normalizeFieldOptionsForSelect
};
