export function timeToPx(time: number, pixelsPerSecond: number): number {
  return time * pixelsPerSecond;
}

export function pxToTime(px: number, pixelsPerSecond: number): number {
  return px / pixelsPerSecond;
}

export function centerScrollOnPlayhead(
  playheadTime: number,
  pixelsPerSecond: number,
  viewportWidth: number,
): number {
  const playheadPx = timeToPx(playheadTime, pixelsPerSecond);
  return Math.max(0, playheadPx - viewportWidth / 2);
}

export function formatTime(seconds: number): string {
  const mins = Math.floor(seconds / 60);
  const secs = seconds % 60;
  return `${mins}:${secs.toFixed(2).padStart(5, '0')}`;
}

export function tickInterval(pixelsPerSecond: number): number {
  if (pixelsPerSecond >= 200) return 0.1;
  if (pixelsPerSecond >= 100) return 0.5;
  if (pixelsPerSecond >= 50) return 1;
  if (pixelsPerSecond >= 25) return 2;
  return 5;
}
