#pragma once

#include <string>
#include <unordered_map>
#include <vector>

#include "torlinkc/sources/types.hpp"

namespace torlinkc {

// Builds a fresh copy of all 10 sources. Cheap (each Source is a handful of
// strings plus a std::function wrapping a stateless free function), and
// avoids any static-initialization-order question -- callers needing to run
// several sources concurrently (Phase 3's SearchAggregator) can each hold
// their own copy safely. Ported from sources/registry.ts::SOURCES.
std::vector<Source> allSources();

// id -> Source, for looking up a TorrentResult's `source` field back to its
// `groups`/`reportsHealth` (category filtering, ui::filterResults's
// hideDead check).
std::unordered_map<std::string, Source> sourceById();

// The full ordered category list, matching registry.ts::sourcesByGroup's
// GROUP_ORDER (Games, Movies, TV, Anime) plus a leading "All".
enum class Category { All, Games, Movies, TV, Anime };
std::string categoryLabel(Category c);
bool sourceInCategory(const Source& source, Category c);

}  // namespace torlinkc
