#pragma once

#include <string>
#include <unordered_map>

#include <imgui/imgui.h>

#include "types.hpp"

namespace anm2ed::imgui
{
  inline const std::unordered_map<std::string, ImGuiKey> KEY_MAP = {
      {"A", ImGuiKey_A},
      {"B", ImGuiKey_B},
      {"C", ImGuiKey_C},
      {"D", ImGuiKey_D},
      {"E", ImGuiKey_E},
      {"F", ImGuiKey_F},
      {"G", ImGuiKey_G},
      {"H", ImGuiKey_H},
      {"I", ImGuiKey_I},
      {"J", ImGuiKey_J},
      {"K", ImGuiKey_K},
      {"L", ImGuiKey_L},
      {"M", ImGuiKey_M},
      {"N", ImGuiKey_N},
      {"O", ImGuiKey_O},
      {"P", ImGuiKey_P},
      {"Q", ImGuiKey_Q},
      {"R", ImGuiKey_R},
      {"S", ImGuiKey_S},
      {"T", ImGuiKey_T},
      {"U", ImGuiKey_U},
      {"V", ImGuiKey_V},
      {"W", ImGuiKey_W},
      {"X", ImGuiKey_X},
      {"Y", ImGuiKey_Y},
      {"Z", ImGuiKey_Z},
      {"0", ImGuiKey_0},
      {"1", ImGuiKey_1},
      {"2", ImGuiKey_2},
      {"3", ImGuiKey_3},
      {"4", ImGuiKey_4},
      {"5", ImGuiKey_5},
      {"6", ImGuiKey_6},
      {"7", ImGuiKey_7},
      {"8", ImGuiKey_8},
      {"9", ImGuiKey_9},
      {"Num0", ImGuiKey_Keypad0},
      {"Num1", ImGuiKey_Keypad1},
      {"Num2", ImGuiKey_Keypad2},
      {"Num3", ImGuiKey_Keypad3},
      {"Num4", ImGuiKey_Keypad4},
      {"Num5", ImGuiKey_Keypad5},
      {"Num6", ImGuiKey_Keypad6},
      {"Num7", ImGuiKey_Keypad7},
      {"Num8", ImGuiKey_Keypad8},
      {"Num9", ImGuiKey_Keypad9},
      {"NumAdd", ImGuiKey_KeypadAdd},
      {"NumSubtract", ImGuiKey_KeypadSubtract},
      {"NumMultiply", ImGuiKey_KeypadMultiply},
      {"NumDivide", ImGuiKey_KeypadDivide},
      {"NumEnter", ImGuiKey_KeypadEnter},
      {"NumDecimal", ImGuiKey_KeypadDecimal},
      {"NumEqual", ImGuiKey_KeypadEqual},
      {"F1", ImGuiKey_F1},
      {"F2", ImGuiKey_F2},
      {"F3", ImGuiKey_F3},
      {"F4", ImGuiKey_F4},
      {"F5", ImGuiKey_F5},
      {"F6", ImGuiKey_F6},
      {"F7", ImGuiKey_F7},
      {"F8", ImGuiKey_F8},
      {"F9", ImGuiKey_F9},
      {"F10", ImGuiKey_F10},
      {"F11", ImGuiKey_F11},
      {"F12", ImGuiKey_F12},
      {"Up", ImGuiKey_UpArrow},
      {"Down", ImGuiKey_DownArrow},
      {"Left", ImGuiKey_LeftArrow},
      {"Right", ImGuiKey_RightArrow},
      {"Space", ImGuiKey_Space},
      {"Enter", ImGuiKey_Enter},
      {"Escape", ImGuiKey_Escape},
      {"Tab", ImGuiKey_Tab},
      {"Backspace", ImGuiKey_Backspace},
      {"Delete", ImGuiKey_Delete},
      {"Insert", ImGuiKey_Insert},
      {"Home", ImGuiKey_Home},
      {"End", ImGuiKey_End},
      {"PageUp", ImGuiKey_PageUp},
      {"PageDown", ImGuiKey_PageDown},
      {"Minus", ImGuiKey_Minus},
      {"Equal", ImGuiKey_Equal},
      {"LeftBracket", ImGuiKey_LeftBracket},
      {"RightBracket", ImGuiKey_RightBracket},
      {"Semicolon", ImGuiKey_Semicolon},
      {"Apostrophe", ImGuiKey_Apostrophe},
      {"Comma", ImGuiKey_Comma},
      {"Period", ImGuiKey_Period},
      {"Slash", ImGuiKey_Slash},
      {"Backslash", ImGuiKey_Backslash},
      {"GraveAccent", ImGuiKey_GraveAccent},
      {"Keypad0", ImGuiKey_Keypad0},
      {"Keypad1", ImGuiKey_Keypad1},
      {"Keypad2", ImGuiKey_Keypad2},
      {"Keypad3", ImGuiKey_Keypad3},
      {"Keypad4", ImGuiKey_Keypad4},
      {"Keypad5", ImGuiKey_Keypad5},
      {"Keypad6", ImGuiKey_Keypad6},
      {"Keypad7", ImGuiKey_Keypad7},
      {"Keypad8", ImGuiKey_Keypad8},
      {"Keypad9", ImGuiKey_Keypad9},
      {"KeypadAdd", ImGuiKey_KeypadAdd},
      {"KeypadSubtract", ImGuiKey_KeypadSubtract},
      {"KeypadMultiply", ImGuiKey_KeypadMultiply},
      {"KeypadDivide", ImGuiKey_KeypadDivide},
      {"KeypadEnter", ImGuiKey_KeypadEnter},
      {"KeypadDecimal", ImGuiKey_KeypadDecimal},
      {"KeypadEqual", ImGuiKey_KeypadEqual},
      {"UpArrow", ImGuiKey_UpArrow},
      {"DownArrow", ImGuiKey_DownArrow},
      {"LeftArrow", ImGuiKey_LeftArrow},
      {"RightArrow", ImGuiKey_RightArrow},
  };

  inline const std::unordered_map<std::string, ImGuiKey> MOD_MAP = {
      {"Ctrl", ImGuiMod_Ctrl},
      {"Shift", ImGuiMod_Shift},
      {"Alt", ImGuiMod_Alt},
      {"Super", ImGuiMod_Super},
  };

  std::string chord_to_string(ImGuiKeyChord);
  ImGuiKeyChord string_to_chord(const std::string&);
  bool shortcut(ImGuiKeyChord, types::shortcut::Type = types::shortcut::FOCUSED_SET);
}
