import type { ReactNode } from "react"; import { type DateInput } from "./relative-time.js"; export type UsageMeterVariant = "bar" | "text" | "ring"; export type UsageMeterDensity = "full" | "compact"; export type UsageLevel = "healthy" | "low" | "exhausted" | "unknown"; /** Below this share left, the meter takes the danger tone. */ export declare const USAGE_LOW_THRESHOLD = 10; /** * The level for a reading. `percent` is what the meter measures: the share * left (default) or the share used (machines). */ export declare function usageLevel(percent: number | null | undefined, measure?: "left" | "used", lowAt?: number): UsageLevel; /** Clamps to 0-100 and rounds, so "21.6" never shows as "21.6% left". */ export declare function clampPercent(percent: number): number; /** The short value text: "22% left", "Limit reached", "Not reported yet". */ export declare function usageValueText(percent: number | null | undefined, measure?: "left" | "used", lowAt?: number): string; /** * The reset time as it reads after "Resets": "Mon 28 Sep, 09:00" stays, but * "Today, 17:10" becomes "today, 17:10" mid-sentence. */ export declare function resetPhrase(resetsLabel: string): string; /** The sentence a screen reader hears for one meter. */ export declare function usageAccessibleText({ label, percent, measure, valueLabel, resetsLabel, lowAt, }: { label: string; percent: number | null | undefined; measure?: "left" | "used" | undefined; valueLabel?: string | undefined; resetsLabel?: string | undefined; lowAt?: number | undefined; }): string; export interface UsageMeterProps { /** "Weekly", "5-hour", "Memory". Never abbreviated. */ label: string; /** 0-100, or null when the provider hasn't reported a reading. */ percent: number | null; /** What `percent` measures. Quotas count what's left; machines count what's used. */ measure?: "left" | "used" | undefined; /** Overrides the value text, for example "5.1 of 16 GB". */ valueLabel?: string | undefined; /** Explicit provider rejection, independent of a missing or approximate percentage. */ limitReached?: boolean | undefined; /** Formatted reset time, "Mon 28 Sep, 09:00". */ resetsLabel?: string | undefined; /** A (bar, default), B (text) or C (ring). */ variant?: UsageMeterVariant | undefined; /** "full" in a sheet, "compact" in a row. */ density?: UsageMeterDensity | undefined; /** Share left below which the meter turns red. Default 10. */ lowAt?: number | undefined; loading?: boolean | undefined; className?: string | undefined; } /** One quota window. */ export declare function UsageMeter({ label, percent, measure, valueLabel, limitReached, resetsLabel, variant, density, lowAt, loading, className, }: UsageMeterProps): import("react").JSX.Element; /** * The usage readout at the end of an account row: "78% left this week" and a * 64px bar, right-aligned so it sits against the row's chevron, and under it * when the limits reset: "Resets Thu 09:00 ยท 5-hour 14:20". Without a reading * it says why in words ("No usage yet"). Where the row folds its facts into * the meta line (narrow lists), only the words stay. */ export declare function UsageReadout({ percent, window: windowLabel, resets, loading, fallback, limitReached, now: fixedNow, className, }: { /** Share left, 0-100, or null when there is no reading. */ percent: number | null; /** How the window reads after "left": "this week", "this period". */ window: string; /** * When the account's limits reset, the shown window's first (no label), * then any other window by name. Times already past are left out. */ resets?: readonly UsageReset[] | undefined; loading?: boolean | undefined; /** Words for a missing reading: "No usage yet", "Usage unavailable". */ fallback?: string | undefined; limitReached?: boolean | undefined; /** The clock reset times are read against. Defaults to the shared minute clock. */ now?: number | undefined; className?: string | undefined; }): import("react").JSX.Element; /** When one quota window resets. Without a label it is the window the readout shows. */ export interface UsageReset { label?: string | undefined; at: DateInput; } /** * A readout's resets from an account's windows: the shown window first, then * the others that report a reset, in their given order. A window resetting * in the same minute as an earlier one adds nothing and is left out. */ export declare function usageResets(readings: readonly UsageWindowReading[], shown: string): UsageReset[]; export interface UsageWindowReading { label: string; percent: number | null; resetsLabel?: string | undefined; /** The reset time `resetsLabel` formats, for places that format it themselves. */ resetsAt?: number | undefined; limitReached?: boolean | undefined; valueLabel?: string | undefined; } export interface UsageMeterGroupProps { windows: UsageWindowReading[]; variant?: UsageMeterVariant | undefined; density?: UsageMeterDensity | undefined; /** "Checked just now". Pass a RelativeTime for the exact time on hover. */ checked?: ReactNode | undefined; /** Shows a refresh button next to `checked`. */ onRefresh?: (() => void) | undefined; refreshing?: boolean | undefined; /** Disables the refresh button and explains why, for example a reconnect. */ refreshDisabledReason?: ReactNode | undefined; /** Replaces the footer line when the last check failed. */ error?: ReactNode | undefined; loading?: boolean | undefined; className?: string | undefined; } /** * Every window of one account: stacked in a sheet, inline in a row. The * footer carries when it was checked and a refresh button. */ export declare function UsageMeterGroup({ windows, variant, density, checked, onRefresh, refreshing, refreshDisabledReason, error, loading, className, }: UsageMeterGroupProps): import("react").JSX.Element;