<template>
  <teleport to="body" v-if="currentTag.hotspotType">
    <div class="tag-layer" @click.stop>
      <div class="tag-header">
        <span>{{ currentTag.hotspotTitle }}</span>
        <ui-icon
          class="close"
          @click.stop="close"
          type="player_close"
        ></ui-icon>
      </div>
      <metasImage @close="close" v-if="currentTag.hotspotType == 'image'" />
      <metasWeb v-if="currentTag.hotspotType == 'link'" />
      <metasAudio v-if="currentTag.hotspotType == 'audio'" />
      <metasVideo v-if="currentTag.hotspotType == 'video'" />
      <metasText v-if="currentTag.hotspotType == 'textarea'" />
      <metasPdf v-if="currentTag.hotspotType == 'pdf'" />
      <metasArticle v-if="currentTag.hotspotType == 'article'" />
      <metasImageText
        @close="close"
        v-if="currentTag.hotspotType == 'imageText'"
      />
    </div>
  </teleport>
</template>

<script setup>
import metasImage from "./metas/metas-image";
import metasWeb from "./metas/metas-web";
import metasAudio from "./metas/metas-audio";
import metasVideo from "./metas/metas-video";
import metasText from "./metas/metas-text";
import metasPdf from "./metas/metas-pdf.vue";
import metasArticle from "./metas/metas-article.vue";
import metasImageText from "./metas/metas-imagetext.vue";

import {
  reactive,
  defineEmits,
  onBeforeMount,
  onMounted,
  ref,
  watchEffect,
  computed,
  watch,
  nextTick,
} from "vue";
import { useStore } from "vuex";
const store = useStore();

const currentTag = computed(() => store.getters["tags/currentTag"]);

const emit = defineEmits(["close"]);

const close = () => {
  emit("close");
  store.commit("tags/setCurrentTag", {});
};
</script>

<style lang="scss" scoped>
.tag-layer {
  width: 100%;
  height: 100%;
  z-index: 10000;
  top: 0;
  position: fixed;
  left: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  .tag-header {
    display: flex;
    width: 100%;
    padding: 0 20px;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    font-size: 18px;
    border-bottom: solid 1px rgba(255, 255, 255, 0.16);
    color: #fff;

    > span {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .close {
      color: rgba(255, 255, 255, 0.6);
      z-index: 999;
    }
  }
}
</style>
