#pragma once
// ── CS2 External C++ WebRadar — Core Types ────────────────────────────────────

#include <cstdint>
#include <cmath>
#include <string>

// ── 2D vector ─────────────────────────────────────────────────────────────────
struct Vec2 {
    float x = 0, y = 0;
};

// ── 3D vector ─────────────────────────────────────────────────────────────────
struct Vec3 {
    float x = 0, y = 0, z = 0;

    Vec3 operator+(const Vec3& o) const { return {x + o.x, y + o.y, z + o.z}; }
    Vec3 operator-(const Vec3& o) const { return {x - o.x, y - o.y, z - o.z}; }
    Vec3 operator*(float s)       const { return {x * s, y * s, z * s}; }
    Vec3 operator/(float s)       const { return {x / s, y / s, z / s}; }

    bool is_zero() const { return x == 0 && y == 0 && z == 0; }

    float length() const { return std::sqrt(x*x + y*y + z*z); }
    float length_sq() const { return x*x + y*y + z*z; }

    static Vec3 lerp(const Vec3& a, const Vec3& b, float t) {
        return { a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t };
    }

    static const Vec3 Zero;
};

inline const Vec3 Vec3::Zero = {0, 0, 0};

// ── 4×4 row-major matrix ─────────────────────────────────────────────────────
struct Mat4x4 {
    float m[4][4] = {};

    static Mat4x4 transpose(const Mat4x4& src) {
        Mat4x4 dst;
        for (int r = 0; r < 4; r++)
            for (int c = 0; c < 4; c++)
                dst.m[r][c] = src.m[c][r];
        return dst;
    }
};

// ── Team ──────────────────────────────────────────────────────────────────────
enum class Team : int32_t {
    Unknown           = 0,
    Spectator         = 1,
    Terrorists        = 2,
    CounterTerrorists = 3,
};

inline Team to_team(int32_t val) {
    switch (val) {
        case 1:  return Team::Spectator;
        case 2:  return Team::Terrorists;
        case 3:  return Team::CounterTerrorists;
        default: return Team::Unknown;
    }
}

// ── Life state ────────────────────────────────────────────────────────────────
constexpr uint8_t LIFE_ALIVE = 0;
constexpr uint8_t LIFE_DYING = 1;
constexpr uint8_t LIFE_DEAD  = 2;

// ── Weapon indexes ────────────────────────────────────────────────────────────
// Maps CS2 weapon item definition indexes to SVG icon keys
enum class WeaponIndex : int32_t {
    // Pistols
    DEAGLE      = 1,
    ELITE       = 2,
    FIVESEVEN   = 3,
    GLOCK       = 4,
    P2000       = 32,  // also HKP2000
    USP_S       = 61,  // USP-Silencer
    P250        = 36,
    CZ75A       = 63,
    TEC9        = 30,
    REVOLVER    = 64,
    // SMGs
    MAC10       = 17,
    MP9         = 23,
    MP7         = 24,
    MP5SD       = 23,  // actually MP5-SD
    UMP45       = 26,
    P90         = 19,
    BIZON       = 18,
    // Rifles
    GALILAR     = 13,
    FAMAS       = 14,
    AK47        = 7,
    M4A4        = 16,
    M4A1_S      = 60,
    SG556       = 39,
    AUG         = 8,
    // Snipers
    SSG08       = 40,
    AWP         = 9,
    G3SG1       = 11,
    SCAR20      = 38,
    // Heavy
    M249        = 14,
    NEGEV       = 28,
    // Shotguns
    NOVA        = 35,
    XM1014      = 25,
    SAWEDOFF    = 29,
    MAG7        = 27,
    // Equipment
    TASER       = 31,
    // Grenades
    HE          = 44,
    FLASH       = 43,
    SMOKE       = 45,
    MOLOTOV     = 46,
    INCENDIARY  = 48,
    DECOY       = 47,
    // Bomb
    C4          = 49,
    // Knife types
    KNIFE       = 42,
    KNIFE_T     = 59,
    KNIFE_BAYONET = 500,
    KNIFE_FLIP  = 505,
    KNIFE_GUT   = 506,
    KNIFE_KARAMBIT = 507,
    KNIFE_M9    = 508,
    KNIFE_HUNTSMAN = 509,
    KNIFE_FALCHION = 512,
    KNIFE_BOWIE = 514,
    KNIFE_BUTTERFLY = 515,
    KNIFE_DAGGERS = 516,
    KNIFE_PARACORD = 517,
    KNIFE_SURVIVAL = 518,
    KNIFE_URSUS  = 519,
    KNIFE_NAVAJA = 520,
    KNIFE_NOMAD  = 521,
    KNIFE_STILETTO = 522,
    KNIFE_TALON  = 523,
    KNIFE_SKELETON = 525,
};

// ── Character def indexes ─────────────────────────────────────────────────────
enum class CharacterDefIndex : int32_t {
    // Phoenix / T side
    PHOENIX          = 1,
    PHOENIX_ELITE    = 2,
    PHOENIX_LEET     = 3,
    PHOENIX_LEET_2   = 4,
    PHOENIX_LEET_3   = 5,
    PHOENIX_SOLDIER  = 6,
    PHOENIX_LEET_4   = 7,
    PHOENIX_SOLDIER_2 = 8,
    // SEAL Team 6 / CT side
    SEAL             = 9,
    SEAL_SOLDIER     = 10,
    SEAL_ELITE       = 11,
    SEAL_LEET        = 12,
    SEAL_SOLDIER_2   = 13,
    SEAL_ELITE_2     = 14,
    SEAL_LEET_2      = 15,
    SEAL_SOLDIER_3   = 16,
    // Custom skins range 100-600+
    PROFESSIONAL     = 100,
    STREET                      = 101,
    HEAVY_MERCENARY             = 102,
    GROUND_REBEL_113            = 113,
    GROUND_REBEL_114            = 114,
    GROUND_REBEL_115            = 115,
    PHOENIX_COMMANDO_117        = 117,
    PHOENIX_COMMANDO_118        = 118,
    PHOENIX_COMMANDO_119        = 119,
    PIRATE                       = 120,
    PIRATE_121                   = 121,
    SOLDIER_122                  = 122,
    SOLDIER_123                  = 123,
    SOLDIER_124                  = 124,
    GIGN_126                    = 126,
    GIGN_127                    = 127,
    GIGN_128                    = 128,
    GSG9_129                    = 129,
    GSG9_130                    = 130,
    GSG9_131                    = 131,
    FBI_132                     = 132,
    FBI_133                     = 133,
    FBI_134                     = 134,
    ST6_135                     = 135,
    ST6_136                     = 136,
    ST6_137                     = 137,
    SWAT_138                    = 138,
    SWAT_139                    = 139,
    SWAT_140                    = 140,
    HEAVY_PHOENIX_141           = 141,
    HEAVY_PHOENIX_142           = 142,
    HEAVY_PHOENIX_143           = 143,
    GUERILLA_145                = 145,
    GUERILLA_146                = 146,
    GUERILLA_147                = 147,
    GROUND_REBEL_148            = 148,
    GROUND_REBEL_149            = 149,
    XRAY_150                    = 150,
    XRAY_151                    = 151,
    ARCTIC_152                  = 152,
    ARCTIC_153                  = 153,
};
