"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _reactAddonsTextContent = _interopRequireDefault(require("react-addons-text-content"));

var _components = require("@patternplate/components");

var _text = _interopRequireDefault(require("./text"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _default = Flag;
exports.default = _default;

function Flag(props) {
  return _react.default.createElement(StyledText, {
    className: props.className
  }, props.children);
}

const StyledText = (0, _components.styled)(_text.default).withConfig({
  displayName: "flag__StyledText"
})(["display:inline-block;padding:2px 4px;border:1px solid ", ";border-radius:3px;", ";"], props => props.theme.border, props => {
  const color = getFlagColor((0, _reactAddonsTextContent.default)(props.children), props.theme);
  return `
			border-color: ${color};
			color: ${color};
		`;
});

function getFlagColor(flag, theme) {
  switch (flag) {
    case "alpha":
      return theme.error;

    case "beta":
      return theme.warning;

    case "rc":
      return theme.info;

    case "stable":
      return theme.success;

    case "deprecated":
      return theme.error;

    default:
      return theme.error;
  }
}
//# sourceMappingURL=flag.js.map