<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Lua GG Script Generator</title>
	<style id="dynamic-style">
    <style>
 body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background-color: #f9f9f9;
        }
        h1, h2 {
            text-align: center;
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
         button {
        font-size: 15px;
        font-weight: bold;
        color: white;
        padding: 10px 20px;
        border: none;
        border-radius: 10px;
        cursor: pointer;
        transition: background-color 0.3s, box-shadow 0.3s;
        background-image: linear-gradient(to right, #2196F3, #64B5F6);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        margin-bottom: 10px; /* Add margin-bottom to create space between buttons */
    }

    button:hover {
        background-image: linear-gradient(to right, #2196F3, #64B5F6);
        box-shadow: 0 8px 16px rgba(10, 5, 5, 0.8);
    }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
		#emojiMenu select {
    width: 10%; /* Задайте ширину на 100% */
    height: auto; /* Змініть висоту відповідно до вмісту */
}
    </style>
</head>
<body>

 <h1 id="version-title" style="text-align: center;font-size: 24px; font-weight: bold; color: #2196F3; text-shadow: 0 0 10px #64B5F6; border-bottom: 4px solid #64B5F6; padding-bottom: 10px;">Script Lua Builder</h1>
 <h3 id="version-title" style="text-align: center;font-size: 24px; font-weight: bold; color: #2196F3; text-shadow: 0 0 10px #64B5F6; border-bottom: 4px solid #64B5F6; padding-bottom: 10px;">CreateD By - @LambaTyT</h3>

<!-- Set Style Button -->
<button onclick="toggleStyleMenu()">Set Style</button>
<div id="styleMenu" class="menu-options">
    <button onclick="setDefaultStyle()">Default Style</button>
    <button onclick="setGradientStyle()">Gradient Style</button>
    <button onclick="setGradientStyle2()">Gradient Style 2</button>
    <button onclick="setGradientStyle3()">Gradient Style 3</button>
    <button onclick="setGradientStyle4()">Gradient Style 4</button>
    <button onclick="setGradientStyle5()">Gradient Style 5</button>
    <button onclick="setGradientStyle6()">Gradient Style 6</button>
    <button onclick="setGradientStyle7()">Gradient Style 7</button>
    <button onclick="setGradientStyle8()">Gradient Style 8</button>
    <button onclick="setGradientStyle9()">Gradient Style 9</button>
    <button onclick="setGradientStyle10()">Gradient Style 10</button>
</div>
<div class="instructions-container">
    <button onclick="showInstruction()">Инструкция</button>
</div>
<!-- Скрытый блок с инструкцией -->
<div id="instructionBlock" style="display: none; margin-top: 15px; padding: 10px; border: 1px solid #ccc; background-color: #f9f9f9;">
    <h3>Пример использования `gg.getResults`:</h3>
    <p><strong>Описание:</strong> <code>gg.getResults</code> получает данные результатов (количество).</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Получить результаты поиска
gg.searchNumber("4", gg.TYPE_DWORD)
local results = gg.getResults(10) -- Получаем 10 найденных значений
gg.toast("Найдено " .. #results .. " результатов")
    </pre>
    <h3>Пример использования `gg.setVisible(false)`:</h3>
    <p><strong>Описание:</strong> <code>gg.setVisible(false)</code> делает интерфейс Game Guardian невидимым.</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Скрыть интерфейс Game Guardian
gg.setVisible(false)
-- Ваш следующий код
gg.toast("Game Guardian успешно скрыт")
    </pre>
    <h3>Пример использования `gg.setRanges`:</h3>
    <p><strong>Описание:</strong> <code>gg.setRanges</code> задает область памяти для поиска значений.</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Установить основной регион
gg.setRanges(gg.REGION_ANONYMOUS) -- Устанавливаем Анонимную память
-- Ваш следующий код
gg.toast("Регион установлен: Анонимная память")
    </pre>
    <h3>Пример использования `gg.setRanges` с кастомными регионами:</h3>
    <p><strong>Описание:</strong> <code>gg.setRanges</code> выбирает несколько областей памяти (например, C-ALLOC и C-DATA).</p>
    <p><strong>Пример:</strong></p>
    <pre style="background-color: #f4f4f4; padding: 10px; border-radius: 5px;">
-- Установить кастомные регионы памяти
gg.setRanges(gg.REGION_C_ALLOC | gg.REGION_C_DATA)
-- Ваш следующий код
gg.toast("Регион установлен: C-ALLOC и C-DATA")
    </pre>
    <button onclick="hideInstruction()">Закрыть инструкцию</button>
</div>
<!-- Setting Button -->
<div class="settings-container">
    <button onclick="toggleSettingsMenu()">Setting</button>
    <div id="settingsMenu" class="menu-options">
        <button onclick="toggleDesktopMode()">ПК</button>
    </div>
</div>
<div class="container">
    <!-- Ввод имени функции -->
    <input type="text" id="functionNameInput" placeholder="Введите название функции (например: myFunction)">
    <button onclick="setFunctionName()">Установить название функции</button>
    <br><br>

  

    <!-- Добавление главного меню -->
    <label for="mainMenuFunction">Введите название меню (УЖЕ ПОСЛЕ ОКОНЧАНИЯ):</label>
    <input type="text" id="mainMenuFunction" placeholder="Введите название меню">
    <button onclick="addMenu()">Добавить меню</button>
    <br><br>

    <!-- Кнопка настройки "Главного меню" -->
    <button onclick="setupMainMenu()">Настроить "Главное меню"</button>
    
    <div id="menuSettings" class="menu-options">
        <div class="menu-settings">
            <label for="menuFunctionCount">Количество функций:</label>
            <input type="number" id="menuFunctionCount" min="1" placeholder="Введите число">
        </div>

   <div class="menu-settings">
    <label for="menuAuthor">Автор меню:</label>
    <input type="text" id="menuAuthor" placeholder="Введите имя автора">

    <label for="menuText">Текст в меню:</label>
    <input type="text" id="menuText" placeholder="Введите текст для меню">
</div>

        <div class="menu-settings">
    <label for="menuType">Тип меню:</label>
    <select id="menuType">
        <option value="choice">Обычное меню (gg.choice)</option>
        <option value="multiChoice">Мультивыбор (gg.multiChoice)</option>
    </select>
</div>

        <div class="menu-settings">
    <label for="menuItemNames">Названия пунктов меню (через запятую):</label>
    <input type="text" id="menuItemNames" placeholder="Пример: Взлом патронов, Вода, Земля">
</div>
<div class="menu-settings">
    <label for="menuFunctionNames">Названия функций (через запятую):</label>
    <input type="text" id="menuFunctionNames" placeholder="Пример: F1, F2, F3">
</div>
<div class="menu-settings">
    <label for="menuEmojis">Эмодзи пунктов меню (через запятую):</label>
    <input type="text" id="menuEmojis" placeholder="Пример: 🔥,🌊,🌍">
</div>

        <button onclick="generateMainMenu()">Сгенерировать главное меню</button>
    </div>
	 <!-- Кнопка настройки "Главного меню" -->
    <button onclick="setupMainF()">Настроить "Меню Функций"</button>
	<div class="menu-settings">
	<div id="menuSettingss" class="menu-options">
        <div class="menu-settings">
    <label for="subMenuFunctionName">Название подменю/функции:</label>
    <input type="text" id="subMenuFunctionName" placeholder="Введите название функции подменю (например, OP)">
</div>
<div class="menu-settings">
    <label for="subMenuItemNames">Названия пунктов подменю (через запятую):</label>
    <input type="text" id="subMenuItemNames" placeholder="Пример: Настройка1, Настройка2">
</div>
<div class="menu-settings">
    <label for="subMenuFunctions">Названия вызываемых функций из подменю (через запятую):</label>
    <input type="text" id="subMenuFunctions" placeholder="Пример: SubOp1, SubOp2">
</div>
<div id="drawer">
        <button onclick="toggleEmojiMenu()">Емодзi для функцій</button>
        
        <div id="emojiMenu" style="display: none;"></div>
    </div>
<!-- повторюйте для кожної функції -->
 <div class="menu-settings">
        <label for="menuStyle">Стиль меню:</label>
        <select id="menuStyle">
            <option value="normal">1. Обычный</option>
            <option value="circle">2. Круг</option>
        </select>
    </div>
	<div class="menu-settings">
        <label for="functionStyle">Стиль функций:</label>
        <select id="functionStyle">
            <option value="default">Обычный</option>
            <option value="brackets">『 ➱ 』</option>
            <option value="arrow">➤</option>
            <option value="bars">▁▂▃ (начало) ▃▂▁ (конец)</option>
			<option value="parallel">║  ║</option>
			<option value="cut">◤  ◥</option>
			<option value="but">[+]</option>
        </select>
    </div>

<button onclick="generateSubMenu()">Сгенерировать подменю/функцию</button>
</div>
    <h2>Настройка вашей функции</h2>
	    <!-- Невидимость GG -->
    <div class="functions">
    <div class="function">
        <input type="checkbox" id="hideGG">
        <label for="hideGG">Скрыть Game Guardian (gg.setVisible(false))</label>
    </div>
	<div class="function">
        <input type="checkbox" id="usePrimaryRegion">
        <label for="primaryRegion">Выберите основной регион:</label>
        <select id="primaryRegion" disabled>
        <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
        <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
        <option value="gg.REGION_C_BSS">C-BSS</option>
        <option value="gg.REGION_C_DATA">C-DATA</option>
        <option value="gg.REGION_CODE_APP">Код приложения</option>
        <option value="gg.REGION_CODE_SYS">Код системы</option>
        <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
        <option value="gg.REGION_STACK">Стек</option>
        <option value="gg.REGION_VIDEO">Видео</option>
        <option value="gg.REGION_OTHER">Другое</option>
        <option value="gg.REGION_BAD">Неиспользуемая память</option>
    </select>
</div>
<div class="function">
    <label>Кастомные регионы (максимум 3):</label>
    <div id="customRegions">
        <label for="customRegion1">Регион 1:</label>
        <select id="customRegion1">
            <option value="">Не выбран</option>
            <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
            <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
            <option value="gg.REGION_C_BSS">C-BSS</option>
            <option value="gg.REGION_C_DATA">C-DATA</option>
            <option value="gg.REGION_CODE_APP">Код приложения</option>
            <option value="gg.REGION_CODE_SYS">Код системы</option>
            <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
            <option value="gg.REGION_STACK">Стек</option>
            <option value="gg.REGION_VIDEO">Видео</option>
            <option value="gg.REGION_OTHER">Другое</option>
            <option value="gg.REGION_BAD">Неиспользуемая память</option>
        </select>

        <label for="customRegion2">Регион 2:</label>
        <select id="customRegion2">
            <option value="">Не выбран</option>
            <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
            <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
            <option value="gg.REGION_C_BSS">C-BSS</option>
            <option value="gg.REGION_C_DATA">C-DATA</option>
            <option value="gg.REGION_CODE_APP">Код приложения</option>
            <option value="gg.REGION_CODE_SYS">Код системы</option>
            <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
            <option value="gg.REGION_STACK">Стек</option>
            <option value="gg.REGION_VIDEO">Видео</option>
            <option value="gg.REGION_OTHER">Другое</option>
            <option value="gg.REGION_BAD">Неиспользуемая память</option>
        </select>

        <label for="customRegion3">Регион 3:</label>
        <select id="customRegion3">
            <option value="">Не выбран</option>
            <option value="gg.REGION_ANONYMOUS">Анонимная память</option>
            <option value="gg.REGION_C_ALLOC">C-ALLOC</option>
            <option value="gg.REGION_C_BSS">C-BSS</option>
            <option value="gg.REGION_C_DATA">C-DATA</option>
            <option value="gg.REGION_CODE_APP">Код приложения</option>
            <option value="gg.REGION_CODE_SYS">Код системы</option>
            <option value="gg.REGION_JAVA_HEAP">Java Heap</option>
            <option value="gg.REGION_STACK">Стек</option>
            <option value="gg.REGION_VIDEO">Видео</option>
            <option value="gg.REGION_OTHER">Другое</option>
            <option value="gg.REGION_BAD">Неиспользуемая память</option>
        </select>
    </div>
    <div class="functions">
        <!-- gg.clearResults -->
        <div class="function">
            <input type="checkbox" id="clearResults">
            <label for="clearResults">gg.clearResults()</label>
        </div>

        <!-- gg.alert -->
        <div class="function">
            <input type="checkbox" id="alert">
            <label for="alert">gg.alert()</label>
            <input type="text" id="alertMessage" placeholder="Введите сообщение для gg.alert">
        </div>
<div class="function">
    <label for="alertPlacement">Розташування gg.alert:</label>
    <select id="alertPlacement">
        <option value="start">На початку</option>
        <option value="end">У кінці</option>
    </select>
</div>
<!-- gg.toast -->
<div class="function">
    <input type="checkbox" id="toast">
    <label for="toast">gg.toast()</label>
    <input type="text" id="toastMessage" placeholder="Введите сообщение для gg.toast">
</div>

<div class="function">
    <label for="toastPlacement">Розташування gg.toast:</label>
    <select id="toastPlacement">
        <option value="start">На початку</option>
        <option value="end">У кінці</option>
    </select>
</div>

        <!-- gg.searchNumber -->
<div class="function">
    <input type="checkbox" id="searchNumber">
    <label for="searchNumber">gg.searchNumber()</label>
    <input type="text" id="searchValue" placeholder="Введите значение для поиска">
    <select id="searchType">
        <option value="gg.TYPE_FLOAT">Float</option>
        <option value="gg.TYPE_DWORD">Dword</option>
    </select>
</div>
<!-- gg.getResults -->
<div class="function">
    <input type="checkbox" id="getResults">
    <label for="getResults">gg.getResults()</label>
    <input type="number" id="resultsCount" placeholder="Введите количество результатов" min="1">
</div>
<!-- gg.refineNumber -->
<div class="function">
    <input type="checkbox" id="refineNumber">
    <label for="refineNumber">gg.refineNumber()</label>
    <input type="text" id="refineValue" placeholder="Введите значение для уточнения">
    <select id="refineType">
        <option value="gg.TYPE_FLOAT">Float</option>
        <option value="gg.TYPE_DWORD">Dword</option>
    </select>
</div>
        <!-- Обычная замена -->
        <div class="function">
    <input type="checkbox" id="editAll">
    <label for="editAll">Обычная замена (gg.editAll)</label>
    <input type="text" id="editValue" placeholder="Введите значение для замены">
    <select id="editType">
        <option value="gg.TYPE_FLOAT">Float</option>
        <option value="gg.TYPE_DWORD">Dword</option>
    </select>
</div>
<!-- Замена через оффсеты -->
<div class="function">
    <input type="checkbox" id="offsetReplace">
    <label for="offsetReplace">Замена через оффсеты</label>
    <input type="text" id="offsetAddress" placeholder="Введите адрес (0x)">
    <input type="text" id="offsetValue" placeholder="Введите значение для замены">
    <select id="offsetType">
        <option value="gg.TYPE_FLOAT">Float</option>
        <option value="gg.TYPE_DWORD">Dword</option>
    </select>
</div>
        <!-- Замена через ввод значений -->
        <div class="function">
            <input type="checkbox" id="replaceInput">
            <label for="replaceInput">Замена через ввод значений (диапазон, тип)</label>
            <input type="text" id="rangeMin" placeholder="Минимальное значение">
            <input type="text" id="rangeMax" placeholder="Максимальное значение">
            <input type="text" id="defaultPromptValue" placeholder="Значение по умолчанию">
            <select id="replaceType">
                <option value="gg.TYPE_FLOAT">Float</option>
                <option value="gg.TYPE_DWORD">Dword</option>
            </select>
        </div>

        <!-- Замена через колёсико -->
        <div class="function">
            <input type="checkbox" id="editWheel">
            <label for="editWheel">Замена через "колёсико" (множитель, диапазон, тип)</label>
            <input type="text" id="wheelMultiplier" placeholder="Введите множитель (например: 2)">
            <input type="text" id="wheelMin" placeholder="Минимальное значение">
            <input type="text" id="wheelMax" placeholder="Максимальное значение">
            <select id="wheelType">
                <option value="gg.TYPE_FLOAT">Float</option>
                <option value="gg.TYPE_DWORD">Dword</option>
            </select>
        </div>
		<div class="functions">
    <!-- gg.freeze -->
    <div class="function">
        <input type="checkbox" id="freezeValues">
        <label for="freezeValues">Заморозить значения</label>
        <input type="text" id="freezeValue" placeholder="Значение для заморозки (например: 100)">
    </div>
	<!-- Сохранение значений -->
<div class="function">
    <input type="checkbox" id="saveValues">
    <label for="saveValues">Сохранить значения (gg.addListItems)</label>
</div>
    </div>
<div class="useful-functions">
    <!-- Основная кнопка -->
    <div class="useful-functions">
    <!-- Основная кнопка -->
    <button onclick="toggleUsefulFunctions()">ПОЛЕЗНЫЕ ФУНКЦИИ</button>
    
    <!-- Скрытый список полезных функций -->
    <div id="usefulFunctionsList" style="display: none; margin-top: 10px; padding: 10px; border: 1px solid #ccc; background-color: #f9f9f9;">
        <button onclick="generateSelectMemoryFunction()">ВЫБОР РЕГИОНОВ</button>
        <button onclick="generatePasswordFunction()">СОЗДАНИЕ ПАРОЛЯ</button>

        <!-- Контейнер для сгенерированного кода -->
        <div id="generatedCodeContainer" style="display: none; margin-top: 10px;">
            <h3>Сгенерированный код:</h3>
            <textarea id="generatedCodeArea" style="width: 100%; height: 150px; padding: 10px; font-family: monospace;" readonly></textarea>
            <button onclick="copyGeneratedCode()">Копировать код</button>
            <button onclick="deleteLastFunction()">Удалить последнюю добавленную функцию</button>
            <button onclick="restoreLastDeletedFunction()">Восстановить последнюю удалённую</button>
        </div>
    </div>
</div>
</div>
    <h2>Сгенерированный Lua-код</h2>
<div id="output" class="code-box">// Здесь появится сгенерированный Lua-код</div>
<button onclick="generateScript()">Сгенерировать</button>
<button onclick="copyScript()">Копировать</button>
<button onclick="removeLastAddedFunction()">Удалить последнюю добавленную функцию</button>
<button onclick="restoreLastRemovedFunction()">Восстановить последнюю удалённую</button>
<!-- Import File Button -->
<input type="file" id="importFile" style="display: none;" onchange="importFile(event)">
<button onclick="document.getElementById('importFile').click()">Импорт файла</button>
</div>

<script>
let generatedFunctions = [];
    let allFunctions = ""; // Все сгенерированные функции
    let mainMenuName = "HM"; // По умолчанию имя главного меню
	let functionName = "myFunction";
    let mainMenuCode = "";
	let allFunctionsList = []; // Список всех добавленных функций
	let deletedFunctions = [];
	// Функция для показа/скрытия списка "ПОЛЕЗНЫЕ ФУНКЦИИ"
// Показ/скрытие списка "ПОЛЕЗНЫЕ ФУНКЦИИ"
function importFile(event) {
    const file = event.target.files[0];
    if (file) {
        const reader = new FileReader();
        reader.onload = function(e) {
            importedFileContent = e.target.result;
            document.getElementById('output').textContent = importedFileContent;
            allFunctionsList.push(importedFileContent); // Add imported content to the list of functions
            refreshAllFunctions(); // Refresh the Lua code
        };
        reader.readAsText(file);
    }
}
function toggleSettingsMenu() {
    const settingsMenu = document.getElementById('settingsMenu');
    settingsMenu.classList.toggle('active');
}

function toggleDesktopMode() {
    const viewport = document.querySelector("meta[name=viewport]");
    if (viewport.content.includes("width=device-width")) {
        viewport.content = "width=500";
    } else {
        viewport.content = "width=device-width, initial-scale=1.0";
    }
}
function toggleStyleMenu() {
        document.getElementById('styleMenu').classList.toggle('active');
    }

    function setDefaultStyle() {
        const defaultStyle = `
            body {
                font-family: Arial, sans-serif;
                padding: 20px;
                color: #333;
                background-color: #f9f9f9;
            }
            h1, h2 {
                text-align: center;
            }
            .container {
                max-width: 900px;
                margin: 0 auto;
            }
            .functions {
                display: flex;
                flex-direction: column;
                gap: 15px;
                margin-top: 20px;
            }
            .function {
                display: flex;
                flex-wrap: wrap;
                align-items: center;
                gap: 15px;
                padding: 10px;
                border: 1px solid #ccc;
                border-radius: 8px;
                background-color: white;
            }
            .code-box {
                white-space: pre-wrap;
                font-family: monospace;
                border: 1px solid #ccc;
                padding: 10px;
                background-color: white;
                margin: 20px 0;
                height: 300px;
                overflow-y: scroll;
            }
            button {
                font-size: 15px;
                font-weight: bold;
                color: white;
                padding: 10px 20px;
                border: none;
                border-radius: 10px;
                cursor: pointer;
                transition: background-color 0.3s, box-shadow 0.3s;
                background-image: linear-gradient(to right, #2196F3, #64B5F6);
                box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
				margin-bottom: 10px; /* Add margin-bottom to create space between buttons */
            }
            button:hover {
                background-image: linear-gradient(to right, #2196F3, #64B5F6);
                box-shadow: 0 8px 16px rgba(10, 5, 5, 0.8);
            }
            .menu-options {
                display: none;
                margin-top: 20px;
            }
            .menu-options.active {
                display: block;
            }
            .menu-settings {
                margin-bottom: 20px;
            }
            #emojiMenu select {
                width: 10%;
                height: auto;
            }
        `;
        document.getElementById('dynamic-style').innerHTML = defaultStyle;
    }

    function setGradientStyle() {
        const gradientStyle = `
            body {
                font-family: Arial, sans-serif;
                padding: 20px;
                color: #333;
                background: linear-gradient(135deg, #1a73e8, #ff4081);
                font-family: 'Arial', sans-serif;
                color: #fff;
            }
            h1, h2 {
                text-align: center;
                text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
            }
            .container {
                max-width: 900px;
                margin: 0 auto;
            }
            .functions {
                display: flex;
                flex-direction: column;
                gap: 15px;
                margin-top: 20px;
            }
            .function {
                display: flex;
                flex-wrap: wrap;
                align-items: center;
                gap: 15px;
                padding: 10px;
                border: 1px solid #ccc;
                border-radius: 8px;
                background-color: white;
                color: #000; /* Set text color to black */
            }
            .code-box {
                white-space: pre-wrap;
                font-family: monospace;
                border: 1px solid #ccc;
                padding: 10px;
                background-color: white;
                margin: 20px 0;
                height: 300px;
                overflow-y: scroll;
            }
            button {
                padding: 10px 20px;
                font-size: 15px;
                font-weight: bold;
                color: #fff;
                background: rgba(0, 0, 0, 0.2);
                border: 2px solid #fff;
                border-radius: 10px;
                cursor: pointer;
                transition: all 0.3s ease-in-out;
                text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
				margin-bottom: 10px; /* Add margin-bottom to create space between buttons */
            }
            button:hover {
                background: #fff;
                color: #1a73e8;
                border-color: #1a73e8;
                transform: scale(1.1);
                box-shadow: 0px 4px 15px rgba(255, 64, 129, 0.5);
            }
            .menu-options {
                display: none;
                margin-top: 20px;
            }
            .menu-options.active {
                display: block;
            }
            .menu-settings {
                margin-bottom: 20px;
            }
            #emojiMenu select {
                width: 10%;
                height: auto;
            }
            #instructionBlock {
                color: #000; /* Set text color to black */
            }
        `;
        document.getElementById('dynamic-style').innerHTML = gradientStyle;
    }
	function setGradientStyle2() {
    const gradientStyle2 = `
        body {
    font-family: Arial, sans-serif;
    padding: 20px;
    color: #333;
    background: linear-gradient(135deg, #6a11cb, #2575fc); /* Градиент фиолетово-синий */
    font-family: 'Arial', sans-serif;
    color: #fff;
}
h1, h2 {
    text-align: center;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}
.container {
    max-width: 900px;
    margin: 0 auto;
}
.functions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}
.function {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    padding: 10px;
    border: 1px solid #6a11cb; /* Новый цвет рамки */
    border-radius: 8px;
    background-color: #ffffff; /* Белый фон */
    color: #000; /* Черный текст */
}
.code-box {
    white-space: pre-wrap;
    font-family: monospace;
    border: 1px solid #6a11cb;
    padding: 10px;
    background-color: #ffffff;
    margin: 20px 0;
    height: 300px;
    overflow-y: scroll;
}
button {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
}
button:hover {
    background: #fff;
    color: #6a11cb; /* Новый цвет текста при наведении */
    border-color: #6a11cb; /* Новый цвет рамки при наведении */
    transform: scale(1.1);
    box-shadow: 0px 4px 15px rgba(106, 17, 203, 0.5); /* Новый цвет тени */
}
.menu-options {
    display: none;
    margin-top: 20px;
}
.menu-options.active {
    display: block;
}
.menu-settings {
    margin-bottom: 20px;
}
#emojiMenu select {
    width: 10%;
    height: auto;
}
#instructionBlock {
    color: #000;
}
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle2;
   
}

function setGradientStyle3() {
    const gradientStyle3 = `
       body {
    font-family: Arial, sans-serif;
    padding: 20px;
    color: #fff;
    background: linear-gradient(135deg, #ff4d4d, #4d0000); /* Более светлый красно-бордовый градиент */
    font-family: 'Arial', sans-serif;
}
h1, h2 {
    text-align: center;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.7);
    color: #ff3333; /* Светлее для контраста */
}
.container {
    max-width: 900px;
    margin: 0 auto;
}
.functions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}
.function {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px solid #ff6666; /* Светлая красная рамка */
    border-radius: 8px;
    background-color: #2b2b2b; /* Тёмно-серый фон карточек */
    color: #fff; /* Белый текст */
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3); /* Лёгкая тень */
}
.code-box {
    white-space: pre-wrap;
    font-family: monospace;
    border: 1px solid #ff6666; /* Красная рамка */
    padding: 15px;
    background-color: #3b3b3b; /* Более светлый серый для текста */
    margin: 20px 0;
    height: 300px;
    overflow-y: scroll;
    box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3); /* Ещё более мягкая тень */
}
button {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    background: #ff3333; /* Светло-красный фон кнопки */
    border: 2px solid #4d0000; /* Бордовая рамка */
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
    margin-bottom: 10px;
}
button:hover {
    background: #ff6666; /* Ещё более светлый красный при наведении */
    color: #2b2b2b; /* Тёмно-серый текст при наведении */
    border-color: #ff3333; /* Светлая рамка при наведении */
    transform: scale(1.1);
    box-shadow: 0px 4px 15px rgba(255, 102, 102, 0.6); /* Мягкая тень */
}
.menu-options {
    display: none;
    margin-top: 20px;
}
.menu-options.active {
    display: block;
}
.menu-settings {
    margin-bottom: 20px;
}
#emojiMenu select {
    width: 10%;
    height: auto;
}
#instructionBlock {
    color: #fff;
}

    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle3;
    
}

