import{defineComponent as X,computed as i,ref as Y,createVNode as m}from"vue";import{LeftOutlined as Z,RightOutlined as ee,LoadingOutlined as te}from"@antsoo-lib/icons";import oe from"../_util/classNames.mjs";import ae from"../_util/omit.mjs";import ne from"../_util/props-util/initDefaultProps.mjs";import{getMergedStatus as re,getStatusClassNames as le}from"../_util/statusUtils.mjs";import{getTransitionName as x,getTransitionDirection as se}from"../_util/transition.mjs";import{withInstall as ce}from"../_util/type.mjs";import ie from"../_util/vue-types/index.mjs";import{useInjectDisabled as ue}from"../config-provider/DisabledContext.mjs";import de from"../config-provider/hooks/useConfigInject.mjs";import"../form/index.mjs";import{useInjectFormItemContext as me,FormItemInputContext as fe}from"../form/FormItemContext.mjs";import pe from"../select/style/index.mjs";import he from"../select/utils/iconUtil.mjs";import{useCompactItemContext as ge}from"../space/Compact.mjs";import ve,{internalCascaderProps as Ce}from"../vc-cascader/Cascader.mjs";import we from"./style/index.mjs";import{SHOW_PARENT as Ie,SHOW_CHILD as Se}from"../vc-cascader/utils/commonUtil.mjs";function be(e,d,f){const o=e.toLowerCase().split(d).reduce((a,u,t)=>t===0?[u]:[...a,d,u],[]),r=[];let s=0;return o.forEach((a,u)=>{const t=s+a.length;let c=e.slice(s,t);s=t,u%2===1&&(c=m("span",{class:`${f}-menu-item-keyword`,key:"seperator"},[c])),r.push(c)}),r}const xe=({inputValue:e,path:d,prefixCls:f,fieldNames:o})=>{const r=[],s=e.toLowerCase();return d.forEach((a,u)=>{u!==0&&r.push(" / ");let t=a[o.label];const c=typeof t;(c==="string"||c==="number")&&(t=be(String(t),s,f)),r.push(t)}),r};function ye(){return{...ae(Ce(),["customSlots","checkable","options"]),multiple:{type:Boolean,default:void 0},size:String,bordered:{type:Boolean,default:void 0},placement:{type:String},suffixIcon:ie.any,status:String,options:Array,popupClassName:String,dropdownClassName:String,"onUpdate:value":Function}}const Ne=X({compatConfig:{MODE:3},name:"ACascader",inheritAttrs:!1,props:ne(ye(),{bordered:!0,choiceTransitionName:"",allowClear:!0}),setup(e,{attrs:d,expose:f,slots:o,emit:r}){const s=me(),a=fe.useInject(),u=i(()=>re(a.status,e.status)),{prefixCls:t,rootPrefixCls:c,getPrefixCls:y,direction:p,getPopupContainer:N,renderEmpty:P,size:F,disabled:R}=de("cascader",e),n=i(()=>y("select",e.prefixCls)),{compactSize:k,compactItemClassnames:$}=ge(n,p),v=i(()=>k.value||F.value),A=ue(),T=i(()=>R.value??A.value),[D,C]=pe(n),[L]=we(t),h=i(()=>p.value==="rtl"),O=i(()=>{if(!e.showSearch)return e.showSearch;let l={render:xe};return typeof e.showSearch=="object"&&(l={...l,...e.showSearch}),l}),j=i(()=>oe(e.popupClassName||e.dropdownClassName,`${t.value}-dropdown`,{[`${t.value}-dropdown-rtl`]:h.value},C.value)),g=Y();f({focus(){g.value?.focus()},blur(){g.value?.blur()}});const E=(...l)=>{r("update:value",l[0]),r("change",...l),s.onFieldChange()},z=(...l)=>{r("blur",...l),s.onFieldBlur()},B=i(()=>e.showArrow!==void 0?e.showArrow:e.loading||!e.multiple),w=i(()=>e.placement!==void 0?e.placement:p.value==="rtl"?"bottomRight":"bottomLeft");return()=>{const{notFoundContent:l=o.notFoundContent?.(),expandIcon:I=o.expandIcon?.(),multiple:S,bordered:H,allowClear:W,choiceTransitionName:M,transitionName:_,id:U=s.id.value,...V}=e,q=l||P("Cascader");let b=I;I||(b=h.value?m(Z,null,null):m(ee,null,null));const G=m("span",{class:`${n.value}-menu-item-loading-icon`},[m(te,{spin:!0},null)]),{suffixIcon:J,removeIcon:K,clearIcon:Q}=he({...e,hasFeedback:a.hasFeedback,feedbackIcon:a.feedbackIcon,multiple:S,prefixCls:n.value,showArrow:B.value},o);return L(D(m(ve,{...V,...d,id:U,prefixCls:n.value,class:[t.value,{[`${n.value}-lg`]:v.value==="large",[`${n.value}-sm`]:v.value==="small",[`${n.value}-rtl`]:h.value,[`${n.value}-borderless`]:!H,[`${n.value}-in-form-item`]:a.isFormItemInput},le(n.value,u.value,a.hasFeedback),$.value,d.class,C.value],disabled:T.value,direction:p.value,placement:w.value,notFoundContent:q,allowClear:W,showSearch:O.value,expandIcon:b,inputIcon:J,removeIcon:K,clearIcon:Q,loadingIcon:G,checkable:!!S,dropdownClassName:j.value,dropdownPrefixCls:t.value,choiceTransitionName:x(c.value,"",M),transitionName:x(c.value,se(w.value),_),getPopupContainer:N?.value,customSlots:{...o,checkable:()=>m("span",{class:`${t.value}-checkbox-inner`},null)},tagRender:e.tagRender||o.tagRender,displayRender:e.displayRender||o.displayRender,maxTagPlaceholder:e.maxTagPlaceholder||o.maxTagPlaceholder,showArrow:a.hasFeedback||e.showArrow,onChange:E,onBlur:z,ref:g},o)))}}}),Ve=ce(Object.assign(Ne,{SHOW_CHILD:Se,SHOW_PARENT:Ie}));export{ye as cascaderProps,Ve as default};
