/**
 * Thresholds for complexity categories.
 * Each tier is inclusive on the lower bound.
 */
const THRESHOLDS = {
    trivial: { maxCriteria: 0, maxHours: 1, maxFiles: 1 },
    small: { maxCriteria: 5, maxHours: 4, maxFiles: 3 },
    medium: { maxCriteria: 12, maxHours: 16, maxFiles: 10 },
    // large: anything above medium
};
/**
 * Derives the complexity category from the dominant metric.
 * Uses "worst case wins": the highest severity score among the three metrics
 * determines the final category.
 */
function deriveCategory(criteriaCount, estimatedHours, filesToModify) {
    const scores = [
        scoreCriteria(criteriaCount),
        scoreHours(estimatedHours),
        scoreFiles(filesToModify),
    ];
    const maxScore = Math.max(...scores);
    if (maxScore === 0) {
        return 'trivial';
    }
    if (maxScore === 1) {
        return 'small';
    }
    if (maxScore === 2) {
        return 'medium';
    }
    return 'large';
}
function scoreCriteria(count) {
    if (count <= THRESHOLDS.trivial.maxCriteria) {
        return 0;
    }
    if (count <= THRESHOLDS.small.maxCriteria) {
        return 1;
    }
    if (count <= THRESHOLDS.medium.maxCriteria) {
        return 2;
    }
    return 3;
}
function scoreHours(hours) {
    if (hours <= THRESHOLDS.trivial.maxHours) {
        return 0;
    }
    if (hours <= THRESHOLDS.small.maxHours) {
        return 1;
    }
    if (hours <= THRESHOLDS.medium.maxHours) {
        return 2;
    }
    return 3;
}
function scoreFiles(files) {
    if (files <= THRESHOLDS.trivial.maxFiles) {
        return 0;
    }
    if (files <= THRESHOLDS.small.maxFiles) {
        return 1;
    }
    if (files <= THRESHOLDS.medium.maxFiles) {
        return 2;
    }
    return 3;
}
function buildReasoning(category, criteriaCount, estimatedHours, filesToModify) {
    const label = category.charAt(0).toUpperCase() + category.slice(1);
    return `${label} spec: ${criteriaCount} criteria, ${estimatedHours}h estimated, ${filesToModify} file${filesToModify !== 1 ? 's' : ''} to modify.`;
}
/**
 * Categorizes a spec into trivial/small/medium/large based on its metrics.
 */
export function categorize(input) {
    const { criteriaCount, estimatedHours, filesToModify } = input;
    const effectiveFiles = Math.max(filesToModify, 1);
    const criteriaToFilesRatio = criteriaCount / effectiveFiles;
    const category = deriveCategory(criteriaCount, estimatedHours, filesToModify);
    const suggestBacklogIdea = category === 'trivial';
    return {
        category,
        criteriaToFilesRatio,
        reasoning: buildReasoning(category, criteriaCount, estimatedHours, filesToModify),
        suggestBacklogIdea,
    };
}
//# sourceMappingURL=categorizer.js.map