import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["size", "children", "closeButton", "hideCloseButton", "className"];
import React, { useContext } from 'react';
import { CommonWrapper } from "../../../internal/CommonWrapper";
import { ThemeContext } from "../../../lib/theming/ThemeContext";
import { cx } from "../../../lib/theming/Emotion";
import { globalClasses, styles } from "../Token.styles";
export function TokenView(props) {
  var _cx;
  var _props$size = props.size,
    size = _props$size === void 0 ? 'small' : _props$size,
    children = props.children,
    closeButton = props.closeButton,
    hideCloseButton = props.hideCloseButton,
    className = props.className,
    rest = _objectWithoutPropertiesLoose(props, _excluded);
  var theme = useContext(ThemeContext);
  var getSizeClassName = function getSizeClassName(size) {
    switch (size) {
      case 'large':
        return styles.tokenLarge(theme);
      case 'medium':
        return styles.tokenMedium(theme);
      case 'small':
      default:
        return styles.tokenSmall(theme);
    }
  };
  var closeButtonNode = hideCloseButton ? null : /*#__PURE__*/
  React.createElement("span", {
    className: cx(styles.removeIcon(theme), globalClasses.removeIcon)
  }, closeButton);
  return /*#__PURE__*/(
    React.createElement(CommonWrapper, props, /*#__PURE__*/
    React.createElement("div", _extends({}, rest, {
      className: cx(getSizeClassName(size), (_cx = {}, _cx[styles.token(theme)] = true, _cx))
    }), children, closeButtonNode))
  );
}