const e=require("../_util/warning.js"),t=require("../_util/classNames.js"),n=require("../_util/omit.js"),r=require("../_util/props-util/index.js"),i=require("../config-provider/hooks/useConfigInject.js"),a=require("../_util/vue-types/index.js"),o=require("../_util/statusUtils.js"),s=require("../form/FormItemContext.js"),c=require("../menu/src/OverrideContext.js"),l=require("../spin/index.js"),u=require("../vc-mentions/src/mentionsProps.js"),d=require("../vc-mentions/src/Option.js"),f=require("../vc-mentions/index.js"),p=require("./style/index.js");let m=require("vue");function h(){return!0}var g=(e=``,t={})=>{let{prefix:n=`@`,split:r=` `}=t,i=Array.isArray(n)?n:[n];return e.split(r).map((e=``)=>{let t=null;return i.some(n=>e.slice(0,n.length)===n?(t=n,!0):!1),t===null?null:{prefix:t,value:e.slice(t.length)}}).filter(e=>!!e&&!!e.value)},_=()=>({...u.mentionsProps,loading:{type:Boolean,default:void 0},onFocus:{type:Function},onBlur:{type:Function},onSelect:{type:Function},onChange:{type:Function},onPressenter:{type:Function},"onUpdate:value":{type:Function},notFoundContent:a.default.any,defaultValue:String,id:String,status:String}),v=(0,m.defineComponent)({compatConfig:{MODE:3},name:`AMentions`,inheritAttrs:!1,props:_(),slots:Object,setup(a,{slots:u,emit:d,attrs:g,expose:_}){let{prefixCls:v,renderEmpty:y,direction:b}=i.default(`mentions`,a),[x,S]=p.default(v),C=(0,m.shallowRef)(!1),w=(0,m.shallowRef)(null),T=(0,m.shallowRef)(a.value??a.defaultValue??``),E=s.useInjectFormItemContext(),D=s.FormItemInputContext.useInject(),O=(0,m.computed)(()=>o.getMergedStatus(D.status,a.status));c.useProvideOverride({prefixCls:(0,m.computed)(()=>`${v.value}-menu`),mode:(0,m.computed)(()=>`vertical`),selectable:(0,m.computed)(()=>!1),onClick:()=>{},validator:({mode:t})=>{e.default(!t||t===`vertical`,`Mentions`,`mode="${t}" is not supported for Mentions's Menu.`)}}),(0,m.watch)(()=>a.value,e=>{T.value=e});let k=e=>{C.value=!0,d(`focus`,e)},A=e=>{C.value=!1,d(`blur`,e),E.onFieldBlur()},j=(...e)=>{d(`select`,...e),C.value=!0},M=e=>{a.value===void 0&&(T.value=e),d(`update:value`,e),d(`change`,e),E.onFieldChange()},N=()=>{let e=a.notFoundContent;return e===void 0?u.notFoundContent?u.notFoundContent():y(`Select`):e},P=()=>r.flattenChildren(u.default?.()||[]).map(e=>({...r.getOptionProps(e),label:e.children?.default?.()}));_({focus:()=>{w.value.focus()},blur:()=>{w.value.blur()}});let F=(0,m.computed)(()=>a.loading?h:a.filterOption);return()=>{let{disabled:e,getPopupContainer:r,rows:i=1,id:s=E.id.value,...c}=a,{hasFeedback:d,feedbackIcon:p}=D,{class:h,..._}=g,y=n.default(c,[`defaultValue`,`onUpdate:value`,`prefixCls`]),I=t.default({[`${v.value}-disabled`]:e,[`${v.value}-focused`]:C.value,[`${v.value}-rtl`]:b.value===`rtl`},o.getStatusClassNames(v.value,O.value),!d&&h,S.value),L=(0,m.createVNode)(f.default,{prefixCls:v.value,...y,disabled:e,direction:b.value,filterOption:F.value,getPopupContainer:r,options:a.loading?[{value:`ANTDV_SEARCHING`,disabled:!0,label:(0,m.createVNode)(l.default,{size:`small`},null)}]:a.options||P(),class:I,..._,rows:i,onChange:M,onSelect:j,onFocus:k,onBlur:A,ref:w,value:T.value,id:s,dropdownClassName:S.value},{notFoundContent:N,option:u.option});return x(d?(0,m.createVNode)(`div`,{class:t.default(`${v.value}-affix-wrapper`,o.getStatusClassNames(`${v.value}-affix-wrapper`,O.value,d),h,S.value)},[L,(0,m.createVNode)(`span`,{class:`${v.value}-suffix`},[p])]):L)}}}),y=(0,m.defineComponent)({compatConfig:{MODE:3},...d.optionOptions,name:`AMentionsOption`,props:d.optionProps}),b=Object.assign(v,{Option:y,getMentions:g,install:e=>(e.component(v.name,v),e.component(y.name,y),e)});exports.MentionsOption=y,exports.default=b,exports.mentionsProps=_;