import { useToast } from '@astryxdesign/core'

export interface DeckToastOptions {
  title: string
  description?: string
  tone?: 'success' | 'danger'
}

export interface DeckToastFn {
  toast(options: DeckToastOptions): void
}

/** astryx toast bridge keeping the prior title/description/tone contract (title/description/tone). */
export function useDeckToast(): DeckToastFn {
  const showToast = useToast()
  return {
    toast(options) {
      showToast({
        type: options.tone === 'danger' ? 'error' : 'info',
        body: (
          <span className="flex flex-col gap-0.5">
            <strong>{options.title}</strong>
            {options.description && <span className="max-w-72 text-sm opacity-80">{options.description}</span>}
          </span>
        ),
      })
    },
  }
}