"use strict";

exports.__esModule = true;
exports.default = exports.ApplicationDialog = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactIntl = require("react-intl");
var _sharedMessages = _interopRequireDefault(require("../../../sharedMessages"));
var _Link = _interopRequireDefault(require("@material-ui/core/Link"));
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
var _styles = require("@material-ui/core/styles");
var _classnames = _interopRequireDefault(require("classnames"));
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);
})();
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 {
    popperContainer: {
      cursor: "pointer",
      position: "relative"
    },
    header: {
      borderBottom: "1px solid ".concat(theme.palette.grey.light),
      margin: theme.spacing(0),
      padding: "".concat(theme.spacing(1, 2), " !important"),
      width: "calc(100% + ".concat(theme.spacing(2), ")"),
      maxWidth: "none",
      flexGrow: 1,
      backgroundColor: theme.palette.grey.lighter,
      textAlign: "center",
      borderRadius: theme.spacing(1, 1, 0, 0)
    },
    content: {
      borderRadius: theme.shape.borderRadius
    },
    wrapper: {
      backgroundColor: theme.palette.background.paper,
      width: theme.spacing(82),
      borderRadius: theme.spacing(1),
      border: "1px solid ".concat(theme.palette.grey.borders),
      boxShadow: "".concat(theme.spacing(0, 0, 2), " rgba(0,0,0,0.5)"),
      position: "relative"
    },
    container: {
      borderRadius: theme.shape.borderRadius,
      textAlign: "center",
      "&:hover": {
        backgroundColor: theme.palette.grey.lighter
      },
      overflow: "hidden"
    },
    containerSelected: {
      boxShadow: "".concat(theme.spacing(0, 0, 0.8), " ").concat(theme.palette.grey.borders)
    },
    appLink: {
      padding: theme.spacing(2),
      display: "block"
    },
    headerTitle: {
      fontSize: theme.typography.h3Size,
      textTransform: theme.typography.button.textTransform,
      fontFamily: theme.typography.button.fontFamily,
      fontWeight: theme.typography.button.fontWeight
    },
    label: {
      fontSize: theme.typography.h4Size,
      color: theme.palette.text.primary
    }
  };
});
var ApplicationDialog = exports.ApplicationDialog = function ApplicationDialog(_ref) {
  var toggle = _ref.toggle,
    applications = _ref.applications,
    applicationId = _ref.applicationId,
    applicationOrder = _ref.applicationOrder;
  var classes = useStyles();
  return /*#__PURE__*/_react.default.createElement(_Grid.default, {
    container: true,
    spacing: 2,
    className: classes.wrapper
  }, /*#__PURE__*/_react.default.createElement(_Grid.default, {
    item: true,
    xs: 12,
    className: classes.header
  }, /*#__PURE__*/_react.default.createElement(_Typography.default, {
    children: /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.appSelectorTitle),
    className: classes.headerTitle
  })), /*#__PURE__*/_react.default.createElement(_Grid.default, {
    item: true,
    container: true,
    xs: 12,
    className: classes.content
  }, applications.map(function (app) {
    return /*#__PURE__*/_react.default.createElement(_Grid.default, {
      className: (0, _classnames.default)(classes.container, app.name === applicationId ? classes.containerSelected : ""),
      item: true,
      key: app.name,
      xs: 6,
      md: 3
    }, /*#__PURE__*/_react.default.createElement(_Link.default, {
      className: classes.appLink,
      id: app.name,
      href: app.url,
      target: "_blank",
      underline: "none",
      onClick: app.name === applicationId ? function (event) {
        event.preventDefault();
        toggle();
      } : /* istanbul ignore next */
      function () {}
    }, /*#__PURE__*/_react.default.createElement("img", {
      height: "60",
      src: app.iconUri,
      alt: app.displayName
    }), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_Typography.default, {
      children: app.displayName,
      className: classes.label
    })));
  })));
};
__signature__(ApplicationDialog, "useStyles{classes}", function () {
  return [useStyles];
});
__signature__(ApplicationDialog, "useStyles{classes}", function () {
  return [useStyles];
});
var _default = ApplicationDialog;
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/ApplicationSelector/ApplicationDialog.js");
  reactHotLoader.register(ApplicationDialog, "ApplicationDialog", "/home/vsts/work/1/s/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/AppFrame/ApplicationSelector/ApplicationDialog.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/ApplicationSelector/ApplicationDialog.js");
  reactHotLoader.register(ApplicationDialog, "ApplicationDialog", "/home/vsts/work/1/s/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/AppFrame/ApplicationSelector/ApplicationDialog.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();