import { jsx as b } from "@emotion/react/jsx-runtime";
import { createAutocompleteAsyncOnChangeFilterParms as V } from "./createAutocompleteAsyncOnChangeFilterParms.js";
import { normalizeAutocompletePropsFromBackend as S } from "./normalizeAutocompletePropsFromBackend.js";
import { resolveFieldHelperMessage as q, resolveFieldMandatory as H } from "../../../resolveFieldContractAliases.js";
import { RHFAutocompleteAsync as T } from "../../../../../hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js";
import { RHFAutocomplete as C } from "../../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
const N = {
  componentIds: ["RHFAutoComplete"],
  /** Renders the RHFAutocomplete component for the given field and context. */
  render(O) {
    const { field: e, props: y } = O, { size: s = "medium", disabled: a, readOnly: p, getLabel: h, hostApiRemote: f, suppressLabel: d } = y, { name: m, placeholder: c } = e, { endpoint: l, endpointParams: E } = e, u = q(e), F = H(e), L = S(e, h, f), {
      isMultiple: r,
      resolvedLabel: g,
      resolvedOptions: M,
      resolvedGetOptionLabel: P,
      resolvedIsOptionEqualToValue: R,
      resolvedOptionStartAdornment: t,
      resolvedOptionEndAdornment: n
    } = L, v = P ?? ((o) => o.label), A = R ?? ((o, i) => o === i);
    if (typeof l == "string" && l.trim() !== "") {
      const o = e.endpointFilterFieldLabel !== void 0 || e.endpointFilterFieldValueString !== void 0 || e.endpointFilterFieldValueNumber !== void 0, i = !r && o ? V(e) : void 0;
      return /* @__PURE__ */ b(
        T,
        {
          name: m,
          size: s,
          ...!d && { label: g, mandatory: F },
          helperMessage: u || "",
          disabled: a || p,
          placeholder: c ?? void 0,
          multiple: r,
          endPoint: l,
          parms: E,
          getOptionLabel: v,
          isOptionEqualToValue: A,
          ...t ? { getOptionStartAdornment: t } : {},
          ...n ? { getOptionEndAdornment: n } : {},
          onChangeFilterParms: i
        }
      );
    }
    return /* @__PURE__ */ b(
      C,
      {
        name: m,
        size: s,
        ...!d && { label: g, mandatory: F },
        helperMessage: u || "",
        disabled: a || p,
        placeholder: c ?? void 0,
        options: M,
        multiple: r,
        getOptionLabel: v,
        isOptionEqualToValue: A,
        ...t ? { getOptionStartAdornment: t } : {},
        ...n ? { getOptionEndAdornment: n } : {}
      }
    );
  }
};
export {
  N as autocompleteStrategy
};
