import "@styles/Viewer.scss";
import { IChannel, IClient } from "react-ts5-remote-app-api";
export default function Viewer({
  clients,
  channel,
  showChannelName = false,
  hideNonTalking = false,
  clientLimit = 0,
}: {
  clients: IClient[] | undefined;
  channel: IChannel | undefined;
  showChannelName?: boolean;
  hideNonTalking?: boolean;
  clientLimit?: number;
}) {
  return (
    
      {showChannelName ? (
        
          
{channel?.properties.name}
        
      ) : null}
      {clients?.map((client, i) => {
        //* Client limit
        if (clientLimit != 0 && i >= clientLimit) {
          return null;
        }
        if (client) {
          //* Non-talking client
          if (
            hideNonTalking &&
            (client.properties.inputMuted || client.properties.outputMuted || client.talkStatus == 0)
          ) {
            return null;
          }
          //* Normal client
          return (
            
              {client.properties.outputHardware == false ? (
                
              ) : client.properties.inputHardware == false ? (
                
              ) : client.properties.outputMuted ? (
                
              ) : client.properties.inputMuted ? (
                
              ) : client.talkStatus == 1 ? (
                
              ) : (
                
              )}
              
{client.properties.nickname}
            
          );
        } else {
          return 
;
        }
      })}