/**
 * slides/23-pros-cons.js
 * ----------------------------------------------------------------------------
 * Slide 23 -- Pros / cons vs Claude Code / Devin
 */
'use strict';

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

function buildProsConsComparison(pres, theme) {
  const slide = pres.addSlide();
  helpers.slideBase(slide, pres, theme);
  helpers.addHeader(slide, pres, theme, {
    eyebrow: 'STAGE 4',
    sectionNumber: 4,
    title: 'Open SWE vs Claude Code / Devin',
  });

  helpers.addProsCons(slide, pres, theme, {
    x: 0.5, y: layouts.CONTENT_TOP, w: 4.4, h: 1.7,
    pros: [
      'MIT license, форкайте',
      'Pluggable sandbox',
      'Triggers: Slack/Linear/GH',
      'AGENTS.md convention',
      'Subagents + middleware',
      'Built on Deep Agents',
    ],
    cons: [
      'Не finished product',
      'Sandbox = платные аккаунты',
      'OAuth setup нужен',
      '"Trust the LLM" модель',
      'Prod deployment сложный',
      'Доки быстро устаревают',
    ],
  });

  // Comparison card on the right
  slide.addShape(pres.ShapeType.roundRect, {
    x: 5.1, y: layouts.CONTENT_TOP, w: 4.4, h: 3.5,
    fill: { color: theme.palette.bg.elevated },
    line: { color: theme.palette.border.subtle, width: 1 },
    rectRadius: 0.08,
  });

  slide.addText('VS Claude Code / Devin', {
    x: 5.3, y: layouts.CONTENT_TOP + 0.1, w: 4.0, h: 0.3,
    fontFace: helpers.withFallback(theme.fonts.ui),
    fontSize: theme.sizes.h3,
    color: theme.palette.accent.secondary,
    bold: true,
  });

  const compareRows = [
    ['Audience',   'IDE',         'SaaS',     'org'],
    ['License',    'proprietary', 'proprietary','MIT'],
    ['Trigger',    'manual',      'Web UI',   'Slack/Lin/GH'],
    ['Sandbox',    'local+cloud', 'remote',   'pluggable'],
    ['Customize',  'config',      'no',       'full src'],
    ['Runs in',    'IDE/term',    'cloud',    'your infra'],
  ];

  const tY = layouts.CONTENT_TOP + 0.55;
  compareRows.forEach(function (row, idx) {
    const ry = tY + idx * 0.45;
    row.forEach(function (cell, cidx) {
      const widths = [1.1, 1.0, 1.0, 1.1];
      let cx = 5.3;
      for (let i = 0; i < cidx; i++) cx += widths[i] + 0.05;
      slide.addText(cell, {
        x: cx, y: ry, w: widths[cidx], h: 0.4,
        fontFace: helpers.withFallback(
          cidx === 0 ? theme.fonts.ui : theme.fonts.code),
        fontSize: cidx === 0 ? theme.sizes.caption : 8,
        color: cidx === 3
          ? theme.palette.accent.tertiary
          : theme.palette.text.secondary,
        bold: cidx === 0,
        valign: 'middle',
      });
    });
  });

  helpers.addPageNumber(slide, pres, theme, 23);
  helpers.addSourceLine(slide, pres, theme, {
    source: 'research/per-tech/openswe.md: 291-310',
  });
  return slide;
}

module.exports = { buildProsConsComparison };
