import { ApiError, request } from './client';
import type { MangaCard } from './mangas';

/**
 * GET /v1/me/recommendations — content-based "Recommended for you" feed.
 * Returns an empty list for guests (401) so callers can render nothing
 * without special-casing auth.
 */
export async function listMyRecommendations(): Promise<MangaCard[]> {
    try {
        const r = await request<{ items: MangaCard[] }>('/v1/me/recommendations');
        return r.items;
    } catch (e) {
        if (e instanceof ApiError && e.status === 401) return [];
        throw e;
    }
}
