"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.anyMatchRegexOrMinimatch = exports.matchRegexOrMinimatch = void 0;
const tslib_1 = require("tslib");
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
const logger_1 = require("../../logger");
const minimatch_1 = require("../minimatch");
const regex_1 = require("../regex");
function matchRegexOrMinimatch(pattern, input) {
    if (pattern.length > 2 && pattern.startsWith('/') && pattern.endsWith('/')) {
        try {
            const regex = (0, regex_1.regEx)(pattern.slice(1, -1));
            return regex.test(input);
        }
        catch (err) {
            logger_1.logger.once.warn({ err, pattern }, 'Invalid regex pattern');
            return false;
        }
    }
    return (0, minimatch_1.minimatch)(pattern, { dot: true }).match(input);
}
exports.matchRegexOrMinimatch = matchRegexOrMinimatch;
function anyMatchRegexOrMinimatch(patterns, input) {
    if (is_1.default.undefined(patterns)) {
        return null;
    }
    if (is_1.default.undefined(input)) {
        return false;
    }
    return patterns.some((pattern) => matchRegexOrMinimatch(pattern, input));
}
exports.anyMatchRegexOrMinimatch = anyMatchRegexOrMinimatch;
//# sourceMappingURL=match.js.map