import e from"../_util/classNames.mjs";import t from"../_util/omit.mjs";import n from"../_util/BaseInput.mjs";import{inputProps as r}from"./inputProps.mjs";import{fixControlledValue as i,hasAddon as a,hasPrefixSuffix as o,resolveOnChange as s,triggerFocus as c}from"./utils/commonUtils.mjs";import l from"./BaseInput.mjs";import{Fragment as u,computed as d,createVNode as f,defineComponent as p,nextTick as m,onMounted as h,shallowRef as g,watch as _}from"vue";var v=p({name:`VCInput`,inheritAttrs:!1,props:r(),setup(r,{slots:p,attrs:v,expose:y,emit:b}){let x=g(r.value===void 0?r.defaultValue:r.value),S=g(!1),C=g(),w=g();_(()=>r.value,()=>{x.value=r.value}),_(()=>r.disabled,()=>{r.disabled&&(S.value=!1)});let T=e=>{C.value&&c(C.value.input,e)};y({focus:T,blur:()=>{C.value.input?.blur()},input:d(()=>C.value.input?.input),stateValue:x,setSelectionRange:(e,t,n)=>{C.value.input?.setSelectionRange(e,t,n)},select:()=>{C.value.input?.select()}});let E=e=>{b(`change`,e)},D=(e,t)=>{x.value!==e&&(r.value===void 0?x.value=e:m(()=>{C.value.input.value!==x.value&&w.value?.$forceUpdate()}),m(()=>{t&&t()}))},O=e=>{let{value:t}=e.target;if(x.value===t)return;let n=e.target.value;s(C.value.input,e,E),D(n)},k=e=>{e.keyCode===13&&b(`pressEnter`,e),b(`keydown`,e)},A=e=>{S.value=!0,b(`focus`,e)},j=e=>{S.value=!1,b(`blur`,e)},M=e=>{s(C.value.input,e,E),D(``,()=>{T()})},N=()=>{let{addonBefore:i=p.addonBefore,addonAfter:s=p.addonAfter,disabled:c,valueModifiers:l={},htmlSize:u,autocomplete:d,prefixCls:m,inputClassName:h,prefix:g=p.prefix?.(),suffix:_=p.suffix?.(),allowClear:y,type:b=`text`}=r,x={...t(r,[`prefixCls`,`onPressEnter`,`addonBefore`,`addonAfter`,`prefix`,`suffix`,`allowClear`,`defaultValue`,`size`,`bordered`,`htmlSize`,`lazy`,`showCount`,`valueModifiers`,`showCount`,`affixWrapperClassName`,`groupClassName`,`inputClassName`,`wrapperClassName`]),...v,autocomplete:d,onChange:O,onInput:O,onFocus:A,onBlur:j,onKeydown:k,class:e(m,{[`${m}-disabled`]:c},h,!a({addonAfter:s,addonBefore:i})&&!o({prefix:g,suffix:_,allowClear:y})&&v.class),ref:C,key:`ant-input`,size:u,type:b,lazy:r.lazy};return l.lazy&&delete x.onInput,x.autofocus||delete x.autofocus,f(n,t(x,[`size`]),null)},P=()=>{let{maxlength:t,suffix:n=p.suffix?.(),showCount:a,prefixCls:o}=r,s=Number(t)>0;if(n||a){let r=[...i(x.value)].length,c=typeof a==`object`?a.formatter({count:r,maxlength:t}):`${r}${s?` / ${t}`:``}`;return f(u,null,[!!a&&f(`span`,{class:e(`${o}-show-count-suffix`,{[`${o}-show-count-has-suffix`]:!!n})},[c]),n])}return null};return h(()=>{}),()=>{let{prefixCls:e,disabled:t,...n}=r;return f(l,{...n,...v,ref:w,prefixCls:e,inputElement:N(),handleReset:M,value:i(x.value),focused:S.value,triggerFocus:T,suffix:P(),disabled:t},p)}}});export{v as default};