import{c as L,r as i,bm as P,ap as D,d3 as W,j as s,b$ as H,c0 as M,ch as U,c1 as B,bJ as _,b9 as O,d4 as A}from"./index-DCNLpqIv.js";import{u as G}from"./uniqueId-Dgo2nsPZ.js";import{I as J}from"./InputInstructions-BgxdtQsQ.js";import{a as K}from"./useBasicWidgetState-9vtYd9vP.js";import{u as N,a as $,b as q}from"./useUpdateUiValue-BF7Ryinr.js";import{I as Q}from"./input-DTfsWA-x.js";import"./FormClearHelper-fvwQICEk.js";import"./inputUtils-CptNuJwn.js";import"./base-input-D2OIsCyG.js";const X=L("div",{target:"e11y4ecf0"})({name:"bjn8wh",styles:"position:relative"});function Y({disabled:a,element:e,widgetMgr:r,fragmentId:d}){const[l,u]=i.useState(()=>S(r,e)??null),[I,y]=P(),[o,p]=i.useState(!1),T=i.useCallback(()=>{u(e.default??null),p(!0)},[e.default]),[C,c]=K({getStateFromWidgetMgr:S,getDefaultStateFromProto:Z,getCurrStateFromProto:ee,updateWidgetMgrState:te,element:e,widgetMgr:r,fragmentId:d,onFormCleared:T});N(C,l,u,o);const[j,h]=i.useState(!1),t=D(),[f]=i.useState(()=>G("text_input_")),{placeholder:v,formId:n,icon:m,maxChars:b}=e,g=i.useCallback(()=>{p(!1),c({value:l,fromUi:!0})},[l,c]),F=W({formId:n})?r.allowFormEnterToSubmit(n):o,z=j&&I>t.breakpoints.hideWidgetDetails,R=i.useCallback(()=>{o&&g(),h(!1)},[o,g]),V=i.useCallback(()=>{h(!0)},[]),w=$({formId:n,maxChars:b,setDirty:p,setUiValue:u,setValueWithSource:c}),E=q(n,g,o,r,d),x=m?.startsWith(":material"),k=x?"lg":"base";return s.jsxs(X,{className:"stTextInput","data-testid":"stTextInput",ref:y,children:[s.jsx(H,{label:e.label,disabled:a,labelVisibility:M(e.labelVisibility?.value),htmlFor:f,children:e.help&&s.jsx(U,{children:s.jsx(B,{content:e.help,placement:_.TOP_RIGHT})})}),s.jsx(Q,{value:l??"",placeholder:v,onBlur:R,onFocus:V,onChange:w,onKeyPress:E,"aria-label":e.label,disabled:a,id:f,type:ae(e),autoComplete:e.autocomplete,startEnhancer:m&&s.jsx(O,{"data-testid":"stTextInputIcon",iconValue:m,size:k}),overrides:{Input:{style:{fontWeight:t.fontWeights.normal,minWidth:0,lineHeight:t.lineHeights.inputWidget,paddingRight:t.spacing.sm,paddingLeft:t.spacing.md,paddingBottom:t.spacing.sm,paddingTop:t.spacing.sm,"::placeholder":{color:t.colors.fadedText60}}},Root:{props:{"data-testid":"stTextInputRootElement"},style:{height:t.sizes.minElementHeight,borderLeftWidth:t.sizes.borderWidth,borderRightWidth:t.sizes.borderWidth,borderTopWidth:t.sizes.borderWidth,borderBottomWidth:t.sizes.borderWidth,paddingLeft:m?t.spacing.sm:0}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:t.iconSizes.lg,color:x?t.colors.fadedText60:"inherit"}}}}),z&&s.jsx(J,{dirty:o,value:l??"",maxLength:b,inForm:W({formId:n}),allowEnterToSubmit:F})]})}function S(a,e){return a.getStringValue(e)??null}function Z(a){return a.default??null}function ee(a){return a.value??null}function te(a,e,r,d){e.setStringValue(a,r.value,{fromUi:r.fromUi},d)}function ae(a){return a.type===A.Type.PASSWORD?"password":"text"}const ie=i.memo(Y);export{ie as default};
