import { jsx as n, jsxs as ce } from "react/jsx-runtime";
import P, { createContext as le, useRef as B } from "react";
import { createSlotRecipeContext as ie, mergeRefs as ne } from "@chakra-ui/react";
import { useSlotRecipe as de } from "@chakra-ui/react/styled-system";
import { $ as fe, a as $e } from "./Input-Cmg08oRP.es.js";
import { $ as pe } from "./Button-BjcDZ5eb.es.js";
import { $ as g, c as be, b as ve, f as he, a as xe, e as me } from "./utils-B6pV5ewr.es.js";
import { $ as Ce } from "./FieldError-CXcEMuBf.es.js";
import { c as Pe } from "./RSPContexts-DLgb84PF.es.js";
import { $ as ge } from "./Form-CXcEMuBf.es.js";
import { a as De } from "./Group-BQc9LuMT.es.js";
import { $ as Be } from "./Label-DIseLESi.es.js";
import { $ as Ee } from "./Text-DOcU1ycg.es.js";
import { $ as Ie } from "./Hidden-X9vuhkMZ.es.js";
import { $ as Se } from "./filterDOMProps-BSVCO5jK.es.js";
import { $ as ye } from "./useControlledState-u436Wbp1.es.js";
import { e as Re } from "./mergeProps-Dsl8k3Ig.es.js";
import { $ as ke } from "./useLocalizedStringFormatter-DWb0DkHL.es.js";
import { $ as Me } from "./useTextField-yuaT8-G4.es.js";
import { Search as Fe, Close as _e } from "@commercetools/nimbus-icons";
import { e as ze } from "./extract-style-props-BdibuNZ7.es.js";
import { o as Ae } from "./index-C2qW4ynb.es.js";
import { n as h, u as Ve } from "./normalize-messages-D5T4I93D.es.js";
import { $ as we } from "./useObjectRef-CaJ5pgjX.es.js";
import { I as Le } from "./icon-button-CosIm3oY.es.js";
var E = {};
E = {
  "Clear search": "مسح البحث"
};
var I = {};
I = {
  "Clear search": "Изчистване на търсене"
};
var S = {};
S = {
  "Clear search": "Vymazat hledání"
};
var y = {};
y = {
  "Clear search": "Ryd søgning"
};
var R = {};
R = {
  "Clear search": "Suche zurücksetzen"
};
var k = {};
k = {
  "Clear search": "Απαλοιφή αναζήτησης"
};
var M = {};
M = {
  "Clear search": "Clear search"
};
var F = {};
F = {
  "Clear search": "Borrar búsqueda"
};
var _ = {};
_ = {
  "Clear search": "Tühjenda otsing"
};
var z = {};
z = {
  "Clear search": "Tyhjennä haku"
};
var A = {};
A = {
  "Clear search": "Effacer la recherche"
};
var V = {};
V = {
  "Clear search": "נקה חיפוש"
};
var w = {};
w = {
  "Clear search": "Obriši pretragu"
};
var L = {};
L = {
  "Clear search": "Keresés törlése"
};
var O = {};
O = {
  "Clear search": "Cancella ricerca"
};
var T = {};
T = {
  "Clear search": "検索をクリア"
};
var K = {};
K = {
  "Clear search": "검색 지우기"
};
var j = {};
j = {
  "Clear search": "Išvalyti iešką"
};
var N = {};
N = {
  "Clear search": "Notīrīt meklēšanu"
};
var q = {};
q = {
  "Clear search": "Tøm søk"
};
var U = {};
U = {
  "Clear search": "Zoekactie wissen"
};
var G = {};
G = {
  "Clear search": "Wyczyść zawartość wyszukiwania"
};
var H = {};
H = {
  "Clear search": "Limpar pesquisa"
};
var W = {};
W = {
  "Clear search": "Limpar pesquisa"
};
var Z = {};
Z = {
  "Clear search": "Ştergeţi căutarea"
};
var J = {};
J = {
  "Clear search": "Очистить поиск"
};
var Q = {};
Q = {
  "Clear search": "Vymazať vyhľadávanie"
};
var X = {};
X = {
  "Clear search": "Počisti iskanje"
};
var Y = {};
Y = {
  "Clear search": "Obriši pretragu"
};
var ee = {};
ee = {
  "Clear search": "Rensa sökning"
};
var ae = {};
ae = {
  "Clear search": "Aramayı temizle"
};
var re = {};
re = {
  "Clear search": "Очистити пошук"
};
var te = {};
te = {
  "Clear search": "清除搜索"
};
var se = {};
se = {
  "Clear search": "清除搜尋條件"
};
var oe = {};
oe = {
  "ar-AE": E,
  "bg-BG": I,
  "cs-CZ": S,
  "da-DK": y,
  "de-DE": R,
  "el-GR": k,
  "en-US": M,
  "es-ES": F,
  "et-EE": _,
  "fi-FI": z,
  "fr-FR": A,
  "he-IL": V,
  "hr-HR": w,
  "hu-HU": L,
  "it-IT": O,
  "ja-JP": T,
  "ko-KR": K,
  "lt-LT": j,
  "lv-LV": N,
  "nb-NO": q,
  "nl-NL": U,
  "pl-PL": G,
  "pt-BR": H,
  "pt-PT": W,
  "ro-RO": Z,
  "ru-RU": J,
  "sk-SK": Q,
  "sl-SI": X,
  "sr-SP": Y,
  "sv-SE": ee,
  "tr-TR": ae,
  "uk-UA": re,
  "zh-CN": te,
  "zh-TW": se
};
function Oe(a) {
  return a && a.__esModule ? a.default : a;
}
function Te(a, e, r) {
  let $ = ke(Oe(oe), "@react-aria/searchfield"), { isDisabled: u, isReadOnly: o, onSubmit: l, onClear: s, type: p = "search" } = a, b = (t) => {
    const f = t.key;
    f === "Enter" && (u || o) && t.preventDefault(), !(u || o) && (f === "Enter" && l && (t.preventDefault(), l(e.value)), f === "Escape" && (e.value === "" && (!r.current || r.current.value === "") ? t.continuePropagation() : (t.preventDefault(), e.setValue(""), s && s())));
  }, c = () => {
    e.setValue(""), s && s();
  }, v = () => {
    var t;
    (t = r.current) === null || t === void 0 || t.focus();
  }, { labelProps: i, inputProps: x, descriptionProps: m, errorMessageProps: C, ...d } = Me({
    ...a,
    value: e.value,
    onChange: e.setValue,
    onKeyDown: o ? a.onKeyDown : Re(b, a.onKeyDown),
    type: p
  }, r);
  return {
    labelProps: i,
    inputProps: {
      ...x,
      // already handled by useSearchFieldState
      defaultValue: void 0
    },
    clearButtonProps: {
      "aria-label": $.format("Clear search"),
      excludeFromTabOrder: !0,
      preventFocusOnPress: !0,
      isDisabled: u || o,
      onPress: c,
      onPressStart: v
    },
    descriptionProps: m,
    errorMessageProps: C,
    ...d
  };
}
function Ke(a) {
  let [e, r] = ye(D(a.value), D(a.defaultValue) || "", a.onChange);
  return {
    value: e,
    setValue: r
  };
}
function D(a) {
  if (a != null)
    return a.toString();
}
const je = /* @__PURE__ */ le(null), Ne = /* @__PURE__ */ Ie(function(e, r) {
  [e, r] = g(e, r, je);
  let { validationBehavior: $ } = be(ge) || {};
  var u, o;
  let l = (o = (u = e.validationBehavior) !== null && u !== void 0 ? u : $) !== null && o !== void 0 ? o : "native", s = B(null);
  [e, s] = g(e, s, Pe);
  let [p, b] = ve(!e["aria-label"] && !e["aria-labelledby"]), c = Ke({
    ...e,
    validationBehavior: l
  }), { labelProps: v, inputProps: i, clearButtonProps: x, descriptionProps: m, errorMessageProps: C, ...d } = Te({
    ...he(e),
    label: b,
    validationBehavior: l
  }, c, s), t = xe({
    ...e,
    values: {
      isEmpty: c.value === "",
      isDisabled: e.isDisabled || !1,
      isInvalid: d.isInvalid || !1,
      state: c
    },
    defaultClassName: "react-aria-SearchField"
  }), f = Se(e, {
    global: !0
  });
  return delete f.id, /* @__PURE__ */ P.createElement("div", {
    ...f,
    ...t,
    ref: r,
    slot: e.slot || void 0,
    "data-empty": c.value === "" || void 0,
    "data-disabled": e.isDisabled || void 0,
    "data-invalid": d.isInvalid || void 0
  }, /* @__PURE__ */ P.createElement(me, {
    values: [
      [
        Be,
        {
          ...v,
          ref: p
        }
      ],
      [
        fe,
        {
          ...i,
          ref: s
        }
      ],
      [
        pe,
        x
      ],
      [
        Ee,
        {
          slots: {
            description: m,
            errorMessage: C
          }
        }
      ],
      [
        De,
        {
          isInvalid: d.isInvalid,
          isDisabled: e.isDisabled || !1
        }
      ],
      [
        Ce,
        d
      ]
    ]
  }, t.children));
}), { withProvider: qe, withContext: ue } = /* @__PURE__ */ ie({
  key: "searchInput"
}), Ue = /* @__PURE__ */ qe("div", "root"), Ge = /* @__PURE__ */ ue(
  "div",
  "leadingElement"
), He = /* @__PURE__ */ ue("input", "input"), We = { clearInput: "Clear search input" }, Ze = { clearInput: "Suchfeld löschen" }, Je = { clearInput: "Borrar entrada de búsqueda" }, Qe = { clearInput: "Effacer les données de recherche" }, Xe = { clearInput: "Limpar entrada de pesquisa" }, Ye = {
  en: /* @__PURE__ */ h(We),
  de: /* @__PURE__ */ h(Ze),
  es: /* @__PURE__ */ h(Je),
  "fr-FR": /* @__PURE__ */ h(Qe),
  "pt-BR": /* @__PURE__ */ h(Xe)
}, ea = (a) => {
  const { ref: e, ...r } = a, $ = Ve(Ye), u = de({ recipe: Ae }), [o, l] = u.splitVariantProps(r), s = B(null), p = we(ne(s, e)), [b, c] = ze(l), v = {
    "data-disabled": a.isDisabled ? "true" : void 0,
    "data-invalid": a.isInvalid ? "true" : "false"
  };
  return /* @__PURE__ */ n(Ne, { ...c, children: ({ state: i }) => /* @__PURE__ */ ce(Ue, { ...o, ...b, ...v, children: [
    /* @__PURE__ */ n(Ge, { children: /* @__PURE__ */ n(Fe, {}) }),
    /* @__PURE__ */ n(He, { asChild: !0, children: /* @__PURE__ */ n($e, { ref: p }) }),
    /* @__PURE__ */ n(
      Le,
      {
        slot: "null",
        size: "2xs",
        variant: "ghost",
        colorPalette: "primary",
        "aria-label": $.format("clearInput"),
        onPress: () => i.setValue(""),
        opacity: i.value ? 1 : 0,
        pointerEvents: i.value ? "auto" : "none",
        isDisabled: a.isDisabled || a.isReadOnly,
        children: /* @__PURE__ */ n(_e, {})
      }
    )
  ] }) });
};
ea.displayName = "SearchInput";
export {
  ea as S
};
//# sourceMappingURL=search-input-BDUJ48BC.es.js.map
