import type {
  DebugNetworkDownloadStats,
  DebugNetworkHandshakeStats,
  DebugNetworkTextStats,
  DebugNetworkStreamStats
} from '../../models/debugging.models';

export const LOCAL_NETWORK_NODE_ID = 'client:local';
export const NETWORK_TYPING_TTL_MS = 4_500;
export const NETWORK_RECENT_EDGE_TTL_MS = 30_000;
export const NETWORK_MESSAGE_GROUP_LIMIT = 12;
export const NETWORK_FILE_TRANSFER_RATE_WINDOW_MS = 6_000;
export const NETWORK_DOWNLOAD_STAT_TTL_MS = 8_000;
export const NETWORK_IGNORED_MESSAGE_TYPES = new Set([
  'ping',
  'pong',
  'state-request',
  'voice-state-request'
]);

export function createEmptyHandshakeStats(): DebugNetworkHandshakeStats {
  return {
    answersReceived: 0,
    answersSent: 0,
    iceReceived: 0,
    iceSent: 0,
    offersReceived: 0,
    offersSent: 0
  };
}

export function createEmptyTextStats(): DebugNetworkTextStats {
  return {
    received: 0,
    sent: 0
  };
}

export function createEmptyStreamStats(): DebugNetworkStreamStats {
  return {
    audio: 0,
    video: 0
  };
}

export function createEmptyDownloadStats(): DebugNetworkDownloadStats {
  return {
    audioMbps: null,
    fileMbps: null,
    videoMbps: null
  };
}
