// Mock data + simulated API for the prototype
// In production: replace with axios calls to VITE_API_BASE_URL

const mockTitles = (topic) => {
  const t = topic.trim() || "Selected Market";
  return [
    {
      title: `${t}: Global Outlook & Strategic Forecast 2024–2030`,
      description: "Comprehensive long-range forecast with regional segmentation, demand-side drivers, supply-chain analysis, and competitive intelligence on top 25 players.",
      tag: "Most Comprehensive",
    },
    {
      title: `${t} — Market Size, Share & Growth Trends`,
      description: "Tightly scoped sizing report focused on TAM/SAM/SOM, CAGR by sub-segment, pricing benchmarks, and 12-quarter trend lines.",
      tag: "Sizing-Focused",
    },
    {
      title: `${t}: Technology, Innovation & Patent Landscape`,
      description: "Deep dive on emerging tech, R&D pipelines, patent filings, and roadmaps for the next product generation across major OEMs.",
      tag: "Tech Deep-Dive",
    },
    {
      title: `${t} Competitive Benchmarking & M&A Activity`,
      description: "Player-by-player benchmarking on capacity, margins, geographic reach, and a curated list of recent M&A, partnerships, and JVs.",
      tag: "Competitive",
    },
  ];
};

// Realistic-feeling ToC for a market research report
const mockSections = [
  { num: "1", title: "Executive Summary", est: 8 },
  { num: "1.1", title: "Key Findings", est: 3 },
  { num: "1.2", title: "Strategic Recommendations", est: 4 },
  { num: "2", title: "Market Overview & Scope", est: 12 },
  { num: "2.1", title: "Market Definition", est: 3 },
  { num: "2.2", title: "Research Methodology", est: 4 },
  { num: "2.3", title: "Assumptions & Limitations", est: 2 },
  { num: "2.4", title: "Glossary of Terms", est: 3 },
  { num: "3", title: "Market Dynamics", est: 18 },
  { num: "3.1", title: "Drivers", est: 5 },
  { num: "3.2", title: "Restraints", est: 4 },
  { num: "3.3", title: "Opportunities", est: 5 },
  { num: "3.4", title: "Challenges & Risks", est: 4 },
  { num: "4", title: "Market Segmentation Analysis", est: 28 },
  { num: "4.1", title: "By Chemistry (Li-ion, NiMH, Solid-State)", est: 8 },
  { num: "4.2", title: "By Application", est: 6 },
  { num: "4.3", title: "By Vehicle Type", est: 7 },
  { num: "4.4", title: "By End-User", est: 7 },
  { num: "5", title: "Regional Analysis", est: 36 },
  { num: "5.1", title: "North America", est: 9 },
  { num: "5.2", title: "Europe", est: 9 },
  { num: "5.3", title: "Asia-Pacific", est: 10 },
  { num: "5.4", title: "Latin America", est: 4 },
  { num: "5.5", title: "Middle East & Africa", est: 4 },
  { num: "6", title: "Competitive Landscape", est: 24 },
  { num: "6.1", title: "Market Share Analysis", est: 5 },
  { num: "6.2", title: "Strategic Initiatives & Partnerships", est: 6 },
  { num: "6.3", title: "Recent M&A Activity", est: 5 },
  { num: "6.4", title: "SWOT of Top 10 Players", est: 8 },
  { num: "7", title: "Company Profiles", est: 48 },
  { num: "7.1", title: "CATL", est: 5 },
  { num: "7.2", title: "LG Energy Solution", est: 5 },
  { num: "7.3", title: "Panasonic Energy", est: 5 },
  { num: "7.4", title: "BYD Company", est: 5 },
  { num: "7.5", title: "Samsung SDI", est: 5 },
  { num: "7.6", title: "SK On", est: 5 },
  { num: "7.7", title: "Northvolt", est: 5 },
  { num: "7.8", title: "QuantumScape", est: 4 },
  { num: "7.9", title: "Other Emerging Players", est: 9 },
  { num: "8", title: "Forecast & Outlook 2024–2030", est: 18 },
  { num: "8.1", title: "Revenue Forecast by Segment", est: 6 },
  { num: "8.2", title: "Volume Forecast (GWh)", est: 6 },
  { num: "8.3", title: "Scenario Analysis", est: 6 },
];

const mockTopics = [
  "Global Electric Vehicle Battery Market",
  "Generative AI in Healthcare",
  "Solid-State Battery Technology",
  "Quantum Computing Hardware",
  "Sustainable Aviation Fuel",
  "Vertical Farming Equipment",
];

const pastReports = [
  { id: "rep_9af3", title: "Generative AI in Healthcare", date: "Today", status: "generating", progress: 0.62 },
  { id: "rep_7c12", title: "Vertical Farming Equipment 2024-2030", date: "Yesterday", status: "complete" },
  { id: "rep_5b88", title: "Solid-State Battery Technology Outlook", date: "May 8", status: "complete" },
  { id: "rep_4d22", title: "Quantum Computing Hardware Landscape", date: "May 6", status: "draft" },
  { id: "rep_3a91", title: "Sustainable Aviation Fuel Market", date: "May 2", status: "complete" },
  { id: "rep_2f60", title: "Industrial Robotics in APAC", date: "Apr 28", status: "complete" },
  { id: "rep_1e44", title: "5G Private Networks for Manufacturing", date: "Apr 21", status: "complete" },
  { id: "rep_0c11", title: "Plant-Based Protein Ingredients", date: "Apr 12", status: "complete" },
];

const topicTags = [
  "Market Size", "CAGR", "Regional Splits", "Top Players", "Pricing",
  "M&A Activity", "Patent Trends", "Regulatory Outlook", "Forecasts"
];

// Simulated API
const wait = (ms) => new Promise((r) => setTimeout(r, ms));

const mockApi = {
  async suggestTitles(body) {
    await wait(1600);
    return { titles: mockTitles(body.topic) };
  },
  async confirmTitle(body) {
    await wait(1400);
    return { report_version_id: "v_" + Math.random().toString(36).slice(2, 8), report_id: "r_" + Math.random().toString(36).slice(2, 8) };
  },
  async getSections() {
    await wait(900);
    return { sections: mockSections };
  },
  async startWorkflow() {
    await wait(600);
    return { job_id: "job_" + Math.random().toString(36).slice(2, 8) };
  },
};

window.MOCK = { mockTitles, mockSections, mockTopics, pastReports, topicTags, mockApi };
