import * as React from "react" import { cn } from "@/lib/utils" export type ProgressCircleProps = React.ComponentProps<"svg"> & { value?: number max?: number size?: number strokeWidth?: number label?: React.ReactNode description?: React.ReactNode tone?: "default" | "success" | "warning" | "danger" loading?: boolean } const toneClassName = { default: "stroke-primary", success: "stroke-[color:var(--aui-success,var(--primary))]", warning: "stroke-[color:var(--aui-warning,var(--primary))]", danger: "stroke-destructive", } function ProgressCircle({ value, max = 100, size = 120, strokeWidth = 10, label, description, tone = "default", loading = false, className, ...props }: ProgressCircleProps) { const radius = (size - strokeWidth) / 2 const circumference = 2 * Math.PI * radius const percentage = typeof value === "number" ? Math.min(Math.max(value / max, 0), 1) : 0 const offset = circumference - percentage * circumference const progressLabel = label ?? (typeof value === "number" ? `${Math.round(percentage * 100)}%` : undefined) return ( {progressLabel ? ( {progressLabel} ) : null} {description ? ( {description} ) : null} ) } export { ProgressCircle }