// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3

// Embedded Resources Header
// This provides access to resources embedded in the binary

#pragma once
#include <cstddef>
#include <cstdint>
#include <string>
#include <unordered_map>

namespace dragonx {
namespace embedded {

// Forward declarations for embedded data (generated at build time)
struct EmbeddedResource {
    const unsigned char* data;
    size_t size;
};

// Resource registry
class Resources {
public:
    static Resources& instance() {
        static Resources inst;
        return inst;
    }
    
    // Get embedded resource by name
    // Returns nullptr if not found
    const EmbeddedResource* get(const std::string& name) const {
        auto it = resources_.find(name);
        if (it != resources_.end()) {
            return &it->second;
        }
        return nullptr;
    }
    
    // Check if resource exists
    bool has(const std::string& name) const {
        return resources_.find(name) != resources_.end();
    }
    
    // Register a resource (called during static init)
    void registerResource(const std::string& name, const unsigned char* data, size_t size) {
        resources_[name] = {data, size};
    }

private:
    Resources() = default;
    std::unordered_map<std::string, EmbeddedResource> resources_;
};

// Helper macro for registering resources
#define REGISTER_EMBEDDED_RESOURCE(name, data, size) \
    static struct _EmbeddedResourceRegister_##name { \
        _EmbeddedResourceRegister_##name() { \
            dragonx::embedded::Resources::instance().registerResource(#name, data, size); \
        } \
    } _embedded_resource_register_##name

} // namespace embedded
} // namespace dragonx
