"use strict";const h=require("./tslib.es6-C4EgNkz1.js"),o=require("react"),ce=require("classnames"),ue=require("./forwardRef-DBQKIlPy.js"),p=require("./utils-C9NL3q0j.js"),w=require("./icon-I30uh1Ov.js"),de=require("./icon-button-AJ6dtyvc.js"),be=require("./hooks-uidlIIid.js"),K=t=>{var{children:s,name:a,icon:l,buttonAriaLabel:i,onClick:u=()=>{}}=t,d=h.__rest(t,["children","name","icon","buttonAriaLabel","onClick"]);return a||l?i?o.createElement(de.EbayIconButton,Object.assign({"aria-label":i,icon:l||a,transparent:!0,onClick:u},d)):l||o.createElement(w.EbayIcon,Object.assign({name:a},d)):s},P=t=>o.createElement("span",Object.assign({},t)),F=t=>{var{children:s,name:a,icon:l}=t,i=h.__rest(t,["children","name","icon"]);return a?o.createElement(w.EbayIcon,Object.assign({name:a},i)):l||s},_=t=>o.createElement("span",Object.assign({},t)),m=t=>typeof t<"u",xe=t=>{var s,a,{type:l="text",invalid:i,fluid:u,multiline:d,onChange:q=()=>{},onInputChange:B=()=>{},onFocus:j=()=>{},onBlur:k=()=>{},onKeyPress:O=()=>{},onKeyUp:V=()=>{},onKeyDown:R=()=>{},onInvalid:N=()=>{},onFloatingLabelInit:S=()=>{},onButtonClick:D=()=>{},autoFocus:E,defaultValue:g="",value:y,forwardedRef:U,inputRef:z,inputSize:C="default",floatingLabel:$,floatingLabelStatic:A,children:b,placeholder:M,opaqueLabel:W}=t,c=h.__rest(t,["type","invalid","fluid","multiline","onChange","onInputChange","onFocus","onBlur","onKeyPress","onKeyUp","onKeyDown","onInvalid","onFloatingLabelInit","onButtonClick","autoFocus","defaultValue","value","forwardedRef","inputRef","inputSize","floatingLabel","floatingLabelStatic","children","placeholder","opaqueLabel"]);const[I,G]=o.useState(g),[H,J]=o.useState(g),T=be.useFloatingLabel({text:$,disabled:c.disabled,size:C,invalid:i,opaqueLabel:W,static:A||l==="date",onMount:S,containerTagName:u?"div":"span"}),L=n=>{var e;j(n,{value:((e=n?.target)===null||e===void 0?void 0:e.value)||g})},Q=n=>{var e;const r=(e=n.target)===null||e===void 0?void 0:e.value;k(n,{value:r}),r!==I&&(q(n,{value:r}),G(r))},X=n=>{const e=n.target;O(n,{value:e?.value})},Y=n=>{const e=n.target;V(n,{value:e?.value})},Z=n=>{const e=n.target;R(n,{value:e?.value})},ee=n=>{const e=n.target;N(n,{value:e?.value})},ne=n=>{D(n,{value:I})};o.useEffect(()=>{E&&L()},[]);const te=n=>{var e;const r=(e=n.target)===null||e===void 0?void 0:e.value;m(y)||J(r),B(n,{value:r})},oe=d?"textarea":"input",ae=u?"div":"span",le=p.findComponent(b,F),x=p.findComponent(b,_),ie=(s=x?.props)===null||s===void 0?void 0:s.id,v=p.findComponent(b,K),f=p.findComponent(b,P),se=(a=f?.props)===null||a===void 0?void 0:a.id,re=ce("textbox",c.className,{"textbox--fluid":u,"textbox--large":C==="large","textbox--disabled":c.disabled,"textbox--invalid":i,"textbox--readonly":c.readOnly});return o.createElement(T.Container,null,o.createElement(T.Label,{htmlFor:c.id}),o.createElement(ae,{className:re},le,x,o.createElement(oe,Object.assign({"aria-describedby":[ie,se].filter(Boolean).join(" ")||void 0},c,{className:"textbox__control",type:l,"aria-invalid":i,value:m(y)?y:H,onChange:te,onBlur:Q,onFocus:L,onKeyPress:X,onKeyUp:Y,onKeyDown:Z,onInvalid:ee,autoFocus:E,ref:z||U,placeholder:M})),f,v&&o.cloneElement(v,Object.assign(Object.assign({},v.props),{onClick:n=>{const{onClick:e=()=>{}}=v.props;e(n),ne(n)}}))))},ve=ue.withForwardRef(xe);exports.EbayTextbox=ve;exports.EbayTextboxPostfixIcon=K;exports.EbayTextboxPostfixText=P;exports.EbayTextboxPrefixIcon=F;exports.EbayTextboxPrefixText=_;exports.isControlled=m;
