"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _Modal = _interopRequireDefault(require("./../Modal"));
var _modalProps = _interopRequireDefault(require("./../modalProps"));
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
var _styles = require("@material-ui/core/styles");
var _sharedMessages = _interopRequireDefault(require("../../../../sharedMessages"));
var _reactIntl = require("react-intl");
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 {
    actionPanel: {
      display: "flex",
      marginLeft: "auto",
      flex: "1 1 0",
      justifyContent: "flex-end"
    }
  };
});
var ActionModal = function ActionModal(_ref) {
  var title = _ref.title,
    message = _ref.message,
    open = _ref.open,
    type = _ref.type,
    actions = _ref.actions,
    backdropClickCallback = _ref.backdropClickCallback;
  var classes = useStyles();
  var modalProps = new _modalProps.default();
  var titleComponent = title || /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.confirmation);
  modalProps.set(_modalProps.default.propNames.title, titleComponent);
  modalProps.set(_modalProps.default.propNames.open, open);
  modalProps.set(_modalProps.default.propNames.type, type);
  modalProps.set(_modalProps.default.propNames.backdropClickCallback, backdropClickCallback);
  var actionPanel = /*#__PURE__*/_react.default.createElement("div", {
    className: classes.actionPanel
  }, actions.map(function (action) {
    var _action$disabled;
    return /*#__PURE__*/_react.default.createElement(_Button.default, {
      key: action.label.id,
      variant: action.isPrimary ? "contained" : "outlined",
      color: action.isPrimary ? "primary" : "default",
      disableElevation: action.isPrimary,
      disabled: (_action$disabled = action.disabled) != null ? _action$disabled : false,
      onClick: function onClick(e) {
        return action.handler(e);
      }
    }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, action.label));
  }));
  modalProps.set(_modalProps.default.propNames.actionPanel, actionPanel);
  return /*#__PURE__*/_react.default.createElement(_Modal.default, {
    message: message,
    modalProps: modalProps
  });
};
__signature__(ActionModal, "useStyles{classes}", function () {
  return [useStyles];
});
__signature__(ActionModal, "useStyles{classes}", function () {
  return [useStyles];
});
var _default = ActionModal;
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/MaterialUI/DataDisplay/PredefinedElements/ActionModal.js");
  reactHotLoader.register(ActionModal, "ActionModal", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/PredefinedElements/ActionModal.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/PredefinedElements/ActionModal.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/MaterialUI/DataDisplay/PredefinedElements/ActionModal.js");
  reactHotLoader.register(ActionModal, "ActionModal", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/PredefinedElements/ActionModal.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/PredefinedElements/ActionModal.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();