"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));

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

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

var _Flex = _interopRequireDefault(require("../Flex"));

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

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var _ref2 =
/*#__PURE__*/
_react.default.createElement("span", null);

var _ref3 =
/*#__PURE__*/
_react.default.createElement("span", null);

var _ref4 =
/*#__PURE__*/
_react.default.createElement("span", null);

var Hamburger = function Hamburger(_ref) {
  var isOpen = _ref.isOpen,
      rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["isOpen"]);
  return _react.default.createElement(_Flex.default, (0, _extends2.default)({
    sx: {
      transition: 'background-color .25s ease-in',
      backgroundColor: isOpen ? 'primary' : 'transparent',
      height: 64,
      width: 64,
      alignItems: 'center',
      justifyContent: 'center',
      cursor: 'pointer'
    }
  }, rest), _react.default.createElement(_Box.default, {
    sx: {
      position: 'relative',
      width: '24px',
      height: '18px',
      transform: 'rotate(0deg)',
      transition: '.3s ease-in-out',
      span: {
        display: 'block',
        position: 'absolute',
        height: '2px',
        width: '100%',
        backgroundColor: 'primary',
        opacity: 1,
        transform: 'translateX(0)',
        transition: 'transform .25s ease-in, opacity .25s ease-in'
      },
      'span:nth-child(1)': _objectSpread({
        top: 0
      }, isOpen ? {
        backgroundColor: 'white',
        transform: 'translateX(200%)',
        opacity: 0
      } : {}),
      'span:nth-child(2)': _objectSpread({
        top: 'calc(( 100% / 2 ) - 1px )'
      }, isOpen ? {
        transform: 'rotate(-45deg)',
        backgroundColor: 'white'
      } : {}, {
        '&:after': _objectSpread({
          content: '""',
          display: 'block',
          position: 'absolute',
          height: '2px',
          width: '100%',
          backgroundColor: 'primary',
          opacity: 0,
          left: 0,
          transform: 'rotate(0) translateX(0)',
          transition: 'opacity .25s ease-in, transform .25s ease-in'
        }, isOpen ? {
          transform: 'rotate(90deg)',
          opacity: 1,
          backgroundColor: 'white'
        } : {})
      }),
      'span:nth-child(3)': _objectSpread({
        bottom: 0
      }, isOpen ? {
        backgroundColor: 'white',
        transform: 'translateX(200%)',
        opacity: 0
      } : {})
    }
  }, _ref2, _ref3, _ref4));
};

Hamburger.propTypes = {
  isOpen: _propTypes.default.bool
};
var _default = Hamburger;
exports.default = _default;