33 lines
889 B
TypeScript
33 lines
889 B
TypeScript
export const LIMIT_LABELS: Record<string, string> = {
|
|
five_hour: "5-hour",
|
|
overage: "overage",
|
|
seven_day: "7-day",
|
|
seven_day_opus: "7-day · Opus",
|
|
seven_day_sonnet: "7-day · Sonnet",
|
|
};
|
|
|
|
const SEVEN_DAY = "seven_day_";
|
|
|
|
export function limitLabel(window: string): string {
|
|
const known = LIMIT_LABELS[window];
|
|
if (known) {
|
|
return known;
|
|
}
|
|
if (window.startsWith(SEVEN_DAY)) {
|
|
const model = window.slice(SEVEN_DAY.length);
|
|
return `7-day · ${model.charAt(0).toUpperCase()}${model.slice(1)}`;
|
|
}
|
|
return window.replaceAll("_", " ");
|
|
}
|
|
|
|
// The status as a word, for the windows the API never puts a figure on.
|
|
export const LIMIT_WORDS: Record<string, string> = {
|
|
allowed: "clear",
|
|
allowed_warning: "near the limit",
|
|
rejected: "rejected",
|
|
};
|
|
|
|
export function limitWord(status: string): string {
|
|
return LIMIT_WORDS[status] ?? status.replace("_", " ");
|
|
}
|