export function formatValue(value: number): string {
  if (Math.abs(value) >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`;
  if (Math.abs(value) >= 1_000) return `${(value / 1_000).toFixed(1)}k`;
  if (Number.isInteger(value)) return value.toLocaleString();
  return value.toFixed(1);
}

export function formatFilterValue(value: number): string {
  if (Math.abs(value) >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`;
  if (Math.abs(value) >= 1_000) return `${(value / 1_000).toFixed(1)}k`;
  if (Number.isInteger(value)) return value.toString();
  return value.toFixed(2);
}

export function formatDuration(d: string): string {
  if (d === 'F') return 'Freehold';
  if (d === 'L') return 'Leasehold';
  return d;
}

export function formatAge(value: number, approximate = true): string {
  if (value >= 1000) return approximate ? `~${Math.round(value)}` : `${Math.round(value)}`;
  return Math.round(value).toString();
}
