export interface ViralClip {
  id: string;
  start_time: number;
  end_time: number;
  transcript: string;
  virality_score: number;
  reason: string;
  thumbnail?: string;
}

export interface JobResult {
  id: string;
  youtube_url: string;
  video_title: string;
  video_thumbnail: string;
  duration: number;
  status: "processing" | "done" | "failed";
  clips: ViralClip[];
  created_at: string;
  user_email: string;
}

export interface User {
  id: string;
  name: string;
  email: string;
  plan: "free" | "pro" | "pro_max";
  join_date: string;
  status: "active" | "inactive" | "suspended";
  videos_today: number;
  total_videos: number;
  avatar?: string;
}

export interface Subscription {
  id: string;
  user_name: string;
  user_email: string;
  plan: "free" | "pro" | "pro_max";
  start_date: string;
  renewal_date: string;
  status: "active" | "cancelled" | "expired";
  amount: number;
}

export const mockApiResponse: JobResult = {
  id: "job_001",
  youtube_url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  video_title: "How to Build a SaaS Product in 30 Days - Complete Guide",
  video_thumbnail: "https://img.youtube.com/vi/dQw4w9WgXcQ/maxresdefault.jpg",
  duration: 1847,
  status: "done",
  user_email: "user@example.com",
  created_at: "2024-01-15T10:30:00Z",
  clips: [
    {
      id: "clip_001",
      start_time: 124,
      end_time: 189,
      transcript:
        "The biggest mistake most founders make is building before they validate. I spent 6 months building something nobody wanted. Here's the 3-step validation framework that changed everything for me.",
      virality_score: 94,
      reason: "High emotional hook with personal failure story + actionable framework promise",
    },
    {
      id: "clip_002",
      start_time: 445,
      end_time: 510,
      transcript:
        "Revenue went from zero to ten thousand dollars in just 47 days. Not because we had the best product — because we had the best distribution. Let me show you exactly how we did it.",
      virality_score: 91,
      reason: "Specific numbers + short timeframe + counter-intuitive insight",
    },
    {
      id: "clip_003",
      start_time: 823,
      end_time: 878,
      transcript:
        "Stop trying to compete on features. Your competitors have more money, more engineers, more time. The only thing they can't copy is your community. Build that first.",
      virality_score: 88,
      reason: "Contrarian advice + competitor framing + community building hook",
    },
    {
      id: "clip_004",
      start_time: 1102,
      end_time: 1167,
      transcript:
        "I was rejected by 47 investors before finding the one who believed in the vision. That rejection list became my most valuable asset — it forced me to get crystal clear on our value proposition.",
      virality_score: 85,
      reason: "Resilience narrative + specific rejection number + silver lining insight",
    },
    {
      id: "clip_005",
      start_time: 1534,
      end_time: 1590,
      transcript:
        "The most counterintuitive growth hack nobody talks about: make it harder to sign up. We added a 3-question intake form and conversions went UP by 40% because we filtered for the right users.",
      virality_score: 82,
      reason: "Counter-intuitive growth tactic + specific percentage result",
    },
  ],
};

export const mockUsers: User[] = [
  {
    id: "u1",
    name: "Arjun Sharma",
    email: "arjun@example.com",
    plan: "pro",
    join_date: "2024-01-05",
    status: "active",
    videos_today: 3,
    total_videos: 142,
  },
  {
    id: "u2",
    name: "Priya Patel",
    email: "priya@startup.io",
    plan: "pro_max",
    join_date: "2023-11-20",
    status: "active",
    videos_today: 12,
    total_videos: 891,
  },
  {
    id: "u3",
    name: "Rahul Verma",
    email: "rahul@gmail.com",
    plan: "free",
    join_date: "2024-02-14",
    status: "active",
    videos_today: 1,
    total_videos: 23,
  },
  {
    id: "u4",
    name: "Sneha Iyer",
    email: "sneha@agency.com",
    plan: "pro",
    join_date: "2023-12-01",
    status: "active",
    videos_today: 4,
    total_videos: 356,
  },
  {
    id: "u5",
    name: "Vikram Singh",
    email: "vikram@content.co",
    plan: "pro_max",
    join_date: "2023-10-15",
    status: "active",
    videos_today: 8,
    total_videos: 1204,
  },
  {
    id: "u6",
    name: "Ananya Roy",
    email: "ananya@media.in",
    plan: "free",
    join_date: "2024-02-28",
    status: "inactive",
    videos_today: 0,
    total_videos: 7,
  },
];

