"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _picture = _interopRequireDefault(require("../../atom/picture"));
var _link = _interopRequireDefault(require("../../atom/link"));
var _buttonLink = _interopRequireDefault(require("../../atom/button-link"));
var _buttonLinkIcon = _interopRequireDefault(require("../../atom/button-link-icon"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const SetupHeader = props => {
  const [show, updateShow] = _react.default.useState(false);
  const {
    platformName,
    items,
    href,
    user = {},
    logo,
    logoMobile,
    isHome = false,
    isDashboard = false
  } = props;
  const {
    image = ''
  } = user;
  function onMouseEnter() {
    updateShow(true);
  }
  function onMouseLeave() {
    updateShow(false);
  }
  const platformListButtonProps = {
    type: 'tertiary',
    label: items.platformList.label,
    'aria-label': items.platformList.label,
    'data-name': `platform-list-button`,
    link: {
      href: items.platformList.href
    },
    icon: {
      position: 'left',
      type: 'list'
    }
  };
  const platformListIconButtonProps = {
    'aria-label': items.platformList.label,
    'data-name': `platform-list-button`,
    link: {
      href: items.platformList.href
    },
    icon: 'list'
  };
  const goAnalyticsButtonProps = items.globalAnalytics && isDashboard === false ? {
    type: 'secondary',
    label: items.globalAnalytics.label,
    'aria-label': items.globalAnalytics.label,
    'data-name': `platform-list-button`,
    link: {
      href: items.globalAnalytics.href
    },
    icon: {
      position: 'left',
      type: 'analytics'
    }
  } : null;
  const seeMyPlatformButtonProps = {
    type: 'primary',
    label: items.seeMyPlatform.label,
    'aria-label': items.seeMyPlatform.label,
    'data-name': `see-my-platform`,
    link: {
      href: items.seeMyPlatform.href,
      target: '_blank'
    },
    icon: {
      position: 'left',
      type: 'see'
    }
  };
  const logoutButtonProps = {
    type: 'text',
    label: items.logOut.label,
    'aria-label': items.logOut.label,
    'data-name': `logout-list-button`,
    link: {
      href: items.logOut.href,
      onClick: items.logOut.onClick
    },
    icon: {
      position: 'left',
      type: 'logout'
    }
  };
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.container
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.wrapper
  }, isHome ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.logo
  }, /*#__PURE__*/_react.default.createElement(_link.default, {
    href: href
  }, /*#__PURE__*/_react.default.createElement(_picture.default, {
    className: _style.default.logoDesktop,
    src: logo
  }), /*#__PURE__*/_react.default.createElement(_picture.default, {
    className: _style.default.logoMobile,
    src: logoMobile
  }))) : /*#__PURE__*/_react.default.createElement("ul", {
    className: _style.default.list
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)([_style.default.button, _style.default.platformList])
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, platformListButtonProps)), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.platformListIcon
  }, /*#__PURE__*/_react.default.createElement(_buttonLinkIcon.default, platformListIconButtonProps)), !isDashboard ? /*#__PURE__*/_react.default.createElement("li", {
    className: (0, _classnames.default)(_style.default.element, _style.default.platformName)
  }, platformName) : null), /*#__PURE__*/_react.default.createElement("ul", {
    className: _style.default.list
  }, goAnalyticsButtonProps ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.button
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, goAnalyticsButtonProps)) : null, isDashboard || isHome ? null : /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.button
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, seeMyPlatformButtonProps)), /*#__PURE__*/_react.default.createElement("li", {
    onMouseEnter: onMouseEnter,
    className: _style.default.profilePicture
  }, /*#__PURE__*/_react.default.createElement("img", {
    src: image
  })), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.logOut
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, logoutButtonProps)))), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": `logout-${show ? 'show' : 'hide'}`
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.arrowUp
  }), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.logOut,
    onMouseLeave: onMouseLeave
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, logoutButtonProps))));
};
SetupHeader.propTypes = process.env.NODE_ENV !== "production" ? {
  items: _propTypes.default.shape({
    seeMyPlatform: _propTypes.default.shape(_buttonLink.default.propTypes),
    logOut: _propTypes.default.shape(_buttonLink.default.propTypes),
    globalAnalytics: _propTypes.default.shape(_buttonLink.default.propTypes),
    platformList: _propTypes.default.shape(_buttonLink.default.propTypes)
  }),
  platformName: _propTypes.default.string,
  isDashboard: _propTypes.default.bool,
  isHome: _propTypes.default.bool,
  href: _link.default.propTypes.href,
  user: _propTypes.default.shape({
    username: _propTypes.default.string,
    image: _propTypes.default.string
  }),
  logo: _picture.default.propTypes.src,
  logoMobile: _picture.default.propTypes.src
} : {};
var _default = exports.default = SetupHeader;
//# sourceMappingURL=index.js.map