<script lang="ts">
  async function downloadAPK() {
    try {
      const response = await fetch("https://pub-7bffd5f7a2874c54bc70ce78955004de.r2.dev/calchat.apk");
      const blob = await response.blob();
      const objectUrl = URL.createObjectURL(blob);

      const a = document.createElement("a");
      a.style.display = "none";
      a.href = objectUrl;
      a.download = "calchat.apk";

      document.body.appendChild(a);
      a.click();

      document.body.removeChild(a);
      URL.revokeObjectURL(objectUrl);
    } catch (error) {
      console.error(`coudn't download calchat apk: ${error}`);
    }
  }
</script>

<h1 class="text-4xl font-bold">This is where CalChat builds can be downloaded from.</h1>
<h3 class="text-xl font-bold">Currently only available for Android arm64</h3>
<button on:click={downloadAPK}>Download APK here!</button>
