<script setup lang="ts">
import cogIcon from '~/assets/images/icons/cog.png'
import pearlIcon from '~/assets/images/icons/pearl.gif'

const theme = useVThemeSSR()
const config = useAppConfig()
const fqdn = config.url.split('//')[1]

const mailTemplate = `I've just found a bug on ${config.url} and would like to report it.%0D%0A%0D%0AWebsite version: ${
  config.build.version
}%0D%0ABuild date: ${
  config.build.date
}%0D%0ATimestamp: ${new Date().toISOString()}%0D%0A%0D%0A%0D%0ASteps to reproduce:%0D%0A{ Explain in detail what happened here, or attach a video/screenshot }%0D%0A%0D%0AAdditional information:%0D%0A{ Helpful information, such as developer console output / Leave empty if none }%0D%0A%0D%0A%0D%0A// Keep in mind that it's just a template, you can change it as you wish! :)`
</script>

<template>
  <VDialog>
    <template #activator="{ props }">
      <div v-bind="props" class="options clickable">
        <img
          draggable="false"
          :src="cogIcon"
          alt="Options"
          class="logo user-select-none"
        />
      </div>
    </template>
    <template #default="{ isActive }">
      <VCard>
        <template #title>
          <h3 class="alex text-align-center">Site options</h3>
        </template>
        <div class="overlay background"></div>
        <VCardText class="overlay content">
          <img
            draggable="false"
            :src="pearlIcon"
            alt="Pearl"
            class="icon-badge user-select-none"
          />
          <div>
            <div class="row">
              <div class="col-12 col-sm-6">
                <p>
                  <strong>Theme</strong><br />
                  Available in all flavors, vanilla and chocolate.
                </p>
              </div>
              <div class="col-12 col-sm-6">
                <p>
                  <strong>Animation</strong><br />
                  Some computers may have issues rendering that gorgeous
                  background animation. Enabling it substantially increases
                  power consumption.
                </p>
              </div>
            </div>
          </div>
          <EMail
            class="link-hi"
            :address="`contact@${fqdn}`"
            :cc="`admin@${fqdn}`"
            :subject="`Bug report: ${fqdn}`"
            :body="mailTemplate"
          >
            <strong>Report a bug</strong>
          </EMail>
        </VCardText>
        <VCardActions>
          <VSpacer></VSpacer>
          <VBtn color="danger" @click="theme.toggle()" />
          <VBtn
            variant="outlined"
            prepend-icon="close"
            @click="isActive.value = false"
          >
            Close
          </VBtn>
        </VCardActions>
      </VCard>
    </template>
  </VDialog>
</template>

<style scoped lang="scss">
.options {
  display: flex;
  position: fixed;

  top: 0;
  right: 0;

  padding: 10px;
}

.icon-badge {
  position: fixed;

  top: -16px;
  left: -16px;

  transform: rotate(-30deg);
}

.logo {
  width: 16px;
  height: 16px;
}
</style>
