/**
 * Demo data for all 65 GHL MCP apps.
 * Provides realistic business data so apps render with content
 * instead of showing "Waiting for data..."
 *
 * Uses today's date as reference: 2026-02-03
 */

// ─── Shared identifiers & contacts ──────────────────────────────────────────

const IDS = {
  loc: "loc_7Kd9x2Rp4mNv",
  pipeline: "pipe_Qw3Xm8Jv5tBn",
  calendar: "cal_Hf6Yz1Ws9pLk",
  calendar2: "cal_Rt2Mn7Dp4xKj",
} as const;

interface DemoContact {
  id: string;
  firstName: string;
  lastName: string;
  email: string;
  phone: string;
  tags: string[];
  dateAdded: string;
  source: string;
  companyName?: string;
}

const CONTACTS: DemoContact[] = [
  { id: "ct_a1b2c3d4", firstName: "Sarah", lastName: "Martinez", email: "sarah@martinezdigital.com", phone: "+1 (512) 555-0147", tags: ["VIP", "Marketing"], dateAdded: "2025-11-15T10:30:00Z", source: "Website Form", companyName: "Martinez Digital Marketing" },
  { id: "ct_e5f6g7h8", firstName: "David", lastName: "Chen", email: "david@goldendragonatx.com", phone: "+1 (512) 555-0293", tags: ["Restaurant", "Active"], dateAdded: "2025-12-02T14:15:00Z", source: "Referral", companyName: "Golden Dragon Restaurant" },
  { id: "ct_i9j0k1l2", firstName: "Emily", lastName: "Thompson", email: "emily.t@gmail.com", phone: "+1 (512) 555-0381", tags: ["Patient", "Recall Due"], dateAdded: "2026-01-08T09:00:00Z", source: "Google Ads" },
  { id: "ct_m3n4o5p6", firstName: "Marcus", lastName: "Johnson", email: "mjohnson@jnconsulting.com", phone: "+1 (512) 555-0467", tags: ["Consulting", "Enterprise"], dateAdded: "2025-10-20T16:45:00Z", source: "LinkedIn", companyName: "Johnson & Associates" },
  { id: "ct_q7r8s9t0", firstName: "Lisa", lastName: "Rodriguez", email: "lisa@rodriguezrealty.com", phone: "+1 (512) 555-0524", tags: ["Real Estate", "Referral Partner"], dateAdded: "2026-01-15T11:20:00Z", source: "Networking Event", companyName: "Rodriguez Realty Group" },
  { id: "ct_u1v2w3x4", firstName: "James", lastName: "Wilson", email: "jwilson.contractor@gmail.com", phone: "+1 (512) 555-0618", tags: ["Contractor", "Lead"], dateAdded: "2026-01-22T08:30:00Z", source: "Facebook Ads" },
  { id: "ct_y5z6a7b8", firstName: "Rachel", lastName: "Kim", email: "rachel@eventsbyrk.com", phone: "+1 (512) 555-0735", tags: ["Events", "Active"], dateAdded: "2025-09-10T13:00:00Z", source: "Instagram", companyName: "Events by RK" },
  { id: "ct_c9d0e1f2", firstName: "Thomas", lastName: "Brown", email: "tom.brown@lonestarhomes.com", phone: "+1 (512) 555-0892", tags: ["Real Estate", "Warm Lead"], dateAdded: "2026-01-28T15:10:00Z", source: "Website Form", companyName: "Lone Star Homes" },
  { id: "ct_g3h4i5j6", firstName: "Jennifer", lastName: "Davis", email: "jen@mindfulwellnessatx.com", phone: "+1 (512) 555-0946", tags: ["Wellness", "VIP"], dateAdded: "2025-08-05T10:00:00Z", source: "Referral", companyName: "Mindful Wellness ATX" },
  { id: "ct_k7l8m9n0", firstName: "Michael", lastName: "Turner", email: "mike@turnerautocare.com", phone: "+1 (512) 555-1053", tags: ["Auto", "Active"], dateAdded: "2026-02-01T09:45:00Z", source: "Google My Business", companyName: "Turner Auto Care" },
];

const COMPANIES = [
  { id: "co_x1y2z3", name: "Martinez Digital Marketing", phone: "+1 (512) 555-0100", email: "info@martinezdigital.com", website: "https://martinezdigital.com", address: "1201 S Lamar Blvd, Austin, TX 78704", industry: "Marketing Agency", employeeCount: 12, contactId: "ct_a1b2c3d4" },
  { id: "co_a4b5c6", name: "Golden Dragon Restaurant", phone: "+1 (512) 555-0200", email: "hello@goldendragonatx.com", website: "https://goldendragonatx.com", address: "2400 E Cesar Chavez St, Austin, TX 78702", industry: "Restaurant", employeeCount: 25, contactId: "ct_e5f6g7h8" },
  { id: "co_d7e8f9", name: "Thompson Family Dentistry", phone: "+1 (512) 555-0300", email: "office@thompsondental.com", website: "https://thompsondental.com", address: "3500 Jefferson St, Austin, TX 78731", industry: "Healthcare", employeeCount: 8, contactId: "ct_i9j0k1l2" },
  { id: "co_g0h1i2", name: "Johnson & Associates", phone: "+1 (512) 555-0400", email: "info@jnconsulting.com", website: "https://jnconsulting.com", address: "100 Congress Ave #800, Austin, TX 78701", industry: "Consulting", employeeCount: 35, contactId: "ct_m3n4o5p6" },
  { id: "co_j3k4l5", name: "Rodriguez Realty Group", phone: "+1 (512) 555-0500", email: "team@rodriguezrealty.com", website: "https://rodriguezrealty.com", address: "5600 N Lamar Blvd, Austin, TX 78756", industry: "Real Estate", employeeCount: 6, contactId: "ct_q7r8s9t0" },
  { id: "co_m6n7o8", name: "Events by RK", phone: "+1 (512) 555-0700", email: "hello@eventsbyrk.com", website: "https://eventsbyrk.com", address: "900 E 6th St, Austin, TX 78702", industry: "Event Planning", employeeCount: 4, contactId: "ct_y5z6a7b8" },
  { id: "co_p9q0r1", name: "Turner Auto Care", phone: "+1 (512) 555-1000", email: "service@turnerautocare.com", website: "https://turnerautocare.com", address: "7800 Burnet Rd, Austin, TX 78757", industry: "Automotive", employeeCount: 10, contactId: "ct_k7l8m9n0" },
];

// ─── Pipeline stages ─────────────────────────────────────────────────────────

const STAGES = [
  { id: "stg_new", name: "New Lead", position: 0 },
  { id: "stg_contact", name: "Contacted", position: 1 },
  { id: "stg_qual", name: "Qualified", position: 2 },
  { id: "stg_proposal", name: "Proposal Sent", position: 3 },
  { id: "stg_negotiate", name: "Negotiation", position: 4 },
  { id: "stg_won", name: "Closed Won", position: 5 },
  { id: "stg_lost", name: "Closed Lost", position: 6 },
];

const PIPELINE = {
  id: IDS.pipeline,
  name: "Sales Pipeline",
  stages: STAGES,
};

