"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _vue = _interopRequireWildcard(require("vue"));

var _propsUtil = require("../_util/props-util");

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var Col = function Col(_, _ref) {
  var _ref2;

  var attrs = _ref.attrs;
  var _attrs$child = attrs.child,
      child = _attrs$child === void 0 ? {} : _attrs$child,
      bordered = attrs.bordered,
      colon = attrs.colon,
      type = attrs.type,
      layout = attrs.layout,
      key = attrs.colKey;

  var _getOptionProps = (0, _propsUtil.getOptionProps)(child),
      prefixCls = _getOptionProps.prefixCls,
      _getOptionProps$span = _getOptionProps.span,
      span = _getOptionProps$span === void 0 ? 1 : _getOptionProps$span;

  var _child$children = child.children,
      children = _child$children === void 0 ? {} : _child$children,
      _child$props = child.props,
      props = _child$props === void 0 ? {} : _child$props;
  var label = props.label || children.label && children.label();
  var defaultSlot = children.default && children.default();
  var labelProps = {
    class: ["".concat(prefixCls, "-item-label"), (_ref2 = {}, _defineProperty(_ref2, "".concat(prefixCls, "-item-colon"), colon), _defineProperty(_ref2, "".concat(prefixCls, "-item-no-label"), !label), _ref2)],
    key: "".concat(key, "-label")
  };

  if (layout === 'vertical') {
    labelProps.colspan = span * 2 - 1;
  }

  if (bordered) {
    if (type === 'label') {
      return _vue.createVNode("th", labelProps, [label]);
    }

    return _vue.createVNode("td", {
      "class": "".concat(prefixCls, "-item-content"),
      "key": "".concat(key, "-content"),
      "colspan": span * 2 - 1
    }, [defaultSlot]);
  }

  if (layout === 'vertical') {
    if (type === 'content') {
      return _vue.createVNode("td", {
        "colspan": span,
        "class": "".concat(prefixCls, "-item")
      }, [_vue.createVNode("span", {
        "class": "".concat(prefixCls, "-item-content"),
        "key": "".concat(key, "-content")
      }, [defaultSlot])]);
    }

    return _vue.createVNode("td", {
      "colspan": span,
      "class": "".concat(prefixCls, "-item")
    }, [_vue.createVNode("span", {
      "class": ["".concat(prefixCls, "-item-label"), _defineProperty({}, "".concat(prefixCls, "-item-colon"), colon)],
      "key": "".concat(key, "-label")
    }, [label])]);
  }

  return _vue.createVNode("td", {
    "colspan": span,
    "class": "".concat(prefixCls, "-item")
  }, [_vue.createVNode("span", labelProps, [label]), _vue.createVNode("span", {
    "class": "".concat(prefixCls, "-item-content"),
    "key": "".concat(key, "-content")
  }, [defaultSlot])]);
};

var _default = Col;
exports.default = _default;