"use client"; import { useState } from "react"; import { AlertTriangle, CheckCircle, Clock, Cpu, ExternalLink, Tag } from "lucide-react"; import { BriefSchema, CitedPoint } from "@/lib/types"; import { formatDate } from "@/lib/utils"; interface AIBriefCardProps { brief?: BriefSchema | null; } function isCited(p: string | CitedPoint): p is CitedPoint { return typeof p === "object" && p !== null && "text" in p; } interface CitedItemProps { point: string | CitedPoint; icon: React.ReactNode; govinfo_url?: string; openKey: string; activeKey: string | null; setActiveKey: (key: string | null) => void; } function CitedItem({ point, icon, govinfo_url, openKey, activeKey, setActiveKey }: CitedItemProps) { const cited = isCited(point); const isOpen = activeKey === openKey; return (
  • {icon} {cited ? point.text : point} {cited && ( )}
    {cited && isOpen && (
    "{point.quote}"
    {govinfo_url && ( View source )}
    )}
  • ); } export function AIBriefCard({ brief }: AIBriefCardProps) { const [activeKey, setActiveKey] = useState(null); if (!brief) { return (

    AI Analysis

    Analysis not yet generated. It will appear once the bill text has been processed.

    ); } return (

    AI Analysis

    {brief.llm_provider}/{brief.llm_model} · {formatDate(brief.created_at)}
    {brief.summary && (

    Summary

    {brief.summary}

    )} {brief.key_points && brief.key_points.length > 0 && (

    Key Points

      {brief.key_points.map((point, i) => ( } govinfo_url={brief.govinfo_url} openKey={`kp-${i}`} activeKey={activeKey} setActiveKey={setActiveKey} /> ))}
    )} {brief.risks && brief.risks.length > 0 && (

    Risks & Concerns

      {brief.risks.map((risk, i) => ( } govinfo_url={brief.govinfo_url} openKey={`risk-${i}`} activeKey={activeKey} setActiveKey={setActiveKey} /> ))}
    )} {brief.deadlines && brief.deadlines.length > 0 && (

    Deadlines

      {brief.deadlines.map((d, i) => (
    • {d.date ? {formatDate(d.date)}: : ""} {d.description}
    • ))}
    )} {brief.topic_tags && brief.topic_tags.length > 0 && (
    {brief.topic_tags.map((tag) => ( {tag} ))}
    )}
    ); }