let simple = true;
let version = 'v10';
let wheel0 = [0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26];

let simulation_win_loss = false;
let global_win_loss = 3;
let global_bouncy_bet_index = 0;
let global_bouncy_index_array = [];
let global_bouncy_bet_array = [1, 2, 2, 6, 6, 18, 18, 54, 54, 162, 162];
let global_bouncy_radio_selection = "";
let global_bouncy_current_bet = 0;


let global_win_loss_bounceRow = 3;
let global_bouncy_bet_index_bounceRow = 0;
let global_bouncy_index_array_bounceRow = [];
let global_bouncy_bet_array_bounceRow = [1, 2, 2, 6, 6, 18, 18, 54, 54, 162, 162];
let global_bouncy_radio_selection_bounceRow = "";
let global_bouncy_current_bet_bounceRow = 0;

// Roulette wheel attributes
const rouletteAttributes = {
    red: [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36],
    black: [2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35],
    columns: [
        [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34], // Column 1
        [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35], // Column 2
        [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]  // Column 3
    ],
    dozens: [
        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], // Dozen 1
        [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], // Dozen 2
        [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36] // Dozen 3
    ]
};

let production = true;
let rebetMultiplier = 2;
let oldUserBets = new Map();
let oldUserBets_rows = new Map();
let oldUserBets_dozens = new Map();
let oldUserBets_Edge3 = new Map();
let userBets = new Map();
let previousBankValue = 1000;

let showRebetButton = true;
let bankValue = 1000;
let currentBet = 0;
let wager = 5;
let lastWager = 0;

let lastBets = []; 
let bet = [];
let oldBet = [];

let PreviousBet = [];
let numbersBet = [];
let previousNumbers = [];
let historyBankValue = [];
let historyCurrentBet = [];
let historyWager = [];
let historyLastWager = [];
let historBet = [];
let historyNumbersBet = [];
let historyPreviousNumbers = [];
historyBankValue.push(bankValue);
historyCurrentBet.push(currentBet);
historyWager.push(wager);
historyLastWager.push(lastWager);
historBet.push(bet);
historyNumbersBet.push(numbersBet);
historyPreviousNumbers.push(previousNumbers);


let numbers = [];
let numberHistory = [];

let triggerGroups = [];
let triggerListLoss = [];
let triggerListItem = [];
let triggerListText = [];
let triggerListWinLoss = [];
let triggerListName = [];

let alertCounter = [];
let alertItem = [];
let alertItemDetail = [];
let alertHighLightStack = [];
let alertId = [];
let alertWinLoss = [];

let watch_id = [];
let watch_count = [];
let watch_loss = [];
let watchCounter = [];
let watchItem = [];
let watchItemDetail = [];
let watch_highlight_stack = [];
let watchWinLoss = [];

let alert_nameTag = [];
let watch_nameTag = [];

let rebet_lastThis = [];
let rebet_amount = [];
let rebet_target = [];
let rebet_odds = [];
let rebet_wager = [];

let redo_lastThis = [];
let redo_amount = [];
let redo_target = [];
let redo_odds = [];
let redo_wager = [];

let detailFunctionsSelected = [];
let detailValueSelected = [];


let numRed = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36];
let wheelnumbersAC = [0, 26, 3, 35, 12, 28, 7, 29, 18, 22, 9, 31, 14, 20, 1, 33, 16, 24, 5, 10, 23, 8, 30, 11, 36, 13, 27, 6, 34, 17, 25, 2, 21, 4, 19, 15, 32];
let numBlack = [26, 35, 28, 29, 22, 31, 20, 33, 24, 10, 8, 11, 13, 6, 17, 2, 4, 15];
let triggerDropDown = [
    { value: 'AllOut', text: 'Outside Bets' },
    { value: 'All', text: 'All No Straights' },
    { value: 'Even', text: 'Even' },
    { value: 'Odd', text: 'Odd' },
    { value: 'Red', text: 'Red' },
    { value: 'Black', text: 'Black' },
    { value: 'High', text: 'High' },
    { value: 'Low', text: 'Low' },
    { value: 'Dozen1', text: 'Dozen 1' },
    { value: 'Dozen2', text: 'Dozen 2' },
    { value: 'Dozen3', text: 'Dozen 3' },
    { value: 'Row1', text: 'Row 1' },
    { value: 'Row2', text: 'Row 2' },
    { value: 'Row3', text: 'Row 3' },
    { value: 'Quads', text: 'Quads' },
    { value: 'Splits', text: 'Splits' },
    { value: 'Streets', text: 'Streets' },
    { value: 'DoubleStreet', text: 'Lines' },
    { value: 'StraightNumbers', text: 'Straights' },
];

// Track whether dragging is enabled
let isDraggingEnabled = false;

// Store original positions
let originalPositions = {};

// -----------------------------------------------------
// Start: Mouse Events  const { x, y } = getCurrentMouseCoordinates();
// -----------------------------------------------------
var cursorPosition = { x: 0, y: 0 };
// Variables to hold the latest mouse coordinates
let mouseX = 0;
let mouseY = 0;

// Event listener for mouse movement
document.addEventListener('mousemove', function(event) {
    mouseX = event.clientX; // Get the horizontal coordinate
    mouseY = event.clientY; // Get the vertical coordinate
});

// Function to return the current mouse coordinates
function getCurrentMouseCoordinates() {
    return { x: mouseX, y: mouseY };
}
// -----------------------------------------------------
// End: Mouse Events
// -----------------------------------------------------

let wheel = null;
let ballTrack = null;

let panelTriggers = document.createElement('div');

var chart;

let miss_even = 0;
let miss_dozen = 0;
let miss_line = 0;
let miss_quad = 0;
let miss_street = 0;
let miss_split = 0;
let miss_straight = 0;

let db_miss_even = 0;
let db_miss_dozen = 0;
let db_miss_line = 0;
let db_miss_quad = 0;
let db_miss_street = 0;
let db_miss_split = 0;
let db_miss_straight = 0;


function consoleLogMissedRecordVariables()
{



}


// -----------------------------------------------------
// DESCRIPTIONS
// -----------------------------------------------------
let record_miss_description = "This records the longest misses in a row for the record of all players, and the longest misses in a row for your current session.";
let double_zero_message = "Use 0 if double 00 comes up.";
let zoom_message = "For best experience, please use the webpage at 100% zoom level.";
let high_score_message = "Starting with 1000 bankroll<br/>be honest and add your high scores.";

let startingBank = bankValue;
let currentBank = bankValue;
let currentTaIbtem = null;
let currentTabOdd = null;

let tableChart = [];
var masterEdgeChart = [];
let masterEdgeChart_save = [];

let current_bets = null;
let global_chip_span_id_counter = 0;
let global_chip_id = [];
let global_chip_amt = [];