import{jsx as t,jsxs as N}from"react/jsx-runtime";import{Children as z,cloneElement as k,isValidElement as ee,forwardRef as D,useRef as E}from"react";import{useTextField as S,useFocusRing as w,useHover as B,mergeProps as H}from"react-aria";import R from"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import p from"../primitives/text.js";import{textInput as V}from"../../recipes/text-input.js";import{cx as q,css as re}from"@styled/css";import{Flex as P,VStack as te,HStack as oe}from"@styled/jsx";import{token as A}from"@styled/tokens";import{createSlot as m,createHost as ie}from"create-slots";const K=m(({children:o,...s})=>t(P,{alignItems:"center",justifyContent:"center",children:z.map(o,e=>{var r;return k(e,{...s,color:(r=e.props.color)!==null&&r!==void 0?r:A("colors.neutral.primary")})})})),M=m(({children:o,...s})=>t(P,{alignItems:"center",justifyContent:"center",children:z.map(o,e=>{var r;return ee(e)?k(e,{...s,color:(r=e.props.color)!==null&&r!==void 0?r:A("colors.brand.base")}):null})})),O=m(R),W=m(p),$=m(p),G=D((o,s)=>{const{label:e,disabled:r,size:n="md",alignText:h="left",attr:f,description:a,autoFocus:g,className:x="",errorMessage:d,required:l}=o,u=n==="sm"?16:20,L=E(null),I=s||L,{labelProps:Q,inputProps:U,descriptionProps:X,errorMessageProps:Y,isInvalid:y,validationErrors:C}=S({...o,isDisabled:r??!1,isInvalid:!!d},I),{focusProps:Z}=w({autoFocus:g??!1}),{hoverProps:_}=B({isDisabled:r??!1});return ie(o.children,c=>{const v=c.get(K),b=c.get(M),j=c.getProps(O),F=c.getProps(W),T=c.getProps($),i=V({size:n,alignText:h,disabled:r,isError:y});return N(te,{className:q(i.container,x),children:[e&&N("label",{className:i.label,...Q,children:[e," ",l&&t("span",{className:re({color:"negative.darker"}),children:"*"})]}),N(oe,{className:i.inputContainer,children:[v&&{...v,props:{...v.props,className:i.typeIcon,width:u,height:u}},F&&t(p,{...F,fontColor:"text.tertiary"}),t("input",{ref:I,className:i.input,...H(U,Z,_),...f}),T&&t(p,{...T,fontColor:"text.tertiary"}),b&&{...b,props:{...b.props,className:i.actionIcon,width:u,height:u}},j&&t(P,{alignItems:"center",justifyContent:"center",className:i.actionButton,children:t(R,{...j,variant:"text",size:n})})]}),a&&t("div",{className:i.description,...X,children:a}),y&&t(p,{variant:"error",...Y,size:"sm",fontWeight:"normal",children:C.length>0?C.join(" "):d})]})})}),J=D((o,s)=>{const{disabled:e,autoFocus:r,className:n="",attr:h}=o,f=E(null),a=s||f,{inputProps:g}=S({...o,isDisabled:e??!1},a),{focusProps:x}=w({autoFocus:r??!1}),{hoverProps:d}=B({isDisabled:e??!1}),l=V({char:!0,disabled:e});return t("div",{className:q(l.container,l.inputContainer,n),children:t("input",{ref:a,className:l.input,...H(g,x,d),size:1,...h})})}),se=Object.assign(G,{TypeIcon:K,ActionIcon:M,ActionButton:O,Char:J,Prefix:W,Suffix:$});G.displayName="TextInput",J.displayName="TextInputChar";export{se as TextInput};
//# sourceMappingURL=text-input.js.map
