import{z as b,j as t,Z as N,I as C}from"./index-CmAiVN5e.js";import{a as M,r as S}from"./vendor-animations-CsoOZIH8.js";import{p as T}from"./pluralize-BqhPSiJS.js";const i="text-input-group-v2",c=`${i}__form`,$=`${c}_mode_multiline`,h=`${i}__control`,F=e=>{const[g,s]=M.useState(!1),{t:u}=b(),f=e.value||"",a=e.inputRef||S.useRef(null),_=e.maxLength?`${f.length}/${e.maxLength} ${T(e.maxLength,u("general:symbols:one"),u("general:symbols:two"),u("general:symbols:many"))}`:"",y=()=>{a.current&&e.maxLength&&(a.current.value=a.current.value.substring(0,e.maxLength))},r=n=>{y(),e.onChange&&e.onChange(n.target.value)},o=n=>{var x;if(n.key==="Enter"){(x=e.onEnter)==null||x.call(e);return}},l=n=>n===e.iconPosition&&e.icon?t.jsx("div",{className:`${i}__icon-wrapper_${n}`,children:t.jsx(C,{type:e.icon})}):null,m=()=>s(!0),d=()=>{e.onBlur&&e.onBlur(),s(!1)},L=()=>e.isMultiline?t.jsxs("div",{className:`${$} ${c}`,children:[l("left"),t.jsx("textarea",{ref:a,className:h,placeholder:e.placeholder,value:e.value,name:e.name,disabled:e.isDisabled,onChange:r,onKeyDown:o,onFocus:m,onBlur:d,readOnly:e.isCopyonly,maxLength:e.maxLength}),l("right")]}):t.jsxs("div",{className:c,children:[l("left"),t.jsx("input",{ref:a,className:h,type:e.type??"text",name:e.name,autoFocus:e.autoFocus,inputMode:e.inputMode,placeholder:e.placeholder,value:e.value,disabled:e.isDisabled,onChange:r,onKeyDown:o,onFocus:m,onBlur:d,readOnly:e.isCopyonly,maxLength:e.maxLength}),l("right")]}),v=()=>L();return t.jsx(N,{className:i,title:e.title,subtitle:e.subtitle,errorText:e.errorText,hintText:e.hintText,limitText:_,isDisabled:e.isDisabled,isFocused:g,isFilled:!!e.value,children:v()})};export{F as T};