const OPPORTUNITIES = [
  { id: "opp_1a", name: "Martinez Digital — SEO Retainer", pipelineId: IDS.pipeline, stageId: "stg_proposal", status: "open", monetaryValue: 4500, contactId: "ct_a1b2c3d4", contactName: "Sarah Martinez", createdAt: "2026-01-10T09:00:00Z", assignedTo: "Jake Shore" },
  { id: "opp_2b", name: "Golden Dragon — Website Redesign", pipelineId: IDS.pipeline, stageId: "stg_negotiate", status: "open", monetaryValue: 8500, contactId: "ct_e5f6g7h8", contactName: "David Chen", createdAt: "2025-12-15T14:00:00Z", assignedTo: "Jake Shore" },
  { id: "opp_3c", name: "Thompson Dental — Patient Marketing", pipelineId: IDS.pipeline, stageId: "stg_qual", status: "open", monetaryValue: 3200, contactId: "ct_i9j0k1l2", contactName: "Emily Thompson", createdAt: "2026-01-20T11:00:00Z", assignedTo: "Alex Rivera" },
  { id: "opp_4d", name: "Johnson & Assoc — Full Stack Consulting", pipelineId: IDS.pipeline, stageId: "stg_won", status: "won", monetaryValue: 24000, contactId: "ct_m3n4o5p6", contactName: "Marcus Johnson", createdAt: "2025-10-25T10:00:00Z", assignedTo: "Jake Shore" },
  { id: "opp_5e", name: "Rodriguez Realty — Lead Gen Campaign", pipelineId: IDS.pipeline, stageId: "stg_new", status: "open", monetaryValue: 2800, contactId: "ct_q7r8s9t0", contactName: "Lisa Rodriguez", createdAt: "2026-02-01T08:00:00Z", assignedTo: "Alex Rivera" },
  { id: "opp_6f", name: "Wilson Contracting — Google Ads", pipelineId: IDS.pipeline, stageId: "stg_contact", status: "open", monetaryValue: 1500, contactId: "ct_u1v2w3x4", contactName: "James Wilson", createdAt: "2026-01-25T16:00:00Z", assignedTo: "Jake Shore" },
  { id: "opp_7g", name: "Events by RK — Social Media Package", pipelineId: IDS.pipeline, stageId: "stg_won", status: "won", monetaryValue: 6000, contactId: "ct_y5z6a7b8", contactName: "Rachel Kim", createdAt: "2025-09-20T13:00:00Z", assignedTo: "Alex Rivera" },
  { id: "opp_8h", name: "Lone Star Homes — Listing Ads", pipelineId: IDS.pipeline, stageId: "stg_proposal", status: "open", monetaryValue: 3500, contactId: "ct_c9d0e1f2", contactName: "Thomas Brown", createdAt: "2026-01-30T10:00:00Z", assignedTo: "Jake Shore" },
  { id: "opp_9i", name: "Mindful Wellness — Email Funnel", pipelineId: IDS.pipeline, stageId: "stg_lost", status: "lost", monetaryValue: 5000, contactId: "ct_g3h4i5j6", contactName: "Jennifer Davis", createdAt: "2025-11-01T09:00:00Z", assignedTo: "Alex Rivera" },
  { id: "opp_10j", name: "Turner Auto — Review Campaign", pipelineId: IDS.pipeline, stageId: "stg_contact", status: "open", monetaryValue: 1200, contactId: "ct_k7l8m9n0", contactName: "Michael Turner", createdAt: "2026-02-02T14:00:00Z", assignedTo: "Jake Shore" },
];

// ─── Helper to pick subset ──────────────────────────────────────────────────

function pick<T>(arr: T[], n: number): T[] {
  return arr.slice(0, n);
}

// ─── Per-app data generators ─────────────────────────────────────────────────

