const screen_size = Global.GetScreenSize();
var stored = false;
var x_offs = 0;
var y_offs = 0;
UI.AddSliderInt("binds x", 0, screen_size[0]);
UI.AddSliderInt("binds y", 0, screen_size[1]);
UI.SetEnabled("Script items", "binds x", false);
UI.SetEnabled("Script items", "binds y", false);
const in_bounds = function(vec, x, y, x2, y2) {
    return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)
}
const keybinds = function() {
    var keybinds = [];
    if (UI.IsMenuOpen()) {                                                       keybinds.push("Menu is Open") };
    if (UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction")) {            keybinds.push("Freestand") };
    if (UI.IsHotkeyActive("Rage", "Exploits", "Double tap")) {                   keybinds.push("Double Tap") };
    if (UI.IsHotkeyActive("Rage", "Exploits", "Hide shots")) {                   keybinds.push("Hide Shots") };
    if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {                   keybinds.push("Fake Duck") };
    if (UI.IsHotkeyActive("Rage", "General", "General", "Force body aim")) {     keybinds.push("Body Aim") };
    if (UI.IsHotkeyActive("Rage", "General", "General", "Force safe point")) {   keybinds.push("Safe Points") };
    if (UI.IsHotkeyActive("Script items", "min damage")) {                       keybinds.push("Minimum Damage") };
 
    const x = UI.GetValue("Script items", "binds x"),
    y = UI.GetValue("Script items", "binds y");
    const font = Render.AddFont("Calibri", 13, 600);
    const active = Render.AddFont("Calibri", 11, 100);
    const icon = Render.AddFont("untitled-font-1", 14, 100);
    Render.FilledRect(x, y, 150, 25, [11, 11, 20, 200]);
    Render.StringCustom(x + 5, y + 3, 0, "a", [0, 130, 255, 255], icon);
    Render.StringCustom(x + 30, y + 1, 0, "Binds", [255, 255, 255, 255], font);
    Render.FilledRect(x, y + 24, 150, 24 + 19 * (keybinds.length - 1), [200, 200, 200, 15]);
    for (i = 0; i < keybinds.length; i++){
        Render.StringCustom(x + 3, y + 26 + 20 * i, 0, keybinds[i], [255, 255, 255, 255], active);
        Render.StringCustom(x + 132, y + 26 + 20 * i, 0, "on", [255, 255, 255, 255], active);
    }
 
    if(UI.IsMenuOpen() && Input.IsKeyPressed(0x1)){
        const mouse_pos = Global.GetCursorPosition();
        if (in_bounds(mouse_pos, x, y, x + 150, y + 40)) {
            if(!stored){
                x_offs = mouse_pos[0] - x;
                y_offs = mouse_pos[1] - y;
                stored = true;
            }
            UI.SetValue("Script items", "binds x", mouse_pos[0] - x_offs);
            UI.SetValue("Script items", "binds y", mouse_pos[1] - y_offs);
        }
    } else if(stored) stored = false;
}
Global.RegisterCallback("Draw", "keybinds");