"use strict";

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

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

var _styles = require("@fluent-ui/styles");

var _Typography = require("./Typography.styled");

var _Typography2 = require("./Typography.type");

var _Box = _interopRequireDefault(require("../Box"));

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

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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 _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 defaultVariantMapping = {
  h1: 'h1',
  h2: 'h2',
  h3: 'h3',
  h4: 'h4',
  h5: 'h5',
  h6: 'h6',
  subtitle1: 'h6',
  subtitle2: 'h6',
  body1: 'p',
  body2: 'p'
};
exports.defaultVariantMapping = defaultVariantMapping;
var name = 'Typography';
exports.name = name;
var useStyles = (0, _styles.createUseStyles)(_Typography.styles, {
  name: name
});
var Typography = React.forwardRef(function (props, ref) {
  var _classNames;

  var as = props.as,
      classNameProp = props.className,
      _props$variant = props.variant,
      variant = _props$variant === void 0 ? 'body1' : _props$variant,
      _props$variantMapping = props.variantMapping,
      variantMapping = _props$variantMapping === void 0 ? defaultVariantMapping : _props$variantMapping,
      _props$gutterTop = props.gutterTop,
      gutterTop = _props$gutterTop === void 0 ? false : _props$gutterTop,
      _props$gutterBottom = props.gutterBottom,
      gutterBottom = _props$gutterBottom === void 0 ? false : _props$gutterBottom,
      _props$noWrap = props.noWrap,
      noWrap = _props$noWrap === void 0 ? false : _props$noWrap,
      rest = _objectWithoutProperties(props, ["as", "className", "variant", "variantMapping", "gutterTop", "gutterBottom", "noWrap"]);

  var classes = useStyles(props);
  var className = (0, _classnames["default"])(classes.root, classes.variants, (_classNames = {}, _defineProperty(_classNames, classes.gutterTop, gutterTop), _defineProperty(_classNames, classes.gutterBottom, gutterBottom), _defineProperty(_classNames, classes.noWrap, noWrap), _classNames), classNameProp);
  var component = as || variantMapping[variant] || defaultVariantMapping[variant] || 'span';
  return React.createElement(_Box["default"], _extends({
    className: className,
    ref: ref,
    as: component
  }, rest));
});
Typography.displayName = "F".concat(name);
Typography.propTypes = _Typography2.TypographyPropTypes;
Typography.defaultProps = {
  variant: 'body1',
  variantMapping: defaultVariantMapping,
  gutterTop: false,
  gutterBottom: false,
  noWrap: false
};
var _default = Typography;
exports["default"] = _default;