import type { Conversation } from "./types";

const av = (id: string) =>
  `https://images.unsplash.com/photo-${id}?w=120&h=120&fit=crop&q=80`;
const img = (id: string) =>
  `https://images.unsplash.com/photo-${id}?w=400&h=300&fit=crop&q=80`;

export let msgIdCounter = 100;
export function generateMsgId() {
  return `msg-${++msgIdCounter}`;
}

export const BUYER_AUTO_REPLIES = [
  "Thanks! I'll think about it.",
  "That's a bit high for me. Can we negotiate?",
  "Sounds good! When can I come see it?",
  "Let me check my schedule and get back to you.",
  "Is there any warranty left on it?",
];

export const SELLER_AUTO_REPLIES = [
  "Yes it's available! When would you like to see it?",
  "The price is firm, but I can consider if you pick up today.",
  "It's in excellent condition, no issues at all.",
  "Alright, let's meet. I'm free this weekend.",
  "I have another interested buyer. Please confirm ASAP.",
];

export const MOCK_CONVERSATIONS: Conversation[] = [
  {
    id: "conv1",
    listingId: "bl1",
    listingSlug: "iphone-14-pro-max-256gb-deep-purple",
    listingTitle: "iPhone 14 Pro Max 256GB Deep Purple",
    listingImage: img("1510557880182-3d4d3cba35a5"),
    listingPrice: 68000,
    listingCondition: "Like New",
    listingCity: "Mumbai",
    listingStatus: "available",
    otherUserId: "s1",
    otherUserName: "Rahul Sharma",
    otherUserAvatar: av("1535713875002-d1d0cf377fde"),
    otherUserVerified: true,
    otherUserIsOnline: true,
    myRole: "buyer",
    lastMessage: "Can you do ₹62,000? That's my best offer.",
    lastMessageTime: "2026-06-26T11:45:00Z",
    unreadCount: 2,
    isPinned: true,
    isArchived: false,
    isBlocked: false,
    messages: [
      {
        id: "m1-1",
        conversationId: "conv1",
        senderId: "me",
        type: "text",
        content: "Hi! Is this iPhone still available?",
        timestamp: "2026-06-25T10:00:00Z",
        readAt: "2026-06-25T10:02:00Z",
      },
      {
        id: "m1-2",
        conversationId: "conv1",
        senderId: "s1",
        type: "text",
        content:
          "Yes, it's still available! Perfect condition, battery health 98%. Original box and all accessories included.",
        timestamp: "2026-06-25T10:05:00Z",
      },
      {
        id: "m1-3",
        conversationId: "conv1",
        senderId: "me",
        type: "text",
        content: "Great! Can you share more photos of the phone?",
        timestamp: "2026-06-25T10:07:00Z",
        readAt: "2026-06-25T10:09:00Z",
      },
      {
        id: "m1-4",
        conversationId: "conv1",
        senderId: "s1",
        type: "text",
        content:
          "Sure, I'll send them shortly. No scratches at all, used with a case and screen protector.",
        timestamp: "2026-06-25T10:12:00Z",
      },
      {
        id: "m1-5",
        conversationId: "conv1",
        senderId: "me",
        type: "offer",
        content: "Here's my offer for the iPhone:",
        timestamp: "2026-06-26T11:30:00Z",
        readAt: "2026-06-26T11:32:00Z",
        offer: {
          amount: 63000,
          originalPrice: 68000,
          status: "pending",
          message:
            "Serious buyer. Can pick up tomorrow in Andheri. Please consider.",
        },
      },
      {
        id: "m1-6",
        conversationId: "conv1",
        senderId: "s1",
        type: "text",
        content: "Thanks for the offer! Minimum I can go is ₹65,000.",
        timestamp: "2026-06-26T11:40:00Z",
      },
      {
        id: "m1-7",
        conversationId: "conv1",
        senderId: "me",
        type: "text",
        content: "Can you do ₹62,000? That's my best offer.",
        timestamp: "2026-06-26T11:45:00Z",
      },
    ],
  },
  {
    id: "conv2",
    listingId: "bl2",
    listingSlug: "macbook-air-m2-13inch-midnight",
    listingTitle: "MacBook Air M2 13-inch — Midnight",
    listingImage: img("1517336714731-489689fd1ca8"),
    listingPrice: 75000,
    listingCondition: "Like New",
    listingCity: "Bangalore",
    listingStatus: "reserved",
    otherUserId: "s2",
    otherUserName: "Priya Mehta",
    otherUserAvatar: av("1494790108377-be9c29b29330"),
    otherUserVerified: true,
    otherUserIsOnline: false,
    otherUserLastSeen: "2026-06-26T10:00:00Z",
    myRole: "buyer",
    lastMessage: "Deal! I'll transfer the amount today. 🎉",
    lastMessageTime: "2026-06-26T09:00:00Z",
    unreadCount: 0,
    isPinned: false,
    isArchived: false,
    isBlocked: false,
    messages: [
      {
        id: "m2-1",
        conversationId: "conv2",
        senderId: "me",
        type: "text",
        content: "Hi Priya! I'm very interested in the MacBook Air M2.",
        timestamp: "2026-06-25T14:00:00Z",
        readAt: "2026-06-25T14:05:00Z",
      },
      {
        id: "m2-2",
        conversationId: "conv2",
        senderId: "s2",
        type: "text",
        content:
          "Hello! Yes it's available. Barely 2 months old, office machine. Comes with AppleCare+.",
        timestamp: "2026-06-25T14:10:00Z",
      },
      {
        id: "m2-3",
        conversationId: "conv2",
        senderId: "me",
        type: "offer",
        content: "Making an offer:",
        timestamp: "2026-06-25T15:00:00Z",
        readAt: "2026-06-25T15:03:00Z",
        offer: {
          amount: 70000,
          originalPrice: 75000,
          status: "accepted",
          message: "I can pick up today evening from Koramangala.",
        },
      },
      {
        id: "m2-4",
        conversationId: "conv2",
        senderId: "s2",
        type: "text",
        content: "Accepted! ₹70,000 works. Come over at 6 PM today.",
        timestamp: "2026-06-25T15:20:00Z",
      },
      {
        id: "m2-5",
        conversationId: "conv2",
        senderId: "me",
        type: "text",
        content: "Deal! I'll transfer the amount today. 🎉",
        timestamp: "2026-06-26T09:00:00Z",
        readAt: "2026-06-26T09:05:00Z",
      },
    ],
  },
  {
    id: "conv3",
    listingId: "bl5",
    listingSlug: "canon-eos-r50-mirrorless-kit",
    listingTitle: "Canon EOS R50 + 18-45mm Kit Lens",
    listingImage: img("1502920917128-1aa500764cbd"),
    listingPrice: 42000,
    listingCondition: "Like New",
    listingCity: "Mumbai",
    listingStatus: "available",
    otherUserId: "b1",
    otherUserName: "Arjun Nair",
    otherUserAvatar: av("1500648767791-00dcc994a43e"),
    otherUserVerified: false,
    otherUserIsOnline: true,
    myRole: "seller",
    lastMessage: "Could you come down to ₹38,000?",
    lastMessageTime: "2026-06-26T11:00:00Z",
    unreadCount: 1,
    isPinned: false,
    isArchived: false,
    isBlocked: false,
    messages: [
      {
        id: "m3-1",
        conversationId: "conv3",
        senderId: "b1",
        type: "text",
        content: "Hi! Is the Canon R50 still available?",
        timestamp: "2026-06-26T10:00:00Z",
      },
      {
        id: "m3-2",
        conversationId: "conv3",
        senderId: "me",
        type: "text",
        content:
          "Yes! Like-new condition. Comes with 18-45mm kit lens, original box, and all accessories.",
        timestamp: "2026-06-26T10:05:00Z",
        readAt: "2026-06-26T10:07:00Z",
      },
      {
        id: "m3-3",
        conversationId: "conv3",
        senderId: "b1",
        type: "offer",
        content: "Here's my offer:",
        timestamp: "2026-06-26T10:30:00Z",
        offer: {
          amount: 38000,
          originalPrice: 42000,
          status: "pending",
          message: "I can pick up today. Genuine buyer.",
        },
      },
      {
        id: "m3-4",
        conversationId: "conv3",
        senderId: "me",
        type: "text",
        content: "The lowest I can go is ₹40,000. It's practically new.",
        timestamp: "2026-06-26T10:50:00Z",
        readAt: "2026-06-26T10:52:00Z",
      },
      {
        id: "m3-5",
        conversationId: "conv3",
        senderId: "b1",
        type: "text",
        content: "Could you come down to ₹38,000?",
        timestamp: "2026-06-26T11:00:00Z",
      },
    ],
  },
  {
    id: "conv4",
    listingId: "bl3",
    listingSlug: "sony-wh1000xm5-noise-cancelling",
    listingTitle: "Sony WH-1000XM5 — All Accessories",
    listingImage: img("1505740420928-5e560c06d30e"),
    listingPrice: 22000,
    listingCondition: "Good",
    listingCity: "Delhi",
    listingStatus: "sold",
    otherUserId: "b2",
    otherUserName: "Meera Joshi",
    otherUserAvatar: av("1438761681033-6461ffad8d80"),
    otherUserVerified: false,
    otherUserIsOnline: false,
    otherUserLastSeen: "2026-06-25T18:00:00Z",
    myRole: "seller",
    lastMessage: "This item has been marked as Sold.",
    lastMessageTime: "2026-06-25T20:00:00Z",
    unreadCount: 0,
    isPinned: false,
    isArchived: false,
    isBlocked: false,
    messages: [
      {
        id: "m4-1",
        conversationId: "conv4",
        senderId: "b2",
        type: "text",
        content: "Hello! Are the Sony headphones still available?",
        timestamp: "2026-06-25T14:00:00Z",
      },
      {
        id: "m4-2",
        conversationId: "conv4",
        senderId: "me",
        type: "text",
        content:
          "Hi! Sorry, I just sold it to another buyer a few minutes ago.",
        timestamp: "2026-06-25T15:00:00Z",
        readAt: "2026-06-25T15:02:00Z",
      },
      {
        id: "m4-3",
        conversationId: "conv4",
        senderId: "b2",
        type: "text",
        content: "Oh no! Do you have any other headphones to sell?",
        timestamp: "2026-06-25T15:05:00Z",
      },
      {
        id: "m4-4",
        conversationId: "conv4",
        senderId: "system",
        type: "system",
        content: "This item has been marked as Sold.",
        timestamp: "2026-06-25T20:00:00Z",
      },
    ],
  },
  {
    id: "conv5",
    listingId: "bl4",
    listingSlug: "royal-enfield-classic-350-2022",
    listingTitle: "Royal Enfield Classic 350 — 2022",
    listingImage: img("1558618666-fcd25c85cd64"),
    listingPrice: 145000,
    listingCondition: "Good",
    listingCity: "Pune",
    listingStatus: "available",
    otherUserId: "s4",
    otherUserName: "Vikram Singh",
    otherUserAvatar: av("1507003211169-0a1dd7228f2d"),
    otherUserVerified: true,
    otherUserIsOnline: false,
    otherUserLastSeen: "2026-06-25T12:00:00Z",
    myRole: "buyer",
    lastMessage: "Okay, I'll think about it and get back.",
    lastMessageTime: "2026-06-24T16:00:00Z",
    unreadCount: 0,
    isPinned: false,
    isArchived: true,
    isBlocked: false,
    messages: [
      {
        id: "m5-1",
        conversationId: "conv5",
        senderId: "me",
        type: "text",
        content: "Hi Vikram! Is the Royal Enfield available for test ride?",
        timestamp: "2026-06-24T14:00:00Z",
        readAt: "2026-06-24T14:05:00Z",
      },
      {
        id: "m5-2",
        conversationId: "conv5",
        senderId: "s4",
        type: "text",
        content:
          "Yes! You can come to Pune. No negotiation on price — it's fixed.",
        timestamp: "2026-06-24T14:30:00Z",
      },
      {
        id: "m5-3",
        conversationId: "conv5",
        senderId: "me",
        type: "text",
        content: "Okay, I'll think about it and get back.",
        timestamp: "2026-06-24T16:00:00Z",
        readAt: "2026-06-24T16:05:00Z",
      },
    ],
  },
];
