"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatternValidator = void 0;
const types_1 = require("../types");
class PatternValidator {
    validate(category, from, to, language) {
        const errors = [];
        const warnings = [];
        if (!category || category.trim().length === 0) {
            errors.push('Category is empty');
        }
        else if (!types_1.VALID_CATEGORIES.includes(category)) {
            warnings.push(`Unknown category: "${category}"`);
        }
        if (!from || from.trim().length === 0) {
            errors.push('Source pattern ("from") is empty');
        }
        if (!to || to.trim().length === 0) {
            errors.push('Target pattern ("to") is empty');
        }
        if (from === to) {
            warnings.push('Source and target are identical');
        }
        if (language && !types_1.VALID_LANGUAGES.includes(language.toLowerCase())) {
            warnings.push(`Unknown language: "${language}"`);
        }
        if (category && category.length > 100) {
            errors.push('Category exceeds 100 characters');
        }
        if (from && from.length > 500) {
            errors.push('Source pattern exceeds 500 characters');
        }
        if (to && to.length > 500) {
            errors.push('Target pattern exceeds 500 characters');
        }
        return {
            valid: errors.length === 0,
            errors,
            warnings,
        };
    }
    isDuplicate(category, from, to, existingPatterns) {
        return existingPatterns.some((p) => p.category === category && p.from === from && p.to === to);
    }
}
exports.PatternValidator = PatternValidator;
//# sourceMappingURL=pattern-validator.js.map