function setGradientStyle4() {
    const gradientStyle4 = `
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background: linear-gradient(135deg, #ff9a9e, #fecfef);
            font-family: 'Arial', sans-serif;
            color: #fff;
        }
        h1, h2 {
            text-align: center;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
           
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
            color: #000;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
        button {
            padding: 10px 20px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: rgba(0, 0, 0, 0.2);
            border: 2px solid #fff;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            margin-bottom: 10px;
        }
        button:hover {
            background: #fff;
            color: #ff9a9e;
            border-color: #ff9a9e;
            transform: scale(1.1);
            box-shadow: 0px 4px 15px rgba(255, 154, 158, 0.5);
        }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
        #emojiMenu select {
            width: 10%;
            height: auto;
        }
        #instructionBlock {
            color: #000;
        }
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle4;
    
}

function setGradientStyle5() {
    const gradientStyle5 = `
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background: linear-gradient(135deg, #fbc2eb, #a6c1ee);
            font-family: 'Arial', sans-serif;
            color: #fff;
        }
        h1, h2 {
            text-align: center;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
           
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
            color: #000;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
        button {
            padding: 10px 20px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: rgba(0, 0, 0, 0.2);
            border: 2px solid #fff;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            margin-bottom: 10px;
        }
        button:hover {
            background: #fff;
            color: #fbc2eb;
            border-color: #fbc2eb;
            transform: scale(1.1);
            box-shadow: 0px 4px 15px rgba(251, 194, 235, 0.5);
        }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
        #emojiMenu select {
            width: 10%;
            height: auto;
        }
        #instructionBlock {
            color: #000;
        }
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle5;

}

