'use strict';

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

var _tslib = require('../../chunks/bundle-CxoFSSXv.js');
var React = require('react');
var useChannelSettings = require('../../chunks/bundle-CcVLRLk8.js');
var LocalizationContext = require('../../chunks/bundle-DDNdw3A9.js');
var ChannelSettings_hooks_useMenuList = require('../hooks/useMenuList.js');
var utils = require('../../chunks/bundle-DQNu-S6D.js');
var ChannelSettings_components_ChannelSettingsHeader = require('./ChannelSettingsHeader.js');
var ui_PlaceHolder = require('../../ui/PlaceHolder.js');
var ui_Label = require('../../chunks/bundle-B0UICprZ.js');
var ui_Icon = require('../../ui/Icon.js');
var ChannelSettings_components_ChannelProfile = require('./ChannelProfile.js');
var ChannelSettings_components_LeaveChannel = require('./LeaveChannel.js');
var ChannelSettings_components_ChannelSettingsMenuItem = require('./ChannelSettingsMenuItem.js');
var ChannelSettings_components_ChannelSettingMenuList = require('./ChannelSettingMenuList.js');
var useSendbird = require('../../chunks/bundle-LI9JjqG2.js');
var MutedMemberList = require('../../chunks/bundle-CdtZVJ6y.js');
var MemberList = require('../../chunks/bundle-D5wxUmg4.js');
require('../../chunks/bundle-AAO7jUU2.js');
require('../../chunks/bundle-yU9Mr2pS.js');
require('@sendbird/chat/groupChannel');
require('../../chunks/bundle-BUGwK1WK.js');
require('../../chunks/bundle-CvQwksvR.js');
require('../../chunks/bundle-DeyX1dvY.js');
require('../../chunks/bundle-EhtiN7UV.js');
require('../../chunks/bundle-BV7y6VDn.js');
require('../../ui/Badge.js');
require('../../ui/Toggle.js');
require('../../ui/Header.js');
require('../../chunks/bundle-CyQD5TkW.js');
require('../../ui/TextButton.js');
require('../../chunks/bundle-BIrmQghI.js');
require('../../ui/IconButton.js');
require('../../ui/Loader.js');
require('../../ui/ChannelAvatar.js');
require('../../chunks/bundle-CLL-nCFU.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-C8MACRPO.js');
require('../../chunks/bundle-DAVPwIxJ.js');
require('./EditDetailsModal.js');
require('../../chunks/bundle-YeW89zsR.js');
require('react-dom');
require('../../ui/Button.js');
require('../../ui/Input.js');
require('../../chunks/bundle-D7YiKR6i.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-dfqZUdij.js');
require('../../chunks/bundle-Dn0hi6OJ.js');
require('../../chunks/bundle-C1G0SKDq.js');
require('../../chunks/bundle-CqFqMb6S.js');
require('@sendbird/chat/message');
require('@sendbird/chat');
require('@sendbird/chat/openChannel');
require('../../chunks/bundle-BWtBhW43.js');
require('../../chunks/bundle-Bqahh-7Q.js');
require('../../ui/SortByRow.js');
require('../../ui/UserListItem.js');
require('../../ui/MutedAvatarOverlay.js');
require('../../ui/Checkbox.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../chunks/bundle-BPWJgESF.js');
require('../../chunks/bundle-DwVBqZFY.js');
require('@sendbird/uikit-tools');
require('../../chunks/bundle-D4Il5UXX.js');

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

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

