import e from"../_util/warning.mjs";import t from"../_util/omit.mjs";import{flattenChildren as n,isValidElement as r}from"../_util/props-util/index.mjs";import i from"../config-provider/hooks/useConfigInject.mjs";import a,{selectProps as o}from"../select/index.mjs";import s from"./OptGroup.mjs";import c from"./Option.mjs";import{createVNode as l,defineComponent as u,ref as d}from"vue";function f(e){return e?.type?.isSelectOption||e?.type?.isSelectOptGroup}var p=()=>({...t(o(),[`loading`,`mode`,`optionLabelProp`,`labelInValue`]),dataSource:Array,dropdownMenuStyle:{type:Object,default:void 0},dropdownMatchSelectWidth:{type:[Number,Boolean],default:!0},prefixCls:String,showSearch:{type:Boolean,default:void 0},transitionName:String,choiceTransitionName:{type:String,default:`zoom`},autofocus:{type:Boolean,default:void 0},backfill:{type:Boolean,default:void 0},filterOption:{type:[Boolean,Function],default:!1},defaultActiveFirstOption:{type:Boolean,default:!0},status:String}),m=c,h=s,g=u({compatConfig:{MODE:3},name:`AAutoComplete`,inheritAttrs:!1,props:p(),slots:Object,setup(o,{slots:s,attrs:u,expose:p}){e(!(`dataSource`in s),`AutoComplete`,"`dataSource` slot is deprecated, please use props `options` instead."),e(!(`options`in s),`AutoComplete`,"`options` slot is deprecated, please use props `options` instead."),e(!o.dropdownClassName,`AutoComplete`,"`dropdownClassName` is deprecated, please use `popupClassName` instead.");let m=d(),h=()=>{let e=n(s.default?.());return e.length?e[0]:void 0};p({focus:()=>{m.value?.focus()},blur:()=>{m.value?.blur()}});let{prefixCls:g}=i(`select`,o);return()=>{let{size:e,dataSource:n,notFoundContent:i=s.notFoundContent?.()}=o,d,{class:p}=u,_={[p]:!!p,[`${g.value}-lg`]:e===`large`,[`${g.value}-sm`]:e===`small`,[`${g.value}-show-search`]:!0,[`${g.value}-auto-complete`]:!0};if(o.options===void 0){let e=s.dataSource?.()||s.options?.()||[];d=e.length&&f(e[0])?e:n?n.map(e=>{if(r(e))return e;switch(typeof e){case`string`:return l(c,{key:e,value:e},{default:()=>[e]});case`object`:return l(c,{key:e.value,value:e.value},{default:()=>[e.text]});default:throw Error("AutoComplete[dataSource] only supports type `string[] | Object[]`.")}}):[]}return l(a,t({...o,...u,mode:a.SECRET_COMBOBOX_MODE_DO_NOT_USE,getInputElement:h,notFoundContent:i,class:_,popupClassName:o.popupClassName||o.dropdownClassName,ref:m},[`dataSource`,`loading`]),{default:()=>[d],...t(s,[`default`,`dataSource`,`options`])})}}}),_=Object.assign(g,{Option:c,OptGroup:s,install(e){return e.component(g.name,g),e.component(c.displayName,c),e.component(s.displayName,s),e}});export{h as AutoCompleteOptGroup,m as AutoCompleteOption,p as autoCompleteProps,_ as default};