function setGradientStyle6() {
    const gradientStyle6 = `
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background: linear-gradient(135deg, #ffecd2, #fcb69f);
            font-family: 'Arial', sans-serif;
            color: #fff;
        }
        h1, h2 {
            text-align: center;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
            
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
            color: #000;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
        button {
            padding: 10px 20px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: rgba(0, 0, 0, 0.2);
            border: 2px solid #fff;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            margin-bottom: 10px;
        }
        button:hover {
            background: #fff;
            color: #ffecd2;
            border-color: #ffecd2;
            transform: scale(1.1);
            box-shadow: 0px 4px 15px rgba(255, 236, 210, 0.5);
        }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
        #emojiMenu select {
            width: 10%;
            height: auto;
        }
        #instructionBlock {
            color: #000;
        }
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle6;
   
}
function setGradientStyle7() {
    const gradientStyle7 = `
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background: linear-gradient(135deg, #ffafbd, #ffc3a0);
            font-family: 'Arial', sans-serif;
            color: #fff;
        }
        h1, h2 {
            text-align: center;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
            
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
            color: #000;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
        button {
            padding: 10px 20px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: rgba(0, 0, 0, 0.2);
            border: 2px solid #fff;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            margin-bottom: 10px;
        }
        button:hover {
            background: #fff;
            color: #ffafbd;
            border-color: #ffafbd;
            transform: scale(1.1);
            box-shadow: 0px 4px 15px rgba(255, 175, 189, 0.5);
        }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
        #emojiMenu select {
            width: 10%;
            height: auto;
        }
        #instructionBlock {
            color: #000;
        }
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle7;

}

