/**
 * slides/17-per-user-settings.js
 * ----------------------------------------------------------------------------
 * Slide 17 -- Per-user settings + team defaults + repos
 */
'use strict';

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

function buildPerUserSettings(pres, theme) {
  const slide = pres.addSlide();
  helpers.slideBase(slide, pres, theme);
  helpers.addHeader(slide, pres, theme, {
    eyebrow: 'STAGE 4',
    sectionNumber: 4,
    title: 'Per-user настройки',
  });

  helpers.addCodeBlock(slide, pres, theme, {
    x: 0.5, y: layouts.CONTENT_TOP, w: 5.6, h: 3.5,
    language: 'python',
    code: [
      '# settings schema (per-user)',
      'USER_DEFAULTS = {',
      '    "model": "anthropic:claude-opus-4-6",',
      '    "profile": "balanced",',
      '    "max_steps": 80,',
      '    "auto_open_pr": False,',
      '    "require_approval": True,',
      '    "extra_repos": ["acme/internal-tools"],',
      '}',
      '',
      '# team defaults (allowlist)',
      'TEAM_DEFAULTS = {',
      '    "sandbox_backend": "ModalBackend",',
      '    "allowed_repos": ["acme/*"],',
      '}',
    ].join('\n'),
    filePath: 'open_swe/settings.py',
    startLine: 1,
    highlightLines: [3, 4, 5, 6, 7, 11, 12],
  });

  helpers.addCallout(slide, pres, theme, {
    x: 6.3, y: layouts.CONTENT_TOP, w: 3.2, h: 1.55,
    kind: 'info',
    title: 'User mappings',
    text:
      'GitHub login -> Slack user -> ' +
      'Linear user. Один человек ' +
      'получает свой профиль во ' +
      'всех трех каналах.',
  });

  helpers.addCallout(slide, pres, theme, {
    x: 6.3, y: 2.95, w: 3.2, h: 1.9,
    kind: 'warning',
    title: 'Precedence',
    text:
      'user > team > global. Per-user ' +
      'override работает для всех ' +
      'полей, кроме allowed_repos ' +
      '-- это team-level allowlist.',
  });

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

module.exports = { buildPerUserSettings };
