/** * Progressive disclosure system, smart defaults, quick action definitions. * * Reduces cognitive load by surfacing only relevant UI sections and actions. * Pure client-side TS — no backend dependency. */ import type { ProgressiveSection, QuickAction, SmartDefault } from './types.js'; export const MAX_VISIBLE_ITEMS = 3; export const MAX_VISIBLE_LIST = 5; export function getVisibleSections( sections: ProgressiveSection[], expandedIds: Set ): ProgressiveSection[] { return sections.filter( s => s.defaultExpanded || expandedIds.has(s.id) || s.priority === 'primary' ); } export function getAvailableActions( actions: QuickAction[], context: { isActive?: boolean; isAuthenticated?: boolean } ): QuickAction[] { return actions.filter(a => { if (a.requiresAuth && !context.isAuthenticated) return false; return true; }); } export function pickSmartDefault(candidates: SmartDefault[]): SmartDefault | null { if (candidates.length === 0) return null; const priority: SmartDefault['source'][] = [ 'last_used', 'most_common', 'recommendation', 'system', ]; for (const source of priority) { const match = candidates.find(c => c.source === source); if (match) return match; } return candidates[0]; }