#pragma once

#include <SDL3/SDL.h>

#include <cstdint>
#include <memory>
#include <string>
#include <vector>

// Forward declarations to keep this header light.
namespace Ja {
    struct Music;
    struct Sound;
    void deleteMusic(Music* music);
    void deleteSound(Sound* sound);
}  // namespace Ja

namespace Resource {

    struct MusicDeleter {
        void operator()(Ja::Music* music) const noexcept {
            if (music != nullptr) {
                Ja::deleteMusic(music);
            }
        }
    };

    struct SoundDeleter {
        void operator()(Ja::Sound* sound) const noexcept {
            if (sound != nullptr) {
                Ja::deleteSound(sound);
            }
        }
    };

    struct MusicResource {
        std::string name;
        std::unique_ptr<Ja::Music, MusicDeleter> music;
    };

    struct SoundResource {
        std::string name;
        std::unique_ptr<Ja::Sound, SoundDeleter> sound;
    };

    // Una entrada BITMAP descodifica un GIF i emmagatzema els seus
    // 64000 bytes de píxels paletats + la paleta de 256 colors (768
    // bytes RGB). Així `getSurface(name)` i `getPalette(name)` comparteixen
    // el mateix decode.
    struct SurfaceResource {
        std::string name;
        std::vector<Uint8> pixels;   // 64000 bytes (320 * 200) paletats
        std::vector<Uint8> palette;  // 768 bytes (256 * R G B)
    };

    // Per a fitxers de text generals (locale.yaml, keys.yaml, *.fnt).
    struct TextFileResource {
        std::string name;
        std::vector<uint8_t> bytes;
    };

}  // namespace Resource
