import type { QuotaWindow } from "@paperclipai/shared"; import { cn, quotaSourceDisplayName } from "@/lib/utils"; interface ClaudeSubscriptionPanelProps { windows: QuotaWindow[]; source?: string | null; error?: string | null; } const WINDOW_ORDER = [ "currentsession", "currentweekallmodels", "currentweeksonnetonly", "currentweeksonnet", "currentweekopusonly", "currentweekopus", "extrausage", ] as const; function normalizeLabel(text: string): string { return text.toLowerCase().replace(/[^a-z0-9]+/g, ""); } function detailText(window: QuotaWindow): string | null { if (typeof window.detail === "string" && window.detail.trim().length > 0) return window.detail.trim(); if (window.resetsAt) { const formatted = new Date(window.resetsAt).toLocaleString(undefined, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit", timeZoneName: "short", }); return `Resets ${formatted}`; } return null; } function orderedWindows(windows: QuotaWindow[]): QuotaWindow[] { return [...windows].sort((a, b) => { const aIndex = WINDOW_ORDER.indexOf(normalizeLabel(a.label) as (typeof WINDOW_ORDER)[number]); const bIndex = WINDOW_ORDER.indexOf(normalizeLabel(b.label) as (typeof WINDOW_ORDER)[number]); return (aIndex === -1 ? WINDOW_ORDER.length : aIndex) - (bIndex === -1 ? WINDOW_ORDER.length : bIndex); }); } function fillClass(usedPercent: number | null): string { if (usedPercent == null) return "bg-zinc-700"; if (usedPercent >= 90) return "bg-red-400"; if (usedPercent >= 70) return "bg-amber-400"; return "bg-primary/70"; } export function ClaudeSubscriptionPanel({ windows, source = null, error = null, }: ClaudeSubscriptionPanelProps) { const ordered = orderedWindows(windows); return (