import { put } from '@vercel/blob'
import type { StorageProvider, StorageUploadOptions } from './types'

/**
 * Vercel Blob storage provider implementation
 */
export class VercelBlobStorage implements StorageProvider {
  private token: string

  constructor(token: string) {
    if (!token) {
      throw new Error('Vercel Blob token is required')
    }
    this.token = token
  }

  async upload(key: string, blob: Blob, _options?: StorageUploadOptions): Promise<string> {
    // Vercel Blob only supports 'public' access
    // Options parameter is kept for interface compatibility but not used
    const { url } = await put(key, blob, {
      access: 'public',
      token: this.token
    })
    return url
  }
}
