{"version":3,"file":"Badge.mjs","names":[],"sources":["../../../src/base-ui/Badge/Badge.tsx"],"sourcesContent":["'use client';\n\nimport { cx } from 'antd-style';\nimport { memo, type ReactNode } from 'react';\n\nimport { pillSize, statusColor, styles } from './style';\nimport type { BadgeProps } from './type';\n\nconst Badge = memo<BadgeProps>(\n  ({\n    children,\n    className,\n    color,\n    count,\n    dot = false,\n    offset,\n    overflowCount = 99,\n    ref,\n    showZero = false,\n    size = 'default',\n    status,\n    style,\n    text,\n    ...rest\n  }) => {\n    const isStatusMode = children == null && (status !== undefined || text !== undefined);\n\n    if (isStatusMode) {\n      const dotColor = color ?? statusColor[status ?? 'default'];\n\n      return (\n        <span className={cx(styles.statusRoot, className)} ref={ref} style={style} {...rest}>\n          <span\n            className={cx(styles.statusDot, status === 'processing' && styles.statusDotProcessing)}\n            style={{ background: dotColor, color: dotColor }}\n          />\n          {text && <span className={styles.statusText}>{text}</span>}\n        </span>\n      );\n    }\n\n    let content: ReactNode = null;\n    let renderPill = dot;\n\n    if (!dot) {\n      if (typeof count === 'number') {\n        if (count !== 0 || showZero) {\n          renderPill = true;\n          content = count > overflowCount ? `${overflowCount}+` : count;\n        }\n      } else if (count != null) {\n        renderPill = true;\n        content = count;\n      }\n    }\n\n    const pillStyle = {\n      background: color,\n      transform: offset ? `translate(${offset[0]}px, ${offset[1]}px)` : undefined,\n    };\n\n    if (children == null) {\n      if (!renderPill) return null;\n\n      return (\n        <span\n          className={cx(pillSize({ size }), dot && styles.pillDot, className)}\n          ref={ref}\n          style={{ ...pillStyle, ...style }}\n          {...rest}\n        >\n          {!dot && content}\n        </span>\n      );\n    }\n\n    return (\n      <span className={cx(styles.wrapper, className)} ref={ref} style={style} {...rest}>\n        {children}\n        {renderPill && (\n          <span\n            className={cx(pillSize({ size }), styles.pillAbsolute, dot && styles.pillDot)}\n            style={pillStyle}\n          >\n            {!dot && content}\n          </span>\n        )}\n      </span>\n    );\n  },\n);\n\nBadge.displayName = 'Badge';\n\nexport default Badge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