import { jsxs as c, Fragment as m, jsx as s } from "@emotion/react/jsx-runtime";
import { useModuleDictionary as f } from "@m4l/core";
import { useMemo as u } from "react";
import { SELECT_ASYNC_OPERATORS_MULTIPLE as _, SELECT_ASYNC_OPERATORS_SINGLE as d } from "../../../constants.js";
import { DYNAMIC_FILTER_DICTIONARY_ID as A, DICCTIONARY as i } from "../../../dictionary.js";
import { useDynamicFilterStore as O } from "../../../store/useDynamicFilterStore.js";
import { RHFAutocomplete as E } from "../../../../hook-form/RHFAutocomplete/RHFAutocomplete.js";
import { RHFAutocompleteAsync as y } from "../../../../hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js";
function F() {
  const { getLabel: o } = f(), r = O((e) => e.popoverFilterData?.field), a = r?.selectAsyncOptions, t = a?.multiple ?? !1, l = r?.restritcOperatorsTo;
  if (!r?.selectAsyncOptions?.endPoint)
    throw new Error("El filtro tipo Select requiere la configuración del Endpoint");
  const n = u(
    () => (t ? _ : d).map((e) => ({
      id: e,
      label: o(`${A}.operator_${e}`)
    })).filter((e) => l ? l.includes(e.id) : !0),
    [o, t, l]
  );
  return /* @__PURE__ */ c(m, { children: [
    /* @__PURE__ */ s(
      E,
      {
        type: "text",
        name: "formValueOperator",
        autoComplete: "off",
        options: n,
        getOptionLabel: (e) => e.label,
        isOptionEqualToValue: (e, p) => e.id === p.id,
        label: o(i.label_select_operator)
      }
    ),
    /* @__PURE__ */ s(
      y,
      {
        ...a,
        name: t ? "formValueOperandsArray" : "formValueOperand1",
        autoComplete: "off",
        label: o(t ? i.label_select_async_operands_array : i.label_select_async_operand1)
      }
    )
  ] });
}
export {
  F as SelectAsyncFilter
};
