<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>hesa.lol</title>
  <style>
    body {
      font-family: Arial, sans-serif;
    }
    #dropzone {
      width: 100%;
      max-width: 600px;
      margin: 50px auto;
      padding: 20px;
      border: 2px dashed #cccccc;
      text-align: center;
      color: #666666;
      cursor: pointer;
    }
    #dropzone.hover {
      border-color: #0066cc;
      background-color: #f0f8ff;
    }
    input[type="file"] {
      display: none;
    }
    #message {
      margin-top: 20px;
      color: black;
    }
    .btn {
      display: block;
      width: 200px;
      margin: 20px auto;
      padding: 10px;
      text-align: center;
      background-color: #000000;
      color: white;
      font-size: 16px;
      text-decoration: none;
      border-radius: 5px;
    }
    .btn:hover {
      background-color: #333333;
    }
    #info-text {
      text-align: center;
      margin-top: 20px;
      margin-bottom: 10px;
      color: #000000;
      font-size: 18px;
      font-weight: bold;
    }
    #discord-link {
      text-align: center;
      margin-top: 10px;
      font-size: 16px;
    }
    #discord-link a {
      color: #aaaaaa;
      text-decoration: none;
      font-weight: bold;
    }
    #discord-link a:hover {
      text-decoration: underline;
    }
  </style>
</head>
<body>
  <div id="dropzone">Select or drop files</div>
  <input type="file" id="fileInput" />
  <div id="message"></div>

  <!-- Information Text -->
  <div id="info-text">All upload(s) will NOT expire!</div>

  <!-- Discord Link -->
  <div id="discord-link">
    <p><a href="https://discord.gg/botnet" target="_blank">Discord Invite</p>
  </div>

  <!-- FAQ Button -->
  <a href="https://hesa.lol/faq" class="btn" target="_blank">Go to FAQ</a>

  <!-- TOS Button -->
  <a href="https://hesa.lol/tos" class="btn" target="_blank">Go to TOS</a>

  <script>
    const dropzone = document.getElementById("dropzone");
    const fileInput = document.getElementById("fileInput");
    const message = document.getElementById("message");

    // Highlight the dropzone on drag events
    dropzone.addEventListener("dragover", (e) => {
      e.preventDefault();
      dropzone.classList.add("hover");
    });

    dropzone.addEventListener("dragleave", () => {
      dropzone.classList.remove("hover");
    });

    // Handle file drop
    dropzone.addEventListener("drop", (e) => {
      e.preventDefault();
      dropzone.classList.remove("hover");
      const file = e.dataTransfer.files[0];
      if (file) {
        uploadFile(file);
      }
    });

    // Handle file selection via click
    dropzone.addEventListener("click", () => {
      fileInput.click();
    });

    fileInput.addEventListener("change", () => {
      const file = fileInput.files[0];
      if (file) {
        uploadFile(file);
      }
    });

    // Upload file function
    async function uploadFile(file) {
      const formData = new FormData();
      formData.append("file", file);

      try {
        const response = await fetch("https://hesa.lol/upload.php", {
          method: "POST",
          body: formData,
        });

        if (response.ok) {
          const result = await response.text();
          message.innerHTML = result; // Show the shareable link returned by PHP
        } else {
          message.textContent = "File upload failed.";
        }
      } catch (error) {
        console.error("Error uploading file:", error);
        message.textContent = "An error occurred while uploading the file.";
      }
    }
  </script>
</body>
</html>