"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "HEADLINE_ALIGN", {
  enumerable: true,
  get: function get() {
    return _headlineConsts.HEADLINE_ALIGN;
  }
});
Object.defineProperty(exports, "HEADLINE_AS", {
  enumerable: true,
  get: function get() {
    return _headlineConsts.HEADLINE_AS;
  }
});
Object.defineProperty(exports, "HEADLINE_SIZE", {
  enumerable: true,
  get: function get() {
    return _headlineConsts.HEADLINE_SIZE;
  }
});
Object.defineProperty(exports, "HEADLINE_TRANSFORM", {
  enumerable: true,
  get: function get() {
    return _headlineConsts.HEADLINE_TRANSFORM;
  }
});
Object.defineProperty(exports, "TEXT_COLOR", {
  enumerable: true,
  get: function get() {
    return _Text.TEXT_COLOR;
  }
});
exports.default = void 0;

var React = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _headlineConsts = require("./headlineConsts");

var _Text = require("./Text");

var _responsiveProps = require("../utils/responsive-props");

var _excluded = ["children", "as", "size", "extraBold", "transform", "align", "color", "className", "inherited"];

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

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

  var children = _ref.children,
      _ref$as = _ref.as,
      as = _ref$as === void 0 ? _headlineConsts.HEADLINE_AS.H1 : _ref$as,
      size = _ref.size,
      extraBold = _ref.extraBold,
      transform = _ref.transform,
      align = _ref.align,
      color = _ref.color,
      className = _ref.className,
      _ref$inherited = _ref.inherited,
      inherited = _ref$inherited === void 0 ? false : _ref$inherited,
      props = _objectWithoutProperties(_ref, _excluded);

  var Type = as;

  var headlineClass = _classnames.default.apply(void 0, ['sg-headline', (_ref2 = {
    'sg-headline--inherited': inherited
  }, _defineProperty(_ref2, "sg-headline--".concat(String(color)), color), _defineProperty(_ref2, 'sg-headline--extra-bold', as === 'strong'), _ref2)].concat(_toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-headline--".concat(propValue);
  }, size)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-headline--".concat(propValue);
  }, transform)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue ? "sg-headline--extra-bold" : 'sg-headline--no-bold';
  }, extraBold)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-headline--".concat(propValue);
  }, align)), [className]));

  return /*#__PURE__*/React.createElement(Type, _extends({}, props, {
    className: headlineClass
  }), children);
};

var _default = Headline;
exports.default = _default;