import { computed } from 'vue';
import { isEmpty } from 'lodash-es';
import '../../../utils/index.mjs';
import '../../../hooks/index.mjs';
import { createContext } from '../../../hooks/create-context/index.mjs';
import { classNames } from '../../../utils/dom/class.mjs';

const SpaceCompactItemContext = createContext(null);
function useCompactItemContext(prefixCls, direction) {
  const compactItemContext = SpaceCompactItemContext.useInject();
  const compactItemClassnames = computed(() => {
    if (!compactItemContext || isEmpty(compactItemContext))
      return "";
    const { compactDirection, isFirstItem, isLastItem } = compactItemContext;
    const separator = compactDirection === "vertical" ? "-vertical-" : "-";
    return classNames({
      [`${prefixCls.value}-compact${separator}item`]: true,
      [`${prefixCls.value}-compact${separator}first-item`]: isFirstItem,
      [`${prefixCls.value}-compact${separator}last-item`]: isLastItem,
      [`${prefixCls.value}-compact${separator}item-rtl`]: direction.value === "rtl"
    });
  });
  return {
    compactSize: computed(() => compactItemContext == null ? void 0 : compactItemContext.compactSize),
    compactDirection: computed(() => compactItemContext == null ? void 0 : compactItemContext.compactDirection),
    compactItemClassnames
  };
}

export { SpaceCompactItemContext, useCompactItemContext };
//# sourceMappingURL=context.mjs.map
