"use strict";

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

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

var _classnames = _interopRequireDefault(require("classnames"));

var _Modal = _interopRequireDefault(require("@material-ui/core/Modal"));

var _styles = require("@material-ui/core/styles");

var _modalProps = _interopRequireWildcard(require("./modalProps"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(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 _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

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 {
    modal: {
      display: "flex",
      alignItems: "center",
      justifyContent: "center"
    },
    baseContainer: {
      borderRadius: theme.spacing(0.8),
      display: "flex",
      flexDirection: "column",
      backgroundColor: theme.palette.primary.contrastText,
      "&:focus": {
        outline: "none"
      }
    },
    containerNormal: {
      width: theme.spacing(48)
    },
    containerWide: {
      width: theme.spacing(106.4),
      height: "calc(100% - 80px)",
      maxHeight: theme.spacing(73)
    },
    containerFullwidth: {
      width: "calc(100% - 80px)",
      height: "calc(100% - 80px)"
    },
    title: {
      height: theme.spacing(4),
      backgroundColor: theme.palette.grey.lighter,
      padding: theme.spacing(0, 2),
      borderRadius: theme.spacing(0.8, 0.8, 0, 0),
      borderBottom: "1px solid ".concat(theme.palette.grey.borders),
      display: "flex",
      alignItems: "center",
      fontSize: theme.typography.h3Size,
      textTransform: theme.typography.button.textTransform,
      fontFamily: theme.typography.button.fontFamily,
      fontWeight: theme.typography.button.fontWeight,
      flexShrink: 0
    },
    message: {
      minHeight: theme.spacing(10),
      backgroundColor: theme.palette.primary.contrastText,
      display: "flex",
      alignItems: "center",
      whiteSpace: "pre-wrap",
      padding: theme.spacing(2, 2),
      overflowY: "auto",
      fontSize: theme.typography.fontsize,
      fontFamily: theme.typography.fontFamily
    },
    messageWide: {
      minHeight: theme.spacing(10),
      backgroundColor: theme.palette.primary.contrastText,
      display: "flex",
      alignItems: "stretch",
      whiteSpace: "pre-wrap",
      padding: theme.spacing(2, 2),
      overflowY: "auto",
      flexGrow: 1,
      fontSize: theme.typography.fontsize,
      fontFamily: theme.typography.fontFamily
    },
    actionPanel: {
      padding: theme.spacing(1, 2),
      backgroundColor: theme.palette.grey.lighter,
      borderRadius: theme.spacing(0, 0, 0.8, 0.8),
      borderTop: "1px solid ".concat(theme.palette.grey.borders)
    }
  };
});

var Modal = function Modal(_ref) {
  var _modalProps$get, _modalProps$get2, _classNames, _classNames2;

  var message = _ref.message,
      modalProps = _ref.modalProps;
  var classes = useStyles();

  if ((0, _modalProps.isModalProps)(modalProps) === false) {
    throw new TypeError("modalProps property is not of type ModalProps");
  }

  var open = (_modalProps$get = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.open)) != null ? _modalProps$get : false;
  var title = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.title);
  var actionPanel = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.actionPanel);
  var backdropClickCallback = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.backdropClickCallback);
  var modalType = (_modalProps$get2 = modalProps == null ? void 0 : modalProps.get(_modalProps.default.propNames.type)) != null ? _modalProps$get2 : "normal";
  var containerCls = (0, _classnames.default)((_classNames = {}, _defineProperty(_classNames, classes.containerNormal, modalType === "normal"), _defineProperty(_classNames, classes.containerWide, modalType === "wide"), _defineProperty(_classNames, classes.containerFullwidth, modalType === "fullwidth"), _classNames));
  var messageCls = (0, _classnames.default)((_classNames2 = {}, _defineProperty(_classNames2, classes.message, modalType === "normal"), _defineProperty(_classNames2, classes.messageWide, modalType === "wide" || modalType === "fullwidth"), _classNames2));

  var onCloseCallback = function onCloseCallback(e, reason) {
    if (backdropClickCallback && reason === "backdropClick") {
      backdropClickCallback(e);
    }
  };

  var model = /*#__PURE__*/_react.default.createElement(_Modal.default, {
    disablePortal: true,
    disableEnforceFocus: true,
    disableAutoFocus: true,
    open: open,
    className: classes.modal,
    onClose: onCloseCallback
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(classes.baseContainer, containerCls)
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.title
  }, title), /*#__PURE__*/_react.default.createElement("div", {
    className: messageCls
  }, message), /*#__PURE__*/_react.default.createElement("div", {
    className: classes.actionPanel
  }, actionPanel)));

  return model;
};

__signature__(Modal, "useStyles{classes}", function () {
  return [useStyles];
});

__signature__(Modal, "useStyles{classes}", function () {
  return [useStyles];
});

var _default = Modal;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(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/Modal.js");
  reactHotLoader.register(Modal, "Modal", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Modal.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Modal.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/Modal.js");
  reactHotLoader.register(Modal, "Modal", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Modal.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Modal.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();