import { jsx as a, jsxs as H } from "react/jsx-runtime";
import { useId as J, useRef as Q, useCallback as d } from "react";
import { useSlotRecipe as U } from "@chakra-ui/react/styled-system";
import { S as t } from "./select-DiSjgVZP.es.js";
import { S as X } from "./search-input-DkAInzQF.es.js";
import { e as Y } from "./extract-style-props-CMyV-es-.es.js";
import { f as Z } from "./index-N3Xxo-X9.es.js";
import { createSlotRecipeContext as ee } from "@chakra-ui/react";
import { n as o, u as ae } from "./normalize-messages-BN9BAFXe.es.js";
const { withProvider: re, withContext: m } = /* @__PURE__ */ ee({
  key: "nimbusScopedSearchInput"
}), se = /* @__PURE__ */ re("div", "root"), te = /* @__PURE__ */ m(
  "div",
  "container"
), oe = /* @__PURE__ */ m(
  "div",
  "selectWrapper"
), ce = /* @__PURE__ */ m(
  "div",
  "searchWrapper"
), le = (c) => !c.text || c.text.trim().length === 0, ne = { searchLabel: "Search", selectLabel: "Filter by" }, ie = { searchLabel: "Suche", selectLabel: "Filtern nach" }, pe = { searchLabel: "Buscar", selectLabel: "Filtrar por" }, de = { searchLabel: "Rechercher", selectLabel: "Filtrer par" }, he = { searchLabel: "Pesquisa", selectLabel: "Filtrar por" }, ue = {
  en: /* @__PURE__ */ o(ne),
  de: /* @__PURE__ */ o(ie),
  es: /* @__PURE__ */ o(pe),
  "fr-FR": /* @__PURE__ */ o(de),
  "pt-BR": /* @__PURE__ */ o(he)
}, F = (c) => {
  const {
    value: r,
    onValueChange: l,
    onTextChange: g,
    onOptionChange: f,
    onSubmit: I,
    onReset: y,
    options: M,
    selectPlaceholder: D,
    searchPlaceholder: O,
    selectAriaLabel: _,
    searchAriaLabel: W,
    isClearable: z = !0,
    isDisabled: n,
    isReadOnly: i,
    isInvalid: j,
    isRequired: C,
    id: k,
    "aria-describedby": L,
    "aria-labelledby": R,
    size: h,
    ...q
  } = c, v = ae(ue), A = U({ recipe: Z }), [B, E] = A.splitVariantProps({
    size: h,
    ...q
  }), [T, V] = Y(E), $ = J(), x = k || $, G = `${x}-select`, P = `${x}-search`, u = Q(null), b = d(
    (e) => {
      g?.(e), l?.({ ...r, text: e });
    },
    [r, g, l]
  ), K = d(
    (e) => {
      if (e === null) return;
      const s = String(e);
      f?.(s), l?.({ ...r, option: s }), u.current && !n && !i && setTimeout(() => {
        u.current?.focus();
      }, 0);
    },
    [r, f, l, n, i]
  ), N = d(() => {
    I(r);
  }, [r, I]), w = d(() => {
    y?.(), b("");
  }, [y, b]);
  return /* @__PURE__ */ a(
    se,
    {
      ...B,
      ...T,
      ...V,
      children: /* @__PURE__ */ H(te, { children: [
        /* @__PURE__ */ a(oe, { asChild: !0, children: /* @__PURE__ */ a(
          t.Root,
          {
            id: G,
            selectedKey: r.option,
            onSelectionChange: i ? void 0 : K,
            placeholder: D,
            "aria-label": _ || v.format("selectLabel"),
            "aria-controls": P,
            "aria-describedby": L,
            "aria-labelledby": R,
            size: h,
            isClearable: !1,
            isDisabled: n,
            isRequired: C,
            children: /* @__PURE__ */ a(t.Options, { children: M.map(
              (e) => {
                if ("options" in e) {
                  const S = e;
                  return /* @__PURE__ */ a(t.OptionGroup, { label: S.label, children: S.options.map((p) => /* @__PURE__ */ a(
                    t.Option,
                    {
                      id: p.value,
                      isDisabled: p.isDisabled,
                      children: p.label
                    },
                    p.value
                  )) }, S.label);
                }
                const s = e;
                return /* @__PURE__ */ a(
                  t.Option,
                  {
                    id: s.value,
                    isDisabled: s.isDisabled,
                    children: s.label
                  },
                  s.value
                );
              }
            ) })
          }
        ) }),
        /* @__PURE__ */ a(ce, { asChild: !0, children: /* @__PURE__ */ a(
          X,
          {
            ref: u,
            id: P,
            value: r.text,
            onChange: b,
            onSubmit: N,
            onClear: z ? w : void 0,
            placeholder: O,
            "aria-label": W || v.format("searchLabel"),
            "aria-describedby": L,
            "aria-labelledby": R,
            size: h,
            isDisabled: n,
            isReadOnly: i,
            isInvalid: j,
            isRequired: C
          }
        ) })
      ] })
    }
  );
};
F.isEmpty = le;
F.displayName = "ScopedSearchInput";
export {
  F as S
};
//# sourceMappingURL=scoped-search-input-DEidPWv8.es.js.map