export const mockJobs: JobResult[] = [
  {
    id: "job_101",
    youtube_url: "https://youtube.com/watch?v=abc123",
    video_title: "10 Productivity Hacks That Changed My Life",
    video_thumbnail: "https://img.youtube.com/vi/abc123/mqdefault.jpg",
    duration: 923,
    status: "done",
    user_email: "arjun@example.com",
    created_at: "2024-03-01T09:15:00Z",
    clips: [],
  },
  {
    id: "job_102",
    youtube_url: "https://youtube.com/watch?v=def456",
    video_title: "Building in Public: Month 3 Update",
    video_thumbnail: "https://img.youtube.com/vi/def456/mqdefault.jpg",
    duration: 1245,
    status: "done",
    user_email: "priya@startup.io",
    created_at: "2024-03-01T10:30:00Z",
    clips: [],
  },
  {
    id: "job_103",
    youtube_url: "https://youtube.com/watch?v=ghi789",
    video_title: "How I Got 100k Followers in 90 Days",
    video_thumbnail: "https://img.youtube.com/vi/ghi789/mqdefault.jpg",
    duration: 1834,
    status: "processing",
    user_email: "rahul@gmail.com",
    created_at: "2024-03-01T11:00:00Z",
    clips: [],
  },
  {
    id: "job_104",
    youtube_url: "https://youtube.com/watch?v=jkl012",
    video_title: "The Truth About Passive Income",
    video_thumbnail: "https://img.youtube.com/vi/jkl012/mqdefault.jpg",
    duration: 756,
    status: "failed",
    user_email: "sneha@agency.com",
    created_at: "2024-03-01T08:45:00Z",
    clips: [],
  },
  {
    id: "job_105",
    youtube_url: "https://youtube.com/watch?v=mno345",
    video_title: "React 19 Complete Tutorial",
    video_thumbnail: "https://img.youtube.com/vi/mno345/mqdefault.jpg",
    duration: 3621,
    status: "done",
    user_email: "vikram@content.co",
    created_at: "2024-02-29T14:20:00Z",
    clips: [],
  },
];

export const mockSubscriptions: Subscription[] = [
  {
    id: "sub_1",
    user_name: "Arjun Sharma",
    user_email: "arjun@example.com",
    plan: "pro",
    start_date: "2024-01-05",
    renewal_date: "2024-04-05",
    status: "active",
    amount: 799,
  },
  {
    id: "sub_2",
    user_name: "Priya Patel",
    user_email: "priya@startup.io",
    plan: "pro_max",
    start_date: "2023-11-20",
    renewal_date: "2024-05-20",
    status: "active",
    amount: 4999,
  },
  {
    id: "sub_3",
    user_name: "Rahul Verma",
    user_email: "rahul@gmail.com",
    plan: "free",
    start_date: "2024-02-14",
    renewal_date: "-",
    status: "active",
    amount: 0,
  },
  {
    id: "sub_4",
    user_name: "Sneha Iyer",
    user_email: "sneha@agency.com",
    plan: "pro",
    start_date: "2023-12-01",
    renewal_date: "2024-03-01",
    status: "cancelled",
    amount: 799,
  },
];

export const mockDashboardStats = {
  total_users: 1284,
  active_subscriptions: 347,
  videos_today: 892,
  revenue_mtd: 284750,
  weekly_jobs: [
    { day: "Mon", count: 124 },
    { day: "Tue", count: 189 },
    { day: "Wed", count: 156 },
    { day: "Thu", count: 234 },
    { day: "Fri", count: 298 },
    { day: "Sat", count: 167 },
    { day: "Sun", count: 89 },
  ],
};

export const formatTime = (seconds: number): string => {
  const m = Math.floor(seconds / 60);
  const s = seconds % 60;
  return `${m}:${s.toString().padStart(2, "0")}`;
};

export const formatDuration = (seconds: number): string => {
  const h = Math.floor(seconds / 3600);
  const m = Math.floor((seconds % 3600) / 60);
  if (h > 0) return `${h}h ${m}m`;
  return `${m}m`;
};
