import { objectEntries } from "ts-extras";
/* eslint-disable security/detect-non-literal-regexp -- Rule options intentionally accept user-provided regex strings. */
/**
 * Compile ignore-option regex patterns into mode buckets.
 *
 * Invalid regex patterns are returned for caller-side reporting so rule
 * configuration issues are never swallowed silently.
 */
export const compileIgnorePatterns = (ignored) => {
    let namePatterns = [];
    let pathPatterns = [];
    let invalidPatterns = [];
    for (const [pattern, mode] of objectEntries(ignored)) {
        try {
            const regularExpression = new RegExp(pattern, "u");
            if (mode === "name") {
                namePatterns = [...namePatterns, regularExpression];
            }
            else {
                pathPatterns = [...pathPatterns, regularExpression];
            }
        }
        catch {
            invalidPatterns = [...invalidPatterns, pattern];
        }
    }
    return {
        invalidPatterns,
        patterns: {
            name: namePatterns,
            path: pathPatterns,
        },
    };
};
/* eslint-enable security/detect-non-literal-regexp -- Re-enable dynamic-regex checks outside option pattern compilation. */
//# sourceMappingURL=ignore-patterns.js.map