import {
  BlockType,
  Message,
  SystemBlockTypes,
  UnsupportedBlockTypes,
} from '@modules/chats/interfaces';

export const isSystemMessage = (message: Pick<Message, 'blocks'>) => {
  return !!message.blocks?.every(block =>
    SystemBlockTypes.includes(block.type),
  );
};

export const hasUnsupportedBlocks = (message: Pick<Message, 'blocks'>) => {
  return !!message.blocks?.some(block =>
    UnsupportedBlockTypes.includes(block.type),
  );
};

export const isMessageForwarded = (message: Pick<Message, 'blocks'>) => {
  return !!message.blocks?.some(
    block => block.type === BlockType.MessageForwarded,
  );
};

export const isMessageReplied = (message: Pick<Message, 'blocks'>) => {
  return !!message.blocks?.some(
    block => block.type === BlockType.MessageReplied,
  );
};
