import e from"../_util/classNames.mjs";import{cloneElement as t}from"../_util/vnode.mjs";import{baseInputProps as n}from"./inputProps.mjs";import{hasAddon as r,hasPrefixSuffix as i}from"./utils/commonUtils.mjs";import{createVNode as a,defineComponent as o,ref as s}from"vue";var c=o({name:`BaseInput`,inheritAttrs:!1,props:n(),setup(n,{slots:o,attrs:c}){let l=s(),u=e=>{if(l.value?.contains(e.target)){let{triggerFocus:e}=n;e?.()}},d=()=>{let{allowClear:t,value:r,disabled:i,readonly:s,handleReset:c,suffix:l=o.suffix,prefixCls:u}=n;if(!t)return null;let d=!i&&!s&&r,f=`${u}-clear-icon`,p=o.clearIcon?.()||`*`;return a(`span`,{onClick:c,onMousedown:e=>e.preventDefault(),class:e({[`${f}-hidden`]:!d,[`${f}-has-suffix`]:!!l},f),role:`button`,tabindex:-1},[p])};return()=>{let{focused:s,value:f,disabled:p,allowClear:m,readonly:h,hidden:g,prefixCls:_,prefix:v=o.prefix?.(),suffix:y=o.suffix?.(),addonAfter:b=o.addonAfter,addonBefore:x=o.addonBefore,inputElement:S,affixWrapperClassName:C,wrapperClassName:w,groupClassName:T}=n,E=t(S,{value:f,hidden:g});if(i({prefix:v,suffix:y,allowClear:m})){let n=`${_}-affix-wrapper`,i=e(n,{[`${n}-disabled`]:p,[`${n}-focused`]:s,[`${n}-readonly`]:h,[`${n}-input-with-clear-btn`]:y&&m&&f},!r({addonAfter:b,addonBefore:x})&&c.class,C),o=(y||m)&&a(`span`,{class:`${_}-suffix`},[d(),y]);E=a(`span`,{class:i,style:c.style,hidden:!r({addonAfter:b,addonBefore:x})&&g,onMousedown:u,ref:l},[v&&a(`span`,{class:`${_}-prefix`},[v]),t(S,{style:null,value:f,hidden:null}),o])}if(r({addonAfter:b,addonBefore:x})){let n=`${_}-group`,r=`${n}-addon`,i=e(`${_}-wrapper`,n,w);return a(`span`,{class:e(`${_}-group-wrapper`,c.class,T),style:c.style,hidden:g},[a(`span`,{class:i},[x&&a(`span`,{class:r},[x]),t(E,{style:null,hidden:null}),b&&a(`span`,{class:r},[b])])])}return E}}});export{c as default};