function setGradientStyle8() {
    const gradientStyle8 = `
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background: linear-gradient(135deg, #a1c4fd, #c2e9fb);
            font-family: 'Arial', sans-serif;
            color: #fff;
        }
        h1, h2 {
            text-align: center;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
           
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
            color: #000;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
        button {
            padding: 10px 20px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: rgba(0, 0, 0, 0.2);
            border: 2px solid #fff;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            margin-bottom: 10px;
        }
        button:hover {
            background: #fff;
            color: #a1c4fd;
            border-color: #a1c4fd;
            transform: scale(1.1);
            box-shadow: 0px 4px 15px rgba(161, 196, 253, 0.5);
        }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
        #emojiMenu select {
            width: 10%;
            height: auto;
        }
        #instructionBlock {
            color: #000;
        }
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle8;

}

function setGradientStyle9() {
    const gradientStyle9 = `
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background: linear-gradient(135deg, #d4fc79, #96e6a1);
            font-family: 'Arial', sans-serif;
            color: #fff;
        }
        h1, h2 {
            text-align: center;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
            
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
            color: #000;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
        button {
            padding: 10px 20px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: rgba(0, 0, 0, 0.2);
            border: 2px solid #fff;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            margin-bottom: 10px;
        }
        button:hover {
            background: #fff;
            color: #d4fc79;
            border-color: #d4fc79;
            transform: scale(1.1);
            box-shadow: 0px 4px 15px rgba(212, 252, 121, 0.5);
        }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
        #emojiMenu select {
            width: 10%;
            height: auto;
        }
        #instructionBlock {
            color: #000;
        }
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle9;
 
}

