import{defineComponent as P,computed as l,ref as b,watch as R,createVNode as c,Fragment as T}from"vue";import V from"../_util/classNames.mjs";import k from"../_util/hooks/useFlexGapSupport.mjs";import{filterEmpty as L}from"../_util/props-util/index.mjs";import{booleanType as M,tuple as N}from"../_util/type.mjs";import O from"../_util/vue-types/index.mjs";import W from"../config-provider/hooks/useConfigInject.mjs";import g from"./Compact.mjs";import q from"./style/index.mjs";const H={small:8,middle:16,large:24},J=()=>({prefixCls:String,size:{type:[String,Number,Array]},direction:O.oneOf(N("horizontal","vertical")).def("horizontal"),align:O.oneOf(N("start","end","center","baseline")),wrap:M()});function K(e){return typeof e=="string"?H[e]:e||0}const m=P({compatConfig:{MODE:3},name:"ASpace",inheritAttrs:!1,props:J(),slots:Object,setup(e,{slots:d,attrs:u}){const{prefixCls:a,space:G,direction:y}=W("space",e),[I,B]=q(a),$=k(),n=l(()=>e.size??G?.value?.size??"small"),p=b(),r=b();R(n,()=>{[p.value,r.value]=(Array.isArray(n.value)?n.value:[n.value,n.value]).map(t=>K(t))},{immediate:!0});const S=l(()=>e.align===void 0&&e.direction==="horizontal"?"center":e.align),F=l(()=>V(a.value,B.value,`${a.value}-${e.direction}`,{[`${a.value}-rtl`]:y.value==="rtl",[`${a.value}-align-${S.value}`]:S.value})),j=l(()=>y.value==="rtl"?"marginLeft":"marginRight"),D=l(()=>{const t={};return $.value&&(t.columnGap=`${p.value}px`,t.rowGap=`${r.value}px`),{...t,...e.wrap&&{flexWrap:"wrap",marginBottom:`${-r.value}px`}}});return()=>{const{wrap:t,direction:E="horizontal"}=e,z=d.default?.(),h=L(z),x=h.length;if(x===0)return null;const o=d.split?.(),C=`${a.value}-item`,w=p.value,f=x-1;return c("div",{...u,class:[F.value,u.class],style:[D.value,u.style]},[h.map((A,i)=>{let v=z.indexOf(A);v===-1&&(v=`$$space-${i}`);let s={};return $.value||(E==="vertical"?i<f&&(s={marginBottom:`${w/(o?2:1)}px`}):s={...i<f&&{[j.value]:`${w/(o?2:1)}px`},...t&&{paddingBottom:`${r.value}px`}}),I(c(T,{key:v},[c("div",{class:C,style:s},[A]),i<f&&o&&c("span",{class:`${C}-split`,style:s},[o])]))})])}}});m.Compact=g;m.install=function(e){return e.component(m.name,m),e.component(g.name,g),e};export{g as Compact,m as default,J as spaceProps};
