import type { TextSegment } from './utils';
import type { Card } from '$lib/config';

export type LineType = 
	| 'command' | 'output' | 'prompt' | 'error' | 'success' | 'info' | 'warning'
	| 'image' | 'blank' | 'header' | 'button' | 'divider' | 'link'
	| 'card' | 'progress' | 'accordion' | 'table' | 'tooltip' | 'cardgrid';

export interface TerminalLine {
	type: LineType;
	content: string;
	delay?: number;
	image?: string;
	imageAlt?: string;
	imageWidth?: number;
	// For button and link types
	action?: () => void;
	href?: string;
	icon?: string;
	external?: boolean; // Opens in new tab
	// For styling
	style?: 'primary' | 'secondary' | 'accent' | 'warning' | 'error';
	// For card type
	cardTitle?: string;
	cardFooter?: string;
	// For progress type
	progress?: number; // 0-100
	progressLabel?: string;
	// For accordion type
	accordionOpen?: boolean;
	accordionItems?: { title: string; content: string }[];
	// For table type
	tableHeaders?: string[];
	tableRows?: string[][];
	// For tooltip type
	tooltipText?: string;
	tooltipPosition?: 'top' | 'bottom' | 'left' | 'right';
	// For cardgrid type
	cards?: Card[];
}

// Pre-parsed line with segments ready for rendering
export interface ParsedLine {
	line: TerminalLine;
	segments: TextSegment[];
	plainText: string;  // Plain text without color codes for length calculation
}

// Display state for a line during typing animation
export interface DisplayedLine {
	parsed: ParsedLine;
	charIndex: number;  // How many plain-text characters to show
	complete: boolean;
	showImage: boolean;
}
