"use strict";

/** @format */

import React, { useMemo } from 'react';
import { View, StyleSheet, Image, Text } from 'react-native';
import { ProfileImagePlaceholder } from '../MainComponents/ProfileImagePlaceholder';
import { useChatSettingState } from '../../hooks/useChatSettingState';
import { BurgerMenuIcon } from '../../assets/icons';
import Button from '../styled/Button';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export const HeaderRoomList = ({
  setDrawerOpen
}) => {
  const {
    config,
    user,
    selectedUser
  } = useChatSettingState();
  const modalUser = selectedUser ?? user;
  const HeaderLogo = useMemo(() => {
    const image = config?.headerLogo;
    if (image) {
      if (typeof image === 'function') {
        const SvgComponent = image;
        return /*#__PURE__*/_jsx(SvgComponent, {});
      } else if (typeof image === 'string') {
        return /*#__PURE__*/_jsx(Image, {
          source: {
            uri: image
          }
        });
      } else {
        return image;
      }
    }
    return /*#__PURE__*/_jsx(View, {});
  }, [config?.backgroundChat?.image]);
  return /*#__PURE__*/_jsxs(View, {
    style: styles.headerContainer,
    children: [!config?.disableRoomMenu && config?.headerMenu ? /*#__PURE__*/_jsx(View, {
      style: styles.leftContainer,
      children: /*#__PURE__*/_jsx(Button, {
        style: styles.menuButton,
        color: "black",
        unstyled: true,
        EndIcon: /*#__PURE__*/_jsx(BurgerMenuIcon, {
          color: config?.colors?.primary
        }),
        onPress: () => config?.headerMenu && config?.headerMenu()
      })
    }) : /*#__PURE__*/_jsx(View, {
      style: styles.leftContainer
    }), /*#__PURE__*/_jsx(View, {
      style: styles.centerContainer,
      children: config?.headerLogo ? HeaderLogo : /*#__PURE__*/_jsx(Text, {
        style: {
          fontWeight: 500,
          fontSize: 18
        },
        children: "Chats"
      })
    }), /*#__PURE__*/_jsx(View, {
      style: styles.rightContainer,
      children: /*#__PURE__*/_jsx(ProfileImagePlaceholder, {
        icon: modalUser?.profileImage ?? null,
        name: modalUser?.name ?? modalUser?.firstName,
        size: 30,
        click: {
          isClick: true,
          onPress: setDrawerOpen
        }
      })
    })]
  });
};
const styles = 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