/** * Colours and width-safe text helpers. * * The chrome follows the active theme. The few colours that come from the brand (see brand.ts) * are the primary mark colour, the plan-mode colour, a quiet neutral, and the two surface shades. */ import type { Theme } from "@earendil-works/pi-coding-agent"; import { type Color } from "@earendil-works/pi-tui"; import type { WidgetColor, WidgetLevel } from "./api.ts"; import { type BrandColors, type BrandSurfaces } from "./brand.ts"; /** Parse a colour string once; an unusable value falls back to `fallback`. */ export declare function toColor(value: string, fallback?: string): Color; /** A brand colour, parsed. */ export declare const brandColor: (name: keyof BrandColors) => Color; /** Paint text with a concrete colour, honouring the theme's colour mode (truecolor/256). */ export declare function paint(theme: Theme, color: Color, text: string): string; /** True under a light theme. A theme without an `appearance` (a test double) counts as dark. */ export declare const isLight: (theme: Theme) => boolean; /** WCAG contrast ratio of two colours, 1 to 21. */ export declare function contrast(a: Color, b: Color): number; /** * `color` moved along its own lightness (hue and saturation kept) until it has at least `min` * contrast against `bg`: darker on a light background, lighter on a dark one. A colour that is * readable already comes back as it is. On a background in the middle, where that direction cannot * reach `min`, the other direction is tried; failing both, black or white, whichever reads better. */ export declare function readableOn(color: Color, bg: Color, min?: number): Color; /** * A brand or widget colour used as text. On a light theme it is darkened until it can be read on the * surfaces; on a dark theme it is used as given, which is how the brand colours were chosen. */ export declare const textColor: (theme: Theme, color: Color) => Color; /** Text in the brand's primary colour: the active-mode mark, the brand glyph, the header art. */ export declare const primary: (theme: Theme, text: string) => string; /** * One frame of the working spinner: the glyph in the brand's primary colour, so it follows whatever * brand is installed. A primary colour that cannot be parsed falls back to the theme's accent. */ export declare function spinnerFrame(theme: Theme, glyph: string): string; /** Text in the brand's neutral colour. */ export declare const neutral: (theme: Theme, text: string) => string; /** Text in the plan-mode colour. */ export declare const planColor: (theme: Theme, text: string) => string; /** The brand mark and name: " ", or just the glyph. Painted; no version. */ export declare function brandMark(theme: Theme): string; /** " pi 1.1.0" (plus " ยท chassis 0.1.0" when given): the brand line on the home screen bottom bar and in the sidebar. */ export declare function brandLine(theme: Theme, version: string, chassisVersion?: string): string; /** * Surface shades, OpenCode-style steps above the background (OpenCode: #0a0a0a, panel #141414, * element #1e1e1e): * panel sidebar, user messages, tool blocks * element the prompt box * The brand supplies the values: `surfaces` for a dark theme, `lightSurfaces` for a light one. A theme should use the same ones for userMessageBg, * toolSuccessBg and customMessageBg, so pi's own blocks match ours. */ export type Surface = keyof BrandSurfaces; export declare const surfaceColor: (theme: Theme, surface: Surface) => Color; export declare const surfaceBg: (theme: Theme, surface: Surface) => string; /** * Paint a line on a surface background across exactly `width` columns. Resets inside the line * (\x1b[0m, \x1b[49m) would end the shading early, so the background is re-applied after each. */ export declare function shade(theme: Theme, line: string, width: number, surface?: Surface): string; /** Resolve a widget colour (theme token, brand colour or hex) and paint text with it. */ export declare function widgetPaint(theme: Theme, color: WidgetColor | undefined, level: WidgetLevel | undefined, text: string): string; /** Pad or truncate a (possibly styled) line to exactly `width` columns. */ export declare function fit(line: string, width: number): string; export { sanitize, sanitizeKeepColor, sanitizeLines, scrubText, stripEscapes } from "./sanitize.ts"; /** True if a string sets its own foreground colour. */ export declare function hasOwnColor(text: string): boolean; export declare function fmtTokens(n: number): string; export declare function fmtDuration(ms: number): string; /** "just now", "5m ago", "3h ago", "2d ago", "6w ago". */ export declare function fmtAgo(ms: number): string; /** * `path` as shown on screen: the home directory written as `~`, and escape sequences and control * characters removed, because a directory name is chosen by whoever made the directory. Uses the OS * home directory (HOME on Unix, the user profile on Windows) and accepts either path separator * after it. */ export declare function homeRelative(path: string): string; /** Index of the last path separator ("/" or "\\"), or -1. */ export declare function lastSep(path: string): number; export declare const finite: (v: unknown) => number;