#include "adapters/eft/items/catalog/ItemTemplateCatalogService.h"

#include "adapters/hooks/items/ItemHookState.h"

namespace ta::adapters::eft::items
{
    void ItemTemplateCatalogService::update()
    {
        if (!ta::adapters::hooks::items::item_factory())
            static_cast<void>(ta::adapters::hooks::items::ensure_item_factory_available());
        rebuild_job_.update(ta::adapters::hooks::items::item_factory());
    }

    void ItemTemplateCatalogService::request_reload() noexcept
    {
        rebuild_job_.request_reload();
    }

    const std::vector<ta::features::items::contracts::ItemCatalogEntry>& ItemTemplateCatalogService::entries() const noexcept
    {
        return rebuild_job_.entries();
    }

    ta::features::items::contracts::ItemCategory ItemTemplateCatalogService::category_for(
        const std::string_view template_id) const
    {
        return rebuild_job_.category_for(template_id);
    }

    int ItemTemplateCatalogService::max_stack_for(const std::string_view template_id) const noexcept
    {
        return rebuild_job_.max_stack_for(template_id);
    }

    std::uint64_t ItemTemplateCatalogService::revision() const noexcept { return rebuild_job_.revision(); }
    bool ItemTemplateCatalogService::loading() const noexcept { return rebuild_job_.loading(); }
    bool ItemTemplateCatalogService::ready() const noexcept { return rebuild_job_.ready(); }
    CatalogPhase ItemTemplateCatalogService::phase() const noexcept { return rebuild_job_.phase(); }
}
