// engine/ears/pattern-matcher.ts — EARS pattern detection (SPEC-410)
// EARS pattern regexes (case-insensitive).
// Order matters: more specific patterns are tested before generic ones.
const EARS_PATTERN_CHECKS = [
    { pattern: 'conditional', regex: /\bif\b.+\bthen\b.+\bthe system shall\b/i },
    { pattern: 'event-driven', regex: /\bwhen\b.+\bthe system shall\b/i },
    { pattern: 'state-driven', regex: /\bwhile\b.+\bthe system shall\b/i },
    { pattern: 'optional', regex: /\bwhere\b.+\bthe system shall\b/i },
    { pattern: 'ubiquitous', regex: /\bthe system shall\b/i },
];
// Vagueness words that make criteria hard to test
const VAGUENESS_FLAGS = [
    'should',
    'easy',
    'fast',
    'user-friendly',
    'intuitive',
    'simple',
    'quickly',
    'efficiently',
    'nice',
    'good',
    'better',
    'appropriate',
    'suitable',
    'seamlessly',
    'ideally',
];
export function detectEarsPattern(criterion) {
    for (const { pattern, regex } of EARS_PATTERN_CHECKS) {
        if (regex.test(criterion)) {
            return pattern;
        }
    }
    return 'none';
}
export function detectVaguenessFlags(criterion) {
    const lower = criterion.toLowerCase();
    return VAGUENESS_FLAGS.filter((flag) => {
        // Match whole word to avoid false positives (e.g., "easily" vs "easy")
        const wordBoundary = new RegExp(`\\b${flag.replace('-', '[- ]')}\\b`, 'i');
        return wordBoundary.test(lower);
    });
}
export function isEarsCompliant(criterion) {
    return detectEarsPattern(criterion) !== 'none';
}
//# sourceMappingURL=pattern-matcher.js.map