import { createVNode, Fragment } from 'vue';
import '../../../utils/index.mjs';
import Cell from './Cell.mjs';
import { useProviderContext } from './useContext.mjs';
import { getSlot, getClass, getStyle } from '../../../utils/vue/props.mjs';

const Row = (props) => {
  const renderCells = (items, {
    colon,
    prefixCls: prefixCls2,
    bordered: bordered2
  }, {
    component,
    type,
    showLabel,
    showContent,
    labelStyle: rootLabelStyle,
    contentStyle: rootContentStyle
  }) => {
    return items.map((item, index2) => {
      var _a, _b;
      const itemProps = item.props || {};
      const {
        prefixCls: itemPrefixCls = prefixCls2,
        span = 1,
        labelStyle: labelStyle2 = itemProps["label-style"],
        contentStyle: contentStyle2 = itemProps["content-style"],
        label = (_b = (_a = item.children) == null ? void 0 : _a.label) == null ? void 0 : _b.call(_a)
      } = itemProps;
      const children = getSlot(item);
      const className = getClass(item);
      const style = getStyle(item);
      const {
        key
      } = item;
      if (typeof component === "string") {
        return createVNode(Cell, {
          "key": `${type}-${String(key) || index2}`,
          "class": className,
          "style": style,
          "labelStyle": {
            ...rootLabelStyle,
            ...labelStyle2
          },
          "contentStyle": {
            ...rootContentStyle,
            ...contentStyle2
          },
          "span": span,
          "colon": colon,
          "component": component,
          "itemPrefixCls": itemPrefixCls,
          "bordered": bordered2,
          "label": showLabel ? label : null,
          "content": showContent ? children : null
        }, null);
      }
      return [createVNode(Cell, {
        "key": `label-${String(key) || index2}`,
        "class": className,
        "style": {
          ...rootLabelStyle,
          ...style,
          ...labelStyle2
        },
        "span": 1,
        "colon": colon,
        "component": component[0],
        "itemPrefixCls": itemPrefixCls,
        "bordered": bordered2,
        "label": label
      }, null), createVNode(Cell, {
        "key": `content-${String(key) || index2}`,
        "class": className,
        "style": {
          ...rootContentStyle,
          ...style,
          ...contentStyle2
        },
        "span": span * 2 - 1,
        "component": component[1],
        "itemPrefixCls": itemPrefixCls,
        "bordered": bordered2,
        "content": children
      }, null)];
    });
  };
  const {
    prefixCls,
    vertical,
    row,
    index,
    bordered
  } = props;
  const {
    labelStyle,
    contentStyle
  } = useProviderContext();
  if (vertical) {
    return createVNode(Fragment, null, [createVNode("tr", {
      "key": `label-${index}`,
      "class": `${prefixCls}-row`
    }, [renderCells(row, props, {
      component: "th",
      type: "label",
      showLabel: true,
      labelStyle: labelStyle.value,
      contentStyle: contentStyle.value
    })]), createVNode("tr", {
      "key": `content-${index}`,
      "class": `${prefixCls}-row`
    }, [renderCells(row, props, {
      component: "td",
      type: "content",
      showContent: true,
      labelStyle: labelStyle.value,
      contentStyle: contentStyle.value
    })])]);
  }
  return createVNode("tr", {
    "key": index,
    "class": `${prefixCls}-row`
  }, [renderCells(row, props, {
    component: bordered ? ["th", "td"] : "td",
    type: "item",
    showLabel: true,
    showContent: true,
    labelStyle: labelStyle.value,
    contentStyle: contentStyle.value
  })]);
};

export { Row as default };
//# sourceMappingURL=Row.mjs.map
