import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef } from 'react';
import { GRADIENT_TEXT_CLASS } from '../../utils/constants.js';
import cls from 'classnames';
import { base as base$1 } from './variations/_view/base.js';
import { base as base$2 } from './variations/_size/base.js';
import { base as base$3 } from './variations/_pilled/base.js';
import { base as base$4 } from './variations/_transparent/base.js';
import { base as base$5 } from './variations/_clear/base.js';
import { base, StyledContentLeft, StyledContentMain, StyledContentRight } from './Badge.styles.js';
import { privateTokens, classes } from './Badge.tokens.js';

var _excluded = ["children", "className", "style", "text", "contentLeft", "contentRight", "size", "view", "customColor", "customBackgroundColor", "pilled", "transparent", "clear", "maxWidth"];
var badgeRoot = function badgeRoot(Root) {
  return /*#__PURE__*/forwardRef(function (props, ref) {
    var _StyledContentLeft, _StyledContentMain, _StyledContentMain2, _StyledContentRight;
    var children = props.children,
      className = props.className,
      style = props.style,
      text = props.text,
      contentLeft = props.contentLeft,
      contentRight = props.contentRight,
      size = props.size,
      view = props.view,
      customColor = props.customColor,
      customBackgroundColor = props.customBackgroundColor,
      _props$pilled = props.pilled,
      pilled = _props$pilled === void 0 ? false : _props$pilled,
      _props$transparent = props.transparent,
      transparent = _props$transparent === void 0 ? false : _props$transparent,
      _props$clear = props.clear,
      clear = _props$clear === void 0 ? false : _props$clear,
      _props$maxWidth = props.maxWidth,
      maxWidth = _props$maxWidth === void 0 ? 'auto' : _props$maxWidth,
      rest = _objectWithoutProperties(props, _excluded);
    var pilledClass = pilled ? classes.badgePilled : undefined;
    var transparentClass = transparent ? classes.badgeTransparent : undefined;
    var clearClass = clear ? classes.badgeClear : undefined;
    var truncateClass = maxWidth !== 'auto' ? classes.badgeTruncate : undefined;
    var txt = !text && typeof children === 'string' ? children : text;
    var iconOnlyClass = !txt && contentLeft ? classes.iconOnly : undefined;
    var BadgeContent = function BadgeContent() {
      if (contentLeft) {
        return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, _StyledContentLeft || (_StyledContentLeft = /*#__PURE__*/React__default.createElement(StyledContentLeft, null, contentLeft)), txt ? _StyledContentMain || (_StyledContentMain = /*#__PURE__*/React__default.createElement(StyledContentMain, {
          className: GRADIENT_TEXT_CLASS
        }, txt)) : children);
      }
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, txt ? _StyledContentMain2 || (_StyledContentMain2 = /*#__PURE__*/React__default.createElement(StyledContentMain, {
        className: GRADIENT_TEXT_CLASS
      }, txt)) : children, contentRight && (_StyledContentRight || (_StyledContentRight = /*#__PURE__*/React__default.createElement(StyledContentRight, null, contentRight))));
    };
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      ref: ref,
      className: cls(pilledClass, transparentClass, clearClass, truncateClass, iconOnlyClass, className, {}),
      view: view,
      size: size,
      pilled: pilled,
      transparent: transparent,
      clear: clear,
      style: _objectSpread2(_objectSpread2({}, style), {}, _defineProperty(_defineProperty({
        maxWidth: maxWidth
      }, privateTokens.customBackground, customBackgroundColor), privateTokens.customColor, customColor))
    }, rest), /*#__PURE__*/React__default.createElement(BadgeContent, null));
  });
};
var badgeConfig = {
  name: 'Badge',
  tag: 'div',
  layout: badgeRoot,
  base: base,
  variations: {
    view: {
      css: base$1
    },
    size: {
      css: base$2
    },
    pilled: {
      css: base$3,
      attrs: true
    },
    transparent: {
      css: base$4,
      attrs: true
    },
    clear: {
      css: base$5,
      attrs: true
    }
  },
  defaults: {
    view: 'primary',
    size: 'm'
  }
};

export { badgeConfig, badgeRoot };
