export async function parseErrorResponse(res: Response): Promise<{ msg: string; code?: string }> {
  try {
    const data = await res.json()
    return { msg: data.error || data.message || 'Error', code: data.code }
  } catch {
    const text = await res.text()
    return { msg: text || 'Error' }
  }
}

export function isEmailValid(email: string): boolean {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)
}

export function isPasswordStrong(password: string): boolean {
  return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]{8,}$/.test(password)
}
