"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;exports.__esModule = true;exports.TokenView = TokenView;var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _react = _interopRequireWildcard(require("react"));

var _CommonWrapper = require("../../internal/CommonWrapper");
var _ThemeContext = require("../../lib/theming/ThemeContext");
var _Emotion = require("../../lib/theming/Emotion");


var _Token = require("./Token.styles");var _excluded = ["size", "children", "closeButton", "hideCloseButton", "className"];










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 = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
  var theme = (0, _react.useContext)(_ThemeContext.ThemeContext);
  var getSizeClassName = function getSizeClassName(size) {
    switch (size) {
      case 'large':
        return _Token.styles.tokenLarge(theme);
      case 'medium':
        return _Token.styles.tokenMedium(theme);
      case 'small':
      default:
        return _Token.styles.tokenSmall(theme);
    }
  };
  var closeButtonNode = hideCloseButton ? null : /*#__PURE__*/
  _react.default.createElement("span", { className: (0, _Emotion.cx)(_Token.styles.removeIcon(theme), _Token.globalClasses.removeIcon) }, closeButton);


  return /*#__PURE__*/(
    _react.default.createElement(_CommonWrapper.CommonWrapper, props, /*#__PURE__*/
    _react.default.createElement("div", (0, _extends2.default)({},
    rest, {
      className: (0, _Emotion.cx)(getSizeClassName(size), (_cx = {}, _cx[
      _Token.styles.token(theme)] = true, _cx)
      ) }),

    children,
    closeButtonNode
    )
    ));

}