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 _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; }

import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";

var Header = function Header(_ref) {
  var backLinkHref = _ref.backLinkHref,
      backLinkOnClick = _ref.backLinkOnClick,
      backLinkText = _ref.backLinkText,
      className = _ref.className,
      hasBackLink = _ref.hasBackLink,
      isFullHeight = _ref.isFullHeight,
      primaryTitle = _ref.primaryTitle,
      projectName = _ref.projectName,
      secondaryTitle = _ref.secondaryTitle,
      shouldHeaderScroll = _ref.shouldHeaderScroll,
      usesMonospaceStyling = _ref.usesMonospaceStyling,
      props = _objectWithoutProperties(_ref, ["backLinkHref", "backLinkOnClick", "backLinkText", "className", "hasBackLink", "isFullHeight", "primaryTitle", "projectName", "secondaryTitle", "shouldHeaderScroll", "usesMonospaceStyling"]);

  var maxCharCount = 22;
  return React.createElement("div", _extends({
    className: classNames({
      sidenav__header: true,
      "sidenav__header--full-height": isFullHeight,
      "overflow-y--auto": shouldHeaderScroll
    }, className)
  }, props), React.createElement("div", {
    className: "micro muted",
    "data-test-section": "header-project-name"
  }, projectName), hasBackLink && React.createElement("div", {
    className: "push--bottom"
  }, React.createElement("a", {
    href: backLinkHref,
    onClick: backLinkOnClick,
    className: "nav-link nav-link--back",
    "data-test-section": "header-back-link"
  }, backLinkText)), primaryTitle && React.createElement("h1", {
    className: classNames({
      sidenav__header__title: true,
      "flush--bottom": true,
      "force-break": true,
      gamma: !usesMonospaceStyling,
      delta: usesMonospaceStyling && primaryTitle.length <= maxCharCount,
      zeta: usesMonospaceStyling && primaryTitle.length > maxCharCount,
      monospace: usesMonospaceStyling
    }),
    title: primaryTitle,
    "data-test-section": "header-title"
  }, primaryTitle), secondaryTitle && React.createElement("p", null, secondaryTitle), props.children);
};

Header.propTypes = {
  /** Href URL to use for Breadcrumb */
  backLinkHref: PropTypes.string,

  /** Callback to perform when breadcrumb link is clicked */
  backLinkOnClick: PropTypes.func,

  /** Text to use for Breadcrumb */
  backLinkText: PropTypes.string,

  /** Content to render below the main title */
  children: PropTypes.node,

  /** CSS class names. */
  className: PropTypes.string,

  /** Whether or not a breadcrumb back link is present */
  hasBackLink: PropTypes.bool,

  /** Whether or not the header should be full height */
  isFullHeight: PropTypes.bool,

  /** The title of the current entity */
  primaryTitle: PropTypes.string,

  /** The name of the current project */
  projectName: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,

  /** A secondary name of the current entity, if applicable */
  secondaryTitle: PropTypes.string,

  /** Whether or not the header should scroll */
  shouldHeaderScroll: PropTypes.bool,

  /** Whether or not the header uses monospace styling */
  usesMonospaceStyling: PropTypes.bool
};
Header.defaultProps = {
  isFullHeight: false,
  usesMonospaceStyling: false,
  hasBackLink: true,
  primaryTitle: null
};
export default Header;