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