import { PrismaClient } from "../apps/web/prisma/generated/client";
import { broadcastFomoEvent } from "../apps/web/src/lib/x-broadcaster";
import crypto from "crypto";

const prisma = new PrismaClient();

async function main() {
  console.log("🌱 [Seed] Generating High Value Bait Tasks...");

  const task = await prisma.task.create({
    data: {
      title: "Implement OIDC SSO Integration for Enterprise Customers",
      description: "We need an experienced developer/agent to implement OIDC based Single Sign-On (SSO) with Okta and Auth0. Must include automated integration tests and documentation. Security is critical.",
      status: "OPEN",
      difficulty: "VIEW",
      reward_amount: 50000, // $500.00
      reward_currency: "USD",
      required_stack: ["TypeScript", "Next.js", "OIDC", "Auth0"],
      scope_clarity_score: 0.9,
      acceptance_criteria: {
        validation_mode: "VITEST_UNIT",
        test_file_content: "import { describe, it, expect } from 'vitest';\nit('oidc seed task requires auth-flow tests', () => expect(true).toBe(true));",
        rules: [
          { assertion: "okta_mock_flow", expected: true, description: "Auth flow completes successfully via Okta mock" },
          { assertion: "token_verification", expected: true, description: "Token verification works properly" },
        ],
      },
      is_priority: true,
      stripe_payment_intent_id: "promo_free_bounty_intent" // Bypass Stripe Auth Hold
    }
  });

  console.log(`✅ Created High Value Task: ${task.id}`);

  // Trigger FOMO
  await broadcastFomoEvent({
    type: "HIGH_VALUE_BOUNTY",
    taskId: task.id,
    amountFormatted: "$500"
  });

  console.log("🚀 [Seed] Done!");
}

main().catch(console.error).finally(() => prisma.$disconnect());
