const e=require("../../_util/vue-types/index.js"),t=require("../../_util/KeyCode.js"),n=require("../../_util/createRef.js"),r=require("../hooks/useLock.js"),i=require("../utils/keyUtil.js"),a=require("./MultipleSelector.js"),o=require("./SingleSelector.js");let s=require("vue");var c=(0,s.defineComponent)({name:`Selector`,inheritAttrs:!1,props:{id:String,prefixCls:String,showSearch:{type:Boolean,default:void 0},open:{type:Boolean,default:void 0},values:e.default.array,multiple:{type:Boolean,default:void 0},mode:String,searchValue:String,activeValue:String,inputElement:e.default.any,autofocus:{type:Boolean,default:void 0},activeDescendantId:String,tabindex:e.default.oneOfType([e.default.number,e.default.string]),disabled:{type:Boolean,default:void 0},placeholder:e.default.any,removeIcon:e.default.any,maxTagCount:e.default.oneOfType([e.default.number,e.default.string]),maxTagTextLength:Number,maxTagPlaceholder:e.default.any,tagRender:Function,optionLabelRender:Function,tokenWithEnter:{type:Boolean,default:void 0},choiceTransitionName:String,onToggleOpen:{type:Function},onSearch:Function,onSearchSubmit:Function,onRemove:Function,onInputKeyDown:{type:Function},domRef:Function},setup(e,{expose:c}){let l=n.default(),u=(0,s.ref)(!1),[d,f]=r.default(0),p=n=>{let{which:r}=n;(r===t.default.UP||r===t.default.DOWN)&&n.preventDefault(),e.onInputKeyDown&&e.onInputKeyDown(n),r===t.default.ENTER&&e.mode===`tags`&&!u.value&&!e.open&&e.onSearchSubmit(n.target.value),i.isValidateOpenKey(r)&&e.onToggleOpen(!0)},m=()=>{f(!0)},h=null,g=t=>{e.onSearch(t,!0,u.value)!==!1&&e.onToggleOpen(!0)},_=()=>{u.value=!0},v=t=>{u.value=!1,e.mode!==`combobox`&&g(t.target.value)},y=t=>{let{target:{value:n}}=t;if(e.tokenWithEnter&&h&&/[\r\n]/.test(h)){let e=h.replace(/[\r\n]+$/,``).replace(/\r\n/g,` `).replace(/[\r\n]/g,` `);n=n.replace(e,h)}h=null,g(n)},b=e=>{let{clipboardData:t}=e;h=t.getData(`text`)},x=({target:e})=>{e!==l.current&&(document.body.style.msTouchAction===void 0?l.current.focus():setTimeout(()=>{l.current.focus()}))},S=t=>{let n=d();t.target!==l.current&&!n&&t.preventDefault(),(e.mode!==`combobox`&&(!e.showSearch||!n)||!e.open)&&(e.open&&e.onSearch(``,!0,!1),e.onToggleOpen())};return c({focus:()=>{l.current.focus()},blur:()=>{l.current.blur()}}),()=>{let{prefixCls:t,domRef:n,mode:r}=e,i={inputRef:l,onInputKeyDown:p,onInputMouseDown:m,onInputChange:y,onInputPaste:b,compositionStatus:u.value,onInputCompositionStart:_,onInputCompositionEnd:v},c=r===`multiple`||r===`tags`?(0,s.createVNode)(a.default,{...e,...i},null):(0,s.createVNode)(o.default,{...e,...i},null);return(0,s.createVNode)(`div`,{ref:n,class:`${t}-selector`,onClick:x,onMousedown:S},[c])}}});exports.default=c;