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