import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * ProgressList — Reusable task checklist with status icons.
 * Extracted from StatusTab logic.
 */
import { Box, Text } from 'ink';
import { Spinner } from '@inkjs/ui';
import { Colors, Icons } from '../styles.js';
import { LoadingBox } from './LoadingBox.js';
export const ProgressList = ({ items, title }) => {
    const completed = items.filter((t) => t.status === 'completed').length;
    const total = items.length;
    return (_jsxs(Box, { flexDirection: "column", children: [title && (_jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: title }), _jsx(Box, { height: 1 })] })), items.length === 0 && _jsx(LoadingBox, { message: "Analyzing project..." }), items.map((item, i) => {
                const icon = item.status === 'completed'
                    ? Icons.squareFilled
                    : item.status === 'in_progress'
                        ? Icons.triangleRight
                        : Icons.squareOpen;
                const color = item.status === 'completed'
                    ? Colors.success
                    : item.status === 'in_progress'
                        ? Colors.primary
                        : Colors.muted;
                const label = item.status === 'in_progress' && item.activeForm
                    ? item.activeForm
                    : item.label;
                return (
                // Icon and label live in separate boxes so wrapped label lines
                // hang-indent under the first label character instead of resetting
                // to column 0 (which broke the visual hierarchy on long labels).
                _jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { flexShrink: 0, children: _jsxs(Text, { color: color, children: [icon, " "] }) }), _jsx(Box, { flexGrow: 1, flexShrink: 1, children: _jsx(Text, { color: item.status === 'pending' ? Colors.muted : undefined, children: label }) })] }, i));
            }), total > 0 && (_jsxs(Box, { marginTop: 1, gap: 1, children: [completed < total && _jsx(Spinner, {}), _jsxs(Text, { color: Colors.muted, children: ["Progress: ", completed, "/", total, " completed"] })] }))] }));
};
