<template>
  <Button
    :isActive="isActive"
    img="icon-hand-tool"
    v-bind="{ ...item }"
    :onClick="onClick"
    :title="$t('header.pan')"
  >
    <Pantool />
  </Button>
</template>

<script setup>
  import { useViewerStore } from '@/stores/modules/viewer'
  import { useDocumentStore } from '@/stores/modules/document'
  import { computed } from 'vue'
  import core from '@/core'
  const { switchTool, switchAnnotationEditorMode } = core
  const useViewer = useViewerStore()
  const useDocument = useDocumentStore()
  const { item } = defineProps(['item'])

  const isActive = computed(() => {
    return useViewer.getActiveHand
  })
  const onClick = () => {
    window.getSelection().empty()
    useViewer.toggleActiveHand(!isActive.value)
    const mode = isActive.value ? 1 : 0
    switchTool(mode)
    switchAnnotationEditorMode(0)
    useViewer.closeActiveStickNote()
    core.webViewerNamedAction('Find', 4)

    useDocument.setToolState('')
    useViewer.setSearchStatus(false)
  }
</script>