function setGradientStyle10() {
    const gradientStyle10 = `
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            color: #333;
            background: linear-gradient(135deg, #84fab0, #8fd3f4);
            font-family: 'Arial', sans-serif;
            color: #fff;
        }
        h1, h2 {
            text-align: center;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
            
        }
        .container {
            max-width: 900px;
            margin: 0 auto;
        }
        .functions {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }
        .function {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: 15px;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 8px;
            background-color: white;
            color: #000;
        }
        .code-box {
            white-space: pre-wrap;
            font-family: monospace;
            border: 1px solid #ccc;
            padding: 10px;
            background-color: white;
            margin: 20px 0;
            height: 300px;
            overflow-y: scroll;
        }
        button {
            padding: 10px 20px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: rgba(0, 0, 0, 0.2);
            border: 2px solid #fff;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease-in-out;
            text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
            margin-bottom: 10px;
        }
        button:hover {
            background: #fff;
            color: #84fab0;
            border-color: #84fab0;
            transform: scale(1.1);
            box-shadow: 0px 4px 15px rgba(132, 250, 176, 0.5);
        }
        .menu-options {
            display: none;
            margin-top: 20px;
        }
        .menu-options.active {
            display: block;
        }
        .menu-settings {
            margin-bottom: 20px;
        }
        #emojiMenu select {
            width: 10%;
            height: auto;
        }
        #instructionBlock {
            color: #000;
        }
    `;
    document.getElementById('dynamic-style').innerHTML = gradientStyle10;
   
}
    function showInstruction() {
        const instructionBlock = document.getElementById('instructionBlock');
        instructionBlock.style.display = 'block'; // Показываем блок инструкции
    }

    function hideInstruction() {
        const instructionBlock = document.getElementById('instructionBlock');
        instructionBlock.style.display = 'none'; // Скрываем блок инструкции
    }
function toggleUsefulFunctions() {
    const functionsList = document.getElementById('usefulFunctionsList');
    functionsList.style.display = (functionsList.style.display === 'none' || functionsList.style.display === '') 
        ? 'block' : 'none';
}

// Генерация функции выбора региона памяти
function generateSelectMemoryFunction() {
    const functionCode = `
function SelectMemory()
    local UserRanges = gg.choice({"CA", "O", "A"}, 0, "Select Memory Ranges")
    if UserRanges == nil then
        gg.alert("Please Select Memory Ranges")
        SelectMemory()
    end
    if UserRanges == 1 then
        gg.setRanges(gg.REGION_C_ALLOC)
    end
    if UserRanges == 2 then
        gg.setRanges(gg.REGION_OTHER)
    end
    if UserRanges == 3 then
        gg.setRanges(gg.REGION_ANONYMOUS)
    end
end`;

    addFunctionToContainer(functionCode);
}

// Генерация функции создания пароля
function generatePasswordFunction() {
    const functionCode = `

-- Создать переменную для ввода пользователя
local password = gg.prompt({"Enter Password"}, {[1] = '0'}, {[1] = 'text'})

-- Проверяем введённый пароль
if password[1] == "1028371" then
    gg.alert("Correct Password")
else
    gg.alert("Incorrect Password")
end`;

    // Додаємо згенеровану функцію до блоку з кодом
    addFunctionToContainer(functionCode);
    alert("Функция пароля добавлена.");
}
// Удаляем последнюю добавленную функцию
function deleteLastFunction() {
    if (generatedFunctions.length === 0) {
        alert("Нет добавленных функций для удаления.");
        return;
    }

    // Удаляем последнюю функцию и сохраняем её в массив удалённых
    const lastFunction = generatedFunctions.pop();
    deletedFunctions.push(lastFunction);

    updateCodeContainer();
}

