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