export function parseDuration(s: string): number {
  const match = s.match(/^(\d+(?:\.\d+)?)(ms|s|m)$/)
  if (!match) throw new Error(`Invalid duration: ${s}`)

  const value = parseFloat(match[1]!)
  const unit = match[2]!

  switch (unit) {
    case "ms": return value
    case "s": return value * 1000
    case "m": return value * 60_000
    default: throw new Error(`Unknown unit: ${unit}`)
  }
}
