import * as React from 'react'; import { LogItemType, LogItemWithMeta } from '../types.cjs'; import '../../tree-view/types.cjs'; /** * Custom hook for managing timeline waterfall state including item expansion, hover interactions, and hierarchical data processing. * * This hook processes log data into a hierarchical structure with parent-child relationships, manages which items * are expanded/collapsed, tracks hover states for visual feedback, and provides utilities for filtering visible items. * * @param logData - Array of log items representing timeline events. Each item can have: * - Basic properties: id, parentId, label, type, color, icon * - Timing data: time, createTime, startTime, duration * - Hierarchy: parentId (null for root items), isCollapsible flag * - Display: indent level for visual nesting * * @example * ```typescript * const logData = [ * { * id: "1", * parentId: null, * type: "task", * label: "generate-report", * startTime: 0, * duration: 20, * isCollapsible: true * }, * { * id: "2", * parentId: "1", * type: "step", * label: "Fetch database records", * startTime: 0.5, * duration: 3 * } * ]; * * const { * expandedItems, // Set of expanded item IDs * hoveredId, // Currently hovered item ID * toggleItem, // Function to expand/collapse items * logDataWithMeta, // Enhanced data with ancestry info * getVisibleLogData // Filter function for visible items * } = useTimelineState(logData); * ``` * * @returns Object containing: * - expandedItems: Set of item IDs that are currently expanded * - hoveredId: ID of currently hovered item (null if none) * - setHoveredId: Function to update hovered item * - toggleItem: Function to expand/collapse collapsible items * - logDataWithMeta: Enhanced log data with ancestor chain and position metadata * - getVisibleLogData: Function that filters data based on parent expansion state */ declare function useTimelineState(logData: LogItemType[]): { expandedItems: Set; hoveredId: string | null; setHoveredId: React.Dispatch>; toggleItem: (id: string) => void; logDataWithMeta: { isLast: boolean; ancestors: LogItemType[]; id: string; parentId: string | null; label: string; isCollapsible?: boolean; actions?: React.ReactNode; disable?: boolean; selectable?: boolean; etype: "task" | "attempt" | "info" | "step"; icon?: "history" | "file-code" | "bot" | "check-circle" | "pause-circle"; createTime?: number; startTime?: number; duration?: number; time?: number; color?: "blue" | "green" | "orange" | "gray-light" | "gray-medium" | "purple"; hasStripes?: boolean; isHaltedStep?: boolean; }[]; getVisibleLogData: (filteredData: LogItemWithMeta[]) => LogItemWithMeta[]; }; export { useTimelineState };