import React__default, { useContext, useState, useMemo } from 'react';
import { a as useChannelSettings } from '../../chunks/bundle-BkZBhjs8.js';
import { L as LocalizationContext } from '../../chunks/bundle-l_QLKq1Y.js';
import ChannelAvatar from '../../ui/ChannelAvatar.js';
import TextButton from '../../ui/TextButton.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../../chunks/bundle-HspRRkmy.js';
import EditDetails from './EditDetailsModal.js';
import { u as useSendbird } from '../../chunks/bundle-I25ah_Bv.js';
import { a as isDefaultChannelName } from '../../chunks/bundle-CgLhYjm5.js';
import '../../chunks/bundle-B8Grfnrx.js';
import '../../chunks/bundle-C4OmfIXk.js';
import '../../chunks/bundle-Ob7Cw3V-.js';
import '@sendbird/chat/groupChannel';
import '../../chunks/bundle-CTkGIdt8.js';
import '../../chunks/bundle-Djq12iSf.js';
import '../../chunks/bundle-CDcu1I4f.js';
import '../../chunks/bundle-BYqblmEM.js';
import '../../chunks/bundle-Y2KBbxRr.js';
import '../../chunks/bundle-BYOddwmS.js';
import '../../chunks/bundle-DgFzcADJ.js';
import '../../ui/ImageRenderer.js';
import '../../chunks/bundle-C_ngoQD_.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-DS6Kt7YS.js';
import '../../chunks/bundle-DED6q4Ti.js';
import '../../chunks/bundle-LnGQMQVt.js';
import 'react-dom';
import '../../chunks/bundle-yKqHFFfz.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '../../ui/Input.js';
import '@sendbird/chat';
import '@sendbird/chat/openChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-BTxw_tIt.js';
import '../../chunks/bundle-De-3zaYV.js';
import '../../chunks/bundle-DYBTopZK.js';

var ChannelProfile = function () {
    var _a, _b, _c;
    var state = useSendbird().state;
    var channel = useChannelSettings().state.channel;
    var stringSet = useContext(LocalizationContext).stringSet;
    var _d = useState(false), showModal = _d[0], setShowModal = _d[1];
    var userId = (_a = state === null || state === void 0 ? void 0 : state.config) === null || _a === void 0 ? void 0 : _a.userId;
    var theme = ((_b = state === null || state === void 0 ? void 0 : state.config) === null || _b === void 0 ? void 0 : _b.theme) || 'light';
    var isOnline = (_c = state === null || state === void 0 ? void 0 : state.config) === null || _c === void 0 ? void 0 : _c.isOnline;
    var disabled = !isOnline;
    var channelName = useMemo(function () {
        if (!(channel === null || channel === void 0 ? void 0 : channel.name) && !(channel === null || channel === void 0 ? void 0 : channel.members))
            return stringSet.NO_TITLE;
        if (isDefaultChannelName(channel))
            return ((channel === null || channel === void 0 ? void 0 : channel.members) || []).map(function (member) { return member.nickname || stringSet.NO_NAME; }).join(', ');
        return channel.name;
    }, [channel === null || channel === void 0 ? void 0 : channel.name, channel === null || channel === void 0 ? void 0 : channel.joinedMemberCount]);
    return (React__default.createElement("div", { className: "sendbird-channel-profile" },
        React__default.createElement("div", { className: "sendbird-channel-profile--inner" },
            React__default.createElement("div", { className: "sendbird-channel-profile__avatar" },
                React__default.createElement(ChannelAvatar, { channel: channel, userId: userId, theme: theme, width: 80, height: 80 })),
            React__default.createElement(Label, { className: "sendbird-channel-profile__title", type: LabelTypography.SUBTITLE_2, color: LabelColors.ONBACKGROUND_1 }, channelName),
            React__default.createElement(TextButton, { disabled: disabled, className: "sendbird-channel-profile__edit", onClick: function () {
                    if (disabled) {
                        return;
                    }
                    setShowModal(true);
                }, disableUnderline: true },
                React__default.createElement(Label, { type: LabelTypography.BUTTON_1, color: disabled ? LabelColors.ONBACKGROUND_2 : LabelColors.PRIMARY }, stringSet.CHANNEL_SETTING__PROFILE__EDIT)),
            showModal && (React__default.createElement(EditDetails, { onCancel: function () { return setShowModal(false); }, onSubmit: function () { return setShowModal(false); } })))));
};

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