"use strict";

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

var _react = require("react");

var _reactRouter = require("react-router");

var _core = require("@emotion/core");

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

var _Nav = _interopRequireDefault(require("./Nav"));

var _Logo = _interopRequireDefault(require("../Logo/Logo"));

var _Icon = _interopRequireDefault(require("../Icon/Icon"));

var _styleConstants = require("../styleConstants");

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

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

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 _templateObject8() {
  var data = _taggedTemplateLiteral(["\n  a& {\n    display: none;\n    padding: 2rem;\n    border: none;\n    padding-right: 0;\n    margin-right: 2rem;\n\n    @media (max-width: 640px) {\n      display: block;\n    }\n  }\n"]);

  _templateObject8 = function _templateObject8() {
    return data;
  };

  return data;
}

function _templateObject7() {
  var data = _taggedTemplateLiteral(["\n  border: none;\n  opacity: 1;\n  transition: none;\n"]);

  _templateObject7 = function _templateObject7() {
    return data;
  };

  return data;
}

function _templateObject6() {
  var data = _taggedTemplateLiteral(["\n  margin: 12px 24px;\n  flex: 2;\n"]);

  _templateObject6 = function _templateObject6() {
    return data;
  };

  return data;
}

function _templateObject5() {
  var data = _taggedTemplateLiteral(["\n  margin: 0 30px 0 0;\n  display: block;\n\n  @media (max-width: 640px) {\n    &.active {\n      display: block;\n    }\n\n    &.inactive {\n      display: none;\n    }\n  }\n"]);

  _templateObject5 = function _templateObject5() {
    return data;
  };

  return data;
}

function _templateObject4() {
  var data = _taggedTemplateLiteral(["\n  ", ";\n  background-color: transparent;\n"]);

  _templateObject4 = function _templateObject4() {
    return data;
  };

  return data;
}

function _templateObject3() {
  var data = _taggedTemplateLiteral(["\n  background-color: ", ";\n  display: flex;\n  z-index: 1;\n  align-items: center;\n  justify-content: center;\n  width: 100%;\n  min-width: 320px;\n  margin: 0 auto;\n  padding: 0;\n"]);

  _templateObject3 = function _templateObject3() {
    return data;
  };

  return data;
}

function _templateObject2() {
  var data = _taggedTemplateLiteral(["\n  ", ";\n  position: fixed;\n  z-index: 100;\n"]);

  _templateObject2 = function _templateObject2() {
    return data;
  };

  return data;
}

function _templateObject() {
  var data = _taggedTemplateLiteral(["\n  width: 100%;\n  min-width: 320px;\n"]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }

var primaryColor = "rgb(34, 15, 37)";
var containerClass = (0, _core.css)(_templateObject());
var overlayContainerClass = (0, _core.css)(_templateObject2(), containerClass);
var headerClass = (0, _core.css)(_templateObject3(), primaryColor);
var overlayHeaderClass = (0, _core.css)(_templateObject4(), headerClass);
var navClass = (0, _core.css)(_templateObject5());
var logoClass = (0, _core.css)(_templateObject6());
var logoLinkClass = (0, _core.css)(_templateObject7());
var burgerClass = (0, _core.css)(_templateObject8());

var Header = function (_Component) {
  _inherits(Header, _Component);

  function Header() {
    var _this;

    _classCallCheck(this, Header);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Header).call(this));

    _defineProperty(_assertThisInitialized(_this), "togglesNestedMenu", function () {
      return _this.setState({
        menuActive: !_this.state.menuActive
      });
    });

    _this.state = {
      menuActive: false
    };
    return _this;
  }

  _createClass(Header, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          children = _this$props.children,
          menu = _this$props.menu,
          title = _this$props.title,
          overlay = _this$props.overlay,
          mainProjectColor = _this$props.mainProjectColor,
          logoType = _this$props.logoType;
      return (0, _core.jsx)("header", {
        css: overlay ? overlayContainerClass : containerClass,
        id: "site-header"
      }, (0, _core.jsx)("nav", {
        css: overlay ? overlayHeaderClass : headerClass,
        style: {
          backgroundColor: mainProjectColor || primaryColor
        }
      }, (0, _core.jsx)("div", {
        css: logoClass
      }, (0, _core.jsx)(_reactRouter.Link, {
        css: logoLinkClass,
        to: "/"
      }, (0, _core.jsx)(_Logo["default"], {
        type: logoType,
        alt: title
      }))), (0, _core.jsx)("div", {
        css: navClass,
        className: this.state.menuActive ? "active" : "inactive"
      }, (0, _core.jsx)(_Nav["default"], {
        menu: menu,
        toggleSubNav: this.togglesNestedMenu,
        showNestedMenu: this.state.nestedMenu,
        togglesNestedMenu: this.togglesNestedMenu
      }), children), (0, _core.jsx)("a", {
        css: burgerClass
      }, (0, _core.jsx)(_Icon["default"], {
        key: "nav-burger",
        className: _styleConstants.ICONS.hamburger,
        handleClick: this.togglesNestedMenu
      }))));
    }
  }]);

  return Header;
}(_react.Component);

Header.displayName = "Header";
Header.propTypes = {
  menu: _propTypes["default"].arrayOf(_propTypes["default"].shape({})),
  title: _propTypes["default"].string,
  children: _propTypes["default"].node,
  overlay: _propTypes["default"].bool,
  mainProjectColor: _propTypes["default"].string,
  logoType: _propTypes["default"].string
};
Header.defaultProps = {
  logoType: "standardLogoAnimatedInverted"
};
var _default = Header;
exports["default"] = _default;