import { isExportFrom } from './isExportFrom';

export function isPartOfChunk(node: any, lastNode: any, sourceCode: any): 'PartOfNewChunk' | 'PartOfChunk' | 'NotPartOfChunk' {
  if (!isExportFrom(node)) return 'NotPartOfChunk';

  const hasGroupingComment = sourceCode
    .getCommentsBefore(node)
    .some((comment: any) => (lastNode == null || comment.loc.start.line > lastNode.loc.end.line) && comment.loc.end.line < node.loc.start.line);

  return hasGroupingComment ? 'PartOfNewChunk' : 'PartOfChunk';
}
