import React__default, { useContext } from 'react';
import { createPortal } from 'react-dom';
import { M as MODAL_ROOT } from '../index-44c86e58.js';
import { a as LocalizationContext } from '../LocalizationContext-1701e5c8.js';
import Button, { ButtonTypes } from './Button.js';
import Icon, { IconTypes, IconColors } from './Icon.js';
import IconButton from './IconButton.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../index-f50d7ab0.js';
import { u as useMediaQueryContext } from '../MediaQueryContext-e5b401d0.js';
import '../stringSet-e9bb0333.js';
import '../index-ff8f2f61.js';
import 'prop-types';
import '../_rollupPluginBabelHelpers-cc035350.js';

const ModalHeader = _ref => {
  let {
    titleText
  } = _ref;
  return /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-modal__header"
  }, /*#__PURE__*/React__default.createElement(Label, {
    type: LabelTypography.H_1,
    color: LabelColors.ONBACKGROUND_1
  }, titleText));
};
const ModalBody = _ref2 => {
  let {
    children
  } = _ref2;
  return /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-modal__body"
  }, /*#__PURE__*/React__default.createElement(Label, {
    type: LabelTypography.SUBTITLE_1,
    color: LabelColors.ONBACKGROUND_2
  }, children));
};
const ModalFooter = _ref3 => {
  let {
    submitText,
    disabled = false,
    type = ButtonTypes.DANGER,
    onSubmit,
    onCancel
  } = _ref3;
  const {
    stringSet
  } = useContext(LocalizationContext);
  return /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-modal__footer"
  }, /*#__PURE__*/React__default.createElement(Button, {
    type: ButtonTypes.SECONDARY,
    onClick: onCancel
  }, /*#__PURE__*/React__default.createElement(Label, {
    type: LabelTypography.BUTTON_1,
    color: LabelColors.ONBACKGROUND_1
  }, stringSet.BUTTON__CANCEL)), /*#__PURE__*/React__default.createElement(Button, {
    type: type,
    disabled: disabled,
    onClick: onSubmit
  }, submitText));
};
function Modal(props) {
  const {
    children = null,
    className = '',
    isCloseOnClickOutside = false,
    isFullScreenOnMobile = false,
    titleText,
    submitText,
    disabled = false,
    hideFooter = false,
    type = ButtonTypes.DANGER,
    onCancel = () => {/* noop */},
    onSubmit = () => {/* noop */},
    renderHeader
  } = props;
  const {
    isMobile
  } = useMediaQueryContext();
  return /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement("div", {
    className: `
      sendbird-modal ${className}
      ${isFullScreenOnMobile && isMobile ? 'sendbird-modal--full-mobile' : ''}
    `
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-modal__content"
  }, (renderHeader === null || renderHeader === void 0 ? void 0 : renderHeader()) || /*#__PURE__*/React__default.createElement(ModalHeader, {
    titleText: titleText
  }), /*#__PURE__*/React__default.createElement(ModalBody, null, children), !hideFooter && /*#__PURE__*/React__default.createElement(ModalFooter, {
    disabled: disabled,
    onCancel: onCancel,
    onSubmit: onSubmit,
    submitText: submitText,
    type: type
  }), /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-modal__close"
  }, /*#__PURE__*/React__default.createElement(IconButton, {
    width: "32px",
    height: "32px",
    onClick: onCancel
  }, /*#__PURE__*/React__default.createElement(Icon, {
    type: IconTypes.CLOSE,
    fillColor: IconColors.DEFAULT,
    width: "24px",
    height: "24px"
  })))), /*#__PURE__*/React__default.createElement("div", {
    className: `
          sendbird-modal__backdrop
          ${isCloseOnClickOutside && 'sendbird-modal__backdrop--clickoutside'}
        `,
    onClick: e => {
      e === null || e === void 0 ? void 0 : e.stopPropagation();
      if (isCloseOnClickOutside) {
        onCancel();
      }
    }
  })), document.getElementById(MODAL_ROOT));
}

export { ModalBody, ModalFooter, ModalHeader, Modal as default };
//# sourceMappingURL=Modal.js.map
