"use strict";

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

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

var _react = require("react");

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

var _FullNav = _interopRequireDefault(require("./FullNav"));

var _SmallNav = _interopRequireDefault(require("./SmallNav"));

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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

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

function _templateObject() {
  var data = _taggedTemplateLiteral(["\n  height: 115px;\n  width: 100vw;\n  position: fixed;\n  background: #fdfdfd;\n  box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);\n  margin: 0;\n  top: 0;\n  z-index: 100;\n\n  @media (max-width: ", "px) {\n    height: 72px;\n  }\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 headerWrapper = function headerWrapper(props) {
  return (0, _core.css)(_templateObject(), props.collapseWidth);
};

var Header = function Header(props) {
  var collapseWidth = props.collapseWidth;

  var _useState = (0, _react.useState)(window.innerWidth),
      _useState2 = _slicedToArray(_useState, 2),
      width = _useState2[0],
      setWidth = _useState2[1];

  var handleResize = function handleResize() {
    setWidth(window.innerWidth);
  };

  (0, _react.useEffect)(function () {
    window.addEventListener("resize", handleResize);
    return function () {
      window.removeEventListener("resize", handleResize);
    };
  });
  return (0, _core.jsx)("header", _extends({
    css: headerWrapper(props)
  }, props), width > collapseWidth ? (0, _core.jsx)(_FullNav["default"], props) : (0, _core.jsx)(_SmallNav["default"], props));
};

Header.propTypes = {
  greatestWidth: _propTypes["default"].number,
  collapseWidth: _propTypes["default"].number,
  condensedWidth: _propTypes["default"].number
};
Header.defaultProps = {
  greatestWidth: 1200,
  collapseWidth: 845,
  condensedWidth: 715
};
Header.displayName = "Header";
var _default = Header;
exports["default"] = _default;