import{defineComponent as X,computed as c,ref as Y,createVNode as m}from"vue";import Z from"@ant-design/icons-vue/LeftOutlined";import ee from"@ant-design/icons-vue/LoadingOutlined";import te from"@ant-design/icons-vue/RightOutlined";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 ie}from"../_util/type.mjs";import ce 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 i=e.slice(s,t);s=t,u%2===1&&(i=m("span",{class:`${f}-menu-item-keyword`,key:"seperator"},[i])),r.push(i)}),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 i=typeof t;(i==="string"||i==="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:ce.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=c(()=>re(a.status,e.status)),{prefixCls:t,rootPrefixCls:i,getPrefixCls:y,direction:p,getPopupContainer:N,renderEmpty:P,size:F,disabled:R}=de("cascader",e),n=c(()=>y("select",e.prefixCls)),{compactSize:k,compactItemClassnames:$}=ge(n,p),v=c(()=>k.value||F.value),A=ue(),T=c(()=>R.value??A.value),[D,C]=pe(n),[L]=we(t),h=c(()=>p.value==="rtl"),O=c(()=>{if(!e.showSearch)return e.showSearch;let l={render:xe};return typeof e.showSearch=="object"&&(l={...l,...e.showSearch}),l}),j=c(()=>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=c(()=>e.showArrow!==void 0?e.showArrow:e.loading||!e.multiple),w=c(()=>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(te,null,null));const G=m("span",{class:`${n.value}-menu-item-loading-icon`},[m(ee,{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(i.value,"",M),transitionName:x(i.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)))}}}),Ge=ie(Object.assign(Ne,{SHOW_CHILD:Se,SHOW_PARENT:Ie}));export{ye as cascaderProps,Ge as default};
