• Internal

    Checks if a match passes all filter criteria; used by UI preview and export to keep results in sync.

    Parameters

    • match: MangaMatchResult

      The match to check.

    • statusFilters: string[] | Set<string>

      Selected status filters (matched, manual, pending, skipped).

    • confidenceThreshold: null | number

      Minimum confidence threshold (null or 0-100).

    • includeUnmatched: boolean

      Include entries without matches.

    • unmatchedOnly: boolean

      Export only unmatched entries (takes precedence).

    Returns boolean

    True if the match passes all applied filters.

    export function matchPassesFilter(
    match: MangaMatchResult,
    statusFilters: Set<string> | string[],
    confidenceThreshold: number | null,
    includeUnmatched: boolean,
    unmatchedOnly: boolean,
    ): boolean {
    const statusFilterSet =
    statusFilters instanceof Set ? statusFilters : new Set(statusFilters);

    // Check status filter
    if (!statusFilterSet.has(match.status)) {
    return false;
    }

    // Check confidence threshold
    if (confidenceThreshold !== null && confidenceThreshold > 0) {
    const highestConfidence =
    match.anilistMatches && match.anilistMatches.length > 0
    ? Math.max(...match.anilistMatches.map((m) => m.confidence ?? 0))
    : 0;
    if (highestConfidence < confidenceThreshold) {
    return false;
    }
    }

    // Check unmatchedOnly filter (takes precedence over includeUnmatched)
    if (unmatchedOnly) {
    const isUnmatched =
    !match.selectedMatch &&
    (!match.anilistMatches || match.anilistMatches.length === 0);
    return isUnmatched;
    }

    // Check includeUnmatched filter
    if (!includeUnmatched) {
    const isMatched = !!(
    match.selectedMatch ||
    (match.anilistMatches && match.anilistMatches.length > 0)
    );
    return isMatched;
    }

    return true;
    }