"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.customDialogStyle = exports.CustomDialogHeader = exports.CustomDialog = void 0;
var _react = _interopRequireDefault(require("react"));
var _styles = require("@material-ui/core/styles");
var _withWidth = _interopRequireDefault(require("@material-ui/core/withWidth"));
var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));
var _DialogTitle = _interopRequireDefault(require("@material-ui/core/DialogTitle"));
var _Icon = _interopRequireDefault(require("@material-ui/core/Icon"));
var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
var _AutoFocusDialogContentContainer = _interopRequireDefault(require("../../App/Shared/Components/AutoFocusDialogContentContainer/AutoFocusDialogContentContainer"));
var _useDialogId2 = require("../../App/Shared/Hooks/useDialogId");
var _excluded = ["className", "classes", "width", "dialogTitle", "onCancel", "children", "fullScreen"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(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 (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
var customDialogStyle = exports.customDialogStyle = function customDialogStyle(theme) {
  var _theme$smallScreen = theme.smallScreen,
    smallScreen = _theme$smallScreen === void 0 ? {
      centeredDialogPadding: 0
    } : _theme$smallScreen;
  return {
    MuiDialogBorder: {
      borderTop: '7px solid ' + theme.palette.primary.main
    },
    MuiStyledDialog: {
      '& .MuiDialog-container': {
        '& .MuiDialog-paperWidthMd': {
          maxWidth: 720
        },
        '& .MuiDialogTitle-root': {
          paddingTop: theme.spacing(2),
          paddingBottom: theme.spacing(2),
          '& .MuiTypography-root': {
            fontSize: 24,
            fontWeight: 'bold',
            letterSpacing: 'normal',
            display: 'flex',
            justifyContent: 'space-between',
            alignItems: 'center'
          }
        },
        '& .MuiDialogActions-root': {
          paddingBottom: 24,
          '& .MuiButton-root': {
            height: 40,
            textTransform: 'none',
            minWidth: 140
          }
        },
        '& .MuiDialogTitle-root, .MuiDialogContent-root, .MuiDialogActions-root': {
          paddingLeft: smallScreen.centeredDialogPadding,
          paddingRight: smallScreen.centeredDialogPadding,
          '& p': {
            fontSize: 15,
            letterSpacing: 'normal'
          }
        }
      }
    }
  };
};
var customDialogHeaderStyle = function customDialogHeaderStyle(theme) {
  return {
    closeButton: {
      marginLeft: 'auto',
      marginRight: theme.spacing(1),
      marginTop: theme.spacing(1)
    },
    dialogHeader: {
      display: 'flex',
      alignItems: 'start'
    },
    dialogTitle: {
      flex: 1
    }
  };
};
var CustomDialogHeader = exports.CustomDialogHeader = (0, _styles.withStyles)(customDialogHeaderStyle, {
  name: 'CustomDialogHeader'
})(function (_ref) {
  var classes = _ref.classes,
    dialogTitle = _ref.dialogTitle,
    dialogTitleId = _ref.dialogTitleId,
    onClose = _ref.onClose,
    children = _ref.children;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: classes.dialogHeader
  }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], {
    className: classes.dialogTitle,
    id: dialogTitleId
  }, dialogTitle), children, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
    onClick: onClose,
    className: classes.closeButton
  }, /*#__PURE__*/_react["default"].createElement(CustomDialogHeader.IconComponent, null)));
});
CustomDialogHeader.IconComponent = function CloseIcon() {
  return /*#__PURE__*/_react["default"].createElement(_Icon["default"], null, "close");
};
var CustomDialog = exports.CustomDialog = (0, _withWidth["default"])({
  initialWidth: 'xl'
})((0, _styles.withStyles)(customDialogStyle, {
  name: 'CustomDialog'
})(function (_ref2) {
  var className = _ref2.className,
    classes = _ref2.classes,
    width = _ref2.width,
    dialogTitle = _ref2.dialogTitle,
    onCancel = _ref2.onCancel,
    children = _ref2.children,
    fullScreen = _ref2.fullScreen,
    props = _objectWithoutProperties(_ref2, _excluded);
  var open = props.open;
  var _useDialogId = (0, _useDialogId2.useDialogId)(),
    dialogTitleId = _useDialogId.dialogTitleId;
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], _extends({
    maxWidth: width === 'md' || width === 'lg' || width === 'xl' ? 'md' : 'sm',
    fullWidth: true,
    classes: {
      paper: classes.MuiDialogBorder,
      root: classes.MuiStyledDialog
    },
    className: className + ' ' + (width === 'xs' ? classes.stickyDialog : ''),
    fullScreen: fullScreen,
    "aria-labelledby": dialogTitleId
  }, props), /*#__PURE__*/_react["default"].createElement(CustomDialog.DialogHeaderComponent, {
    dialogTitle: dialogTitle,
    dialogTitleId: dialogTitleId,
    onClose: onCancel
  }), /*#__PURE__*/_react["default"].createElement(_AutoFocusDialogContentContainer["default"], {
    open: open
  }, children));
}));
CustomDialog.DialogHeaderComponent = CustomDialogHeader;
var _default = exports["default"] = CustomDialog;