var ChannelSettingsUI = function (props) {
    var _a = utils.deleteNullish(props), _b = _a.renderHeader, renderHeader = _b === void 0 ? function (props) { return React__default.default.createElement(ChannelSettings_components_ChannelSettingsHeader.ChannelSettingsHeader, _tslib.__assign({}, props)); } : _b, renderLeaveChannel = _a.renderLeaveChannel, renderChannelProfile = _a.renderChannelProfile, _c = _a.renderModerationPanel, renderModerationPanel = _c === void 0 ? function (props) { return React__default.default.createElement(ChannelSettings_components_ChannelSettingMenuList.MenuListByRole, _tslib.__assign({}, props)); } : _c, renderPlaceholderError = _a.renderPlaceholderError, renderPlaceholderLoading = _a.renderPlaceholderLoading;
    var state = useSendbird.useSendbird().state;
    var isOnline = state.config.isOnline;
    var _d = useChannelSettings.useChannelSettings().state, channel = _d.channel, invalidChannel = _d.invalidChannel, onCloseClick = _d.onCloseClick, loading = _d.loading;
    var stringSet = LocalizationContext.useLocalization().stringSet;
    var menuItems = ChannelSettings_hooks_useMenuList.useMenuItems();
    var _e = React.useState(false), showLeaveChannelModal = _e[0], setShowLeaveChannelModal = _e[1];
    if (loading) {
        if (renderPlaceholderLoading)
            return renderPlaceholderLoading();
        return React__default.default.createElement(ui_PlaceHolder.default, { type: ui_PlaceHolder.PlaceHolderTypes.LOADING });
    }
    var headerProps = { onCloseClick: onCloseClick };
    if (invalidChannel || !channel) {
        return (React__default.default.createElement("div", null,
            renderHeader(headerProps),
            React__default.default.createElement("div", null, renderPlaceholderError ? renderPlaceholderError() : React__default.default.createElement(ui_PlaceHolder.default, { type: ui_PlaceHolder.PlaceHolderTypes.WRONG }))));
    }
    return (React__default.default.createElement(React__default.default.Fragment, null,
        renderHeader(headerProps),
        React__default.default.createElement("div", { className: "sendbird-channel-settings__scroll-area" },
            (renderChannelProfile === null || renderChannelProfile === void 0 ? void 0 : renderChannelProfile()) || React__default.default.createElement(ChannelSettings_components_ChannelProfile, null), renderModerationPanel === null || renderModerationPanel === void 0 ? void 0 :
            renderModerationPanel({ menuItems: menuItems }),
            (renderLeaveChannel === null || renderLeaveChannel === void 0 ? void 0 : renderLeaveChannel()) || (React__default.default.createElement(ChannelSettings_components_ChannelSettingsMenuItem.MenuItem, { className: utils.classnames(!isOnline ? 'sendbird-channel-settings__panel-item__disabled' : '', 'sendbird-channel-settings__panel-item__leave-channel'), onKeyDown: function () {
                    if (!isOnline)
                        return;
                    setShowLeaveChannelModal(true);
                }, onClick: function () {
                    if (!isOnline)
                        return;
                    setShowLeaveChannelModal(true);
                }, renderLeft: function () { return (React__default.default.createElement(ui_Icon.default, { className: ['sendbird-channel-settings__panel-icon-left', 'sendbird-channel-settings__panel-icon__leave'].join(' '), type: ui_Icon.IconTypes.LEAVE, fillColor: ui_Icon.IconColors.ERROR, height: "24px", width: "24px" })); }, renderMiddle: function () { return (React__default.default.createElement(ui_Label.Label, { type: ui_Label.LabelTypography.SUBTITLE_1, color: ui_Label.LabelColors.ONBACKGROUND_1 }, stringSet.CHANNEL_SETTING__LEAVE_CHANNEL__TITLE)); } })),
            showLeaveChannelModal && (React__default.default.createElement(ChannelSettings_components_LeaveChannel, { onCancel: function () {
                    setShowLeaveChannelModal(false);
                }, onSubmit: function () {
                    setShowLeaveChannelModal(false);
                    onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
                } })))));
};

exports.BannedUserList = MutedMemberList.BannedUserList;
exports.MutedMemberList = MutedMemberList.MutedMemberList;
exports.OperatorList = MutedMemberList.OperatorList;
exports.MemberList = MemberList.MemberList;
exports.default = ChannelSettingsUI;
//# sourceMappingURL=ChannelSettingsUI.js.map