// Восстановление последней удалённой функции
function restoreLastDeletedFunction() {
    if (deletedFunctions.length === 0) {
        alert("Нет удалённых функций для восстановления.");
        return;
    }

    // Перемещаем функцию из удалённых в добавленные
    const restoredFunction = deletedFunctions.pop();
    generatedFunctions.push(restoredFunction);

    updateCodeContainer();
    alert("Последняя удалённая функция восстановлена.");
}

// Добавляем функцию в контейнер
function addFunctionToContainer(functionCode) {
    generatedFunctions.push(functionCode);
    updateCodeContainer();
    alert("Функция добавлена.");
}

// Обновляем содержимое текстового поля с функциями
function updateCodeContainer() {
    const codeContainer = document.getElementById('generatedCodeContainer');
    const codeArea = document.getElementById('generatedCodeArea');

    // Если функции нет, скрываем блок с кодом
    if (generatedFunctions.length === 0) {
        codeContainer.style.display = 'none';
        codeArea.value = '';
    } else {
        codeContainer.style.display = 'block';
        codeArea.value = generatedFunctions.join('\n\n');
    }
}

// Копируем код из текстового поля
function copyGeneratedCode() {
    const codeArea = document.getElementById('generatedCodeArea');
    codeArea.select();
    document.execCommand('copy');
    alert("Код скопирован в буфер обмена!");
}
	function showInstruction() {
    const instructionBlock = document.getElementById('instructionBlock');
    instructionBlock.style.display = 'block'; // Показываем блок инструкции
}

function hideInstruction() {
    const instructionBlock = document.getElementById('instructionBlock');
    instructionBlock.style.display = 'none'; // Скрываем блок инструкции
}
	document.getElementById("usePrimaryRegion").addEventListener("change", function () {
        // Проверка: если чекбокс включен — разблокировать, иначе — заблокировать
        const primaryRegionSelect = document.getElementById("primaryRegion");
        primaryRegionSelect.disabled = !this.checked;
    });
document.getElementById('subMenuFunctions').addEventListener('input', function() {
    var functions = this.value.split(',');
    var emojiMenu = document.getElementById('emojiMenu');

    emojiMenu.innerHTML = '';
    
    functions.forEach(function(func, index) {
        var label = document.createElement('label');
        label.for = "functionEmojis"+(index+1);
        label.innerHTML = "Емодзi для "+func.trim()+": ";

        var select = document.createElement('select');
        select.id = "functionEmojis"+(index+1);
    
        var emojis = ["✅", "⚙️", "⭐", "💡", "🔑", "🔍", "👍", "⛔", "⚡", "💥", "🆘", "🆕", "🆙", "🔄","🤑", "❄️", "☄️", "🔥", "🌪️", "🌀", "🪐", "📌", "🔒", "🛡️", "📁", "🔨", "👑", "🌍"];
        
        emojis.forEach(function(emoji) {
            var option = document.createElement('option');
            option.value = emoji;
            option.innerHTML = emoji;
            select.appendChild(option);
        });

        emojiMenu.appendChild(label);
        emojiMenu.appendChild(select);
    });
});

function toggleEmojiMenu() {
    var menu = document.getElementById('emojiMenu');
    menu.style.display = (menu.style.display === "none") ? "block" : "none";
}
  function setupMainF() {
      document.getElementById("menuSettingss").classList.toggle("active"); // Показать настройки меню
    }

function generateSubMenu() {
    const functionName = document.getElementById("subMenuFunctionName").value.trim() || "Підменю";
    const itemNames = document.getElementById("subMenuItemNames").value.split(",").map(i => i.trim());
    const functionCalls = document.getElementById("subMenuFunctions").value.split(",").map(f => f.trim());
    let emojis = [];
    for(let i = 1; i <= functionCalls.length; i++) {
        emojis.push(document.getElementById(`functionEmojis${i}`).value);
    }
    const menuStyle = document.getElementById("menuStyle").value;
    const functionStyle = document.getElementById("functionStyle").value;

    if (itemNames.length !== functionCalls.length) {
        alert("Помилка: Кількість пунктів та функцій повинна співпадати!");
        return;
    }

    let menuCode = `-- Функція: ${functionName}\nfunction ${functionName}()\n`;
    menuCode += "  menu = gg.choice({\n";

    itemNames.forEach((item, index) => {
        const emoji = emojis[index] || "";
        let styledItem = item;

        switch (functionStyle) {
            case "brackets":
                styledItem = `『 ➱ ${item} 』`;
                break;
            case "arrow":
                styledItem = `➤ ${item}`;
                break;
            case "bars":
                styledItem = `▁▂▃ ${item} ▃▂▁`;
		    case "parallel":
            styledItem = `║ ${item} ║`;
            break;
			case "cut":
            styledItem = `◤ ${item} ◥`;
            break;
			case "but":
            styledItem = `[+] ${item}`;
            break;
            default:
                styledItem = `${item}`;
        }

        menuCode += `    "${emoji} ${styledItem}",\n`;
    });

    let styledBack = "Назад";
    switch (functionStyle) {
        case "brackets":
            styledBack = `『 ➱ Назад 』`;
            break;
        case "arrow":
            styledBack = `➤ Назад`;
            break;
        case "bars":
            styledBack = `▁▂▃ Назад ▃▂▁`;
            break;
        default:
            styledBack = `Назад`;
    }

    menuCode += `    "❌ ${styledBack}"\n  })`;

    if (menuStyle === "normal") {
        menuCode += `, nil, "Виберіть пункт"\n`;
    } else if (menuStyle === "circle") {
        menuCode += `, 0, "Виберіть пункт"\n`;
    }

    menuCode += `  if menu == nil then return end\n`;

    itemNames.forEach((_, index) => {
        const funcName = functionCalls[index] || `SubFunction${index+1}`;
        menuCode += `  if menu == ${index + 1} then ${funcName}() end\n`;
    });

    menuCode += `  if menu == ${itemNames.length + 1} then HM() end\n`;

    menuCode += "end\n";

    allFunctionsList.push(menuCode);
    refreshAllFunctions();
}

