import type { ReactNode } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card"; import { Badge } from "../components/ui/badge"; import type { CtePlanCte, CtePlanFilter, CtePlanV2 } from "./artifactV2"; const CHIP = "rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground/90"; function Chip({ children }: { children: ReactNode }) { return {children}; } function FilterChip({ filter }: { filter: CtePlanFilter }) { return (
{filter.column} {filter.op} {filter.value} {filter.description &&

{filter.description}

} {filter.rationale &&

{filter.rationale}

}
); } function CteCard({ cte, total }: { cte: CtePlanCte; total: number }) { const dependsOn = cte.depends_on ?? []; return (
CTE {cte.index}/{total} {cte.name}
{cte.purpose &&

{cte.purpose}

}

Depends on

{dependsOn.length ? (
{dependsOn.map((d) => ( {d} ))}
) : (

no dependencies

)}
{cte.tables && cte.tables.length > 0 && (

Tables

{cte.tables.map((t) => (
{t.name} {t.description && (

{t.description}

)}
))}
)} {cte.keys && cte.keys.length > 0 && (

Keys

{cte.keys.map((k) => ( {k} ))}
)} {cte.filters && cte.filters.length > 0 && (

Filters

{cte.filters.map((f, i) => ( ))}
)} {cte.output_columns && cte.output_columns.length > 0 && (

Output columns

{cte.output_columns.map((c) => ( {c} ))}
)} {cte.rationale && (

Rationale

{cte.rationale}

)}
); } export function CtePlanViewer({ plan }: { plan: CtePlanV2 }) { return (
{plan.question &&

{plan.question}

} {plan.strategy &&

{plan.strategy}

}
{plan.ctes.map((c, i) => ( {i > 0 && } {c.name} ))}
{plan.ctes.map((cte) => ( ))}
); }