• Filter matches based on configuration rules (one-shots, adult content, custom rules).

    Applies user-configured filtering during automatic matching:

    1. Removes any manga that matches the curated blacklist.
    2. Filters out one-shots (if enabled)
    3. Filters out adult content (if enabled)
    4. Skip rules applied first - these take precedence and remove matches entirely
    5. Accept rules tracked but not removed - matched accept rules are marked for confidence boost

    Confidence Boost Behavior: When a match satisfies a custom accept rule, it's marked internally. The createMangaMatchResult() function later applies a confidence floor: 85% for exact title matches, 75% otherwise. Skip rules always take precedence - if a match matches both skip and accept rules, it's skipped.

    Parameters

    • potentialMatches: AniListManga[]

      Potential manga matches.

    • mangaTitle: string

      Title of manga being matched.

    • matchConfig: Partial<MatchConfig>

      Configuration with shouldIgnoreOneShots, shouldIgnoreAdultContent.

    • kenmeiManga: KenmeiManga

      Kenmei manga for custom rule evaluation.

    • Optionaloptions: { skipSystemFilters?: boolean }

    Returns (AniListManga & { matchedAcceptRule?: CustomRule })[]

    Filtered list of manga matches (with internal accept rule tracking if applicable).

    export function applyMatchFiltering(
    potentialMatches: AniListManga[],
    mangaTitle: string,
    matchConfig: Partial<MatchConfig>,
    kenmeiManga: KenmeiManga,
    options?: { skipSystemFilters?: boolean },
    ): Array<AniListManga & { matchedAcceptRule?: CustomRule }> {
    const sanitizedMatches = filterOutBlacklistedManga(potentialMatches);

    let filteredMatches: Array<
    AniListManga & { matchedAcceptRule?: CustomRule }
    > = sanitizedMatches.map((m) => ({ ...m }));

    if (!options?.skipSystemFilters) {
    // Apply system content filters (novels, one-shots, adult content)
    const systemFiltered = applySystemContentFilters(
    filteredMatches,
    matchConfig,
    kenmeiManga,
    mangaTitle,
    );
    filteredMatches = systemFiltered.map((m) => ({
    ...m,
    })) as Array<AniListManga & { matchedAcceptRule?: CustomRule }>;
    }

    // Mark matches that satisfy custom accept rules (without removing them)
    // Confidence will be boosted later in createMangaMatchResult()
    filteredMatches = filteredMatches.map((match) => {
    const { shouldAccept, matchedRule } = shouldAcceptByCustomRules(
    match,
    kenmeiManga,
    );
    if (shouldAccept && matchedRule) {
    console.debug(
    `[MangaSearchService] ⭐ Marking confidence boost for "${match.title?.romaji || match.title?.english}" due to custom accept rule: "${matchedRule.description}"`,
    );
    return { ...match, matchedAcceptRule: matchedRule };
    }
    return match;
    });

    return filteredMatches;
    }