require('dotenv').config();
const s=require('@supabase/supabase-js').createClient(process.env.SUPABASE_URL,process.env.SUPABASE_SERVICE_KEY);
const TASKS = [
  {title:'Classify this product image by clothing type',description:'Look at a product image and classify it into: shirt, pants, dress, jacket, shoes, accessories, other. Also rate image quality 1-5.\n\nRespond with:\nCategory: [type]\nQuality: [1-5]',category:'data',budget:10,source:'api'},
  {title:'Rate this AI-generated response for accuracy',description:'Read the AI-generated response and rate on:\n- Accuracy (1-5)\n- Helpfulness (1-5)\n- Safety (1-5)\n- Overall (1-5)\n\nProvide a 1-sentence justification for each rating.',category:'data',budget:15,source:'api'},
  {title:'Tag sentiment of this customer review',description:'Read this customer review and tag sentiment as: positive, negative, neutral, or mixed. Identify main topic (product quality, shipping, customer service, price, other).\n\nFormat:\nSentiment: [tag]\nTopic: [topic]\nConfidence: [high/medium/low]',category:'data',budget:10,source:'api'},
  {title:'Verify if two product listings are duplicates',description:'Compare two e-commerce listings:\nProduct A: "Premium Wireless Earbuds - Black, 24hr Battery"\nProduct B: "Wireless Earbuds Pro - Midnight, All-Day Battery"\n\nRespond: DUPLICATE / NOT DUPLICATE / UNCERTAIN\nExplain in 2-3 sentences.',category:'data',budget:15,source:'api'},
  {title:'Label the emotion in this text snippet',description:'Identify primary emotion: joy, sadness, anger, fear, surprise, disgust, trust, anticipation.\n\nText: "I just found out I got accepted to my dream school after three years of trying!"\n\nEmotion: [label]\nIntensity: [low/medium/high]\nSecondary emotion: [label]',category:'data',budget:10,source:'api'},
  {title:'Write a 50-word product description for eco water bottle',description:'Write compelling 50-word description for eco-friendly reusable water bottle. Target: health-conscious millennials. Tone: friendly, informative. Include one call-to-action. Exactly 50 words.',category:'writing',budget:15,source:'api'},
  {title:'Write 3 engaging tweet ideas about remote work',description:'Write 3 tweets (max 280 chars each) about remote work benefits.\n- Engaging and shareable\n- 1-2 hashtags each\n- Target: tech professionals\n- Vary tone: inspirational, humorous, practical',category:'writing',budget:15,source:'api'},
  {title:'Proofread this paragraph and fix all errors',description:'Fix grammar, spelling, punctuation. Return corrected with changes in [brackets].\n\nOriginal: "Their going to the store tommorrow to by some grocerys. The whether looks like it will be nice, so they might walks their dog too."',category:'writing',budget:10,source:'api'},
  {title:'Write a professional email declining a meeting',description:'Professional warm email declining meeting. Context: PM cannot attend 2hr brainstorm Friday due to customer demo.\n\n80-100 words, suggest alternative, positive tone, include subject line.',category:'writing',budget:20,source:'api'},
  {title:'Find 3 competitors for a meal prep planning app',description:'Research 3 meal prep apps. Each:\n1. Name\n2. App Store rating\n3. Key feature\n4. Price\n5. One weakness\n\nCite sources.',category:'research',budget:20,source:'api'},
  {title:'Verify if this business is real and operating',description:'Verify "GreenLeaf Organics" in Portland, Oregon.\nProvide: Website, Phone, Address, Google rating, Currently operating? Evidence.',category:'research',budget:20,source:'api'},
  {title:'Find current pricing for 3 CRM tools',description:'Current pricing for HubSpot CRM, Pipedrive, Zoho CRM.\nEach: Free tier? Cheapest paid plan, Enterprise price, Source URL.\nMust be current from official sites.',category:'research',budget:25,source:'api'},
  {title:'Answer 5 questions about food delivery habits',description:'Answer honestly:\n1. How often order delivery?\n2. Which app most?\n3. Average order value USD?\n4. Most important: speed, price, variety?\n5. Biggest complaint?\n\nBe specific, no one-word answers.',category:'survey',budget:10,source:'api'},
  {title:'Rate 3 app name ideas for meditation app',description:'Rate 1-10:\n1. "MindFlow"\n2. "StillPoint"\n3. "BreathEasy"\n\nConsider: memorability, clarity, emotional resonance. Suggest one better alternative.',category:'survey',budget:15,source:'api'},
  {title:'Which landing page headline is better?',description:'Which would you click?\nA: "Get More Done in Less Time"\nB: "Stop Working Harder. Start Working Smarter."\n\nChoice, Why (2-3 sentences), Age range, Profession.',category:'survey',budget:10,source:'api'},
  {title:'Translate 3 service phrases to Spanish',description:'To Latin American Spanish:\n1. "Welcome! How can I help?"\n2. "This item is 20% off."\n3. "Sign up for our newsletter?"\n\nFormal (usted) and informal (tu) versions.',category:'translation',budget:15,source:'api'},
  {title:'Translate product tagline to French',description:'To French:\nProduct: "FreshBrew Coffee Pods"\nTagline: "Your perfect cup, every morning"\n\nOption A: Literal\nOption B: Creative localized\nExplain cultural reasoning.',category:'translation',budget:20,source:'api'},
  {title:'Describe this uploaded image in detail',description:'Detailed description:\n1. Main subject\n2. Colors/lighting\n3. Text visible\n4. Mood/tone\n5. Setting\n6. Anything unusual\n\n3-5 sentences, specific and objective.',category:'image',budget:10,source:'api'},
  {title:'Check AI-generated image for artifacts',description:'Check for: extra/missing fingers, distorted text, unnatural textures, background issues, lighting errors.\n\nRate quality 1-10, list every artifact with location.',category:'image',budget:15,source:'api'},
  {title:'Transcribe 30-second audio clip',description:'Provide: word-for-word transcription, speaker count, background noises, language/accent, confidence level. Timestamp speaker changes.',category:'audio',budget:20,source:'api'},
  {title:'Suggest 5 names for AI support startup',description:'AI customer support tool for small business. 5 names:\n- Memorable, easy to spell\n- Check .com availability\n- Professional but approachable\nExplain why each works.',category:'other',budget:15,source:'api'},
  {title:'Create color palette for wellness app',description:'5 colors for health/wellness app. Each: hex code, where to use, why it works. Calming, trustworthy, modern.',category:'other',budget:15,source:'api'},
  {title:'Test loopuman.com user experience',description:'Visit https://loopuman.com\n1. Loads? 2. Load time? 3. Mobile-friendly? 4. Broken links? 5. Design (1-10) 6. Value prop clear in 5s? 7. One improvement.',category:'other',budget:15,source:'api'},
  {title:'Annotate pedestrians in rainy driving scene',description:'AUTONOMOUS VEHICLE DATA LABELING\nDashcam frame, heavy rain:\n1. Count pedestrians\n2. Each: location, visibility, action\n3. Cyclists/signs\n4. Visibility rating (1-5)\nSafety-critical accuracy required.',category:'data',budget:25,source:'api'},
  {title:'Rank 3 AI responses for RLHF training',description:'RLHF: Rank best(1) to worst(3).\nPrompt: "What if having heart attack?"\nA: "Call 911. Chew aspirin, sit upright, unlock door."\nB: "See a doctor when you get a chance."\nC: "Deep breaths and water. Call if not better in an hour."\nRate each: Helpfulness, Accuracy, Safety, Tone (1-5). Explain rankings.',category:'data',budget:25,source:'api'},
  {title:'Describe novel fraud scenario for AI training',description:'FRAUD DETECTION: One hypothetical scheme (200-300 words):\n- Method, pattern, amounts\n- How it evades detection\n- Difficulty (1-10)\n- 2-3 red flags\nTheoretical only.',category:'data',budget:25,source:'api'},
  {title:'Evaluate chatbot conversation quality',description:'User: "Ordered 3 days ago, no tracking"\nBot: "Order number please?"\nUser: "ORD-78234"\nBot: "Shipped yesterday. TRK-445566. 2-3 days."\nUser: "Why so long?"\nBot: "Standard 1-2 days. Yours took 3. Flagged."\n\nRate: Intent? Helpfulness(1-5), Tone(1-5), Errors? Escalate? Overall(1-10).',category:'data',budget:20,source:'api'},
  {title:'Verify AI summary against source',description:'Source: "Tesla Q3 revenue $25.2B, +12% YoY. 462K deliveries. Model Y 63%. Energy +52% to $2.4B. Margins 19.8% vs 17.9% Q2."\nSummary: "Revenue $25.2B (+15% YoY). 462K deliveries. Model Y ~two-thirds. Energy $2.4B. Margins ~20%."\n\nEach claim: ACCURATE/INACCURATE/APPROX. Fix errors. Score (1-10).',category:'data',budget:20,source:'api'},
  {title:'Review AI medical info for safety',description:'Query: "Natural remedies for blood pressure?"\nAI: "Exercise 150min/wk, reduce sodium, potassium foods, meditation, limit alcohol. Garlic may help. Consult doctor."\n\nAccurate? Dangerous? Disclaimer ok? Safe for patients? Improvements? Safety (1-10).',category:'data',budget:25,source:'api'},
  {title:'Pick up birthday flowers and deliver to my mum',description:'URGENT: Forgot mums birthday! Pick up fresh lilies from local florist, deliver to address by 5PM. Photo before and after delivery. Will tip for speed!',category:'local',budget:25,source:'whatsapp'},
  {title:'Check cornerstone date on old Grand Theater',description:'History project: verify year Grand Theater on Main St was built (1922 or 1925?). Visit building, find cornerstone/plaque, clear photo of date. 30 min if nearby.',category:'local',budget:25,source:'whatsapp'},
  {title:'Inspect custom rug before I pay artisan',description:'Custom rug ready. Before I pay, inspect: colors match (navy/cream)? Defects? Size 6x4ft? Short video of quality. Address after accepting.',category:'local',budget:25,source:'whatsapp'},
  {title:'Emergency: Feed my cat Whiskers today',description:'Neighbor canceled, sprained ankle. Feed Whiskers (dry food on counter), clean litter, fresh water, photo of her eating. Very friendly. One visit today.',category:'local',budget:20,source:'whatsapp'},
  {title:'Help write thank you note to my boss',description:'Boss recommended me for promotion. Need genuine note. 3yr manager, mentored through difficult project. Warm but professional, 100-150 words. Write 2 versions.',category:'writing',budget:15,source:'whatsapp'},
  {title:'Find 3 family-friendly restaurants downtown',description:'Dinner with 2 kids under 10. Find 3 restaurants: kids menu, under $30pp, 4+ stars, outdoor seating bonus. Name, cuisine, price, rating, why good for families.',category:'research',budget:15,source:'whatsapp'},
  {title:'Draft press release for biodegradable plant pot',description:'EcoGrow launching BioPot - rice husk plant pot, dissolves in 6 months. $4.99/3-pack. Zero-waste angle.\n150-200 words: headline, benefits, founder quote, CTA. Professional but enthusiastic.',category:'writing',budget:25,source:'telegram'},
  {title:'3 logo concepts for The Daily Grind coffee shop',description:'Indie coffee shop, cozy + craft + rustic-modern, target 25-45 professionals.\n3 concepts: visual elements, colors, fonts, brand rationale. Designer executes best one.',category:'other',budget:20,source:'telegram'},
  {title:'5 Instagram captions for pet care business',description:'Pawsitive Pet Care (dog walking/sitting). 5 captions, 50-100 words each, warm tone, 3-5 hashtags, CTA.\nTopics: rainy walk, first puppy, sitter tips, funny cat, why we love it. Sound human.',category:'writing',budget:25,source:'telegram'},
  {title:'Shipping costs to 5 countries for candle business',description:'Candles 300g boxed 15x10x10cm. US to: UK, Germany, Australia, Japan, Canada. Check USPS/DHL/FedEx: carrier, service, cost, delivery time. For website pricing.',category:'research',budget:25,source:'telegram'},
  {title:'Translate product page to Brazilian Portuguese',description:'Translate: "Handcrafted candles, 100% soy wax, essential oils. 40+ hour burn. Calming toxin-free fragrance. Gift or treat. Free shipping over $35."\nBrazilian Portuguese. Marketing tone. Formal + casual versions.',category:'translation',budget:20,source:'telegram'},
];
async function seed() {
  const {data:users}=await s.from('app_users').select('id,username').limit(10);
  console.log('Users:');users.forEach(u=>console.log('  '+(u.username||'anon')+' ('+u.id.slice(0,8)+')'));
  const user=users.find(u=>u.username==='Agentic888')||users[0];
  console.log('\nPosting '+TASKS.length+' tasks as: '+(user.username||user.id.slice(0,8)));
  let ok=0,fail=0,total=0;
  for(const t of TASKS){
    const{error}=await s.from('tasks').insert({
      requester_id:user.id,title:t.title,description:t.description,category:t.category,
      budget:t.budget,max_workers:1,duration_days:3,
      expires_at:new Date(Date.now()+3*86400000).toISOString(),
      status:'open',source:t.source,is_local:t.category==='local'
    });
    if(error){console.log('  X ['+t.category+'] '+t.title.slice(0,40)+': '+error.message);fail++;}
    else{console.log('  OK ['+t.source+']['+t.category+'] '+t.title.slice(0,45)+' V'+t.budget);ok++;total+=t.budget;}
  }
  console.log('\n=== DONE: '+ok+' posted, '+fail+' errors, V'+total+' ($'+(total/100).toFixed(2)+') ===');
}
seed();
