import e from"../../_util/vue-types/index.mjs";import t from"../../vc-tree-select/LegacyContext.mjs";import n from"../../_util/pickAttrs.mjs";import r from"./Input.mjs";import{Fragment as i,computed as a,createVNode as o,defineComponent as s,shallowRef as c,watch as l}from"vue";var u={inputElement:e.any,id:String,prefixCls:String,values:e.array,open:{type:Boolean,default:void 0},searchValue:String,inputRef:e.any,placeholder:e.any,compositionStatus:{type:Boolean,default:void 0},disabled:{type:Boolean,default:void 0},mode:String,showSearch:{type:Boolean,default:void 0},autofocus:{type:Boolean,default:void 0},autocomplete:String,activeDescendantId:String,tabindex:e.oneOfType([e.number,e.string]),activeValue:String,backfill:{type:Boolean,default:void 0},optionLabelRender:Function,onInputChange:Function,onInputPaste:Function,onInputKeyDown:Function,onInputMouseDown:Function,onInputCompositionStart:Function,onInputCompositionEnd:Function},d=s({name:`SingleSelector`,setup(e){let s=c(!1),u=a(()=>e.mode===`combobox`),d=a(()=>u.value||e.showSearch),f=a(()=>{let t=e.searchValue||``;return u.value&&e.activeValue&&!s.value&&(t=e.activeValue),t}),p=t();l([u,()=>e.activeValue],()=>{u.value&&(s.value=!1)},{immediate:!0});let m=a(()=>e.mode!==`combobox`&&!e.open&&!e.showSearch?!1:!!f.value||e.compositionStatus),h=a(()=>{let t=e.values[0];return t&&(typeof t.label==`string`||typeof t.label==`number`)?t.label.toString():void 0}),g=()=>{if(e.values[0])return null;let t=m.value?{visibility:`hidden`}:void 0;return o(`span`,{class:`${e.prefixCls}-selection-placeholder`,style:t},[e.placeholder])},_=t=>{t.target.composing||(s.value=!0,e.onInputChange(t))};return()=>{let{inputElement:t,prefixCls:a,id:s,values:c,inputRef:l,disabled:v,autofocus:y,autocomplete:b,activeDescendantId:x,open:S,tabindex:C,optionLabelRender:w,onInputKeyDown:T,onInputMouseDown:E,onInputPaste:D,onInputCompositionStart:O,onInputCompositionEnd:k}=e,A=c[0],j=null;if(A&&p.customSlots){let e=A.key??A.value,t=p.keyEntities[e]?.node||{};j=p.customSlots[t.slots?.title]||p.customSlots.title||A.label,typeof j==`function`&&(j=j(t))}else j=w&&A?w(A.option):A?.label;return o(i,null,[o(`span`,{class:`${a}-selection-search`},[o(r,{inputRef:l,prefixCls:a,id:s,open:S,inputElement:t,disabled:v,autofocus:y,autocomplete:b,editable:d.value,activeDescendantId:x,value:f.value,onKeydown:T,onMousedown:E,onChange:_,onPaste:D,onCompositionstart:O,onCompositionend:k,tabindex:C,attrs:n(e,!0)},null)]),!u.value&&A&&!m.value&&o(`span`,{class:`${a}-selection-item`,title:h.value},[o(i,{key:A.key??A.value},[j])]),g()])}}});d.props=u,d.inheritAttrs=!1;export{d as default};