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