<script lang="ts">
  import type { ActivityItem } from '$lib/api'

  let { value }: { value: unknown } = $props()

  function fmtDuration(ms: number | null): string {
    if (ms == null) return '—'
    if (ms < 1000) return `${ms}ms`
    const s = Math.round(ms / 1000)
    if (s < 60) return `${s}s`
    return `${Math.floor(s / 60)}m ${s % 60}s`
  }
</script>

<span class="text-xs text-muted-foreground">{fmtDuration(value as number | null)}</span>
