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