import { type PaletteName, type PalettePreset, type PowerlineBlockName, SEGMENT_NAMES, type SegmentName, type SegmentPalette, } from "../types.js"; import { CANDY_PRESET } from "./candy.js"; import { CUSTOM_PRESET } from "./custom.js"; import { FOREST_PRESET } from "./forest.js"; import { MONO_PRESET } from "./mono.js"; import { NEON_PRESET } from "./neon.js"; import { OCEAN_PRESET } from "./ocean.js"; import { SUNSET_PRESET } from "./sunset.js"; import { TOKYO_NIGHT_PRESET } from "./tokyo-night.js"; import type { PowerlinePreset } from "./types.js"; const CLASSIC_PRESET: PowerlinePreset = { blocks: { header: {}, directory: {}, git: {}, runtime: {}, meter: {}, }, extensionSeparator: "", }; const PRESETS = { classic: CLASSIC_PRESET, "tokyo-night": TOKYO_NIGHT_PRESET, ocean: OCEAN_PRESET, sunset: SUNSET_PRESET, forest: FOREST_PRESET, candy: CANDY_PRESET, neon: NEON_PRESET, mono: MONO_PRESET, custom: CUSTOM_PRESET, } satisfies Record; const SEGMENT_BLOCKS: Record = { brand: "header", provider: "header", model: "header", thinking: "header", cwd: "directory", branch: "git", tools: "runtime", context: "runtime", tokens: "runtime", cache: "runtime", cost: "meter", time: "meter", turn: "meter", }; export function resolvePreset(preset: PalettePreset): PowerlinePreset { return PRESETS[preset]; } export function segmentPaletteForPreset(preset: PaletteName): SegmentPalette { const blocks = PRESETS[preset].blocks; return Object.fromEntries(SEGMENT_NAMES.map((name) => [name, { ...blocks[SEGMENT_BLOCKS[name]] }])) as SegmentPalette; }