"use client" import { useState } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { Badge } from "@/components/ui/badge" import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip" import { Brain, Shield, HelpCircle } from "lucide-react" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" interface Category { id: string name: string type: "capability" | "risk" description: string } interface CategorySelectionProps { categories: Category[] selectedCategories: string[] onSelectionChange: (categories: string[], excludedReasons: Record) => void } export function CategorySelection({ categories, selectedCategories, onSelectionChange }: CategorySelectionProps) { const allCategoryIds = categories.map((c) => c.id) const [localSelection, setLocalSelection] = useState( selectedCategories && selectedCategories.length > 0 ? selectedCategories : allCategoryIds, ) const [localReasons, setLocalReasons] = useState>({}) const capabilityCategories = categories.filter((c) => c.type === "capability") const riskCategories = categories.filter((c) => c.type === "risk") const handleCategoryToggle = (categoryId: string, checked: boolean) => { setLocalSelection((prev) => { if (checked) { // if re-selecting, remove any existing reason setLocalReasons((r) => { const copy = { ...r } delete copy[categoryId] return copy }) return [...prev, categoryId] } // when unselecting, initialize an empty reason entry to make it required setLocalReasons((r) => ({ ...r, [categoryId]: r[categoryId] || "" })) return prev.filter((id) => id !== categoryId) }) } const handleSelectAll = (type: "capability" | "risk") => { const categoryIds = categories.filter((c) => c.type === type).map((c) => c.id) const allSelected = categoryIds.every((id) => localSelection.includes(id)) if (allSelected) { // deselect these categories and initialize empty reasons for them setLocalSelection((prev) => { const next = prev.filter((id) => !categoryIds.includes(id)) setLocalReasons((r) => { const copy = { ...r } categoryIds.forEach((id) => { if (!(id in copy)) copy[id] = "" }) return copy }) return next }) } else { setLocalSelection((prev) => { // when selecting these, remove any reasons for them setLocalReasons((r) => { const copy = { ...r } categoryIds.forEach((id) => delete copy[id]) return copy }) return [...new Set([...prev, ...categoryIds])] }) } } const handleContinue = () => { onSelectionChange(localSelection, localReasons) } return (
Category Applicability Assessment Select which categories are applicable to your AI system. Only complete the detailed evaluation for categories marked as applicable.
Selected Categories: {localSelection.length}/20
{/* Capability Categories */}
Capability Categories
Core functional capabilities and performance areas
{capabilityCategories.map((category) => (
handleCategoryToggle(category.id, checked as boolean)} />

{category.description}

{/* If unchecked, require a reason */} {!localSelection.includes(category.id) && (