import { defineStore } from 'pinia'

export const useTourStore = defineStore('tour', () => {
  const showAskTabTour = ref(false)

  const shouldShowAskTabTour = ref(false)
  let hasHitTimes = Number(localStorage.getItem('hasHitAskTabTourTimes')) || 0
  const MAX_HIT_TIMES = 3

  const hitAskTabTour = async () => {
    if (hasHitTimes >= MAX_HIT_TIMES) return

    hasHitTimes++
    localStorage.setItem('hasHitAskTabTourTimes', String(hasHitTimes))
    showAskTabTour.value = true
  }

  return {
    showAskTabTour,
    shouldShowAskTabTour,
    hitAskTabTour,
  }
})
