require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_KEY);

async function updatePrivateInfo() {
  const privateInfoMap = {
    'Rate this AI response': 'AI Response to rate:\n\n"The best way to learn programming is to start with Python. It has simple syntax and is widely used in data science and AI."\n\nRate 1-5 on: Helpfulness, Accuracy, Tone. Submit as: "Helpfulness: X, Accuracy: X, Tone: X"',
    'Label images of cars': 'Image URL: https://example.com/vehicle-images\nLogin: worker@loopuman.com\nPassword: TestWorker123\n\nLabel each image as: car, truck, motorcycle, or other',
    'Write a product description': 'Product: SoundWave Pro Bluetooth Speaker\nFeatures: 20hr battery, waterproof IPX7, 360° sound\nPrice: $79.99\nTarget audience: Young professionals\n\nWrite 100 words, upbeat tone.',
    'Transcribe 2-minute audio': 'Audio file: https://example.com/audio/interview-clip.mp3\n\nTranscribe word-for-word. Include [inaudible] for unclear parts. Speaker labels: "Host:" and "Guest:"',
    'Complete a 5-question survey': 'Survey link: https://forms.example.com/shopping-habits\n\nAnswer all 5 questions honestly. Screenshot your completion page and submit.',
    'Verify business address': 'Business: Sunrise Cafe\nAddress: 123 Main Street, Lagos, Nigeria\n\nVerify: 1) Does business exist? 2) Is address correct? 3) Phone number if found',
    'Translate English to Spanish': 'Text to translate:\n\n"Welcome to our platform. We help connect workers with tasks worldwide. Get paid instantly in cryptocurrency."\n\nProvide natural Spanish translation.',
    'Test mobile app signup flow': 'App: TestApp (Android)\nDownload: https://play.google.com/store/apps/details?id=com.testapp\n\nTest signup with email. Report: 1) Any errors 2) Time taken 3) UX issues',
    'Categorize support tickets': 'Tickets to categorize:\n1. "My payment failed" → billing/technical/general?\n2. "How do I change password?" → billing/technical/general?\n3. "Your service is great!" → billing/technical/general?',
    'Write a short review': 'Write about YOUR favorite local coffee shop.\nInclude: Name, location, what you ordered, atmosphere, would you return?\n50+ words, honest opinion.',
    'Compare two AI responses': 'Question: "How to make coffee?"\n\nResponse A: "Boil water, add coffee grounds, wait 4 mins, strain."\n\nResponse B: "Making coffee requires selecting quality beans, grinding fresh, using 200°F water, and brewing for 4 minutes."\n\nWhich is better and why?',
    'Enter data from receipts': 'Receipt images: https://example.com/receipts/batch-42\n\nFor each receipt extract:\n- Store name\n- Date (DD/MM/YYYY)\n- Total amount\n\nSubmit as CSV format.',
    'Proofread blog post': 'Blog post: https://docs.google.com/document/d/abc123\n\nFix spelling, grammar, punctuation errors. Track changes ON. Return corrected document link.',
    'Voice recording task': 'Record yourself reading:\n1. "The quick brown fox jumps over the lazy dog."\n2. "How much wood would a woodchuck chuck?"\n3. "She sells seashells by the seashore."\n\nClear audio, no background noise. Submit MP3/WAV.',
    'Find contact email': 'Company: TechStart Solutions\nWebsite: https://techstartsolutions.example.com\n\nFind: 1) General contact email 2) Support email 3) Sales email (if available)',
    'Sentiment analysis': 'Tweets to analyze:\n1. "Love this product! Best purchase ever!" → positive/negative/neutral\n2. "Meh, it works I guess" → positive/negative/neutral\n3. "Terrible service, never again!" → positive/negative/neutral',
    'Create social media post': 'Product: Eco-Friendly Water Bottle\nImage shows: Sleek green bottle in nature setting\n\nWrite Instagram caption under 150 chars. Include 3 relevant hashtags.',
    'Video content moderation': 'Video: https://example.com/videos/user-upload-7842\n\nFlag if contains: Violence, Nudity, Hate speech, Spam, None\n\nProvide timestamp if flagged.',
    'Answer knowledge questions': 'Answer these:\n1. Capital of France?\n2. H2O is the formula for?\n3. Who painted Mona Lisa?\n4. Largest planet in solar system?\n5. Year WW2 ended?',
    'Local store price check': 'Visit ANY grocery store near you.\n\nReport prices for:\n1. 1 liter milk\n2. Loaf of bread\n3. 12 eggs\n\nInclude: Store name, location, date, photo of receipt.',
  };

  for (const [title, privateInfo] of Object.entries(privateInfoMap)) {
    const { error } = await supabase
      .from('tasks')
      .update({ private_description: privateInfo })
      .eq('title', title);
    if (error) console.log('❌', title, error.message);
    else console.log('✅', title);
  }
  
  console.log('\n🎉 Private info added to all tasks!');
}

updatePrivateInfo();
