import type { Difficulty, MachineCategory, ReleasePhase } from '@/types/catalogue'; export function formatNumber(value: number): string { return new Intl.NumberFormat('en', { maximumFractionDigits: 0 }).format(value); } export function pluralize(count: number, singular: string, plural = `${singular}s`): string { return `${formatNumber(count)} ${count === 1 ? singular : plural}`; } export function partCountLabel(count: number): string { return pluralize(count, 'part'); } export function difficultyToTone( difficulty: Difficulty, ): 'success' | 'warm' | 'accent' | 'neutral' { switch (difficulty) { case 'Beginner': return 'success'; case 'Intermediate': return 'warm'; case 'Advanced': return 'accent'; default: return 'neutral'; } } export function difficultyDescription(difficulty: Difficulty): string { switch (difficulty) { case 'Beginner': return 'Conceptual model with accessible motion and minimal prerequisites.'; case 'Intermediate': return 'Requires comfort with basic kinematics, pressure, or gear terminology.'; case 'Advanced': return 'Multi-domain system with coupled timing, flow, thermal, or control effects.'; default: return 'Engineering reference difficulty.'; } } export function phaseLabel(phase: ReleasePhase): string { return phase === 'core' ? 'Core' : 'Stretch'; } export function phaseDescription(phase: ReleasePhase): string { return phase === 'core' ? 'Part of the Phase 1 machine catalogue.' : 'Architecture-supported stretch machine for later 3D expansion.'; } export function categoryToSlug(category: MachineCategory): string { return category .toLowerCase() .replace(/&/g, 'and') .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, ''); } export function categoryShortLabel(category: MachineCategory): string { switch (category) { case 'Gearboxes & Drives': return 'Drives'; case 'Pumps & Fluid Systems': return 'Fluids'; case 'Structural / Other': return 'Structural'; default: return category; } }