• Filters match results based on provided criteria using shared filter logic with UI preview.

    Parameters

    Returns MangaMatchResult[]

    Filtered array of match results.

    export function filterMatchResults(
    matches: MangaMatchResult[],
    filters: ExportFilterOptions,
    ): MangaMatchResult[] {
    // Convert filter options to matchPassesFilter parameters
    const statusFilters = new Set(
    filters.statusFilter || ["matched", "manual", "pending", "skipped"],
    );
    const confidenceThreshold = filters.confidenceThreshold ?? null;

    // Enforce filter semantics: unmatchedOnly forces includeUnmatched=true
    // This prevents UI mismatches where unmatchedOnly=true but includeUnmatched=false
    const unmatchedOnly = filters.unmatchedOnly ?? false;
    const includeUnmatched = unmatchedOnly
    ? true
    : (filters.includeUnmatched ?? true);

    return matches.filter((match) =>
    matchPassesFilter(
    match,
    statusFilters,
    confidenceThreshold,
    includeUnmatched,
    unmatchedOnly,
    ),
    );
    }