import _extends from "@babel/runtime/helpers/esm/extends";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["children", "as", "size", "weight", "color", "transform", "align", "noWrap", "asContainer", "full", "breakWords", "whiteSpace", "className", "inherited"];
import * as React from 'react';
import classNames from 'classnames';
import { TEXT_AS, TEXT_WHITE_SPACE } from './textConsts';
import { generateResponsiveClassNames } from '../utils/responsive-props';
export { AS, // backward compatibility
SIZE, // backward compatibility
COLOR, // backward compatibility
WEIGHT, // backward compatibility
TEXT_AS, TEXT_SIZE, TEXT_COLOR, TEXT_WEIGHT, TEXT_TRANSFORM, TEXT_ALIGN, TEXT_WHITE_SPACE } from './textConsts';

var Text = function Text(_ref) {
  var _ref2;

  var children = _ref.children,
      _ref$as = _ref.as,
      as = _ref$as === void 0 ? TEXT_AS.DIV : _ref$as,
      size = _ref.size,
      weight = _ref.weight,
      color = _ref.color,
      transform = _ref.transform,
      align = _ref.align,
      noWrap = _ref.noWrap,
      asContainer = _ref.asContainer,
      full = _ref.full,
      breakWords = _ref.breakWords,
      whiteSpace = _ref.whiteSpace,
      className = _ref.className,
      _ref$inherited = _ref.inherited,
      inherited = _ref$inherited === void 0 ? false : _ref$inherited,
      props = _objectWithoutProperties(_ref, _excluded);

  var Type = as;
  var textClass = classNames.apply(void 0, ['sg-text', (_ref2 = {
    'sg-text--inherited': inherited
  }, _defineProperty(_ref2, "sg-text--".concat(String(color)), color), _defineProperty(_ref2, 'sg-text--container', asContainer), _defineProperty(_ref2, 'sg-text--bold', as === 'strong'), _ref2)].concat(_toConsumableArray(generateResponsiveClassNames(function (size) {
    return "sg-text--".concat(size);
  }, size)), _toConsumableArray(generateResponsiveClassNames(function (weight) {
    return "sg-text--".concat(weight);
  }, weight)), _toConsumableArray(generateResponsiveClassNames(function (transform) {
    return "sg-text--".concat(transform);
  }, transform)), _toConsumableArray(generateResponsiveClassNames(function (align) {
    return "sg-text--".concat(align);
  }, align)), _toConsumableArray(generateResponsiveClassNames(function (noWrap) {
    return noWrap ? "sg-text--no-wrap" : 'sg-text--wrap';
  }, noWrap)), _toConsumableArray(generateResponsiveClassNames(function (full) {
    return full ? "sg-text--full" : 'sg-text--auto';
  }, full)), _toConsumableArray(generateResponsiveClassNames(function (breakWords) {
    return breakWords ? 'sg-text--break-words' : 'sg-text--word-break-normal';
  }, breakWords)), _toConsumableArray(generateResponsiveClassNames(function (whiteSpace) {
    if (whiteSpace === TEXT_WHITE_SPACE.PRE_WRAP) {
      return 'sg-text--pre-wrap';
    } else if (whiteSpace === TEXT_WHITE_SPACE.PRE_LINE) {
      return 'sg-text--pre-line';
    } else {
      return 'sg-text--white-space-normal';
    }
  }, whiteSpace)), [className]));
  return /*#__PURE__*/React.createElement(Type, _extends({}, props, {
    className: textClass
  }), children);
};

export default Text;