"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackagePrefixesMatcher = void 0;
const tslib_1 = require("tslib");
const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
const logger_1 = require("../../logger");
const base_1 = require("./base");
class PackagePrefixesMatcher extends base_1.Matcher {
    matches({ depName, packageName }, { matchPackagePrefixes }) {
        if (is_1.default.undefined(matchPackagePrefixes)) {
            return null;
        }
        if (is_1.default.undefined(depName)) {
            return false;
        }
        if (is_1.default.string(packageName) &&
            matchPackagePrefixes.some((prefix) => packageName.startsWith(prefix))) {
            return true;
        }
        if (matchPackagePrefixes.some((prefix) => depName.startsWith(prefix))) {
            logger_1.logger.once.warn({ packageName, depName }, 'Use matchDepPatterns instead of matchPackagePrefixes');
            return true;
        }
        return false;
    }
    excludes({ depName }, { excludePackagePrefixes }) {
        if (is_1.default.undefined(excludePackagePrefixes)) {
            return null;
        }
        if (is_1.default.undefined(depName)) {
            return false;
        }
        return excludePackagePrefixes.some((prefix) => depName.startsWith(prefix));
    }
}
exports.PackagePrefixesMatcher = PackagePrefixesMatcher;
//# sourceMappingURL=package-prefixes.js.map