const demoDataMap: Record<string, () => object> = {

  // ── Contacts ──────────────────────────────────────────────────────────────

  "contact-grid": () => ({ contacts: CONTACTS }),

  "contact-card": () => ({ contact: { ...CONTACTS[0], notes: "VIP client — handles our biggest retainer account. Prefers email communication.", customFields: { "Preferred Contact": "Email", "Account Manager": "Jake Shore" } } }),

  "contact-creator": () => ({}),

  "contact-timeline": () => ({
    contact: CONTACTS[0],
    appointments: [
      { id: "apt_1", title: "Strategy Review", date: "2026-02-05T14:00:00Z", status: "confirmed", calendarId: IDS.calendar },
      { id: "apt_2", title: "Monthly Check-in", date: "2026-01-15T10:00:00Z", status: "completed", calendarId: IDS.calendar },
      { id: "apt_3", title: "Onboarding Call", date: "2025-11-20T09:00:00Z", status: "completed", calendarId: IDS.calendar },
    ],
    notes: [
      { id: "note_1", body: "Sarah wants to expand into TikTok marketing Q2 2026.", createdAt: "2026-01-28T11:00:00Z", createdBy: "Jake Shore" },
      { id: "note_2", body: "Contract renewal coming up March 1st — prepare proposal.", createdAt: "2026-01-20T15:30:00Z", createdBy: "Alex Rivera" },
    ],
    tasks: [
      { id: "task_1", title: "Send Q1 performance report", dueDate: "2026-02-07T17:00:00Z", status: "pending", assignedTo: "Jake Shore" },
      { id: "task_2", title: "Prepare renewal proposal", dueDate: "2026-02-15T17:00:00Z", status: "pending", assignedTo: "Alex Rivera" },
    ],
  }),

  "duplicate-checker": () => ({
    contact: CONTACTS[0],
    duplicates: [
      { id: "ct_dup_1", firstName: "Sarah", lastName: "Martinez", email: "s.martinez@martinezdigital.com", phone: "+1 (512) 555-0147", matchScore: 92, matchFields: ["phone", "lastName"] },
      { id: "ct_dup_2", firstName: "Sara", lastName: "Martinez", email: "sara.martinez@gmail.com", phone: "+1 (512) 555-8821", matchScore: 78, matchFields: ["lastName", "firstName"] },
    ],
  }),

  "smartlist-viewer": () => ({
    smartLists: [
      { id: "sl_1", name: "Hot Leads — Last 7 Days", count: 12, filters: [{ field: "dateAdded", operator: "after", value: "2026-01-27" }] },
      { id: "sl_2", name: "VIP Clients", count: 8, filters: [{ field: "tags", operator: "contains", value: "VIP" }] },
      { id: "sl_3", name: "Stale Leads (30+ days)", count: 23, filters: [{ field: "lastActivity", operator: "before", value: "2026-01-04" }] },
      { id: "sl_4", name: "Restaurant Contacts", count: 6, filters: [{ field: "tags", operator: "contains", value: "Restaurant" }] },
    ],
    data: pick(CONTACTS, 6),
  }),

  // ── Companies ─────────────────────────────────────────────────────────────

  "company-list": () => ({ companies: COMPANIES }),

  "company-detail": () => ({
    company: {
      ...COMPANIES[0],
      contacts: pick(CONTACTS, 3),
      opportunities: pick(OPPORTUNITIES, 2),
      notes: [{ id: "cn_1", body: "Agency focused on local Austin businesses. Great referral partner.", createdAt: "2025-12-01T10:00:00Z" }],
    },
  }),

  // ── Pipeline / Opportunities ──────────────────────────────────────────────

  "pipeline-kanban": () => ({ pipeline: PIPELINE, opportunities: OPPORTUNITIES, stages: STAGES }),

  "pipeline-analytics": () => ({
    pipeline: PIPELINE,
    opportunities: OPPORTUNITIES,
    stages: STAGES,
    summary: { totalValue: 60200, avgDealSize: 6020, winRate: 0.28, avgDaysToClose: 34 },
  }),

  "pipeline-funnel": () => ({
    pipeline: PIPELINE,
    opportunities: OPPORTUNITIES,
  }),

  "opportunity-card": () => ({
    opportunity: {
      ...OPPORTUNITIES[1],
      contact: CONTACTS[1],
      activities: [
        { id: "act_1", type: "email", description: "Sent proposal v2", date: "2026-01-28T10:00:00Z" },
        { id: "act_2", type: "call", description: "Follow-up call — positive feedback", date: "2026-01-25T15:00:00Z" },
      ],
    },
  }),

  "opportunity-editor": () => ({
    opportunity: OPPORTUNITIES[1],
    pipeline: PIPELINE,
    stages: STAGES,
  }),

  // ── Calendar ──────────────────────────────────────────────────────────────

  "calendar-view": () => ({
    events: [
      { id: "ev_1", title: "Strategy Review — Sarah Martinez", start: "2026-02-05T14:00:00Z", end: "2026-02-05T15:00:00Z", calendarId: IDS.calendar, contactId: "ct_a1b2c3d4", status: "confirmed" },
      { id: "ev_2", title: "Website Demo — David Chen", start: "2026-02-04T10:00:00Z", end: "2026-02-04T11:00:00Z", calendarId: IDS.calendar, contactId: "ct_e5f6g7h8", status: "confirmed" },
      { id: "ev_3", title: "Proposal Review — Thomas Brown", start: "2026-02-06T09:00:00Z", end: "2026-02-06T09:30:00Z", calendarId: IDS.calendar, contactId: "ct_c9d0e1f2", status: "pending" },
      { id: "ev_4", title: "Team Standup", start: "2026-02-03T09:00:00Z", end: "2026-02-03T09:30:00Z", calendarId: IDS.calendar2, status: "confirmed" },
      { id: "ev_5", title: "Pipeline Review", start: "2026-02-03T14:00:00Z", end: "2026-02-03T15:00:00Z", calendarId: IDS.calendar2, status: "confirmed" },
      { id: "ev_6", title: "Lead Gen Workshop — Lisa Rodriguez", start: "2026-02-07T11:00:00Z", end: "2026-02-07T12:00:00Z", calendarId: IDS.calendar, contactId: "ct_q7r8s9t0", status: "confirmed" },
      { id: "ev_7", title: "Client Onboarding — Michael Turner", start: "2026-02-10T13:00:00Z", end: "2026-02-10T14:00:00Z", calendarId: IDS.calendar, contactId: "ct_k7l8m9n0", status: "pending" },
    ],
    calendar: { id: IDS.calendar, name: "Client Meetings", timezone: "America/Chicago" },
    startDate: "2026-02-01",
    endDate: "2026-02-28",
  }),

  "calendar-resources": () => ({
    resources: [
      { id: "res_1", name: "Jake Shore", email: "jake@localbosses.com", calendarId: IDS.calendar, availability: "available" },
      { id: "res_2", name: "Alex Rivera", email: "alex@localbosses.com", calendarId: IDS.calendar2, availability: "available" },
      { id: "res_3", name: "Conference Room A", type: "room", calendarId: "cal_room1", availability: "busy" },
      { id: "res_4", name: "Conference Room B", type: "room", calendarId: "cal_room2", availability: "available" },
    ],
  }),

  "appointment-booker": () => ({
    slots: [
      { id: "slot_1", start: "2026-02-04T09:00:00Z", end: "2026-02-04T09:30:00Z", available: true },
      { id: "slot_2", start: "2026-02-04T09:30:00Z", end: "2026-02-04T10:00:00Z", available: true },
      { id: "slot_3", start: "2026-02-04T10:00:00Z", end: "2026-02-04T10:30:00Z", available: false },
      { id: "slot_4", start: "2026-02-04T11:00:00Z", end: "2026-02-04T11:30:00Z", available: true },
      { id: "slot_5", start: "2026-02-04T13:00:00Z", end: "2026-02-04T13:30:00Z", available: true },
      { id: "slot_6", start: "2026-02-04T14:00:00Z", end: "2026-02-04T14:30:00Z", available: true },
      { id: "slot_7", start: "2026-02-05T09:00:00Z", end: "2026-02-05T09:30:00Z", available: true },
      { id: "slot_8", start: "2026-02-05T10:00:00Z", end: "2026-02-05T10:30:00Z", available: true },
    ],
    calendar: { id: IDS.calendar, name: "Client Meetings", timezone: "America/Chicago" },
    contact: CONTACTS[2],
    locationId: IDS.loc,
  }),

  "appointment-detail": () => ({
    appointment: {
      id: "apt_det_1",
      title: "Strategy Review — Sarah Martinez",
      start: "2026-02-05T14:00:00Z",
      end: "2026-02-05T15:00:00Z",
      status: "confirmed",
      calendarId: IDS.calendar,
      contact: CONTACTS[0],
      assignedTo: "Jake Shore",
      location: "Zoom Meeting",
    },
    notes: [
      { id: "anote_1", body: "Prepare Q1 performance deck before the meeting.", createdAt: "2026-02-02T11:00:00Z", createdBy: "Jake Shore" },
    ],
  }),

  "free-slots-finder": () => ({
    freeSlots: [
      { start: "2026-02-04T09:00:00Z", end: "2026-02-04T10:00:00Z" },
      { start: "2026-02-04T11:00:00Z", end: "2026-02-04T12:00:00Z" },
      { start: "2026-02-04T14:00:00Z", end: "2026-02-04T16:00:00Z" },
      { start: "2026-02-05T09:00:00Z", end: "2026-02-05T11:00:00Z" },
      { start: "2026-02-05T13:00:00Z", end: "2026-02-05T15:00:00Z" },
      { start: "2026-02-06T10:00:00Z", end: "2026-02-06T12:00:00Z" },
      { start: "2026-02-06T14:00:00Z", end: "2026-02-06T17:00:00Z" },
    ],
    calendarId: IDS.calendar,
  }),

  // ── Messaging ─────────────────────────────────────────────────────────────

  "conversation-list": () => ({
    conversations: [
      { id: "conv_1", contactId: "ct_a1b2c3d4", contactName: "Sarah Martinez", lastMessage: "Sounds great — let's schedule for Thursday!", lastMessageDate: "2026-02-03T10:15:00Z", unreadCount: 1, type: "sms", contactEmail: "sarah@martinezdigital.com" },
      { id: "conv_2", contactId: "ct_e5f6g7h8", contactName: "David Chen", lastMessage: "Can you send over the mockups?", lastMessageDate: "2026-02-02T16:40:00Z", unreadCount: 0, type: "email", contactEmail: "david@goldendragonatx.com" },
      { id: "conv_3", contactId: "ct_q7r8s9t0", contactName: "Lisa Rodriguez", lastMessage: "I'd love to discuss the lead gen proposal.", lastMessageDate: "2026-02-02T09:20:00Z", unreadCount: 2, type: "sms", contactEmail: "lisa@rodriguezrealty.com" },
      { id: "conv_4", contactId: "ct_k7l8m9n0", contactName: "Michael Turner", lastMessage: "Thanks for the quick response!", lastMessageDate: "2026-02-01T14:55:00Z", unreadCount: 0, type: "sms", contactEmail: "mike@turnerautocare.com" },
      { id: "conv_5", contactId: "ct_u1v2w3x4", contactName: "James Wilson", lastMessage: "What's included in the Google Ads package?", lastMessageDate: "2026-01-31T11:30:00Z", unreadCount: 1, type: "email", contactEmail: "jwilson.contractor@gmail.com" },
      { id: "conv_6", contactId: "ct_y5z6a7b8", contactName: "Rachel Kim", lastMessage: "The social media campaign is performing great!", lastMessageDate: "2026-01-30T15:10:00Z", unreadCount: 0, type: "sms", contactEmail: "rachel@eventsbyrk.com" },
    ],
  }),

  "conversation-thread": () => ({
    conversation: { id: "conv_1", contactId: "ct_a1b2c3d4", contactName: "Sarah Martinez", type: "sms" },
    messages: [
      { id: "msg_1", direction: "inbound", body: "Hey Jake! Do you have any availability this week for a strategy session?", date: "2026-02-03T09:45:00Z", type: "sms", status: "delivered" },
      { id: "msg_2", direction: "outbound", body: "Hi Sarah! Absolutely — how about Thursday at 2pm?", date: "2026-02-03T10:02:00Z", type: "sms", status: "delivered" },
      { id: "msg_3", direction: "inbound", body: "Sounds great — let's schedule for Thursday!", date: "2026-02-03T10:15:00Z", type: "sms", status: "delivered" },
      { id: "msg_4", direction: "outbound", body: "Perfect, I've sent you a calendar invite. Looking forward to it!", date: "2026-02-03T10:20:00Z", type: "sms", status: "delivered" },
    ],
  }),

  "message-composer": () => ({ contact: CONTACTS[0] }),

  "message-detail": () => ({
    message: { id: "msg_det_1", direction: "inbound", body: "Hi, I'd like to discuss our marketing strategy for Q2. Can we set up a call?", date: "2026-02-02T11:00:00Z", type: "voicemail", contactId: "ct_a1b2c3d4", contactName: "Sarah Martinez", duration: 45 },
    recording: { url: "#", duration: 45, format: "mp3" },
    transcription: "Hi Jake, this is Sarah from Martinez Digital. I wanted to touch base about our Q2 marketing strategy. We're looking at expanding into TikTok and wanted your thoughts on budget allocation. Give me a call back when you get a chance. Thanks!",
  }),

  "email-template-preview": () => ({
    template: {
      id: "tpl_1",
      name: "Monthly Newsletter",
      subject: "{{contact.firstName}}, here's your February marketing update",
      body: "<h2>Hi {{contact.firstName}},</h2><p>Here's what's happening this month at LocalBosses HQ:</p><ul><li>New Google Ads strategies for local businesses</li><li>Case study: How we grew Golden Dragon's traffic by 340%</li><li>Upcoming webinar: Social Media Mastery</li></ul><p>Best,<br>The LocalBosses Team</p>",
      previewText: "Your monthly marketing insights are here...",
      createdAt: "2026-01-25T10:00:00Z",
      updatedAt: "2026-02-01T14:00:00Z",
    },
  }),

  "template-library": () => ({
    templates: [
      { id: "tpl_1", name: "Monthly Newsletter", type: "email", subject: "Your February marketing update", category: "Newsletter", lastUsed: "2026-02-01T10:00:00Z" },
      { id: "tpl_2", name: "Welcome Sequence — Day 1", type: "email", subject: "Welcome to LocalBosses!", category: "Onboarding", lastUsed: "2026-01-28T09:00:00Z" },
      { id: "tpl_3", name: "Appointment Reminder", type: "sms", subject: "", category: "Reminders", lastUsed: "2026-02-03T08:00:00Z" },
      { id: "tpl_4", name: "Review Request", type: "sms", subject: "", category: "Reviews", lastUsed: "2026-01-30T11:00:00Z" },
      { id: "tpl_5", name: "Proposal Follow-Up", type: "email", subject: "Following up on our proposal", category: "Sales", lastUsed: "2026-01-27T14:00:00Z" },
      { id: "tpl_6", name: "Re-engagement — 30 Day", type: "email", subject: "We miss you, {{contact.firstName}}!", category: "Re-engagement", lastUsed: "2026-01-15T10:00:00Z" },
      { id: "tpl_7", name: "Invoice Payment Reminder", type: "email", subject: "Friendly reminder: Invoice #{{invoice.number}} is due", category: "Billing", lastUsed: "2026-02-02T09:00:00Z" },
    ],
  }),

  // ── Calls ─────────────────────────────────────────────────────────────────

  "call-log": () => ({
    calls: [
      { id: "call_1", contactId: "ct_a1b2c3d4", contactName: "Sarah Martinez", direction: "outbound", status: "completed", duration: 420, date: "2026-02-03T11:00:00Z", outcome: "Scheduled follow-up" },
      { id: "call_2", contactId: "ct_e5f6g7h8", contactName: "David Chen", direction: "inbound", status: "completed", duration: 180, date: "2026-02-02T15:30:00Z", outcome: "Sent proposal" },
      { id: "call_3", contactId: "ct_u1v2w3x4", contactName: "James Wilson", direction: "outbound", status: "no-answer", duration: 0, date: "2026-02-02T10:00:00Z", outcome: "Left voicemail" },
      { id: "call_4", contactId: "ct_q7r8s9t0", contactName: "Lisa Rodriguez", direction: "inbound", status: "completed", duration: 600, date: "2026-02-01T14:00:00Z", outcome: "Discovery call" },
      { id: "call_5", contactId: "ct_k7l8m9n0", contactName: "Michael Turner", direction: "outbound", status: "completed", duration: 300, date: "2026-02-01T09:30:00Z", outcome: "Onboarding intro" },
      { id: "call_6", contactId: "ct_c9d0e1f2", contactName: "Thomas Brown", direction: "outbound", status: "completed", duration: 240, date: "2026-01-30T16:00:00Z", outcome: "Proposal review" },
    ],
  }),

  "call-detail": () => ({
    call: {
      id: "call_1",
      contactId: "ct_a1b2c3d4",
      contactName: "Sarah Martinez",
      contactPhone: "+1 (512) 555-0147",
      direction: "outbound",
      status: "completed",
      duration: 420,
      date: "2026-02-03T11:00:00Z",
      outcome: "Scheduled strategy review for Thursday",
      recording: { url: "#", duration: 420 },
      notes: "Sarah confirmed she wants to explore TikTok marketing. Needs a revised proposal by Friday.",
    },
  }),

  // ── Campaigns ─────────────────────────────────────────────────────────────

  "campaign-stats": () => ({
    campaigns: [
      { id: "camp_1", name: "February Newsletter", type: "email", status: "sent", sent: 847, opened: 412, clicked: 128, bounced: 12, sentDate: "2026-02-01T10:00:00Z" },
      { id: "camp_2", name: "Valentine's Day Promo", type: "email", status: "scheduled", sent: 0, opened: 0, clicked: 0, bounced: 0, sentDate: "2026-02-12T09:00:00Z" },
      { id: "camp_3", name: "New Year Re-engagement", type: "email", status: "sent", sent: 523, opened: 289, clicked: 87, bounced: 8, sentDate: "2026-01-05T10:00:00Z" },
      { id: "camp_4", name: "Review Request — Jan", type: "sms", status: "sent", sent: 156, opened: 0, clicked: 42, bounced: 3, sentDate: "2026-01-15T11:00:00Z" },
      { id: "camp_5", name: "Holiday Thank You", type: "email", status: "sent", sent: 1024, opened: 687, clicked: 234, bounced: 15, sentDate: "2025-12-20T10:00:00Z" },
    ],
    campaign: { id: "camp_1", name: "February Newsletter", type: "email", status: "sent", sent: 847, opened: 412, clicked: 128, bounced: 12, openRate: 48.6, clickRate: 15.1, sentDate: "2026-02-01T10:00:00Z" },
  }),

  // ── Invoicing / Payments ──────────────────────────────────────────────────

  "invoice-builder": () => ({}),

  "invoice-list": () => ({
    invoices: [
      { id: "inv_001", number: "INV-2026-001", contactId: "ct_a1b2c3d4", contactName: "Sarah Martinez", amount: 4500, status: "paid", dueDate: "2026-01-31", paidDate: "2026-01-28T10:00:00Z", createdAt: "2026-01-01T10:00:00Z" },
      { id: "inv_002", number: "INV-2026-002", contactId: "ct_e5f6g7h8", contactName: "David Chen", amount: 2500, status: "sent", dueDate: "2026-02-15", paidDate: null, createdAt: "2026-01-15T10:00:00Z" },
      { id: "inv_003", number: "INV-2026-003", contactId: "ct_m3n4o5p6", contactName: "Marcus Johnson", amount: 8000, status: "paid", dueDate: "2026-01-15", paidDate: "2026-01-12T14:00:00Z", createdAt: "2025-12-15T10:00:00Z" },
      { id: "inv_004", number: "INV-2026-004", contactId: "ct_y5z6a7b8", contactName: "Rachel Kim", amount: 3000, status: "paid", dueDate: "2026-02-01", paidDate: "2026-01-30T09:00:00Z", createdAt: "2026-01-01T10:00:00Z" },
      { id: "inv_005", number: "INV-2026-005", contactId: "ct_q7r8s9t0", contactName: "Lisa Rodriguez", amount: 2800, status: "draft", dueDate: "2026-02-28", paidDate: null, createdAt: "2026-02-01T10:00:00Z" },
      { id: "inv_006", number: "INV-2026-006", contactId: "ct_k7l8m9n0", contactName: "Michael Turner", amount: 1200, status: "overdue", dueDate: "2026-01-20", paidDate: null, createdAt: "2025-12-20T10:00:00Z" },
    ],
    currency: "USD",
  }),

  "invoice-preview": () => ({
    invoice: {
      id: "inv_002",
      number: "INV-2026-002",
      contact: CONTACTS[1],
      items: [
        { description: "Website Redesign — Phase 1", quantity: 1, unitPrice: 1500, total: 1500 },
        { description: "Hosting Setup & Configuration", quantity: 1, unitPrice: 500, total: 500 },
        { description: "SEO Audit & Optimization", quantity: 1, unitPrice: 500, total: 500 },
      ],
      subtotal: 2500,
      tax: 0,
      total: 2500,
      status: "sent",
      dueDate: "2026-02-15",
      createdAt: "2026-01-15T10:00:00Z",
      currency: "USD",
    },
  }),

  "estimate-builder": () => ({ currency: "USD" }),

  "estimate-preview": () => ({
    estimate: {
      id: "est_001",
      number: "EST-2026-001",
      contact: CONTACTS[7],
      items: [
        { description: "Google Ads Campaign Setup", quantity: 1, unitPrice: 1500, total: 1500 },
        { description: "Monthly Ad Management (3 months)", quantity: 3, unitPrice: 800, total: 2400 },
        { description: "Landing Page Design", quantity: 2, unitPrice: 600, total: 1200 },
      ],
      subtotal: 5100,
      tax: 0,
      total: 5100,
      status: "sent",
      validUntil: "2026-02-28",
      createdAt: "2026-01-30T10:00:00Z",
      currency: "USD",
    },
  }),

  "transaction-list": () => ({
    transactions: [
      { id: "txn_1", type: "payment", amount: 4500, contactName: "Sarah Martinez", description: "INV-2026-001 payment", date: "2026-01-28T10:00:00Z", status: "succeeded", method: "credit_card" },
      { id: "txn_2", type: "payment", amount: 8000, contactName: "Marcus Johnson", description: "INV-2026-003 payment", date: "2026-01-12T14:00:00Z", status: "succeeded", method: "ach" },
      { id: "txn_3", type: "payment", amount: 3000, contactName: "Rachel Kim", description: "INV-2026-004 payment", date: "2026-01-30T09:00:00Z", status: "succeeded", method: "credit_card" },
      { id: "txn_4", type: "refund", amount: -500, contactName: "Jennifer Davis", description: "Partial refund — unused credits", date: "2026-01-25T11:00:00Z", status: "succeeded", method: "credit_card" },
      { id: "txn_5", type: "payment", amount: 6000, contactName: "Rachel Kim", description: "Social media package — annual", date: "2025-12-15T10:00:00Z", status: "succeeded", method: "credit_card" },
      { id: "txn_6", type: "payment", amount: 2400, contactName: "David Chen", description: "Monthly retainer — December", date: "2025-12-01T10:00:00Z", status: "succeeded", method: "ach" },
    ],
    currency: "USD",
  }),

  "revenue-dashboard": () => ({
    invoices: [
      { id: "inv_001", amount: 4500, status: "paid", paidDate: "2026-01-28", month: "January" },
      { id: "inv_003", amount: 8000, status: "paid", paidDate: "2026-01-12", month: "January" },
      { id: "inv_004", amount: 3000, status: "paid", paidDate: "2026-01-30", month: "January" },
      { id: "inv_002", amount: 2500, status: "sent", dueDate: "2026-02-15", month: "February" },
      { id: "inv_005", amount: 2800, status: "draft", dueDate: "2026-02-28", month: "February" },
    ],
    opportunities: OPPORTUNITIES,
  }),

  "subscription-manager": () => ({
    subscriptions: [
      { id: "sub_1", contactId: "ct_a1b2c3d4", contactName: "Sarah Martinez", plan: "SEO Retainer — Monthly", amount: 4500, interval: "monthly", status: "active", startDate: "2025-06-01", nextBilling: "2026-03-01" },
      { id: "sub_2", contactId: "ct_y5z6a7b8", contactName: "Rachel Kim", plan: "Social Media Package — Annual", amount: 6000, interval: "yearly", status: "active", startDate: "2025-09-20", nextBilling: "2026-09-20" },
      { id: "sub_3", contactId: "ct_e5f6g7h8", contactName: "David Chen", plan: "Monthly Web Maintenance", amount: 800, interval: "monthly", status: "active", startDate: "2025-12-15", nextBilling: "2026-02-15" },
      { id: "sub_4", contactId: "ct_m3n4o5p6", contactName: "Marcus Johnson", plan: "Consulting Retainer", amount: 8000, interval: "monthly", status: "active", startDate: "2025-10-01", nextBilling: "2026-03-01" },
      { id: "sub_5", contactId: "ct_g3h4i5j6", contactName: "Jennifer Davis", plan: "Email Marketing — Monthly", amount: 1200, interval: "monthly", status: "cancelled", startDate: "2025-08-01", nextBilling: null },
    ],
    currency: "USD",
  }),

  "coupon-manager": () => ({
    coupons: [
      { id: "cpn_1", code: "WELCOME20", name: "Welcome Discount", type: "percentage", value: 20, usageCount: 34, maxUses: 100, status: "active", expiresAt: "2026-06-30" },
      { id: "cpn_2", code: "REFER50", name: "Referral Bonus", type: "fixed", value: 50, usageCount: 12, maxUses: null, status: "active", expiresAt: null },
      { id: "cpn_3", code: "VALENTINES", name: "Valentine's Day Special", type: "percentage", value: 15, usageCount: 0, maxUses: 50, status: "active", expiresAt: "2026-02-28" },
      { id: "cpn_4", code: "HOLIDAY2025", name: "Holiday Sale", type: "percentage", value: 25, usageCount: 89, maxUses: 100, status: "expired", expiresAt: "2025-12-31" },
    ],
    currency: "USD",
  }),

  // ── Orders / Products ─────────────────────────────────────────────────────

  "order-list": () => ({
    orders: [
      { id: "ord_1", contactName: "Sarah Martinez", items: 2, total: 4500, status: "completed", createdAt: "2026-01-28T10:00:00Z", paymentStatus: "paid" },
      { id: "ord_2", contactName: "David Chen", items: 3, total: 2500, status: "processing", createdAt: "2026-02-01T14:00:00Z", paymentStatus: "pending" },
      { id: "ord_3", contactName: "Marcus Johnson", items: 1, total: 8000, status: "completed", createdAt: "2026-01-12T14:00:00Z", paymentStatus: "paid" },
      { id: "ord_4", contactName: "Rachel Kim", items: 1, total: 6000, status: "completed", createdAt: "2025-12-15T10:00:00Z", paymentStatus: "paid" },
      { id: "ord_5", contactName: "Lisa Rodriguez", items: 2, total: 2800, status: "pending", createdAt: "2026-02-02T09:00:00Z", paymentStatus: "unpaid" },
    ],
    currency: "USD",
  }),

  "order-detail": () => ({}),

  "product-catalog": () => ({
    products: [
      { id: "prod_1", name: "SEO Retainer — Monthly", price: 4500, category: "Services", status: "active", description: "Full-service SEO including keyword research, on-page optimization, and monthly reporting.", image: null },
      { id: "prod_2", name: "Website Design Package", price: 5000, category: "Services", status: "active", description: "Custom responsive website design with up to 10 pages.", image: null },
      { id: "prod_3", name: "Google Ads Management", price: 1500, category: "Services", status: "active", description: "Monthly Google Ads campaign management and optimization.", image: null },
      { id: "prod_4", name: "Social Media Package — Monthly", price: 2000, category: "Services", status: "active", description: "Content creation and posting across 3 platforms.", image: null },
      { id: "prod_5", name: "Email Marketing Setup", price: 1200, category: "Services", status: "active", description: "Email funnel design, template creation, and automation setup.", image: null },
      { id: "prod_6", name: "Brand Identity Kit", price: 3500, category: "Services", status: "active", description: "Logo, color palette, typography, and brand guidelines.", image: null },
      { id: "prod_7", name: "Landing Page Design", price: 600, category: "Add-ons", status: "active", description: "Single high-converting landing page.", image: null },
    ],
    currency: "USD",
  }),

  "product-detail": () => ({
    product: { id: "prod_1", name: "SEO Retainer — Monthly", description: "Full-service SEO including keyword research, on-page optimization, link building, and monthly reporting. Includes bi-weekly check-in calls.", category: "Services", status: "active", createdAt: "2025-06-01T10:00:00Z" },
    prices: [
      { id: "price_1a", name: "Standard", amount: 4500, interval: "monthly", currency: "USD", active: true },
      { id: "price_1b", name: "Annual (Save 10%)", amount: 48600, interval: "yearly", currency: "USD", active: true },
    ],
  }),

  "inventory-dashboard": () => ({
    inventory: [
      { id: "inv_item_1", name: "Business Card Templates", sku: "BC-001", quantity: 500, reorderLevel: 100, category: "Print Materials", lastUpdated: "2026-01-15T10:00:00Z" },
      { id: "inv_item_2", name: "Branded Stickers", sku: "STK-001", quantity: 250, reorderLevel: 50, category: "Promotional", lastUpdated: "2026-01-20T10:00:00Z" },
      { id: "inv_item_3", name: "Client Welcome Kits", sku: "WK-001", quantity: 15, reorderLevel: 10, category: "Onboarding", lastUpdated: "2026-02-01T10:00:00Z" },
      { id: "inv_item_4", name: "USB Drives (Branded)", sku: "USB-001", quantity: 75, reorderLevel: 25, category: "Promotional", lastUpdated: "2026-01-10T10:00:00Z" },
      { id: "inv_item_5", name: "Presentation Folders", sku: "PF-001", quantity: 200, reorderLevel: 50, category: "Print Materials", lastUpdated: "2025-12-20T10:00:00Z" },
    ],
  }),

  // ── Funnels / Forms ───────────────────────────────────────────────────────

  "funnel-list": () => ({
    funnels: [
      { id: "fun_1", name: "Free SEO Audit Funnel", steps: 4, status: "active", visits: 1247, conversions: 89, conversionRate: 7.1, createdAt: "2025-09-01T10:00:00Z" },
      { id: "fun_2", name: "Website Redesign Inquiry", steps: 3, status: "active", visits: 834, conversions: 42, conversionRate: 5.0, createdAt: "2025-10-15T10:00:00Z" },
      { id: "fun_3", name: "Social Media Strategy Session", steps: 3, status: "active", visits: 567, conversions: 31, conversionRate: 5.5, createdAt: "2025-11-01T10:00:00Z" },
      { id: "fun_4", name: "Holiday Promo Landing Page", steps: 2, status: "inactive", visits: 2100, conversions: 178, conversionRate: 8.5, createdAt: "2025-11-20T10:00:00Z" },
      { id: "fun_5", name: "Client Referral Program", steps: 3, status: "active", visits: 345, conversions: 23, conversionRate: 6.7, createdAt: "2026-01-05T10:00:00Z" },
    ],
  }),

  "funnel-detail": () => ({
    funnel: {
      id: "fun_1",
      name: "Free SEO Audit Funnel",
      status: "active",
      steps: [
        { id: "fs_1", name: "Landing Page", type: "page", visits: 1247, conversions: 412 },
        { id: "fs_2", name: "Audit Form", type: "form", visits: 412, conversions: 234 },
        { id: "fs_3", name: "Calendar Booking", type: "booking", visits: 234, conversions: 128 },
        { id: "fs_4", name: "Thank You Page", type: "page", visits: 128, conversions: 89 },
      ],
      totalVisits: 1247,
      totalConversions: 89,
      conversionRate: 7.1,
      createdAt: "2025-09-01T10:00:00Z",
    },
  }),

  "form-list": () => ({
    forms: [
      { id: "form_1", name: "Contact Us", submissions: 234, status: "active", createdAt: "2025-06-01T10:00:00Z", lastSubmission: "2026-02-03T08:20:00Z" },
      { id: "form_2", name: "Free SEO Audit Request", submissions: 89, status: "active", createdAt: "2025-09-01T10:00:00Z", lastSubmission: "2026-02-02T14:30:00Z" },
      { id: "form_3", name: "Newsletter Signup", submissions: 567, status: "active", createdAt: "2025-03-15T10:00:00Z", lastSubmission: "2026-02-03T10:15:00Z" },
      { id: "form_4", name: "Client Feedback Survey", submissions: 42, status: "active", createdAt: "2025-11-01T10:00:00Z", lastSubmission: "2026-01-28T16:00:00Z" },
      { id: "form_5", name: "Partnership Inquiry", submissions: 18, status: "active", createdAt: "2026-01-01T10:00:00Z", lastSubmission: "2026-01-31T11:00:00Z" },
    ],
  }),

  "form-submissions": () => ({
    submissions: [
      { id: "fsub_1", formId: "form_1", data: { name: "Tom Richards", email: "tom@richards.com", phone: "+1 (512) 555-2200", message: "Interested in website design services" }, submittedAt: "2026-02-03T08:20:00Z" },
      { id: "fsub_2", formId: "form_1", data: { name: "Amy Park", email: "amy.park@outlook.com", phone: "+1 (512) 555-3301", message: "Need help with Google Ads" }, submittedAt: "2026-02-02T14:30:00Z" },
      { id: "fsub_3", formId: "form_1", data: { name: "Carlos Mendez", email: "carlos@cmplumbing.com", phone: "+1 (512) 555-4402", message: "Looking for a marketing agency for my plumbing business" }, submittedAt: "2026-02-01T11:00:00Z" },
      { id: "fsub_4", formId: "form_1", data: { name: "Diana Foster", email: "diana.foster@gmail.com", phone: "+1 (512) 555-5503", message: "Can you help with social media management?" }, submittedAt: "2026-01-31T09:45:00Z" },
      { id: "fsub_5", formId: "form_1", data: { name: "Ryan Mitchell", email: "ryan@mitchelllaw.com", phone: "+1 (512) 555-6604", message: "Need SEO for my law firm website" }, submittedAt: "2026-01-30T16:20:00Z" },
    ],
    formName: "Contact Form",
  }),

  // ── Surveys ───────────────────────────────────────────────────────────────

  "survey-list": () => ({
    surveys: [
      { id: "srv_1", name: "Customer Satisfaction — Q1 2026", responses: 47, status: "active", createdAt: "2026-01-01T10:00:00Z" },
      { id: "srv_2", name: "Service Quality Feedback", responses: 23, status: "active", createdAt: "2025-10-01T10:00:00Z" },
      { id: "srv_3", name: "Net Promoter Score", responses: 89, status: "active", createdAt: "2025-06-01T10:00:00Z" },
      { id: "srv_4", name: "Event Feedback — Holiday Party", responses: 31, status: "closed", createdAt: "2025-12-18T10:00:00Z" },
    ],
  }),

  "survey-submissions": () => ({
    submissions: [
      { id: "ssub_1", surveyId: "srv_1", respondentName: "Sarah Martinez", responses: { overall: 5, communication: 5, quality: 5, recommend: "Definitely" }, submittedAt: "2026-01-28T10:00:00Z" },
      { id: "ssub_2", surveyId: "srv_1", respondentName: "David Chen", responses: { overall: 4, communication: 4, quality: 5, recommend: "Likely" }, submittedAt: "2026-01-25T14:00:00Z" },
      { id: "ssub_3", surveyId: "srv_1", respondentName: "Lisa Rodriguez", responses: { overall: 5, communication: 5, quality: 4, recommend: "Definitely" }, submittedAt: "2026-01-20T11:00:00Z" },
      { id: "ssub_4", surveyId: "srv_1", respondentName: "Rachel Kim", responses: { overall: 4, communication: 5, quality: 4, recommend: "Likely" }, submittedAt: "2026-01-18T09:00:00Z" },
      { id: "ssub_5", surveyId: "srv_1", respondentName: "Michael Turner", responses: { overall: 5, communication: 4, quality: 5, recommend: "Definitely" }, submittedAt: "2026-01-15T15:00:00Z" },
    ],
    surveyName: "Customer Feedback",
  }),

  // ── Social ────────────────────────────────────────────────────────────────

  "social-accounts": () => ({
    accounts: [
      { id: "soc_1", platform: "facebook", name: "LocalBosses", handle: "@localbosses", followers: 2340, status: "connected", avatar: null },
      { id: "soc_2", platform: "instagram", name: "LocalBosses", handle: "@localbosses", followers: 4120, status: "connected", avatar: null },
      { id: "soc_3", platform: "linkedin", name: "LocalBosses", handle: "localbosses", followers: 1890, status: "connected", avatar: null },
      { id: "soc_4", platform: "twitter", name: "LocalBosses", handle: "@localbosseshq", followers: 987, status: "connected", avatar: null },
      { id: "soc_5", platform: "google_business", name: "LocalBosses HQ", handle: "", followers: 0, status: "connected", avatar: null },
    ],
  }),

  "social-calendar": () => ({
    posts: [
      { id: "sp_1", platform: "instagram", content: "🚀 New case study: How we helped Golden Dragon Restaurant increase online orders by 250%! Link in bio.", scheduledDate: "2026-02-04T12:00:00Z", status: "scheduled" },
      { id: "sp_2", platform: "facebook", content: "Free SEO Audit! Want to know how your website ranks? Get a free comprehensive audit today. 🔍", scheduledDate: "2026-02-05T10:00:00Z", status: "scheduled" },
      { id: "sp_3", platform: "linkedin", content: "5 marketing mistakes small businesses make (and how to fix them). Our latest blog post breaks it all down.", scheduledDate: "2026-02-06T14:00:00Z", status: "scheduled" },
      { id: "sp_4", platform: "instagram", content: "Happy client alert! 🎉 Sarah from Martinez Digital just hit 10K monthly website visitors.", publishedDate: "2026-02-02T11:00:00Z", status: "published", likes: 87, comments: 12 },
      { id: "sp_5", platform: "facebook", content: "Behind the scenes at LocalBosses HQ — our team brainstorming the next big campaign! 💡", publishedDate: "2026-01-30T15:00:00Z", status: "published", likes: 134, comments: 23 },
      { id: "sp_6", platform: "twitter", content: "Local businesses that invest in SEO see an average of 40% more organic traffic within 6 months. Ready to grow? 📈", publishedDate: "2026-01-28T09:00:00Z", status: "published", likes: 42, comments: 5 },
    ],
  }),

  "social-post-composer": () => ({
    accounts: [
      { id: "soc_1", platform: "facebook", name: "LocalBosses", handle: "@localbosses", connected: true },
      { id: "soc_2", platform: "instagram", name: "LocalBosses", handle: "@localbosses", connected: true },
      { id: "soc_3", platform: "linkedin", name: "LocalBosses", handle: "localbosses", connected: true },
      { id: "soc_4", platform: "twitter", name: "LocalBosses", handle: "@localbosseshq", connected: true },
    ],
  }),

  // ── Courses ───────────────────────────────────────────────────────────────

  "course-catalog": () => ({
    courses: [
      { id: "crs_1", title: "Local SEO Masterclass", description: "Learn how to dominate local search results.", lessons: 12, students: 89, status: "published", price: 297, thumbnail: null },
      { id: "crs_2", title: "Google Ads for Small Business", description: "Create profitable Google Ads campaigns from scratch.", lessons: 8, students: 56, status: "published", price: 197, thumbnail: null },
      { id: "crs_3", title: "Social Media Strategy Blueprint", description: "Build a winning social media presence for your local business.", lessons: 10, students: 134, status: "published", price: 247, thumbnail: null },
      { id: "crs_4", title: "Email Marketing Automation", description: "Set up email funnels that convert leads into customers.", lessons: 6, students: 42, status: "draft", price: 147, thumbnail: null },
    ],
  }),

  "course-detail": () => ({
    course: {
      id: "crs_1",
      title: "Local SEO Masterclass",
      description: "Learn how to dominate local search results with proven strategies for Google Business Profile, local keywords, citations, and reviews.",
      lessons: [
        { id: "les_1", title: "Introduction to Local SEO", duration: "12:30", completed: true },
        { id: "les_2", title: "Google Business Profile Optimization", duration: "18:45", completed: true },
        { id: "les_3", title: "Keyword Research for Local Businesses", duration: "15:20", completed: true },
        { id: "les_4", title: "On-Page SEO Fundamentals", duration: "22:10", completed: false },
        { id: "les_5", title: "Building Local Citations", duration: "14:00", completed: false },
        { id: "les_6", title: "Review Management Strategy", duration: "16:30", completed: false },
      ],
      students: 89,
      status: "published",
      price: 297,
      progress: 50,
    },
  }),

  // ── Blog ──────────────────────────────────────────────────────────────────

  "blog-manager": () => ({}),

  // ── Media ─────────────────────────────────────────────────────────────────

  "media-library": () => ({
    files: [
      { id: "file_1", name: "logo-primary.png", type: "image/png", size: 245000, url: "#", uploadedAt: "2025-06-01T10:00:00Z", folder: "Brand Assets" },
      { id: "file_2", name: "hero-banner.jpg", type: "image/jpeg", size: 1200000, url: "#", uploadedAt: "2025-09-15T10:00:00Z", folder: "Website" },
      { id: "file_3", name: "case-study-golden-dragon.pdf", type: "application/pdf", size: 3400000, url: "#", uploadedAt: "2026-01-20T10:00:00Z", folder: "Case Studies" },
      { id: "file_4", name: "social-post-template.psd", type: "image/vnd.adobe.photoshop", size: 8500000, url: "#", uploadedAt: "2025-11-01T10:00:00Z", folder: "Templates" },
      { id: "file_5", name: "client-testimonial-sarah.mp4", type: "video/mp4", size: 45000000, url: "#", uploadedAt: "2026-01-15T10:00:00Z", folder: "Testimonials" },
      { id: "file_6", name: "seo-checklist.pdf", type: "application/pdf", size: 890000, url: "#", uploadedAt: "2025-08-10T10:00:00Z", folder: "Resources" },
    ],
    items: [
      { id: "file_1", name: "logo-primary.png", type: "image/png", size: 245000, url: "#", uploadedAt: "2025-06-01T10:00:00Z" },
      { id: "file_2", name: "hero-banner.jpg", type: "image/jpeg", size: 1200000, url: "#", uploadedAt: "2025-09-15T10:00:00Z" },
      { id: "file_3", name: "case-study-golden-dragon.pdf", type: "application/pdf", size: 3400000, url: "#", uploadedAt: "2026-01-20T10:00:00Z" },
    ],
  }),

  // ── Workflows ─────────────────────────────────────────────────────────────

  "workflow-status": () => ({
    workflows: [
      { id: "wf_1", name: "New Lead — Welcome Sequence", status: "active", triggerType: "contact_created", executionCount: 347, lastRun: "2026-02-03T08:20:00Z", createdAt: "2025-06-01T10:00:00Z" },
      { id: "wf_2", name: "Appointment Reminder (24hr)", status: "active", triggerType: "appointment_scheduled", executionCount: 892, lastRun: "2026-02-03T09:00:00Z", createdAt: "2025-06-15T10:00:00Z" },
      { id: "wf_3", name: "Review Request — Post Appointment", status: "active", triggerType: "appointment_completed", executionCount: 234, lastRun: "2026-02-02T17:00:00Z", createdAt: "2025-07-01T10:00:00Z" },
      { id: "wf_4", name: "Stale Lead Re-engagement", status: "active", triggerType: "scheduled", executionCount: 156, lastRun: "2026-02-01T06:00:00Z", createdAt: "2025-09-01T10:00:00Z" },
      { id: "wf_5", name: "Invoice Payment Reminder", status: "active", triggerType: "invoice_overdue", executionCount: 67, lastRun: "2026-01-31T10:00:00Z", createdAt: "2025-10-01T10:00:00Z" },
      { id: "wf_6", name: "Birthday Campaign", status: "paused", triggerType: "contact_birthday", executionCount: 23, lastRun: "2026-01-15T08:00:00Z", createdAt: "2025-12-01T10:00:00Z" },
    ],
  }),

  "workflow-detail": () => ({
    workflow: {
      id: "wf_1",
      name: "New Lead — Welcome Sequence",
      status: "active",
      triggerType: "contact_created",
      trigger: { type: "contact_created", filters: [{ field: "source", value: "Website Form" }] },
      actions: [
        { id: "wa_1", type: "send_email", name: "Welcome Email", delay: "0m", templateId: "tpl_2" },
        { id: "wa_2", type: "wait", name: "Wait 24 Hours", delay: "24h" },
        { id: "wa_3", type: "send_sms", name: "Follow-up SMS", delay: "0m", message: "Hi {{contact.firstName}}, thanks for reaching out! Want to schedule a quick call?" },
        { id: "wa_4", type: "create_task", name: "Create Follow-up Task", delay: "0m", taskTitle: "Follow up with {{contact.firstName}} {{contact.lastName}}" },
        { id: "wa_5", type: "wait", name: "Wait 3 Days", delay: "72h" },
        { id: "wa_6", type: "send_email", name: "Value Email", delay: "0m", templateId: "tpl_6" },
      ],
      executionCount: 347,
      lastRun: "2026-02-03T08:20:00Z",
      createdAt: "2025-06-01T10:00:00Z",
    },
  }),

  // ── Team / Tasks ──────────────────────────────────────────────────────────

  "task-board": () => ({
    tasks: [
      { id: "tb_1", title: "Send Q1 performance report to Sarah", assignedTo: "Jake Shore", dueDate: "2026-02-07T17:00:00Z", priority: "high", status: "todo", contactId: "ct_a1b2c3d4" },
      { id: "tb_2", title: "Prepare renewal proposal for Martinez Digital", assignedTo: "Alex Rivera", dueDate: "2026-02-15T17:00:00Z", priority: "high", status: "todo", contactId: "ct_a1b2c3d4" },
      { id: "tb_3", title: "Follow up with James Wilson on Google Ads", assignedTo: "Jake Shore", dueDate: "2026-02-05T17:00:00Z", priority: "medium", status: "in_progress", contactId: "ct_u1v2w3x4" },
      { id: "tb_4", title: "Create mockups for Golden Dragon redesign", assignedTo: "Alex Rivera", dueDate: "2026-02-10T17:00:00Z", priority: "high", status: "in_progress", contactId: "ct_e5f6g7h8" },
      { id: "tb_5", title: "Set up review automation for Turner Auto", assignedTo: "Jake Shore", dueDate: "2026-02-08T17:00:00Z", priority: "medium", status: "todo", contactId: "ct_k7l8m9n0" },
      { id: "tb_6", title: "Publish February blog post", assignedTo: "Alex Rivera", dueDate: "2026-02-06T17:00:00Z", priority: "low", status: "in_progress" },
      { id: "tb_7", title: "Update client reporting dashboard", assignedTo: "Jake Shore", dueDate: "2026-02-03T17:00:00Z", priority: "medium", status: "done" },
      { id: "tb_8", title: "Onboard Michael Turner", assignedTo: "Jake Shore", dueDate: "2026-02-04T17:00:00Z", priority: "high", status: "todo", contactId: "ct_k7l8m9n0" },
    ],
  }),

  "team-management": () => ({
    members: [
      { id: "usr_1", name: "Jake Shore", email: "jake@localbosses.com", role: "Owner", status: "active", avatar: null, lastActive: "2026-02-03T17:00:00Z" },
      { id: "usr_2", name: "Alex Rivera", email: "alex@localbosses.com", role: "Account Manager", status: "active", avatar: null, lastActive: "2026-02-03T16:30:00Z" },
      { id: "usr_3", name: "Sam Patel", email: "sam@localbosses.com", role: "Content Specialist", status: "active", avatar: null, lastActive: "2026-02-03T15:00:00Z" },
      { id: "usr_4", name: "Jordan Lee", email: "jordan@localbosses.com", role: "Ads Specialist", status: "active", avatar: null, lastActive: "2026-02-02T18:00:00Z" },
    ],
    users: [
      { id: "usr_1", name: "Jake Shore", email: "jake@localbosses.com", role: "Owner", status: "active" },
      { id: "usr_2", name: "Alex Rivera", email: "alex@localbosses.com", role: "Account Manager", status: "active" },
      { id: "usr_3", name: "Sam Patel", email: "sam@localbosses.com", role: "Content Specialist", status: "active" },
      { id: "usr_4", name: "Jordan Lee", email: "jordan@localbosses.com", role: "Ads Specialist", status: "active" },
    ],
  }),

  "user-detail": () => ({
    user: {
      id: "usr_1",
      name: "Jake Shore",
      email: "jake@localbosses.com",
      phone: "+1 (512) 555-0001",
      role: "Owner",
      status: "active",
      permissions: ["admin", "billing", "contacts", "pipelines", "calendars", "workflows", "reporting"],
      createdAt: "2025-01-01T10:00:00Z",
      lastActive: "2026-02-03T17:00:00Z",
    },
  }),

  "agent-stats": () => ({
    userId: "demo",
    appointmentsBooked: 45,
    callsMade: 120,
    emailsSent: 89,
    tasksCompleted: 67,
    activityLog: [
      { id: "al_1", type: "call", description: "Called Sarah Martinez", date: "2026-02-03T11:00:00Z" },
      { id: "al_2", type: "email", description: "Sent proposal to David Chen", date: "2026-02-03T10:30:00Z" },
      { id: "al_3", type: "task", description: "Completed: Update reporting dashboard", date: "2026-02-03T09:00:00Z" },
      { id: "al_4", type: "appointment", description: "Booked meeting with Lisa Rodriguez", date: "2026-02-02T15:00:00Z" },
      { id: "al_5", type: "call", description: "Called James Wilson (no answer)", date: "2026-02-02T10:00:00Z" },
      { id: "al_6", type: "email", description: "Sent follow-up to Thomas Brown", date: "2026-02-01T16:00:00Z" },
      { id: "al_7", type: "task", description: "Completed: Set up Turner Auto Care account", date: "2026-02-01T14:00:00Z" },
    ],
    activityOverTime: [
      { date: "2026-01-27", calls: 15, emails: 12, tasks: 8 },
      { date: "2026-01-28", calls: 18, emails: 10, tasks: 11 },
      { date: "2026-01-29", calls: 12, emails: 14, tasks: 9 },
      { date: "2026-01-30", calls: 20, emails: 8, tasks: 7 },
      { date: "2026-01-31", calls: 16, emails: 11, tasks: 10 },
      { date: "2026-02-01", calls: 22, emails: 15, tasks: 12 },
      { date: "2026-02-02", calls: 14, emails: 9, tasks: 6 },
      { date: "2026-02-03", calls: 3, emails: 2, tasks: 4 },
    ],
  }),

  // ── Reviews ───────────────────────────────────────────────────────────────

  "reviews-dashboard": () => ({
    reviews: [
      { id: "rev_1", platform: "google", author: "Sarah M.", rating: 5, body: "LocalBosses completely transformed our online presence. Our website traffic tripled in 6 months!", date: "2026-01-28T10:00:00Z", replied: true },
      { id: "rev_2", platform: "google", author: "David C.", rating: 5, body: "Professional team, excellent results. Our restaurant's online orders went up 250%.", date: "2026-01-20T14:00:00Z", replied: true },
      { id: "rev_3", platform: "facebook", author: "Lisa R.", rating: 4, body: "Great marketing agency for local businesses. Responsive and data-driven.", date: "2026-01-15T11:00:00Z", replied: true },
      { id: "rev_4", platform: "google", author: "Rachel K.", rating: 5, body: "Jake and his team are amazing! They helped us build a social media strategy that actually works.", date: "2026-01-10T09:00:00Z", replied: true },
      { id: "rev_5", platform: "yelp", author: "Marcus J.", rating: 4, body: "Solid consulting services. They know the Austin market inside and out.", date: "2025-12-20T15:00:00Z", replied: false },
      { id: "rev_6", platform: "google", author: "Michael T.", rating: 5, body: "Just started working with LocalBosses and already seeing improvements. Highly recommend!", date: "2026-02-02T10:00:00Z", replied: false },
    ],
    reviewsCount: 47,
  }),

  // ── Affiliate ─────────────────────────────────────────────────────────────

  "affiliate-dashboard": () => ({
    stats: { totalAffiliates: 12, activeAffiliates: 8, totalRevenue: 14500, totalCommissions: 2175, conversionRate: 6.8 },
    campaigns: [
      { id: "aff_1", name: "SEO Audit Referral", affiliates: 5, clicks: 234, conversions: 12, revenue: 5940, commission: 891, status: "active" },
      { id: "aff_2", name: "Website Design Referral", affiliates: 3, clicks: 156, conversions: 5, revenue: 5000, commission: 750, status: "active" },
      { id: "aff_3", name: "Social Media Package Referral", affiliates: 4, clicks: 89, conversions: 3, revenue: 3560, commission: 534, status: "active" },
    ],
    summary: { totalClicks: 479, totalConversions: 20, totalRevenue: 14500, totalCommissions: 2175, avgCommissionRate: 15 },
  }),

  // ── Location ──────────────────────────────────────────────────────────────

  "location-dashboard": () => ({
    locationName: "LocalBosses HQ",
    locationId: IDS.loc,
    totalContacts: 1247,
    activeDeals: 23,
    totalPipelineValue: 185000,
    recentContacts: pick(CONTACTS, 5),
    upcomingAppointments: [
      { id: "ua_1", title: "Website Demo — David Chen", date: "2026-02-04T10:00:00Z", contact: "David Chen" },
      { id: "ua_2", title: "Strategy Review — Sarah Martinez", date: "2026-02-05T14:00:00Z", contact: "Sarah Martinez" },
      { id: "ua_3", title: "Proposal Review — Thomas Brown", date: "2026-02-06T09:00:00Z", contact: "Thomas Brown" },
      { id: "ua_4", title: "Lead Gen Workshop — Lisa Rodriguez", date: "2026-02-07T11:00:00Z", contact: "Lisa Rodriguez" },
    ],
    pipelines: [PIPELINE],
    contactsTrend: [
      { date: "2025-09", count: 980 }, { date: "2025-10", count: 1020 }, { date: "2025-11", count: 1078 },
      { date: "2025-12", count: 1134 }, { date: "2026-01", count: 1210 }, { date: "2026-02", count: 1247 },
    ],
    dealsTrend: [
      { date: "2025-09", count: 15 }, { date: "2025-10", count: 18 }, { date: "2025-11", count: 20 },
      { date: "2025-12", count: 17 }, { date: "2026-01", count: 22 }, { date: "2026-02", count: 23 },
    ],
    valueTrend: [
      { date: "2025-09", value: 120000 }, { date: "2025-10", value: 135000 }, { date: "2025-11", value: 148000 },
      { date: "2025-12", value: 155000 }, { date: "2026-01", value: 172000 }, { date: "2026-02", value: 185000 },
    ],
    appointmentsTrend: [
      { date: "2025-09", count: 28 }, { date: "2025-10", count: 35 }, { date: "2025-11", count: 31 },
      { date: "2025-12", count: 22 }, { date: "2026-01", count: 38 }, { date: "2026-02", count: 14 },
    ],
    calendars: [
      { id: IDS.calendar, name: "Client Meetings" },
      { id: IDS.calendar2, name: "Internal Meetings" },
    ],
  }),

  // ── Custom Fields ─────────────────────────────────────────────────────────

  "custom-fields-manager": () => ({
    fields: [
      { id: "cf_1", name: "Preferred Contact Method", key: "preferred_contact", type: "dropdown", options: ["Email", "Phone", "SMS", "WhatsApp"], objectKey: "contact", required: false },
      { id: "cf_2", name: "Account Manager", key: "account_manager", type: "text", objectKey: "contact", required: false },
      { id: "cf_3", name: "Industry", key: "industry", type: "dropdown", options: ["Restaurant", "Healthcare", "Real Estate", "Consulting", "Retail", "Events", "Auto", "Wellness"], objectKey: "contact", required: false },
      { id: "cf_4", name: "Monthly Budget", key: "monthly_budget", type: "number", objectKey: "contact", required: false },
      { id: "cf_5", name: "Contract Start Date", key: "contract_start", type: "date", objectKey: "contact", required: false },
      { id: "cf_6", name: "Referral Source", key: "referral_source", type: "text", objectKey: "contact", required: false },
    ],
    objectKey: "contact",
  }),

  // ── Tags ──────────────────────────────────────────────────────────────────

  "tags-manager": () => ({
    tags: [
      { id: "tag_1", name: "VIP", count: 8, color: "#ff6d5a" },
      { id: "tag_2", name: "Active", count: 34, color: "#4caf50" },
      { id: "tag_3", name: "Marketing", count: 12, color: "#2196f3" },
      { id: "tag_4", name: "Restaurant", count: 6, color: "#ff9800" },
      { id: "tag_5", name: "Real Estate", count: 9, color: "#9c27b0" },
      { id: "tag_6", name: "Lead", count: 45, color: "#00bcd4" },
      { id: "tag_7", name: "Warm Lead", count: 18, color: "#ffc107" },
      { id: "tag_8", name: "Referral Partner", count: 5, color: "#e91e63" },
      { id: "tag_9", name: "Enterprise", count: 3, color: "#673ab7" },
      { id: "tag_10", name: "Patient", count: 7, color: "#009688" },
      { id: "tag_11", name: "Contractor", count: 4, color: "#795548" },
      { id: "tag_12", name: "Recall Due", count: 11, color: "#f44336" },
    ],
  }),
};

// ─── Public API ──────────────────────────────────────────────────────────────

/**
 * Returns demo data for a GHL app by its file name (e.g. "contact-grid").
 * Returns null if no demo data is defined for the given app.
 */
export function getGhlDemoData(appName: string): object | null {
  const generator = demoDataMap[appName];
  return generator ? generator() : null;
}
