import e from"../_util/classNames.mjs";import t from"../_util/omit.mjs";import n from"../config-provider/hooks/useConfigInject.mjs";import r from"../_util/vue-types/index.mjs";import{cloneElement as i}from"../_util/vnode.mjs";import a from"../button/index.mjs";import o from"./inputProps.mjs";import s from"./Input.mjs";import{computed as c,createVNode as l,defineComponent as u,shallowRef as d}from"vue";import{SearchOutlined as f}from"@antsoo-lib/icons";import p from"lodash-es/isPlainObject";var m=u({compatConfig:{MODE:3},name:`AInputSearch`,inheritAttrs:!1,props:{...o(),inputPrefixCls:String,enterButton:r.any,onSearch:{type:Function}},setup(r,{slots:o,attrs:u,expose:m,emit:h}){let g=d(),_=d(!1);m({focus:()=>{g.value?.focus()},blur:()=>{g.value?.blur()}});let v=e=>{h(`update:value`,e.target.value),e&&e.target&&e.type===`click`&&h(`search`,e.target.value,e),h(`change`,e)},y=e=>{document.activeElement===g.value?.input&&e.preventDefault()},b=e=>{h(`search`,g.value?.input?.stateValue,e)},x=e=>{_.value||r.loading||b(e)},S=e=>{_.value=!0,h(`compositionstart`,e)},C=e=>{_.value=!1,h(`compositionend`,e)},{prefixCls:w,getPrefixCls:T,direction:E,size:D}=n(`input-search`,r),O=c(()=>T(`input`,r.inputPrefixCls));return()=>{let{disabled:n,loading:c,addonAfter:d=o.addonAfter?.(),suffix:m=o.suffix?.(),...h}=r,{enterButton:_=o.enterButton?.()??!1}=r;_=_||_===``;let T=typeof _==`boolean`?l(f,null,null):null,k=`${w.value}-button`,A=Array.isArray(_)?_[0]:_,j,M=A.type&&p(A.type)&&A.type.__ANT_BUTTON;if(M||A.tagName===`button`)j=i(A,{onMousedown:y,onClick:b,key:`enterButton`,...M?{class:k,size:D.value}:{}},!1);else{let e=T&&!_;j=l(a,{class:k,type:_?`primary`:void 0,size:D.value,disabled:n,key:`enterButton`,onMousedown:y,onClick:b,loading:c,icon:e?T:null},{default:()=>[e?null:T||_]})}d&&(j=[j,d]);let N=e(w.value,{[`${w.value}-rtl`]:E.value===`rtl`,[`${w.value}-${D.value}`]:!!D.value,[`${w.value}-with-button`]:!!_},u.class);return l(s,{ref:g,...t(h,[`onUpdate:value`,`onSearch`,`enterButton`]),...u,onPressEnter:x,onCompositionstart:S,onCompositionend:C,size:D.value,prefixCls:O.value,addonAfter:j,suffix:m,onChange:v,class:N,disabled:n},o)}}});export{m as default};