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