"use strict";const t=require("react/jsx-runtime"),n=require("react"),x=require("@chakra-ui/react"),T=require("@chakra-ui/react/styled-system"),h=require("./utils-BNYGVv6l.cjs.js"),o=require("./Input-vwFPIv-x.cjs.js"),E=require("./extract-style-props-DVhOcGEi.cjs.js"),j=require("./index-Dzrt5_tw.cjs.js"),C=require("./useObjectRef-4v2MxSjQ.cjs.js"),O=require("./mergeProps-DD8aR8go.cjs.js"),k=require("./useTextField-xUsOzG8r.cjs.js"),{withProvider:w,withContext:c}=x.createSlotRecipeContext({key:"nimbusTextInput"}),L=w("div","root"),N=c("div","leadingElement"),D=c("input","input"),F=c("div","trailingElement"),$=a=>{const{leadingElement:d,trailingElement:l,ref:b,...m}=a,v=T.useSlotRecipe({recipe:j.textInputSlotRecipe}),[R,q]=v.splitVariantProps(m),i=n.useRef(null),r=n.useRef(null),u=C.$df56164dff5785e2$export$4338b53315abf666(x.mergeRefs(r,b)),[I,P]=E.extractStyleProps(q),e=h.$64fa3d84918910a7$export$fabf2dc03a41866e(o.$3985021b0ad6602f$export$37fb8590cf2c088c),g=n.useMemo(()=>({...e,isDisabled:e?.isDisabled??e?.disabled,isRequired:e?.isRequired??e?.required,isReadOnly:e?.isReadOnly??e?.readOnly,isInvalid:e?.isInvalid??(e?.["aria-invalid"]===!0||e?.["aria-invalid"]==="true"?!0:e?.["aria-invalid"]===!1||e?.["aria-invalid"]==="false"?!1:void 0),disabled:void 0,required:void 0,readOnly:void 0}),[e]),y=O.$3ef42575df84b30b$export$9d1611c77c2fe928(g,P),{inputProps:s}=k.$2d73ec29415bd339$export$712718f7aec83d5(y,u),S={"data-disabled":s.disabled?"true":void 0,"data-invalid":s["aria-invalid"]?"true":"false"};return n.useEffect(()=>{const p=f=>{i.current&&i.current.contains(f.target)&&r.current&&f.target!==r.current&&r.current.focus()};return document.addEventListener("click",p),()=>{document.removeEventListener("click",p)}},[]),t.jsxs(L,{ref:i,className:a?.className,...R,...I,...S,children:[d&&t.jsx(N,{children:d}),t.jsx(D,{asChild:!0,children:t.jsx(o.$3985021b0ad6602f$export$f5b8910cec6cf069,{ref:u,...s})}),l&&t.jsx(F,{children:l})]})};$.displayName="TextInput";const z=Object.assign($,{Context:o.$3985021b0ad6602f$export$37fb8590cf2c088c});exports.TextInput=z;
//# sourceMappingURL=text-input-BcnTka1I.cjs.js.map
