import { createElement as a } from "react";
import { isRecord as I } from "../../../isRecord.js";
import { resolveFieldTypeComponentProps as P } from "../../../resolveFieldContractAliases.js";
import { isPositiveInteger as r } from "../../../isPositiveInteger.js";
import { resolveAssetSrcWithBase as c } from "../../helpers/resolveAssetSrcWithBase.js";
import { resolveFieldInputLabel as u } from "../../../resolveFieldInputLabel/resolveFieldInputLabel.js";
import { Icon as p } from "../../../../../Icon/Icon.js";
function k(n, f, m) {
  const s = u(n, f), t = P(n.fieldType);
  if (!I(t))
    return { resolvedLabel: s };
  const o = {};
  typeof t.id == "string" && t.id.trim() !== "" && (o.id = t.id.trim()), typeof t.htmlFor == "string" && t.htmlFor.trim() !== "" && (o.htmlFor = t.htmlFor.trim()), typeof t.placeholder == "string" && t.placeholder.trim() !== "" && (o.placeholder = t.placeholder.trim()), r(t.maxLength) && (o.maxLength = t.maxLength), typeof t.multiline == "boolean" && (o.multiline = t.multiline), r(t.rows) && (o.rows = t.rows), r(t.minRows) && (o.minRows = t.minRows), r(t.maxRows) && (o.maxRows = t.maxRows);
  let e, i;
  typeof t.startAdormentPath == "string" && t.startAdormentPath.trim() !== "" && (e = t.startAdormentPath), typeof t.endAdormentPath == "string" && t.endAdormentPath.trim() !== "" && (i = t.endAdormentPath);
  const l = e ? a(p, { src: c(m, e) }) : void 0, d = i ? a(p, { src: c(m, i) }) : void 0, {
    startIcon: g,
    endIcon: v,
    ...h
  } = o;
  return {
    ...h,
    resolvedLabel: s,
    ...l !== void 0 ? { startIcon: l } : {},
    ...d !== void 0 ? { endIcon: d } : {}
  };
}
export {
  k as normalizeTextFieldPropsFromBackend
};
