"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.HeaderRoomList = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _ProfileImagePlaceholder = require("../MainComponents/ProfileImagePlaceholder");
var _useChatSettingState = require("../../hooks/useChatSettingState");
var _icons = require("../../assets/icons");
var _Button = _interopRequireDefault(require("../styled/Button"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/** @format */

const HeaderRoomList = ({
  setDrawerOpen
}) => {
  const {
    config,
    user,
    selectedUser
  } = (0, _useChatSettingState.useChatSettingState)();
  const modalUser = selectedUser ?? user;
  const HeaderLogo = (0, _react.useMemo)(() => {
    const image = config?.headerLogo;
    if (image) {
      if (typeof image === 'function') {
        const SvgComponent = image;
        return /*#__PURE__*/(0, _jsxRuntime.jsx)(SvgComponent, {});
      } else if (typeof image === 'string') {
        return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
          source: {
            uri: image
          }
        });
      } else {
        return image;
      }
    }
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {});
  }, [config?.backgroundChat?.image]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
    style: styles.headerContainer,
    children: [!config?.disableRoomMenu && config?.headerMenu ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: styles.leftContainer,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
        style: styles.menuButton,
        color: "black",
        unstyled: true,
        EndIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.BurgerMenuIcon, {
          color: config?.colors?.primary
        }),
        onPress: () => config?.headerMenu && config?.headerMenu()
      })
    }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: styles.leftContainer
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: styles.centerContainer,
      children: config?.headerLogo ? HeaderLogo : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: {
          fontWeight: 500,
          fontSize: 18
        },
        children: "Chats"
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: styles.rightContainer,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProfileImagePlaceholder.ProfileImagePlaceholder, {
        icon: modalUser?.profileImage ?? null,
        name: modalUser?.name ?? modalUser?.firstName,
        size: 30,
        click: {
          isClick: true,
          onPress: setDrawerOpen
        }
      })
    })]
  });
};
exports.HeaderRoomList = HeaderRoomList;
const styles = _reactNative.StyleSheet.create({
  headerContainer: {
    flexDirection: 'row',
    alignItems: 'center',
    paddingHorizontal: 16,
    paddingTop: 16,
    paddingBottom: 8,
    minHeight: 56,
    justifyContent: 'space-between'
  },
  menuButton: {
    padding: 8,
    borderRadius: 16,
    backgroundColor: 'transparent'
  },
  leftContainer: {
    width: 40,
    alignItems: 'flex-start',
    justifyContent: 'center'
  },
  centerContainer: {
    position: 'absolute',
    left: 0,
    right: 0,
    alignItems: 'center',
    justifyContent: 'center'
  },
  rightContainer: {
    width: 40,
    alignItems: 'flex-end',
    justifyContent: 'center'
  }
});
//# sourceMappingURL=HeaderRoomList.js.map