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