/**
 * slides/24-roadmap.js
 * ----------------------------------------------------------------------------
 * Slide 24 -- Roadmap: что ожидать
 */
'use strict';

const { helpers, layouts } = require('../../design-system');

function buildRoadmap(pres, theme) {
  const slide = pres.addSlide();
  helpers.slideBase(slide, pres, theme);
  helpers.addHeader(slide, pres, theme, {
    eyebrow: 'STAGE 4',
    sectionNumber: 4,
    title: 'Roadmap: 2026-2027',
  });

  // Timeline cards
  const items = [
    {
      period: 'Q2 2026',
      title: 'Stable v1',
      points: [
        'deep-agent harness заморожен',
        'API стабилизирован',
        'semver commitment',
      ],
    },
    {
      period: 'Q3 2026',
      title: 'Multi-tenant',
      points: [
        'per-org quota + billing',
        'team-level audit log',
        'rbac на sandbox providers',
      ],
    },
    {
      period: 'Q4 2026',
      title: 'More triggers',
      points: [
        'Jira / Azure DevOps',
        'Sentry для авто-fix багов',
        'PagerDuty для incident triage',
      ],
    },
    {
      period: '2027',
      title: 'SDK + Marketplace',
      points: [
        'public SDK (Python + TS)',
        'plugin marketplace',
        'shared subagent library',
      ],
    },
  ];

  const cardY = layouts.CONTENT_TOP;
  const cardW = 2.2;
  const cardH = 3.5;
  const gap = 0.13;

  items.forEach(function (it, idx) {
    const cx = 0.5 + idx * (cardW + gap);

    slide.addShape(pres.ShapeType.roundRect, {
      x: cx, y: cardY, w: cardW, h: cardH,
      fill: { color: theme.palette.bg.elevated },
      line: { color: theme.palette.accent.primary, width: 1 },
      rectRadius: 0.08,
    });

    // Period header
    slide.addShape(pres.ShapeType.rect, {
      x: cx, y: cardY, w: cardW, h: 0.5,
      fill: { color: theme.palette.accent.primary },
      line: { color: theme.palette.accent.primary, width: 1 },
    });
    slide.addText(it.period, {
      x: cx, y: cardY, w: cardW, h: 0.5,
      fontFace: helpers.withFallback(theme.fonts.ui),
      fontSize: theme.sizes.h3,
      color: theme.palette.text.inverse,
      bold: true,
      align: 'center',
      valign: 'middle',
    });

    // Title
    slide.addText(it.title, {
      x: cx + 0.15, y: cardY + 0.65, w: cardW - 0.3, h: 0.4,
      fontFace: helpers.withFallback(theme.fonts.ui),
      fontSize: theme.sizes.h3,
      color: theme.palette.text.primary,
      bold: true,
    });

    // Divider
    slide.addShape(pres.ShapeType.line, {
      x: cx + 0.15, y: cardY + 1.1, w: cardW - 0.3, h: 0,
      line: { color: theme.palette.border.subtle, width: 0.75 },
    });

    // Bullets
    const bulletItems = it.points.map(function (p) {
      return {
        text: '> ' + p + '\n',
        options: {
          fontFace: helpers.withFallback(theme.fonts.code),
          fontSize: 10,
          color: theme.palette.text.secondary,
        },
      };
    });
    slide.addText(bulletItems, {
      x: cx + 0.15, y: cardY + 1.2, w: cardW - 0.3, h: cardH - 1.3,
      valign: 'top',
      paraSpaceAfter: 4,
    });
  });

  helpers.addPageNumber(slide, pres, theme, 24);
  helpers.addSourceLine(slide, pres, theme, {
    source: 'github.com/langchain-ai/open-swe/issues + blog.langchain.com',
  });
  return slide;
}

module.exports = { buildRoadmap };
