<template>
  <div
    class="button custom-button"
    :data-element="dataElement"
    :class="{
      [type]: type,
      disabled,
      [className]: className
    }"
    @click="disabled || !onClick ? NOOP() : onClick($event)"
    @dblclick="disabled ? NOOP : onDoubleClick"
    @mouseup="disabled ? NOOP : onDoubleClick"
    :disabled="disabled"
    :title="title"
  >
    <template v-if="img">
      <div v-if="isSVG" v-html="img" class="img"></div>
      <img v-else :src="img" alt="" class="img">
    </template>
    <span v-if="item.dropItem" class="text">{{ item.text }}</span>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
import { useViewerStore } from '@/stores/modules/viewer'
import { useDocumentStore } from '@/stores/modules/document'
import { computed } from 'vue'
import core from '@/core'
const useViewer = useViewerStore()
const useDocument = useDocumentStore()

const { item } = defineProps(['item'])
const {
  type,
  img,
  dataElement,
  onClick,
  title,
  disabled,
  className
} = item

const isSVG = img?.trim().toLowerCase().startsWith('<svg');

const NOOP = (e) => {
  e?.stopPropagation()
  e?.preventDefault()
}
</script>

<style lang="scss">
</style>