import React__default from 'react';
import useSendbirdStateContext from '../../useSendbirdStateContext.js';
import { useChannelSettingsContext } from '../context.js';
import { n as noop } from '../../utils-dc344408.js';
import Modal from '../../ui/Modal.js';
import { u as useLocalization } from '../../LocalizationContext-a6f8fb25.js';
import '../../withSendbird.js';
import '../../_rollupPluginBabelHelpers-b9099c54.js';
import '../../UserProfileContext-58463608.js';
import 'prop-types';
import '../../uuid-bd74c65a.js';
import 'react-dom';
import '../../index-ecc6d4a9.js';
import '../../ui/Button.js';
import '../../tslib.es6-84f8edfa.js';
import '../../index-c2f20322.js';
import '../../stringSet-ed906148.js';
import '../../ui/Icon.js';
import '../../ui/IconButton.js';
import '../../index-fb7fd76d.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
