"use strict";

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

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactOuiIcons = _interopRequireDefault(require("react-oui-icons"));

var _Link = _interopRequireDefault(require("../Link"));

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

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 Navigation = function Navigation(_ref) {
  var className = _ref.className,
      helpUrl = _ref.helpUrl,
      homeUrl = _ref.homeUrl,
      logoUrl = _ref.logoUrl,
      _ref$onHelpClick = _ref.onHelpClick,
      onHelpClick = _ref$onHelpClick === void 0 ? function () {
    return null;
  } : _ref$onHelpClick,
      _ref$theme = _ref.theme,
      theme = _ref$theme === void 0 ? "dark" : _ref$theme,
      title = _ref.title,
      props = _objectWithoutProperties(_ref, ["className", "helpUrl", "homeUrl", "logoUrl", "onHelpClick", "theme", "title"]);

  var themeClass = "axiom-navigation--".concat(theme);
  var classes = (0, _classnames["default"])(_defineProperty({
    "axiom-navigation": true,
    "flex": true,
    "flex-align--center": true
  }, themeClass, true), className);

  var onAppRouteLinkClick = function onAppRouteLinkClick(event) {
    return onHelpClick(event, helpUrl);
  };

  return _react["default"].createElement("nav", _extends({
    className: classes,
    "data-test-section": "navigation"
  }, props), _react["default"].createElement("div", {
    className: "axiom-navigation__brand soft-double--right flex flex-align--center flex-shrink--none"
  }, logoUrl && _react["default"].createElement("div", {
    className: "axiom-navigation__logo"
  }, _react["default"].createElement(_Link["default"], {
    href: homeUrl,
    testSection: "navigation--brand-logo"
  }, _react["default"].createElement("img", {
    alt: "logo",
    src: logoUrl,
    className: "push--right axiom-navigation__logo--mark"
  }))), title && _react["default"].createElement("div", {
    className: "axiom-navigation__title"
  }, title)), _react["default"].createElement("div", {
    className: "axiom-navigation__actions push-double--right flex flex-align--center flex-shrink--none"
  }, helpUrl && _react["default"].createElement(_Link["default"], {
    className: "flex flex-align--center",
    href: helpUrl,
    onClick: onAppRouteLinkClick,
    testSection: "navigation--help-icon"
  }, _react["default"].createElement(_reactOuiIcons["default"], {
    description: "center",
    name: "help",
    fill: theme === "dark" ? "white" : "black",
    size: "large",
    style: {
      alignSelf: "center"
    }
  }))));
};

exports.Navigation = Navigation;
Navigation.propTypes = {
  className: _propTypes["default"].string,
  helpUrl: _propTypes["default"].string,
  homeUrl: _propTypes["default"].string,
  logoUrl: _propTypes["default"].string,
  onHelpClick: _propTypes["default"].func,
  theme: _propTypes["default"].oneOf(["dark", "light"]),
  title: _propTypes["default"].string.isRequired
};