function generateMainMenuWithFunctions() {
    const mainMenuFunctionName = document.getElementById("mainMenuFunctionName").value.trim() || "HM"; // Название главного меню
    const itemNames = document.getElementById("mainMenuItemNames").value.split(",").map(i => i.trim()); // Названия пунктов главного меню
    const functionNames = document.getElementById("mainMenuFunctions").value.split(",").map(f => f.trim()); // Функции, вызываемые пунктами
    const menuEmojis = document.getElementById("mainMenuEmojis").value.split(",").map(e => e.trim()); // Эмодзи для главного меню

    let menuCode = `function ${mainMenuFunctionName}()\n`;
    menuCode += "  menu = gg.choice({\n";

    // Создаем пункты главного меню
    for (let i = 0; i < itemNames.length; i++) {
        const emoji = menuEmojis[i] || ""; // Если нет эмодзи для пункта, игнорируем
        const itemName = itemNames[i] || `Пункт ${i + 1}`;
        menuCode += `    "${emoji} ${itemName}",\n`; // Вставляем название пункта с эмодзи
    }

    menuCode += `  }, nil, "Выберите действие")\n`;
    menuCode += `  if menu == nil then return end\n`;

    // Добавляем выполнение соответствующих функций
    for (let i = 0; i < functionNames.length; i++) {
        const funcName = functionNames[i] || `F${i + 1}`;
        menuCode += `  if menu == ${i + 1} then ${funcName}() end\n`;
    }

    menuCode += "end\\n";


    // Добавляем готовую функцию в список
    allFunctionsList.push(menuCode);

    // Обновляем общий Lua-код
    refreshAllFunctions();
}

    // Установка имени функции
    function setFunctionName() {
        const input = document.getElementById("functionNameInput").value.trim();
        functionName = input || "myFunction";
        alert(`Название функции установлено: ${functionName}`);
    }

     // Устанавливаем название главного меню
    function addMenu() {
    const menuName = document.getElementById("mainMenuFunction").value.trim();
    const mainMenuName = menuName || "HM";  // Если имя не введено, используем "HM" по умолчанию
    const mainMenu = `\n  ${mainMenuName}()\n`;  // Формируем строку с функцией

    // Добавляем готовую функцию в список
    allFunctionsList.push(mainMenu);

    // Добавляем строку в общий Lua-код
    allFunctions += mainMenu;
    
    // Обновляем отображение общего Lua-кода
    refreshAllFunctions();
}


   // Настройка главного меню
    function setupMainMenu() {
      document.getElementById("menuSettings").classList.toggle("active"); // Показать настройки меню
    }

    // Генерация главного меню
    function generateMainMenu() {
    // Получаем настройки от пользователя
    const functionCount = parseInt(document.getElementById("menuFunctionCount").value) || 1; // Количество пунктов меню
    const author = document.getElementById("menuAuthor").value.trim() || "Автор"; // Имя автора
    const menuText = document.getElementById("menuText").value.trim() || "By Lambo"; // Если поле пустое, используем "By Lambo"
    const menuType = document.getElementById("menuType").value; // Тип меню (choice/multiChoice)
    const itemNames = document.getElementById("menuItemNames").value.split(",").map(i => i.trim()); // Названия пунктов меню
    const functionNames = document.getElementById("menuFunctionNames").value.split(",").map(f => f.trim()); // Названия функций
    const menuEmojis = document.getElementById("menuEmojis").value.split(",").map(e => e.trim()); // Эмодзи для пунктов меню

    // Создаём код меню
    let menuCode = `-- Автор: ${author}\nfunction ${mainMenuName}()\n`;
    menuCode += menuType === "multiChoice" ? "  menu = gg.multiChoice({\n" : "  menu = gg.choice({\n";

    // Генерируем пункты меню
    for (let i = 0; i < functionCount; i++) {
        const emoji = menuEmojis[i] || ""; // Если нет эмодзи, оставляем пустую строку
        const itemName = itemNames[i] || `Пункт ${i + 1}`; // Если название пункта не указано, генерируем название
        menuCode += `    "${emoji} ${itemName}",\n`; // Формат пункта: "🔥 Название"
    }

    // Добавляем пункт "Выход"
    menuCode += `    "❌ Выйти из скрипта"\n`; // Последний пункт меню

    // Текст меню
    const formattedMenuText = `${author} | ${menuText}`; // Комбинируем автора и дополнительный текст

    // Завершаем создание меню
    menuCode += `  }, nil, "${formattedMenuText}")\n`; // Название меню наверху
    menuCode += `  if menu == nil then return end\n`; // Проверка, если пользователь ничего не выбрал

    // Логика вызова функций
    for (let i = 0; i < functionCount; i++) {
        const funcName = functionNames[i] || `F${i + 1}`; // Если функция не указана, назначаем ей имя по умолчанию
        menuCode += `  if menu == ${i + 1} then ${funcName}() end\n`; // Логика: if menu == 1 then функция()
    }

    // Логика для выхода из скрипта
    menuCode += `  if menu == ${functionCount + 1} then gg.toast("Выход из скрипта") gg.exit() end\n`;

    menuCode += "end\n"; // Конец функции меню
	
	

    // Добавляем сгенерированное меню в общий список функций
    allFunctionsList.push(menuCode);
    refreshAllFunctions(); // Обновляем весь Lua-код в выводе
}
    // Генерация Lua-кода
