"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.renderImpactAnalysisJson = renderImpactAnalysisJson;
exports.renderImpactAnalysisMarkdown = renderImpactAnalysisMarkdown;
function renderStringList(values) {
    if (values.length === 0) {
        return '- (none)';
    }
    return values.map((value) => `- ${value}`).join('\n');
}
function renderImpactAnalysisJson(model) {
    return `${JSON.stringify(model, null, 2)}\n`;
}
function renderImpactAnalysisMarkdown(model) {
    const riskModules = model.riskModules.length === 0
        ? '- (none)'
        : model.riskModules
            .map((entry) => `- ${entry.moduleName} | in=${entry.incomingDependencyCount}, out=${entry.outgoingDependencyCount} | ${entry.reasons.join(', ')}`)
            .join('\n');
    const suggestedFiles = model.suggestedFilesToInspect.length === 0
        ? '- (none)'
        : model.suggestedFilesToInspect
            .map((entry) => `- ${entry.path} (${entry.kind}, ${entry.exists ? 'exists' : 'missing'})`)
            .join('\n');
    const notes = model.notes.length === 0 ? '- (none)' : model.notes.map((note) => `- ${note}`).join('\n');
    const impactedSurface = model.impact.affectedSurface;
    const factors = model.impact.factors.length === 0
        ? '- (none)'
        : model.impact.factors
            .map((factor) => `- ${factor.id} | ${factor.label} | ${factor.category} | weight=${factor.weight}`)
            .join('\n');
    const dependencyChains = [
        ...model.impact.directDependencyChains.map((entry) => entry.chain.join(' -> ')),
        ...model.impact.transitiveDependencyChains.map((entry) => entry.chain.join(' -> ')),
    ];
    const reasoning = model.impact.reasoning.length === 0
        ? '- (none)'
        : model.impact.reasoning
            .map((entry) => `- ${entry.id} | ${entry.type} | ${entry.evidence}`)
            .join('\n');
    return `# ArchPilot Architecture Impact Analysis

- Project: ${model.projectName}
- Generated at (UTC): ${model.generatedAtUtc}
- Report version: ${model.reportVersion}

## Target
- Requested target: ${model.target}
- Module resolved: ${model.moduleResolved ? 'yes' : 'no'}
- Resolution mode: ${model.resolutionMode}
- Detected module: ${model.module ?? '(unresolved)'}
- Modules discovered: ${model.modulesDiscovered}

## Dependents
### Direct Dependents
${renderStringList(model.directDependents)}

### Transitive Dependents
${renderStringList(model.transitiveDependents)}

## Module Dependencies
${renderStringList(model.dependencies)}

## Impact Summary
- Impact level: ${model.impact.impactLevel}
- Impact score: ${model.impact.impactRadiusScore}
- Summary: ${model.impact.summary}
- Scoring formula: ${model.impact.scoring.formula}
- Scoring components:
  - changedModules=${model.impact.scoring.components.changedModules}
  - directlyAffectedModules=${model.impact.scoring.components.directlyAffectedModules}
  - transitivelyAffectedModules=${model.impact.scoring.components.transitivelyAffectedModules}
  - governanceSurfaceItems=${model.impact.scoring.components.governanceSurfaceItems}
  - maxTransitiveChainDepth=${model.impact.scoring.components.maxTransitiveChainDepth}

## Affected Surface
- Changed modules: ${impactedSurface.changedModules.join(', ') || '(none)'}
- Directly affected modules: ${impactedSurface.directlyAffectedModules.join(', ') || '(none)'}
- Transitively affected modules: ${impactedSurface.transitivelyAffectedModules.join(', ') || '(none)'}
- Impacted contracts: ${impactedSurface.impactedContracts.join(', ') || '(none)'}
- Impacted public entrypoints: ${impactedSurface.impactedPublicEntrypoints.join(', ') || '(none)'}
- Impacted ADRs: ${impactedSurface.impactedAdrs.join(', ') || '(none)'}
- Impacted architecture artifacts: ${impactedSurface.impactedArchitectureArtifacts.join(', ') || '(none)'}

## Dependency Chains
${dependencyChains.length === 0 ? '- (none)' : dependencyChains.map((entry) => `- ${entry}`).join('\n')}

## Impact Factors
${factors}

## Impact Reasoning
${reasoning}

## Cycle and Orphan Status
- Participates in cycle: ${model.inCycle ? 'yes' : 'no'}
- Orphan: ${model.orphan ? 'yes' : 'no'}

## Potential Architecture Risks
${riskModules}

## Suggested Modules To Review
${renderStringList(model.suggestedModulesToReview)}

## Suggested Files To Inspect
${suggestedFiles}

## Notes
${notes}
`.trimEnd() + '\n';
}
//# sourceMappingURL=impactAnalysisReporter.js.map