import React from 'react'; import { strategies } from './data/strategies'; type GroupedStrategies = Record; const categoryOrder: (typeof strategies)[number]['category'][] = [ 'Static (Single-Turn)', 'Dynamic (Single-Turn)', 'Multi-turn', 'Regression', 'Custom', ]; const groupedStrategies = strategies.reduce((acc, strategy) => { if (!acc[strategy.category]) { acc[strategy.category] = []; } acc[strategy.category].push(strategy); return acc; }, {}); Object.values(groupedStrategies).forEach((categoryStrategies) => { categoryStrategies.sort((a, b) => a.displayName.localeCompare(b.displayName)); }); const RecommendedBadge = () => ( Recommended ); interface StrategyTableProps { shouldRenderCategory?: boolean; shouldRenderStrategy?: boolean; shouldRenderDescription?: boolean; shouldRenderLongDescription?: boolean; shouldRenderCost?: boolean; shouldRenderAsrIncrease?: boolean; showRemoteStatus?: boolean; } const StrategyTable = ({ shouldRenderCategory = true, shouldRenderStrategy = true, shouldRenderDescription = true, shouldRenderLongDescription = true, shouldRenderCost = true, shouldRenderAsrIncrease = true, showRemoteStatus = false, }: StrategyTableProps) => { return (
{shouldRenderCategory && ( )} {shouldRenderStrategy && } {shouldRenderDescription && } {shouldRenderLongDescription && } {shouldRenderCost && } {shouldRenderAsrIncrease && ( )} {categoryOrder.map((category) => { const categoryStrategies = groupedStrategies[category] || []; return ( {categoryStrategies.map((strategy, index) => ( {index === 0 && shouldRenderCategory && ( )} {shouldRenderStrategy && ( )} {shouldRenderDescription && ( )} {shouldRenderLongDescription && ( )} {shouldRenderCost && } {shouldRenderAsrIncrease && ( )} ))} ); })}
CategoryStrategyDescriptionDetailsCost ASR Increase *
{category} {strategy.link ? ( {strategy.displayName} {strategy.recommended && } ) : ( <> {strategy.displayName} {strategy.recommended && } )} {strategy.description} {showRemoteStatus && strategy.isRemote && ( 🌐 )} {strategy.longDescription}{strategy.cost}{strategy.asrIncrease}
{shouldRenderAsrIncrease && (
* ASR Increase: Relative increase in Attack Success Rate compared to running the same test without any strategy
)}
); }; export default StrategyTable;