#!/usr/bin/env bun

console.log('Minimal Debug Test')

// Test basic fetch first
console.log('\n1. Testing raw fetch...')
try {
  const response = await fetch('https://api.github.com/users/torvalds')
  const data = await response.json()
  console.log('✅ Raw fetch works:', data.login)
} catch (error) {
  console.error('❌ Raw fetch failed:', error)
}

// Test the revolutionary module
console.log('\n2. Testing revolutionary module...')
try {
  const { tf } = await import('../src/index.js')
  console.log('✅ Module imported')
  
  // Add temporary debug logging
  const originalFetch = global.fetch
  let fetchCallCount = 0
  global.fetch = async (...args) => {
    console.log(`   [DEBUG] fetch called #${++fetchCallCount}:`, args[0])
    const result = await originalFetch(...args)
    console.log(`   [DEBUG] fetch returned status:`, result.status)
    return result
  }
  
  console.log('\n3. Calling tf.get...')
  try {
    const result = await tf.get('https://api.github.com/users/torvalds')
    console.log('✅ tf.get succeeded:', result.data?.login)
  } catch (error) {
    console.error('❌ tf.get failed:', error)
    console.error('Stack:', error.stack)
  }
  
  // Restore original fetch
  global.fetch = originalFetch
  
} catch (error) {
  console.error('❌ Module import failed:', error)
}