import{defineComponent as v,computed as n,createVNode as I}from"vue";import{isEmpty as $}from"lodash-es";import y from"../_util/classNames.mjs";import g from"../_util/createContext.mjs";import{flattenChildren as x}from"../_util/props-util/index.mjs";import{booleanType as S,tuple as f}from"../_util/type.mjs";import d from"../_util/vue-types/index.mjs";import k from"../config-provider/hooks/useConfigInject.mjs";import b from"./style/index.mjs";const D=()=>({compactSize:String,compactDirection:d.oneOf(f("horizontal","vertical")).def("horizontal"),isFirstItem:S(),isLastItem:S()}),i=g(null),R=(t,e)=>{const c=i.useInject(),o=n(()=>{if(!c||$(c))return"";const{compactDirection:m,isFirstItem:a,isLastItem:s}=c,r=m==="vertical"?"-vertical-":"-";return y({[`${t.value}-compact${r}item`]:!0,[`${t.value}-compact${r}first-item`]:a,[`${t.value}-compact${r}last-item`]:s,[`${t.value}-compact${r}item-rtl`]:e.value==="rtl"})});return{compactSize:n(()=>c?.compactSize),compactDirection:n(()=>c?.compactDirection),compactItemClassnames:o}},V=v({name:"NoCompactStyle",setup(t,{slots:e}){return i.useProvide(null),()=>e.default?.()}}),N=()=>({prefixCls:String,size:{type:String},direction:d.oneOf(f("horizontal","vertical")).def("horizontal"),align:d.oneOf(f("start","end","center","baseline")),block:{type:Boolean,default:void 0}}),P=v({name:"CompactItem",props:D(),setup(t,{slots:e}){return i.useProvide(t),()=>e.default?.()}}),_=v({name:"ASpaceCompact",inheritAttrs:!1,props:N(),setup(t,{attrs:e,slots:c}){const{prefixCls:o,direction:m}=k("space-compact",t),a=i.useInject(),[s,r]=b(o),z=n(()=>y(o.value,r.value,{[`${o.value}-rtl`]:m.value==="rtl",[`${o.value}-block`]:t.block,[`${o.value}-vertical`]:t.direction==="vertical"}));return()=>{const l=x(c.default?.()||[]);return l.length===0?null:s(I("div",{...e,class:[z.value,e.class]},[l.map((p,u)=>{const h=p&&p.key||`${o.value}-item-${u}`,C=!a||$(a);return I(P,{key:h,compactSize:t.size??"middle",compactDirection:t.direction,isFirstItem:u===0&&(C||a?.isFirstItem),isLastItem:u===l.length-1&&(C||a?.isLastItem)},{default:()=>[p]})})]))}}});export{V as NoCompactStyle,i as SpaceCompactItemContext,_ as default,D as spaceCompactItemProps,N as spaceCompactProps,R as useCompactItemContext};
