"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RelationshipEngine = void 0;
const RELATED_CATEGORIES = {
    variable_declaration: ['type_annotation', 'modifier_change'],
    type_annotation: ['variable_declaration', 'null_safety'],
    error_handling: ['async_await', 'null_safety', 'logging'],
    async_await: ['error_handling', 'function_style'],
    function_style: ['async_await', 'structural'],
    string_style: ['template_literal', 'destructuring'],
    null_safety: ['error_handling', 'type_annotation'],
    import_change: ['structural', 'modifier_change'],
    testing: ['error_handling', 'performance'],
    security: ['error_handling', 'testing'],
    performance: ['testing', 'state_management'],
    logging: ['error_handling', 'testing'],
};
const CONFLICTING_CATEGORIES = {
    variable_declaration: ['variable_declaration'],
    function_style: ['function_style'],
    string_style: ['string_style'],
    naming: ['naming'],
};
class RelationshipEngine {
    buildRelationships(patternId, category, from, to, allPatterns) {
        const related = [];
        const conflicting = [];
        const complementary = [];
        const dependencies = [];
        const relatedCats = RELATED_CATEGORIES[category] || [];
        const conflictCats = CONFLICTING_CATEGORIES[category] || [];
        for (const other of allPatterns) {
            if (other.patternId === patternId)
                continue;
            if (relatedCats.includes(other.category)) {
                related.push(other.patternId);
            }
            if (conflictCats.includes(other.category) && other.from === from && other.to !== to) {
                conflicting.push(other.patternId);
            }
            if (other.category === category && other.from !== from && other.to === to) {
                complementary.push(other.patternId);
            }
            if (this.isDependency(category, other.category)) {
                dependencies.push(other.patternId);
            }
        }
        return {
            related: [...new Set(related)],
            conflicting: [...new Set(conflicting)],
            complementary: [...new Set(complementary)],
            dependencies: [...new Set(dependencies)],
        };
    }
    isDependency(catA, catB) {
        const depMap = {
            async_await: ['function_style', 'error_handling'],
            error_handling: ['null_safety'],
            destructuring: ['variable_declaration'],
            testing: ['function_style', 'error_handling'],
        };
        return (depMap[catA] || []).includes(catB);
    }
}
exports.RelationshipEngine = RelationshipEngine;
//# sourceMappingURL=pattern-relationships.js.map