import React__default from 'react';
import useSendbirdStateContext from '../../useSendbirdStateContext.js';
import { useChannelSettingsContext } from '../context.js';
import { n as noop } from '../../utils-ea8d6707.js';
import Modal from '../../ui/Modal.js';
import { u as useLocalization } from '../../LocalizationContext-fd0d32ab.js';
import '../../withSendbird.js';
import '../../_rollupPluginBabelHelpers-f6b9b32e.js';
import '../../UserProfileContext-d36099b1.js';
import 'prop-types';
import '../../uuid-e8248f01.js';
import 'react-dom';
import '../../index-8b78f6b4.js';
import '../../ui/Button.js';
import '../../tslib.es6-46e4c379.js';
import '../../index-dfa71ceb.js';
import '../../stringSet-eb4a64cb.js';
import '../../ui/Icon.js';
import '../../ui/IconButton.js';
import '../../index-ce08211b.js';

var LeaveChannel = function (props) {
  var _a, _b, _c;

  var _d = props.onSubmit,
      onSubmit = _d === void 0 ? noop : _d,
      _e = props.onCancel,
      onCancel = _e === void 0 ? noop : _e;
  var channel = (_a = useChannelSettingsContext()) === null || _a === void 0 ? void 0 : _a.channel;
  var stringSet = useLocalization().stringSet;
  var state = useSendbirdStateContext();
  var logger = (_b = state === null || state === void 0 ? void 0 : state.config) === null || _b === void 0 ? void 0 : _b.logger;
  var isOnline = (_c = state === null || state === void 0 ? void 0 : state.config) === null || _c === void 0 ? void 0 : _c.isOnline;

  if (channel) {
    return /*#__PURE__*/React__default.createElement(Modal, {
      disabled: !isOnline,
      onCancel: onCancel,
      onSubmit: function () {
        logger.info('ChannelSettings: Leaving channel', channel);
        channel === null || channel === void 0 ? void 0 : channel.leave().then(function () {
          logger.info('ChannelSettings: Leaving channel successful!', channel);
          onSubmit();
        });
      },
      submitText: stringSet.MODAL__LEAVE_CHANNEL__FOOTER,
      titleText: stringSet.MODAL__LEAVE_CHANNEL__TITLE
    });
  }
};

export { LeaveChannel as default };
//# sourceMappingURL=LeaveChannel.js.map
