'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var reactDom = require('react-dom');
var index = require('../index-32562627.js');
var LocalizationContext = require('../LocalizationContext-da62a103.js');
var ui_Button = require('../index-05692021.js');
var ui_Icon = require('./Icon.js');
var ui_IconButton = require('./IconButton.js');
var ui_Label = require('../index-089e0fba.js');
require('../stringSet-857a128c.js');
require('../index-25336220.js');
require('../tslib.es6-ba69891c.js');
require('../_rollupPluginBabelHelpers-4265e501.js');
require('prop-types');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var ModalHeader = function ModalHeader(_a) {
  var titleText = _a.titleText;
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__header"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.H_1,
    color: ui_Label.LabelColors.ONBACKGROUND_1
  }, titleText));
};
var ModalBody = function ModalBody(_a) {
  var children = _a.children;
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__body"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.SUBTITLE_1,
    color: ui_Label.LabelColors.ONBACKGROUND_2
  }, children));
};
var ModalFooter = function ModalFooter(_a) {
  var submitText = _a.submitText,
      _b = _a.disabled,
      disabled = _b === void 0 ? false : _b,
      _c = _a.type,
      type = _c === void 0 ? ui_Button.ButtonTypes.DANGER : _c,
      onSubmit = _a.onSubmit,
      onCancel = _a.onCancel;
  var stringSet = React.useContext(LocalizationContext.LocalizationContext).stringSet;
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__footer"
  }, /*#__PURE__*/React__default["default"].createElement(ui_Button.Button, {
    type: ui_Button.ButtonTypes.SECONDARY,
    onClick: onCancel
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.BUTTON_1,
    color: ui_Label.LabelColors.ONBACKGROUND_1
  }, stringSet.BUTTON__CANCEL)), /*#__PURE__*/React__default["default"].createElement(ui_Button.Button, {
    type: type,
    disabled: disabled,
    onClick: onSubmit
  }, submitText));
};
function Modal(props) {
  var _a = props.children,
      children = _a === void 0 ? null : _a,
      titleText = props.titleText,
      submitText = props.submitText,
      _b = props.disabled,
      disabled = _b === void 0 ? false : _b,
      _c = props.hideFooter,
      hideFooter = _c === void 0 ? false : _c,
      _d = props.type,
      type = _d === void 0 ? ui_Button.ButtonTypes.DANGER : _d,
      _e = props.onCancel,
      onCancel = _e === void 0 ? function () {} : _e,
      _f = props.onSubmit,
      onSubmit = _f === void 0 ? function () {} : _f;
  return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal"
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__content"
  }, /*#__PURE__*/React__default["default"].createElement(ModalHeader, {
    titleText: titleText
  }), /*#__PURE__*/React__default["default"].createElement(ModalBody, null, children), !hideFooter && /*#__PURE__*/React__default["default"].createElement(ModalFooter, {
    disabled: disabled,
    onCancel: onCancel,
    onSubmit: onSubmit,
    submitText: submitText,
    type: type
  }), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__close"
  }, /*#__PURE__*/React__default["default"].createElement(ui_IconButton, {
    width: "32px",
    height: "32px",
    onClick: onCancel
  }, /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    type: ui_Icon.IconTypes.CLOSE,
    fillColor: ui_Icon.IconColors.DEFAULT,
    width: "24px",
    height: "24px"
  })))), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-modal__backdrop"
  })), document.getElementById(index.MODAL_ROOT));
}

exports.ModalBody = ModalBody;
exports.ModalFooter = ModalFooter;
exports.ModalHeader = ModalHeader;
exports["default"] = Modal;
//# sourceMappingURL=Modal.js.map
