var _excluded = ["children", "background", "color", "data-testid", "flavour", "hollow", "icon", "iconSize", "normal", "reverse", "size", "textSize", "tiny", "textProps", "semi", "ref"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import React from "react";
import { TextBig, Text, TextNano, TextSmall } from "../typography";
import Flex from "../templates/flex";
import PillIcon from "./icon";
import { getPillColor } from "./mixins/colors";
import { PillContainer } from "./styled";
var textComponents = {
  "default": Text,
  large: TextBig,
  normal: Text,
  small: TextSmall,
  tiny: TextNano
};
var Pill = function Pill(_ref) {
  var children = _ref.children,
    background = _ref.background,
    color = _ref.color,
    _ref$dataTestid = _ref["data-testid"],
    testId = _ref$dataTestid === void 0 ? "pill" : _ref$dataTestid,
    flavour = _ref.flavour,
    hollow = _ref.hollow,
    icon = _ref.icon,
    iconSize = _ref.iconSize,
    _ref$normal = _ref.normal,
    normal = _ref$normal === void 0 ? true : _ref$normal,
    reverse = _ref.reverse,
    size = _ref.size,
    textSize = _ref.textSize,
    tiny = _ref.tiny,
    textProps = _ref.textProps,
    semi = _ref.semi,
    ref = _ref.ref,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var iconProps = {
    color: color,
    flavour: flavour,
    hollow: hollow,
    icon: icon,
    size: iconSize
  };
  var TextComponent = tiny ? textComponents.tiny : textSize ? textComponents[textSize] : textComponents[size] || textComponents["default"];
  return /*#__PURE__*/React.createElement(PillContainer, _extends({
    background: background,
    "data-testid": testId,
    flavour: flavour,
    gap: 1,
    hollow: hollow,
    ref: ref,
    size: size,
    tiny: tiny,
    semi: semi
  }, rest), !reverse && /*#__PURE__*/React.createElement(PillIcon, _extends({
    "data-testid": testId + "-icon-left"
  }, iconProps)), children && /*#__PURE__*/React.createElement(Flex, _extends({
    as: TextComponent,
    color: color || (hollow ? getPillColor("color", flavour) : "bright"),
    "data-testid": testId + "-text",
    strong: !normal,
    whiteSpace: "nowrap"
  }, textProps), children), reverse && /*#__PURE__*/React.createElement(PillIcon, _extends({
    "data-testid": testId + "-icon-right"
  }, iconProps)));
};
export default Pill;