'use strict';

var React = require('react');
var LocalizationContext = require('../../LocalizationContext-44d2f61b.js');
var ui_Label = require('../../index-2bfd366f.js');
var ui_TextButton = require('../../ui/TextButton.js');
var ui_OpenChannelAvatar = require('../../ui/OpenChannelAvatar.js');
var OpenChannelSettings_components_EditDetailsModal = require('./EditDetailsModal.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var OpenChannelSettings_context = require('../context.js');
require('../../stringSet-7aebf034.js');
require('../../index-88e8fdfa.js');
require('prop-types');
require('../../color-0c04efbd.js');
require('../../ui/Avatar.js');
require('../../ui/ImageRenderer.js');
require('../../ui/Icon.js');
require('../../uuid-dee74248.js');
require('../../utils-c71f0bea.js');
require('../../topics-373d2156.js');
require('../../ui/Modal.js');
require('react-dom');
require('../../index-0a446cca.js');
require('../../ui/Button.js');
require('../../ui/IconButton.js');
require('../../_rollupPluginBabelHelpers-21ae158b.js');
require('../../MediaQueryContext-5d311a86.js');
require('../../ui/Input.js');
require('../../withSendbird.js');
require('@sendbird/chat/openChannel');
require('../../UserProfileContext-9d843d68.js');

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

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

function ChannelProfile() {
  var _globalState$config, _globalState$config2;
  const globalState = useSendbirdStateContext();
  const disabled = !(globalState !== null && globalState !== void 0 && (_globalState$config = globalState.config) !== null && _globalState$config !== void 0 && _globalState$config.isOnline);
  const theme = globalState === null || globalState === void 0 ? void 0 : (_globalState$config2 = globalState.config) === null || _globalState$config2 === void 0 ? void 0 : _globalState$config2.theme;
  const {
    channel
  } = OpenChannelSettings_context.useOpenChannelSettingsContext();
  const title = channel === null || channel === void 0 ? void 0 : channel.name;
  const [showModal, setShowModal] = React.useState(false);
  const {
    stringSet
  } = React.useContext(LocalizationContext.LocalizationContext);
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-openchannel-profile"
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-openchannel-profile--inner"
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-openchannel-profile__avatar"
  }, /*#__PURE__*/React__default["default"].createElement(ui_OpenChannelAvatar, {
    channel: channel,
    theme: theme,
    height: 80,
    width: 80
  })), /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.SUBTITLE_2,
    color: ui_Label.LabelColors.ONBACKGROUND_1,
    className: "sendbird-openchannel-profile__title"
  }, title || stringSet.OPEN_CHANNEL_SETTINGS__NO_TITLE), /*#__PURE__*/React__default["default"].createElement(ui_TextButton, {
    disabled: disabled,
    className: "sendbird-openchannel-profile__edit",
    onClick: () => {
      if (disabled) {
        return;
      }
      setShowModal(true);
    },
    disableUnderline: true
  }, /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.BUTTON_1,
    color: disabled ? ui_Label.LabelColors.ONBACKGROUND_2 : ui_Label.LabelColors.PRIMARY
  }, stringSet.CHANNEL_SETTING__PROFILE__EDIT)), showModal && /*#__PURE__*/React__default["default"].createElement(OpenChannelSettings_components_EditDetailsModal, {
    onCancel: () => setShowModal(false)
  })));
}

module.exports = ChannelProfile;
//# sourceMappingURL=OpenChannelProfile.js.map