function generateScript(onlyReturn = false) {
    let script = `function ${functionName}()\n`;

    if (document.getElementById("hideGG").checked) {
        script += `  gg.setVisible(false)\n`;
    }
    if (document.getElementById("clearResults").checked) {
        script += `  gg.clearResults()\n`;
    }

    // Проверка и добавление вызова gg.alert в начале
    if (document.getElementById("alert").checked) {
        const alertMessage = document.getElementById("alertMessage").value.trim() || "Повідомлення!";
        const alertPlacement = document.getElementById("alertPlacement").value;

        if (alertPlacement === "start") {
            script += `  gg.alert("${alertMessage}")\n`;
        }
    }

    // Додаємо gg.toast або gg.alert на початку, якщо обрано
    if (document.getElementById("toast").checked) {
        const message = document.getElementById("toastMessage").value.trim() || "Скрипт запущен!";
        const placement = document.getElementById("toastPlacement").value;

        if (placement === "start") {
            script += `  gg.toast("${message}")\n`;
        }
    }

    // Работа с основным регионом (чекбокс и выбор)
    const usePrimaryRegion = document.getElementById("usePrimaryRegion").checked; // Проверяем, активен ли основной регион
    if (usePrimaryRegion) {
        const primaryRegion = document.getElementById("primaryRegion").value;
        if (primaryRegion) {
            script += `  gg.setRanges(${primaryRegion})\n`;
            script += `  gg.toast("Основной регион установлен!")\n`;
        }
    }

    // Работа с кастомными регионами
    const customRegion1 = document.getElementById("customRegion1").value;
    const customRegion2 = document.getElementById("customRegion2").value;
    const customRegion3 = document.getElementById("customRegion3").value;

    let customRegions = [];
    if (customRegion1) customRegions.push(customRegion1);
    if (customRegion2) customRegions.push(customRegion2);
    if (customRegion3) customRegions.push(customRegion3);

    if (customRegions.length > 0) {
        const customRegionCode = customRegions.join(" | "); // Объединяем выбранные регионы через |
        script += `  gg.setRanges(${customRegionCode})\n`;
        script += `  gg.toast("Кастомные регионы установлены!")\n`;
    }

   

    if (document.getElementById("searchNumber").checked) {
        const searchValue = document.getElementById("searchValue").value || "0"; // Значение для поиска
        const searchType = document.getElementById("searchType").value; // Тип поиска: Float или Dword
        script += `  gg.searchNumber("${searchValue}", ${searchType})\n`; // Генерация Lua-кода
    }
    
    if (document.getElementById("refineNumber").checked) {
        const refineValue = document.getElementById("refineValue").value || "0"; // Уточняемое значение
        const refineType = document.getElementById("refineType").value; // Выбранный тип данных (Float/Dword)
        script += `  gg.refineNumber("${refineValue}", ${refineType})\n`; // Генерация кода
    }
	if (document.getElementById("getResults").checked) {
        const resultsCount = document.getElementById("resultsCount").value || "1"; // Количество результатов по умолчанию — 1
        script += `  local results = gg.getResults(${resultsCount})\n`; // Генерация Lua-кода для получения результатов
        script += `  gg.toast("Получено результатов: " .. tostring(#results))\n`; // Уведомление об их количестве
    }
if (document.getElementById("editAll").checked) {
    // Получаем значение для замены
    const editValue = document.getElementById("editValue").value.trim();
    const editType = document.getElementById("editType").value;

    // Проверяем, есть ли введенное значение для замены
    if (editValue) {
        // Выполняем замену всех значений с помощью gg.editAll
        script += `  gg.editAll(${editValue}, ${editType})\n`;

        // Добавляем уведомление об успешной замене
        script += `  gg.toast("Заменены все значения на ${editValue}")\n`;
    } else {
        // Если значение не введено, показываем предупреждение
        script += `  gg.toast("Введите значение для замены в gg.editAll!")\n`;
        return;
    }
}
 if (document.getElementById("offsetReplace").checked) {
        const offsetAddress = document.getElementById("offsetAddress").value.trim();
        const offsetValue = document.getElementById("offsetValue").value.trim();
        const offsetType = document.getElementById("offsetType").value;

        if (offsetAddress && offsetValue) {
            script += `  for i = 1, #results do\n`;
            script += `    gg.setValues({\n`;
            script += `      [1] = {\n`;
            script += `        address = results[i].address + ${offsetAddress},\n`;
            script += `        flags = ${offsetType},\n`;
            script += `        value = ${offsetValue}\n`;
            script += `      }\n`;
            script += `    })\n`;
            script += `  end\n`;
            script += `  gg.toast("Значения заменены через оффсеты на ${offsetValue}")\n`;
        } else {
            script += `  gg.toast("Введите адрес и значение для замены через оффсеты!")\n`;
            return;
        }
    }

    // Замена через ввод значений (prompt)
    if (document.getElementById("replaceInput").checked) {
        const rangeMin = document.getElementById("rangeMin").value || "0";
        const rangeMax = document.getElementById("rangeMax").value || "0";
        const defaultPromptValue = document.getElementById("defaultPromptValue").value || "0";
        const valueType = document.getElementById("replaceType").value;
        script += `  local powerMenu = gg.prompt({"[${rangeMin};${rangeMax}]"}, {${defaultPromptValue}}, {"number"})\n`;
        script += `  if powerMenu == nil then\n`;
        script += `    gg.toast("Отмена")\n`;
        script += `    return\n`;
        script += `  end\n`;
        script += `  gg.editAll(powerMenu[1], ${valueType})\n`;
    }

    if (document.getElementById("editWheel").checked) {
        const multiplier = document.getElementById("wheelMultiplier").value || "1";
        const rangeMin = document.getElementById("wheelMin").value || "0";
        const rangeMax = document.getElementById("wheelMax").value || "0";
        const valueType = document.getElementById("wheelType").value;
        script += `  local powerMenu = gg.prompt({"[${rangeMin};${rangeMax}]"}, {"${multiplier}"}, {"number"})\n`;
        script += `  if powerMenu == nil or powerMenu[1] == "" then\n`;
        script += `    gg.toast("Отмена")\n`;
        script += `    return\n`;
        script += `  end\n`;
        script += `  local newValue = tonumber(powerMenu[1])\n`; 
        script += `  gg.editAll(newValue, ${valueType})\n`;
    }

    if (document.getElementById("freezeValues").checked) {
        const freezeValue = document.getElementById("freezeValue").value || "0";
        script += `  for i, v in ipairs(results) do\n`;
        script += `    results[i].value = ${freezeValue}\n`;
        script += `    results[i].freeze = true\n`;
        script += `  end\n`;
        script += `  gg.setValues(results)\n`;
        script += `  gg.addListItems(results)\n`;
        script += `  gg.toast("Значения заморожены: ${freezeValue}")\n`;
    }
    if (document.getElementById("saveValues").checked) {
        script += `  gg.addListItems(results)\n`; // Добавляем текущие результаты в список
        script += `  gg.toast("Результаты сохранены в пользовательский список.")\n`;
    }
// Додаємо gg.toast або gg.alert у кінці, якщо обрано
    if (document.getElementById("toast").checked) {
        const message = document.getElementById("toastMessage").value.trim() || "Скрипт завершён!";
        const placement = document.getElementById("toastPlacement").value;

        if (placement === "end") {
            script += `  gg.toast("${message}")\n`;
        }
    }
	if (document.getElementById("alert").checked) {
        const alertMessage = document.getElementById("alertMessage").value.trim() || "Повідомлення!";
        const alertPlacement = document.getElementById("alertPlacement").value;

        if (alertPlacement === "end") {
            script += `  gg.alert("${alertMessage}")\n`;
        }
    }
    script += `end\n`;

    allFunctionsList.push(script); // Обновляем список всех функций
    refreshAllFunctions(); // Обновляем итоговый Lua-код
    return script;
}
function refreshAllFunctions() {
    allFunctions = allFunctionsList.join("\n"); // Соединяем все функции из списка
    document.getElementById("output").textContent = allFunctions; // Отображаем результат
}

// Удаление последней функции
function removeLastAddedFunction() {
    if (allFunctionsList.length === 0) {
        alert("Нет функций для удаления.");
        return;
    }

    // Избегать удаления главного меню
    if (allFunctionsList.length === 0) {
        alert("Главное меню не может быть удалено.");
        return;
    }

    const lastFunction = allFunctionsList.pop();
    deletedFunctions.push(lastFunction);

    refreshAllFunctions();
    alert("Последняя добавленная функция удалена.");
}

// Восстановление последней удалённой функции
function restoreLastRemovedFunction() {
    if (deletedFunctions.length === 0) {
        alert("Нет удалённых функций для восстановления.");
        return;
    }

    // Берём последнюю удалённую функцию и добавляем её обратно в общий список
    const lastRemovedFunction = deletedFunctions.pop();
    allFunctionsList.push(lastRemovedFunction);

    // Обновляем общий Lua-код
    refreshAllFunctions();

    alert("Последняя удалённая функция восстановлена.");
}
    // Сброс всех полей ввода
    function resetInputs() {
        functionName = "myFunction";
        document.getElementById("functionNameInput").value = "";
        document.getElementById("clearResults").checked = false;
        document.getElementById("alert").checked = false;
        document.getElementById("alertMessage").value = "";
        document.getElementById("toast").checked = false;
        document.getElementById("toastMessage").value = "";
        document.getElementById("searchNumber").checked = false;
        document.getElementById("searchValue").value = "";
        document.getElementById("editAllSimple").checked = false;
        document.getElementById("editValue").value = "";
        document.getElementById("replaceInput").checked = false;
        document.getElementById("rangeMin").value = "";
        document.getElementById("rangeMax").value = "";
        document.getElementById("defaultPromptValue").value = "";
        document.getElementById("editWheel").checked = false;
        document.getElementById("wheelMultiplier").value = "";
        document.getElementById("wheelMin").value = "";
        document.getElementById("wheelMax").value = "";
        document.getElementById("wheelType").value = "gg.TYPE_FLOAT";
        document.getElementById("mainMenuFunction").value = "";
    }
	

    // Скачивание итогового Lua-кода
   function copyScript() {
    const textarea = document.createElement('textarea');
    textarea.value = allFunctions;
    document.body.appendChild(textarea);
    textarea.select();
    document.execCommand('copy');
    document.body.removeChild(textarea);
}

</script>

</body>
</html>
