<script setup lang="ts">
import { computed } from 'vue'
import { cva, type VariantProps } from 'class-variance-authority'
import { cn } from '@/lib/utils'

const buttonVariants = cva(
  'inline-flex items-center justify-center whitespace-nowrap rounded-2xl text-[13px] font-bold ring-offset-background transition-all active:scale-95 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary/10 disabled:pointer-events-none disabled:opacity-50',
  {
    variants: {
      variant: {
        default: 'bg-primary text-primary-foreground hover:shadow-lg hover:shadow-primary/25',
        destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
        outline: 'border border-black/[0.08] bg-white hover:bg-secondary hover:text-foreground shadow-sm',
        secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/70 border border-black/[0.02]',
        ghost: 'hover:bg-secondary hover:text-foreground',
        link: 'text-primary underline-offset-4 hover:underline',
        hero: 'bg-primary text-primary-foreground rounded-full px-10 shadow-xl shadow-primary/20 hover:scale-[1.02]',
        heroOutline: 'border border-black/[0.08] bg-white text-foreground hover:bg-secondary rounded-full px-10'
      },
      size: {
        default: 'h-10 px-6 py-2',
        sm: 'h-8 px-4',
        lg: 'h-12 rounded-full px-10',
        xl: 'h-14 rounded-full px-12 text-base',
        icon: 'h-10 w-10',
      },
    },
    defaultVariants: {
      variant: 'default',
      size: 'default',
    },
  }
)

type ButtonVariants = VariantProps<typeof buttonVariants>

interface Props {
  variant?: ButtonVariants['variant']
  size?: ButtonVariants['size']
  as?: any
  to?: string | any
  href?: string
}

const props = withDefaults(defineProps<Props>(), {
  as: 'button',
})
</script>

<template>
  <component
    :is="as"
    :to="to"
    :href="href"
    :class="cn(buttonVariants({ variant, size }), $attrs.class ?? '')"
  >
    <slot />
  </component>
</template>
