/**
 * slides/22-typescript.js
 * ----------------------------------------------------------------------------
 * Slide 22 -- TypeScript analogues: где есть, где нет
 */
'use strict';

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

function buildTypescript(pres, theme) {
  const slide = pres.addSlide();
  helpers.slideBase(slide, pres, theme);
  helpers.addHeader(slide, pres, theme, {
    eyebrow: 'STAGE 4',
    sectionNumber: 4,
    title: 'TypeScript: только UI',
  });

  helpers.addCodeBlock(slide, pres, theme, {
    x: 0.5, y: layouts.CONTENT_TOP, w: 5.6, h: 3.5,
    language: 'typescript',
    code: [
      '// apps/open-swe-ui/src/lib/client.ts',
      'import { OpenSWEClient } from',
      '  "@openswe/client";',
      '',
      'const client = new OpenSWEClient({',
      '  langsmithApiKey: process.env.',
      '    LANGSMITH_API_KEY!,',
      '});',
      '',
      'await client.invoke({',
      '  threadId: "issue-123",',
      '  prompt: "Fix the bug",',
      '});',
    ].join('\n'),
    filePath: 'apps/open-swe-ui/src/lib/client.ts',
    startLine: 1,
  });

  helpers.addProsCons(slide, pres, theme, {
    x: 6.3, y: layouts.CONTENT_TOP, w: 3.2, h: 3.5,
    pros: [
      'UI: полностью TS',
      'TanStack Start + Vite',
      'strict TS config',
      'streaming SDK',
    ],
    cons: [
      'Нет TS для backend',
      'Агент -- Python only',
      'Webhook handlers только Py',
      'SDK -- thin wrapper',
    ],
  });

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

module.exports = { buildTypescript };
