'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * ContributorOnboardingView — client wrapper that composes the four
 * contributor onboarding components (LaneChooser, CuratedIssuesList,
 * DoctorSummary, ContributorLeaderboard) and drives the lane → curated
 * issues interaction via a server action (spec 097, task-47).
 */
import { useState, useTransition } from 'react';
import { LaneChooser } from './LaneChooser.js';
import { CuratedIssuesList } from './CuratedIssuesList.js';
import { DoctorSummary } from './DoctorSummary.js';
import { ContributorLeaderboard } from './ContributorLeaderboard.js';
import { loadCuratedIssues } from '../../app/actions/load-curated-issues.js';
export function ContributorOnboardingView({ initialLeaderboard, initialDoctorReport, doctorError, }) {
    const [lane, setLane] = useState(undefined);
    const [issues, setIssues] = useState([]);
    const [issuesError, setIssuesError] = useState(undefined);
    const [pending, startTransition] = useTransition();
    function handleLaneChange(next) {
        setLane(next);
        setIssuesError(undefined);
        startTransition(async () => {
            const result = await loadCuratedIssues(next);
            if (result.error) {
                setIssues([]);
                setIssuesError(result.error);
            }
            else {
                setIssues(result.issues ?? []);
            }
        });
    }
    return (_jsxs("div", { className: "flex flex-col gap-8", "data-testid": "contributor-onboarding-view", children: [_jsxs("header", { className: "flex flex-col gap-2", children: [_jsx("h1", { className: "text-2xl font-semibold", children: "Contribute to Shep" }), _jsx("p", { className: "text-muted-foreground max-w-2xl text-sm", children: "Pick a lane that matches what you want to work on. Shep will list curated good-first-issues you can ship in under 30 minutes \u2014 and run a quick environment check so your fresh clone actually builds." })] }), _jsxs("section", { className: "flex flex-col gap-3", "data-testid": "contributor-pick-issue", children: [_jsx(LaneChooser, { value: lane, onLaneChange: handleLaneChange }), lane ? (_jsx(CuratedIssuesList, { issues: issues, loading: pending, error: issuesError })) : (_jsx("p", { className: "text-muted-foreground rounded-lg border border-dashed p-4 text-sm", "data-testid": "contributor-pick-issue-prompt", children: "Choose a lane to see curated issues." }))] }), _jsx(DoctorSummary, { report: initialDoctorReport }), doctorError ? (_jsxs("p", { className: "text-muted-foreground text-xs", "data-testid": "doctor-summary-fallback", children: ["Environment check unavailable: ", doctorError] })) : null, _jsx(ContributorLeaderboard, { scope: initialLeaderboard.scope, entries: initialLeaderboard.entries, error: initialLeaderboard.error })] }));
}
