"use strict";

exports.__esModule = true;
exports.useMenuProps = exports.default = exports.Menu = exports.CurrentApp = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactRedux = require("react-redux");
var _reactIntl = require("react-intl");
var _styles = require("@material-ui/core/styles");
var _authentication = require("../../selectors/authentication");
var _view = require("../../actions/view");
var _authentication2 = require("../../actions/authentication");
var _Preferences = require("./Preferences");
var _About = require("./About");
var _ApplicationSelector = _interopRequireDefault(require("./ApplicationSelector"));
var _DropMenu = _interopRequireDefault(require("../DropMenu"));
var _Anchor = _interopRequireDefault(require("./Anchor"));
var _Help = _interopRequireDefault(require("./Help"));
var _sharedMessages = _interopRequireDefault(require("./../../sharedMessages"));
var _excluded = ["menuLabel"],
  _excluded2 = ["applications", "applicationId", "currentApplication", "onClick", "helpUrl"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    wrapper: {
      height: "40px",
      color: theme.palette.text.hint,
      display: "flex",
      justifyContent: "space-between"
    },
    appBox: {
      height: "100%",
      display: "flex",
      flex: 1,
      alignItems: "stretch"
    },
    appLabel: {
      backgroundColor: "#000000",
      color: theme.palette.primary.light,
      fontFamily: theme.typography.button.fontFamily,
      fontSize: "14px",
      textTransform: "uppercase",
      paddingRight: "20px",
      paddingLeft: "6px",
      display: "flex",
      alignItems: "center"
    },
    appLogo: {
      height: "30px",
      marginRight: "10px"
    }
  };
});
var useMenuProps = exports.useMenuProps = function useMenuProps() {
  var intl = (0, _reactIntl.useIntl)();
  var dispatch = (0, _reactRedux.useDispatch)();
  return {
    id: "userMenu",
    menuLabel: (0, _reactRedux.useSelector)(_authentication.selectCurrentUsername),
    menuItems: [{
      id: "userMenuSignOut",
      label: intl.formatMessage(_sharedMessages.default.signOut),
      handler: function handler() {
        return dispatch((0, _authentication2.signOut)());
      },
      icon: "logout"
    }, {
      id: "userMenuPrefsMenu",
      label: intl.formatMessage(_sharedMessages.default.preferences),
      handler: function handler() {
        return dispatch((0, _view.setStateField)(_Preferences.PREFS_NAME, "show", true));
      },
      icon: "cogwheel"
    }, {
      id: "userMenuAbout",
      label: intl.formatMessage(_sharedMessages.default.about),
      handler: function handler() {
        return dispatch((0, _view.setStateField)(_About.ABOUT_NAME, "show", true));
      },
      icon: "info"
    }]
  };
};
__signature__(useMenuProps, "useIntl{intl}\nuseDispatch{dispatch}\nuseSelector{}", function () {
  return [_reactIntl.useIntl, _reactRedux.useDispatch, _reactRedux.useSelector];
});
__signature__(useMenuProps, "useIntl{intl}\nuseDispatch{dispatch}\nuseSelector{}", function () {
  return [_reactIntl.useIntl, _reactRedux.useDispatch, _reactRedux.useSelector];
});
var Menu = exports.Menu = function Menu() {
  var _useMenuProps = useMenuProps(),
    menuLabel = _useMenuProps.menuLabel,
    menuProps = _objectWithoutProperties(_useMenuProps, _excluded);
  return /*#__PURE__*/_react.default.createElement(_DropMenu.default, menuProps, /*#__PURE__*/_react.default.createElement(_Anchor.default, {
    menuLabel: menuLabel
  }));
};
__signature__(Menu, "useMenuProps{{ menuLabel, ...menuProps }}", function () {
  return [useMenuProps];
});
__signature__(Menu, "useMenuProps{{ menuLabel, ...menuProps }}", function () {
  return [useMenuProps];
});
var CurrentApp = exports.CurrentApp = function CurrentApp(_ref) {
  var displayName = _ref.displayName,
    iconUri = _ref.iconUri;
  var classes = useStyles();
  return /*#__PURE__*/_react.default.createElement("div", {
    className: classes.appLabel
  }, /*#__PURE__*/_react.default.createElement("img", {
    src: iconUri,
    className: classes.appLogo
  }), displayName);
};
__signature__(CurrentApp, "useStyles{classes}", function () {
  return [useStyles];
});
__signature__(CurrentApp, "useStyles{classes}", function () {
  return [useStyles];
});
CurrentApp.displayName = "CurrentApp";
var Topbar = function Topbar(_ref2) {
  var applications = _ref2.applications,
    applicationId = _ref2.applicationId,
    currentApplication = _ref2.currentApplication,
    onClick = _ref2.onClick,
    helpUrl = _ref2.helpUrl,
    config = _objectWithoutProperties(_ref2, _excluded2);
  var classes = useStyles();
  return /*#__PURE__*/_react.default.createElement("div", {
    onClick: onClick,
    className: classes.wrapper,
    "data-test-id": "wrapper"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.appBox
  }, /*#__PURE__*/_react.default.createElement(_ApplicationSelector.default, {
    applications: applications,
    applicationId: applicationId
  }), /*#__PURE__*/_react.default.createElement(CurrentApp, currentApplication || {})), /*#__PURE__*/_react.default.createElement(Menu, config), /*#__PURE__*/_react.default.createElement(_Help.default, {
    helpUrl: helpUrl
  }));
};
__signature__(Topbar, "useStyles{classes}", function () {
  return [useStyles];
});
__signature__(Topbar, "useStyles{classes}", function () {
  return [useStyles];
});
var _default = Topbar;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(useMenuProps, "useMenuProps", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Menu, "Menu", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(CurrentApp, "CurrentApp", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Topbar, "Topbar", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(useMenuProps, "useMenuProps", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Menu, "Menu", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(CurrentApp, "CurrentApp", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(Topbar, "Topbar", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/AppFrame/Topbar.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();