// engine/compliance-test-generator/control-mapper.ts — SPEC-390: Maps criteria to compliance controls
import { SOC2_CONTROLS } from './frameworks/soc2.js';
import { PCI_DSS_CONTROLS } from './frameworks/pci-dss.js';
import { ISO_42001_CONTROLS } from './frameworks/iso42001.js';
export function getControlsForFrameworks(frameworks) {
    const controls = [];
    for (const fw of frameworks) {
        if (fw === 'soc2') {
            controls.push(...SOC2_CONTROLS);
        }
        else if (fw === 'pci-dss') {
            controls.push(...PCI_DSS_CONTROLS);
        }
        else if (fw === 'iso-42001') {
            controls.push(...ISO_42001_CONTROLS);
        }
        // hipaa and gdpr: no built-in controls yet — extensible via future framework files
    }
    return controls;
}
export function mapCriteriaToControls(criteria, frameworks) {
    const allControls = getControlsForFrameworks(frameworks);
    const mapped = [];
    for (const criterion of criteria) {
        const lowerCriterion = criterion.toLowerCase();
        for (const control of allControls) {
            const matchedKeywords = control.keywords.filter((kw) => lowerCriterion.includes(kw));
            if (matchedKeywords.length >= 1) {
                mapped.push({
                    control,
                    criterion,
                    testCode: '', // filled by formatter
                    rationale: `Criterion mentions: ${matchedKeywords.join(', ')}`,
                });
                break; // one control per criterion
            }
        }
    }
    return mapped;
}
//# sourceMappingURL=control-mapper.js.map