import React from 'react';
import { Badge } from 'antd';
/**
 * BadgeWrapper 角标包装组件
 * 负责角标的渲染和定位，支持红点、数字、文本三种类型
 *
 * @example
 * ```tsx
 * // 红点角标
 * <BadgeWrapper badge={{ type: 'dot' }}>
 *   <TextCard text="Item" />
 * </BadgeWrapper>
 *
 * // 数字角标
 * <BadgeWrapper badge={{ type: 'number', content: 99 }}>
 *   <TextCard text="Item" />
 * </BadgeWrapper>
 *
 * // 文本角标
 * <BadgeWrapper badge={{ type: 'text', content: 'New' }}>
 *   <TextCard text="Item" />
 * </BadgeWrapper>
 * ```
 */
var BadgeWrapper = function BadgeWrapper(props) {
  var badge = props.badge,
    children = props.children;

  // 如果没有角标配置，直接返回子元素
  if (!badge) {
    return /*#__PURE__*/React.createElement(React.Fragment, null, children);
  }
  var _badge$type = badge.type,
    type = _badge$type === void 0 ? 'dot' : _badge$type,
    content = badge.content,
    _badge$position = badge.position,
    position = _badge$position === void 0 ? 'top-right' : _badge$position,
    offset = badge.offset,
    color = badge.color,
    style = badge.style;

  /**
   * 根据角标类型渲染不同的 Badge
   */
  var renderBadge = function renderBadge() {
    // 红点类型
    if (type === 'dot') {
      return /*#__PURE__*/React.createElement(Badge, {
        dot: true,
        color: color,
        offset: offset,
        style: style
      }, children);
    }

    // 数字或文本类型
    if (type === 'number' || type === 'text') {
      return /*#__PURE__*/React.createElement(Badge, {
        count: content,
        color: color,
        offset: offset,
        style: style,
        showZero: type === 'number'
      }, children);
    }
    return /*#__PURE__*/React.createElement(React.Fragment, null, children);
  };
  return renderBadge();
};
export default BadgeWrapper;