import {
  StorageStatisticsSegmentDto,
  StorageStatisticsSegmentUnboxedDto
} from "@upload-io/upload-shared-iso/statistics/storage/dtos/StorageStatisticsSegmentDto";
import { UploadStatisticsMimeRecord } from "@upload-io/upload-shared-iso/statistics/storage/dtos/UploadStatisticsMimeRecord";

export interface UploadStatisticsDto {
  all: StorageStatisticsSegmentDto;
  mime: UploadStatisticsMimeRecord<StorageStatisticsSegmentDto>;
}

export interface UploadStatisticsUnboxedDto {
  all: StorageStatisticsSegmentUnboxedDto;
  mime: UploadStatisticsMimeRecord<StorageStatisticsSegmentUnboxedDto>;
}

export namespace UploadStatisticsDto {
  export const empty: UploadStatisticsDto = {
    all: StorageStatisticsSegmentDto.empty,
    mime: {
      audio: StorageStatisticsSegmentDto.empty,
      image: StorageStatisticsSegmentDto.empty,
      video: StorageStatisticsSegmentDto.empty,
      document: StorageStatisticsSegmentDto.empty,
      other: StorageStatisticsSegmentDto.empty
    }
  };

  export function combine(left: UploadStatisticsDto, right: UploadStatisticsDto): UploadStatisticsDto {
    return {
      all: StorageStatisticsSegmentDto.combine(left.all, right.all),
      mime: {
        audio: StorageStatisticsSegmentDto.combine(left.mime.audio, right.mime.audio),
        image: StorageStatisticsSegmentDto.combine(left.mime.image, right.mime.image),
        video: StorageStatisticsSegmentDto.combine(left.mime.video, right.mime.video),
        document: StorageStatisticsSegmentDto.combine(left.mime.document, right.mime.document),
        other: StorageStatisticsSegmentDto.combine(left.mime.other, right.mime.other)
      }
    };
  }
}
