import { useMemo } from "react" import { useTranslation } from "react-i18next" import { formatLargeNumber } from "@/utils/format" import { calculateTokenDistribution } from "@/utils/model-utils" import { StandardTooltip } from "@/components/ui" interface ContextWindowProgressProps { contextWindow: number contextTokens: number maxTokens?: number } export const ContextWindowProgress = ({ contextWindow, contextTokens, maxTokens }: ContextWindowProgressProps) => { const { t } = useTranslation() // Use the shared utility function to calculate all token distribution values const tokenDistribution = useMemo( () => calculateTokenDistribution(contextWindow, contextTokens, maxTokens), [contextWindow, contextTokens, maxTokens], ) // Destructure the values we need const { currentPercent, reservedPercent, availableSize, reservedForOutput, availablePercent } = tokenDistribution // For display purposes const safeContextWindow = Math.max(0, contextWindow) const safeContextTokens = Math.max(0, contextTokens) // Combine all tooltip content into a single tooltip const tooltipContent = (