'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var lodashEs = require('lodash-es');
require('../../../utils/index.cjs');
var useConfigInject = require('../../config-provider/src/hooks/useConfigInject.cjs');
var index = require('../style/index.cjs');
var Item = require('./Item.cjs');
var props = require('./props.cjs');
var context = require('./context.cjs');
var _class = require('../../../utils/dom/class.cjs');
var props$1 = require('../../../utils/vue/props.cjs');

var ACompact = /* @__PURE__ */ vue.defineComponent({
  name: "ASpaceCompact",
  inheritAttrs: false,
  props: props.spaceCompactProps(),
  setup(props, {
    attrs,
    slots
  }) {
    const {
      prefixCls,
      direction: directionConfig
    } = useConfigInject.default("space-compact", props);
    const compactItemContext = context.SpaceCompactItemContext.useInject();
    const [wrapSSR, hashId] = index.default(prefixCls);
    const clx = vue.computed(() => {
      return _class.classNames(prefixCls.value, hashId.value, {
        [`${prefixCls.value}-rtl`]: directionConfig.value === "rtl",
        [`${prefixCls.value}-block`]: props.block,
        [`${prefixCls.value}-vertical`]: props.direction === "vertical"
      });
    });
    return () => {
      var _a;
      const childNodes = props$1.flattenChildren(((_a = slots.default) == null ? void 0 : _a.call(slots)) || []);
      if (childNodes.length === 0)
        return null;
      return wrapSSR(vue.createVNode("div", {
        ...attrs,
        "class": [clx.value, attrs.class]
      }, [childNodes.map((child, i) => {
        var _a2;
        const key = child && child.key || `${prefixCls.value}-item-${i}`;
        const noCompactItemContext = !compactItemContext || lodashEs.isEmpty(compactItemContext);
        return vue.createVNode(Item.default, {
          "key": key,
          "compactSize": (_a2 = props.size) != null ? _a2 : "middle",
          "compactDirection": props.direction,
          "isFirstItem": i === 0 && (noCompactItemContext || (compactItemContext == null ? void 0 : compactItemContext.isFirstItem)),
          "isLastItem": i === childNodes.length - 1 && (noCompactItemContext || (compactItemContext == null ? void 0 : compactItemContext.isLastItem))
        }, {
          default: () => [child]
        });
      })]));
    };
  }
});

exports.default = ACompact;
//# sourceMappingURL=Compact.cjs.map
