[{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/analysis-aggregator.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/article-generator.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":174,"column":17,"endLine":174,"endColumn":24}],"suppressedMessages":[{"ruleId":"no-fallthrough","severity":2,"message":"Expected a 'break' statement before 'default'.","line":268,"column":5,"messageId":"default","endLine":269,"endColumn":52,"suppressions":[{"kind":"directive","justification":""}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Aggregator/ArticleGenerator\n * @description CLI entry point for the analysis-artifact-driven article\n * pipeline. Given a run directory under `analysis/daily/`, it aggregates\n * every artifact into a canonical Markdown document, renders it to HTML,\n * and writes one HTML variant per language (plus the English source\n * Markdown).\n *\n * Usage:\n *   npm run generate-article -- --run analysis/daily/2026-01-15/breaking-run1\n *   npm run generate-article -- --run ... --lang en --lang sv\n *   npm run generate-article -- --run ... --out-dir news --title \"Headline\"\n *\n * Designed to be idempotent: running again with no changes overwrites\n * identical files byte-for-byte.\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport {\n  aggregateAnalysisRun,\n  resolveArticleTypeFromManifest,\n  type AggregatedRun,\n  type AnalysisManifest,\n} from './analysis-aggregator.js';\nimport {\n  resolveArticleMetadata,\n  extractStrongProseLine,\n  type MetadataManifest,\n  type ResolvedMetadata,\n} from './article-metadata.js';\nimport { renderMarkdown } from './markdown-renderer.js';\nimport { wrapArticleHtml, getArticleFilename } from './article-html.js';\nimport { ALL_LANGUAGES } from '../constants/language-core.js';\nimport type { LanguageCode } from '../types/index.js';\nimport { blobUrl } from './infra/github-urls.js';\nimport {\n  buildArticleSlug as _buildArticleSlug,\n  sanitizeRunSuffix as _sanitizeRunSuffix,\n} from './slug/index.js';\nimport {\n  discoverAnalysisRuns as _discoverAnalysisRuns,\n  groupRunsForCollision as _groupRunsForCollision,\n  type DiscoveredRun as _DiscoveredRun,\n} from './runs/index.js';\n\n/** Parsed CLI arguments. */\nexport interface CliOptions {\n  /**\n   * Absolute path to a single analysis run directory, or `null` when\n   * operating in `--all` mode (batch over every discovered run).\n   */\n  readonly runDir: string | null;\n  /**\n   * Batch mode: when `true`, walk `analysis/daily/**\\/manifest.json` and\n   * render every run that has a valid `articleType` in its manifest.\n   */\n  readonly all: boolean;\n  /**\n   * Optional lower bound (inclusive) on the `YYYY-MM-DD` run date when\n   * `all === true`. Runs whose manifest `date` (or directory-derived date)\n   * is earlier are skipped.\n   */\n  readonly since?: string;\n  /** Languages to render (defaults to all 14). */\n  readonly langs: readonly LanguageCode[];\n  /** Output directory for HTML files (defaults to `news/`). */\n  readonly outDir: string;\n  /** Repo root used for relative path computation. */\n  readonly repoRoot: string;\n  /** Optional: override the auto-derived article title (single-run only). */\n  readonly title?: string;\n  /** Optional: override the auto-derived article description (single-run only). */\n  readonly description?: string;\n  /**\n   * When true, only the source Markdown is written (no HTML) — useful for\n   * upstream pipelines that translate first and then batch-render.\n   */\n  readonly markdownOnly: boolean;\n}\n\n/** Result summary returned by {@link generateArticle}. */\nexport interface GenerateResult {\n  /** Repo-relative path of the English source Markdown that was written. */\n  readonly sourceMarkdownRelPath: string;\n  /**\n   * Repo-relative path of the `article.md` written directly into the\n   * analysis run directory — canonical Markdown source that lives alongside\n   * the artifacts that produced it (riksdagsmonitor pattern).\n   */\n  readonly runArticleMdRelPath: string;\n  /** Filenames written under `outDir`, relative to `outDir`. */\n  readonly writtenFiles: readonly string[];\n  /** Metadata from {@link aggregateAnalysisRun}. */\n  readonly aggregated: AggregatedRun;\n}\n\n/**\n * Parse a flat list of CLI args (no node/script entries) into {@link CliOptions}.\n * Supports `--flag value` and `--flag=value` styles, and repeatable `--lang`.\n *\n * @param argv - Argument list, typically `process.argv.slice(2)`\n * @param repoRoot - Absolute repo root used to resolve default output paths\n * @returns Fully-populated {@link CliOptions} ready for {@link generateArticle}\n */\n/** Mutable accumulator backing {@link parseCliArgs}. */\ninterface CliParseAccumulator {\n  runDir: string | null;\n  all: boolean;\n  since?: string;\n  langs: LanguageCode[];\n  outDir: string;\n  title?: string;\n  description?: string;\n  markdownOnly: boolean;\n}\n\n/**\n * Fold one parsed {@link FlagResult} into the accumulator. Split out so\n * {@link parseCliArgs} stays under the cognitive-complexity budget.\n *\n * @param acc - Mutable accumulator\n * @param result - Parsed flag result\n */\nfunction applyFlagResult(acc: CliParseAccumulator, result: FlagResult): void {\n  switch (result.kind) {\n    case 'runDir':\n      acc.runDir = result.value;\n      return;\n    case 'all':\n      acc.all = true;\n      return;\n    case 'since':\n      acc.since = result.value;\n      return;\n    case 'lang':\n      acc.langs.push(result.value);\n      return;\n    case 'outDir':\n      acc.outDir = result.value;\n      return;\n    case 'title':\n      acc.title = result.value;\n      return;\n    case 'description':\n      acc.description = result.value;\n      return;\n    case 'markdownOnly':\n      acc.markdownOnly = true;\n      return;\n    default: {\n      // Exhaustiveness guard — if a new FlagResult kind is added without a\n      // matching case the compiler will surface the gap.\n      const exhaustive: never = result;\n      throw new Error(`Unhandled flag result: ${JSON.stringify(exhaustive)}`);\n    }\n  }\n}\n\nexport function parseCliArgs(argv: readonly string[], repoRoot: string): CliOptions {\n  const acc: CliParseAccumulator = {\n    runDir: null,\n    all: false,\n    langs: [],\n    outDir: path.join(repoRoot, 'news'),\n    markdownOnly: false,\n  };\n\n  for (let i = 0; i < argv.length; i++) {\n    const arg = argv[i] ?? '';\n    const [flag, inlineValue] = arg.includes('=') ? splitFlag(arg) : [arg, undefined];\n    const takeValue = (): string => {\n      if (inlineValue !== undefined) return inlineValue;\n      const next = argv[i + 1];\n      if (next === undefined) {\n        throw new Error(`Missing value for ${flag}`);\n      }\n      i++;\n      return next;\n    };\n    applyFlagResult(acc, applyCliFlag(flag, takeValue));\n  }\n  if (!acc.all) {\n    if (!acc.runDir) {\n      throw new Error('--run <path> or --all is required');\n    }\n    if (!fs.existsSync(acc.runDir)) {\n      throw new Error(`Run directory does not exist: ${acc.runDir}`);\n    }\n  }\n  const opts: CliOptions = {\n    runDir: acc.runDir,\n    all: acc.all,\n    langs: acc.langs.length > 0 ? acc.langs : [...ALL_LANGUAGES],\n    outDir: acc.outDir,\n    repoRoot,\n    markdownOnly: acc.markdownOnly,\n    ...(acc.since !== undefined ? { since: acc.since } : {}),\n    ...(acc.title !== undefined ? { title: acc.title } : {}),\n    ...(acc.description !== undefined ? { description: acc.description } : {}),\n  };\n  return opts;\n}\n\n/**\n * Result of applying a single CLI flag. Each kind corresponds to one of\n * the accumulator variables in {@link parseCliArgs}. Extracted so the main\n * parser stays under the cognitive-complexity budget.\n */\ntype FlagResult =\n  | { kind: 'runDir'; value: string }\n  | { kind: 'all' }\n  | { kind: 'since'; value: string }\n  | { kind: 'lang'; value: LanguageCode }\n  | { kind: 'outDir'; value: string }\n  | { kind: 'title'; value: string }\n  | { kind: 'description'; value: string }\n  | { kind: 'markdownOnly' };\n\n/**\n * Resolve one CLI flag to a {@link FlagResult}. Throws `Error` for any\n * unsupported flag or language code.\n *\n * @param flag - Flag name (e.g. `--run`)\n * @param takeValue - Lazily returns the value argument for value-bearing flags\n * @returns Parsed {@link FlagResult}\n */\nfunction applyCliFlag(flag: string, takeValue: () => string): FlagResult {\n  switch (flag) {\n    case '--run':\n    case '--analysis-dir':\n      return { kind: 'runDir', value: path.resolve(takeValue()) };\n    case '--all':\n      return { kind: 'all' };\n    case '--since': {\n      const value = takeValue();\n      if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) {\n        throw new Error(`--since expects a YYYY-MM-DD date, got: ${value}`);\n      }\n      return { kind: 'since', value };\n    }\n    case '--lang':\n    case '--language': {\n      const value = takeValue();\n      if (!ALL_LANGUAGES.includes(value as LanguageCode)) {\n        throw new Error(`Unsupported language code: ${value}`);\n      }\n      return { kind: 'lang', value: value as LanguageCode };\n    }\n    case '--out-dir':\n    case '--output':\n      return { kind: 'outDir', value: path.resolve(takeValue()) };\n    case '--title':\n      return { kind: 'title', value: takeValue() };\n    case '--description':\n      return { kind: 'description', value: takeValue() };\n    case '--markdown-only':\n      return { kind: 'markdownOnly' };\n    case '--help':\n    case '-h':\n      printHelp();\n      process.exit(0);\n    // eslint-disable-next-line no-fallthrough\n    default:\n      throw new Error(`Unknown argument: ${flag}`);\n  }\n}\n\n/**\n * Split `--flag=value` into `[\"--flag\", \"value\"]`.\n *\n * @param arg - Raw argument in `--flag=value` form\n * @returns Tuple of `[flag, value]`\n */\nfunction splitFlag(arg: string): [string, string] {\n  const eq = arg.indexOf('=');\n  return [arg.slice(0, eq), arg.slice(eq + 1)];\n}\n\n/**\n * Print CLI help text to stdout.\n */\nfunction printHelp(): void {\n  process.stdout.write(\n    [\n      'Usage:',\n      '  generate-article --run <path> [options]',\n      '  generate-article --all [--since YYYY-MM-DD] [options]',\n      '',\n      'Aggregate analysis artifacts from an `analysis/daily/**/<run>` directory',\n      'into a canonical Markdown document and render it to HTML in all 14',\n      'languages. The `--all` form walks every run under `analysis/daily/`',\n      'and regenerates the full historic catalogue in one pass.',\n      '',\n      'Options:',\n      '  --run <path>          Analysis run directory (single-run mode)',\n      '  --all                 Batch-regenerate every run under analysis/daily/',\n      '  --since YYYY-MM-DD    With --all: skip runs dated before this cut-off',\n      '  --lang <code>         Language to render (repeatable; default: all 14)',\n      '  --out-dir <path>      Output directory (default: news/)',\n      '  --title <text>        Override article title (single-run only)',\n      '  --description <text>  Override article meta description (single-run only)',\n      '  --markdown-only       Write only the source .md (skip HTML)',\n      '  --help, -h            Show this help',\n      '',\n    ].join('\\n')\n  );\n}\n\n/**\n * Build the article slug `YYYY-MM-DD-<article-type>[-<runSuffix>]`.\n *\n * Thin re-export of the canonical implementation in\n * `aggregator/slug/index.js` preserved here for back-compat with the\n * existing test suite.\n *\n * @param date - ISO date string (`YYYY-MM-DD`)\n * @param articleType - Article-type slug (e.g. `breaking`)\n * @param runSuffix - Optional collision-suffix (e.g. `run191`)\n * @returns Combined slug used as the file-stem for every language variant\n */\nexport function buildArticleSlug(date: string, articleType: string, runSuffix?: string): string {\n  return _buildArticleSlug(date, articleType, runSuffix);\n}\n\n/**\n * Turn an arbitrary run-id string into a short, filename-safe suffix.\n *\n * Thin re-export of the canonical implementation in\n * `aggregator/slug/index.js`.\n *\n * @param runId - Raw run identifier from the manifest (or directory name)\n * @returns Sanitised suffix usable in a filename\n */\nexport function sanitizeRunSuffix(runId: string): string {\n  return _sanitizeRunSuffix(runId);\n}\n\n/**\n * Return `true` when a line should be skipped when hunting for the default\n * description. Thin wrapper preserved for back-compat — real logic lives\n * in `src/aggregator/article-metadata.ts`'s `shouldSkipDescriptionLine`.\n *\n * @param line - Trimmed line from the aggregated Markdown source\n * @returns `true` when the line is not prose and should be skipped\n */\nfunction shouldSkipDescriptionLine(line: string): boolean {\n  if (line.length === 0) return true;\n  if (line.startsWith('#')) return true;\n  if (line.startsWith('>')) return true;\n  if (line.startsWith('<')) return true;\n  if (line.startsWith('|')) return true;\n  return false;\n}\n\n/** Description used when no prose paragraph qualifies. */\nconst FALLBACK_DESCRIPTION =\n  'EU Parliament intelligence summary derived from committed analysis artifacts.';\n\n/**\n * Extract a short description from the first prose paragraph of the\n * aggregated Markdown — used as the default `<meta name=\"description\">`.\n * Uses the stricter `extractStrongProseLine` filter from\n * `article-metadata.ts` so mermaid `%%{init}` blocks, `title …` directives,\n * emoji-banner metadata rows, and `Analysis Date:` / `Run:` / `Window:`\n * style banners no longer leak into `<meta description>`. Kept as an\n * exported thin wrapper for back-compat with the existing test suite.\n *\n * @param markdown - Aggregated Markdown document\n * @returns Plain-text description, truncated to ≤300 characters\n */\nexport function extractDefaultDescription(markdown: string): string {\n  // Suppress unused warning: keep `shouldSkipDescriptionLine` for any\n  // legacy consumer importing it transitively.\n  void shouldSkipDescriptionLine;\n  const strong = extractStrongProseLine(markdown);\n  return strong.length > 0 ? strong : FALLBACK_DESCRIPTION;\n}\n\n/**\n * Escape a string for a conservative double-quoted YAML scalar.\n *\n * @param value - Raw metadata value\n * @returns YAML-safe quoted string content (without surrounding quotes)\n */\nfunction yamlEscape(value: string): string {\n  return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"').replace(/\\r?\\n/g, ' ');\n}\n\n/**\n * Build the Jekyll-compatible Markdown source committed as `article.md`.\n * The renderer strips this front matter before HTML conversion, while the\n * source file stays portable to Jekyll/GitHub Pages and aligned with the\n * Riksdagsmonitor article contract.\n *\n * @param aggregated - Aggregated analysis body and run metadata\n * @param metadata - English metadata resolved for SEO\n * @param metadata.title - Resolved English article title\n * @param metadata.description - Resolved English article description\n * @param slug - Article slug used by generated news paths\n * @param sourceFolder - Repo-relative analysis run directory\n * @returns Markdown with YAML front matter followed by the aggregate body\n */\nfunction buildJekyllArticleMarkdown(\n  aggregated: AggregatedRun,\n  metadata: { readonly title: string; readonly description: string },\n  slug: string,\n  sourceFolder: string\n): string {\n  const frontMatter = [\n    '---',\n    `title: \"${yamlEscape(metadata.title)}\"`,\n    `description: \"${yamlEscape(metadata.description)}\"`,\n    `date: ${aggregated.date}`,\n    `article_type: ${aggregated.articleType}`,\n    `slug: ${slug}`,\n    `source_folder: ${sourceFolder}`,\n    `generated_at: ${aggregated.date}T00:00:00.000Z`,\n    'language: en',\n    'layout: article',\n    '---',\n    '',\n  ].join('\\n');\n  return `${frontMatter}${aggregated.markdown}`;\n}\n\n/**\n * Render a single language-variant article. Pulls from a pre-translated\n * `<slug>.<lang>.md` file when it exists, otherwise renders the English\n * aggregate. Extracted from {@link generateArticle} so the outer function\n * stays under the cognitive-complexity budget.\n *\n * @param lang - Target language code\n * @param slug - Article slug (`<date>-<type>`)\n * @param aggregated - Aggregated-run metadata\n * @param englishHtml - Pre-rendered HTML of the English aggregate\n * @param chromeOptions - Shared chrome options\n * @param chromeOptions.metadata - Per-language `{title, description}` map\n *        resolved by {@link resolveArticleMetadata}\n * @param chromeOptions.sourceMarkdownRelPath - Repo-relative path of the\n *        canonical English Markdown source written by the same run\n * @param chromeOptions.articleCount - Total article count surfaced in the\n *        site footer's `<p class=\"footer-stats\">…</p>` line\n * @param opts - CLI options (needed for `outDir`)\n * @returns Relative filename of the HTML file written\n */\nfunction writeLanguageVariant(\n  lang: LanguageCode,\n  slug: string,\n  aggregated: AggregatedRun,\n  englishHtml: string,\n  chromeOptions: {\n    metadata: ResolvedMetadata;\n    sourceMarkdownRelPath: string;\n    articleCount: number;\n  },\n  opts: CliOptions\n): string {\n  const langMdFilename = `${slug}.${lang}.md`;\n  const langMdAbs = path.join(opts.outDir, langMdFilename);\n  let bodyHtml = englishHtml;\n  let metaSource = aggregated.markdown;\n  if (lang !== 'en' && fs.existsSync(langMdAbs)) {\n    metaSource = fs.readFileSync(langMdAbs, 'utf8');\n    bodyHtml = renderMarkdown(metaSource).html;\n  }\n  // When a per-language translated source exists, prefer a summary derived\n  // from it so the `<meta description>` matches the visible prose. The\n  // editorial title still comes from the English resolver (per-language\n  // translations of the headline are a future enhancement tracked as\n  // out-of-scope).\n  const entry = getMetadataEntry(chromeOptions.metadata, lang);\n  const perLangDescription =\n    lang !== 'en' && metaSource !== aggregated.markdown\n      ? extractStrongProseLine(metaSource) || entry.description\n      : entry.description;\n  const html = wrapArticleHtml({\n    lang,\n    articleSlug: slug,\n    body: bodyHtml,\n    title: entry.title,\n    description: perLangDescription,\n    date: aggregated.date,\n    articleType: aggregated.articleType,\n    sourceMarkdownRelPath: chromeOptions.sourceMarkdownRelPath,\n    toc: aggregated.sectionToc,\n    articleCount: chromeOptions.articleCount,\n    isBasedOn: aggregated.includedArtifacts.map((a) => blobUrl(a.repoRelPath)),\n  });\n  const filename = getArticleFilename(slug, lang);\n  fs.writeFileSync(path.join(opts.outDir, filename), html, 'utf8');\n  return filename;\n}\n\n/**\n * Safely look up one language entry in a {@link ResolvedMetadata} map.\n * The runtime shape is always complete (one entry per language), but the\n * access goes via `Object.getOwnPropertyDescriptor` to satisfy ESLint's\n * `security/detect-object-injection` rule.\n *\n * @param map - Resolved per-language metadata\n * @param lang - Target language code\n * @returns The entry for `lang` (always populated by\n *          {@link resolveArticleMetadata})\n */\nfunction getMetadataEntry(\n  map: ResolvedMetadata,\n  lang: LanguageCode\n): { readonly title: string; readonly description: string } {\n  const descriptor = Object.getOwnPropertyDescriptor(map, lang);\n  if (descriptor?.value) {\n    return descriptor.value as { readonly title: string; readonly description: string };\n  }\n  const en = Object.getOwnPropertyDescriptor(map, 'en')?.value as\n    | { readonly title: string; readonly description: string }\n    | undefined;\n  return en ?? { title: '', description: '' };\n}\n\n/**\n * Count the number of articles the site currently publishes, derived\n * from `analysis/daily/**` runs with a valid `articleType` — the same\n * set that `npm run generate-article:all` would materialise. Using the\n * analysis-run catalogue (rather than the `<outDir>` filesystem) keeps\n * the derived count stable across repeated invocations of\n * {@link generateArticle}, preserving determinism for reproducible-build\n * tests and preventing the footer from drifting as a batch run\n * progresses.\n *\n * @param repoRoot - Absolute path to the repository root\n * @returns Non-negative article count (zero when the analysis tree is empty)\n */\nfunction countPublishedArticles(repoRoot: string): number {\n  try {\n    return discoverAnalysisRuns(repoRoot).length;\n  } catch {\n    return 0;\n  }\n}\n\n/**\n * Run the full aggregate → render → write pipeline for one run.\n *\n * @param opts - Fully-populated {@link CliOptions} (typically from\n *               {@link parseCliArgs}) — must have a non-null `runDir`\n * @param runSuffix - Optional collision-suffix appended to the slug when\n *        multiple runs share the same (date, articleType) pair in batch mode\n * @param articleCountOverride - Optional total article count to surface in\n *        the footer's `<p class=\"footer-stats\">…</p>`. When omitted the\n *        count is derived from `<outDir>/*-en.html` — accurate for single\n *        runs but misleading mid-batch, so {@link generateAllArticles}\n *        passes the final total here.\n * @returns Summary of the generated artefacts ({@link GenerateResult})\n */\nexport function generateArticle(\n  opts: CliOptions,\n  runSuffix?: string,\n  articleCountOverride?: number\n): GenerateResult {\n  if (!opts.runDir) {\n    throw new Error('generateArticle: runDir is required');\n  }\n  const aggregated = aggregateAnalysisRun({\n    runDir: opts.runDir,\n    repoRoot: opts.repoRoot,\n  });\n  const slug = buildArticleSlug(aggregated.date, aggregated.articleType, runSuffix);\n\n  // Resolve per-language {title, description} from the real article\n  // content (manifest override → artefact H1 → aggregated H1 → strong\n  // prose → localized template). This replaces the previous\n  // `defaultTitle()` + `extractDefaultDescription()` approach which\n  // produced boring, repeated metadata.\n  const manifestMetadata = readManifestMetadata(opts.runDir);\n  const resolvedMetadata = resolveArticleMetadata({\n    articleType: aggregated.articleType,\n    date: aggregated.date,\n    markdown: aggregated.markdown,\n    manifest: manifestMetadata,\n    runDir: opts.runDir,\n  });\n\n  // CLI `--title` / `--description` overrides still win over everything\n  // (used by ad-hoc curator runs and by the existing test suite).\n  const effectiveMetadata: ResolvedMetadata =\n    opts.title || opts.description\n      ? applyCliOverrides(resolvedMetadata, opts.title, opts.description)\n      : resolvedMetadata;\n  const runDirRelPath = path.relative(opts.repoRoot, opts.runDir).split(path.sep).join('/');\n  const sourceMarkdown = buildJekyllArticleMarkdown(\n    aggregated,\n    getMetadataEntry(effectiveMetadata, 'en'),\n    slug,\n    runDirRelPath\n  );\n\n  // Write article.md INTO the analysis run directory — canonical Markdown\n  // source that lives alongside the artifacts that produced it.\n  // This mirrors the riksdagsmonitor pattern where `article.md` is committed\n  // inside `analysis/daily/<date>/<type>/` so every run has a browsable,\n  // version-controlled Markdown source in its own directory.\n  const runArticleMdAbs = path.join(opts.runDir, 'article.md');\n  fs.writeFileSync(runArticleMdAbs, sourceMarkdown, 'utf8');\n  const runArticleMdRelPath = path\n    .relative(opts.repoRoot, runArticleMdAbs)\n    .split(path.sep)\n    .join('/');\n\n  // Also write source Markdown under <outDir>/<slug>.en.md for search\n  // indexing and backwards compatibility with existing news-index scripts.\n  ensureDir(opts.outDir);\n  const sourceMdFilename = `${slug}.en.md`;\n  const sourceMdAbs = path.join(opts.outDir, sourceMdFilename);\n  fs.writeFileSync(sourceMdAbs, sourceMarkdown, 'utf8');\n\n  const written: string[] = [sourceMdFilename];\n  if (!opts.markdownOnly) {\n    const rendered = renderMarkdown(sourceMarkdown);\n    const chromeOptions = {\n      metadata: effectiveMetadata,\n      // Point the \"View source Markdown\" link at the canonical run-directory\n      // article.md so readers can trace the HTML back to the analysis tree.\n      sourceMarkdownRelPath: runArticleMdRelPath,\n      articleCount: articleCountOverride ?? countPublishedArticles(opts.repoRoot),\n    };\n    for (const lang of opts.langs) {\n      const filename = writeLanguageVariant(\n        lang,\n        slug,\n        aggregated,\n        rendered.html,\n        chromeOptions,\n        opts\n      );\n      written.push(filename);\n    }\n  }\n  return {\n    sourceMarkdownRelPath: runArticleMdRelPath,\n    runArticleMdRelPath,\n    writtenFiles: written,\n    aggregated,\n  };\n}\n\n/** Candidate run discovered under `analysis/daily/`. */\n/**\n * One run discovered by {@link discoverAnalysisRuns}.\n *\n * @deprecated Re-exported from `aggregator/runs/index.js` for back-compat.\n */\nexport type DiscoveredRun = _DiscoveredRun;\n\n/**\n * Walk `analysis/daily/` recursively and return every subdirectory that\n * contains a `manifest.json` with a non-empty, non-`unknown` `articleType`.\n *\n * Thin re-export of {@link _discoverAnalysisRuns} from\n * `aggregator/runs/index.js`.\n *\n * @param repoRoot - Absolute repository root\n * @returns Sorted list of discovered runs (oldest date first, then lexical)\n */\nexport function discoverAnalysisRuns(repoRoot: string): DiscoveredRun[] {\n  return _discoverAnalysisRuns(repoRoot);\n}\n\n/**\n * Group discovered runs by `(date, articleType)` so callers can decide\n * whether a collision-suffix is needed when writing articles.\n *\n * Thin re-export of {@link _groupRunsForCollision} from\n * `aggregator/runs/index.js`.\n *\n * @param runs - Discovered runs\n * @returns Map from `\"<date>|<articleType>\"` to the runs in that group\n */\nexport function groupRunsForCollision(\n  runs: readonly DiscoveredRun[]\n): Map<string, DiscoveredRun[]> {\n  return _groupRunsForCollision(runs);\n}\n\n/**\n * Batch-generate articles for every discovered run. Runs that share a\n * `(date, articleType)` pair are disambiguated by appending the sanitised\n * `runId` as a slug suffix so none of the language variants are ever\n * silently overwritten.\n *\n * @param opts - CLI options (must have `all: true`)\n * @returns Per-run generation results in the order they were processed\n */\nexport function generateAllArticles(opts: CliOptions): GenerateResult[] {\n  const allRuns = discoverAnalysisRuns(opts.repoRoot);\n  const filtered = opts.since ? allRuns.filter((r) => r.date >= (opts.since as string)) : allRuns;\n  const groups = groupRunsForCollision(filtered);\n  const results: GenerateResult[] = [];\n  // Pre-compute the total article count so every footer in the batch\n  // surfaces a stable number rather than the directory size at the moment\n  // each run is rendered (which would grow from 0 → N during the batch).\n  const articleCountOverride = filtered.length;\n  for (const run of filtered) {\n    const key = `${run.date}|${run.articleType}`;\n    const bucket = groups.get(key) ?? [];\n    const suffix = bucket.length > 1 ? sanitizeRunSuffix(run.runId) : undefined;\n    const runOpts: CliOptions = { ...opts, runDir: run.runDir };\n    results.push(generateArticle(runOpts, suffix, articleCountOverride));\n  }\n  return results;\n}\n\n/**\n * Read the raw manifest.json from a run directory and return the subset\n * of fields consumed by {@link resolveArticleMetadata}. Returns an empty\n * object when the manifest is missing or unreadable so the resolver\n * simply falls through to the artefact / aggregator tiers.\n *\n * @param runDir - Absolute run directory path\n * @returns Metadata-relevant manifest fields (never `undefined`)\n */\nfunction readManifestMetadata(runDir: string): MetadataManifest {\n  const manifestPath = path.join(runDir, 'manifest.json');\n  if (!fs.existsSync(manifestPath)) return {};\n  try {\n    const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;\n    const manifest: MetadataManifest = {};\n    const resolvedType = resolveArticleTypeFromManifest(parsed as unknown as AnalysisManifest);\n    if (resolvedType && resolvedType !== 'unknown') {\n      Object.assign(manifest, { articleType: resolvedType });\n    }\n    if (typeof parsed.date === 'string') {\n      Object.assign(manifest, { date: parsed.date });\n    }\n    if (typeof parsed.runId === 'string') {\n      Object.assign(manifest, { runId: parsed.runId });\n    }\n    if (typeof parsed.title === 'string' || isLanguageMapLike(parsed.title)) {\n      Object.assign(manifest, { title: parsed.title });\n    }\n    if (typeof parsed.description === 'string' || isLanguageMapLike(parsed.description)) {\n      Object.assign(manifest, { description: parsed.description });\n    }\n    if (typeof parsed.committee === 'string') {\n      Object.assign(manifest, { committee: parsed.committee });\n    }\n    return manifest;\n  } catch {\n    return {};\n  }\n}\n\n/**\n * Shallow-check that a value looks like a `LanguageMap<string>` without\n * pulling in the full `LanguageCode` list at the runtime import site.\n *\n * @param value - Arbitrary JSON value\n * @returns `true` when `value` is a plain object with string values\n */\nfunction isLanguageMapLike(value: unknown): value is Record<string, string> {\n  if (!value || typeof value !== 'object' || Array.isArray(value)) return false;\n  for (const entry of Object.values(value as Record<string, unknown>)) {\n    if (typeof entry !== 'string') return false;\n  }\n  return true;\n}\n\n/**\n * Apply ad-hoc CLI `--title` / `--description` overrides on top of the\n * resolver output. Overrides are applied to every language so the operator\n * can hand-author a single headline for a one-off run without having to\n * know which language variant they're working in.\n *\n * @param base - Resolver output\n * @param titleOverride - CLI `--title` value, if any\n * @param descriptionOverride - CLI `--description` value, if any\n * @returns Metadata with overrides applied uniformly across languages\n */\nfunction applyCliOverrides(\n  base: ResolvedMetadata,\n  titleOverride: string | undefined,\n  descriptionOverride: string | undefined\n): ResolvedMetadata {\n  const result: Record<LanguageCode, { readonly title: string; readonly description: string }> =\n    Object.create(null) as Record<\n      LanguageCode,\n      { readonly title: string; readonly description: string }\n    >;\n  for (const lang of ALL_LANGUAGES) {\n    const entry = getMetadataEntry(base, lang);\n    Object.defineProperty(result, lang, {\n      value: {\n        title: titleOverride ?? entry.title,\n        description: descriptionOverride ?? entry.description,\n      },\n      enumerable: true,\n      writable: true,\n      configurable: true,\n    });\n  }\n  return result;\n}\n\n/**\n * Derive a default article title from the aggregated run metadata.\n * Preserved as a thin back-compat wrapper — production callers now go\n * through {@link resolveArticleMetadata}.\n *\n * @param run - Aggregated run metadata\n * @returns Human-readable title like `EU Parliament Breaking — 2026-01-15`\n */\nfunction defaultTitle(run: AggregatedRun): string {\n  const typeLabel = run.articleType\n    .split(/[-_]/g)\n    .map((seg) => (seg ? seg.charAt(0).toUpperCase() + seg.slice(1) : seg))\n    .join(' ')\n    .trim();\n  return `EU Parliament ${typeLabel || 'Intelligence'} — ${run.date}`;\n}\n\n// Retain the back-compat export even though the in-module callers no\n// longer invoke it — some downstream curators import it via the bundled\n// `scripts/` output. The `void` reference keeps ESLint's\n// `no-unused-vars` happy without an explicit export.\nvoid defaultTitle;\n\n/**\n * Create `dir` recursively if it doesn't already exist.\n *\n * @param dir - Absolute directory path to ensure\n */\nfunction ensureDir(dir: string): void {\n  if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });\n}\n\n/**\n * Main entry when invoked as a script. Uses `process.argv.slice(2)` and the\n * current working directory as repo root unless overridden by `REPO_ROOT`.\n *\n * @param argv - Argument list (defaults to `process.argv.slice(2)`)\n */\nexport async function main(argv: readonly string[] = process.argv.slice(2)): Promise<void> {\n  const repoRoot = process.env.REPO_ROOT ? path.resolve(process.env.REPO_ROOT) : process.cwd();\n  const opts = parseCliArgs(argv, repoRoot);\n  if (opts.all) {\n    const results = generateAllArticles(opts);\n    let totalFiles = 0;\n    let totalArtifacts = 0;\n    for (const r of results) {\n      totalFiles += r.writtenFiles.length;\n      totalArtifacts += r.aggregated.includedArtifacts.length;\n      process.stdout.write(\n        `  [${r.aggregated.date}/${r.aggregated.articleType}] ${r.writtenFiles.length} file(s) · ${r.aggregated.includedArtifacts.length} artifact(s) · gate ${r.aggregated.gateResult}\\n`\n      );\n    }\n    process.stdout.write(\n      `Generated ${totalFiles} file(s) across ${results.length} run(s) from ${totalArtifacts} total artifact(s)\\n`\n    );\n    return;\n  }\n  const result = generateArticle(opts);\n  process.stdout.write(\n    `Generated ${result.writtenFiles.length} file(s) from ${result.aggregated.includedArtifacts.length} artifact(s) — gate: ${result.aggregated.gateResult}\\n`\n  );\n  for (const f of result.writtenFiles) process.stdout.write(`  ${f}\\n`);\n}\n\n// Only run when invoked directly, not when imported by tests.\nconst isMain = (() => {\n  const entry = process.argv[1];\n  if (!entry) return false;\n  try {\n    return import.meta.url === pathToFileURL(entry).href;\n  } catch {\n    return false;\n  }\n})();\n\nif (isMain) {\n  main().catch((err: unknown) => {\n    const msg = err instanceof Error ? err.message : String(err);\n    process.stderr.write(`generate-article: ${msg}\\n`);\n    process.exit(1);\n  });\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/article-html.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/article-metadata.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":479,"column":19,"endLine":479,"endColumn":27},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":735,"column":15,"endLine":735,"endColumn":54},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":805,"column":22,"endLine":805,"endColumn":36}],"suppressedMessages":[{"ruleId":"security/detect-non-literal-regexp","severity":1,"message":"Found non-literal argument to RegExp Constructor","line":396,"column":28,"endLine":396,"endColumn":90,"suppressions":[{"kind":"directive","justification":"`human` derives from a sanitised slug via escapeRegex"}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Aggregator/ArticleMetadata\n * @description Resolve per-language `{title, description}` for an article\n * rendered by the aggregator pipeline. The resolver follows a strict\n * priority ladder that prefers *real editorial highlights* over boring,\n * repeated templates — satisfying the core SEO requirement that every\n * published article carry a unique, content-reflective headline and\n * description in every language variant.\n *\n * Priority ladder (per language, highest wins):\n *\n * 1. **Manifest override** — `manifest.title` / `manifest.description` on\n *    the analysis-run manifest, either as a plain string (applied to every\n *    language) or a `LanguageMap<string>` object for explicit per-language\n *    values. Authored by Stage-B agents when they have an editorial\n *    headline for the day.\n * 2. **Artefact editorial H1** — first `# …` heading from the first\n *    substantive artefact under the run directory (e.g.\n *    `intelligence/synthesis-summary.md`, `breaking-news-analysis.md`).\n *    Accepted only when the heading is not a generic\n *    `${humanize(articleType)} — ${date}` form.\n * 3. **Aggregated-markdown H1** — the first `# …` heading in the aggregator\n *    output, accepted under the same non-generic rule. In practice this\n *    tier rarely fires because the aggregator itself writes the generic\n *    default, but it covers hand-edited or legacy aggregates.\n * 4. **First strong prose paragraph** — the first line of the aggregated\n *    Markdown that survives {@link shouldSkipDescriptionLine}. Used for\n *    `description`; also used for `title` as a last editorial-content\n *    resort when every heading-level source is generic.\n * 5. **Localized template** — the per-article-type `*_TITLES` generator\n *    from `src/constants/language-articles.ts`. Always parameterised by\n *    date (or derived values), so the title changes from run to run even\n *    when this last tier fires — but still the \"boring repeated\" option.\n *\n * English highlights (tiers 2–4) are reserved for the `en` language\n * variant; non-English variants skip them and drop to the localized\n * template (tier 5) unless an explicit `manifest.title.<lang>` /\n * `manifest.description.<lang>` override is present. This guarantees\n * every variant's `<title>` and `<meta description>` are in the correct\n * locale even while the article body itself is still rendered from an\n * English source (until per-language body translations ship).\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { ALL_LANGUAGES, getLocalizedString } from '../constants/language-core.js';\nimport {\n  BREAKING_NEWS_TITLES,\n  COMMITTEE_REPORTS_TITLES,\n  MONTH_AHEAD_TITLES,\n  MONTHLY_REVIEW_TITLES,\n  MOTIONS_TITLES,\n  PROPOSITIONS_TITLES,\n  WEEK_AHEAD_TITLES,\n  WEEKLY_REVIEW_TITLES,\n} from '../constants/language-articles.js';\nimport type { LangTitleSubtitle, LanguageCode, LanguageMap } from '../types/index.js';\n\n/** One resolved `(title, description)` pair for a single language. */\nexport interface ResolvedMetadataEntry {\n  readonly title: string;\n  readonly description: string;\n}\n\n/** Fully resolved metadata — one entry per supported language. */\nexport type ResolvedMetadata = LanguageMap<ResolvedMetadataEntry>;\n\n/**\n * Raw manifest subset consumed by the resolver. Deliberately narrower\n * than the full {@link AnalysisManifest} shape so the resolver stays\n * usable for backport (which only has the manifest in text form) and for\n * callers that don't need the full typed structure.\n */\nexport interface MetadataManifest {\n  readonly articleType?: string;\n  readonly date?: string;\n  readonly runId?: string;\n  /**\n   * Optional editorial-title override. `string` is applied to every\n   * language; an object allows explicit per-language overrides.\n   */\n  readonly title?: string | Partial<Record<LanguageCode, string>>;\n  /**\n   * Optional editorial-description override. Same shape rules as\n   * {@link title}.\n   */\n  readonly description?: string | Partial<Record<LanguageCode, string>>;\n  /**\n   * Optional committee code (e.g. `ENVI`) used by\n   * {@link COMMITTEE_REPORTS_TITLES} when the template fallback fires.\n   */\n  readonly committee?: string;\n}\n\n/** Inputs to {@link resolveArticleMetadata}. */\nexport interface ResolveMetadataOptions {\n  /** Article type slug (e.g. `breaking`, `motions`, `week-ahead`). */\n  readonly articleType: string;\n  /** ISO date of the run (`YYYY-MM-DD`). */\n  readonly date: string;\n  /** Aggregated Markdown document body (after provenance/header). */\n  readonly markdown: string;\n  /** Parsed analysis manifest (may be empty for legacy/backport callers). */\n  readonly manifest?: MetadataManifest;\n  /**\n   * Absolute path to the analysis run directory so the resolver can\n   * peek at individual artefact files. Omit for callers that only have\n   * the aggregated Markdown (the artefact-H1 tier is then skipped).\n   */\n  readonly runDir?: string;\n}\n\n/** Maximum `<meta description>` length we will emit. */\nconst DESCRIPTION_MAX_LENGTH = 300;\n\n/** Maximum `<title>` length — anything longer is truncated with an ellipsis. */\nconst TITLE_MAX_LENGTH = 140;\n\n/** Ordered list of artefact filenames that typically carry the editorial H1. */\nconst EDITORIAL_ARTEFACT_CANDIDATES: readonly string[] = [\n  'intelligence/synthesis-summary.md',\n  'intelligence/executive-summary.md',\n  'intelligence/intelligence-briefing.md',\n  'executive-summary.md',\n  'intelligence-briefing.md',\n  'synthesis-summary.md',\n  'breaking-news-analysis.md',\n  'committee-activity-report.md',\n  'legislative-pipeline-analysis.md',\n  'weekly-outlook.md',\n  'monthly-outlook.md',\n  'week-in-review.md',\n  'month-in-review.md',\n  'motions-analysis.md',\n  'propositions-analysis.md',\n];\n\n/**\n * Emoji-banner prefixes that Stage-B agents use to decorate metadata rows\n * (e.g. `📋 Analysis Owner:`). Any line starting with one of these is\n * metadata, never prose.\n */\nconst EMOJI_BANNER_CHARS = [\n  '📋',\n  '📅',\n  '🔍',\n  '🏛',\n  '📰',\n  '📊',\n  '🏷',\n  '📈',\n  '📉',\n  '⚠',\n  '🔔',\n  '🎯',\n  '🗳',\n  '🏢',\n  '📄',\n];\n\n/**\n * Label prefixes that a prose description must never start with. Every\n * entry matches case-insensitively at the start of a trimmed line, followed\n * by optional space and a colon.\n */\nconst METADATA_LINE_PREFIXES: readonly string[] = [\n  'Analysis Date',\n  'Analysis Owner',\n  'Article Type',\n  'Assessment Date',\n  'Classification',\n  'Classification Date',\n  'Confidence',\n  'Data Sources',\n  'Document Type',\n  'Generated',\n  'Last Updated',\n  'Parliamentary Status',\n  'Parliamentary Term',\n  'Period',\n  'Run',\n  'Run ID',\n  'Series',\n  'Series Run',\n  'SPDX-FileCopyrightText',\n  'SPDX-License-Identifier',\n  'Type',\n  'Window',\n];\n\n/**\n * Return `true` when a line cannot serve as a prose description. Rejects\n * Markdown structural lines (headings, blockquotes, tables, HTML),\n * mermaid/chart directives, emoji-banner metadata rows, and the known\n * `Key: value` banners that Stage-B agents emit as artefact preamble.\n *\n * @param line - Trimmed line from the aggregated Markdown source\n * @returns `true` when the line is not prose and should be skipped\n */\nexport function shouldSkipDescriptionLine(line: string): boolean {\n  if (line.length === 0) return true;\n\n  // Markdown structural openers\n  if (line.startsWith('#')) return true;\n  if (line.startsWith('>')) return true;\n  if (line.startsWith('<')) return true;\n  if (line.startsWith('|')) return true;\n  if (line.startsWith('---') || line.startsWith('===')) return true;\n  if (line.startsWith('```') || line.startsWith('~~~')) return true;\n\n  // Mermaid / chart init blocks and the `title <text>` directive inside them\n  if (line.startsWith('%%')) return true;\n  if (/^title\\s/i.test(line)) return true;\n\n  // Emoji-banner metadata rows\n  if (EMOJI_BANNER_CHARS.some((char) => line.startsWith(char))) return true;\n\n  // `Key: value` metadata banners. Match plain text, bold `**Key**`,\n  // and italic `*Key*` variants.\n  const labelSource = line.replace(/^\\*+/, '').replace(/^\\*\\*/, '').replace(/^_+/, '').trim();\n  for (const prefix of METADATA_LINE_PREFIXES) {\n    const lower = labelSource.toLowerCase();\n    const prefixLower = prefix.toLowerCase();\n    if (\n      lower.startsWith(`${prefixLower}:`) ||\n      lower.startsWith(`${prefixLower} :`) ||\n      lower.startsWith(`${prefixLower}**:`) ||\n      lower.startsWith(`${prefixLower}*:`)\n    ) {\n      return true;\n    }\n  }\n\n  // Pure punctuation / decorative separators\n  if (/^[-*_=~.]{3,}$/.test(line)) return true;\n\n  return false;\n}\n\n/**\n * Strip inline Markdown decorations so we can use the remaining text as\n * plain-text meta-tag content. Removes link syntax, emphasis, inline code\n * backticks, and HTML-entity fragments that the Markdown source sometimes\n * smuggles in. Keeps the visible text readable.\n *\n * @param raw - Trimmed Markdown line\n * @returns Plain-text variant\n */\nexport function stripInlineMarkdown(raw: string): string {\n  // All inner character classes are length-bounded to eliminate the\n  // polynomial-regex worst case that CodeQL flags on uncontrolled input —\n  // none of these decorations are legitimately longer than 500 chars.\n  return raw\n    .replace(/!\\[([^\\]\\n]{0,500})\\]\\(([^)\\n]{0,500})\\)/g, '$1') // ![alt](img) — must precede [text](url)\n    .replace(/\\[([^\\]\\n]{1,500})\\]\\(([^)\\n]{0,500})\\)/g, '$1') // [text](url) → text\n    .replace(/`([^`\\n]{1,500})`/g, '$1') // inline code\n    .replace(/\\*\\*([^*\\n]{1,500})\\*\\*/g, '$1') // **bold**\n    .replace(/__([^_\\n]{1,500})__/g, '$1') // __bold__\n    .replace(/\\*([^*\\n]{1,500})\\*/g, '$1') // *italic*\n    .replace(/_([^_\\n]{1,500})_/g, '$1') // _italic_\n    .replace(/~~([^~\\n]{1,500})~~/g, '$1') // ~~strike~~\n    .replace(/\\s+/g, ' ')\n    .trim();\n}\n\n/**\n * Clamp a string to {@link DESCRIPTION_MAX_LENGTH} characters, appending\n * an ellipsis when truncation actually happens. Does not break words if\n * avoidable — a trailing partial word is trimmed back to the previous\n * space first.\n *\n * @param text - Raw description text\n * @returns Truncated description with trailing ellipsis when clipped\n */\nexport function truncateDescription(text: string): string {\n  if (text.length <= DESCRIPTION_MAX_LENGTH) return text;\n  const cut = text.slice(0, DESCRIPTION_MAX_LENGTH - 3);\n  const lastSpace = cut.lastIndexOf(' ');\n  const safe = lastSpace > DESCRIPTION_MAX_LENGTH - 60 ? cut.slice(0, lastSpace) : cut;\n  return `${safe.replace(/[.,;:—-]+$/, '')}…`;\n}\n\n/**\n * Clamp a title to {@link TITLE_MAX_LENGTH} characters in the same\n * word-boundary-preserving fashion as {@link truncateDescription}.\n *\n * @param text - Raw title text\n * @returns Truncated title with trailing ellipsis when clipped\n */\nexport function truncateTitle(text: string): string {\n  if (text.length <= TITLE_MAX_LENGTH) return text;\n  const cut = text.slice(0, TITLE_MAX_LENGTH - 3);\n  const lastSpace = cut.lastIndexOf(' ');\n  const safe = lastSpace > TITLE_MAX_LENGTH - 40 ? cut.slice(0, lastSpace) : cut;\n  return `${safe.replace(/[.,;:—-]+$/, '')}…`;\n}\n\n/**\n * Return the first Markdown H1 (`# …`) in the supplied text, stripped of\n * the leading `#` and trailing anchor syntax. Returns an empty string when\n * no H1 is present.\n *\n * @param markdown - Markdown source\n * @returns Plain-text H1, or empty string when none found\n */\nexport function extractFirstH1(markdown: string): string {\n  for (const raw of markdown.split('\\n')) {\n    const line = raw.trim();\n    if (!line.startsWith('#')) continue;\n    // Accept `# Title` but not `## Sub-heading`.\n    if (!/^#\\s+/.test(line)) continue;\n    // Strip the leading `# ` marker, then trim trailing `#` characters\n    // without an unbounded `\\s*#+\\s*$` regex (CodeQL flags that form as\n    // polynomial on pathological repeated-`#` input).\n    let text = line.replace(/^#\\s+/, '').trimEnd();\n    while (text.endsWith('#')) text = text.slice(0, -1).trimEnd();\n    return stripInlineMarkdown(text);\n  }\n  return '';\n}\n\n/**\n * Walk every line of the Markdown source and return the first line that\n * survives {@link shouldSkipDescriptionLine}. Inline Markdown decorations\n * are stripped and the result is truncated to fit `<meta description>`.\n *\n * @param markdown - Markdown source\n * @returns Prose description, or empty string when nothing qualifies\n */\nexport function extractStrongProseLine(markdown: string): string {\n  for (const raw of markdown.split('\\n')) {\n    const line = raw.trim();\n    if (shouldSkipDescriptionLine(line)) continue;\n    const plain = stripInlineMarkdown(line);\n    if (plain.length < 40) continue;\n    return truncateDescription(plain);\n  }\n  return '';\n}\n\n/**\n * Humanise an `article-type` slug the same way the aggregator does (see\n * `src/aggregator/analysis-aggregator.ts:humanize`). Kept in sync by value\n * — we deliberately do not import the private helper.\n *\n * @param slug - Slug like `week-ahead` or `breaking_news`\n * @returns Title-cased humanised form (`Week Ahead`, `Breaking News`)\n */\nexport function humanizeSlug(slug: string): string {\n  return slug\n    .split(/[-_]/g)\n    .map((seg) => (seg ? seg.charAt(0).toUpperCase() + seg.slice(1) : seg))\n    .join(' ')\n    .trim();\n}\n\n/**\n * Return `true` when the supplied heading matches the generic\n * `${humanize(articleType)} — ${date}` form that the aggregator writes as\n * its default document title. Accepts em-dash, en-dash, and ASCII hyphen\n * separators, and matches the `breaking-breaking` variant that some\n * same-day collision runs produce.\n *\n * @param heading - Plain-text heading (post-{@link stripInlineMarkdown})\n * @param articleType - Article type slug\n * @param date - ISO date string\n * @returns `true` when the heading carries no editorial information\n */\nexport function isGenericHeading(heading: string, articleType: string, date: string): boolean {\n  const normalized = heading.trim().replace(/\\s+/g, ' ');\n  if (normalized === '') return true;\n\n  const human = humanizeSlug(articleType);\n  const patterns = [\n    `${human} — ${date}`,\n    `${human} - ${date}`,\n    `${human} – ${date}`,\n    `${human}: ${date}`,\n    `${human} ${date}`,\n  ];\n\n  // Also accept the collision-suffix pattern (e.g. `Breaking Breaking — …`)\n  // and the auto-generated \"EU Parliament <Type> — <date>\" legacy form.\n  const humanRedundant = `${human} ${human}`;\n  for (const p of patterns) {\n    if (normalized === p) return true;\n    if (normalized === `EU Parliament ${p}`) return true;\n    if (normalized === `${humanRedundant} — ${date}`) return true;\n  }\n\n  // The bare `${human} — <anything>` with nothing extra is also generic.\n  // eslint-disable-next-line security/detect-non-literal-regexp -- `human` derives from a sanitised slug via escapeRegex\n  const trailingDateOnly = new RegExp(`^${escapeRegex(human)}\\\\s*[—–-]\\\\s*[\\\\d-]+$`, 'u');\n  if (trailingDateOnly.test(normalized)) {\n    return true;\n  }\n\n  return false;\n}\n\n/**\n * Escape regex metacharacters so a dynamic string can be embedded safely\n * in a pattern built at runtime.\n *\n * @param input - Raw string\n * @returns Regex-safe form of {@link input}\n */\nfunction escapeRegex(input: string): string {\n  return input.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Attempt to read the first H1 and first prose paragraph from the first\n * existing artefact under {@link EDITORIAL_ARTEFACT_CANDIDATES}. Returns\n * `null` when no candidate artefact exists.\n *\n * @param runDir - Absolute run directory path\n * @param articleType - Article type slug (used by {@link isGenericHeading})\n * @param date - ISO run date (used by {@link isGenericHeading})\n * @returns `{headline, summary}` where either field may be empty\n */\nexport function extractArtifactHighlight(\n  runDir: string,\n  articleType: string,\n  date: string\n): { readonly headline: string; readonly summary: string } | null {\n  if (!runDir || !fs.existsSync(runDir)) return null;\n\n  // Direct candidate lookup — cheap and deterministic.\n  for (const rel of EDITORIAL_ARTEFACT_CANDIDATES) {\n    const abs = path.join(runDir, rel);\n    if (!fs.existsSync(abs)) continue;\n    const body = readArtefactBody(abs);\n    const headline = extractFirstH1(body);\n    if (!headline) continue;\n    if (isGenericHeading(headline, articleType, date)) continue;\n    const summary = extractStrongProseLine(body);\n    return { headline: truncateTitle(headline), summary };\n  }\n\n  // Fallback: walk the top-level `.md` files in the run dir once, looking\n  // for any that starts with `#` and has a non-generic headline.\n  const topLevel = safeReaddir(runDir).filter((f) => f.endsWith('.md'));\n  for (const rel of topLevel) {\n    if (rel === 'manifest.json') continue;\n    const abs = path.join(runDir, rel);\n    const body = readArtefactBody(abs);\n    const headline = extractFirstH1(body);\n    if (!headline) continue;\n    if (isGenericHeading(headline, articleType, date)) continue;\n    const summary = extractStrongProseLine(body);\n    return { headline: truncateTitle(headline), summary };\n  }\n\n  return null;\n}\n\n/**\n * Read an artefact file, skipping any SPDX HTML-comment header rows so the\n * first-H1 / first-prose logic is never derailed by the REUSE preamble.\n *\n * @param abs - Absolute file path\n * @returns File contents with SPDX comment lines dropped\n */\nfunction readArtefactBody(abs: string): string {\n  let text: string;\n  try {\n    text = fs.readFileSync(abs, 'utf8');\n  } catch {\n    return '';\n  }\n  const lines = text.split('\\n');\n  // Drop a run of leading `<!--` SPDX/provenance comments plus blank lines.\n  let i = 0;\n  while (i < lines.length) {\n    const line = (lines[i] ?? '').trim();\n    if (line === '') {\n      i++;\n      continue;\n    }\n    if (line.startsWith('<!--') && line.endsWith('-->')) {\n      i++;\n      continue;\n    }\n    break;\n  }\n  return lines.slice(i).join('\\n');\n}\n\n/**\n * `fs.readdirSync` wrapped to never throw for missing or unreadable\n * directories.\n *\n * @param dir - Absolute directory path\n * @returns Entries in {@link dir} or `[]` when unreadable\n */\nfunction safeReaddir(dir: string): string[] {\n  try {\n    return fs.readdirSync(dir);\n  } catch {\n    return [];\n  }\n}\n\n/**\n * Build the per-language `{title, description}` pair using the\n * article-type–specific `*_TITLES` generator from\n * `src/constants/language-articles.ts`. This is the last-resort tier and\n * is always parameterised by date (or equivalent), so even when it fires\n * the result is not identical across runs of the same type.\n *\n * @param articleType - Article type slug\n * @param date - ISO run date\n * @param committee - Optional committee code (used by `committee-reports`)\n * @returns Per-language `LangTitleSubtitle`\n */\nexport function buildTemplateFallback(\n  articleType: string,\n  date: string,\n  committee?: string\n): LanguageMap<LangTitleSubtitle> {\n  const map: Record<LanguageCode, LangTitleSubtitle> = Object.create(null) as Record<\n    LanguageCode,\n    LangTitleSubtitle\n  >;\n  // week-in-review uses the D-36→D-8 reporting window (ADR-006) so that\n  // EP roll-call voting data — published 2–6 weeks after the sitting —\n  // is always available in the analysis window.\n  const weekRange =\n    articleType === 'week-in-review'\n      ? deriveReportingWindowForWeekInReview(date)\n      : deriveWeekRange(date);\n  const monthLabel = deriveMonthLabel(date);\n  const committeeLabel = committee && committee.trim().length > 0 ? committee : 'Main Committees';\n\n  for (const lang of ALL_LANGUAGES) {\n    const entry = templateForType(lang, articleType, {\n      date,\n      weekStart: weekRange.start,\n      weekEnd: weekRange.end,\n      month: monthLabel,\n      committee: committeeLabel,\n    });\n    Object.defineProperty(map, lang, {\n      value: entry,\n      enumerable: true,\n      writable: true,\n      configurable: true,\n    });\n  }\n  return map;\n}\n\n/** Inputs for {@link templateForType}. */\ninterface TemplateInputs {\n  readonly date: string;\n  readonly weekStart: string;\n  readonly weekEnd: string;\n  readonly month: string;\n  readonly committee: string;\n}\n\n/**\n * Dispatch an article-type slug to the matching localized template\n * generator. Unknown types get a uniform fallback built from\n * {@link humanizeSlug} and the run date.\n *\n * @param lang - Target language code\n * @param articleType - Article type slug\n * @param inputs - Pre-derived inputs used by the generators\n * @returns `LangTitleSubtitle` for the requested language\n */\nfunction templateForType(\n  lang: LanguageCode,\n  articleType: string,\n  inputs: TemplateInputs\n): LangTitleSubtitle {\n  switch (articleType) {\n    case 'breaking':\n    case 'breaking-breaking':\n      return getLocalizedString(BREAKING_NEWS_TITLES, lang)(inputs.date);\n    case 'committee-reports':\n      return getLocalizedString(COMMITTEE_REPORTS_TITLES, lang)(inputs.committee);\n    case 'motions':\n      return getLocalizedString(MOTIONS_TITLES, lang)(inputs.date);\n    case 'propositions':\n      return getLocalizedString(PROPOSITIONS_TITLES, lang)();\n    case 'week-ahead':\n      return getLocalizedString(WEEK_AHEAD_TITLES, lang)(inputs.weekStart, inputs.weekEnd);\n    case 'month-ahead':\n      return getLocalizedString(MONTH_AHEAD_TITLES, lang)(inputs.month);\n    case 'week-in-review':\n      return getLocalizedString(WEEKLY_REVIEW_TITLES, lang)(inputs.weekStart, inputs.weekEnd);\n    case 'month-in-review':\n      return getLocalizedString(MONTHLY_REVIEW_TITLES, lang)(inputs.month);\n    default:\n      return {\n        title: `${humanizeSlug(articleType)} — ${inputs.date}`,\n        subtitle: `EU Parliament analysis — ${inputs.date}`,\n      };\n  }\n}\n\n/** Milliseconds in one UTC day — used by date-window derivation helpers. */\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * Parse an ISO date and return the `[start, end]` week range as ISO\n * strings. Week starts on Monday and ends on the following Sunday.\n *\n * @param date - ISO date string (`YYYY-MM-DD`)\n * @returns `{ start, end }` both in `YYYY-MM-DD` form\n */\nexport function deriveWeekRange(date: string): { readonly start: string; readonly end: string } {\n  const parsed = parseIsoDate(date);\n  if (!parsed) return { start: date, end: date };\n  // getUTCDay(): 0 = Sunday, 1 = Monday, …\n  const day = parsed.getUTCDay();\n  // Shift so Monday = 0, Sunday = 6.\n  const shift = (day + 6) % 7;\n  const startMs = parsed.getTime() - shift * MS_PER_DAY;\n  const endMs = startMs + 6 * MS_PER_DAY;\n  return { start: formatIsoDate(new Date(startMs)), end: formatIsoDate(new Date(endMs)) };\n}\n\n/**\n * Return the D-36 → D-8 reporting window for the `week-in-review`\n * article type. EP roll-call voting data is published with a 2–6 week\n * lag, so using the most-recent 7 days structurally produces a\n * vote-empty dataset. Shifting 8 days back and widening to 28 days\n * (start = D-36, end = D-8) ensures the window always contains at\n * least one full EP plenary week with published roll-call data\n * (ADR-006). Direction is consistent with the workflow's\n * `DATE_FROM` (start = D-36) → `DATE_TO` (end = D-8) variables.\n *\n * @param date - ISO article date string (`YYYY-MM-DD`) — typically TODAY\n * @returns `{ start: D-36, end: D-8 }` both as `YYYY-MM-DD` ISO strings\n */\nexport function deriveReportingWindowForWeekInReview(date: string): {\n  readonly start: string;\n  readonly end: string;\n} {\n  const parsed = parseIsoDate(date);\n  if (!parsed) return { start: date, end: date };\n  return {\n    start: formatIsoDate(new Date(parsed.getTime() - 36 * MS_PER_DAY)),\n    end: formatIsoDate(new Date(parsed.getTime() - 8 * MS_PER_DAY)),\n  };\n}\n\n/**\n * Return a human-friendly month label for an ISO date — English month\n * name + four-digit year (e.g. `April 2026`). The non-English template\n * generators accept this same label verbatim because they interpolate it\n * into a localized sentence rather than translating the month itself.\n *\n * @param date - ISO date string\n * @returns Month label, or the input when parsing fails\n */\nexport function deriveMonthLabel(date: string): string {\n  const parsed = parseIsoDate(date);\n  if (!parsed) return date;\n  const monthNames = [\n    'January',\n    'February',\n    'March',\n    'April',\n    'May',\n    'June',\n    'July',\n    'August',\n    'September',\n    'October',\n    'November',\n    'December',\n  ];\n  const name = monthNames[parsed.getUTCMonth()] ?? '';\n  return `${name} ${parsed.getUTCFullYear()}`.trim();\n}\n\n/**\n * Parse an ISO date string as UTC midnight. Returns `null` for malformed\n * input so callers can skip month/week derivation gracefully.\n *\n * @param iso - ISO date string\n * @returns Parsed `Date` or `null`\n */\nfunction parseIsoDate(iso: string): Date | null {\n  if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(iso)) return null;\n  const parsed = new Date(`${iso}T00:00:00Z`);\n  return Number.isNaN(parsed.getTime()) ? null : parsed;\n}\n\n/**\n * Format a `Date` as `YYYY-MM-DD` in UTC.\n *\n * @param d - Date object\n * @returns ISO date string\n */\nfunction formatIsoDate(d: Date): string {\n  const y = d.getUTCFullYear();\n  const m = String(d.getUTCMonth() + 1).padStart(2, '0');\n  const day = String(d.getUTCDate()).padStart(2, '0');\n  return `${y}-${m}-${day}`;\n}\n\n/**\n * Extract a manifest override value for a single language. Accepts either\n * a plain string (applied to every language) or a `LanguageMap` object.\n *\n * @param value - Raw manifest value (string or per-lang object)\n * @param lang - Target language code\n * @returns Override string, or empty string when absent\n */\nfunction manifestOverrideFor(\n  value: string | Partial<Record<LanguageCode, string>> | undefined,\n  lang: LanguageCode\n): string {\n  // A plain string is a blanket editorial override — the operator is\n  // telling the resolver \"use this exact text for every language\". This\n  // is the one path where a single string is applied cross-locale; the\n  // operator takes responsibility for its language.\n  if (typeof value === 'string') return value.trim();\n  if (!value) return '';\n  // Per-language object: respect ONLY the explicit entry for `lang`. We\n  // deliberately do NOT fall back to the `en` entry for non-English\n  // variants — otherwise an EN-only override would leak English into\n  // every other locale's <title>. Missing languages fall through to the\n  // localized template tier.\n  const map = new Map<string, string>();\n  for (const key of Object.keys(value)) {\n    const v = (value as Record<string, unknown>)[key];\n    if (typeof v === 'string') map.set(key, v);\n  }\n  const entry = map.get(lang);\n  return typeof entry === 'string' ? entry.trim() : '';\n}\n\n/**\n * Internal: best editorial `{headline, summary}` pair available from the\n * aggregator output and artefacts, independent of language. Used for\n * tiers 2–4.\n *\n * @param opts - Resolver inputs\n * @returns Editorial content derived from English source\n */\nfunction resolveEditorialContent(opts: ResolveMetadataOptions): {\n  readonly headline: string;\n  readonly summary: string;\n} {\n  const { articleType, date, markdown, runDir } = opts;\n\n  // Tier 2: first non-generic H1 in the first substantive artefact.\n  if (runDir) {\n    const highlight = extractArtifactHighlight(runDir, articleType, date);\n    if (highlight?.headline) {\n      return {\n        headline: highlight.headline,\n        summary: highlight.summary,\n      };\n    }\n  }\n\n  // Tier 3: first non-generic H1 in the aggregated Markdown itself.\n  const aggregatedH1 = extractFirstH1(markdown);\n  const aggregatedSummary = extractStrongProseLine(markdown);\n  if (aggregatedH1 && !isGenericHeading(aggregatedH1, articleType, date)) {\n    return {\n      headline: truncateTitle(aggregatedH1),\n      summary: aggregatedSummary,\n    };\n  }\n\n  // Tier 4: first strong prose paragraph (title = same prose clipped).\n  if (aggregatedSummary) {\n    return { headline: truncateTitle(aggregatedSummary), summary: aggregatedSummary };\n  }\n\n  return { headline: '', summary: '' };\n}\n\n/**\n * Resolve per-language `{title, description}` for one article following\n * the priority ladder documented at the top of this module.\n *\n * @param opts - Resolver inputs ({@link ResolveMetadataOptions})\n * @returns One `{title, description}` entry per supported language\n */\nexport function resolveArticleMetadata(opts: ResolveMetadataOptions): ResolvedMetadata {\n  const manifest = opts.manifest ?? {};\n  const editorial = resolveEditorialContent(opts);\n  const template = buildTemplateFallback(opts.articleType, opts.date, manifest.committee);\n\n  const result: Record<LanguageCode, ResolvedMetadataEntry> = Object.create(null) as Record<\n    LanguageCode,\n    ResolvedMetadataEntry\n  >;\n\n  for (const lang of ALL_LANGUAGES) {\n    const manifestTitle = manifestOverrideFor(manifest.title, lang);\n    const manifestDescription = manifestOverrideFor(manifest.description, lang);\n    const fallback = template[lang];\n\n    // Non-English languages must not inherit the English editorial\n    // headline/summary — they would render a non-locale title in a\n    // localized chrome. We skip tiers 2–4 for non-EN and drop straight to\n    // the localized template (or explicit manifest override when provided).\n    const useEditorial = lang === 'en';\n    const titleCandidates = useEditorial\n      ? [manifestTitle, editorial.headline, fallback.title]\n      : [manifestTitle, fallback.title];\n    const descCandidates = useEditorial\n      ? [manifestDescription, editorial.summary, fallback.subtitle]\n      : [manifestDescription, fallback.subtitle];\n\n    const title = pickFirstNonEmpty(titleCandidates) || fallback.title;\n    const description = pickFirstNonEmpty(descCandidates) || fallback.subtitle;\n\n    Object.defineProperty(result, lang, {\n      value: {\n        title: truncateTitle(title),\n        description: truncateDescription(description),\n      },\n      enumerable: true,\n      writable: true,\n      configurable: true,\n    });\n  }\n\n  return result;\n}\n\n/**\n * Return the first non-empty, trimmed entry from a candidate list, or\n * the empty string when every entry is blank.\n *\n * @param candidates - Ordered list of candidate strings\n * @returns First non-empty entry\n */\nfunction pickFirstNonEmpty(candidates: readonly string[]): string {\n  for (const c of candidates) {\n    if (typeof c === 'string' && c.trim().length > 0) return c.trim();\n  }\n  return '';\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/artifact-order.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/clean-artifact.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":149,"column":18,"endLine":149,"endColumn":26},{"ruleId":"@typescript-eslint/prefer-optional-chain","severity":1,"message":"Prefer using an optional chain expression instead, as it's more concise and easier to read.","line":241,"column":7,"messageId":"preferOptionalChain","endLine":241,"endColumn":36,"fix":{"range":[8834,8863],"text":"!fenceMatch?.[2]"}},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":267,"column":16,"endLine":267,"endColumn":28},{"ruleId":"@typescript-eslint/prefer-optional-chain","severity":1,"message":"Prefer using an optional chain expression instead, as it's more concise and easier to read.","line":274,"column":7,"messageId":"preferOptionalChain","endLine":274,"endColumn":22,"fix":{"range":[10232,10247],"text":"!atx?.[2]"}},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":307,"column":18,"endLine":307,"endColumn":26},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":388,"column":18,"endLine":388,"endColumn":26},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":394,"column":5,"endLine":394,"endColumn":13},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":570,"column":23,"endLine":570,"endColumn":31},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":597,"column":18,"endLine":597,"endColumn":26},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":614,"column":47,"endLine":614,"endColumn":64},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":669,"column":31,"endLine":669,"endColumn":39},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":672,"column":56,"endLine":672,"endColumn":64},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":679,"column":18,"endLine":679,"endColumn":32},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":689,"column":39,"endLine":689,"endColumn":55},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":690,"column":54,"endLine":690,"endColumn":70}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":15,"fixableErrorCount":0,"fixableWarningCount":2,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Aggregator/CleanArtifact\n * @description Normalise a single analysis-artifact Markdown file so it can be\n * merged into the aggregate document without producing duplicate banners,\n * competing H1 headings, or broken relative links.\n *\n * Applied transformations (in order):\n *   1. Strip leading YAML front-matter (`---\\n…\\n---\\n`).\n *   2. Strip ISMS/owner/classification banners (emoji rows, shields.io badges,\n *      `<p align=\"center\">` blocks, and the separator `---` that usually\n *      follows them).\n *   3. Remove the artifact's own H1; the aggregator owns the document outline.\n *   4. Demote every remaining heading by one level (H2→H3, etc.) so the\n *      aggregate has a single H1.\n *   5. Rewrite repo-relative links/images to absolute GitHub URLs so the\n *      published HTML is portable.\n *   6. Deduplicate mermaid fence bodies on a per-document basis (caller-owned\n *      state) — identical blocks are replaced with a reference comment.\n */\n\n// Re-export GitHub URL helpers from the canonical infra module so callers\n// that already imported `githubBlobUrl` / `githubRawUrl` from this file\n// keep working. New code should import from `aggregator/infra/github-urls.js`.\nimport { blobUrl as _blobUrl, rawUrl as _rawUrl } from './infra/github-urls.js';\n\n/**\n * Build a GitHub blob URL for a repo-relative path.\n *\n * @param relPath - Repo-relative file path\n * @returns Absolute `https://github.com/.../blob/main/...` URL\n */\nexport function githubBlobUrl(relPath: string): string {\n  return _blobUrl(relPath);\n}\n\n/**\n * Build a `raw.githubusercontent.com` URL for a repo-relative path.\n *\n * @param relPath - Repo-relative file path\n * @returns Absolute raw-content URL\n */\nexport function githubRawUrl(relPath: string): string {\n  return _rawUrl(relPath);\n}\n\n/** Options controlling artifact cleanup. */\nexport interface CleanArtifactOptions {\n  /**\n   * Repo-relative path of the artifact being cleaned (e.g.\n   * `analysis/daily/2026-01-15/breaking-run1/intelligence/synthesis-summary.md`).\n   * Used to resolve relative links/images against.\n   */\n  readonly artifactRelPath: string;\n  /**\n   * Shared set of mermaid-body hashes seen so far in the aggregate document.\n   * Identical blocks are replaced with a cross-reference comment; the caller\n   * owns the set so it persists across artifacts.\n   */\n  readonly seenMermaidHashes?: Set<string>;\n}\n\n/** Result of {@link cleanArtifact}. */\nexport interface CleanArtifactResult {\n  /** Cleaned Markdown ready to be concatenated into the aggregate. */\n  readonly markdown: string;\n  /** Headings removed (for debugging/telemetry). */\n  readonly strippedH1s: number;\n  /** Banner/metadata lines removed. */\n  readonly strippedBannerLines: number;\n  /** Operational metadata preamble lines removed (e.g. **Run:** / **Window:** blocks). */\n  readonly strippedMetaLines: number;\n  /** Mermaid blocks deduplicated as a reference to a previous occurrence. */\n  readonly dedupedMermaidBlocks: number;\n}\n\n/**\n * Strip YAML front-matter from the head of a Markdown document. Matches\n * `---\\n...\\n---\\n` *only* at position 0 — quoted `---` dividers deeper in\n * the document are left alone.\n *\n * @param md - Raw Markdown source\n * @returns Markdown with the leading front-matter block removed\n */\nexport function stripFrontMatter(md: string): string {\n  if (!md.startsWith('---')) return md;\n  const match = /^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/.exec(md);\n  return match ? md.slice(match[0].length) : md;\n}\n\n/**\n * Regex patterns identifying banner / document-owner / shields.io / center-pic\n * lines that clutter the aggregate. All are line-level patterns; the caller\n * applies them after front-matter strip.\n */\nconst BANNER_LINE_PATTERNS: readonly RegExp[] = [\n  /^\\s*<p\\s+align=\"center\">/i,\n  /^\\s*<\\/p>\\s*$/i,\n  /^\\s*<img\\s+[^>]*hack23\\.com\\/icon-/i,\n  /^\\s*<h1\\s+align=\"center\">/i,\n  /^\\s*<\\/h1>\\s*$/i,\n  /^\\s*<a\\s+href=\"#\"><img\\s+src=\"https:\\/\\/img\\.shields\\.io\\//i,\n  /^\\s*\\*\\*\\s*📋\\s*Document Owner/i,\n  /^\\s*\\*\\*\\s*🔄\\s*Review Cycle/i,\n  /^\\s*\\*\\*\\s*🏢\\s*Owner/i,\n  /^\\s*<strong>\\s*(?:📋|🔄|🏢)/i,\n  // Standalone center-aligned block closings\n  /^\\s*<\\/p>\\s*$/,\n];\n\n/**\n * Line-level matcher for a standalone horizontal rule. Used to drop the\n * `---` separator that usually follows the banner block.\n */\nconst HR_LINE = /^\\s*---\\s*$/;\n\n/**\n * Return true when the line should be stripped as banner content.\n *\n * @param line - Single line of Markdown\n * @returns `true` if the line matches any banner pattern\n */\nfunction isBannerLine(line: string): boolean {\n  for (const p of BANNER_LINE_PATTERNS) {\n    if (p.test(line)) return true;\n  }\n  return false;\n}\n\n/**\n * Drop banner/metadata blocks from the head of the document. Rules:\n *  - A run of banner lines (contiguous, or separated only by blank lines) is\n *    removed. A trailing `---` horizontal rule immediately after the banner\n *    run is also removed.\n *  - Stops scanning as soon as we hit a line that looks like real content\n *    (headings, prose, tables, fences) that isn't a banner or blank.\n *\n * @param md - Raw Markdown source\n * @returns `{ md, lines }` — stripped Markdown and count of removed lines\n */\nexport function stripBanners(md: string): { md: string; lines: number } {\n  const lines = md.split('\\n');\n  let i = 0;\n  let bannerEnd = 0;\n  let stripped = 0;\n  while (i < lines.length) {\n    const line = lines[i] ?? '';\n    if (isBannerLine(line)) {\n      bannerEnd = i + 1;\n      stripped++;\n      i++;\n      continue;\n    }\n    if (line.trim() === '') {\n      // blank line — keep scanning for more banner lines\n      i++;\n      continue;\n    }\n    // Real content reached — but absorb a trailing HR if it immediately\n    // follows a banner run.\n    if (bannerEnd > 0 && HR_LINE.test(line)) {\n      bannerEnd = i + 1;\n      stripped++;\n    }\n    break;\n  }\n  if (bannerEnd === 0) return { md, lines: 0 };\n  return { md: lines.slice(bannerEnd).join('\\n').replace(/^\\n+/, ''), lines: stripped };\n}\n\n// REUSE-IgnoreStart\n/**\n * Matches an SPDX tag anywhere on a line, whether wrapped in HTML comments\n * (SPDX-License-Identifier line inside `<!-- ... -->`), inline markdown\n * emphasis (italic-wrapped SPDX-License-Identifier / SPDX-FileCopyrightText),\n * or written bare. Used to purge artifact-level SPDX metadata before rendering\n * so it doesn't leak into the aggregated HTML (where the REUSE tool would then\n * parse the surrounding markup as part of the SPDX expression).\n */\n// REUSE-IgnoreEnd\nconst SPDX_TAG_LINE =\n  /SPDX-(?:License-Identifier|FileCopyrightText|PackageName|PackageSupplier|PackageDownloadLocation)\\b/;\n\n// REUSE-IgnoreStart\n/**\n * Remove every line containing an SPDX tag from the Markdown source. The\n * aggregated article HTML carries its own file-level SPDX header via\n * `REUSE.toml`; per-artifact tags would otherwise surface as visible footer\n * text (italic-wrapped SPDX tags rendered inside `<em>` / `</em></p>`) and\n * trip the REUSE compliance scanner, which would parse the trailing markup\n * as part of the SPDX expression.\n *\n * @param md - Raw Markdown source\n * @returns `{ md, lines }` — stripped Markdown and count of removed lines\n */\n// REUSE-IgnoreEnd\nexport function stripSpdxTags(md: string): { md: string; lines: number } {\n  const lines = md.split('\\n');\n  const kept: string[] = [];\n  let stripped = 0;\n  for (const line of lines) {\n    if (SPDX_TAG_LINE.test(line)) {\n      stripped++;\n      continue;\n    }\n    kept.push(line);\n  }\n  return { md: kept.join('\\n'), lines: stripped };\n}\n\n/**\n * Remove every H1 (`^# ` and the setext H1 form) and demote every other\n * ATX heading by one level. Setext H2 (`----` underline) stays as H2 because\n * converting it to H3 would require replacing the underline form.\n *\n * Skips changes inside fenced code blocks.\n *\n * @param md - Raw Markdown source\n * @returns `{ md, h1Count }` — transformed Markdown and number of H1s removed\n */\n/**\n * Track open/close of a fenced code block. Returns the updated fence state\n * and the original line (unmodified). Centralising the state machine keeps\n * callers simple and makes cognitive complexity linear.\n *\n * @param line - Current line of Markdown\n * @param inFence - Whether the previous line was inside a fenced block\n * @param fenceMarker - Opening marker for the current fence (or `\"\"`)\n * @returns `{ inFence, fenceMarker, matched }` reflecting the state after\n *          processing `line`; `matched` is `true` when the line itself is a\n *          fence boundary (and should therefore be passed through verbatim)\n */\nfunction advanceFenceState(\n  line: string,\n  inFence: boolean,\n  fenceMarker: string\n): { inFence: boolean; fenceMarker: string; matched: boolean } {\n  const fenceMatch = /^(\\s*)(```+|~~~+)(.*)$/.exec(line);\n  if (!fenceMatch || !fenceMatch[2]) return { inFence, fenceMarker, matched: false };\n  const marker = fenceMatch[2];\n  if (!inFence) {\n    return { inFence: true, fenceMarker: marker, matched: true };\n  }\n  if (marker.startsWith(fenceMarker.charAt(0)) && marker.length >= fenceMarker.length) {\n    return { inFence: false, fenceMarker: '', matched: true };\n  }\n  return { inFence, fenceMarker, matched: true };\n}\n\n/**\n * Transform one non-fence heading line: setext H1, ATX H1, or ATX H2-H6.\n * Returns the processed output plus how many source lines it consumed and\n * whether an H1 was removed.\n *\n * @param lines - All source lines (used to peek at the next line for setext)\n * @param index - Zero-based index of the line under consideration\n * @returns `{ output, consumed, h1Removed }` — `consumed` is how many lines\n *          the caller should advance by (1 for ATX; 2 for setext H1; 0 when\n *          the line is not a heading at all)\n */\nfunction processHeadingLine(\n  lines: readonly string[],\n  index: number\n): { output: string | null; consumed: number; h1Removed: boolean } {\n  const line = lines[index] ?? '';\n  // Setext H1: current line has text, next line is `===+`\n  const nextLine = lines[index + 1] ?? '';\n  if (/^\\s*=+\\s*$/.test(nextLine) && /\\S/.test(line)) {\n    return { output: null, consumed: 2, h1Removed: true };\n  }\n  const atx = /^(\\s*)(#{1,6})(\\s.*)$/.exec(line);\n  if (!atx || !atx[2]) {\n    return { output: line, consumed: 1, h1Removed: false };\n  }\n  const level = atx[2].length;\n  if (level === 1) {\n    return { output: null, consumed: 1, h1Removed: true };\n  }\n  const demoted = level === 6 ? '######' : '#'.repeat(level + 1);\n  return {\n    output: `${atx[1] ?? ''}${demoted}${atx[3] ?? ''}`,\n    consumed: 1,\n    h1Removed: false,\n  };\n}\n\n/**\n * Remove every H1 (`^# ` and the setext H1 form) and demote every other\n * ATX heading by one level. Setext H2 (`----` underline) stays as H2 because\n * converting it to H3 would require replacing the underline form.\n *\n * Skips changes inside fenced code blocks.\n *\n * @param md - Raw Markdown source\n * @returns `{ md, h1Count }` — transformed Markdown and number of H1s removed\n */\nexport function demoteHeadings(md: string): { md: string; h1Count: number } {\n  const lines = md.split('\\n');\n  const out: string[] = [];\n  let inFence = false;\n  let fenceMarker = '';\n  let h1Count = 0;\n  let i = 0;\n  while (i < lines.length) {\n    const line = lines[i] ?? '';\n    const fence = advanceFenceState(line, inFence, fenceMarker);\n    if (fence.matched || inFence) {\n      inFence = fence.inFence;\n      fenceMarker = fence.fenceMarker;\n      out.push(line);\n      i++;\n      continue;\n    }\n    const result = processHeadingLine(lines, i);\n    if (result.h1Removed) h1Count++;\n    if (result.output !== null) out.push(result.output);\n    i += result.consumed;\n  }\n  return { md: out.join('\\n'), h1Count };\n}\n\n/**\n * Resolve a relative link target against the artifact's directory and\n * return an absolute GitHub URL.\n *\n * @param target - Original link target (e.g. `../templates/foo.md`)\n * @param artifactRelPath - Repo-relative path of the artifact\n * @param raw - When true, produce a raw.githubusercontent URL (for images)\n * @returns Absolute URL (or the original target for anchors/absolute links)\n */\nexport function resolveLink(target: string, artifactRelPath: string, raw: boolean): string {\n  // Preserve absolute URLs, anchors, mailto/tel, and protocol-relative\n  if (\n    /^[a-z][a-z0-9+.-]*:\\/\\//i.test(target) ||\n    target.startsWith('//') ||\n    target.startsWith('#') ||\n    target.startsWith('mailto:') ||\n    target.startsWith('tel:') ||\n    target.startsWith('data:')\n  ) {\n    return target;\n  }\n  const artifactDir = artifactRelPath.split('/').slice(0, -1).join('/');\n  // Split off an optional `#fragment` or `?query` suffix for re-attachment.\n  const suffixMatch = /[#?].*$/.exec(target);\n  const suffix = suffixMatch ? suffixMatch[0] : '';\n  const bare = suffix ? target.slice(0, -suffix.length) : target;\n  const resolved = posixResolve(artifactDir, bare);\n  const url = raw ? githubRawUrl(resolved) : githubBlobUrl(resolved);\n  return `${url}${suffix}`;\n}\n\n/**\n * POSIX path-resolve over `/`-separated strings. Mirrors `path.posix.resolve`\n * on a virtual absolute root so we don't depend on `path` for pure string ops.\n *\n * @param baseDir - Directory portion of the base path (POSIX separators)\n * @param rel - Relative path to resolve against `baseDir`\n * @returns Resolved path with `.` / `..` segments collapsed\n */\nfunction posixResolve(baseDir: string, rel: string): string {\n  const parts = `${baseDir}/${rel}`.split('/');\n  const stack: string[] = [];\n  for (const part of parts) {\n    if (part === '' || part === '.') continue;\n    if (part === '..') {\n      stack.pop();\n      continue;\n    }\n    stack.push(part);\n  }\n  return stack.join('/');\n}\n\n/**\n * Rewrite `[text](relative.md)` and `![alt](img.png)` links to GitHub URLs.\n *\n * @param md - Markdown source (may contain fenced code blocks, left untouched)\n * @param artifactRelPath - Repo-relative path of the artifact\n * @returns Markdown with every non-fence-local link rewritten\n */\nexport function rewriteLinks(md: string, artifactRelPath: string): string {\n  const lines = md.split('\\n');\n  let inFence = false;\n  for (let i = 0; i < lines.length; i++) {\n    const line = lines[i] ?? '';\n    if (/^\\s*(```+|~~~+)/.test(line)) {\n      inFence = !inFence;\n      continue;\n    }\n    if (inFence) continue;\n    lines[i] = rewriteLinksInLine(line, artifactRelPath);\n  }\n  return lines.join('\\n');\n}\n\n/**\n * Rewrite every `[text](target)` occurrence in a single non-fenced line.\n * Uses a manual scanner instead of a global regex to avoid catastrophic\n * backtracking on nested brackets.\n *\n * @param line - One line of Markdown, outside any fenced code block\n * @param artifactRelPath - Repo-relative path of the source artifact\n * @returns Line with every local `.md` target rewritten to a GitHub URL\n */\n/**\n * Attempt to parse a Markdown link starting at `line[index]`. Returns\n * `null` when no valid `[text](target)` / `![alt](target)` link is present.\n *\n * @param line - Source line being scanned\n * @param index - Zero-based index of the candidate `[` or `!`\n * @param artifactRelPath - Repo-relative path of the source artifact\n * @returns `{ replacement, nextIndex }` when a link was rewritten, else `null`\n */\nfunction tryParseLinkAt(\n  line: string,\n  index: number,\n  artifactRelPath: string\n): { replacement: string; nextIndex: number } | null {\n  const ch = line.charAt(index);\n  const isImage = ch === '!' && line.charAt(index + 1) === '[';\n  const isLink = ch === '[';\n  if (!isImage && !isLink) return null;\n  const start = isImage ? index + 1 : index;\n  const closeText = findMatchingBracket(line, start);\n  if (closeText === -1 || line.charAt(closeText + 1) !== '(') return null;\n  const openParen = closeText + 1;\n  const closeParen = findMatchingParen(line, openParen);\n  if (closeParen === -1) return null;\n  const label = line.slice(start, closeText + 1);\n  const rawTarget = line.slice(openParen + 1, closeParen).trim();\n  const { target, title } = splitTargetAndTitle(rawTarget);\n  const newTarget = resolveLink(target, artifactRelPath, isImage);\n  const replacement = (isImage ? '!' : '') + label + '(' + newTarget + title + ')';\n  return { replacement, nextIndex: closeParen + 1 };\n}\n\n/**\n * Rewrite every `[text](target)` occurrence in a single non-fenced line.\n * Uses a manual scanner instead of a global regex to avoid catastrophic\n * backtracking on nested brackets.\n *\n * @param line - One line of Markdown, outside any fenced code block\n * @param artifactRelPath - Repo-relative path of the source artifact\n * @returns Line with every local `.md` target rewritten to a GitHub URL\n */\nfunction rewriteLinksInLine(line: string, artifactRelPath: string): string {\n  let out = '';\n  let i = 0;\n  while (i < line.length) {\n    const parsed = tryParseLinkAt(line, i, artifactRelPath);\n    if (parsed) {\n      out += parsed.replacement;\n      i = parsed.nextIndex;\n      continue;\n    }\n    out += line.charAt(i);\n    i++;\n  }\n  return out;\n}\n\n/**\n * Split a raw Markdown link target into its URL and optional `\"title\"`\n * suffix. Uses a linear scanner instead of a regex to avoid catastrophic\n * backtracking on pathological input.\n *\n * @param raw - Raw contents between the parentheses of a Markdown link\n * @returns `{ target, title }` where `title` is `\"\"` when absent, or the\n *          leading whitespace + `\"...\"` suffix when present\n */\nfunction splitTargetAndTitle(raw: string): { target: string; title: string } {\n  let i = 0;\n  while (i < raw.length && !/\\s/.test(raw.charAt(i))) i++;\n  if (i === raw.length) return { target: raw, title: '' };\n  const target = raw.slice(0, i);\n  const rest = raw.slice(i);\n  // Accept only exactly-matched `\"...\"` title; otherwise treat whole thing\n  // as part of the target so we don't silently drop content.\n  const trimmed = rest.trimStart();\n  if (\n    trimmed.length >= 2 &&\n    trimmed.charAt(0) === '\"' &&\n    trimmed.charAt(trimmed.length - 1) === '\"'\n  ) {\n    return { target, title: rest };\n  }\n  return { target: raw, title: '' };\n}\n\n/**\n * Index of the matching `]` for a `[` at position `start`, or `-1` if none.\n *\n * @param line - Line being scanned\n * @param start - Zero-based index of the opening `[`\n * @returns Zero-based index of the matching `]`, or `-1`\n */\nfunction findMatchingBracket(line: string, start: number): number {\n  let depth = 0;\n  for (let i = start; i < line.length; i++) {\n    const ch = line.charAt(i);\n    if (ch === '\\\\') {\n      i++;\n      continue;\n    }\n    if (ch === '[') depth++;\n    else if (ch === ']') {\n      depth--;\n      if (depth === 0) return i;\n    }\n  }\n  return -1;\n}\n\n/**\n * Index of the matching `)` for a `(` at position `start`, or `-1` if none.\n *\n * @param line - Line being scanned\n * @param start - Zero-based index of the opening `(`\n * @returns Zero-based index of the matching `)`, or `-1`\n */\nfunction findMatchingParen(line: string, start: number): number {\n  let depth = 0;\n  for (let i = start; i < line.length; i++) {\n    const ch = line.charAt(i);\n    if (ch === '\\\\') {\n      i++;\n      continue;\n    }\n    if (ch === '(') depth++;\n    else if (ch === ')') {\n      depth--;\n      if (depth === 0) return i;\n    }\n  }\n  return -1;\n}\n\n/**\n * Deduplicate identical mermaid fence blocks by body hash. The caller owns\n * the `seen` Set so dedup state persists across artifacts in the same\n * aggregate.\n *\n * When a duplicate is found the fence is replaced with a single-line HTML\n * comment pointing at the earlier occurrence. Non-mermaid fences are left\n * untouched.\n *\n * @param md - Markdown source that may contain mermaid fences\n * @param seen - Shared set of mermaid-body hashes (caller-owned)\n * @returns `{ md, deduped }` — cleaned Markdown and count of replacements\n */\n/**\n * Scan forward from `start` to find the body and closing fence of a\n * mermaid block whose opening was detected on `lines[start - 1]`.\n *\n * @param lines - Source lines\n * @param start - Index of the first body line after the opening fence\n * @returns `{ body, closeIndex }` — body lines and index of the closing\n *          fence (or `lines.length` if no closing fence is present)\n */\nfunction scanMermaidBody(\n  lines: readonly string[],\n  start: number\n): { body: string[]; closeIndex: number } {\n  const body: string[] = [];\n  let j = start;\n  while (j < lines.length) {\n    const candidate = lines[j] ?? '';\n    if (/^\\s*```+\\s*$/.test(candidate)) break;\n    body.push(candidate);\n    j++;\n  }\n  return { body, closeIndex: j };\n}\n\n/**\n * Deduplicate identical mermaid fence blocks by body hash. The caller owns\n * the `seen` Set so dedup state persists across artifacts in the same\n * aggregate.\n *\n * When a duplicate is found the fence is replaced with a single-line HTML\n * comment pointing at the earlier occurrence. Non-mermaid fences are left\n * untouched.\n *\n * @param md - Markdown source that may contain mermaid fences\n * @param seen - Shared set of mermaid-body hashes (caller-owned)\n * @returns `{ md, deduped }` — cleaned Markdown and count of replacements\n */\nexport function dedupMermaid(md: string, seen: Set<string>): { md: string; deduped: number } {\n  const lines = md.split('\\n');\n  const out: string[] = [];\n  let deduped = 0;\n  let i = 0;\n  while (i < lines.length) {\n    const line = lines[i] ?? '';\n    if (!/^\\s*```+\\s*mermaid\\s*$/i.test(line)) {\n      out.push(line);\n      i++;\n      continue;\n    }\n    const { body, closeIndex } = scanMermaidBody(lines, i + 1);\n    const hash = hashString(body.join('\\n').trim());\n    if (seen.has(hash)) {\n      out.push(\n        `<!-- mermaid block deduplicated: identical to earlier occurrence (hash=${hash}) -->`\n      );\n      deduped++;\n    } else {\n      seen.add(hash);\n      out.push(line);\n      out.push(...body);\n      if (closeIndex < lines.length) out.push(lines[closeIndex] ?? '');\n    }\n    i = closeIndex + 1;\n  }\n  return { md: out.join('\\n'), deduped };\n}\n\n/**\n * 32-bit FNV-1a hash rendered as hex. Not cryptographic — used only to\n * identify identical mermaid bodies within one aggregate document. The\n * surface is entirely derived from committed repo content.\n *\n * @param input - String to hash\n * @returns 8-character lowercase hex digest\n */\nfunction hashString(input: string): string {\n  let h = 0x811c9dc5;\n  for (let i = 0; i < input.length; i++) {\n    h ^= input.charCodeAt(i);\n    h = Math.imul(h, 0x01000193);\n  }\n  return (h >>> 0).toString(16).padStart(8, '0');\n}\n\n/**\n * Pattern matching an operational metadata line at the start of an artifact.\n * Examples: `**Run:** breaking-run-123`, `**Window:** 2026-04-24 00:00Z — 05:49Z`.\n * The pattern requires the line to start with `**<Word>**` followed by a colon\n * or whitespace so ordinary bold prose is not mistakenly treated as metadata.\n */\nconst METADATA_LINE_PATTERN = /^\\*\\*[A-Za-z][^*\\n]*\\*\\*[:\\s]/;\n\n/**\n * Strip the operational metadata preamble that agent pipelines prepend to\n * artifacts. These are lines of the form `**Run:** …`, `**Window:** …`,\n * `**Methodology:** …`, etc., followed optionally by a standalone `---`\n * horizontal rule. They are agent-operational metadata that should not appear\n * in the published article.\n *\n * Algorithm:\n *  1. Skip leading blank lines (they don't count as metadata).\n *  2. If the first non-blank line does NOT match the metadata pattern, return\n *     the document unchanged (`lines: 0`).\n *  3. Otherwise consume all metadata lines and interspersed blank lines.\n *  4. If the next non-blank line is a standalone `---`, consume that too.\n *  5. Return the stripped Markdown and the count of lines removed.\n *\n * @param md - Markdown source (after banner/heading passes)\n * @returns `{ md, lines }` — stripped Markdown and number of lines removed\n */\nexport function stripArtifactMetadataPreamble(md: string): { md: string; lines: number } {\n  const lines = md.split('\\n');\n  let i = 0;\n\n  // Skip purely blank lines at the very head\n  while (i < lines.length && (lines[i] ?? '').trim() === '') i++;\n\n  // If the first real line is not a metadata line, return unchanged\n  if (i >= lines.length || !METADATA_LINE_PATTERN.test(lines[i] ?? '')) {\n    return { md, lines: 0 };\n  }\n\n  // Consume the metadata block (metadata lines + interspersed blank lines)\n  let metaEnd = i;\n  while (metaEnd < lines.length) {\n    const line = lines[metaEnd] ?? '';\n    if (METADATA_LINE_PATTERN.test(line) || line.trim() === '') {\n      metaEnd++;\n    } else {\n      break;\n    }\n  }\n\n  // If the next non-blank line is a standalone HR, absorb it\n  let scanAhead = metaEnd;\n  while (scanAhead < lines.length && (lines[scanAhead] ?? '').trim() === '') scanAhead++;\n  if (scanAhead < lines.length && /^\\s*---\\s*$/.test(lines[scanAhead] ?? '')) {\n    metaEnd = scanAhead + 1;\n  }\n\n  const removed = metaEnd;\n  const stripped = lines.slice(removed).join('\\n').replace(/^\\n+/, '');\n  return { md: stripped, lines: removed };\n}\n\n/**\n * Apply all cleanup passes and return the normalised Markdown plus\n * simple counters for telemetry/tests.\n *\n * @param source - Raw Markdown contents of the artifact file\n * @param options - Cleanup options (artifact path, shared mermaid dedup set)\n * @returns {@link CleanArtifactResult} with the normalised Markdown\n */\nexport function cleanArtifact(source: string, options: CleanArtifactOptions): CleanArtifactResult {\n  const seen = options.seenMermaidHashes ?? new Set<string>();\n  let md = stripFrontMatter(source);\n  md = stripSpdxTags(md).md;\n  const { md: mdAfterBanners, lines: strippedBannerLines } = stripBanners(md);\n  md = mdAfterBanners;\n  const { md: mdAfterHeadings, h1Count } = demoteHeadings(md);\n  md = mdAfterHeadings;\n  const { md: mdAfterMeta, lines: strippedMetaLines } = stripArtifactMetadataPreamble(md);\n  md = mdAfterMeta;\n  md = rewriteLinks(md, options.artifactRelPath);\n  const { md: mdAfterMermaid, deduped } = dedupMermaid(md, seen);\n  md = mdAfterMermaid;\n  // Collapse excessive blank lines to at most 2 consecutive blanks\n  md = md.replace(/\\n{3,}/g, '\\n\\n').trimEnd() + '\\n';\n  return {\n    markdown: md,\n    strippedH1s: h1Count,\n    strippedBannerLines,\n    strippedMetaLines,\n    dedupedMermaidBlocks: deduped,\n  };\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/cli/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/cli/parse.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/infra/github-urls.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/manifest/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/manifest/reader.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/manifest/resolver.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":87,"column":19,"endLine":87,"endColumn":29}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Aggregator/Manifest/Resolver\n * @description Pure resolution helpers over a parsed {@link Manifest}.\n * Consolidates the article-type precedence ladder (`articleType` →\n * `articleTypes[0]` → `runType`), the latest-gate-result lookup, and the\n * `manifest.files` flattener so they live in one bounded context instead of\n * being duplicated across `analysis-aggregator.ts` and `article-generator.ts`.\n */\n\nimport type { Manifest, ManifestFiles } from './types.js';\n\n/** Sentinel used when no schema variant supplies a usable article type. */\nexport const UNKNOWN_ARTICLE_TYPE = 'unknown';\n\n/**\n * Resolve the article-type slug from a manifest, tolerating legacy schemas.\n *\n * Resolution order (highest precedence first):\n *   1. `articleType` — canonical singular field\n *   2. `articleTypes[0]` — pre-aggregator-pipeline plural array\n *   3. `runType` — legacy field on older breaking-run manifests\n *\n * Falls back to `'unknown'` when none of the above is a non-empty string.\n *\n * @param manifest - Parsed manifest (any of the supported schemas)\n * @returns Article-type slug usable as a filename component\n */\nexport function resolveArticleType(manifest: Manifest): string {\n  if (typeof manifest.articleType === 'string' && manifest.articleType) {\n    return manifest.articleType;\n  }\n  const first = manifest.articleTypes?.[0];\n  if (typeof first === 'string' && first) {\n    return first;\n  }\n  if (typeof manifest.runType === 'string' && manifest.runType) {\n    return manifest.runType;\n  }\n  return UNKNOWN_ARTICLE_TYPE;\n}\n\n/**\n * Resolve the run-id from a manifest, falling back to a caller-provided\n * default (typically the run-directory basename) when the manifest carries\n * neither a string nor a numeric `runId`.\n *\n * @param manifest - Parsed manifest\n * @param fallback - Default returned when `runId` is missing or non-string\n * @returns Best-effort run identifier\n */\nexport function resolveRunId(manifest: Manifest, fallback: string): string {\n  if (typeof manifest.runId === 'string' && manifest.runId) {\n    return manifest.runId;\n  }\n  if (typeof manifest.runId === 'number') {\n    return String(manifest.runId);\n  }\n  return fallback;\n}\n\n/**\n * Resolve the ISO date for a manifest, accepting only a strictly-formed\n * `YYYY-MM-DD` value. Returns `undefined` when the manifest has no usable\n * date so callers can fall through to a path-based heuristic.\n *\n * @param manifest - Parsed manifest\n * @returns Strict ISO date or `undefined`\n */\nexport function resolveDate(manifest: Manifest): string | undefined {\n  const candidate = typeof manifest.date === 'string' ? manifest.date : '';\n  return /^\\d{4}-\\d{2}-\\d{2}$/.test(candidate) ? candidate : undefined;\n}\n\n/**\n * Pick the latest non-`PENDING` `gateResult` from `manifest.history[]`,\n * falling back to `'PENDING'` when no closed gate is recorded.\n *\n * @param manifest - Parsed manifest\n * @returns Latest non-PENDING gate result, or `'PENDING'`\n */\nexport function latestGateResult(manifest: Manifest): string {\n  const history = manifest.history ?? [];\n  for (let i = history.length - 1; i >= 0; i--) {\n    const entry = history[i];\n    const gr = entry?.gateResult;\n    if (gr && gr !== 'PENDING') return gr;\n  }\n  return 'PENDING';\n}\n\n/**\n * Extract every string entry from a single `files` value (which may be an\n * array of strings or a `path → description` object).\n *\n * @param value - One value from `Object.values(files)`\n * @returns Strings contained within, or `[]` when the shape is unknown\n */\nfunction extractFileEntries(value: unknown): string[] {\n  if (Array.isArray(value)) {\n    return value.filter((e): e is string => typeof e === 'string');\n  }\n  if (value && typeof value === 'object') {\n    return Object.keys(value as Record<string, unknown>);\n  }\n  return [];\n}\n\n/**\n * Normalise `manifest.files` into a flat list of `runRelPath` strings.\n *\n * De-duplicates while preserving first-seen order so callers downstream\n * (the aggregator's `availableSet`, `materialiseManifestFiles`, etc.)\n * never observe the same path twice when a manifest section accidentally\n * lists it under two top-level keys.\n *\n * @param files - Manifest `files` section (nested or flat)\n * @returns De-duplicated, first-seen-ordered list of run-relative artifact paths\n */\nexport function flattenManifestFiles(files: ManifestFiles | undefined): string[] {\n  if (!files) return [];\n  const seen = new Set<string>();\n  const out: string[] = [];\n  for (const value of Object.values(files)) {\n    for (const entry of extractFileEntries(value)) {\n      if (seen.has(entry)) continue;\n      seen.add(entry);\n      out.push(entry);\n    }\n  }\n  return out;\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/manifest/types.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/markdown-it-plugins.d.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/markdown-renderer.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":138,"column":19,"endLine":138,"endColumn":30},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":213,"column":19,"endLine":213,"endColumn":28},{"ruleId":"@typescript-eslint/prefer-optional-chain","severity":1,"message":"Prefer using an optional chain expression instead, as it's more concise and easier to read.","line":214,"column":9,"messageId":"preferOptionalChain","endLine":214,"endColumn":48,"fix":{"range":[8250,8289],"text":"token?.type !== 'heading_open'"}},{"ruleId":"@typescript-eslint/prefer-optional-chain","severity":1,"message":"Prefer using an optional chain expression instead, as it's more concise and easier to read.","line":219,"column":9,"messageId":"preferOptionalChain","endLine":219,"endColumn":44,"fix":{"range":[8554,8589],"text":"inline?.type !== 'inline'"}}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":2,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Aggregator/MarkdownRenderer\n * @description Markdown-to-HTML renderer for the aggregated article.\n *\n * Uses `markdown-it` with a focused plugin stack:\n *  - `markdown-it-anchor` — slugged `id`s on every heading\n *  - `markdown-it-footnote` — footnote reference support for artifacts\n *  - `markdown-it-attrs` — `{.class #id}` suffixes for table/fence styling\n *  - `markdown-it-deflist` — definition lists in stakeholder artifacts\n *\n * A custom fence override transforms ```` ```mermaid ```` blocks into\n * `<pre class=\"mermaid\" role=\"img\" aria-label=\"...\">…</pre>` so the\n * vendored client-side `mermaid.esm.min.mjs` (shipped under `js/vendor/`)\n * can progressively enhance them. No network calls, no inline script,\n * CSP `script-src 'self'` preserved.\n */\n\nimport MarkdownIt from 'markdown-it';\nimport anchor from 'markdown-it-anchor';\nimport footnote from 'markdown-it-footnote';\nimport attrs from 'markdown-it-attrs';\nimport deflist from 'markdown-it-deflist';\nimport type Token from 'markdown-it/lib/token.mjs';\n\n/** Options controlling {@link renderMarkdown}. */\nexport interface RenderOptions {\n  /**\n   * Optional accessible label builder for mermaid figures. Receives the\n   * zero-based mermaid block index and the raw mermaid source; returns\n   * the `aria-label` used on the wrapping `<figure>`. Defaults to\n   * `\"Mermaid diagram N\"`.\n   */\n  readonly mermaidLabel?: (index: number, body: string) => string;\n}\n\n/** Output from {@link renderMarkdown}. */\nexport interface RenderedMarkdown {\n  /** Full HTML body fragment (no `<html>` / `<head>` wrapper). */\n  readonly html: string;\n  /** Table-of-contents entries harvested from the heading stream. */\n  readonly toc: readonly TocEntry[];\n  /** Number of mermaid blocks rendered. */\n  readonly mermaidCount: number;\n}\n\n/** One entry in the generated table of contents. */\nexport interface TocEntry {\n  /** Heading level (2–6). */\n  readonly level: number;\n  /** Slugged id used as the fragment anchor. */\n  readonly slug: string;\n  /** Heading text (escaped for display). */\n  readonly text: string;\n}\n\n/**\n * Build a preconfigured markdown-it instance. Exposed so callers (e.g.\n * tests) can inspect plugin configuration without re-rendering.\n *\n * @returns Configured MarkdownIt instance with anchor, footnote, attrs,\n *          deflist, mermaid fence override, and table wrapping installed\n */\nexport function buildMarkdownIt(): MarkdownIt {\n  const md = new MarkdownIt({\n    html: true, // artifacts already contain hand-authored HTML wrappers\n    linkify: false, // avoid surprising auto-linking of plain text URLs\n    typographer: false, // keep exact punctuation\n    breaks: false,\n  });\n  md.use(anchor, {\n    level: [2, 3, 4, 5, 6],\n    permalink: anchor.permalink.headerLink({ safariReaderFix: true }),\n    slugify: slugify,\n  });\n  md.use(footnote);\n  md.use(attrs, { allowedAttributes: ['id', 'class'] });\n  md.use(deflist);\n  installMermaidFence(md);\n  installTableWrapper(md);\n  return md;\n}\n\n/**\n * Strip a leading YAML front matter block from a Markdown document. Generated\n * `article.md` files are Jekyll-compatible, but the deterministic HTML\n * renderer must render the body, not the metadata fence.\n *\n * @param markdown - Markdown with optional `---` front matter at byte 0\n * @returns Markdown body with the front matter removed\n */\nexport function stripMarkdownFrontMatter(markdown: string): string {\n  if (!markdown.startsWith('---\\n')) return markdown;\n  const end = markdown.indexOf('\\n---\\n', 4);\n  if (end === -1) return markdown;\n  return markdown.slice(end + 5).replace(/^\\n+/, '');\n}\n\n/**\n * Slugify a heading text into a stable URL fragment.\n *\n * @param text - Heading text (may contain unicode punctuation / marks)\n * @returns Slug of up to 80 ASCII-ish characters, with dashes as separators\n */\nexport function slugify(text: string): string {\n  return (\n    text\n      .toLowerCase()\n      .normalize('NFKD')\n      // Strip combining diacritical marks (Unicode range U+0300..U+036F)\n      .replace(/[\\u0300-\\u036F]/g, '')\n      // Strip general punctuation and supplemental punctuation\n      .replace(/[\\u2000-\\u206F]/g, '')\n      .replace(/[\\u2E00-\\u2E7F]/g, '')\n      .replace(/[^\\p{L}\\p{N}\\s-]/gu, '')\n      .replace(/\\s+/g, '-')\n      .replace(/-+/g, '-')\n      .replace(/^-|-$/g, '')\n      .slice(0, 80)\n  );\n}\n\n/**\n * Override the `fence` renderer so fenced `mermaid` blocks emit a\n * `<pre class=\"mermaid\">` wrapped in an accessible `<figure>`. Everything\n * else falls back to the default renderer.\n *\n * @param md - MarkdownIt instance to patch in-place\n */\nfunction installMermaidFence(md: MarkdownIt): void {\n  const defaultFence =\n    md.renderer.rules.fence ??\n    ((tokens, idx, opts, _env, self) => self.renderToken(tokens, idx, opts));\n  let mermaidIndex = 0;\n  md.renderer.rules.fence = (tokens, idx, opts, env, self) => {\n    const token = tokens[idx];\n    if (!token) return '';\n    const info = (token.info || '').trim().toLowerCase();\n    if (info === 'mermaid') {\n      const currentIndex = mermaidIndex++;\n      const env2 = env as { mermaidLabel?: RenderOptions['mermaidLabel'] };\n      const labelFn: RenderOptions['mermaidLabel'] =\n        env2.mermaidLabel ?? ((n) => `Mermaid diagram ${n + 1}`);\n      const label = md.utils.escapeHtml(labelFn(currentIndex, token.content));\n      const body = md.utils.escapeHtml(token.content);\n      return `<figure class=\"mermaid-figure\" role=\"img\" aria-label=\"${label}\">\\n<pre class=\"mermaid\">${body}</pre>\\n</figure>\\n`;\n    }\n    return defaultFence(tokens, idx, opts, env, self);\n  };\n}\n\n/**\n * Wrap every `<table>` in a `<div class=\"table-scroll\">` for responsive\n * horizontal overflow. The wrapper is announced as a region so assistive\n * tech can surface the focus/scroll behaviour.\n *\n * @param md - MarkdownIt instance to patch in-place\n */\nfunction installTableWrapper(md: MarkdownIt): void {\n  const defaultOpen =\n    md.renderer.rules.table_open ??\n    ((tokens, idx, opts, _env, self) => self.renderToken(tokens, idx, opts));\n  const defaultClose =\n    md.renderer.rules.table_close ??\n    ((tokens, idx, opts, _env, self) => self.renderToken(tokens, idx, opts));\n  md.renderer.rules.table_open = (tokens, idx, opts, env, self) =>\n    `<div class=\"table-scroll\" role=\"region\" tabindex=\"0\">${defaultOpen(tokens, idx, opts, env, self)}`;\n  md.renderer.rules.table_close = (tokens, idx, opts, env, self) =>\n    `${defaultClose(tokens, idx, opts, env, self)}</div>`;\n}\n\n/**\n * Render aggregated Markdown into a sanitised HTML body fragment.\n *\n * @param markdown - Aggregated Markdown source produced by the aggregator\n * @param options - Optional render hooks (e.g. custom mermaid aria-label)\n * @returns {@link RenderedMarkdown} with HTML, TOC, and mermaid count\n */\nexport function renderMarkdown(markdown: string, options: RenderOptions = {}): RenderedMarkdown {\n  const md = buildMarkdownIt();\n  const env: { mermaidLabel?: RenderOptions['mermaidLabel'] } = {};\n  if (options.mermaidLabel) env.mermaidLabel = options.mermaidLabel;\n  const tokens = md.parse(stripMarkdownFrontMatter(markdown), env);\n  const toc = harvestToc(tokens);\n  const html = escapeUppercasePlaceholders(md.renderer.render(tokens, md.options, env));\n  const mermaidCount = countMermaidTokens(tokens);\n  return { html, toc, mermaidCount };\n}\n\n/**\n * Escape non-HTML placeholder markers like `<N>` that appear in analysis prose.\n * Lower-case tags are intentionally left untouched because artifacts may embed\n * trusted HTML wrappers such as `<div>` and `<section>`.\n *\n * @param html - Rendered HTML fragment\n * @returns HTML fragment with uppercase placeholder pseudo-tags escaped\n */\nfunction escapeUppercasePlaceholders(html: string): string {\n  return html.replace(/<([A-Z][A-Z0-9_-]*)>/g, '&lt;$1&gt;');\n}\n\n/**\n * Walk the token stream and collect heading entries for the TOC.\n *\n * @param tokens - Token stream produced by MarkdownIt's parser\n * @returns Flat array of {@link TocEntry} items for H2–H6 headings\n */\nfunction harvestToc(tokens: readonly Token[]): TocEntry[] {\n  const out: TocEntry[] = [];\n  for (let i = 0; i < tokens.length; i++) {\n    const token = tokens[i];\n    if (!token || token.type !== 'heading_open') continue;\n    const level = Number.parseInt(token.tag.slice(1), 10);\n    if (!Number.isFinite(level) || level < 2 || level > 6) continue;\n    const slug = typeof token.attrGet === 'function' ? token.attrGet('id') : null;\n    const inline = tokens[i + 1];\n    if (!inline || inline.type !== 'inline') continue;\n    const text = (inline.content ?? '').trim();\n    out.push({ level, slug: slug ?? slugify(text), text });\n  }\n  return out;\n}\n\n/**\n * Count fence tokens whose info string starts with `mermaid`.\n *\n * @param tokens - Token stream produced by MarkdownIt's parser\n * @returns Number of mermaid fence tokens in the stream\n */\nfunction countMermaidTokens(tokens: readonly Token[]): number {\n  let n = 0;\n  for (const token of tokens) {\n    if (token.type === 'fence' && (token.info ?? '').trim().toLowerCase() === 'mermaid') n++;\n  }\n  return n;\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/runs/discover.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/runs/grouping.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/runs/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/slug/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/aggregator/slug/slug.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/constants/analysis-constants.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/constants/committee-indicator-map.ts","messages":[],"suppressedMessages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":1325,"column":10,"endLine":1325,"endColumn":42,"suppressions":[{"kind":"directive","justification":"key validated via Object.hasOwn"}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/constants/config.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/constants/language-articles.ts","messages":[],"suppressedMessages":[{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":40,"column":7,"endLine":40,"endColumn":22,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":44,"column":7,"endLine":44,"endColumn":28,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 16 times.","line":99,"column":7,"endLine":99,"endColumn":23,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":158,"column":7,"endLine":158,"endColumn":23,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":162,"column":7,"endLine":162,"endColumn":27,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":276,"column":7,"endLine":276,"endColumn":23,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":280,"column":7,"endLine":280,"endColumn":29,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 4 times.","line":281,"column":7,"endLine":281,"endColumn":21,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":335,"column":7,"endLine":335,"endColumn":21,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":339,"column":7,"endLine":339,"endColumn":31,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":394,"column":7,"endLine":394,"endColumn":27,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 4 times.","line":398,"column":7,"endLine":398,"endColumn":20,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":445,"column":7,"endLine":445,"endColumn":27,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 4 times.","line":449,"column":7,"endLine":449,"endColumn":20,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":496,"column":7,"endLine":496,"endColumn":21,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":500,"column":7,"endLine":500,"endColumn":27,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":555,"column":7,"endLine":555,"endColumn":26,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":557,"column":7,"endLine":557,"endColumn":24,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 8 times.","line":591,"column":7,"endLine":591,"endColumn":24,"suppressions":[{"kind":"directive","justification":"Localized keyword dictionaries have intentional repetition across categories"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 4 times.","line":1674,"column":26,"endLine":1674,"endColumn":44,"suppressions":[{"kind":"directive","justification":"Translated analysis strings share common terms across languages"}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 4 times.","line":1741,"column":27,"endLine":1741,"endColumn":46,"suppressions":[{"kind":"directive","justification":"Translated analysis strings share common terms across languages"}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/constants/language-core.ts","messages":[],"suppressedMessages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":84,"column":38,"endLine":84,"endColumn":47,"suppressions":[{"kind":"directive","justification":"key validated via Object.hasOwn"}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/constants/language-ui.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/constants/languages.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/news-indexes.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":102,"column":22,"endLine":102,"endColumn":48},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":209,"column":27,"endLine":209,"endColumn":46},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":362,"column":26,"endLine":362,"endColumn":39}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"#!/usr/bin/env node\n\n// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Generators/NewsIndexes\n * @description Generates index.html files for each language listing all news articles.\n * English is the primary homepage (index.html), other languages use index-{lang}.html.\n * Design follows riksdagsmonitor patterns: compact language switcher, Hack23 AB footer.\n */\n\nimport path, { resolve } from 'path';\nimport { pathToFileURL } from 'url';\nimport { PROJECT_ROOT, APP_VERSION, NEWS_DIR } from '../constants/config.js';\nimport {\n  ALL_LANGUAGES,\n  LANGUAGE_NAMES,\n  LANGUAGE_FLAGS,\n  PAGE_TITLES,\n  PAGE_DESCRIPTIONS,\n  SECTION_HEADINGS,\n  NO_ARTICLES_MESSAGES,\n  SKIP_LINK_TEXTS,\n  AI_SECTION_CONTENT,\n  FILTER_LABELS,\n  ARTICLE_TYPE_LABELS,\n  HEADER_SUBTITLE_LABELS,\n  getLocalizedString,\n  getTextDirection,\n} from '../constants/languages.js';\nimport { buildSiteFooter, buildSiteHeader } from '../templates/section-builders.js';\nimport {\n  getNewsArticles,\n  groupArticlesByLanguage,\n  formatSlug,\n  parseArticleFilename,\n  extractArticleMeta,\n  escapeHTML,\n  atomicWrite,\n} from '../utils/file-utils.js';\nimport { writeMetadataDatabase } from '../utils/news-metadata.js';\nimport { detectCategory } from '../utils/article-category.js';\nimport type {\n  ParsedArticle,\n  ArticleCategoryLabels,\n  ArticleCategory,\n  LanguageCode,\n} from '../types/index.js';\n\n/**\n * Get the index filename for a given language code.\n * English uses index.html (the primary homepage), others use index-{lang}.html.\n *\n * @param lang - Language code\n * @returns Filename string\n */\nexport function getIndexFilename(lang: string): string {\n  return lang === 'en' ? 'index.html' : `index-${lang}.html`;\n}\n\n/**\n * Build the compact language switcher nav HTML.\n * Uses flag emoji + language code, riksdagsmonitor style.\n *\n * @param currentLang - Active language code\n * @returns HTML string\n */\nfunction buildLangSwitcher(currentLang: string): string {\n  return ALL_LANGUAGES.map((code) => {\n    const flag = getLocalizedString(LANGUAGE_FLAGS, code);\n    const name = getLocalizedString(LANGUAGE_NAMES, code);\n    const active = code === currentLang ? ' active' : '';\n    const href = getIndexFilename(code);\n    const current = code === currentLang ? ' aria-current=\"page\"' : '';\n    const safeHref = escapeHTML(href);\n    const safeCode = escapeHTML(code);\n    const safeName = escapeHTML(name);\n    return `<a href=\"${safeHref}\" class=\"lang-link${active}\" hreflang=\"${safeCode}\" lang=\"${safeCode}\" title=\"${safeName}\" aria-label=\"${safeName}\"${current}>${flag} ${code.toUpperCase()}</a>`;\n  }).join('\\n        ');\n}\n\n/**\n * Render a single news card element.\n *\n * @param article - Parsed article data\n * @param meta - Real title and description extracted from the article HTML\n * @param meta.title - Article title\n * @param meta.description - Article description/excerpt\n * @param categoryLabels - Optional localized article category labels\n * @returns HTML string for one card\n */\nfunction renderCard(\n  article: ParsedArticle,\n  meta: { title: string; description: string },\n  categoryLabels?: ArticleCategoryLabels\n): string {\n  const category = detectCategory(article.slug);\n  // Sanitize the category for safe use in CSS class names (allow only alphanumeric and hyphens)\n  const safeCategory = String(category).replace(/[^a-z0-9-]/gi, '');\n  const title = escapeHTML(meta.title || formatSlug(article.slug));\n  const badgeLabel = categoryLabels?.[category] ?? formatSlug(safeCategory);\n  const excerpt = meta.description\n    ? `\\n            <p class=\"news-card__excerpt\">${escapeHTML(meta.description)}</p>`\n    : '';\n\n  return `\n      <li class=\"news-card\">\n        <a href=\"news/${escapeHTML(article.filename)}\" class=\"news-card__link\" lang=\"${escapeHTML(article.lang)}\" hreflang=\"${escapeHTML(article.lang)}\">\n          <div class=\"news-card__accent news-card__accent--${safeCategory}\"></div>\n          <div class=\"news-card__body\">\n            <div class=\"news-card__meta\">\n              <span class=\"news-card__badge news-card__badge--${safeCategory}\">${escapeHTML(badgeLabel)}</span>\n              <time class=\"news-card__date\" datetime=\"${escapeHTML(article.date)}\">${escapeHTML(article.date)}</time>\n            </div>\n            <h3 class=\"news-card__title\">${title}</h3>${excerpt}\n          </div>\n        </a>\n      </li>`;\n}\n\n/**\n * Build hreflang alternate link tags for SEO multi-language support.\n *\n * @returns HTML string of link elements\n */\nfunction buildHreflangTags(): string {\n  const links = ALL_LANGUAGES.map((code) => {\n    const href = getIndexFilename(code);\n    return `<link rel=\"alternate\" hreflang=\"${code}\" href=\"${href}\">`;\n  });\n  links.push('<link rel=\"alternate\" hreflang=\"x-default\" href=\"index.html\">');\n  return links.join('\\n  ');\n}\n\n/**\n * Generate index HTML for a language.\n *\n * Produces a complete, standards-compliant HTML5 page with:\n * - Sticky header with EU branding\n * - Compact language switcher with flag + code\n * - Hero section with page title and description\n * - Responsive card grid for news articles\n * - Accessible empty state when no articles exist\n * - Hack23 AB multi-section footer (About, Quick Links, Built by Hack23, Languages)\n *\n * @param lang - Language code\n * @param articles - Articles for this language\n * @param metaMap - Map of article filename to real title and description\n * @returns Complete HTML document\n */\nexport function generateIndexHTML(\n  lang: string,\n  articles: ParsedArticle[],\n  metaMap: Map<string, { title: string; description: string }> = new Map()\n): string {\n  const title = getLocalizedString(PAGE_TITLES, lang);\n  const description = getLocalizedString(PAGE_DESCRIPTIONS, lang);\n  const heading = getLocalizedString(SECTION_HEADINGS, lang);\n  const noArticlesText = getLocalizedString(NO_ARTICLES_MESSAGES, lang);\n  const skipLinkText = getLocalizedString(SKIP_LINK_TEXTS, lang);\n  const dir = getTextDirection(lang);\n  const selfHref = getIndexFilename(lang);\n  const heroTitle = title.split(' - ')[0] ?? 'EU Parliament Monitor';\n  const filterLabels = getLocalizedString(FILTER_LABELS, lang) as { all: string; search: string };\n  const categoryLabels = getLocalizedString(ARTICLE_TYPE_LABELS, lang) as ArticleCategoryLabels;\n\n  // Collect distinct categories from the current article set\n  const usedCategories = new Set<ArticleCategory>();\n  for (const a of articles) {\n    usedCategories.add(detectCategory(a.slug));\n  }\n\n  const content =\n    articles.length === 0\n      ? `\n    <div class=\"empty-state\">\n      <div class=\"empty-state__icon\" aria-hidden=\"true\">📰</div>\n      <p class=\"empty-state__text\">${noArticlesText}</p>\n    </div>`\n      : `\n    <ul class=\"news-grid\" role=\"list\">\n      ${articles\n        .map((a) =>\n          renderCard(\n            a,\n            metaMap.get(a.filename) ?? { title: formatSlug(a.slug), description: '' },\n            categoryLabels\n          )\n        )\n        .join('\\n')}\n    </ul>`;\n\n  const ai = getLocalizedString(AI_SECTION_CONTENT, lang);\n\n  // Build filter buttons from used categories (with article count)\n  const categoryCounts = new Map<ArticleCategory, number>();\n  for (const a of articles) {\n    const cat = detectCategory(a.slug);\n    categoryCounts.set(cat, (categoryCounts.get(cat) ?? 0) + 1);\n  }\n\n  const filterButtons =\n    articles.length > 0\n      ? Array.from(usedCategories)\n          .sort()\n          .map((cat) => {\n            const safeCat = String(cat).replace(/[^a-z0-9-]/gi, '');\n            const label = categoryLabels[cat] ?? formatSlug(safeCat);\n            const count = categoryCounts.get(cat) ?? 0;\n            return `<button type=\"button\" class=\"filter-btn\" data-category=\"${safeCat}\">${escapeHTML(label)}<span class=\"filter-btn__count\">${count}</span></button>`;\n          })\n          .join('\\n          ')\n      : '';\n\n  const canonicalUrl = `https://hack23.github.io/euparliamentmonitor/${selfHref}`;\n  const header = buildSiteHeader({\n    lang: lang as LanguageCode,\n    pathPrefix: '',\n    homeHref: selfHref,\n    siteTitle: heroTitle,\n    languageSwitcherHtml: buildLangSwitcher(lang),\n  });\n\n  return `<!DOCTYPE html>\n<html lang=\"${lang}\" dir=\"${dir}\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <meta http-equiv=\"X-Content-Type-Options\" content=\"nosniff\">\n  <meta name=\"referrer\" content=\"no-referrer\">\n  <meta name=\"generator\" content=\"EU Parliament Monitor v${escapeHTML(APP_VERSION)}\">\n  <title>${title}</title>\n  <meta name=\"description\" content=\"${description}\">\n  <link rel=\"canonical\" href=\"${canonicalUrl}\">\n  <meta property=\"og:type\" content=\"website\">\n  <meta property=\"og:title\" content=\"${heroTitle}\">\n  <meta property=\"og:description\" content=\"${description}\">\n  <meta property=\"og:url\" content=\"${canonicalUrl}\">\n  <meta property=\"og:site_name\" content=\"EU Parliament Monitor\">\n  <meta property=\"og:locale\" content=\"${lang}\">\n  <meta property=\"og:image\" content=\"https://hack23.github.io/euparliamentmonitor/images/og-image.jpg\">\n  <meta property=\"og:image:width\" content=\"1200\">\n  <meta property=\"og:image:height\" content=\"630\">\n  <meta property=\"og:image:alt\" content=\"EU Parliament Monitor — AI-Disrupted Parliamentary Intelligence\">\n  <meta name=\"twitter:card\" content=\"summary_large_image\">\n  <meta name=\"twitter:title\" content=\"${heroTitle}\">\n  <meta name=\"twitter:description\" content=\"${description}\">\n  <meta name=\"twitter:image\" content=\"https://hack23.github.io/euparliamentmonitor/images/og-image.jpg\">\n  <meta name=\"twitter:image:alt\" content=\"EU Parliament Monitor — AI-Disrupted Parliamentary Intelligence\">\n  ${buildHreflangTags()}\n  <!-- Favicons -->\n  <link rel=\"icon\" type=\"image/x-icon\" href=\"favicon.ico\">\n  <link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"images/favicon-32x32.png\">\n  <link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"images/favicon-16x16.png\">\n  <link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"images/apple-touch-icon.png\">\n  <link rel=\"manifest\" href=\"site.webmanifest\">\n  <meta name=\"theme-color\" content=\"#003399\">\n  <link rel=\"alternate\" type=\"application/rss+xml\" title=\"EU Parliament Monitor RSS\" href=\"rss.xml\">\n  <link rel=\"stylesheet\" href=\"styles.css\">\n</head>\n<body>\n  <a href=\"#main\" class=\"skip-link\">${skipLinkText}</a>\n\n  ${header}\n\n  <section class=\"hero\">\n    <div class=\"hero__inner\">\n      <div class=\"hero__content\">\n        <p class=\"hero__kicker\">${escapeHTML(getLocalizedString(HEADER_SUBTITLE_LABELS, lang))}</p>\n        <h1 class=\"hero__title\">${heroTitle}</h1>\n        <p class=\"hero__description\">${description}</p>\n      </div>\n      <picture class=\"hero__banner\">\n        <source srcset=\"images/banner.webp\" type=\"image/webp\">\n        <img src=\"images/banner.jpg\" alt=\"EU Parliament Monitor — AI-Disrupted Parliamentary Intelligence\" class=\"hero__banner-img\" width=\"1200\" height=\"400\" loading=\"eager\">\n      </picture>\n    </div>\n  </section>\n\n  <main id=\"main\" class=\"site-main\">\n    <h2 class=\"section-heading\"><span class=\"section-heading__icon\" aria-hidden=\"true\">📋</span> ${heading}</h2>${\n      articles.length > 0\n        ? `\n    <div class=\"filter-toolbar\" role=\"toolbar\" aria-label=\"Filter articles\">\n      <div class=\"filter-buttons\">\n        <button type=\"button\" class=\"filter-btn active\" data-category=\"all\">${escapeHTML(filterLabels.all)}<span class=\"filter-btn__count\">${articles.length}</span></button>\n        ${filterButtons}\n      </div>\n      <div class=\"filter-search\">\n        <input type=\"search\" class=\"filter-search__input\" placeholder=\"${escapeHTML(filterLabels.search)}\" aria-label=\"${escapeHTML(filterLabels.search)}\">\n      </div>\n    </div>`\n        : ''\n    }\n    ${content}\n  </main>\n\n  <section class=\"ai-intelligence\" aria-labelledby=\"ai-heading\">\n    <h2 id=\"ai-heading\"><span aria-hidden=\"true\">🤖</span> ${escapeHTML(ai.heading)}</h2>\n    <blockquote class=\"ai-intelligence__quote\">${escapeHTML(ai.quote)}</blockquote>\n    <p>${escapeHTML(ai.description)}</p>\n    <ul class=\"ai-intelligence__features\">\n      <li><strong>${escapeHTML(ai.featureAgents)}</strong> &mdash; ${escapeHTML(ai.featureAgentsDesc)}</li>\n      <li><strong>${escapeHTML(ai.featureSchedule)}</strong> &mdash; ${escapeHTML(ai.featureScheduleDesc)}</li>\n      <li><strong>${escapeHTML(ai.featureHuman)}</strong> &mdash; ${escapeHTML(ai.featureHumanDesc)}</li>\n      <li><strong>${escapeHTML(ai.featureData)}</strong> &mdash; ${escapeHTML(ai.featureDataDesc)}</li>\n    </ul>\n  </section>\n\n  ${buildSiteFooter({ lang: lang as LanguageCode, pathPrefix: '', articleCount: articles.length })}\n\n  <script src=\"js/index-runtime.js\" defer></script>\n</body>\n</html>`;\n}\n\n/**\n * Main execution - generates index files for all languages.\n * English generates index.html (primary homepage), others generate index-{lang}.html.\n */\nfunction main(): void {\n  console.log('📰 Generating news indexes...');\n\n  const articles = getNewsArticles();\n  console.log(`📊 Found ${articles.length} articles`);\n\n  const grouped = groupArticlesByLanguage(articles, ALL_LANGUAGES);\n\n  // Build metadata map (real titles + descriptions from each article HTML)\n  const metaBuildTimerLabel = `⏱️ Built metadata map for ${articles.length} articles`;\n  console.time(metaBuildTimerLabel);\n  const metaMap = new Map<string, { title: string; description: string }>();\n  for (const filename of articles) {\n    const filepath = path.join(NEWS_DIR, filename);\n    metaMap.set(filename, extractArticleMeta(filepath));\n  }\n  console.timeEnd(metaBuildTimerLabel);\n\n  // Also update the metadata database, reusing the already-extracted meta to avoid re-reading files\n  const dbArticles = articles\n    .map((filename) => {\n      const parsed = parseArticleFilename(filename);\n      if (!parsed) return null;\n      const meta = metaMap.get(filename) ?? { title: '', description: '' };\n      return {\n        filename: parsed.filename,\n        date: parsed.date,\n        slug: parsed.slug,\n        lang: parsed.lang,\n        title: meta.title || formatSlug(parsed.slug),\n        description: meta.description,\n      };\n    })\n    .filter((e): e is NonNullable<typeof e> => e !== null);\n  dbArticles.sort((a, b) => b.date.localeCompare(a.date));\n  writeMetadataDatabase({ lastUpdated: new Date().toISOString(), articles: dbArticles });\n  console.log('📝 Updated articles metadata database');\n\n  let generated = 0;\n  for (const lang of ALL_LANGUAGES) {\n    const langArticles = grouped[lang] ?? [];\n    const html = generateIndexHTML(lang, langArticles, metaMap);\n    const filename = getIndexFilename(lang);\n    const filepath = path.join(PROJECT_ROOT, filename);\n\n    atomicWrite(filepath, html);\n    console.log(`  ✅ Generated ${filename} (${langArticles.length} articles)`);\n    generated++;\n  }\n\n  console.log(`✅ Generated ${generated} index files`);\n}\n\n// Only run main when executed directly (not when imported)\nif (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {\n  main();\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence-descriptions.ts","messages":[{"ruleId":null,"message":"Unused eslint-disable directive (no problems were reported from 'security/detect-object-injection').","line":2179,"column":3,"severity":1,"fix":{"range":[102991,103051],"text":" "}},{"ruleId":null,"message":"Unused eslint-disable directive (no problems were reported from 'security/detect-object-injection').","line":2192,"column":3,"severity":1,"fix":{"range":[103514,103574],"text":" "}},{"ruleId":null,"message":"Unused eslint-disable directive (no problems were reported from 'security/detect-object-injection').","line":3179,"column":5,"severity":1,"fix":{"range":[166147,166207],"text":" "}}],"suppressedMessages":[{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":771,"column":9,"endLine":771,"endColumn":29,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":1003,"column":9,"endLine":1003,"endColumn":31,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":1652,"column":9,"endLine":1652,"endColumn":45,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":2107,"column":10,"endLine":2107,"endColumn":22,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":2125,"column":20,"endLine":2125,"endColumn":47,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2154,"column":17,"endLine":2154,"endColumn":42,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":2157,"column":23,"endLine":2157,"endColumn":41,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2222,"column":22,"endLine":2222,"endColumn":41,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2225,"column":23,"endLine":2225,"endColumn":39,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2231,"column":21,"endLine":2231,"endColumn":46,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":2234,"column":23,"endLine":2234,"endColumn":50,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":2252,"column":3,"endLine":2252,"endColumn":19,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":2254,"column":3,"endLine":2254,"endColumn":20,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":2260,"column":3,"endLine":2260,"endColumn":22,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2700,"column":25,"endLine":2700,"endColumn":49,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2727,"column":25,"endLine":2727,"endColumn":46,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2729,"column":24,"endLine":2729,"endColumn":51,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 5 times.","line":2767,"column":27,"endLine":2767,"endColumn":47,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 6 times.","line":2770,"column":36,"endLine":2770,"endColumn":53,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":2776,"column":34,"endLine":2776,"endColumn":51,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 7 times.","line":2781,"column":28,"endLine":2781,"endColumn":53,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 3 times.","line":2787,"column":29,"endLine":2787,"endColumn":49,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"sonarjs/no-duplicate-string","severity":2,"message":"Define a constant instead of duplicating this literal 5 times.","line":2801,"column":39,"endLine":2801,"endColumn":56,"suppressions":[{"kind":"directive","justification":"Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder."}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":2830,"column":21,"endLine":2830,"endColumn":32,"suppressions":[{"kind":"directive","justification":""}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":3197,"column":20,"endLine":3197,"endColumn":51,"suppressions":[{"kind":"directive","justification":""}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":3,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Generators/PoliticalIntelligenceDescriptions\n * @description Curated per-file descriptions for the political-intelligence\n * index page. Replaces the fragile first-paragraph extraction from Markdown\n * source files (which leaked document-owner metadata and `---` separators\n * into the rendered UI) with hand-written, high-quality descriptions keyed\n * by the repository-relative file path.\n *\n * Each entry ships with:\n * - a **canonical English description** (`description`) used as the fallback\n *   only when the caller requests English (`lang === 'en'`);\n * - an optional **per-language overlay** (`i18n`) mapping a subset of the 14\n *   supported language codes to a localized rendering of the same meaning.\n *\n * Non-English callers never receive the raw English `description` as a\n * fallback — {@link getCuratedDescription} synthesizes a localized sentence\n * from the localized title and the localized \"kind\" word (methodology,\n * template, reference, …) so every card on a non-English page reads\n * naturally in that language.\n *\n * Unmapped files fall back to a generic localized phrase built from the\n * file's display title — see {@link buildGenericFallback}.\n */\n\nimport type { LanguageCode } from '../types/index.js';\n\n/** Per-language text overlay keyed by 2-letter language code. */\nexport type TextI18n = Partial<Record<LanguageCode, string>>;\n\n/**\n * @deprecated use {@link TextI18n}. Kept as an alias so consumers outside\n * this module don't break across the title-localization refactor.\n */\nexport type DescriptionI18n = TextI18n;\n\n/** One curated entry for a methodology / template / reference file. */\nexport interface CuratedDescription {\n  /** Canonical English title shown on the card heading and used as the\n   *  fallback when a language-specific title is not provided.\n   *\n   *  Leave empty to keep the H1-extracted title from the source Markdown\n   *  file (useful for files whose H1 already reads well as a card title). */\n  readonly title?: string;\n  /** Optional per-language title overrides. English fallback (or the curated\n   *  `title` field) is used for missing keys. */\n  readonly titleI18n?: TextI18n;\n  /** Canonical English description. */\n  readonly description: string;\n  /** Optional per-language description overrides. English fallback is used\n   *  for missing keys. */\n  readonly i18n?: TextI18n;\n}\n\n/**\n * Curated descriptions keyed by the repository-relative file path.\n * Descriptions are concise (≤ ~220 chars), factual, and describe the\n * methodology / template's *purpose* — not its metadata block.\n *\n * Where a per-language translation is not provided, readers see the\n * English canonical description. The localized \"source materials are in\n * English\" note at the top of the page acknowledges this.\n */\nexport const CURATED_DESCRIPTIONS: Readonly<Record<string, CuratedDescription>> = {\n  // ========================================================================\n  // Methodologies\n  // ========================================================================\n  'analysis/methodologies/README.md': {\n    description:\n      'Index of every analytical tradecraft guide used by EU Parliament Monitor — the entry point for the full methodology library.',\n    i18n: {\n      sv: 'Index över varje analytisk tradecraft-guide som används av EU Parliament Monitor — ingången till hela metodologibiblioteket.',\n      da: 'Indeks over hver analytisk tradecraft-guide brugt af EU Parliament Monitor — indgangen til hele metodebiblioteket.',\n      no: 'Indeks over hver analytisk tradecraft-guide brukt av EU Parliament Monitor — inngangen til hele metodebiblioteket.',\n      fi: 'Luettelo jokaisesta EU Parliament Monitorin käyttämästä analyyttisestä tradecraft-oppaasta — koko metodologiakirjaston sisäänkäynti.',\n      de: 'Index jeder analytischen Tradecraft-Anleitung, die EU Parliament Monitor verwendet — der Einstieg in die gesamte Methodologie-Bibliothek.',\n      fr: 'Index de chaque guide de savoir-faire analytique utilisé par EU Parliament Monitor — le point d’entrée de la bibliothèque complète de méthodologies.',\n      es: 'Índice de cada guía de oficio analítico utilizada por EU Parliament Monitor — punto de entrada a toda la biblioteca de metodologías.',\n      nl: 'Index van elke analytische vakgids die EU Parliament Monitor gebruikt — het startpunt voor de volledige methodologiebibliotheek.',\n      ar: 'فهرس كل دليل حرفي تحليلي يستخدمه مرصد البرلمان الأوروبي — نقطة الدخول إلى مكتبة المنهجيات الكاملة.',\n      he: 'אינדקס של כל מדריך מלאכה אנליטי שבו משתמש EU Parliament Monitor — שער הכניסה לספריית המתודולוגיות המלאה.',\n      ja: 'EU Parliament Monitor が使用するすべての分析トレードクラフトガイドの目次 — 方法論ライブラリ全体への入口。',\n      ko: 'EU Parliament Monitor가 사용하는 모든 분석 트레이드크래프트 가이드의 색인 — 전체 방법론 라이브러리의 진입점.',\n      zh: 'EU Parliament Monitor 使用的每一份分析工艺指南的索引 — 进入完整方法论库的入口。',\n    },\n  },\n  'analysis/methodologies/ai-driven-analysis-guide.md': {\n    description:\n      'The canonical 10-step AI-driven analysis protocol followed by every agentic workflow — Rules 1–22 plus Step 10.5 methodology reflection, with positive voice and colour-coded Mermaid diagrams.',\n    i18n: {\n      sv: 'Det kanoniska 10-stegs AI-drivna analysprotokollet som följs av alla agentiska arbetsflöden — Regler 1–22 plus Steg 10.5 metodologireflektion, med positivt tonläge och färgkodade Mermaid-diagram.',\n      da: 'Den kanoniske 10-trins AI-drevne analyseprotokol, som alle agentiske arbejdsgange følger — Regler 1-22 plus Trin 10.5 metoderefleksion, med positivt tonefald og farvekodede Mermaid-diagrammer.',\n      no: 'Den kanoniske 10-stegs AI-drevne analyseprotokollen som alle agentiske arbeidsflyter følger — Regler 1-22 pluss Steg 10.5 metoderefleksjon, med positiv tone og fargekodede Mermaid-diagrammer.',\n      fi: 'Kanoninen 10-vaiheinen tekoälypohjainen analyysiprotokolla, jota jokainen agenttinen työnkulku noudattaa — säännöt 1–22 ja vaihe 10.5 metodologian reflektio, myönteinen sävy ja väri­koodatut Mermaid-kaaviot.',\n      de: 'Das kanonische 10-Schritt-KI-gesteuerte Analyseprotokoll, dem jeder agentische Workflow folgt — Regeln 1–22 plus Schritt 10.5 Methodologie-Reflexion, mit positiver Tonlage und farbcodierten Mermaid-Diagrammen.',\n      fr: 'Le protocole canonique d’analyse pilotée par IA en 10 étapes suivi par chaque workflow agentique — Règles 1–22 plus Étape 10.5 de réflexion méthodologique, avec voix positive et diagrammes Mermaid codés par couleur.',\n      es: 'El protocolo canónico de análisis impulsado por IA en 10 pasos que sigue cada flujo de trabajo agéntico — Reglas 1–22 más Paso 10.5 de reflexión metodológica, con voz positiva y diagramas Mermaid codificados por color.',\n      nl: 'Het canonieke 10-staps AI-gedreven analyseprotocol dat elke agentische workflow volgt — Regels 1–22 plus Stap 10.5 methodologiereflectie, met positieve toon en kleurgecodeerde Mermaid-diagrammen.',\n      ar: 'بروتوكول التحليل الكنسي المدفوع بالذكاء الاصطناعي من 10 خطوات الذي تتبعه كل سير عمل وكيلي — القواعد 1–22 والخطوة 10.5 للتأمل المنهجي، بنبرة إيجابية ومخططات Mermaid مرمزة بالألوان.',\n      he: 'הפרוטוקול הקנוני בן 10 השלבים לניתוח מבוסס בינה מלאכותית שכל זרימת עבודה אג׳נטית עוקבת אחריו — חוקים 1–22 ושלב 10.5 להתבוננות מתודולוגית, בטון חיובי ותרשימי Mermaid מקודדים בצבע.',\n      ja: 'すべてのエージェント型ワークフローが従う正典的な 10 ステップ AI 駆動分析プロトコル — ルール 1〜22 とステップ 10.5 の方法論的振り返りを、肯定的な語調と色分け Mermaid 図で提供。',\n      ko: '모든 에이전트 워크플로가 따르는 표준 10단계 AI 기반 분석 프로토콜 — 규칙 1–22 및 단계 10.5 방법론 성찰을 긍정적 어조와 색상 코드 Mermaid 다이어그램으로 제공.',\n      zh: '所有代理式工作流遵循的权威 10 步 AI 驱动分析协议 — 规则 1–22 及第 10.5 步方法论反思，采用积极语气和彩色编码的 Mermaid 图表。',\n    },\n  },\n  'analysis/methodologies/artifact-catalog.md': {\n    description:\n      'Master catalog of the 39 analysis artifacts produced by every article-generating workflow — mapping each artifact to its methodology, template, depth floor, and Mermaid diagram type.',\n    i18n: {\n      sv: 'Huvudkatalog över de 39 analysartefakter som varje artikelgenererande arbetsflöde producerar — kopplar varje artefakt till metodologi, mall, djupgolv och Mermaid-diagramtyp.',\n      de: 'Hauptkatalog der 39 Analyse-Artefakte, die von jedem artikelerzeugenden Workflow produziert werden — ordnet jedes Artefakt seiner Methodologie, Vorlage, Tiefenuntergrenze und Mermaid-Diagrammart zu.',\n      fr: 'Catalogue maître des 39 artefacts d’analyse produits par chaque workflow générateur d’articles — associant chaque artefact à sa méthodologie, son modèle, son seuil de profondeur et son type de diagramme Mermaid.',\n      es: 'Catálogo maestro de los 39 artefactos de análisis producidos por cada flujo de trabajo generador de artículos — mapea cada artefacto con su metodología, plantilla, umbral de profundidad y tipo de diagrama Mermaid.',\n      ja: '記事生成ワークフローが生成する 39 の分析成果物のマスターカタログ — 各成果物を方法論・テンプレート・深さ下限・Mermaid 図タイプにマッピング。',\n      ko: '모든 기사 생성 워크플로가 생성하는 39개 분석 산출물의 마스터 카탈로그 — 각 산출물을 방법론·템플릿·깊이 하한·Mermaid 다이어그램 유형에 매핑.',\n      zh: '每个生成文章的工作流产生的 39 个分析产物的主目录 — 将每个产物映射到其方法论、模板、深度下限和 Mermaid 图表类型。',\n    },\n  },\n  'analysis/methodologies/electoral-domain-methodology.md': {\n    description:\n      'Methodology for EU-wide electoral analysis — forecasting, coalition mathematics at the EP (361-seat threshold) and member-state level, and voter-segmentation frameworks.',\n    i18n: {\n      sv: 'Metodologi för EU-omfattande valanalys — prognoser, koalitionsmatematik vid EP-tröskeln på 361 platser och på medlemsstatsnivå, samt ramverk för väljarsegmentering.',\n      de: 'Methodologie für EU-weite Wahlanalysen — Prognosen, Koalitionsmathematik an der 361-Sitze-Schwelle des EP und auf Mitgliedstaatsebene sowie Wählersegmentierungs-Rahmenwerke.',\n      fr: 'Méthodologie pour l’analyse électorale à l’échelle de l’UE — prévisions, mathématiques de coalition au seuil de 361 sièges du PE et au niveau des États membres, et cadres de segmentation des électeurs.',\n      es: 'Metodología para análisis electoral a escala de la UE — pronósticos, matemáticas de coalición en el umbral de 361 escaños del PE y a nivel de Estados miembros, y marcos de segmentación de votantes.',\n      ja: 'EU 全域の選挙分析の方法論 — 予測、EP の 361 議席閾値および加盟国レベルでの連立数学、有権者セグメンテーション枠組み。',\n      ko: 'EU 전역 선거 분석 방법론 — 예측, 유럽의회 361석 임계값 및 회원국 차원의 연정 수학, 유권자 세분화 프레임워크.',\n      zh: '欧盟范围选举分析方法论 — 预测、欧洲议会 361 席阈值及成员国层面的联盟数学，以及选民分群框架。',\n    },\n  },\n  'analysis/methodologies/imf-indicator-mapping.md': {\n    description:\n      'Canonical mapping of IMF WEO, Fiscal Monitor, IFS, BOP, ER and PCPS indicators to European Parliament Monitor article types — the primary source for economic, monetary, fiscal, trade and FDI context.',\n    i18n: {\n      sv: 'Kanonisk mappning av IMF:s indikatorer (WEO, Fiscal Monitor, IFS, BOP, ER, PCPS) till artikeltyper i EU Parliament Monitor — den primära källan för ekonomisk, monetär, finanspolitisk, handels- och FDI-kontext.',\n      de: 'Kanonische Zuordnung der IWF-Indikatoren (WEO, Fiscal Monitor, IFS, BOP, ER, PCPS) zu Artikeltypen von EU Parliament Monitor — die primäre Quelle für wirtschaftlichen, monetären, fiskalischen, Handels- und FDI-Kontext.',\n      fr: 'Mise en correspondance canonique des indicateurs du FMI (WEO, Fiscal Monitor, IFS, BOP, ER, PCPS) avec les types d’articles d’EU Parliament Monitor — source principale pour le contexte économique, monétaire, budgétaire, commercial et IDE.',\n      es: 'Mapeo canónico de los indicadores del FMI (WEO, Fiscal Monitor, IFS, BOP, ER, PCPS) a los tipos de artículos de EU Parliament Monitor — fuente principal para contexto económico, monetario, fiscal, comercial y de IED.',\n      ja: 'IMF 指標（WEO、Fiscal Monitor、IFS、BOP、ER、PCPS）を EU Parliament Monitor の記事種別にマッピングする正典参照 — 経済・金融・財政・貿易・FDI 文脈の主要データ源。',\n      ko: 'IMF 지표(WEO, Fiscal Monitor, IFS, BOP, ER, PCPS)를 EU Parliament Monitor 기사 유형에 매핑하는 표준 참조 — 경제·통화·재정·무역·외국인직접투자 맥락의 주요 출처.',\n      zh: '将 IMF 指标（WEO、Fiscal Monitor、IFS、BOP、ER、PCPS）映射到 EU Parliament Monitor 文章类型的权威参考 — 经济、货币、财政、贸易和 FDI 背景的主要数据源。',\n    },\n  },\n  'analysis/methodologies/osint-tradecraft-standards.md': {\n    description:\n      'OSINT / INTOP tradecraft standards for EP political intelligence — source evaluation, attribution, verification, analytic-confidence grading, and GDPR-compliant collection.',\n    i18n: {\n      sv: 'OSINT/INTOP-tradecraft-standarder för politisk underrättelse om EP — källutvärdering, attribuering, verifiering, analytisk tillförlitlighetsklassificering och GDPR-efterlevande insamling.',\n      de: 'OSINT-/INTOP-Handwerksstandards für politische Aufklärung zum EP — Quellenbewertung, Attribution, Verifikation, analytische Konfidenz­bewertung und DSGVO-konforme Erhebung.',\n      fr: 'Normes de savoir-faire OSINT/INTOP pour le renseignement politique du PE — évaluation des sources, attribution, vérification, notation de confiance analytique et collecte conforme au RGPD.',\n      es: 'Estándares de tradecraft OSINT/INTOP para inteligencia política del PE — evaluación de fuentes, atribución, verificación, clasificación de confianza analítica y recolección conforme al RGPD.',\n      ja: 'EP 政治情報向け OSINT/INTOP トレードクラフト基準 — 情報源評価、帰属、検証、分析信頼度格付け、GDPR 準拠の収集。',\n      ko: 'EP 정치 정보를 위한 OSINT/INTOP 전문 기법 표준 — 출처 평가, 귀속, 검증, 분석 신뢰도 등급, GDPR 준수 수집.',\n      zh: '用于欧洲议会政治情报的 OSINT/INTOP 专业标准 — 信息源评估、归因、验证、分析可信度分级以及符合 GDPR 的收集。',\n    },\n  },\n  'analysis/methodologies/per-artifact-methodologies.md': {\n    description:\n      'Per-artifact methodology notes — 34 sections, one per artifact type, with construction rules, quality signals, and line-count floors enforced at Stage C.',\n    i18n: {\n      sv: 'Metodnoteringar per artefakt — 34 avsnitt, ett per artefakttyp, med konstruktions­regler, kvalitetssignaler och radgolv som upprätthålls i steg C.',\n      de: 'Methodologische Hinweise pro Artefakt — 34 Abschnitte, einer je Artefakttyp, mit Konstruktionsregeln, Qualitätssignalen und Zeilen-Untergrenzen, die in Stufe C durchgesetzt werden.',\n      fr: 'Notes méthodologiques par artefact — 34 sections, une par type d’artefact, avec règles de construction, signaux de qualité et planchers de lignes appliqués à l’étape C.',\n      es: 'Notas metodológicas por artefacto — 34 secciones, una por tipo de artefacto, con reglas de construcción, señales de calidad y pisos de líneas aplicados en la Etapa C.',\n      ja: 'アーティファクトごとの方法論ノート — アーティファクト種別ごとに 34 セクション、構築ルール・品質シグナル・ステージ C で強制される行数下限を収録。',\n      ko: '산출물별 방법론 노트 — 산출물 유형마다 34개 섹션, 구성 규칙·품질 신호·스테이지 C에서 강제되는 줄 수 하한 포함.',\n      zh: '按产物划分的方法论说明 — 每种产物类型 34 个章节，附构建规则、质量信号以及在 C 阶段强制执行的行数下限。',\n    },\n  },\n  'analysis/methodologies/per-document-methodology.md': {\n    description:\n      'Atomic evidence-layer methodology: document-level guidance for extracting, annotating, scoring and contextualising individual EP documents (reports, motions, votes, committee minutes).',\n    i18n: {\n      sv: 'Atomär bevislagersmetodik: dokumentnivåvägledning för att extrahera, annotera, poängsätta och kontextualisera enskilda EP-dokument (rapporter, motioner, röster, utskottsprotokoll).',\n      de: 'Methodologie für die atomare Evidenz­ebene: Dokumentebene-Leitlinien zur Extraktion, Annotation, Bewertung und Kontextualisierung einzelner EP-Dokumente (Berichte, Anträge, Abstimmungen, Ausschussprotokolle).',\n      fr: 'Méthodologie de la couche d’éléments atomiques : orientations au niveau du document pour extraire, annoter, noter et contextualiser chaque document du PE (rapports, motions, votes, procès-verbaux de commission).',\n      es: 'Metodología de la capa de evidencia atómica: orientación a nivel de documento para extraer, anotar, puntuar y contextualizar documentos individuales del PE (informes, mociones, votos, actas de comisión).',\n      ja: '原子的エビデンス層の方法論：個別の EP 文書（報告、動議、投票、委員会議事録）を抽出・注釈・採点・文脈化するための文書単位ガイダンス。',\n      ko: '원자적 증거 계층 방법론: 개별 EP 문서(보고서, 동의안, 표결, 위원회 회의록)를 추출·주석·평가·맥락화하기 위한 문서 수준 지침.',\n      zh: '原子证据层方法论：用于提取、标注、评分并将单个 EP 文件（报告、动议、投票、委员会纪要）置于语境中的文档级指导。',\n    },\n  },\n  'analysis/methodologies/political-classification-guide.md': {\n    description:\n      'Political classification taxonomy for the European Parliament — actors, stances, risk surfaces and information-security classification applied to every analyzed artifact.',\n    i18n: {\n      sv: 'Taxonomi för politisk klassificering av Europaparlamentet — aktörer, hållningar, riskytor och informationssäkerhets­klassificering som tillämpas på varje analyserad artefakt.',\n      de: 'Taxonomie der politischen Klassifikation für das Europäische Parlament — Akteure, Positionen, Risikoflächen und Informationssicherheits­klassifikation, angewandt auf jedes analysierte Artefakt.',\n      fr: 'Taxonomie de classification politique pour le Parlement européen — acteurs, positions, surfaces de risque et classification en sécurité de l’information appliquées à chaque artefact analysé.',\n      es: 'Taxonomía de clasificación política para el Parlamento Europeo — actores, posturas, superficies de riesgo y clasificación de seguridad de la información aplicadas a cada artefacto analizado.',\n      ja: '欧州議会向けの政治分類分類法 — アクター、立場、リスク面、情報セキュリティ分類を、分析対象のすべての成果物に適用。',\n      ko: '유럽의회를 위한 정치 분류 체계 — 모든 분석 산출물에 적용되는 행위자, 입장, 위험 표면, 정보보안 분류.',\n      zh: '面向欧洲议会的政治分类法 — 对每个被分析的产物应用的行为者、立场、风险面与信息安全分类。',\n    },\n  },\n  'analysis/methodologies/political-risk-methodology.md': {\n    description:\n      'Quantitative 5×5 Likelihood × Impact political-risk scoring adapted from the Hack23 ISMS — applied to coalition, policy, budget, institutional and geopolitical risks in the European Parliament.',\n    i18n: {\n      sv: 'Kvantitativ 5×5 sannolikhets × konsekvens-poängsättning av politisk risk anpassad från Hack23 ISMS — tillämpad på koalitions-, policy-, budget-, institutionella och geopolitiska risker i Europaparlamentet.',\n      da: 'Kvantitativ 5×5 sandsynlighed × konsekvens-scoring af politisk risiko tilpasset Hack23 ISMS — anvendt på koalitions-, politik-, budget-, institutionelle og geopolitiske risici i Europa-Parlamentet.',\n      de: 'Quantitative 5×5-Wahrscheinlichkeits × Auswirkungs-Bewertung politischer Risiken, angepasst aus dem Hack23-ISMS — angewandt auf Koalitions-, Politik-, Haushalts-, institutionelle und geopolitische Risiken im Europäischen Parlament.',\n      fr: 'Notation quantitative 5×5 Probabilité × Impact des risques politiques adaptée du SMSI Hack23 — appliquée aux risques de coalition, politiques, budgétaires, institutionnels et géopolitiques au Parlement européen.',\n      es: 'Puntuación cuantitativa 5×5 Probabilidad × Impacto de riesgo político adaptada del ISMS de Hack23 — aplicada a riesgos de coalición, política, presupuesto, institucionales y geopolíticos en el Parlamento Europeo.',\n      nl: 'Kwantitatieve 5×5 Waarschijnlijkheid × Impact-scoring van politieke risico’s, overgenomen uit het Hack23-ISMS — toegepast op coalitie-, beleids-, budget-, institutionele en geopolitieke risico’s in het Europees Parlement.',\n      ja: 'Hack23 ISMS を転用した政治リスクの定量 5×5 可能性×影響スコアリング — 欧州議会における連立・政策・予算・制度・地政学リスクに適用。',\n      ko: 'Hack23 ISMS를 차용한 정치 위험의 정량적 5×5 가능성×영향 점수화 — 유럽의회의 연정·정책·예산·제도·지정학 위험에 적용.',\n      zh: '源自 Hack23 ISMS 的政治风险定量 5×5 可能性 × 影响评分 — 应用于欧洲议会的联盟、政策、预算、制度与地缘政治风险。',\n    },\n  },\n  'analysis/methodologies/political-style-guide.md': {\n    description:\n      'Editorial and political style guide — The Economist-inspired tone, balance, attribution rules, Mermaid diagram conventions, and multi-language considerations across all 14 supported languages.',\n    i18n: {\n      sv: 'Redaktionell och politisk stilguide — The Economist-inspirerad ton, balans, attribueringsregler, Mermaid-diagram­konventioner och övervägande för alla 14 språk.',\n      de: 'Redaktioneller und politischer Styleguide — vom Economist inspirierter Ton, Ausgewogenheit, Attributionsregeln, Mermaid-Diagramm­konventionen und Überlegungen zu allen 14 Sprachen.',\n      fr: 'Guide éditorial et politique — ton inspiré de The Economist, équilibre, règles d’attribution, conventions de diagrammes Mermaid et considérations multilingues pour les 14 langues.',\n      es: 'Guía editorial y política — tono inspirado en The Economist, equilibrio, reglas de atribución, convenciones de diagramas Mermaid y consideraciones multilingües para los 14 idiomas.',\n      ja: '編集・政治スタイルガイド — The Economist に触発された語調・バランス・帰属ルール・Mermaid 図の規約、および 14 言語すべての多言語考慮事項。',\n      ko: '편집 및 정치 스타일 가이드 — The Economist 영감의 어조·균형·귀속 규칙·Mermaid 다이어그램 관례와 14개 언어 전반의 다국어 고려사항.',\n      zh: '编辑与政治文风指南 — 受《经济学人》启发的语气、平衡性、归因规则、Mermaid 图表约定以及对全部 14 种语言的多语言考量。',\n    },\n  },\n  'analysis/methodologies/political-swot-framework.md': {\n    description:\n      'SWOT framework adapted for EU political actors, coalitions and policy positions — with quantitative weighting, TOWS strategy generation, and ≥ 80-word depth floors per quadrant item.',\n    i18n: {\n      sv: 'SWOT-ramverk anpassat för EU:s politiska aktörer, koalitioner och politikpositioner — med kvantitativ viktning, TOWS-strategigenerering och ≥ 80 ord per kvadrantobjekt.',\n      de: 'Für politische EU-Akteure, Koalitionen und Politikpositionen adaptiertes SWOT-Rahmenwerk — mit quantitativer Gewichtung, TOWS-Strategie­generierung und ≥ 80-Wörter-Tiefenuntergrenzen pro Quadrantenpunkt.',\n      fr: 'Cadre SWOT adapté aux acteurs politiques, coalitions et positions de l’UE — avec pondération quantitative, génération de stratégies TOWS et planchers de profondeur de ≥ 80 mots par item de quadrant.',\n      es: 'Marco SWOT adaptado a actores políticos, coaliciones y posiciones de política de la UE — con ponderación cuantitativa, generación de estrategias TOWS y pisos de profundidad de ≥ 80 palabras por ítem de cuadrante.',\n      ja: 'EU の政治アクター・連立・政策立場向けに調整された SWOT 枠組み — 定量的ウェイト、TOWS 戦略生成、象限項目ごとの 80 語以上の深さ下限を伴う。',\n      ko: 'EU의 정치 행위자·연정·정책 입장에 맞춘 SWOT 프레임워크 — 정량 가중치, TOWS 전략 생성, 사분면 항목당 80단어 이상 깊이 하한 포함.',\n      zh: '为欧盟政治行为者、联盟与政策立场调整的 SWOT 框架 — 含定量权重、TOWS 策略生成，以及每个象限项目 ≥ 80 词的深度下限。',\n    },\n  },\n  'analysis/methodologies/political-threat-framework.md': {\n    description:\n      'Six-dimension democratic-threat framework for the European Parliament — institutional, procedural, information, coalition, external-interference and geopolitical threats with STRIDE-style enumeration.',\n    i18n: {\n      sv: 'Sexdimensionellt ramverk för demokratiska hot mot Europaparlamentet — institutionella, procedurella, informations-, koalitions-, externa inblandnings- och geopolitiska hot med STRIDE-liknande uppräkning.',\n      de: 'Sechsdimensionales Rahmenwerk für demokratische Bedrohungen des Europäischen Parlaments — institutionelle, verfahrenstechnische, informationelle, Koalitions-, externe Einflussnahme- und geopolitische Bedrohungen mit STRIDE-artiger Aufzählung.',\n      fr: 'Cadre de menaces démocratiques à six dimensions pour le Parlement européen — menaces institutionnelles, procédurales, informationnelles, de coalition, d’ingérence externe et géopolitiques, avec énumération de type STRIDE.',\n      es: 'Marco de amenazas democráticas de seis dimensiones para el Parlamento Europeo — amenazas institucionales, procedimentales, informativas, de coalición, de injerencia externa y geopolíticas, con enumeración estilo STRIDE.',\n      ja: '欧州議会の民主的脅威のための 6 次元フレームワーク — 制度・手続・情報・連立・対外干渉・地政学的脅威を STRIDE 型で列挙。',\n      ko: '유럽의회를 위한 6차원 민주적 위협 프레임워크 — 제도·절차·정보·연정·외부 개입·지정학적 위협을 STRIDE 방식으로 열거.',\n      zh: '用于欧洲议会的六维民主威胁框架 — 以 STRIDE 风格列举制度、程序、信息、联盟、外部干预与地缘政治威胁。',\n    },\n  },\n  'analysis/methodologies/strategic-extensions-methodology.md': {\n    description:\n      'Strategic extensions to the core methodologies — scenario planning, devil’s-advocate analysis, wildcards and black swans, long-horizon forecasting and cross-run synthesis.',\n    i18n: {\n      sv: 'Strategiska utvidgningar av kärnmetodikerna — scenarioplanering, djävulens-advokat-analys, jokrar och svarta svanar, långhorisontsprognoser och tvärkörningssyntes.',\n      de: 'Strategische Erweiterungen der Kernmethodologien — Szenarienplanung, Devil’s-Advocate-Analyse, Wildcards und Schwarze Schwäne, Langzeitprognosen und Cross-Run-Synthese.',\n      fr: 'Extensions stratégiques des méthodologies centrales — planification de scénarios, analyse avocat du diable, jokers et cygnes noirs, prévisions à long horizon et synthèse entre exécutions.',\n      es: 'Extensiones estratégicas de las metodologías principales — planificación de escenarios, análisis de abogado del diablo, comodines y cisnes negros, pronósticos a largo plazo y síntesis entre ejecuciones.',\n      ja: 'コア方法論への戦略的拡張 — シナリオ計画、悪魔の代弁者分析、ワイルドカードとブラックスワン、長期予測、ラン横断シンセシス。',\n      ko: '핵심 방법론의 전략적 확장 — 시나리오 기획, 악마의 변호인 분석, 와일드카드와 블랙스완, 장기 예측, 런 간 시너지스.',\n      zh: '核心方法论的战略扩展 — 情景规划、魔鬼代言人分析、通配牌与黑天鹅、长视野预测以及跨运行综合。',\n    },\n  },\n  'analysis/methodologies/structural-metadata-methodology.md': {\n    description:\n      'Methodology for structural metadata extraction, provenance tracking and cross-linkage of every EP document type — enabling reproducible analytics and GDPR Article 30 compliance.',\n    i18n: {\n      sv: 'Metodologi för extraktion av strukturell metadata, proveniensspårning och korslänkning av varje EP-dokumenttyp — möjliggör reproducerbar analys och efterlevnad av GDPR artikel 30.',\n      de: 'Methodologie zur Extraktion struktureller Metadaten, Provenienz­verfolgung und Querverknüpfung jedes EP-Dokumenttyps — ermöglicht reproduzierbare Analytik und Einhaltung von DSGVO Art. 30.',\n      fr: 'Méthodologie d’extraction des métadonnées structurelles, de traçabilité de la provenance et d’inter-liaison de chaque type de document du PE — permettant des analyses reproductibles et la conformité à l’article 30 du RGPD.',\n      es: 'Metodología para extracción de metadatos estructurales, trazabilidad de procedencia e interrelación de cada tipo de documento del PE — permite análisis reproducibles y cumplimiento del artículo 30 del RGPD.',\n      ja: 'あらゆる EP 文書タイプの構造的メタデータ抽出・来歴追跡・相互リンクの方法論 — 再現可能な分析と GDPR 第 30 条遵守を実現。',\n      ko: '모든 EP 문서 유형의 구조적 메타데이터 추출·출처 추적·상호 연결 방법론 — 재현 가능한 분석과 GDPR 제30조 준수를 가능하게 함.',\n      zh: '对每种 EP 文件类型进行结构化元数据提取、来源追踪与交叉链接的方法论 — 实现可复现的分析及 GDPR 第 30 条合规。',\n    },\n  },\n  'analysis/methodologies/synthesis-methodology.md': {\n    description:\n      'Synthesis & scoring methodology — combines multiple artifacts into cohesive intelligence products with significance scoring, confidence grading and cross-reference integrity checks.',\n    i18n: {\n      sv: 'Syntes- och poängsättningsmetodik — kombinerar flera artefakter till sammanhängande underrättelseprodukter med betydelsepoäng, tillförlitlighets­klassificering och kontroller av korsreferens­integritet.',\n      de: 'Synthese- und Bewertungs­methodologie — kombiniert mehrere Artefakte zu kohärenten Intelligence-Produkten mit Signifikanz-Scoring, Konfidenz­bewertung und Querverweis-Integritätsprüfungen.',\n      fr: 'Méthodologie de synthèse et de notation — combine plusieurs artefacts en produits de renseignement cohérents avec notation de signification, classement de confiance et vérifications d’intégrité des références croisées.',\n      es: 'Metodología de síntesis y puntuación — combina múltiples artefactos en productos de inteligencia coherentes con puntuación de significancia, gradación de confianza y verificaciones de integridad de referencias cruzadas.',\n      ja: '統合・採点の方法論 — 複数の成果物を、重要度スコアリング、信頼度格付け、相互参照整合性チェックを備えた一貫したインテリジェンス製品に統合。',\n      ko: '종합 및 점수 매김 방법론 — 중요도 채점·신뢰도 등급·상호참조 무결성 점검을 통해 여러 산출물을 일관된 정보 제품으로 결합.',\n      zh: '综合与评分方法论 — 通过重要性评分、可信度分级以及交叉引用完整性检查，将多个产物整合为连贯的情报产品。',\n    },\n  },\n  'analysis/methodologies/worldbank-indicator-mapping.md': {\n    description:\n      'Mapping of non-economic World Bank Open Data indicators to EU Parliament Monitor article types — covering health, education, social, environment, demographics, governance and innovation.',\n    i18n: {\n      sv: 'Mappning av icke-ekonomiska indikatorer från Världsbankens öppna data till artikeltyper i EU Parliament Monitor — hälsa, utbildning, socialt, miljö, demografi, styrning och innovation.',\n      de: 'Zuordnung nicht-ökonomischer Indikatoren der Weltbank-Offene-Daten zu Artikeltypen von EU Parliament Monitor — Gesundheit, Bildung, Soziales, Umwelt, Demografie, Governance und Innovation.',\n      fr: 'Mise en correspondance des indicateurs non économiques des données ouvertes de la Banque mondiale avec les types d’articles d’EU Parliament Monitor — santé, éducation, social, environnement, démographie, gouvernance et innovation.',\n      es: 'Mapeo de indicadores no económicos del Banco Mundial Open Data a los tipos de artículos de EU Parliament Monitor — salud, educación, social, medioambiente, demografía, gobernanza e innovación.',\n      ja: '世界銀行の非経済オープンデータ指標を EU Parliament Monitor 記事種別にマッピング — 保健、教育、社会、環境、人口動態、ガバナンス、イノベーションを網羅。',\n      ko: '세계은행 비경제 공개 데이터 지표를 EU Parliament Monitor 기사 유형에 매핑 — 보건, 교육, 사회, 환경, 인구, 거버넌스, 혁신 포함.',\n      zh: '将世界银行非经济开放数据指标映射到 EU Parliament Monitor 文章类型 — 涵盖健康、教育、社会、环境、人口、治理与创新。',\n    },\n  },\n\n  // ========================================================================\n  // Templates\n  // ========================================================================\n  'analysis/templates/README.md': {\n    description:\n      'Index of the 39 analysis artifact templates — 6 framework templates, 14 agentic-workflow templates, and 25 per-artifact templates used in every daily analysis run.',\n  },\n  'analysis/templates/actor-mapping.md': {\n    description:\n      'Actor mapping template — at least 12 named EP actors with quantified influence weights, committee seats, roll-call alignment and alliance footprints.',\n  },\n  'analysis/templates/actor-threat-profiles.md': {\n    description:\n      'Actor threat profiles — Diamond-Model analysis of political actors (capabilities, infrastructure, victims, adversary relationships) applied to EP politics.',\n  },\n  'analysis/templates/analysis-index.md': {\n    description:\n      'Master run-artifact navigator — indexes every artifact produced during an article-generating workflow, with cross-links to methodology, templates and source data.',\n  },\n  'analysis/templates/coalition-dynamics.md': {\n    description:\n      'Coalition dynamics template — group cohesion rates, alliance pairs, defection patterns and fragmentation index across EP political groups.',\n  },\n  'analysis/templates/coalition-mathematics.md': {\n    description:\n      'Coalition mathematics — seat arithmetic, blocking minorities and majority-feasibility scenarios against the EP 361-seat threshold.',\n  },\n  'analysis/templates/comparative-international.md': {\n    description:\n      'Comparative international template — places EP political events in international context against member states, the US, UK and other peer jurisdictions.',\n  },\n  'analysis/templates/consequence-trees.md': {\n    description:\n      'Multi-level consequence tree template — first-order, second-order and third-order political consequences of each identified threat.',\n  },\n  'analysis/templates/cross-reference-map.md': {\n    description:\n      'Cross-reference map — document-to-document relationship graph showing how evidence flows through every artifact in a run for claim-provenance auditability.',\n  },\n  'analysis/templates/cross-run-diff.md': {\n    description:\n      'Cross-run Bayesian delta analysis — compares the current run to previous runs of the same article type, exposing new signals, reversals and analytical drift.',\n  },\n  'analysis/templates/cross-session-intelligence.md': {\n    description:\n      'Cross-session intelligence — plenary-session progression view linking developments across consecutive EP sessions.',\n  },\n  'analysis/templates/data-download-manifest.md': {\n    description:\n      'Data download manifest — logs every EP MCP tool call and external-data retrieval during a workflow run for reproducibility and GDPR Article 30 compliance.',\n  },\n  'analysis/templates/deep-analysis.md': {\n    description:\n      'Deep political analysis template — long-form Economist-style narrative with ≥ 60% prose ratio, Chart.js visualisations and rigorous per-section evidence citations.',\n  },\n  'analysis/templates/devils-advocate-analysis.md': {\n    description:\n      'Devil’s-advocate template — Analysis of Competing Hypotheses (ACH) stress-testing dominant interpretations with the strongest counter-arguments.',\n  },\n  'analysis/templates/economic-context.md': {\n    description:\n      'Economic context template — anchors article narratives with IMF (primary) and World Bank (supporting) data: GDP, inflation, fiscal balance, trade, FDI.',\n  },\n  'analysis/templates/executive-brief.md': {\n    description:\n      'Executive brief — concise 2-page decision-maker summary with top findings, risks and recommendations for every published article.',\n  },\n  'analysis/templates/forces-analysis.md': {\n    description:\n      'Lewin force-field analysis for EP politics — enumerates driving and restraining forces on each proposed policy or coalition change.',\n  },\n  'analysis/templates/forward-indicators.md': {\n    description:\n      'Forward indicators template — signals worth monitoring over the coming days and weeks, with trigger thresholds and expected impact.',\n  },\n  'analysis/templates/historical-baseline.md': {\n    description:\n      'Historical baseline template — metric trending and anchoring across the current EP term and comparable past terms.',\n  },\n  'analysis/templates/historical-parallels.md': {\n    description:\n      'Historical parallels template — draws on 20+ years of EP data to surface comparable precedents and their outcomes.',\n  },\n  'analysis/templates/impact-matrix.md': {\n    description:\n      'Impact matrix — event × stakeholder grid quantifying positive/negative impact on each affected EP or member-state constituency.',\n  },\n  'analysis/templates/implementation-feasibility.md': {\n    description:\n      'Implementation feasibility template — assesses whether proposed EP policies can realistically be delivered, covering legal, budgetary and operational constraints.',\n  },\n  'analysis/templates/intelligence-assessment.md': {\n    description:\n      'Full intelligence assessment template — judgements, confidence levels, knowledge gaps and dissenting views for each analyzed event.',\n  },\n  'analysis/templates/legislative-disruption.md': {\n    description:\n      'Legislative disruption template — adversarial procedure-level threats: filibusters, amendment storms, quorum-busting and committee-chair manoeuvring.',\n  },\n  'analysis/templates/legislative-velocity-risk.md': {\n    description:\n      'Legislative velocity risk — pipeline throughput and deadline exposure: stalled procedures, trilogue delays and mandate-expiry risk.',\n  },\n  'analysis/templates/mcp-reliability-audit.md': {\n    description:\n      'MCP reliability audit — endpoint health and uptime report for every European Parliament MCP tool invocation during a workflow run.',\n  },\n  'analysis/templates/media-framing-analysis.md': {\n    description:\n      'Media framing analysis — maps how narratives spread across outlets and languages, comparing national-media framings of EP events.',\n  },\n  'analysis/templates/methodology-reflection.md': {\n    description:\n      'Methodology reflection template — the final Step 10.5 artifact capturing lessons learned, protocol gaps and continuous-improvement notes for each run.',\n  },\n  'analysis/templates/per-file-political-intelligence.md': {\n    description:\n      'Per-file political intelligence template — annotates individual EP documents (reports, motions, votes) with structured intelligence findings.',\n  },\n  'analysis/templates/pestle-analysis.md': {\n    description:\n      'PESTLE analysis template — Political, Economic, Social, Technological, Legal, Environmental factors shaping the analyzed EP event.',\n  },\n  'analysis/templates/political-capital-risk.md': {\n    description:\n      'Political capital risk template — named-actor capital exposure: reputational, coalition, electoral and personal political capital at stake.',\n  },\n  'analysis/templates/political-classification.md': {\n    description:\n      'Political event classification — applies the classification taxonomy to the current artifact with actor tags, stance scores and risk flags.',\n  },\n  'analysis/templates/political-threat-landscape.md': {\n    description:\n      'Six-dimension democratic threat view — applied threat landscape for the analyzed EP event across all six threat categories.',\n  },\n  'analysis/templates/quantitative-swot.md': {\n    description:\n      'Quantitative SWOT + TOWS template — numeric-weight SWOT items with derived TOWS strategy matrix (SO, ST, WO, WT).',\n  },\n  'analysis/templates/reference-analysis-quality.md': {\n    description:\n      'Reference quality self-score — benchmarks each cited source against the platform’s reference-quality thresholds (primary/secondary/tertiary + IMF/WB coverage).',\n  },\n  'analysis/templates/risk-assessment.md': {\n    description:\n      'Political risk assessment — enumerated risks with 5×5 Likelihood × Impact scoring, mitigations, residual risk and monitoring indicators.',\n  },\n  'analysis/templates/risk-matrix.md': {\n    description:\n      '5×5 Likelihood × Impact political risk grid — visual heatmap placing every enumerated risk for the analyzed EP event.',\n  },\n  'analysis/templates/scenario-forecast.md': {\n    description:\n      'Scenario forecast template — 3–5 probability-weighted futures with drivers, indicators and decision points for EP policy paths.',\n  },\n  'analysis/templates/session-baseline.md': {\n    description:\n      'Session baseline template — plenary calendar and adopted-texts roster capturing the starting state for an article workflow run.',\n  },\n  'analysis/templates/significance-classification.md': {\n    description:\n      'Significance classification — 5-dimension rubric (institutional, policy, electoral, media, international) for ranking the analyzed event.',\n  },\n  'analysis/templates/significance-scoring.md': {\n    description:\n      'Political significance scoring — numerical rank of artifacts by political and societal importance, used to prioritise article coverage.',\n  },\n  'analysis/templates/stakeholder-impact.md': {\n    description:\n      'Stakeholder impact assessment — maps affected groups (citizens, industry, member states, institutions) and their expected consequences with ≥ 150-word perspectives.',\n  },\n  'analysis/templates/stakeholder-map.md': {\n    description:\n      'Stakeholder map — Power × Alignment grid of actors around the analyzed EP issue, identifying supporters, opponents and swing players.',\n  },\n  'analysis/templates/swot-analysis.md': {\n    description:\n      'Classic SWOT-analysis template customised for EP actors and policies — Strengths, Weaknesses, Opportunities, Threats with ≥ 80 words per quadrant item.',\n  },\n  'analysis/templates/synthesis-summary.md': {\n    description:\n      'Political intelligence synthesis — consolidates every artifact in a run into a single cohesive intelligence product with bottom-line-up-front judgements.',\n  },\n  'analysis/templates/threat-analysis.md': {\n    description:\n      'Political threat landscape analysis — identifies adversaries, tactics, techniques, procedures (TTPs) and political-threat surfaces with defence priorities.',\n  },\n  'analysis/templates/threat-model.md': {\n    description:\n      'Threat model template — democratic and institutional threat analysis using STRIDE-style enumeration over the EP trust boundary.',\n  },\n  'analysis/templates/voter-segmentation.md': {\n    description:\n      'Voter segmentation template — models EU-wide constituencies, demographics and behavioural clusters relevant to the analyzed policy area.',\n  },\n  'analysis/templates/voting-patterns.md': {\n    description:\n      'Voting patterns template — EP roll-call analysis across political groups, national delegations and coalition configurations.',\n  },\n  'analysis/templates/wildcards-blackswans.md': {\n    description:\n      'Wildcards & black swans — low-probability, high-impact events that could disrupt the baseline EP forecast, with early-warning indicators.',\n  },\n  'analysis/templates/workflow-audit.md': {\n    description:\n      'Workflow audit — agentic-run self-assessment covering every step, tool call, artifact produced and Stage A–D completeness gate.',\n  },\n\n  // ========================================================================\n  // Reference / ISMS adaptations\n  // ========================================================================\n  'analysis/reference/isms-classification-adaptation.md': {\n    description:\n      'Adaptation of the Hack23 ISMS information-classification scheme (Public, Internal, Confidential, Restricted) to EU political intelligence artifacts.',\n  },\n  'analysis/reference/isms-risk-assessment-adaptation.md': {\n    description:\n      'Adaptation of the Hack23 ISMS risk-assessment methodology to EU political risk — reuses the 5×5 Likelihood × Impact matrix on coalition, policy and institutional risks.',\n  },\n  'analysis/reference/isms-style-guide-adaptation.md': {\n    description:\n      'Adaptation of the Hack23 ISMS documentation style guide to EU political intelligence writing — structure, tone, citation and multi-language conventions.',\n  },\n  'analysis/reference/isms-threat-modeling-adaptation.md': {\n    description:\n      'Adaptation of the Hack23 ISMS threat-modelling methodology to EU political threats — STRIDE-style enumeration over EP institutional trust boundaries.',\n  },\n\n  // ========================================================================\n  // IMF data pipeline\n  // ========================================================================\n  'analysis/imf/README.md': {\n    description:\n      'IMF data integration overview — how EU Parliament Monitor consumes the IMF SDMX 3.0 REST API via a native TypeScript client for economic, fiscal and monetary context.',\n  },\n  'analysis/imf/chart-integration-guide.md': {\n    description:\n      'IMF chart integration guide — how to render IMF indicator series as Chart.js visualisations embedded in EU Parliament Monitor articles.',\n  },\n  'analysis/imf/eu-country-mapping.md': {\n    description:\n      'IMF country and aggregation codelist — maps every EU-27 member state plus EU/EA aggregates to their canonical IMF 3-letter country codes.',\n  },\n  'analysis/imf/indicator-catalog.md': {\n    description:\n      'Complete IMF indicator catalog — every WEO, Fiscal Monitor, IFS, BOP, ER and PCPS series available to article workflows, keyed to article-type policies.',\n  },\n  'analysis/imf/use-cases.md': {\n    description:\n      'IMF data use cases — worked examples showing how to anchor breaking, week-ahead, committee-report and proposition articles in IMF economic data.',\n  },\n\n  // ========================================================================\n  // World Bank data pipeline\n  // ========================================================================\n  'analysis/worldbank/README.md': {\n    description:\n      'World Bank indicator integration overview — how EU Parliament Monitor consumes the worldbank-mcp server for non-economic development indicators.',\n  },\n  'analysis/worldbank/chart-integration-guide.md': {\n    description:\n      'Chart integration guide for World Bank data in EU Parliament Monitor articles — accessible Chart.js rendering with WCAG 2.1 AA contrast and SR labels.',\n  },\n  'analysis/worldbank/eu-country-mapping.md': {\n    description:\n      'EU-27 → World Bank country-code mapping plus a guard for aggregate codes (EUU, EMU, ECS, OED, WLD) that the worldbank-mcp 1.0.1 server rejects.',\n  },\n  'analysis/worldbank/indicator-catalog.md': {\n    description:\n      'Complete World Bank indicator reference — every non-economic indicator (health, education, social, environment, demographics, governance, innovation) keyed to article types.',\n  },\n  'analysis/worldbank/use-cases.md': {\n    description:\n      'World Bank indicator use cases — worked examples showing how to weave non-economic World Bank data into EP article narratives.',\n  },\n};\n\n/**\n * Curated per-language **titles** keyed by the repository-relative Markdown\n * path. This table is layered *on top* of {@link CURATED_DESCRIPTIONS} so\n * the main description table stays compact; adding a title for a file does\n * not require touching that entry's description block.\n *\n * Each entry provides a canonical English title (`en`) plus optional\n * overlays in the other 13 supported languages. When a language is missing,\n * {@link getCuratedTitle} falls back to the English entry, and when the\n * entire path is missing from this table it falls back to the H1 extracted\n * from the source Markdown by the generator.\n *\n * Titles are kept short (ideally ≤ 60 characters) and free of emoji —\n * emoji comes from `doc.icon` in the card layout, so keeping titles plain\n * improves SEO (`<title>` tag, og:title, twitter:title, JSON-LD BreadcrumbList\n * entries all consume this string).\n */\nexport const CURATED_TITLES: Readonly<Record<string, TextI18n>> = {\n  /* eslint-disable sonarjs/no-duplicate-string --\n     Title translations across closely-related languages (Scandinavian\n     sv/da/no, or English-borrowed technical terms like \"TOWS\", \"IMF\",\n     \"MCP\") legitimately coincide. Extracting a shared constant would\n     obscure the per-language intent and make later divergence harder. */\n  // ========================================================================\n  // Methodologies (17)\n  // ========================================================================\n  'analysis/methodologies/README.md': {\n    en: 'Methodology Library Index',\n    sv: 'Metodologibibliotek — index',\n    da: 'Metodebibliotek — indeks',\n    no: 'Metodebibliotek — indeks',\n    fi: 'Metodologiakirjasto — hakemisto',\n    de: 'Methodologie-Bibliothek — Index',\n    fr: 'Bibliothèque des méthodologies — index',\n    es: 'Biblioteca de metodologías — índice',\n    nl: 'Methodologiebibliotheek — index',\n    ar: 'فهرس مكتبة المنهجيات',\n    he: 'אינדקס ספריית המתודולוגיות',\n    ja: '方法論ライブラリ索引',\n    ko: '방법론 라이브러리 색인',\n    zh: '方法论库索引',\n  },\n  'analysis/methodologies/ai-driven-analysis-guide.md': {\n    en: 'AI-Driven Analysis Guide',\n    sv: 'AI-driven analysguide',\n    da: 'AI-drevet analyseguide',\n    no: 'AI-drevet analyseveiledning',\n    fi: 'Tekoälypohjainen analyysiopas',\n    de: 'KI-gesteuerter Analyseleitfaden',\n    fr: 'Guide d’analyse pilotée par IA',\n    es: 'Guía de análisis impulsado por IA',\n    nl: 'AI-gedreven analysegids',\n    ar: 'دليل التحليل المدفوع بالذكاء الاصطناعي',\n    he: 'מדריך ניתוח מבוסס בינה מלאכותית',\n    ja: 'AI駆動分析ガイド',\n    ko: 'AI 기반 분석 가이드',\n    zh: 'AI 驱动分析指南',\n  },\n  'analysis/methodologies/artifact-catalog.md': {\n    en: 'Analysis Artifact Catalog',\n    sv: 'Katalog över analysartefakter',\n    da: 'Katalog over analyseartefakter',\n    no: 'Katalog over analyseartefakter',\n    fi: 'Analyysiartefaktien luettelo',\n    de: 'Katalog der Analyse-Artefakte',\n    fr: 'Catalogue des artefacts d’analyse',\n    es: 'Catálogo de artefactos de análisis',\n    nl: 'Catalogus van analyse-artefacten',\n    ar: 'كتالوج القطع التحليلية',\n    he: 'קטלוג ארטיפקטי הניתוח',\n    ja: '分析成果物カタログ',\n    ko: '분석 산출물 카탈로그',\n    zh: '分析工件目录',\n  },\n  'analysis/methodologies/electoral-domain-methodology.md': {\n    en: 'Electoral Domain Methodology',\n    sv: 'Valdomänmetodologi',\n    da: 'Valgdomænemetode',\n    no: 'Valgdomenemetodikk',\n    fi: 'Vaalialueen metodologia',\n    de: 'Wahldomänen-Methodologie',\n    fr: 'Méthodologie du domaine électoral',\n    es: 'Metodología del dominio electoral',\n    nl: 'Methodologie voor het kiesdomein',\n    ar: 'منهجية المجال الانتخابي',\n    he: 'מתודולוגיית תחום הבחירות',\n    ja: '選挙領域方法論',\n    ko: '선거 도메인 방법론',\n    zh: '选举领域方法论',\n  },\n  'analysis/methodologies/imf-indicator-mapping.md': {\n    en: 'IMF Indicator → Article-Type Mapping',\n    sv: 'IMF-indikator → artikeltypmappning',\n    da: 'IMF-indikator → artikeltypemapping',\n    no: 'IMF-indikator → artikkeltypekobling',\n    fi: 'IMF-indikaattori → artikkelityypin kartoitus',\n    de: 'IWF-Indikator → Artikeltyp-Zuordnung',\n    fr: 'Indicateur FMI → Mappage par type d’article',\n    es: 'Indicador del FMI → Asignación por tipo de artículo',\n    nl: 'IMF-indicator → toewijzing artikeltype',\n    ar: 'مؤشر صندوق النقد الدولي → خريطة نوع المقال',\n    he: 'מיפוי מדד קרן המטבע → סוג מאמר',\n    ja: 'IMF指標 → 記事タイプマッピング',\n    ko: 'IMF 지표 → 기사 유형 매핑',\n    zh: 'IMF 指标 → 文章类型映射',\n  },\n  'analysis/methodologies/osint-tradecraft-standards.md': {\n    en: 'OSINT Tradecraft Standards',\n    sv: 'OSINT-tradecraft-standarder',\n    da: 'OSINT-tradecraft-standarder',\n    no: 'OSINT-håndverksstandarder',\n    fi: 'OSINT-tradecraft-standardit',\n    de: 'OSINT-Tradecraft-Standards',\n    fr: 'Normes de savoir-faire OSINT',\n    es: 'Estándares de oficio OSINT',\n    nl: 'OSINT-vakstandaarden',\n    ar: 'معايير حرفة الاستخبارات المفتوحة',\n    he: 'תקני מלאכת מודיעין פתוח',\n    ja: 'OSINT トレードクラフト標準',\n    ko: 'OSINT 트레이드크래프트 표준',\n    zh: 'OSINT 情报工艺标准',\n  },\n  'analysis/methodologies/per-artifact-methodologies.md': {\n    en: 'Per-Artifact Methodologies',\n    sv: 'Per-artefakt-metodologier',\n    da: 'Pr.-artefakt-metoder',\n    no: 'Per-artefakt-metodikker',\n    fi: 'Artefaktikohtaiset metodologiat',\n    de: 'Methodologien pro Artefakt',\n    fr: 'Méthodologies par artefact',\n    es: 'Metodologías por artefacto',\n    nl: 'Methodologieën per artefact',\n    ar: 'منهجيات لكل قطعة أثرية',\n    he: 'מתודולוגיות לפי ארטיפקט',\n    ja: '成果物別方法論',\n    ko: '산출물별 방법론',\n    zh: '分工件方法论',\n  },\n  'analysis/methodologies/per-document-methodology.md': {\n    en: 'Per-Document Analysis Methodology',\n    sv: 'Per-dokument-analysmetodologi',\n    da: 'Pr.-dokument analysemetode',\n    no: 'Per-dokument analysemetodikk',\n    fi: 'Asiakirja­kohtainen analyysimetodologia',\n    de: 'Dokumentspezifische Analysemethodologie',\n    fr: 'Méthodologie d’analyse par document',\n    es: 'Metodología de análisis por documento',\n    nl: 'Analysemethodologie per document',\n    ar: 'منهجية التحليل لكل وثيقة',\n    he: 'מתודולוגיית ניתוח למסמך בודד',\n    ja: '文書別分析方法論',\n    ko: '문서별 분석 방법론',\n    zh: '按文档分析方法论',\n  },\n  'analysis/methodologies/political-classification-guide.md': {\n    en: 'Political Event Classification Guide',\n    sv: 'Guide för klassificering av politiska händelser',\n    da: 'Vejledning i klassifikation af politiske begivenheder',\n    no: 'Veiledning for klassifisering av politiske hendelser',\n    fi: 'Poliittisten tapahtumien luokitteluopas',\n    de: 'Leitfaden zur Klassifizierung politischer Ereignisse',\n    fr: 'Guide de classification des événements politiques',\n    es: 'Guía de clasificación de eventos políticos',\n    nl: 'Gids voor classificatie van politieke gebeurtenissen',\n    ar: 'دليل تصنيف الأحداث السياسية',\n    he: 'מדריך סיווג אירועים פוליטיים',\n    ja: '政治イベント分類ガイド',\n    ko: '정치 이벤트 분류 가이드',\n    zh: '政治事件分类指南',\n  },\n  'analysis/methodologies/political-risk-methodology.md': {\n    en: 'Political Risk Methodology',\n    sv: 'Politisk riskmetodologi',\n    da: 'Politisk risikometode',\n    no: 'Politisk risikometodikk',\n    fi: 'Poliittisen riskin metodologia',\n    de: 'Methodologie für politische Risiken',\n    fr: 'Méthodologie des risques politiques',\n    es: 'Metodología de riesgos políticos',\n    nl: 'Methodologie voor politieke risico’s',\n    ar: 'منهجية المخاطر السياسية',\n    he: 'מתודולוגיית סיכון פוליטי',\n    ja: '政治リスク方法論',\n    ko: '정치 리스크 방법론',\n    zh: '政治风险方法论',\n  },\n  'analysis/methodologies/political-style-guide.md': {\n    en: 'Political Style Guide',\n    sv: 'Politisk stilguide',\n    da: 'Politisk stilguide',\n    no: 'Politisk stilguide',\n    fi: 'Poliittinen tyyliopas',\n    de: 'Politischer Stilleitfaden',\n    fr: 'Guide de style politique',\n    es: 'Guía de estilo político',\n    nl: 'Politieke stijlgids',\n    ar: 'دليل الأسلوب السياسي',\n    he: 'מדריך סגנון פוליטי',\n    ja: '政治スタイルガイド',\n    ko: '정치 스타일 가이드',\n    zh: '政治风格指南',\n  },\n  'analysis/methodologies/political-swot-framework.md': {\n    en: 'Political SWOT Framework',\n    sv: 'Politiskt SWOT-ramverk',\n    da: 'Politisk SWOT-ramme',\n    no: 'Politisk SWOT-rammeverk',\n    fi: 'Poliittinen SWOT-viitekehys',\n    de: 'Politisches SWOT-Rahmenwerk',\n    fr: 'Cadre SWOT politique',\n    es: 'Marco SWOT político',\n    nl: 'Politiek SWOT-raamwerk',\n    ar: 'إطار SWOT السياسي',\n    he: 'מסגרת SWOT פוליטית',\n    ja: '政治SWOTフレームワーク',\n    ko: '정치 SWOT 프레임워크',\n    zh: '政治 SWOT 框架',\n  },\n  'analysis/methodologies/political-threat-framework.md': {\n    en: 'Political Threat Framework',\n    sv: 'Politiskt hotramverk',\n    da: 'Politisk trusselramme',\n    no: 'Politisk trusselrammeverk',\n    fi: 'Poliittinen uhkaviitekehys',\n    de: 'Politisches Bedrohungsrahmenwerk',\n    fr: 'Cadre des menaces politiques',\n    es: 'Marco de amenazas políticas',\n    nl: 'Politiek dreigingsraamwerk',\n    ar: 'إطار التهديدات السياسية',\n    he: 'מסגרת איומים פוליטיים',\n    ja: '政治脅威フレームワーク',\n    ko: '정치 위협 프레임워크',\n    zh: '政治威胁框架',\n  },\n  'analysis/methodologies/strategic-extensions-methodology.md': {\n    en: 'Strategic Extensions Methodology',\n    sv: 'Metodologi för strategiska utvidgningar',\n    da: 'Metode for strategiske udvidelser',\n    no: 'Metodikk for strategiske utvidelser',\n    fi: 'Strategisten laajennusten metodologia',\n    de: 'Methodologie strategischer Erweiterungen',\n    fr: 'Méthodologie des extensions stratégiques',\n    es: 'Metodología de extensiones estratégicas',\n    nl: 'Methodologie voor strategische uitbreidingen',\n    ar: 'منهجية الامتدادات الاستراتيجية',\n    he: 'מתודולוגיית הרחבות אסטרטגיות',\n    ja: '戦略的拡張方法論',\n    ko: '전략적 확장 방법론',\n    zh: '战略扩展方法论',\n  },\n  'analysis/methodologies/structural-metadata-methodology.md': {\n    en: 'Structural Metadata Methodology',\n    sv: 'Metodologi för strukturell metadata',\n    da: 'Metode for strukturel metadata',\n    no: 'Metodikk for strukturell metadata',\n    fi: 'Rakenteellisen metatiedon metodologia',\n    de: 'Methodologie struktureller Metadaten',\n    fr: 'Méthodologie des métadonnées structurelles',\n    es: 'Metodología de metadatos estructurales',\n    nl: 'Methodologie voor structurele metadata',\n    ar: 'منهجية البيانات الوصفية الهيكلية',\n    he: 'מתודולוגיית מטא-נתונים מבניים',\n    ja: '構造メタデータ方法論',\n    ko: '구조 메타데이터 방법론',\n    zh: '结构化元数据方法论',\n  },\n  'analysis/methodologies/synthesis-methodology.md': {\n    en: 'Synthesis Methodology',\n    sv: 'Syntesmetodologi',\n    da: 'Syntesemetode',\n    no: 'Syntesemetodikk',\n    fi: 'Synteesin metodologia',\n    de: 'Synthese-Methodologie',\n    fr: 'Méthodologie de synthèse',\n    es: 'Metodología de síntesis',\n    nl: 'Synthesemethodologie',\n    ar: 'منهجية التوليف',\n    he: 'מתודולוגיית סינתזה',\n    ja: '総合方法論',\n    ko: '종합 방법론',\n    zh: '综合方法论',\n  },\n  'analysis/methodologies/worldbank-indicator-mapping.md': {\n    en: 'World Bank Indicator → Article-Type Mapping',\n    sv: 'Världsbanken-indikator → artikeltypmappning',\n    da: 'Verdensbank-indikator → artikeltypemapping',\n    no: 'Verdensbank-indikator → artikkeltypekobling',\n    fi: 'Maailmanpankin indikaattori → artikkelityypin kartoitus',\n    de: 'Weltbank-Indikator → Artikeltyp-Zuordnung',\n    fr: 'Indicateur Banque mondiale → Mappage par type d’article',\n    es: 'Indicador del Banco Mundial → Asignación por tipo de artículo',\n    nl: 'Wereldbank-indicator → toewijzing artikeltype',\n    ar: 'مؤشر البنك الدولي → خريطة نوع المقال',\n    he: 'מיפוי מדד הבנק העולמי → סוג מאמר',\n    ja: '世界銀行指標 → 記事タイプマッピング',\n    ko: '세계은행 지표 → 기사 유형 매핑',\n    zh: '世界银行指标 → 文章类型映射',\n  },\n\n  // ========================================================================\n  // Reference — ISMS adaptations (4)\n  // ========================================================================\n  'analysis/reference/isms-classification-adaptation.md': {\n    en: 'ISMS Classification Adaptation',\n    sv: 'ISMS-klassificeringsanpassning',\n    da: 'ISMS-klassifikationstilpasning',\n    no: 'ISMS-klassifiseringstilpasning',\n    fi: 'ISMS-luokittelun sovellus',\n    de: 'ISMS-Klassifizierungsanpassung',\n    fr: 'Adaptation de classification ISMS',\n    es: 'Adaptación de clasificación ISMS',\n    nl: 'ISMS-classificatieaanpassing',\n    ar: 'تكييف تصنيف ISMS',\n    he: 'התאמת סיווג ISMS',\n    ja: 'ISMS分類適応',\n    ko: 'ISMS 분류 적응',\n    zh: 'ISMS 分类适配',\n  },\n  'analysis/reference/isms-risk-assessment-adaptation.md': {\n    en: 'ISMS Risk-Assessment Adaptation',\n    sv: 'ISMS-riskbedömningsanpassning',\n    da: 'ISMS-risikovurderingstilpasning',\n    no: 'ISMS-risikovurderingstilpasning',\n    fi: 'ISMS-riskiarvioinnin sovellus',\n    de: 'ISMS-Risikobewertungsanpassung',\n    fr: 'Adaptation d’évaluation des risques ISMS',\n    es: 'Adaptación de evaluación de riesgos ISMS',\n    nl: 'ISMS-risicobeoordelingsaanpassing',\n    ar: 'تكييف تقييم مخاطر ISMS',\n    he: 'התאמת הערכת סיכונים ISMS',\n    ja: 'ISMSリスク評価適応',\n    ko: 'ISMS 리스크 평가 적응',\n    zh: 'ISMS 风险评估适配',\n  },\n  'analysis/reference/isms-style-guide-adaptation.md': {\n    en: 'ISMS Style-Guide Adaptation',\n    sv: 'ISMS-stilguideanpassning',\n    da: 'ISMS-stilguidetilpasning',\n    no: 'ISMS-stilveiledningstilpasning',\n    fi: 'ISMS-tyylioppaan sovellus',\n    de: 'ISMS-Stilleitfaden-Anpassung',\n    fr: 'Adaptation du guide de style ISMS',\n    es: 'Adaptación de la guía de estilo ISMS',\n    nl: 'ISMS-stijlgidsaanpassing',\n    ar: 'تكييف دليل أسلوب ISMS',\n    he: 'התאמת מדריך סגנון ISMS',\n    ja: 'ISMSスタイルガイド適応',\n    ko: 'ISMS 스타일 가이드 적응',\n    zh: 'ISMS 风格指南适配',\n  },\n  'analysis/reference/isms-threat-modeling-adaptation.md': {\n    en: 'ISMS Threat-Modeling Adaptation',\n    sv: 'ISMS-hotmodelleringsanpassning',\n    da: 'ISMS-trusselsmodelleringstilpasning',\n    no: 'ISMS-trusselmodelleringstilpasning',\n    fi: 'ISMS-uhkamallinnuksen sovellus',\n    de: 'ISMS-Bedrohungsmodellierungsanpassung',\n    fr: 'Adaptation de modélisation des menaces ISMS',\n    es: 'Adaptación del modelado de amenazas ISMS',\n    nl: 'ISMS-dreigingsmodelleringsaanpassing',\n    ar: 'تكييف نمذجة التهديدات ISMS',\n    he: 'התאמת מידול איומים ISMS',\n    ja: 'ISMS脅威モデリング適応',\n    ko: 'ISMS 위협 모델링 적응',\n    zh: 'ISMS 威胁建模适配',\n  },\n\n  // ========================================================================\n  // IMF Data (5)\n  // ========================================================================\n  'analysis/imf/README.md': {\n    en: 'IMF Data Integration — Overview',\n    sv: 'IMF-dataintegration — översikt',\n    da: 'IMF-dataintegration — oversigt',\n    no: 'IMF-dataintegrasjon — oversikt',\n    fi: 'IMF-datan integrointi — yleiskatsaus',\n    de: 'IWF-Datenintegration — Überblick',\n    fr: 'Intégration des données FMI — aperçu',\n    es: 'Integración de datos del FMI — visión general',\n    nl: 'IMF-data-integratie — overzicht',\n    ar: 'دمج بيانات صندوق النقد الدولي — نظرة عامة',\n    he: 'שילוב נתוני קרן המטבע — סקירה',\n    ja: 'IMFデータ統合 — 概要',\n    ko: 'IMF 데이터 통합 — 개요',\n    zh: 'IMF 数据集成 — 概览',\n  },\n  'analysis/imf/chart-integration-guide.md': {\n    en: 'IMF Chart Integration Guide',\n    sv: 'IMF-diagramintegrationsguide',\n    da: 'IMF-diagramintegrationsvejledning',\n    no: 'IMF-diagramintegrasjonsveiledning',\n    fi: 'IMF-kaavioiden integrointiopas',\n    de: 'IWF-Diagrammintegrationsleitfaden',\n    fr: 'Guide d’intégration des graphiques FMI',\n    es: 'Guía de integración de gráficos del FMI',\n    nl: 'IMF-grafiekintegratiegids',\n    ar: 'دليل دمج مخططات صندوق النقد الدولي',\n    he: 'מדריך שילוב תרשימי קרן המטבע',\n    ja: 'IMFチャート統合ガイド',\n    ko: 'IMF 차트 통합 가이드',\n    zh: 'IMF 图表集成指南',\n  },\n  'analysis/imf/eu-country-mapping.md': {\n    en: 'IMF EU Country & Aggregation Codes',\n    sv: 'IMF EU-land- och aggregatkoder',\n    da: 'IMF EU-lande- og aggregationskoder',\n    no: 'IMF EU-land- og aggregeringskoder',\n    fi: 'IMF EU-maa- ja aggregaattikoodit',\n    de: 'IWF EU-Länder- und Aggregationscodes',\n    fr: 'Codes pays & agrégations FMI UE',\n    es: 'Códigos de países y agregaciones FMI UE',\n    nl: 'IMF EU-land- en aggregatiecodes',\n    ar: 'رموز دول وتجميعات صندوق النقد الدولي للاتحاد الأوروبي',\n    he: 'קודי מדינות ואגרגציה של קרן המטבע לאיחוד האירופי',\n    ja: 'IMF EU 国・集計コード',\n    ko: 'IMF EU 국가 및 집계 코드',\n    zh: 'IMF 欧盟国家与聚合代码',\n  },\n  'analysis/imf/indicator-catalog.md': {\n    en: 'IMF Indicator Catalog',\n    sv: 'IMF-indikatorkatalog',\n    da: 'IMF-indikatorkatalog',\n    no: 'IMF-indikatorkatalog',\n    fi: 'IMF-indikaattorien luettelo',\n    de: 'IWF-Indikatorkatalog',\n    fr: 'Catalogue des indicateurs FMI',\n    es: 'Catálogo de indicadores del FMI',\n    nl: 'IMF-indicatorcatalogus',\n    ar: 'كتالوج مؤشرات صندوق النقد الدولي',\n    he: 'קטלוג מדדי קרן המטבע',\n    ja: 'IMF指標カタログ',\n    ko: 'IMF 지표 카탈로그',\n    zh: 'IMF 指标目录',\n  },\n  'analysis/imf/use-cases.md': {\n    en: 'IMF Data Use Cases',\n    sv: 'Användningsfall för IMF-data',\n    da: 'Use cases for IMF-data',\n    no: 'Brukstilfeller for IMF-data',\n    fi: 'IMF-datan käyttötapaukset',\n    de: 'IWF-Daten — Anwendungsfälle',\n    fr: 'Cas d’utilisation des données FMI',\n    es: 'Casos de uso de datos del FMI',\n    nl: 'Gebruiksgevallen voor IMF-data',\n    ar: 'حالات استخدام بيانات صندوق النقد الدولي',\n    he: 'תרחישי שימוש בנתוני קרן המטבע',\n    ja: 'IMFデータのユースケース',\n    ko: 'IMF 데이터 활용 사례',\n    zh: 'IMF 数据使用案例',\n  },\n\n  // ========================================================================\n  // World Bank Data (5)\n  // ========================================================================\n  'analysis/worldbank/README.md': {\n    en: 'World Bank Indicator Integration — Overview',\n    sv: 'Världsbankens indikatorintegration — översikt',\n    da: 'Verdensbankens indikatorintegration — oversigt',\n    no: 'Verdensbankens indikatorintegrasjon — oversikt',\n    fi: 'Maailmanpankin indikaattorien integrointi — yleiskatsaus',\n    de: 'Weltbank-Indikatorintegration — Überblick',\n    fr: 'Intégration des indicateurs Banque mondiale — aperçu',\n    es: 'Integración de indicadores del Banco Mundial — visión general',\n    nl: 'Wereldbank-indicatorintegratie — overzicht',\n    ar: 'دمج مؤشرات البنك الدولي — نظرة عامة',\n    he: 'שילוב מדדי הבנק העולמי — סקירה',\n    ja: '世界銀行指標統合 — 概要',\n    ko: '세계은행 지표 통합 — 개요',\n    zh: '世界银行指标集成 — 概览',\n  },\n  'analysis/worldbank/chart-integration-guide.md': {\n    en: 'World Bank Chart Integration Guide',\n    sv: 'Världsbankens diagramintegrationsguide',\n    da: 'Verdensbankens diagramintegrationsvejledning',\n    no: 'Verdensbankens diagramintegrasjonsveiledning',\n    fi: 'Maailmanpankin kaavioiden integrointiopas',\n    de: 'Weltbank-Diagrammintegrationsleitfaden',\n    fr: 'Guide d’intégration des graphiques Banque mondiale',\n    es: 'Guía de integración de gráficos del Banco Mundial',\n    nl: 'Wereldbank-grafiekintegratiegids',\n    ar: 'دليل دمج مخططات البنك الدولي',\n    he: 'מדריך שילוב תרשימי הבנק העולמי',\n    ja: '世界銀行チャート統合ガイド',\n    ko: '세계은행 차트 통합 가이드',\n    zh: '世界银行图表集成指南',\n  },\n  'analysis/worldbank/eu-country-mapping.md': {\n    en: 'EU-27 → World Bank Country-Code Mapping',\n    sv: 'EU-27 → Världsbankens landskodsmappning',\n    da: 'EU-27 → Verdensbankens landekodesmapping',\n    no: 'EU-27 → Verdensbankens landskodekobling',\n    fi: 'EU-27 → Maailmanpankin maakoodien kartoitus',\n    de: 'EU-27 → Weltbank-Ländercode-Zuordnung',\n    fr: 'EU-27 → Mappage des codes pays Banque mondiale',\n    es: 'EU-27 → Asignación de códigos de país del Banco Mundial',\n    nl: 'EU-27 → Wereldbank-landcodetoewijzing',\n    ar: 'EU-27 → ربط رموز دول البنك الدولي',\n    he: 'EU-27 → מיפוי קודי מדינות הבנק העולמי',\n    ja: 'EU-27 → 世界銀行国コードマッピング',\n    ko: 'EU-27 → 세계은행 국가 코드 매핑',\n    zh: 'EU-27 → 世界银行国家代码映射',\n  },\n  'analysis/worldbank/indicator-catalog.md': {\n    en: 'World Bank Indicator Catalog',\n    sv: 'Världsbanken-indikatorkatalog',\n    da: 'Verdensbank-indikatorkatalog',\n    no: 'Verdensbank-indikatorkatalog',\n    fi: 'Maailmanpankin indikaattorien luettelo',\n    de: 'Weltbank-Indikatorkatalog',\n    fr: 'Catalogue des indicateurs Banque mondiale',\n    es: 'Catálogo de indicadores del Banco Mundial',\n    nl: 'Wereldbank-indicatorcatalogus',\n    ar: 'كتالوج مؤشرات البنك الدولي',\n    he: 'קטלוג מדדי הבנק העולמי',\n    ja: '世界銀行指標カタログ',\n    ko: '세계은행 지표 카탈로그',\n    zh: '世界银行指标目录',\n  },\n  'analysis/worldbank/use-cases.md': {\n    en: 'World Bank Indicator Use Cases',\n    sv: 'Användningsfall för Världsbanken-indikatorer',\n    da: 'Use cases for Verdensbank-indikatorer',\n    no: 'Brukstilfeller for Verdensbank-indikatorer',\n    fi: 'Maailmanpankin indikaattorien käyttötapaukset',\n    de: 'Weltbank-Indikatoren — Anwendungsfälle',\n    fr: 'Cas d’utilisation des indicateurs Banque mondiale',\n    es: 'Casos de uso de indicadores del Banco Mundial',\n    nl: 'Gebruiksgevallen voor Wereldbank-indicatoren',\n    ar: 'حالات استخدام مؤشرات البنك الدولي',\n    he: 'תרחישי שימוש במדדי הבנק העולמי',\n    ja: '世界銀行指標のユースケース',\n    ko: '세계은행 지표 활용 사례',\n    zh: '世界银行指标使用案例',\n  },\n\n  // ========================================================================\n  // Templates (49) — titles localized; descriptions fall back to\n  // the English canonical + localized \"kind\" fallback sentence.\n  // ========================================================================\n  'analysis/templates/README.md': {\n    en: 'Analysis Template Library Index',\n    sv: 'Analysmallbibliotek — index',\n    da: 'Analyseskabelonbibliotek — indeks',\n    no: 'Analysemalsbibliotek — indeks',\n    fi: 'Analyysimallikirjasto — hakemisto',\n    de: 'Analyse-Vorlagen-Bibliothek — Index',\n    fr: 'Bibliothèque de modèles d’analyse — index',\n    es: 'Biblioteca de plantillas de análisis — índice',\n    nl: 'Analysesjabloonbibliotheek — index',\n    ar: 'فهرس مكتبة قوالب التحليل',\n    he: 'אינדקס ספריית תבניות הניתוח',\n    ja: '分析テンプレートライブラリ索引',\n    ko: '분석 템플릿 라이브러리 색인',\n    zh: '分析模板库索引',\n  },\n  'analysis/templates/actor-mapping.md': {\n    en: 'Actor Mapping',\n    sv: 'Aktörskartläggning',\n    da: 'Aktørmapping',\n    no: 'Aktørkartlegging',\n    fi: 'Toimijoiden kartoitus',\n    de: 'Akteurs-Mapping',\n    fr: 'Cartographie des acteurs',\n    es: 'Mapeo de actores',\n    nl: 'Actor-mapping',\n    ar: 'رسم خرائط الفاعلين',\n    he: 'מיפוי שחקנים',\n    ja: 'アクターマッピング',\n    ko: '행위자 매핑',\n    zh: '参与者映射',\n  },\n  'analysis/templates/actor-threat-profiles.md': {\n    en: 'Actor Threat Profiles',\n    sv: 'Aktörshotprofiler',\n    da: 'Aktørtrusselprofiler',\n    no: 'Aktørtrusselprofiler',\n    fi: 'Toimijoiden uhkaprofiilit',\n    de: 'Akteurs-Bedrohungsprofile',\n    fr: 'Profils de menace des acteurs',\n    es: 'Perfiles de amenaza de actores',\n    nl: 'Dreigingsprofielen van actoren',\n    ar: 'ملفات تعريف تهديد الفاعلين',\n    he: 'פרופילי איום של שחקנים',\n    ja: 'アクター脅威プロファイル',\n    ko: '행위자 위협 프로필',\n    zh: '参与者威胁画像',\n  },\n  'analysis/templates/analysis-index.md': {\n    en: 'Analysis Index (Run Artifact Navigator)',\n    sv: 'Analysindex (artefaktnavigator för körning)',\n    da: 'Analyseindeks (kørselsartefaktnavigator)',\n    no: 'Analyseindeks (kjøringsartefaktnavigator)',\n    fi: 'Analyysihakemisto (ajo­artefaktien navigaattori)',\n    de: 'Analyseindex (Run-Artefakt-Navigator)',\n    fr: 'Index d’analyse (navigateur d’artefacts d’exécution)',\n    es: 'Índice de análisis (navegador de artefactos de ejecución)',\n    nl: 'Analyse-index (run-artefactnavigator)',\n    ar: 'فهرس التحليل (متنقل قطع التشغيل)',\n    he: 'אינדקס ניתוח (ניווט ארטיפקטי ריצה)',\n    ja: '分析索引(ラン成果物ナビゲータ)',\n    ko: '분석 색인(실행 산출물 내비게이터)',\n    zh: '分析索引（运行工件导航器）',\n  },\n  'analysis/templates/coalition-dynamics.md': {\n    en: 'Coalition Dynamics',\n    sv: 'Koalitionsdynamik',\n    da: 'Koalitionsdynamik',\n    no: 'Koalisjonsdynamikk',\n    fi: 'Koalitiodynamiikka',\n    de: 'Koalitionsdynamik',\n    fr: 'Dynamique des coalitions',\n    es: 'Dinámica de coaliciones',\n    nl: 'Coalitiedynamiek',\n    ar: 'ديناميكيات التحالف',\n    he: 'דינמיקת קואליציות',\n    ja: '連立ダイナミクス',\n    ko: '연정 역학',\n    zh: '联盟动态',\n  },\n  'analysis/templates/coalition-mathematics.md': {\n    en: 'Coalition Mathematics',\n    sv: 'Koalitionsmatematik',\n    da: 'Koalitionsmatematik',\n    no: 'Koalisjonsmatematikk',\n    fi: 'Koalitiomatematiikka',\n    de: 'Koalitionsmathematik',\n    fr: 'Mathématiques des coalitions',\n    es: 'Matemáticas de coaliciones',\n    nl: 'Coalitiewiskunde',\n    ar: 'رياضيات التحالف',\n    he: 'מתמטיקה של קואליציות',\n    ja: '連立数学',\n    ko: '연정 수학',\n    zh: '联盟数学',\n  },\n  'analysis/templates/comparative-international.md': {\n    en: 'Comparative International Analysis',\n    sv: 'Jämförande internationell analys',\n    da: 'Komparativ international analyse',\n    no: 'Komparativ internasjonal analyse',\n    fi: 'Vertaileva kansainvälinen analyysi',\n    de: 'Vergleichende internationale Analyse',\n    fr: 'Analyse internationale comparative',\n    es: 'Análisis internacional comparado',\n    nl: 'Vergelijkende internationale analyse',\n    ar: 'التحليل الدولي المقارن',\n    he: 'ניתוח בינלאומי השוואתי',\n    ja: '比較国際分析',\n    ko: '비교 국제 분석',\n    zh: '比较国际分析',\n  },\n  'analysis/templates/consequence-trees.md': {\n    en: 'Consequence Trees',\n    sv: 'Konsekvensträd',\n    da: 'Konsekvenstræer',\n    no: 'Konsekvenstrær',\n    fi: 'Seurauspuut',\n    de: 'Konsequenzbäume',\n    fr: 'Arbres des conséquences',\n    es: 'Árboles de consecuencias',\n    nl: 'Gevolgenbomen',\n    ar: 'أشجار العواقب',\n    he: 'עצי השלכה',\n    ja: '帰結ツリー',\n    ko: '결과 트리',\n    zh: '后果树',\n  },\n  'analysis/templates/cross-reference-map.md': {\n    en: 'Cross-Reference Map',\n    sv: 'Korsreferenskarta',\n    da: 'Krydshenvisningskort',\n    no: 'Kryssreferansekart',\n    fi: 'Ristiviittauskartta',\n    de: 'Querverweiskarte',\n    fr: 'Carte de références croisées',\n    es: 'Mapa de referencias cruzadas',\n    nl: 'Kruisverwijzingskaart',\n    ar: 'خريطة الإحالات المتقاطعة',\n    he: 'מפת הפניות צולבות',\n    ja: 'クロスリファレンスマップ',\n    ko: '교차 참조 지도',\n    zh: '交叉引用地图',\n  },\n  'analysis/templates/cross-run-diff.md': {\n    en: 'Cross-Run Diff (Bayesian Delta)',\n    sv: 'Diff mellan körningar (bayesiansk delta)',\n    da: 'Kørselsdiff (Bayesiansk delta)',\n    no: 'Kjøringsdiff (Bayesiansk delta)',\n    fi: 'Ajojen välinen diff (Bayesin delta)',\n    de: 'Cross-Run-Diff (Bayesianisches Delta)',\n    fr: 'Diff entre exécutions (delta bayésien)',\n    es: 'Diff entre ejecuciones (delta bayesiano)',\n    nl: 'Cross-run-diff (Bayesiaanse delta)',\n    ar: 'فرق عبر التشغيلات (دلتا بايزية)',\n    he: 'דיף בין ריצות (דלתא בייסיאנית)',\n    ja: 'ラン間差分(ベイジアンデルタ)',\n    ko: '실행 간 차분(베이지안 델타)',\n    zh: '跨运行差异（贝叶斯增量）',\n  },\n  'analysis/templates/cross-session-intelligence.md': {\n    en: 'Cross-Session Intelligence',\n    sv: 'Sessionsövergripande underrättelse',\n    da: 'Sessionsovergribende efterretning',\n    no: 'Sesjonsovergripende etterretning',\n    fi: 'Istuntojen välinen tiedustelu',\n    de: 'Sitzungsübergreifende Aufklärung',\n    fr: 'Renseignement inter-sessions',\n    es: 'Inteligencia entre sesiones',\n    nl: 'Intersessionele inlichtingen',\n    ar: 'استخبارات عبر الجلسات',\n    he: 'מודיעין בין-מושבי',\n    ja: 'セッション横断インテリジェンス',\n    ko: '세션 간 정보',\n    zh: '跨会议情报',\n  },\n  'analysis/templates/data-download-manifest.md': {\n    en: 'Data Download Manifest',\n    sv: 'Datanedladdningsmanifest',\n    da: 'Datadownloadmanifest',\n    no: 'Datanedlastingsmanifest',\n    fi: 'Datan latausmanifesti',\n    de: 'Daten-Download-Manifest',\n    fr: 'Manifeste de téléchargement de données',\n    es: 'Manifiesto de descarga de datos',\n    nl: 'Datadownload-manifest',\n    ar: 'بيان تنزيل البيانات',\n    he: 'מניפסט הורדת נתונים',\n    ja: 'データダウンロード・マニフェスト',\n    ko: '데이터 다운로드 매니페스트',\n    zh: '数据下载清单',\n  },\n  'analysis/templates/deep-analysis.md': {\n    en: 'Deep Political Analysis (Long-Form)',\n    sv: 'Djup politisk analys (långformat)',\n    da: 'Dyb politisk analyse (langform)',\n    no: 'Dyp politisk analyse (langform)',\n    fi: 'Syvä poliittinen analyysi (pitkä muoto)',\n    de: 'Tiefgehende politische Analyse (Langform)',\n    fr: 'Analyse politique approfondie (format long)',\n    es: 'Análisis político profundo (formato largo)',\n    nl: 'Diepe politieke analyse (langvorm)',\n    ar: 'تحليل سياسي معمق (شكل مطول)',\n    he: 'ניתוח פוליטי מעמיק (פורמט ארוך)',\n    ja: '深い政治分析(ロングフォーム)',\n    ko: '심층 정치 분석(롱폼)',\n    zh: '深度政治分析（长篇）',\n  },\n  'analysis/templates/devils-advocate-analysis.md': {\n    en: 'Devil’s Advocate Analysis',\n    sv: 'Djävulens advokat-analys',\n    da: 'Djævlens advokat-analyse',\n    no: 'Djevelens advokat-analyse',\n    fi: 'Paholaisen asianajajan analyysi',\n    de: 'Advocatus-Diaboli-Analyse',\n    fr: 'Analyse de l’avocat du diable',\n    es: 'Análisis del abogado del diablo',\n    nl: 'Advocaat-van-de-duivel-analyse',\n    ar: 'تحليل محامي الشيطان',\n    he: 'ניתוח פרקליט השטן',\n    ja: '悪魔の代弁者分析',\n    ko: '악마의 대변인 분석',\n    zh: '魔鬼代言人分析',\n  },\n  'analysis/templates/economic-context.md': {\n    en: 'Economic Context (World Bank & IMF)',\n    sv: 'Ekonomisk kontext (Världsbanken & IMF)',\n    da: 'Økonomisk kontekst (Verdensbanken & IMF)',\n    no: 'Økonomisk kontekst (Verdensbanken & IMF)',\n    fi: 'Taloudellinen konteksti (Maailmanpankki & IMF)',\n    de: 'Wirtschaftlicher Kontext (Weltbank & IWF)',\n    fr: 'Contexte économique (Banque mondiale & FMI)',\n    es: 'Contexto económico (Banco Mundial y FMI)',\n    nl: 'Economische context (Wereldbank & IMF)',\n    ar: 'السياق الاقتصادي (البنك الدولي وصندوق النقد)',\n    he: 'הקשר כלכלי (הבנק העולמי וקרן המטבע)',\n    ja: '経済コンテキスト(世界銀行・IMF)',\n    ko: '경제 컨텍스트(세계은행·IMF)',\n    zh: '经济背景（世界银行与 IMF）',\n  },\n  'analysis/templates/executive-brief.md': {\n    en: 'Executive Brief',\n    sv: 'Ledningsbrief',\n    da: 'Lederbriefing',\n    no: 'Ledelsesbrief',\n    fi: 'Johdon tiivistelmä',\n    de: 'Executive Brief',\n    fr: 'Note exécutive',\n    es: 'Informe ejecutivo',\n    nl: 'Executive briefing',\n    ar: 'موجز تنفيذي',\n    he: 'תדריך ניהולי',\n    ja: 'エグゼクティブ・ブリーフ',\n    ko: '경영진 브리프',\n    zh: '高管简报',\n  },\n  'analysis/templates/forces-analysis.md': {\n    en: 'Forces Analysis (Lewin Force-Field)',\n    sv: 'Kraftanalys (Lewins kraftfält)',\n    da: 'Kraftanalyse (Lewins kraftfelt)',\n    no: 'Kraftanalyse (Lewins kraftfelt)',\n    fi: 'Voima-analyysi (Lewinin voima­kenttä)',\n    de: 'Kräfteanalyse (Lewin-Kraftfeld)',\n    fr: 'Analyse des forces (champ de forces de Lewin)',\n    es: 'Análisis de fuerzas (campo de fuerzas de Lewin)',\n    nl: 'Krachtenanalyse (Lewin-krachtenveld)',\n    ar: 'تحليل القوى (حقل قوى ليفين)',\n    he: 'ניתוח כוחות (שדה כוחות לוין)',\n    ja: '勢力分析(レヴィン力場)',\n    ko: '세력 분석(레빈 역장)',\n    zh: '力场分析（勒温力场）',\n  },\n  'analysis/templates/forward-indicators.md': {\n    en: 'Forward Indicators',\n    sv: 'Framåtblickande indikatorer',\n    da: 'Fremadrettede indikatorer',\n    no: 'Fremoverrettede indikatorer',\n    fi: 'Ennakoivat indikaattorit',\n    de: 'Vorlaufindikatoren',\n    fr: 'Indicateurs avancés',\n    es: 'Indicadores adelantados',\n    nl: 'Voorlopende indicatoren',\n    ar: 'المؤشرات الاستباقية',\n    he: 'מדדים צופים פני עתיד',\n    ja: '先行指標',\n    ko: '선행 지표',\n    zh: '前瞻指标',\n  },\n  'analysis/templates/historical-baseline.md': {\n    en: 'Historical Baseline',\n    sv: 'Historisk baslinje',\n    da: 'Historisk basislinje',\n    no: 'Historisk grunnlinje',\n    fi: 'Historiallinen lähtötaso',\n    de: 'Historische Basislinie',\n    fr: 'Référence historique',\n    es: 'Línea base histórica',\n    nl: 'Historische basislijn',\n    ar: 'خط الأساس التاريخي',\n    he: 'קו בסיס היסטורי',\n    ja: '歴史的ベースライン',\n    ko: '역사적 기준선',\n    zh: '历史基线',\n  },\n  'analysis/templates/historical-parallels.md': {\n    en: 'Historical Parallels',\n    sv: 'Historiska paralleller',\n    da: 'Historiske paralleller',\n    no: 'Historiske paralleller',\n    fi: 'Historialliset rinnakkaistapaukset',\n    de: 'Historische Parallelen',\n    fr: 'Parallèles historiques',\n    es: 'Paralelos históricos',\n    nl: 'Historische parallellen',\n    ar: 'التوازيات التاريخية',\n    he: 'הקבלות היסטוריות',\n    ja: '歴史的類似例',\n    ko: '역사적 유사 사례',\n    zh: '历史类比',\n  },\n  'analysis/templates/impact-matrix.md': {\n    en: 'Impact Matrix (Event × Stakeholder)',\n    sv: 'Effektmatris (händelse × intressent)',\n    da: 'Effektmatrix (begivenhed × interessent)',\n    no: 'Effektmatrise (hendelse × interessent)',\n    fi: 'Vaikutusmatriisi (tapahtuma × sidosryhmä)',\n    de: 'Auswirkungsmatrix (Ereignis × Stakeholder)',\n    fr: 'Matrice d’impact (événement × partie prenante)',\n    es: 'Matriz de impacto (evento × interesado)',\n    nl: 'Impactmatrix (gebeurtenis × belanghebbende)',\n    ar: 'مصفوفة التأثير (حدث × أصحاب مصلحة)',\n    he: 'מטריצת השפעה (אירוע × בעלי עניין)',\n    ja: '影響マトリクス(事象×ステークホルダー)',\n    ko: '영향 매트릭스(이벤트×이해관계자)',\n    zh: '影响矩阵（事件×利益相关方）',\n  },\n  'analysis/templates/implementation-feasibility.md': {\n    en: 'Implementation Feasibility',\n    sv: 'Genomförbarhet av implementering',\n    da: 'Implementeringsgennemførlighed',\n    no: 'Gjennomførbarhet av implementering',\n    fi: 'Toteutettavuus',\n    de: 'Umsetzbarkeit der Implementierung',\n    fr: 'Faisabilité de mise en œuvre',\n    es: 'Viabilidad de implementación',\n    nl: 'Implementeerbaarheid',\n    ar: 'جدوى التنفيذ',\n    he: 'היתכנות יישום',\n    ja: '実装実行可能性',\n    ko: '구현 실현 가능성',\n    zh: '实施可行性',\n  },\n  'analysis/templates/intelligence-assessment.md': {\n    en: 'Intelligence Assessment',\n    sv: 'Underrättelsebedömning',\n    da: 'Efterretningsvurdering',\n    no: 'Etterretningsvurdering',\n    fi: 'Tiedusteluarvio',\n    de: 'Aufklärungsbewertung',\n    fr: 'Évaluation du renseignement',\n    es: 'Evaluación de inteligencia',\n    nl: 'Inlichtingenbeoordeling',\n    ar: 'تقييم استخباراتي',\n    he: 'הערכה מודיעינית',\n    ja: 'インテリジェンス評価',\n    ko: '정보 평가',\n    zh: '情报评估',\n  },\n  'analysis/templates/legislative-disruption.md': {\n    en: 'Legislative Disruption',\n    sv: 'Lagstiftningsstörning',\n    da: 'Lovgivningsforstyrrelse',\n    no: 'Lovgivningsforstyrrelse',\n    fi: 'Lainsäädännön häiriö',\n    de: 'Gesetzgebungsunterbrechung',\n    fr: 'Perturbation législative',\n    es: 'Disrupción legislativa',\n    nl: 'Wetgevingsverstoring',\n    ar: 'اضطراب تشريعي',\n    he: 'שיבוש חקיקתי',\n    ja: '立法撹乱',\n    ko: '입법 교란',\n    zh: '立法干扰',\n  },\n  'analysis/templates/legislative-velocity-risk.md': {\n    en: 'Legislative Velocity Risk',\n    sv: 'Risk för lagstiftningshastighet',\n    da: 'Risiko for lovgivningshastighed',\n    no: 'Risiko for lovgivningshastighet',\n    fi: 'Lainsäädännön nopeuden riski',\n    de: 'Risiko der Gesetzgebungsgeschwindigkeit',\n    fr: 'Risque lié à la vélocité législative',\n    es: 'Riesgo de velocidad legislativa',\n    nl: 'Risico van wetgevingssnelheid',\n    ar: 'مخاطر سرعة التشريع',\n    he: 'סיכון מהירות חקיקה',\n    ja: '立法速度リスク',\n    ko: '입법 속도 리스크',\n    zh: '立法速度风险',\n  },\n  'analysis/templates/mcp-reliability-audit.md': {\n    en: 'MCP Reliability Audit',\n    sv: 'MCP-tillförlitlighetsrevision',\n    da: 'MCP-pålidelighedsrevision',\n    no: 'MCP-pålitelighetsrevisjon',\n    fi: 'MCP-luotettavuustarkastus',\n    de: 'MCP-Zuverlässigkeitsaudit',\n    fr: 'Audit de fiabilité MCP',\n    es: 'Auditoría de fiabilidad MCP',\n    nl: 'MCP-betrouwbaarheidsaudit',\n    ar: 'تدقيق موثوقية MCP',\n    he: 'ביקורת אמינות MCP',\n    ja: 'MCP信頼性監査',\n    ko: 'MCP 신뢰성 감사',\n    zh: 'MCP 可靠性审计',\n  },\n  'analysis/templates/media-framing-analysis.md': {\n    en: 'Media Framing Analysis',\n    sv: 'Mediaframingsanalys',\n    da: 'Medieindramningsanalyse',\n    no: 'Medieinnramningsanalyse',\n    fi: 'Median kehystysanalyysi',\n    de: 'Medien-Framing-Analyse',\n    fr: 'Analyse du cadrage médiatique',\n    es: 'Análisis de encuadre mediático',\n    nl: 'Analyse van mediaframing',\n    ar: 'تحليل التأطير الإعلامي',\n    he: 'ניתוח מסגור תקשורתי',\n    ja: 'メディアフレーミング分析',\n    ko: '미디어 프레이밍 분석',\n    zh: '媒体框架分析',\n  },\n  'analysis/templates/methodology-reflection.md': {\n    en: 'Methodology Reflection (Retrospective)',\n    sv: 'Metodologireflektion (retrospektiv)',\n    da: 'Metoderefleksion (retrospektiv)',\n    no: 'Metoderefleksjon (retrospektiv)',\n    fi: 'Metodologinen reflektio (retrospektiivi)',\n    de: 'Methodologie-Reflexion (Retrospektive)',\n    fr: 'Réflexion méthodologique (rétrospective)',\n    es: 'Reflexión metodológica (retrospectiva)',\n    nl: 'Methodologiereflectie (retrospectief)',\n    ar: 'تأمل منهجي (استعادي)',\n    he: 'רפלקציה מתודולוגית (רטרוספקטיבה)',\n    ja: '方法論振り返り(レトロ)',\n    ko: '방법론 성찰(회고)',\n    zh: '方法论反思（回顾）',\n  },\n  'analysis/templates/per-file-political-intelligence.md': {\n    en: 'Per-File Political Intelligence',\n    sv: 'Per-fil politisk underrättelse',\n    da: 'Pr.-fil politisk efterretning',\n    no: 'Per-fil politisk etterretning',\n    fi: 'Tiedosto­kohtainen poliittinen tiedustelu',\n    de: 'Politische Aufklärung pro Datei',\n    fr: 'Renseignement politique par fichier',\n    es: 'Inteligencia política por archivo',\n    nl: 'Politieke inlichtingen per bestand',\n    ar: 'الاستخبارات السياسية لكل ملف',\n    he: 'מודיעין פוליטי לכל קובץ',\n    ja: 'ファイル別政治インテリジェンス',\n    ko: '파일별 정치 정보',\n    zh: '按文件政治情报',\n  },\n  'analysis/templates/pestle-analysis.md': {\n    en: 'PESTLE Analysis (Six-Dimension Scan)',\n    sv: 'PESTLE-analys (sex dimensioner)',\n    da: 'PESTLE-analyse (seks dimensioner)',\n    no: 'PESTLE-analyse (seks dimensjoner)',\n    fi: 'PESTLE-analyysi (kuusi ulottuvuutta)',\n    de: 'PESTLE-Analyse (Sechs-Dimensionen-Scan)',\n    fr: 'Analyse PESTLE (scan à six dimensions)',\n    es: 'Análisis PESTLE (escaneo de seis dimensiones)',\n    nl: 'PESTLE-analyse (zesdimensionale scan)',\n    ar: 'تحليل PESTLE (مسح سداسي الأبعاد)',\n    he: 'ניתוח PESTLE (סריקה בשישה מימדים)',\n    ja: 'PESTLE分析(六次元スキャン)',\n    ko: 'PESTLE 분석(6차원 스캔)',\n    zh: 'PESTLE 分析（六维扫描）',\n  },\n  'analysis/templates/political-capital-risk.md': {\n    en: 'Political Capital Risk',\n    sv: 'Politisk kapitalrisk',\n    da: 'Politisk kapitalrisiko',\n    no: 'Politisk kapitalrisiko',\n    fi: 'Poliittisen pääoman riski',\n    de: 'Politisches Kapitalrisiko',\n    fr: 'Risque pour le capital politique',\n    es: 'Riesgo de capital político',\n    nl: 'Risico voor politiek kapitaal',\n    ar: 'مخاطر رأس المال السياسي',\n    he: 'סיכון הון פוליטי',\n    ja: '政治資本リスク',\n    ko: '정치 자본 리스크',\n    zh: '政治资本风险',\n  },\n  'analysis/templates/political-classification.md': {\n    en: 'Political Event Classification',\n    sv: 'Klassificering av politiska händelser',\n    da: 'Klassifikation af politiske begivenheder',\n    no: 'Klassifisering av politiske hendelser',\n    fi: 'Poliittisten tapahtumien luokittelu',\n    de: 'Klassifizierung politischer Ereignisse',\n    fr: 'Classification des événements politiques',\n    es: 'Clasificación de eventos políticos',\n    nl: 'Classificatie van politieke gebeurtenissen',\n    ar: 'تصنيف الأحداث السياسية',\n    he: 'סיווג אירועים פוליטיים',\n    ja: '政治イベント分類',\n    ko: '정치 이벤트 분류',\n    zh: '政治事件分类',\n  },\n  'analysis/templates/political-threat-landscape.md': {\n    en: 'Political Threat Landscape',\n    sv: 'Politiskt hotlandskap',\n    da: 'Politisk trusselslandskab',\n    no: 'Politisk trussellandskap',\n    fi: 'Poliittinen uhkamaisema',\n    de: 'Politische Bedrohungslandschaft',\n    fr: 'Paysage des menaces politiques',\n    es: 'Panorama de amenazas políticas',\n    nl: 'Politiek dreigingslandschap',\n    ar: 'مشهد التهديدات السياسية',\n    he: 'נוף איומים פוליטי',\n    ja: '政治脅威ランドスケープ',\n    ko: '정치 위협 환경',\n    zh: '政治威胁格局',\n  },\n  'analysis/templates/quantitative-swot.md': {\n    en: 'Quantitative SWOT (Numeric + TOWS)',\n    sv: 'Kvantitativ SWOT (numerisk + TOWS)',\n    da: 'Kvantitativ SWOT (numerisk + TOWS)',\n    no: 'Kvantitativ SWOT (numerisk + TOWS)',\n    fi: 'Kvantitatiivinen SWOT (numeerinen + TOWS)',\n    de: 'Quantitative SWOT (numerisch + TOWS)',\n    fr: 'SWOT quantitative (numérique + TOWS)',\n    es: 'SWOT cuantitativo (numérico + TOWS)',\n    nl: 'Kwantitatieve SWOT (numeriek + TOWS)',\n    ar: 'SWOT الكمي (عددي + TOWS)',\n    he: 'SWOT כמותי (מספרי + TOWS)',\n    ja: '定量SWOT(数値+TOWS)',\n    ko: '정량 SWOT(수치+TOWS)',\n    zh: '定量 SWOT（数值+TOWS）',\n  },\n  'analysis/templates/reference-analysis-quality.md': {\n    en: 'Reference Analysis Quality',\n    sv: 'Kvalitet på referensanalys',\n    da: 'Kvalitet af referenceanalyse',\n    no: 'Kvalitet på referanseanalyse',\n    fi: 'Viiteanalyysin laatu',\n    de: 'Qualität der Referenzanalyse',\n    fr: 'Qualité de l’analyse de référence',\n    es: 'Calidad del análisis de referencia',\n    nl: 'Kwaliteit van referentieanalyse',\n    ar: 'جودة التحليل المرجعي',\n    he: 'איכות ניתוח ייחוס',\n    ja: '参照分析品質',\n    ko: '참조 분석 품질',\n    zh: '参考分析质量',\n  },\n  'analysis/templates/risk-assessment.md': {\n    en: 'Political Risk Assessment',\n    sv: 'Politisk riskbedömning',\n    da: 'Politisk risikovurdering',\n    no: 'Politisk risikovurdering',\n    fi: 'Poliittinen riskiarviointi',\n    de: 'Politische Risikobewertung',\n    fr: 'Évaluation des risques politiques',\n    es: 'Evaluación de riesgos políticos',\n    nl: 'Politieke risicobeoordeling',\n    ar: 'تقييم المخاطر السياسية',\n    he: 'הערכת סיכונים פוליטיים',\n    ja: '政治リスク評価',\n    ko: '정치 리스크 평가',\n    zh: '政治风险评估',\n  },\n  'analysis/templates/risk-matrix.md': {\n    en: 'Risk Matrix (5×5 Likelihood × Impact)',\n    sv: 'Riskmatris (5×5 sannolikhet × effekt)',\n    da: 'Risikomatrix (5×5 sandsynlighed × effekt)',\n    no: 'Risikomatrise (5×5 sannsynlighet × effekt)',\n    fi: 'Riskimatriisi (5×5 todennäköisyys × vaikutus)',\n    de: 'Risikomatrix (5×5 Wahrscheinlichkeit × Auswirkung)',\n    fr: 'Matrice des risques (5×5 probabilité × impact)',\n    es: 'Matriz de riesgos (5×5 probabilidad × impacto)',\n    nl: 'Risicomatrix (5×5 waarschijnlijkheid × impact)',\n    ar: 'مصفوفة المخاطر (5×5 احتمالية × تأثير)',\n    he: 'מטריצת סיכונים (5×5 הסתברות × השפעה)',\n    ja: 'リスクマトリクス(5×5 確率×影響)',\n    ko: '리스크 매트릭스(5×5 가능성×영향)',\n    zh: '风险矩阵（5×5 可能性×影响）',\n  },\n  'analysis/templates/scenario-forecast.md': {\n    en: 'Scenario Forecast (Probability-Weighted)',\n    sv: 'Scenarioprognos (sannolikhetsviktad)',\n    da: 'Scenarieprognose (sandsynlighedsvægtet)',\n    no: 'Scenarioprognose (sannsynlighetsvektet)',\n    fi: 'Skenaarioennuste (todennäköisyys­painotettu)',\n    de: 'Szenarioprognose (wahrscheinlichkeits­gewichtet)',\n    fr: 'Prévision de scénarios (pondérée par probabilité)',\n    es: 'Pronóstico de escenarios (ponderado por probabilidad)',\n    nl: 'Scenarioprognose (kansgewogen)',\n    ar: 'توقع السيناريوهات (مرجح بالاحتمالية)',\n    he: 'תחזית תרחישים (ממושקלת הסתברות)',\n    ja: 'シナリオ予測(確率加重)',\n    ko: '시나리오 예측(확률 가중)',\n    zh: '情景预测（概率加权）',\n  },\n  'analysis/templates/session-baseline.md': {\n    en: 'Session Baseline (Plenary Calendar)',\n    sv: 'Sessionsbaslinje (plenarkalender)',\n    da: 'Sessionsbasislinje (plenarkalender)',\n    no: 'Sesjonsgrunnlinje (plenarkalender)',\n    fi: 'Istunnon lähtötaso (täysistunto­kalenteri)',\n    de: 'Sitzungsbasislinie (Plenarkalender)',\n    fr: 'Référence de session (calendrier plénier)',\n    es: 'Línea base de sesión (calendario plenario)',\n    nl: 'Sessiebasislijn (plenaire kalender)',\n    ar: 'خط الأساس للجلسة (جدول الجلسة العامة)',\n    he: 'בסיס מושב (לוח מליאה)',\n    ja: 'セッション基準(本会議カレンダー)',\n    ko: '세션 기준선(본회의 일정)',\n    zh: '会议基线（全会日历）',\n  },\n  'analysis/templates/significance-classification.md': {\n    en: 'Significance Classification (5-Dimension Rubric)',\n    sv: 'Signifikansklassificering (5-dimensionell rubrik)',\n    da: 'Signifikansklassifikation (5-dimensionel rubrik)',\n    no: 'Signifikansklassifisering (5-dimensjonal rubrikk)',\n    fi: 'Merkitys­luokitus (5-ulotteinen kriteeristö)',\n    de: 'Signifikanzklassifikation (5-Dimensionen-Rubrik)',\n    fr: 'Classification de la signification (grille à 5 dimensions)',\n    es: 'Clasificación de significancia (rúbrica de 5 dimensiones)',\n    nl: 'Significantieclassificatie (5-dimensionale rubriek)',\n    ar: 'تصنيف الأهمية (جدول بخمسة أبعاد)',\n    he: 'סיווג משמעות (שולחן חמישה-מימדי)',\n    ja: '重要度分類(5次元ルーブリック)',\n    ko: '중요도 분류(5차원 루브릭)',\n    zh: '重要性分类（五维评分表）',\n  },\n  'analysis/templates/significance-scoring.md': {\n    en: 'Political Significance Scoring',\n    sv: 'Politisk signifikanspoäng',\n    da: 'Politisk signifikansscoring',\n    no: 'Politisk signifikansscoring',\n    fi: 'Poliittisen merkityksen pisteytys',\n    de: 'Politische Signifikanzbewertung',\n    fr: 'Notation de la signification politique',\n    es: 'Puntuación de significancia política',\n    nl: 'Politieke significantiescore',\n    ar: 'تسجيل الأهمية السياسية',\n    he: 'דירוג משמעות פוליטית',\n    ja: '政治的重要度スコアリング',\n    ko: '정치적 중요도 점수화',\n    zh: '政治重要性评分',\n  },\n  'analysis/templates/stakeholder-impact.md': {\n    en: 'Stakeholder Impact Assessment',\n    sv: 'Intressenteffektbedömning',\n    da: 'Interessentpåvirkningsvurdering',\n    no: 'Interessentpåvirkningsvurdering',\n    fi: 'Sidosryhmän vaikutusarviointi',\n    de: 'Stakeholder-Impact-Assessment',\n    fr: 'Évaluation de l’impact sur les parties prenantes',\n    es: 'Evaluación de impacto de interesados',\n    nl: 'Impactbeoordeling voor belanghebbenden',\n    ar: 'تقييم تأثير أصحاب المصلحة',\n    he: 'הערכת השפעה על בעלי עניין',\n    ja: 'ステークホルダー影響評価',\n    ko: '이해관계자 영향 평가',\n    zh: '利益相关方影响评估',\n  },\n  'analysis/templates/stakeholder-map.md': {\n    en: 'Stakeholder Map (Power × Alignment)',\n    sv: 'Intressentkarta (makt × linje)',\n    da: 'Interessentkort (magt × linje)',\n    no: 'Interessentkart (makt × linje)',\n    fi: 'Sidosryhmäkartta (valta × linja)',\n    de: 'Stakeholder-Map (Macht × Ausrichtung)',\n    fr: 'Carte des parties prenantes (pouvoir × alignement)',\n    es: 'Mapa de interesados (poder × alineación)',\n    nl: 'Stakeholderkaart (macht × uitlijning)',\n    ar: 'خريطة أصحاب المصلحة (قوة × توافق)',\n    he: 'מפת בעלי עניין (כוח × יישור)',\n    ja: 'ステークホルダー・マップ(権力×整合)',\n    ko: '이해관계자 지도(권력×정렬)',\n    zh: '利益相关方地图（权力×一致）',\n  },\n  'analysis/templates/swot-analysis.md': {\n    en: 'Political SWOT Analysis',\n    sv: 'Politisk SWOT-analys',\n    da: 'Politisk SWOT-analyse',\n    no: 'Politisk SWOT-analyse',\n    fi: 'Poliittinen SWOT-analyysi',\n    de: 'Politische SWOT-Analyse',\n    fr: 'Analyse SWOT politique',\n    es: 'Análisis SWOT político',\n    nl: 'Politieke SWOT-analyse',\n    ar: 'تحليل SWOT السياسي',\n    he: 'ניתוח SWOT פוליטי',\n    ja: '政治SWOT分析',\n    ko: '정치 SWOT 분석',\n    zh: '政治 SWOT 分析',\n  },\n  'analysis/templates/synthesis-summary.md': {\n    en: 'Synthesis Summary',\n    sv: 'Syntessammanfattning',\n    da: 'Syntesesammenfatning',\n    no: 'Syntesesammendrag',\n    fi: 'Synteesiyhteenveto',\n    de: 'Synthese-Zusammenfassung',\n    fr: 'Résumé de synthèse',\n    es: 'Resumen de síntesis',\n    nl: 'Synthese-samenvatting',\n    ar: 'ملخص التوليف',\n    he: 'סיכום סינתזה',\n    ja: '総合サマリー',\n    ko: '종합 요약',\n    zh: '综合摘要',\n  },\n  'analysis/templates/threat-analysis.md': {\n    en: 'Political Threat Landscape Analysis',\n    sv: 'Politisk hotlandskapsanalys',\n    da: 'Politisk trusselslandskabsanalyse',\n    no: 'Politisk trussellandskapsanalyse',\n    fi: 'Poliittisen uhkamaiseman analyysi',\n    de: 'Analyse der politischen Bedrohungslandschaft',\n    fr: 'Analyse du paysage des menaces politiques',\n    es: 'Análisis del panorama de amenazas políticas',\n    nl: 'Analyse van het politieke dreigingslandschap',\n    ar: 'تحليل مشهد التهديدات السياسية',\n    he: 'ניתוח נוף האיומים הפוליטי',\n    ja: '政治脅威ランドスケープ分析',\n    ko: '정치 위협 환경 분석',\n    zh: '政治威胁格局分析',\n  },\n  'analysis/templates/threat-model.md': {\n    en: 'Threat Model (Democratic & Institutional)',\n    sv: 'Hotmodell (demokratisk & institutionell)',\n    da: 'Trusselmodel (demokratisk & institutionel)',\n    no: 'Trusselmodell (demokratisk & institusjonell)',\n    fi: 'Uhkamalli (demokraattinen & institutionaalinen)',\n    de: 'Bedrohungsmodell (demokratisch & institutionell)',\n    fr: 'Modèle de menace (démocratique & institutionnel)',\n    es: 'Modelo de amenazas (democrático e institucional)',\n    nl: 'Dreigingsmodel (democratisch & institutioneel)',\n    ar: 'نموذج التهديد (ديمقراطي ومؤسسي)',\n    he: 'מודל איומים (דמוקרטי ומוסדי)',\n    ja: '脅威モデル(民主的・制度的)',\n    ko: '위협 모델(민주주의 및 제도)',\n    zh: '威胁模型（民主与制度）',\n  },\n  'analysis/templates/voter-segmentation.md': {\n    en: 'Voter Segmentation',\n    sv: 'Väljarsegmentering',\n    da: 'Vælgersegmentering',\n    no: 'Velgersegmentering',\n    fi: 'Äänestäjien segmentointi',\n    de: 'Wählersegmentierung',\n    fr: 'Segmentation des électeurs',\n    es: 'Segmentación de votantes',\n    nl: 'Kiezerssegmentatie',\n    ar: 'تجزئة الناخبين',\n    he: 'חלוקת בוחרים',\n    ja: '有権者セグメンテーション',\n    ko: '유권자 세분화',\n    zh: '选民细分',\n  },\n  'analysis/templates/voting-patterns.md': {\n    en: 'Voting Patterns',\n    sv: 'Röstningsmönster',\n    da: 'Afstemningsmønstre',\n    no: 'Stemmemønstre',\n    fi: 'Äänestys­käyttäytyminen',\n    de: 'Abstimmungsmuster',\n    fr: 'Schémas de vote',\n    es: 'Patrones de voto',\n    nl: 'Stempatronen',\n    ar: 'أنماط التصويت',\n    he: 'דפוסי הצבעה',\n    ja: '投票パターン',\n    ko: '투표 패턴',\n    zh: '投票模式',\n  },\n  'analysis/templates/wildcards-blackswans.md': {\n    en: 'Wildcards & Black Swans',\n    sv: 'Joker­kort & svarta svanar',\n    da: 'Wildcards & sorte svaner',\n    no: 'Wildcards & sorte svaner',\n    fi: 'Jokerit & mustat joutsenet',\n    de: 'Wildcards & Schwarze Schwäne',\n    fr: 'Wildcards & cygnes noirs',\n    es: 'Comodines y cisnes negros',\n    nl: 'Wildcards & zwarte zwanen',\n    ar: 'البطاقات البرية والبجعات السوداء',\n    he: 'ג’וקרים וברבורים שחורים',\n    ja: 'ワイルドカードとブラックスワン',\n    ko: '와일드카드 및 블랙스완',\n    zh: '万能牌与黑天鹅',\n  },\n  'analysis/templates/workflow-audit.md': {\n    en: 'Workflow Audit (Agentic Run Self-Assessment)',\n    sv: 'Arbetsflödes­revision (agentisk körnings-självbedömning)',\n    da: 'Workflow-audit (agentisk kørsels-selvvurdering)',\n    no: 'Arbeidsflyt-revisjon (agentisk kjørings-selvvurdering)',\n    fi: 'Työnkulun auditointi (agenttisen ajon itsearvio)',\n    de: 'Workflow-Audit (agentische Run-Selbstbewertung)',\n    fr: 'Audit de workflow (auto-évaluation d’exécution agentique)',\n    es: 'Auditoría de flujo de trabajo (autoevaluación de ejecución agéntica)',\n    nl: 'Workflow-audit (agentische run-zelfbeoordeling)',\n    ar: 'تدقيق سير العمل (تقييم ذاتي لتشغيل وكيلي)',\n    he: 'ביקורת זרימת עבודה (הערכה עצמית של ריצה אג׳נטית)',\n    ja: 'ワークフロー監査(エージェント実行自己評価)',\n    ko: '워크플로 감사(에이전트 실행 자기 평가)',\n    zh: '工作流审计（代理运行自评）',\n  },\n};\n\n/**\n * Per-language localized generic fallback phrase for **descriptions**.\n *\n * The placeholder `{title}` is replaced with the file's curated/localized\n * title; `{kind}` is replaced with a localized kind word (methodology /\n * template / reference). When `{title}` is omitted from a given language's\n * template, the kind-only form is used (back-compat path).\n *\n * This is what readers see when a file ships without a curated per-language\n * description (e.g. a brand-new methodology added after this table was last\n * updated) — so even new files never display raw English on non-English\n * pages.\n */\nconst GENERIC_FALLBACK_I18N: Record<LanguageCode, string> = {\n  en: '{title} — {kind} in the EU Parliament Monitor analysis library.',\n  sv: '{title} — {kind} i EU Parliament Monitors analysbibliotek.',\n  da: '{title} — {kind} i EU Parliament Monitors analysebibliotek.',\n  no: '{title} — {kind} i EU Parliament Monitors analysebibliotek.',\n  fi: '{title} — {kind} EU Parliament Monitorin analyysikirjastossa.',\n  de: '{title} — {kind} in der EU-Parliament-Monitor-Analysebibliothek.',\n  fr: '{title} — {kind} dans la bibliothèque d’analyse EU Parliament Monitor.',\n  es: '{title} — {kind} en la biblioteca de análisis EU Parliament Monitor.',\n  nl: '{title} — {kind} in de analysebibliotheek van EU Parliament Monitor.',\n  ar: '{title} — {kind} في مكتبة تحليل EU Parliament Monitor.',\n  he: '{title} — {kind} בספריית הניתוחים של EU Parliament Monitor.',\n  ja: '{title} — EU Parliament Monitor 分析ライブラリの{kind}。',\n  ko: '{title} — EU Parliament Monitor 분석 라이브러리의 {kind}.',\n  zh: '{title} — EU Parliament Monitor 分析库中的{kind}。',\n};\n\n/** Per-language word for \"methodology\". */\nconst KIND_WORDS_METHODOLOGY: Record<LanguageCode, string> = {\n  en: 'methodology',\n  sv: 'metodologi',\n  da: 'metode',\n  no: 'metodikk',\n  fi: 'metodologia',\n  de: 'Methodologie',\n  fr: 'méthodologie',\n  es: 'metodología',\n  nl: 'methodologie',\n  ar: 'منهجية',\n  he: 'מתודולוגיה',\n  ja: '方法論',\n  ko: '방법론',\n  zh: '方法论',\n};\n\n/** Per-language word for \"template\". */\nconst KIND_WORDS_TEMPLATE: Record<LanguageCode, string> = {\n  en: 'template',\n  sv: 'mall',\n  da: 'skabelon',\n  no: 'mal',\n  fi: 'malli',\n  de: 'Vorlage',\n  fr: 'modèle',\n  es: 'plantilla',\n  nl: 'sjabloon',\n  ar: 'قالب',\n  he: 'תבנית',\n  ja: 'テンプレート',\n  ko: '템플릿',\n  zh: '模板',\n};\n\n/** Per-language word for \"reference\". */\nconst KIND_WORDS_REFERENCE: Record<LanguageCode, string> = {\n  en: 'reference',\n  sv: 'referens',\n  da: 'reference',\n  no: 'referanse',\n  fi: 'viite',\n  de: 'Referenz',\n  fr: 'référence',\n  es: 'referencia',\n  nl: 'referentie',\n  ar: 'مرجع',\n  he: 'ייחוס',\n  ja: '参照資料',\n  ko: '참조 자료',\n  zh: '参考资料',\n};\n\n/** Per-language word for \"analysis artifact\" (for files under analysis/daily/). */\nconst KIND_WORDS_ARTIFACT: Record<LanguageCode, string> = {\n  en: 'analysis artifact',\n  sv: 'analysartefakt',\n  da: 'analyseartefakt',\n  no: 'analyseartefakt',\n  fi: 'analyysiartefakti',\n  de: 'Analyseartefakt',\n  fr: 'artefact d’analyse',\n  es: 'artefacto de análisis',\n  nl: 'analyse-artefact',\n  ar: 'ناتج تحليل',\n  he: 'תוצר ניתוח',\n  ja: '分析アーティファクト',\n  ko: '분석 산출물',\n  zh: '分析产物',\n};\n\n/**\n * Strip leading emojis/punctuation from a display string and return a\n * title-cased humanized tail. Used only as a last-ditch fallback when no\n * H1 title is provided to {@link getCuratedDescription}.\n *\n * @param keyOrTitle - Raw string (typically a path stem or an H1)\n * @returns Title-cased humanized string\n */\nfunction stripEmojiAndPunct(keyOrTitle: string): string {\n  // Take only the basename (without the extension) as the seed so a raw\n  // path like \"analysis/templates/foo-bar.md\" yields a readable \"Foo Bar\".\n  const seed =\n    keyOrTitle\n      .split('/')\n      .pop()\n      ?.replace(/\\.[^.]+$/, '')\n      ?.replace(/[-_]+/g, ' ')\n      ?.trim() ?? keyOrTitle;\n  return seed.replace(/\\b\\w/g, (c) => c.toUpperCase());\n}\n\n/**\n * Infer a kind (\"methodology\" / \"template\" / \"reference\") from the\n * repository-relative path.\n *\n * @param relPath - Repository-relative Markdown path\n * @returns The inferred kind; falls back to `'reference'` when the path\n *   does not match a `/methodologies/` or `/templates/` directory\n */\nfunction inferKind(relPath: string): 'methodology' | 'template' | 'artifact' | 'reference' {\n  if (relPath.includes('/methodologies/')) return 'methodology';\n  if (relPath.includes('/templates/')) return 'template';\n  if (relPath.includes('/daily/')) return 'artifact';\n  return 'reference';\n}\n\n/**\n * Resolve the localized kind word for a given path and language.\n *\n * @param relPath - Repository-relative Markdown path\n * @param lang    - Target language code\n * @returns Localized kind word (e.g. `'methodology'`, `'mall'`, `'템플릿'`)\n */\nfunction kindWord(relPath: string, lang: LanguageCode): string {\n  const kind = inferKind(relPath);\n  if (kind === 'methodology') return getFromRecord(KIND_WORDS_METHODOLOGY, lang);\n  if (kind === 'template') return getFromRecord(KIND_WORDS_TEMPLATE, lang);\n  if (kind === 'artifact') return getFromRecord(KIND_WORDS_ARTIFACT, lang);\n  return getFromRecord(KIND_WORDS_REFERENCE, lang);\n}\n\n/**\n * Look up a value in a {@link Record} keyed by {@link LanguageCode}, falling\n * back to the English entry if the requested language is not present.\n * Uses a small allowlist pattern to satisfy `security/detect-object-injection`.\n *\n * @param record - Lookup table keyed by language code\n * @param lang   - Language code to resolve (or `'en'` fallback)\n * @returns The resolved string (never empty for well-formed records)\n */\nfunction getFromRecord<T extends Record<LanguageCode, string>>(\n  record: T,\n  lang: LanguageCode\n): string {\n  // eslint-disable-next-line security/detect-object-injection\n  return record[lang] ?? record.en;\n}\n\n/**\n * Build the localized generic fallback sentence for a file the curated\n * table does not know about (or whose curated entry has no per-language\n * description).\n *\n * @param relPath - Repo-relative path to the Markdown file\n * @param lang    - Target language\n * @param title   - Localized title of the file (already resolved via\n *                  {@link getCuratedTitle}) used to make the fallback\n *                  sentence meaningful even when no curated description\n *                  exists\n * @returns Fully localized description sentence\n */\nfunction buildGenericFallback(relPath: string, lang: LanguageCode, title: string): string {\n  // eslint-disable-next-line security/detect-object-injection\n  const template = GENERIC_FALLBACK_I18N[lang] ?? GENERIC_FALLBACK_I18N.en;\n  const kind = kindWord(relPath, lang);\n  return template.replace('{title}', title).replace('{kind}', kind);\n}\n\n/**\n * Resolve the best description for a given methodology / template / reference\n * file and language.\n *\n * Lookup priority:\n * 1. Curated per-language description (`CURATED_DESCRIPTIONS[relPath].i18n[lang]`)\n * 2. Curated English canonical description (`CURATED_DESCRIPTIONS[relPath].description`)\n *    — **only returned for English callers**; non-English callers fall\n *      through to tier 3 so readers don't see raw English on localized\n *      pages when the curated English is non-trivial.\n * 3. Localized generic fallback sentence built from the file's localized\n *    title and a localized kind word\n *\n * @param relPath  - Repository-relative file path (e.g.\n *                   `analysis/methodologies/ai-driven-analysis-guide.md`)\n * @param lang     - Target language code\n * @param fallback - H1-extracted title from the source Markdown (always\n *                   English); used as the title seed for tier 3\n * @returns A non-empty description string\n */\nexport function getCuratedDescription(relPath: string, lang: LanguageCode, fallback = ''): string {\n  // Normalise path separators so Windows callers don't silently miss entries.\n  const key = relPath.replace(/\\\\/g, '/');\n  // eslint-disable-next-line security/detect-object-injection\n  const entry = CURATED_DESCRIPTIONS[key];\n  if (entry) {\n    // eslint-disable-next-line security/detect-object-injection\n    const localized = entry.i18n?.[lang];\n    if (localized) return localized;\n    // English callers get the curated English description. Non-English\n    // callers skip it so the page never shows raw English next to a\n    // localized title — they get the localized fallback built from the\n    // file's localized title instead.\n    if (lang === 'en') return entry.description;\n  }\n  // Build a meaningful localized fallback around the localized title.\n  const localizedTitle = getCuratedTitle(key, lang, fallback || stripEmojiAndPunct(key));\n  return buildGenericFallback(key, lang, localizedTitle);\n}\n\n/**\n * Whether the curated table has an explicit entry (curated English\n * description) for this path — used by tests and by the generator to detect\n * newly-added analysis files that still need a curated entry.\n *\n * @param relPath - Repository-relative file path\n * @returns `true` when the curated table contains the file\n */\nexport function hasCuratedDescription(relPath: string): boolean {\n  // eslint-disable-next-line security/detect-object-injection\n  return Object.prototype.hasOwnProperty.call(CURATED_DESCRIPTIONS, relPath.replace(/\\\\/g, '/'));\n}\n\n/**\n * Whether the curated title overlay has an explicit entry for this path.\n * Used by tests to confirm every shipped methodology/template/reference has\n * a localized title.\n *\n * @param relPath - Repository-relative file path\n * @returns `true` when {@link CURATED_TITLES} contains the file\n */\nexport function hasCuratedTitle(relPath: string): boolean {\n  // eslint-disable-next-line security/detect-object-injection\n  return Object.prototype.hasOwnProperty.call(CURATED_TITLES, relPath.replace(/\\\\/g, '/'));\n}\n\n/**\n * Resolve the best card title for a given methodology / template / reference\n * file and language.\n *\n * Lookup priority:\n * 1. Curated per-language title from {@link CURATED_TITLES} (preferred —\n *    this is where all 14-language localization is maintained)\n * 2. Curated English title from {@link CURATED_TITLES} (`.en` overlay)\n * 3. Per-entry `titleI18n[lang]` on a `CURATED_DESCRIPTIONS` entry\n *    (legacy path; retained so future entries can colocate title + desc)\n * 4. Per-entry `title` on a `CURATED_DESCRIPTIONS` entry\n * 5. `fallback` — the H1-extracted title from the source Markdown\n *\n * The generator always ships `fallback` from the Markdown H1 so this\n * function is guaranteed to return a non-empty string for every file in\n * the library, even when the curated tables have no entry yet.\n *\n * @param relPath  - Repository-relative file path\n * @param lang     - Target language code\n * @param fallback - H1-extracted title from the source Markdown (English)\n * @returns A non-empty display title\n */\nexport function getCuratedTitle(relPath: string, lang: LanguageCode, fallback: string): string {\n  const key = relPath.replace(/\\\\/g, '/');\n  // 1 + 2: curated title overlay\n  // eslint-disable-next-line security/detect-object-injection\n  const titleEntry = CURATED_TITLES[key];\n  if (titleEntry) {\n    // eslint-disable-next-line security/detect-object-injection\n    const localized = titleEntry[lang];\n    if (localized) return localized;\n    if (titleEntry.en) return titleEntry.en;\n  }\n  // 3 + 4: legacy colocated title on CURATED_DESCRIPTIONS entry\n  // eslint-disable-next-line security/detect-object-injection\n  const descEntry = CURATED_DESCRIPTIONS[key];\n  if (descEntry) {\n    // eslint-disable-next-line security/detect-object-injection\n    const localized = descEntry.titleI18n?.[lang];\n    if (localized) return localized;\n    if (descEntry.title) return descEntry.title;\n  }\n  return fallback;\n}\n\n// ============================================================================\n// Daily analysis run types (breaking, week-in-review, motions, …) — used by\n// the political-intelligence generator to render rich, localized run cards\n// in the \"Daily Analysis Runs\" section. Every supported run type carries a\n// 14-language title + description so readers in every locale see a\n// meaningful card, not just a raw slug.\n// ============================================================================\n\n/** Supported run-type slugs. Order drives the prefix-match order. */\nconst RUN_TYPE_SLUGS = [\n  'breaking',\n  'week-in-review',\n  'weekly-review',\n  'month-in-review',\n  'monthly-review',\n  'week-ahead',\n  'month-ahead',\n  'year-ahead',\n  'year-in-review',\n  'committee-reports',\n  'committee',\n  'motions',\n  'propositions',\n  'translate',\n  'deep',\n] as const;\n\ntype RunTypeSlug = (typeof RUN_TYPE_SLUGS)[number];\n\n/** Canonical run-type slugs mapped from aliases. */\nconst RUN_TYPE_ALIASES: Readonly<Record<RunTypeSlug, RunTypeSlug>> = {\n  breaking: 'breaking',\n  'week-in-review': 'week-in-review',\n  'weekly-review': 'week-in-review',\n  'month-in-review': 'month-in-review',\n  'monthly-review': 'month-in-review',\n  'week-ahead': 'week-ahead',\n  'month-ahead': 'month-ahead',\n  'year-ahead': 'year-ahead',\n  'year-in-review': 'year-in-review',\n  'committee-reports': 'committee-reports',\n  committee: 'committee-reports',\n  motions: 'motions',\n  propositions: 'propositions',\n  translate: 'translate',\n  deep: 'deep',\n};\n\n/** Per-language titles for each canonical run type. */\nconst RUN_TYPE_TITLES: Readonly<Record<string, Record<LanguageCode, string>>> = {\n  breaking: {\n    en: 'Breaking Analysis',\n    sv: 'Analys av aktuella nyheter',\n    da: 'Analyse af aktuelle nyheder',\n    no: 'Analyse av aktuelle nyheter',\n    fi: 'Ajankohtaisanalyysi',\n    de: 'Aktuelle Analyse',\n    fr: 'Analyse d’actualité',\n    es: 'Análisis de última hora',\n    nl: 'Analyse actueel nieuws',\n    ar: 'تحليل عاجل',\n    he: 'ניתוח מבזק',\n    ja: '速報分析',\n    ko: '속보 분석',\n    zh: '突发新闻分析',\n  },\n  'week-in-review': {\n    en: 'Week in Review',\n    sv: 'Veckan i återblick',\n    da: 'Ugen i tilbageblik',\n    no: 'Uken i tilbakeblikk',\n    fi: 'Viikko katsauksessa',\n    de: 'Wochenrückblick',\n    fr: 'La semaine en revue',\n    es: 'Semana en revisión',\n    nl: 'Week in terugblik',\n    ar: 'الأسبوع في مراجعة',\n    he: 'סיכום השבוע',\n    ja: '今週のまとめ',\n    ko: '주간 리뷰',\n    zh: '本周回顾',\n  },\n  'month-in-review': {\n    en: 'Month in Review',\n    sv: 'Månaden i återblick',\n    da: 'Måneden i tilbageblik',\n    no: 'Måneden i tilbakeblikk',\n    fi: 'Kuukausi katsauksessa',\n    de: 'Monatsrückblick',\n    fr: 'Le mois en revue',\n    es: 'Mes en revisión',\n    nl: 'Maand in terugblik',\n    ar: 'الشهر في مراجعة',\n    he: 'סיכום החודש',\n    ja: '今月のまとめ',\n    ko: '월간 리뷰',\n    zh: '本月回顾',\n  },\n  'week-ahead': {\n    en: 'Week Ahead',\n    sv: 'Veckan framöver',\n    da: 'Ugen forude',\n    no: 'Uken fremover',\n    fi: 'Tuleva viikko',\n    de: 'Kommende Woche',\n    fr: 'La semaine à venir',\n    es: 'Semana por delante',\n    nl: 'Komende week',\n    ar: 'الأسبوع القادم',\n    he: 'השבוע הקרוב',\n    ja: '来週の展望',\n    ko: '다가오는 주',\n    zh: '下周前瞻',\n  },\n  'month-ahead': {\n    en: 'Month Ahead',\n    sv: 'Månaden framöver',\n    da: 'Måneden forude',\n    no: 'Måneden fremover',\n    fi: 'Tuleva kuukausi',\n    de: 'Kommender Monat',\n    fr: 'Le mois à venir',\n    es: 'Mes por delante',\n    nl: 'Komende maand',\n    ar: 'الشهر القادم',\n    he: 'החודש הקרוב',\n    ja: '来月の展望',\n    ko: '다가오는 달',\n    zh: '下月前瞻',\n  },\n  'year-ahead': {\n    en: 'Year Ahead',\n    sv: 'Året framöver',\n    da: 'Året forude',\n    no: 'Året fremover',\n    fi: 'Tuleva vuosi',\n    de: 'Kommendes Jahr',\n    fr: 'L’année à venir',\n    es: 'Año por delante',\n    nl: 'Komend jaar',\n    ar: 'السنة القادمة',\n    he: 'השנה הקרובה',\n    ja: '来年の展望',\n    ko: '다가오는 해',\n    zh: '来年前瞻',\n  },\n  'year-in-review': {\n    en: 'Year in Review',\n    sv: 'Året i återblick',\n    da: 'Året i tilbageblik',\n    no: 'Året i tilbakeblikk',\n    fi: 'Vuosi katsauksessa',\n    de: 'Jahresrückblick',\n    fr: 'L’année en revue',\n    es: 'Año en revisión',\n    nl: 'Jaar in terugblik',\n    ar: 'السنة في مراجعة',\n    he: 'סיכום השנה',\n    ja: '年間総括',\n    ko: '연간 리뷰',\n    zh: '年度回顾',\n  },\n  'committee-reports': {\n    en: 'Committee Reports',\n    sv: 'Utskottsrapporter',\n    da: 'Udvalgsrapporter',\n    no: 'Komitérapporter',\n    fi: 'Valiokuntaraportit',\n    de: 'Ausschussberichte',\n    fr: 'Rapports de commission',\n    es: 'Informes de comisión',\n    nl: 'Commissieverslagen',\n    ar: 'تقارير اللجان',\n    he: 'דוחות ועדה',\n    ja: '委員会報告',\n    ko: '위원회 보고서',\n    zh: '委员会报告',\n  },\n  motions: {\n    en: 'Motions',\n    sv: 'Motioner',\n    da: 'Beslutningsforslag',\n    no: 'Forslag',\n    fi: 'Aloitteet',\n    de: 'Entschließungsanträge',\n    fr: 'Propositions de résolution',\n    es: 'Mociones',\n    nl: 'Moties',\n    ar: 'مقترحات',\n    he: 'הצעות החלטה',\n    ja: '動議',\n    ko: '동의안',\n    zh: '动议',\n  },\n  propositions: {\n    en: 'Propositions',\n    sv: 'Propositioner',\n    da: 'Lovforslag',\n    no: 'Lovforslag',\n    fi: 'Lakiehdotukset',\n    de: 'Gesetzesvorschläge',\n    fr: 'Propositions législatives',\n    es: 'Propuestas legislativas',\n    nl: 'Wetsvoorstellen',\n    ar: 'مقترحات تشريعية',\n    he: 'הצעות חקיקה',\n    ja: '法案',\n    ko: '법안',\n    zh: '立法提案',\n  },\n  translate: {\n    en: 'Translation Run',\n    sv: 'Översättningskörning',\n    da: 'Oversættelseskørsel',\n    no: 'Oversettelseskjøring',\n    fi: 'Käännösajo',\n    de: 'Übersetzungslauf',\n    fr: 'Exécution de traduction',\n    es: 'Ejecución de traducción',\n    nl: 'Vertaalronde',\n    ar: 'تشغيل الترجمة',\n    he: 'הרצת תרגום',\n    ja: '翻訳ラン',\n    ko: '번역 실행',\n    zh: '翻译运行',\n  },\n  deep: {\n    en: 'Deep Analysis',\n    sv: 'Djupanalys',\n    da: 'Dybdeanalyse',\n    no: 'Dybdeanalyse',\n    fi: 'Syväanalyysi',\n    de: 'Tiefenanalyse',\n    fr: 'Analyse approfondie',\n    es: 'Análisis profundo',\n    nl: 'Diepteanalyse',\n    ar: 'تحليل متعمق',\n    he: 'ניתוח מעמיק',\n    ja: '詳細分析',\n    ko: '심층 분석',\n    zh: '深度分析',\n  },\n};\n\n/** Per-language descriptions for each canonical run type. */\nconst RUN_TYPE_DESCRIPTIONS: Readonly<Record<string, Record<LanguageCode, string>>> = {\n  breaking: {\n    en: 'Fast-turnaround breaking-news analysis of a single European Parliament event — classification, stakeholder map, SWOT, risk scoring and scenario forecast produced within hours.',\n    sv: 'Snabb analys av en enskild Europaparlamentshändelse — klassificering, intressentkarta, SWOT, riskpoängsättning och scenarioprognos producerad inom timmar.',\n    da: 'Hurtig analyse af en enkelt Europa-Parlament-hændelse — klassificering, interessentkort, SWOT, risikoscoring og scenarieprognose produceret inden for timer.',\n    no: 'Rask analyse av en enkelt EP-hendelse — klassifisering, interessentkart, SWOT, risikoscoring og scenarioprognose produsert innen timer.',\n    fi: 'Nopea analyysi yksittäisestä Euroopan parlamentin tapahtumasta — luokittelu, sidosryhmäkartta, SWOT, riskipisteytys ja skenaarioennuste muutamassa tunnissa.',\n    de: 'Schnellanalyse eines einzelnen EP-Ereignisses — Klassifikation, Stakeholder-Karte, SWOT, Risikobewertung und Szenario­prognose innerhalb weniger Stunden.',\n    fr: 'Analyse rapide d’un événement unique du Parlement européen — classification, cartographie des parties prenantes, SWOT, notation des risques et prévision de scénarios en quelques heures.',\n    es: 'Análisis rápido de un único evento del Parlamento Europeo — clasificación, mapa de partes interesadas, SWOT, puntuación de riesgo y pronóstico de escenarios en horas.',\n    nl: 'Snelle analyse van één enkele EP-gebeurtenis — classificatie, stakeholder-kaart, SWOT, risicoscoring en scenarioprognose binnen enkele uren.',\n    ar: 'تحليل سريع لحدث واحد في البرلمان الأوروبي — تصنيف، خريطة أصحاب المصلحة، SWOT، تسجيل المخاطر وتوقّع السيناريوهات خلال ساعات.',\n    he: 'ניתוח מהיר של אירוע יחיד בפרלמנט האירופי — סיווג, מפת בעלי עניין, SWOT, ציוני סיכון ותחזית תרחישים תוך שעות.',\n    ja: '欧州議会の単一事象に対する迅速分析 — 分類、ステークホルダー・マップ、SWOT、リスクスコア、シナリオ予測を数時間で提供。',\n    ko: '유럽의회 단일 사건에 대한 신속 분석 — 분류·이해관계자 지도·SWOT·위험 점수·시나리오 예측을 수 시간 내 제공.',\n    zh: '欧洲议会单一事件的快速分析 — 在数小时内产出分类、利益相关者图谱、SWOT、风险评分与情景预测。',\n  },\n  'week-in-review': {\n    en: 'Weekly retrospective: the past seven days of European Parliament activity distilled into coalition trends, vote tallies, SWOT synthesis and forward indicators.',\n    sv: 'Veckoretrospektiv: Europaparlamentets senaste sju dagar destillerade till koalitionstrender, röstsummor, SWOT-syntes och framåtriktade indikatorer.',\n    da: 'Ugentlig tilbageskuelse: syv dages Europa-Parlamentsaktivitet destilleret til koalitionstendenser, stemmetællinger, SWOT-syntese og fremadrettede indikatorer.',\n    no: 'Ukentlig tilbakeblikk: syv dager med EP-aktivitet destillert til koalisjonstrender, stemmesummer, SWOT-syntese og fremoverrettede indikatorer.',\n    fi: 'Viikkokatsaus: Euroopan parlamentin seitsemän päivän toiminta tiivistettynä koalitiotrendeiksi, äänitaulukoiksi, SWOT-synteesiksi ja ennakoiviksi indikaattoreiksi.',\n    de: 'Wochenrückblick: Sieben Tage EP-Aktivität destilliert zu Koalitionstrends, Abstimmungs­tableaus, SWOT-Synthese und vorausschauenden Indikatoren.',\n    fr: 'Rétrospective hebdomadaire : sept jours d’activité du Parlement européen distillés en tendances de coalition, décomptes de votes, synthèse SWOT et indicateurs prospectifs.',\n    es: 'Retrospectiva semanal: siete días de actividad del Parlamento Europeo destilados en tendencias de coalición, recuentos de votos, síntesis SWOT e indicadores prospectivos.',\n    nl: 'Wekelijkse terugblik: zeven dagen EP-activiteit samengevat in coalitietrends, stemtellingen, SWOT-synthese en vooruitblikkende indicatoren.',\n    ar: 'استعراض أسبوعي: سبعة أيام من نشاط البرلمان الأوروبي مركّزة في اتجاهات تحالف، إحصاءات تصويت، تركيب SWOT ومؤشرات استشرافية.',\n    he: 'סיכום שבועי: שבעה ימי פעילות בפרלמנט האירופי מזוקקים למגמות קואליציה, ספירת הצבעות, סינתזת SWOT ומדדים צופי־פני־עתיד.',\n    ja: '週次振り返り：欧州議会の直近7日間を連立傾向・投票集計・SWOT 統合・先行指標へ凝縮。',\n    ko: '주간 회고: 유럽의회의 지난 7일간 활동을 연정 동향·표결 집계·SWOT 종합·선행 지표로 압축.',\n    zh: '每周回顾：将欧洲议会过去七天的活动凝练为联盟趋势、投票统计、SWOT 综合与前瞻指标。',\n  },\n  'month-in-review': {\n    en: 'Monthly retrospective: a four-week synthesis of EP legislative flow, coalition stability, anomalous votes and cumulative political-risk delta versus the prior month.',\n    sv: 'Månadsretrospektiv: en fyraveckorssyntes av EP:s lagstiftningsflöde, koalitionsstabilitet, avvikande röster och kumulativ politisk-risk-delta jämfört med föregående månad.',\n    da: 'Månedlig tilbageskuelse: en fire-ugers syntese af EP’s lovgivningsflow, koalitionsstabilitet, afvigende stemmer og kumulativt politisk risikodelta mod forrige måned.',\n    no: 'Månedlig tilbakeblikk: en fire-ukers syntese av EPs lovgivningsflyt, koalisjonsstabilitet, avvikende stemmer og kumulativt politisk risikodelta mot forrige måned.',\n    fi: 'Kuukausikatsaus: EU-parlamentin neljän viikon lainsäädäntövirran, koalition vakauden, poikkeavien äänestysten ja kumulatiivisen poliittisen riskin delta edelliseen kuukauteen nähden.',\n    de: 'Monatsrückblick: vierwöchige Synthese des EP-Gesetzgebungsflusses, der Koalitionsstabilität, anomaler Abstimmungen und des kumulativen Politikrisiko-Deltas gegenüber dem Vormonat.',\n    fr: 'Rétrospective mensuelle : synthèse sur quatre semaines du flux législatif du PE, stabilité des coalitions, votes atypiques et delta cumulatif du risque politique par rapport au mois précédent.',\n    es: 'Retrospectiva mensual: síntesis de cuatro semanas del flujo legislativo del PE, estabilidad de coaliciones, votos anómalos y delta acumulado de riesgo político frente al mes anterior.',\n    nl: 'Maandelijks overzicht: een vierwekelijkse synthese van EP-wetgevingsstroom, coalitiestabiliteit, afwijkende stemmingen en cumulatieve politieke-risico-delta t.o.v. de vorige maand.',\n    ar: 'استعراض شهري: تركيب أربعة أسابيع من تدفّق التشريع في البرلمان الأوروبي، استقرار التحالفات، الأصوات الشاذّة، ودلتا المخاطر السياسية التراكمية مقابل الشهر السابق.',\n    he: 'סיכום חודשי: סינתזה של ארבעה שבועות מזרימה חקיקתית בפרלמנט האירופי, יציבות קואליציה, הצבעות חריגות ודלתת סיכון פוליטי מצטברת מול החודש הקודם.',\n    ja: '月次振り返り：欧州議会の 4 週間分の立法フロー・連立安定性・異常投票・前月比の累積政治リスク差分を統合。',\n    ko: '월간 회고: 유럽의회의 4주간 입법 흐름·연정 안정성·이상 표결·전월 대비 누적 정치 위험 델타를 종합.',\n    zh: '月度回顾：将欧洲议会四周的立法流、联盟稳定性、异常投票以及相对上月的累计政治风险增量整合为综合分析。',\n  },\n  'week-ahead': {\n    en: 'Forward-looking weekly brief: the next seven days of scheduled plenary, committee and trilogue activity, with risk scoring and coalition stress indicators.',\n    sv: 'Framåtblickande veckobrief: de kommande sju dagarnas plenar-, utskotts- och trilogaktiviteter, med riskpoängsättning och indikatorer på koalitionsstress.',\n    da: 'Fremadrettet ugebrief: de kommende syv dages plenar-, udvalgs- og trilog-aktiviteter med risikoscoring og indikatorer for koalitionspres.',\n    no: 'Fremoverrettet ukebrief: de neste syv dagers plenum-, komité- og trilogaktivitet med risikoscoring og indikatorer for koalisjonspress.',\n    fi: 'Ennakoiva viikkokatsaus: seuraavien seitsemän päivän täysistunto-, valiokunta- ja trilogiatoiminta, riskipisteytykset ja koalitiokuormaindikaattorit.',\n    de: 'Vorausschauende Wochenvorschau: die nächsten sieben Tage geplanter Plenar-, Ausschuss- und Trilog-Aktivität mit Risikobewertung und Koalitionsstress-Indikatoren.',\n    fr: 'Note hebdomadaire prospective : les sept prochains jours d’activité plénière, en commission et en trilogue, avec notation des risques et indicateurs de tension de coalition.',\n    es: 'Nota semanal prospectiva: los próximos siete días de actividad plenaria, de comisión y de trílogo, con puntuación de riesgo e indicadores de tensión de coalición.',\n    nl: 'Vooruitkijkend weekoverzicht: de komende zeven dagen plenaire, commissie- en trilo­og-activiteit, met risicoscoring en indicatoren voor coalitiedruk.',\n    ar: 'ملخص أسبوعي استشرافي: الأيام السبعة المقبلة من أنشطة الجلسة العامة واللجان والترايلوج، مع تسجيل المخاطر ومؤشرات إجهاد التحالف.',\n    he: 'תקציר שבועי צופה פני עתיד: שבעת הימים הקרובים של פעילות מליאה, ועדות וטרילוג, עם ציוני סיכון ומדדי מתח קואליציוני.',\n    ja: '先行週次ブリーフ：今後 7 日間の本会議・委員会・トリローグの予定を、リスクスコアと連立ストレス指標付きで提示。',\n    ko: '선행 주간 브리프: 향후 7일의 본회의·위원회·삼자협의 일정에 위험 점수와 연정 스트레스 지표를 결합.',\n    zh: '前瞻周报：未来七天的全体会议、委员会与三方谈判议程，附风险评分与联盟压力指标。',\n  },\n  'month-ahead': {\n    en: 'Forward-looking monthly brief: the next four weeks of EP scheduled activity, dossier pipeline, anticipated votes and strategic inflection points.',\n    sv: 'Framåtblickande månadsbrief: de kommande fyra veckornas schemalagda EP-aktiviteter, dossierflöde, förväntade röster och strategiska vändpunkter.',\n    da: 'Fremadrettet månedsbrief: de kommende fire ugers EP-aktiviteter, dossierpipeline, forventede afstemninger og strategiske vendepunkter.',\n    no: 'Fremoverrettet månedsbrief: de neste fire ukenes planlagte EP-aktivitet, dossierløp, forventede stemmer og strategiske vendepunkter.',\n    fi: 'Ennakoiva kuukausikatsaus: seuraavien neljän viikon EP-aktiviteetit, asiakokonaisuuksien putki, odotetut äänestykset ja strategiset taitepisteet.',\n    de: 'Vorausschauende Monatsvorschau: die nächsten vier Wochen geplanter EP-Aktivität, Dossier-Pipeline, erwartete Abstimmungen und strategische Wendepunkte.',\n    fr: 'Note mensuelle prospective : les quatre prochaines semaines d’activité programmée du PE, pipeline de dossiers, votes anticipés et points d’inflexion stratégiques.',\n    es: 'Nota mensual prospectiva: las próximas cuatro semanas de actividad programada del PE, cartera de expedientes, votaciones previstas y puntos de inflexión estratégicos.',\n    nl: 'Vooruitkijkend maandoverzicht: de komende vier weken geplande EP-activiteit, dossier­pipeline, verwachte stemmingen en strategische kantelpunten.',\n    ar: 'ملخص شهري استشرافي: الأسابيع الأربعة القادمة من نشاط البرلمان الأوروبي، خط سير الملفات، التصويتات المتوقعة ونقاط التحوّل الاستراتيجية.',\n    he: 'תקציר חודשי צופה פני עתיד: ארבעת השבועות הקרובים בפעילות הפרלמנט האירופי, קו תיקים, הצבעות צפויות ונקודות מפנה אסטרטגיות.',\n    ja: '先行月次ブリーフ：今後 4 週間の欧州議会予定、法案パイプライン、予定された投票、戦略的転換点を提示。',\n    ko: '선행 월간 브리프: 향후 4주간의 유럽의회 일정·법안 파이프라인·예정 표결·전략적 전환점을 제시.',\n    zh: '前瞻月报：欧洲议会未来四周的日程、议题流水线、预期投票与战略拐点。',\n  },\n  'year-ahead': {\n    en: 'Forward-looking annual brief: the next twelve months of EP agenda, legislative priorities and strategic risk surfaces.',\n    sv: 'Framåtblickande årsbrief: EP:s agenda, lagstiftnings­prioriteringar och strategiska riskytor de kommande tolv månaderna.',\n    da: 'Fremadrettet årsbrief: EP-dagsorden, lovgivnings­prioriteter og strategiske risikoflader de kommende tolv måneder.',\n    no: 'Fremoverrettet årsbrief: EPs agenda, lovgivnings­prioriteringer og strategiske risikoflater de neste tolv månedene.',\n    fi: 'Ennakoiva vuosikatsaus: EP:n asialista, lainsäädäntö­prioriteetit ja strategiset riskipinnat tulevina kahtenatoista kuukautena.',\n    de: 'Vorausschauende Jahres­vorschau: EP-Agenda, Gesetzgebungs­prioritäten und strategische Risikoflächen der nächsten zwölf Monate.',\n    fr: 'Note annuelle prospective : agenda du PE, priorités législatives et surfaces de risque stratégique des douze prochains mois.',\n    es: 'Nota anual prospectiva: agenda del PE, prioridades legislativas y superficies de riesgo estratégico de los próximos doce meses.',\n    nl: 'Vooruitkijkend jaaroverzicht: EP-agenda, wetgevings­prioriteiten en strategische risico­vlakken voor de komende twaalf maanden.',\n    ar: 'ملخص سنوي استشرافي: جدول أعمال البرلمان الأوروبي، الأولويات التشريعية وأسطح المخاطر الاستراتيجية للأشهر الاثني عشر المقبلة.',\n    he: 'תקציר שנתי צופה פני עתיד: סדר היום של הפרלמנט האירופי, סדרי עדיפויות חקיקתיים ומשטחי סיכון אסטרטגיים בשנה הקרובה.',\n    ja: '先行年次ブリーフ：今後 12 か月の欧州議会アジェンダ・立法優先事項・戦略リスク面を提示。',\n    ko: '선행 연간 브리프: 향후 12개월의 유럽의회 의제·입법 우선순위·전략적 위험 표면을 제시.',\n    zh: '前瞻年报：欧洲议会未来十二个月的议程、立法优先事项与战略风险面。',\n  },\n  'year-in-review': {\n    en: 'Annual retrospective: twelve months of EP activity synthesized into coalition maps, dossier throughput, major inflection points and cumulative political-risk trajectory.',\n    sv: 'Årsretrospektiv: tolv månaders EP-aktivitet sammanställd till koalitions­kartor, dossiergenomströmning, större vändpunkter och kumulativ politisk-risk-bana.',\n    da: 'Årlig tilbageskuelse: tolv måneders EP-aktivitet syntetiseret til koalitionskort, dossiergennemløb, større vendepunkter og kumulativt politisk risikoforløb.',\n    no: 'Årlig tilbakeblikk: tolv måneders EP-aktivitet syntetisert til koalisjonskart, dossiergjennomstrømning, store vendepunkter og kumulativ politisk risikobane.',\n    fi: 'Vuosikatsaus: kahdentoista kuukauden EP-toiminta tiivistettynä koalitio­kartoiksi, asiakokonaisuuksien läpivirtaukseksi, taitepisteiksi ja kumulatiiviseksi poliittiseksi riskipoluksi.',\n    de: 'Jahresrückblick: zwölf Monate EP-Aktivität synthetisiert zu Koalitions­karten, Dossier-Durchsatz, wichtigen Wendepunkten und kumulativer Politikrisiko-Trajektorie.',\n    fr: 'Rétrospective annuelle : douze mois d’activité du PE synthétisés en cartes de coalitions, débit des dossiers, principaux points d’inflexion et trajectoire cumulative du risque politique.',\n    es: 'Retrospectiva anual: doce meses de actividad del PE sintetizados en mapas de coaliciones, rendimiento de expedientes, principales puntos de inflexión y trayectoria acumulada de riesgo político.',\n    nl: 'Jaaroverzicht: twaalf maanden EP-activiteit samengevat in coalitie­kaarten, dossier­doorstroom, belangrijke kantelpunten en cumulatieve politieke-risico­traject.',\n    ar: 'استعراض سنوي: اثنا عشر شهرًا من نشاط البرلمان الأوروبي مركّزة في خرائط تحالف، إنتاجية ملفات، نقاط تحوّل كبرى ومسار مخاطر سياسية تراكمي.',\n    he: 'סיכום שנתי: שנים־עשר חודשי פעילות בפרלמנט האירופי בסינתזה של מפות קואליציה, תפוקת תיקים, נקודות מפנה מרכזיות ומסלול סיכון פוליטי מצטבר.',\n    ja: '年間振り返り：12 か月の欧州議会活動を連立マップ、法案スループット、主要転換点、累積政治リスク軌道に統合。',\n    ko: '연간 회고: 12개월간의 유럽의회 활동을 연정 지도·법안 처리량·주요 전환점·누적 정치 위험 궤적으로 종합.',\n    zh: '年度回顾：将欧洲议会十二个月的活动综合为联盟图谱、议题吞吐量、主要拐点和累计政治风险轨迹。',\n  },\n  'committee-reports': {\n    en: 'Dedicated analysis of EP committee reports — rapporteur attribution, amendment tracking, coalition mathematics and projected plenary outcome.',\n    sv: 'Dedikerad analys av EP-utskottsrapporter — föredragande­attribuering, ändringsförslags­spårning, koalitions­matematik och prognostiserat plenar­utfall.',\n    da: 'Dedikeret analyse af EP-udvalgs­rapporter — ordfører­attribution, ændrings­sporing, koalitions­matematik og forventet plenarresultat.',\n    no: 'Dedikert analyse av EP-komitérapporter — ordfører­attribusjon, endrings­sporing, koalisjons­matematikk og forventet plenumsresultat.',\n    fi: 'EP:n valiokunta­raporttien kohdennettu analyysi — esittelijän attribuointi, muutosehdotusten seuranta, koalitio­matematiikka ja ennustettu täysistunto­tulos.',\n    de: 'Gezielte Analyse der EP-Ausschussberichte — Berichterstatter­zuordnung, Änderungs­verfolgung, Koalitions­mathematik und prognostiziertes Plenar­ergebnis.',\n    fr: 'Analyse dédiée des rapports des commissions du PE — attribution du rapporteur, suivi des amendements, mathématiques de coalition et résultat plénier anticipé.',\n    es: 'Análisis dedicado de los informes de comisión del PE — atribución de ponente, seguimiento de enmiendas, matemáticas de coalición y resultado plenario previsto.',\n    nl: 'Toegewijde analyse van EP-commissieverslagen — rapporteur­attributie, amendements­opvolging, coalitie­wiskunde en verwachte plenaire uitkomst.',\n    ar: 'تحليل مكرّس لتقارير لجان البرلمان الأوروبي — إسناد المقرر، تتبع التعديلات، رياضيات التحالف، والنتيجة المتوقعة للجلسة العامة.',\n    he: 'ניתוח ייעודי של דוחות ועדות הפרלמנט האירופי — ייחוס דוברי הוועדה, מעקב תיקונים, מתמטיקת קואליציות ותוצאה צפויה במליאה.',\n    ja: '欧州議会委員会報告の専門分析 — 報告者の帰属、修正追跡、連立算術、本会議での予測結果。',\n    ko: '유럽의회 위원회 보고서에 대한 전용 분석 — 보고위원 귀속, 수정안 추적, 연정 산술, 본회의 예측 결과.',\n    zh: '欧洲议会委员会报告的专门分析 — 报告员归属、修正案追踪、联盟数学与全体会议预期结果。',\n  },\n  motions: {\n    en: 'Analysis of motions for resolution — sponsor coalition, signatory threshold, SWOT, amendment risk and comparative historical votes.',\n    sv: 'Analys av resolutions­motioner — sponsor­koalition, underskrifts­tröskel, SWOT, ändrings­risk och jämförande historiska röster.',\n    da: 'Analyse af beslutnings­forslag — sponsorkoalition, underskriftstærskel, SWOT, ændringsrisiko og sammenlignelige historiske afstemninger.',\n    no: 'Analyse av resolusjonsforslag — sponsorkoalisjon, underskriftsterskel, SWOT, endringsrisiko og sammenlignbare historiske stemmer.',\n    fi: 'Päätöslauselma­aloitteiden analyysi — esittäjäkoalitio, allekirjoitus­kynnys, SWOT, muutosriski ja vertailevat historialliset äänestykset.',\n    de: 'Analyse von Entschließungs­anträgen — Einreicher-Koalition, Unterschriften­schwelle, SWOT, Änderungs­risiko und vergleichbare historische Abstimmungen.',\n    fr: 'Analyse des propositions de résolution — coalition de signataires, seuil de signatures, SWOT, risque d’amendement et votes historiques comparables.',\n    es: 'Análisis de propuestas de resolución — coalición de proponentes, umbral de firmas, SWOT, riesgo de enmienda y votaciones históricas comparables.',\n    nl: 'Analyse van ontwerp­resoluties — coalitie van ondertekenaars, ondertekenings­drempel, SWOT, amendementrisico en vergelijkbare historische stemmingen.',\n    ar: 'تحليل مقترحات القرارات — تحالف المقدّمين، عتبة التوقيع، SWOT، مخاطر التعديلات والتصويتات التاريخية المقارنة.',\n    he: 'ניתוח הצעות החלטה — קואליציית יוזמים, סף חתימות, SWOT, סיכון תיקונים והצבעות היסטוריות משוות.',\n    ja: '決議動議の分析 — 提出者連立、署名閾値、SWOT、修正リスク、比較可能な歴史的投票。',\n    ko: '결의안 동의안 분석 — 발의자 연정, 서명 임계값, SWOT, 수정안 위험 및 비교 가능한 과거 표결.',\n    zh: '决议动议分析 — 提案联盟、联署门槛、SWOT、修正风险与可比的历史投票。',\n  },\n  propositions: {\n    en: 'Analysis of legislative propositions — rapporteur, co-decision pathway, impact assessment, industry stakeholder map and trilogue risk.',\n    sv: 'Analys av lagstiftnings­propositioner — föredragande, medbeslutande­väg, konsekvens­bedömning, branschens intressentkarta och trilogrisk.',\n    da: 'Analyse af lovforslag — ordfører, fælles­beslutnings­vej, konsekvens­vurdering, interessentkort for branchen og trilog-risiko.',\n    no: 'Analyse av lovforslag — ordfører, medbesluttende­løp, konsekvensvurdering, bransjens interessentkart og trilog-risiko.',\n    fi: 'Lakiehdotusten analyysi — esittelijä, yhteispäätös­menettelyn polku, vaikutus­arvio, toimialan sidosryhmä­kartta ja trilogia­riski.',\n    de: 'Analyse von Gesetzes­vorschlägen — Berichterstatter, Mitentscheidungs­weg, Folgen­abschätzung, Stakeholder-Karte der Industrie und Trilog-Risiko.',\n    fr: 'Analyse des propositions législatives — rapporteur, parcours de codécision, évaluation d’impact, cartographie des parties prenantes sectorielles et risque de trilogue.',\n    es: 'Análisis de propuestas legislativas — ponente, vía de codecisión, evaluación de impacto, mapa de partes interesadas del sector y riesgo de trílogo.',\n    nl: 'Analyse van wetsvoorstellen — rapporteur, medebeslissings­traject, impact­beoordeling, stakeholder-kaart van de sector en triloog­risico.',\n    ar: 'تحليل المقترحات التشريعية — المقرر، مسار التقرير المشترك، تقييم الأثر، خريطة أصحاب المصلحة القطاعيين ومخاطر الترايلوج.',\n    he: 'ניתוח הצעות חקיקה — דובר הוועדה, מסלול ההחלטה המשותפת, הערכת השפעה, מפת בעלי עניין ענפיים וסיכון טרילוג.',\n    ja: '立法提案の分析 — 報告者、共同決定経路、影響評価、業界ステークホルダー・マップ、トリローグリスク。',\n    ko: '입법 제안 분석 — 보고위원, 공동결정 경로, 영향 평가, 산업 이해관계자 지도 및 삼자협의 위험.',\n    zh: '立法提案分析 — 报告员、共同决定路径、影响评估、行业利益相关者图谱与三方谈判风险。',\n  },\n  translate: {\n    en: 'Translation run: one published article rendered into all 13 non-English supported languages with per-language quality gates.',\n    sv: 'Översättnings­körning: en publicerad artikel översatt till alla 13 icke-engelska språk med kvalitets­portar per språk.',\n    da: 'Oversættelses­kørsel: én udgivet artikel oversat til alle 13 ikke-engelske sprog med kvalitetsporte pr. sprog.',\n    no: 'Oversettelses­kjøring: én publisert artikkel oversatt til alle 13 ikke-engelske språk med kvalitetsporter per språk.',\n    fi: 'Käännösajo: yksi julkaistu artikkeli käännettynä kaikille 13 ei-englanninkieliselle tuetulle kielelle kielikohtaisin laatuportein.',\n    de: 'Übersetzungslauf: ein veröffentlichter Artikel in alle 13 nicht-englischen unterstützten Sprachen übertragen, mit sprach­spezifischen Qualitäts­gates.',\n    fr: 'Exécution de traduction : un article publié rendu dans les 13 langues prises en charge autres que l’anglais, avec des portes qualité par langue.',\n    es: 'Ejecución de traducción: un artículo publicado traducido a los 13 idiomas admitidos distintos del inglés, con puertas de calidad por idioma.',\n    nl: 'Vertaalronde: één gepubliceerd artikel weergegeven in alle 13 niet-Engelse ondersteunde talen met kwaliteitspoorten per taal.',\n    ar: 'تشغيل الترجمة: مقال منشور يُترجَم إلى جميع اللغات الـ 13 المدعومة غير الإنجليزية مع بوابات جودة لكل لغة.',\n    he: 'הרצת תרגום: מאמר אחד שפורסם מתורגם לכל 13 השפות הנתמכות שאינן אנגלית, עם שערי איכות לכל שפה.',\n    ja: '翻訳ラン：公開された 1 記事を、英語以外のサポート言語 13 種すべてに言語ごとの品質ゲート付きで翻訳。',\n    ko: '번역 실행: 게시된 기사 1건을 영어를 제외한 지원 언어 13개로 언어별 품질 게이트와 함께 번역.',\n    zh: '翻译运行：将一篇已发布的文章翻译为除英语外的全部 13 种受支持语言，按语言执行质量门。',\n  },\n  deep: {\n    en: 'Deep-dive multi-stage analysis: extended artifact set, cross-run synthesis and long-horizon scenario forecasting for a single strategic topic.',\n    sv: 'Fördjupad flerstegs­analys: utökad artefaktuppsättning, tvärkörnings­syntes och lång­horisonts­scenarioprognos för ett enskilt strategiskt ämne.',\n    da: 'Dybdegående analyse i flere trin: udvidet artefaktsæt, tværkørselssyntese og langhorisonts-scenarieprognose for et enkelt strategisk emne.',\n    no: 'Dyp flerstegsanalyse: utvidet artefaktsett, tverrkjøringssyntese og langhorisonts-scenarioprognose for ett enkelt strategisk tema.',\n    fi: 'Monivaiheinen syväanalyysi: laajennettu artefakti­setti, ajojen välinen synteesi ja pitkän aikavälin skenaario­ennuste yhdestä strategisesta aiheesta.',\n    de: 'Mehrstufige Tiefen­analyse: erweitertes Artefakt-Set, Cross-Run-Synthese und Langzeit-Szenario­prognose für ein einzelnes strategisches Thema.',\n    fr: 'Analyse approfondie multi-étapes : ensemble d’artefacts étendu, synthèse inter-exécutions et prévision de scénarios à long horizon pour un sujet stratégique unique.',\n    es: 'Análisis multietapa en profundidad: conjunto extendido de artefactos, síntesis entre ejecuciones y pronóstico de escenarios a largo horizonte para un único tema estratégico.',\n    nl: 'Meerfasige diepgaande analyse: uitgebreide artefactset, cross-run-synthese en scenarioprognose op lange horizon voor één strategisch onderwerp.',\n    ar: 'تحليل معمّق متعدد المراحل: مجموعة قطع موسّعة، تركيب عبر الجلسات وتوقّع سيناريوهات طويل الأمد لموضوع استراتيجي واحد.',\n    he: 'ניתוח מעמיק רב־שלבי: מערך ארטיפקטים מורחב, סינתזה בין־הרצות ותחזית תרחישים באופק ארוך לנושא אסטרטגי יחיד.',\n    ja: '多段階ディープダイブ分析：拡張成果物セット、ラン間シンセシス、単一戦略テーマの長期シナリオ予測。',\n    ko: '다단계 심층 분석: 확장 산출물 세트, 런 간 시너지스, 단일 전략 주제에 대한 장기 시나리오 예측.',\n    zh: '多阶段深度分析：扩展的产物集、跨运行综合以及针对单一战略主题的长视野情景预测。',\n  },\n};\n\n/**\n * Parse a run slug such as `breaking-run192`, `week-in-review-run45` or\n * `committee-reports-run07` into its canonical run-type slug (e.g.\n * `breaking`, `week-in-review`, `committee-reports`) plus the run index\n * (e.g. `192`, `45`, `07`). When the slug doesn't match any known prefix\n * the caller receives `type: null` and the raw slug as `runId`.\n *\n * @param slug - Run directory slug\n * @returns Object with the canonical type (or `null`) and run-id tail\n */\nexport function parseRunSlug(slug: string): { type: RunTypeSlug | null; runId: string } {\n  const lower = slug.toLowerCase();\n  // Longest-prefix match so `committee-reports-run07` matches `committee-reports`\n  // before `committee`, and `week-in-review-run45` matches `week-in-review`\n  // before `week`.\n  const sorted = [...RUN_TYPE_SLUGS].sort((a, b) => b.length - a.length);\n  for (const prefix of sorted) {\n    if (lower === prefix || lower.startsWith(`${prefix}-`) || lower.startsWith(`${prefix}_`)) {\n      // eslint-disable-next-line security/detect-object-injection\n      const canonical = RUN_TYPE_ALIASES[prefix];\n      const tail = slug.slice(prefix.length).replace(/^[-_]+/, '');\n      return { type: canonical, runId: tail };\n    }\n  }\n  return { type: null, runId: slug };\n}\n\n/**\n * Resolve a localized title + description for a daily analysis run.\n *\n * @param slug - Run directory slug (e.g. `breaking-run192`)\n * @param lang - Target language code\n * @returns `{ title, description, runId }` — `title` is always non-empty\n *   (falls back to a humanized slug when no run-type prefix matches);\n *   `description` may be an empty string for unknown run-type slugs or\n *   when the descriptions table has no entry for a recognized type.\n *   `runId` is the run-index tail (`'192'`) or the raw slug when no\n *   run-type prefix matched.\n */\nexport function getRunTypeInfo(\n  slug: string,\n  lang: LanguageCode\n): { title: string; description: string; runId: string } {\n  const { type, runId } = parseRunSlug(slug);\n  if (type) {\n    // eslint-disable-next-line security/detect-object-injection\n    const titleRecord = RUN_TYPE_TITLES[type];\n    // eslint-disable-next-line security/detect-object-injection\n    const descRecord = RUN_TYPE_DESCRIPTIONS[type];\n    const title = titleRecord ? getFromRecord(titleRecord, lang) : stripEmojiAndPunct(slug);\n    const description = descRecord ? getFromRecord(descRecord, lang) : '';\n    return { title, description, runId };\n  }\n  return { title: stripEmojiAndPunct(slug), description: '', runId };\n}\n\n/**\n * Normalize an artifact stem by stripping well-known suffixes and mapping\n * synonyms to a canonical template name. Keeps the `getArtifactInfo`\n * lookup table small while still covering every variant we observe under\n * `analysis/daily/**`.\n *\n * Stripped suffixes:\n *   - `.analysis` (e.g. `political-landscape.analysis.md` → `political-landscape`)\n *   - trailing `-analysis`, `-assessment`, `-context`, `-deep-dive`,\n *     `-brief`, `-intelligence` when the stripped stem has a curated template\n *\n * Synonyms (non-exhaustive — extend as new stems appear):\n *   - `coalition-analysis` / `coalition-intelligence` / `coalition-sentiment-analysis`\n *       → `coalition-dynamics`\n *   - `threat-landscape` / `political-threat-landscape` / `coalition-threat-assessment`\n *       → `threat-analysis`\n *   - `ai-<x>` / `political-<x>` → `<x>` when `<x>` has a template\n *   - `actor-threat-profile` → `actor-threat-profiles`\n *\n * @param stem - Raw filename stem (extension already stripped)\n * @returns Canonical template stem to feed into the curated tables\n */\nfunction canonicalizeArtifactStem(stem: string): string {\n  // Strip \".analysis\" compound extension (e.g. \"foo.analysis.md\" → \"foo\")\n  const s = stem.replace(/\\.analysis$/, '');\n\n  // Exact synonym table — higher priority than prefix stripping. The\n  // lookup uses `hasOwn` to avoid prototype-key surprises when a\n  // malformed filename produces a stem like `__proto__`.\n  const SYNONYMS: Record<string, string> = {\n    'coalition-analysis': 'coalition-dynamics',\n    'coalition-intelligence': 'coalition-dynamics',\n    'coalition-sentiment-analysis': 'coalition-dynamics',\n    'coalition-threat-assessment': 'threat-analysis',\n    'coalition-dynamics-assessment': 'coalition-dynamics',\n    'threat-landscape': 'threat-analysis',\n    'threat-landscape-analysis': 'threat-analysis',\n    'political-threat-landscape': 'threat-analysis',\n    'threat-assessment': 'threat-analysis',\n    'political-risk-assessment': 'risk-assessment',\n    'formal-risk-assessment': 'risk-assessment',\n    'political-risk-matrix': 'risk-matrix',\n    'political-stride-assessment': 'threat-model',\n    'political-swot-analysis': 'swot-analysis',\n    'political-landscape': 'intelligence-assessment',\n    'political-landscape-analysis': 'intelligence-assessment',\n    'political-landscape-assessment': 'intelligence-assessment',\n    'political-landscape-context': 'intelligence-assessment',\n    'actor-threat-profile': 'actor-threat-profiles',\n    'actor-threat-profiling': 'actor-threat-profiles',\n    'stakeholder-analysis': 'stakeholder-impact',\n    'stakeholder-impact-assessment': 'stakeholder-impact',\n    'significance-assessment': 'significance-scoring',\n    'committee-power-analysis': 'intelligence-assessment',\n    'legislative-pipeline-analysis': 'legislative-velocity-risk',\n    'legislative-productivity-analysis': 'legislative-velocity-risk',\n    'recent-legislation-review': 'historical-baseline',\n    'trade-policy-assessment': 'pestle-analysis',\n    'trade-policy-deep-dive': 'deep-analysis',\n    'anti-corruption-reform-intelligence': 'intelligence-assessment',\n    'early-warning-deep-dive': 'wildcards-blackswans',\n    'recess-pattern-analysis': 'historical-baseline',\n    'strategic-recess-assessment': 'scenario-forecast',\n    'post-recess-preparedness': 'scenario-forecast',\n    'pre-restart-intelligence-brief': 'executive-brief',\n    'breaking-news-analysis': 'executive-brief',\n    'breaking-intelligence-brief': 'executive-brief',\n    'weekly-intelligence-brief': 'executive-brief',\n    'intelligence-brief': 'executive-brief',\n    'cross-daily-synthesis': 'synthesis-summary',\n    'cross-session-intelligence': 'cross-session-intelligence',\n    'document-analysis-index': 'analysis-index',\n    'attack-surface-map': 'threat-model',\n    'api-outage-diagnostic': 'mcp-reliability-audit',\n    'api-reliability-assessment': 'mcp-reliability-audit',\n    'agent-risk-workflow': 'workflow-audit',\n    forces: 'forces-analysis',\n    voting: 'voting-patterns',\n    // `ai-<x>` family: the artifact uses the same template as the non-AI variant\n    'ai-actor-mapping': 'actor-mapping',\n    'ai-coalition-dynamics': 'coalition-dynamics',\n    'ai-cross-session-intelligence': 'cross-session-intelligence',\n    'ai-deep-analysis': 'deep-analysis',\n    'ai-political-landscape': 'intelligence-assessment',\n    'ai-risk-assessment': 'risk-assessment',\n    'ai-significance-scoring': 'significance-scoring',\n    'ai-stakeholder-impact': 'stakeholder-impact',\n    'ai-swot-analysis': 'swot-analysis',\n    'ai-threat-assessment': 'threat-analysis',\n    'ai-voting-patterns': 'voting-patterns',\n  };\n  if (Object.prototype.hasOwnProperty.call(SYNONYMS, s)) {\n    // eslint-disable-next-line security/detect-object-injection\n    const synonym = SYNONYMS[s];\n    if (typeof synonym === 'string') return synonym;\n  }\n  return s;\n}\n\n/**\n * Feed-prefix label — when an artifact name starts with one of these\n * canonical EP-API feed prefixes we surface a single localized \"per-item\n * analysis of an EP {feed} entry\" label instead of a noisy raw stem.\n */\nconst FEED_PREFIX_LABELS: Record<\n  string,\n  { title: Record<LanguageCode, string>; desc: Record<LanguageCode, string> }\n> = {\n  adoptedtexts: {\n    title: {\n      en: 'Adopted Text Analysis',\n      sv: 'Analys av antagen text',\n      da: 'Analyse af vedtaget tekst',\n      no: 'Analyse av vedtatt tekst',\n      fi: 'Hyväksytyn tekstin analyysi',\n      de: 'Analyse eines angenommenen Textes',\n      fr: 'Analyse d’un texte adopté',\n      es: 'Análisis de texto adoptado',\n      nl: 'Analyse aangenomen tekst',\n      ar: 'تحليل نص معتمد',\n      he: 'ניתוח טקסט שאומץ',\n      ja: '採択文書の分析',\n      ko: '채택된 문서 분석',\n      zh: '已通过文本分析',\n    },\n    desc: {\n      en: 'Per-item analysis of one adopted European Parliament text (resolution, legislative position or non-legislative decision) — classification, stakeholder impact, SWOT and risk scoring.',\n      sv: 'Enskild analys av en antagen text från Europaparlamentet (resolution, lagstiftningsposition eller icke-lagstiftande beslut) — klassificering, intressentpåverkan, SWOT och riskpoäng.',\n      da: 'Analyse pr. element af én vedtaget tekst fra Europa-Parlamentet — klassificering, interessentpåvirkning, SWOT og risikoscoring.',\n      no: 'Analyse per element av én vedtatt tekst fra Europaparlamentet — klassifisering, interessent­påvirkning, SWOT og risikoscoring.',\n      fi: 'Yhden Euroopan parlamentin hyväksymän tekstin yksittäinen analyysi — luokittelu, sidosryhmä­vaikutus, SWOT ja riskipisteet.',\n      de: 'Einzelanalyse eines angenommenen Textes des Europäischen Parlaments — Klassifizierung, Stakeholder-Wirkung, SWOT und Risikobewertung.',\n      fr: 'Analyse individuelle d’un texte adopté du Parlement européen — classification, impact sur les parties prenantes, SWOT et score de risque.',\n      es: 'Análisis individual de un texto adoptado del Parlamento Europeo — clasificación, impacto en partes interesadas, SWOT y puntuación de riesgo.',\n      nl: 'Individuele analyse van één aangenomen tekst van het Europees Parlement — classificatie, stakeholderimpact, SWOT en risicoscoring.',\n      ar: 'تحليل فردي لنص معتمد في البرلمان الأوروبي — التصنيف وتأثير أصحاب المصلحة وSWOT وتقييم المخاطر.',\n      he: 'ניתוח פרטני של טקסט שאומץ בפרלמנט האירופי — סיווג, השפעה על בעלי עניין, SWOT וניקוד סיכון.',\n      ja: '欧州議会で採択された 1 件の文書の個別分析 — 分類、ステークホルダー影響、SWOT、リスクスコア。',\n      ko: '유럽의회에서 채택된 단일 문서 개별 분석 — 분류, 이해관계자 영향, SWOT 및 위험 점수.',\n      zh: '对欧洲议会一项已通过文本的逐件分析——分类、利益相关者影响、SWOT 及风险评分。',\n    },\n  },\n  procedures: {\n    title: {\n      en: 'Legislative Procedure Analysis',\n      sv: 'Analys av lagstiftningsförfarande',\n      da: 'Analyse af lovgivningsprocedure',\n      no: 'Analyse av lovgivningsprosedyre',\n      fi: 'Lainsäädäntö­menettelyn analyysi',\n      de: 'Analyse eines Gesetzgebungs­verfahrens',\n      fr: 'Analyse de procédure législative',\n      es: 'Análisis de procedimiento legislativo',\n      nl: 'Analyse wetgevingsprocedure',\n      ar: 'تحليل إجراء تشريعي',\n      he: 'ניתוח הליך חקיקה',\n      ja: '立法手続の分析',\n      ko: '입법 절차 분석',\n      zh: '立法程序分析',\n    },\n    desc: {\n      en: 'Per-item analysis of one European Parliament legislative procedure — rapporteur, co-decision path, committee assignments, trilogue risk and amendment map.',\n      sv: 'Enskild analys av ett lagstiftnings­förfarande i Europaparlamentet — föredragande, medbeslutande­väg, utskottstilldelningar, trilog­risk och ändringskarta.',\n      da: 'Analyse pr. element af én EP-lovgivnings­procedure — ordfører, fælles beslutningsforløb, udvalgs­tildelinger, trilog-risiko og ændringskort.',\n      no: 'Analyse per element av én EP-lovgivnings­prosedyre — saksordfører, medbestemmelses­løp, komité­tildelinger, trilog-risiko og endringskart.',\n      fi: 'Yhden EP:n lainsäädäntö­menettelyn yksittäinen analyysi — esittelijä, yhteispäätös­polku, valiokunta­tehtävät, trilogi­riski ja tarkistuskartta.',\n      de: 'Einzelanalyse eines EP-Gesetzgebungs­verfahrens — Berichterstatter, Mitentscheidungs­pfad, Ausschuss­zuweisungen, Trilog-Risiko und Änderungs­karte.',\n      fr: 'Analyse individuelle d’une procédure législative du PE — rapporteur, trajet de codécision, attributions de commissions, risque de trilogue et carte des amendements.',\n      es: 'Análisis individual de un procedimiento legislativo del PE — ponente, vía de codecisión, asignaciones de comisión, riesgo de trílogo y mapa de enmiendas.',\n      nl: 'Individuele analyse van één EP-wetgevings­procedure — rapporteur, medebeslissings­traject, commissie­toewijzingen, triloogrisico en amendementenkaart.',\n      ar: 'تحليل فردي لإجراء تشريعي واحد في البرلمان الأوروبي — المقرر، مسار التقرير المشترك، تكليفات اللجان، مخاطر الترايلوج وخريطة التعديلات.',\n      he: 'ניתוח פרטני של הליך חקיקה בפרלמנט האירופי — דובר הוועדה, מסלול החלטה משותפת, הקצאות ועדות, סיכון טרילוג ומפת תיקונים.',\n      ja: '欧州議会の 1 件の立法手続の個別分析 — 報告者、共同決定の経路、委員会割当、トリローグリスク、修正マップ。',\n      ko: 'EP 단일 입법 절차 개별 분석 — 보고위원, 공동결정 경로, 위원회 배정, 삼자협의 위험, 수정안 지도.',\n      zh: '对一项欧洲议会立法程序的逐件分析——报告员、共同决定路径、委员会分配、三方谈判风险和修正案图谱。',\n    },\n  },\n  documents: {\n    title: {\n      en: 'Committee Document Analysis',\n      sv: 'Analys av utskotts­dokument',\n      da: 'Analyse af udvalgs­dokument',\n      no: 'Analyse av komité­dokument',\n      fi: 'Valiokunta­asiakirjan analyysi',\n      de: 'Analyse eines Ausschuss­dokuments',\n      fr: 'Analyse d’un document de commission',\n      es: 'Análisis de documento de comisión',\n      nl: 'Analyse commissie­document',\n      ar: 'تحليل وثيقة لجنة',\n      he: 'ניתוח מסמך ועדה',\n      ja: '委員会文書の分析',\n      ko: '위원회 문서 분석',\n      zh: '委员会文件分析',\n    },\n    desc: {\n      en: 'Per-item analysis of one EP committee document — working document, draft report or opinion — with stakeholder map, amendment risk and trilogue readiness assessment.',\n      sv: 'Enskild analys av ett EP-utskottsdokument — arbets­dokument, utkast till betänkande eller yttrande — med intressentkarta, ändringsrisk och bedömning av trilog­beredskap.',\n      da: 'Analyse pr. element af ét EP-udvalgs­dokument — arbejds­dokument, udkast til betænkning eller udtalelse — med interessentkort, ændringsrisiko og trilog-paratheds­vurdering.',\n      no: 'Analyse per element av ett EP-komité­dokument — arbeids­dokument, rapportutkast eller uttalelse — med interessentkart, endringsrisiko og trilog-beredskaps­vurdering.',\n      fi: 'Yhden EP:n valiokunta-asiakirjan yksittäinen analyysi — työasiakirja, mietintö­luonnos tai lausunto — sidosryhmä­kartalla, tarkistus­riskillä ja trilogivalmius­arviolla.',\n      de: 'Einzelanalyse eines EP-Ausschuss­dokuments — Arbeitsdokument, Berichtsentwurf oder Stellungnahme — mit Stakeholder-Karte, Änderungsrisiko und Trilog-Bereitschaftsbewertung.',\n      fr: 'Analyse individuelle d’un document de commission PE — document de travail, projet de rapport ou avis — avec carte des parties prenantes, risque d’amendement et évaluation de la préparation au trilogue.',\n      es: 'Análisis individual de un documento de comisión PE — documento de trabajo, proyecto de informe u opinión — con mapa de partes interesadas, riesgo de enmienda y evaluación de preparación para trílogo.',\n      nl: 'Individuele analyse van één EP-commissie­document — werkdocument, ontwerpverslag of advies — met stakeholderkaart, amendement­risico en triloog­paraatheidsbeoordeling.',\n      ar: 'تحليل فردي لوثيقة لجنة في البرلمان الأوروبي — وثيقة عمل أو مسودة تقرير أو رأي — مع خريطة أصحاب المصلحة ومخاطر التعديل وتقييم جاهزية الترايلوج.',\n      he: 'ניתוח פרטני של מסמך ועדה בפרלמנט האירופי — מסמך עבודה, טיוטת דו״ח או חוות דעת — עם מפת בעלי עניין, סיכון תיקונים והערכת מוכנות לטרילוג.',\n      ja: 'EP 委員会文書 1 件の個別分析（作業文書／報告書草案／意見書）— ステークホルダーマップ、修正リスク、トリローグ準備度評価。',\n      ko: 'EP 위원회 문서 1건 개별 분석(작업 문서, 보고서 초안 또는 의견서) — 이해관계자 지도, 수정 위험 및 삼자협의 준비도 평가.',\n      zh: '对一份欧洲议会委员会文件（工作文件、报告草案或意见书）的逐件分析——利益相关者图谱、修正风险及三方谈判准备度评估。',\n    },\n  },\n  events: {\n    title: {\n      en: 'Parliamentary Event Analysis',\n      sv: 'Analys av parlamentariskt evenemang',\n      da: 'Analyse af parlamentarisk begivenhed',\n      no: 'Analyse av parlamentarisk hendelse',\n      fi: 'Parlamentaarisen tapahtuman analyysi',\n      de: 'Analyse einer parlamentarischen Veranstaltung',\n      fr: 'Analyse d’un événement parlementaire',\n      es: 'Análisis de evento parlamentario',\n      nl: 'Analyse parlementair evenement',\n      ar: 'تحليل فعالية برلمانية',\n      he: 'ניתוח אירוע פרלמנטרי',\n      ja: '議会イベントの分析',\n      ko: '의회 이벤트 분석',\n      zh: '议会活动分析',\n    },\n    desc: {\n      en: 'Per-item analysis of one EP event — plenary, committee meeting, hearing or conference — with agenda map, stakeholder participation and political significance scoring.',\n      sv: 'Enskild analys av ett EP-evenemang — plenum, utskottsmöte, utfrågning eller konferens — med dagordningskarta, intressentdeltagande och politisk signifikanspoäng.',\n      da: 'Analyse pr. element af én EP-begivenhed — plenarmøde, udvalgs­møde, høring eller konference — med dagsordens­kort, interessentdeltagelse og politisk signifikansscoring.',\n      no: 'Analyse per element av én EP-hendelse — plenum, komitémøte, høring eller konferanse — med agendakart, interessent­deltakelse og politisk signifikansscore.',\n      fi: 'Yhden EP-tapahtuman yksittäinen analyysi — täysistunto, valiokuntakokous, kuuleminen tai konferenssi — esityslista­kartalla, sidosryhmien osallistumisella ja poliittisella merkitys­pisteytyksellä.',\n      de: 'Einzelanalyse einer EP-Veranstaltung — Plenum, Ausschuss­sitzung, Anhörung oder Konferenz — mit Tagesordnungs­karte, Stakeholder-Teilnahme und politischer Signifikanzbewertung.',\n      fr: 'Analyse individuelle d’un événement PE — plénière, réunion de commission, audition ou conférence — avec carte de l’ordre du jour, participation des parties prenantes et score d’importance politique.',\n      es: 'Análisis individual de un evento PE — pleno, reunión de comisión, audiencia o conferencia — con mapa de orden del día, participación de interesados y puntuación de significancia política.',\n      nl: 'Individuele analyse van één EP-evenement — plenair, commissie­vergadering, hoorzitting of conferentie — met agendakaart, stakeholder­deelname en politieke significantiescore.',\n      ar: 'تحليل فردي لفعالية في البرلمان الأوروبي — جلسة عامة أو اجتماع لجنة أو جلسة استماع أو مؤتمر — مع خريطة جدول الأعمال ومشاركة أصحاب المصلحة وتقييم الأهمية السياسية.',\n      he: 'ניתוח פרטני של אירוע בפרלמנט האירופי — מליאה, ישיבת ועדה, שימוע או כנס — עם מפת סדר יום, השתתפות בעלי עניין ודירוג משמעות פוליטית.',\n      ja: 'EP イベント 1 件の個別分析（本会議／委員会／公聴会／会議）— 議題マップ、ステークホルダー参加、政治的重要度スコア。',\n      ko: 'EP 이벤트 1건 개별 분석(본회의, 위원회 회의, 공청회 또는 콘퍼런스) — 의제 지도, 이해관계자 참여 및 정치적 중요도 점수.',\n      zh: '对一次欧洲议会活动（全体会议、委员会会议、听证会或研讨会）的逐件分析——议程图、利益相关者参与度、政治重要性评分。',\n    },\n  },\n  externaldocuments: {\n    title: {\n      en: 'External Document Analysis',\n      sv: 'Analys av externt dokument',\n      da: 'Analyse af eksternt dokument',\n      no: 'Analyse av eksternt dokument',\n      fi: 'Ulkopuolisen asiakirjan analyysi',\n      de: 'Analyse eines externen Dokuments',\n      fr: 'Analyse d’un document externe',\n      es: 'Análisis de documento externo',\n      nl: 'Analyse extern document',\n      ar: 'تحليل وثيقة خارجية',\n      he: 'ניתוח מסמך חיצוני',\n      ja: '外部文書の分析',\n      ko: '외부 문서 분석',\n      zh: '外部文件分析',\n    },\n    desc: {\n      en: 'Per-item analysis of one external document referenced by the EP — Council position, Commission proposal or partner-institution input — with cross-institutional stakeholder map and risk score.',\n      sv: 'Enskild analys av ett externt dokument som EP hänvisar till — rådets ståndpunkt, kommissionens förslag eller bidrag från partner­institution — med institutionsövergripande intressentkarta och riskpoäng.',\n      da: 'Analyse pr. element af ét eksternt dokument, som EP henviser til — rådets holdning, Kommissionens forslag eller input fra partner­institution — med institutions­overskridende interessentkort og risikoscoring.',\n      no: 'Analyse per element av ett eksternt dokument EP refererer til — råds­posisjon, kommisjons­forslag eller partner­institusjons­innspill — med tverr­institusjonelt interessentkart og risikoscore.',\n      fi: 'Yhden EP:n viittaaman ulkopuolisen asiakirjan yksittäinen analyysi — neuvoston kanta, komission ehdotus tai yhteistyö­laitoksen kontribuutio — toimi­elinten väliseltä sidosryhmä­kartalta ja riskipisteillä.',\n      de: 'Einzelanalyse eines vom EP referenzierten externen Dokuments — Ratsposition, Kommissions­vorschlag oder Beitrag einer Partnerinstitution — mit institutionsübergreifender Stakeholder-Karte und Risikobewertung.',\n      fr: 'Analyse individuelle d’un document externe référencé par le PE — position du Conseil, proposition de la Commission ou apport d’une institution partenaire — avec carte des parties prenantes inter-institutions et score de risque.',\n      es: 'Análisis individual de un documento externo referenciado por el PE — posición del Consejo, propuesta de la Comisión o aportación de una institución socia — con mapa de interesados interinstitucional y puntuación de riesgo.',\n      nl: 'Individuele analyse van één extern document waarnaar het EP verwijst — Raads­standpunt, Commissie­voorstel of input van een partner­instelling — met inter-institutionele stakeholderkaart en risicoscoring.',\n      ar: 'تحليل فردي لوثيقة خارجية يشير إليها البرلمان الأوروبي — موقف المجلس أو اقتراح المفوضية أو مساهمة مؤسسة شريكة — مع خريطة أصحاب المصلحة بين المؤسسات وتقييم المخاطر.',\n      he: 'ניתוח פרטני של מסמך חיצוני שהפרלמנט האירופי מפנה אליו — עמדת המועצה, הצעת הנציבות או קלט ממוסד שותף — עם מפת בעלי עניין בין-מוסדית וניקוד סיכון.',\n      ja: 'EP が参照する外部文書 1 件の個別分析（理事会ポジション／欧州委提案／パートナー機関寄与）— 機関横断ステークホルダーマップ、リスクスコア。',\n      ko: 'EP이 참조하는 외부 문서 1건 개별 분석(이사회 입장, 집행위원회 제안 또는 파트너 기관 기여) — 기관 간 이해관계자 지도 및 위험 점수.',\n      zh: '对欧洲议会引用的一份外部文件（理事会立场、欧委会提案或合作机构意见）的逐件分析——跨机构利益相关者图谱与风险评分。',\n    },\n  },\n};\n\n/**\n * Orphan artifact table — free-standing artifact stems that have no\n * counterpart template under `analysis/templates/`. Every entry ships all\n * 14 languages so non-English pages never show raw English.\n */\nconst ORPHAN_ARTIFACT_INFO: Record<\n  string,\n  { title: Record<LanguageCode, string>; desc: Record<LanguageCode, string> }\n> = {\n  'agent-pre-work': {\n    title: {\n      en: 'Agent Pre-Work',\n      sv: 'Agentens förberedelsearbete',\n      da: 'Agentens forarbejde',\n      no: 'Agentens forarbeid',\n      fi: 'Agentin ennakkotyö',\n      de: 'Agenten-Vorarbeit',\n      fr: 'Travail préparatoire de l’agent',\n      es: 'Trabajo previo del agente',\n      nl: 'Voorbereidend werk van de agent',\n      ar: 'أعمال تمهيدية للعميل',\n      he: 'עבודת הכנה של הסוכן',\n      ja: 'エージェント事前作業',\n      ko: '에이전트 사전 작업',\n      zh: '代理前期工作',\n    },\n    desc: {\n      en: 'Raw inputs the AI agent collected before starting analysis — data-pull logs, scope notes, tool inventory and methodology selection. Gives auditors full traceability of what went into the run.',\n      sv: 'Rådata som AI-agenten samlade in innan analysen — datahämtnings­loggar, omfattnings­anteckningar, verktygsinventering och metodval. Ger granskare full spårbarhet över vad som gick in i körningen.',\n      da: 'Rå input indsamlet af AI-agenten før analysen — datahentningslogfiler, scope-noter, værktøjs­inventar og metodeudvælgelse. Giver revisorer fuld sporbarhed.',\n      no: 'Rådata AI-agenten samlet inn før analysen — datauttrekkslogger, omfangs­notater, verktøy­inventar og metodevalg. Gir full sporbarhet for revisorer.',\n      fi: 'AI-agentin keräämät raakatiedot ennen analyysiä — tiedonhaku­lokit, rajaus­muistiinpanot, työkalu­luettelo ja metodi­valinta. Antaa auditoijille täyden jäljitettävyyden.',\n      de: 'Rohdaten, die der KI-Agent vor Analysebeginn gesammelt hat — Datenabruf­protokolle, Scope-Notizen, Werkzeug­inventar und Methoden­auswahl. Liefert Prüfern volle Nachvollziehbarkeit.',\n      fr: 'Données brutes collectées par l’agent IA avant l’analyse — journaux d’extraction, notes de cadrage, inventaire d’outils et sélection méthodologique. Traçabilité complète pour les auditeurs.',\n      es: 'Entradas en bruto que el agente de IA recopiló antes del análisis — registros de extracción, notas de alcance, inventario de herramientas y selección metodológica. Trazabilidad completa para auditores.',\n      nl: 'Ruwe input die de AI-agent vóór de analyse verzamelde — data-pull­logs, scope-notities, toolinventaris en methodologie­selectie. Volledige traceerbaarheid voor auditors.',\n      ar: 'المدخلات الخام التي جمعها وكيل الذكاء الاصطناعي قبل التحليل — سجلات سحب البيانات، ملاحظات النطاق، جرد الأدوات واختيار المنهجية. يضمن تتبعًا كاملاً.',\n      he: 'קלט גולמי שסוכן ה-AI אסף לפני הניתוח — יומני משיכת נתונים, הערות טווח, מלאי כלים ובחירת מתודולוגיה. עקיבות מלאה לבודקים.',\n      ja: 'AI エージェントが分析開始前に収集した生データ — データ取得ログ、スコープメモ、ツール一覧、方法論の選定。監査人が完全な追跡性を得られる。',\n      ko: 'AI 에이전트가 분석 시작 전 수집한 원시 입력 — 데이터 추출 로그, 범위 메모, 도구 목록, 방법론 선택. 감사자에게 완전한 추적성을 제공합니다.',\n      zh: 'AI 代理在开始分析前收集的原始输入——数据抽取日志、范围说明、工具清单与方法论选择，为审计者提供完整的可追溯性。',\n    },\n  },\n  summary: {\n    title: {\n      en: 'Run Summary',\n      sv: 'Körnings­sammanfattning',\n      da: 'Kørsels­opsummering',\n      no: 'Kjørings­oppsummering',\n      fi: 'Ajon yhteenveto',\n      de: 'Lauf-Zusammenfassung',\n      fr: 'Synthèse d’exécution',\n      es: 'Resumen de ejecución',\n      nl: 'Run-samenvatting',\n      ar: 'ملخص التشغيل',\n      he: 'סיכום ההרצה',\n      ja: '実行サマリー',\n      ko: '실행 요약',\n      zh: '运行摘要',\n    },\n    desc: {\n      en: 'Executive summary of the run — top-line findings, headline risk score, decisive artifacts and the key takeaways fed into the final article.',\n      sv: 'Sammanfattning av körningen — huvudfynd, riskpoäng i rubriken, avgörande artefakter och nyckelslutsatser som gick in i slutartikeln.',\n      da: 'Executive summary af kørslen — hovedfund, overskriftsrisiko­score, afgørende artefakter og nøglebudskaber til slutartiklen.',\n      no: 'Sammendrag av kjøringen — hovedfunn, overskrifts­risikoscore, avgjørende artefakter og nøkkelpunkter til sluttartikkelen.',\n      fi: 'Ajon tiivistelmä — päähavainnot, otsikkotason riskipisteet, ratkaisevat artefaktit ja lopulliseen artikkeliin vietävät avainviestit.',\n      de: 'Executive Summary des Laufs — Kernergebnisse, Kopfzeilen-Risiko, entscheidende Artefakte und Schlüsselaussagen für den Artikel.',\n      fr: 'Synthèse exécutive de l’exécution — conclusions principales, score de risque en une ligne, artefacts décisifs et messages-clés repris dans l’article final.',\n      es: 'Resumen ejecutivo de la ejecución — hallazgos principales, puntuación de riesgo de titular, artefactos decisivos y conclusiones clave que alimentan el artículo final.',\n      nl: 'Executive summary van de run — hoofdbevindingen, kop-risicoscore, beslissende artefacten en kernpunten voor het uiteindelijke artikel.',\n      ar: 'ملخص تنفيذي للتشغيل — أبرز النتائج، درجة المخاطر في العنوان، القطع الحاسمة والرسائل الرئيسية التي تغذي المقال النهائي.',\n      he: 'תקציר מנהלים של ההרצה — ממצאים מרכזיים, ציון סיכון לכותרת, ארטיפקטים מכריעים ומסקנות עיקריות שמזינות את המאמר הסופי.',\n      ja: '実行のエグゼクティブ・サマリー — 主要所見、ヘッドライン・リスクスコア、決定的アーティファクト、最終記事に反映される要点。',\n      ko: '실행 요약 — 핵심 발견, 헤드라인 위험 점수, 결정적 산출물 및 최종 기사에 반영되는 주요 시사점.',\n      zh: '运行的执行摘要——核心发现、头条风险评分、关键产物以及纳入最终文章的主要结论。',\n    },\n  },\n  readme: {\n    title: {\n      en: 'Run README',\n      sv: 'Körnings-README',\n      da: 'Kørsels-README',\n      no: 'Kjørings-README',\n      fi: 'Ajon README',\n      de: 'Lauf-README',\n      fr: 'README d’exécution',\n      es: 'README de ejecución',\n      nl: 'Run-README',\n      ar: 'قراءة أولى للتشغيل',\n      he: 'README של ההרצה',\n      ja: '実行 README',\n      ko: '실행 README',\n      zh: '运行 README',\n    },\n    desc: {\n      en: 'Orientation file for the run — article type, scope, methodology set applied, artifact inventory and how to read the folder.',\n      sv: 'Orienteringsfil för körningen — artikeltyp, omfattning, tillämpad metoduppsättning, artefaktförteckning och hur mappen ska läsas.',\n      da: 'Orienterings­fil for kørslen — artikeltype, scope, anvendt metodesæt, artefakt­oversigt og mappens læseguide.',\n      no: 'Orienterings­fil for kjøringen — artikkeltype, omfang, anvendt metodesett, artefakt­oversikt og mappeguide.',\n      fi: 'Ajon orientaatio­tiedosto — artikkelityyppi, laajuus, sovellettu metodiryhmä, artefakti­luettelo ja kansion luku­ohje.',\n      de: 'Orientierungs­datei für den Lauf — Artikeltyp, Scope, angewandtes Methoden­set, Artefakt­inventar und Lese­leitfaden des Ordners.',\n      fr: 'Fichier d’orientation de l’exécution — type d’article, périmètre, méthodologies appliquées, inventaire d’artefacts et guide de lecture du dossier.',\n      es: 'Archivo de orientación de la ejecución — tipo de artículo, alcance, metodologías aplicadas, inventario de artefactos y guía de lectura de la carpeta.',\n      nl: 'Oriëntatie­bestand voor de run — artikeltype, scope, toegepaste methodologieënset, artefactinventaris en leeswijzer van de map.',\n      ar: 'ملف توجيه للتشغيل — نوع المقال، النطاق، مجموعة المنهجيات المطبقة، جرد القطع وكيفية قراءة المجلد.',\n      he: 'קובץ התמצאות להרצה — סוג המאמר, טווח, ערכת מתודולוגיות שיושמה, מלאי ארטיפקטים ומדריך קריאה של התיקייה.',\n      ja: '実行のオリエンテーション・ファイル — 記事タイプ、スコープ、適用メソドロジーセット、アーティファクト一覧、フォルダ閲覧ガイド。',\n      ko: '실행 안내 파일 — 기사 유형, 범위, 적용된 방법론 세트, 산출물 목록 및 폴더 읽기 가이드.',\n      zh: '运行的指引文件——文章类型、范围、应用的方法论集、产物清单与目录阅读指南。',\n    },\n  },\n};\n\n/**\n * Parse a feed-prefixed artifact stem (e.g. `adoptedtexts-foo-bar-analysis`)\n * into its canonical feed key (`adoptedtexts`) and tail, if recognized.\n *\n * @param stem - Raw filename stem (extension stripped)\n * @returns `{ feed, tail }` when recognized, else `null`\n */\nfunction parseFeedPrefix(stem: string): { feed: string; tail: string } | null {\n  for (const feed of Object.keys(FEED_PREFIX_LABELS)) {\n    if (stem.startsWith(`${feed}-`)) {\n      return { feed, tail: stem.slice(feed.length + 1) };\n    }\n  }\n  return null;\n}\n\n/**\n * Resolve a localized title + description for a single daily analysis\n * artifact Markdown file.\n *\n * Resolution order:\n *   1. Feed-prefix detection — files starting with `adoptedtexts-`,\n *      `procedures-`, `documents-`, `events-`, `externaldocuments-` get a\n *      single fully-localized per-item label irrespective of the slug tail.\n *   2. Stem canonicalization — `ai-swot-analysis` → `swot-analysis`,\n *      `political-risk-assessment` → `risk-assessment`, etc. — so shared\n *      curated template entries apply to every variant.\n *   3. Template lookup — `analysis/templates/<canonical>.md` in the\n *      {@link getCuratedTitle} / {@link getCuratedDescription} tables.\n *   4. Orphan table — for stems with no template we ship curated titles\n *      and descriptions in all 14 languages.\n *   5. Localized generic fallback — humanized stem + language-specific\n *      \"template in the EU Parliament Monitor analysis library\" sentence.\n *\n * @param shortPath - Run-relative path (e.g. `intelligence/swot-analysis.md`)\n * @param lang      - Target language code\n * @returns `{ title, description }` — both always non-empty and localized\n */\nexport function getArtifactInfo(\n  shortPath: string,\n  lang: LanguageCode\n): { title: string; description: string } {\n  const base = shortPath.split('/').pop() ?? shortPath;\n  const rawStem = base.replace(/\\.[^.]+$/, '');\n  // 1. Feed prefix — single localized label. `parseFeedPrefix` already\n  //    restricts its return value to `Object.keys(FEED_PREFIX_LABELS)`,\n  //    and we still guard with `hasOwn` to block any prototype-key surprise.\n  const feed = parseFeedPrefix(rawStem);\n  if (feed && Object.prototype.hasOwnProperty.call(FEED_PREFIX_LABELS, feed.feed)) {\n    // eslint-disable-next-line security/detect-object-injection\n    const entry = FEED_PREFIX_LABELS[feed.feed];\n    if (entry) {\n      return {\n        title: getFromRecord(entry.title, lang),\n        description: getFromRecord(entry.desc, lang),\n      };\n    }\n  }\n  // 2. Canonicalize stem (strip `.analysis`, apply synonym map)\n  const stem = canonicalizeArtifactStem(rawStem);\n  // 3. Orphan-table lookup — stems with no template counterpart.\n  //    Checked before template lookup so orphan entries override the\n  //    localized generic fallback. `hasOwn` blocks prototype-key lookups\n  //    (e.g. a hypothetical `__proto__.md` file).\n  const stemLower = stem.toLowerCase();\n  if (Object.prototype.hasOwnProperty.call(ORPHAN_ARTIFACT_INFO, stemLower)) {\n    // eslint-disable-next-line security/detect-object-injection\n    const orphan = ORPHAN_ARTIFACT_INFO[stemLower];\n    if (orphan) {\n      return {\n        title: getFromRecord(orphan.title, lang),\n        description: getFromRecord(orphan.desc, lang),\n      };\n    }\n  }\n  // 4. Template lookup via existing curated tables. When no curated entry\n  //    exists the description falls through to the generic fallback — in\n  //    that case swap the lookup path from `analysis/templates/…` to\n  //    `analysis/daily/…` so `inferKind()` picks `KIND_WORDS_ARTIFACT`\n  //    (\"artifact\") instead of `KIND_WORDS_TEMPLATE` (\"template\"). This\n  //    keeps the fallback sentence accurate for daily-run artifacts.\n  const templateKey = `analysis/templates/${stem}.md`;\n  const humanized = stripEmojiAndPunct(stem);\n  const title = getCuratedTitle(templateKey, lang, humanized);\n  const descriptionKey = hasCuratedDescription(templateKey)\n    ? templateKey\n    : `analysis/daily/${stem}.md`;\n  const description = getCuratedDescription(descriptionKey, lang, humanized);\n  return { title, description };\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence/copy.ts","messages":[],"suppressedMessages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":611,"column":21,"endLine":611,"endColumn":34,"suppressions":[{"kind":"directive","justification":""}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence/data.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence/html.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence/icons.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence/markdown.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/political-intelligence/types.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/sitemap.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/sitemap/copy.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":471,"column":10,"endLine":471,"endColumn":28}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Generators/Sitemap/Copy\n * @description Localized copy tables and the canonical category order used\n * by the sitemap HTML pages. Lifted out of `sitemap.ts` so the data can\n * be shared between the HTML renderer and any future consumer (RSS title\n * fallback, structured-data builder, etc.) without duplicating 14\n * language variants.\n *\n * **No imports from other generator modules** — this file is leaf data\n * with a single public type re-export from `../types/index.ts`. That\n * keeps the bounded context of \"sitemap copy\" pure, makes the file easy\n * to audit, and lets any new locale be added in one place.\n */\n\nimport { ArticleCategory } from '../../types/index.js';\n\n/** Default sitemap title used as English fallback */\nexport const DEFAULT_SITEMAP_TITLE = 'Sitemap';\n\n/** Sitemap page titles per language */\nexport const SITEMAP_TITLES: Record<string, string> = {\n  en: DEFAULT_SITEMAP_TITLE,\n  sv: 'Webbplatskarta',\n  da: DEFAULT_SITEMAP_TITLE,\n  no: 'Nettstedskart',\n  fi: 'Sivukartta',\n  de: 'Seitenübersicht',\n  fr: 'Plan du site',\n  es: 'Mapa del sitio',\n  nl: DEFAULT_SITEMAP_TITLE,\n  ar: 'خريطة الموقع',\n  he: 'מפת אתר',\n  ja: 'サイトマップ',\n  ko: '사이트맵',\n  zh: '网站地图',\n};\n\n/** Sitemap section headings per language */\nexport const SITEMAP_SECTIONS: Record<string, { news: string; docs: string; pages: string }> = {\n  en: { news: 'News Articles', docs: 'Documentation', pages: 'Pages' },\n  sv: { news: 'Nyhetsartiklar', docs: 'Dokumentation', pages: 'Sidor' },\n  da: { news: 'Nyhedsartikler', docs: 'Dokumentation', pages: 'Sider' },\n  no: { news: 'Nyhetsartikler', docs: 'Dokumentasjon', pages: 'Sider' },\n  fi: { news: 'Uutisartikkelit', docs: 'Dokumentaatio', pages: 'Sivut' },\n  de: { news: 'Nachrichtenartikel', docs: 'Dokumentation', pages: 'Seiten' },\n  fr: { news: 'Articles de presse', docs: 'Documentation', pages: 'Pages' },\n  es: { news: 'Artículos de noticias', docs: 'Documentación', pages: 'Páginas' },\n  nl: { news: 'Nieuwsartikelen', docs: 'Documentatie', pages: \"Pagina's\" },\n  ar: { news: 'مقالات إخبارية', docs: 'التوثيق', pages: 'الصفحات' },\n  he: { news: 'מאמרי חדשות', docs: 'תיעוד', pages: 'דפים' },\n  ja: { news: 'ニュース記事', docs: 'ドキュメント', pages: 'ページ' },\n  ko: { news: '뉴스 기사', docs: '문서', pages: '페이지' },\n  zh: { news: '新闻文章', docs: '文档', pages: '页面' },\n};\n\n/** Documentation section labels per language */\nexport const DOCS_LABELS: Record<\n  string,\n  { api: string; coverage: string; testResults: string; docsHome: string }\n> = {\n  en: {\n    api: 'API Documentation',\n    coverage: 'Code Coverage',\n    testResults: 'Test Results',\n    docsHome: 'Documentation Home',\n  },\n  sv: {\n    api: 'API-dokumentation',\n    coverage: 'Kodtäckning',\n    testResults: 'Testresultat',\n    docsHome: 'Dokumentationsstart',\n  },\n  da: {\n    api: 'API-dokumentation',\n    coverage: 'Kodedækning',\n    testResults: 'Testresultater',\n    docsHome: 'Dokumentationsstart',\n  },\n  no: {\n    api: 'API-dokumentasjon',\n    coverage: 'Kodedekning',\n    testResults: 'Testresultater',\n    docsHome: 'Dokumentasjonsstart',\n  },\n  fi: {\n    api: 'API-dokumentaatio',\n    coverage: 'Koodikattavuus',\n    testResults: 'Testitulokset',\n    docsHome: 'Dokumentaation etusivu',\n  },\n  de: {\n    api: 'API-Dokumentation',\n    coverage: 'Codeabdeckung',\n    testResults: 'Testergebnisse',\n    docsHome: 'Dokumentationsstart',\n  },\n  fr: {\n    api: 'Documentation API',\n    coverage: 'Couverture du code',\n    testResults: 'Résultats des tests',\n    docsHome: 'Accueil documentation',\n  },\n  es: {\n    api: 'Documentación API',\n    coverage: 'Cobertura de código',\n    testResults: 'Resultados de pruebas',\n    docsHome: 'Inicio de documentación',\n  },\n  nl: {\n    api: 'API-documentatie',\n    coverage: 'Codedekking',\n    testResults: 'Testresultaten',\n    docsHome: 'Documentatiestart',\n  },\n  ar: {\n    api: 'وثائق API',\n    coverage: 'تغطية الكود',\n    testResults: 'نتائج الاختبار',\n    docsHome: 'الصفحة الرئيسية للتوثيق',\n  },\n  he: {\n    api: 'תיעוד API',\n    coverage: 'כיסוי קוד',\n    testResults: 'תוצאות בדיקות',\n    docsHome: 'דף הבית של התיעוד',\n  },\n  ja: {\n    api: 'APIドキュメント',\n    coverage: 'コードカバレッジ',\n    testResults: 'テスト結果',\n    docsHome: 'ドキュメントホーム',\n  },\n  ko: {\n    api: 'API 문서',\n    coverage: '코드 커버리지',\n    testResults: '테스트 결과',\n    docsHome: '문서 홈',\n  },\n  zh: { api: 'API 文档', coverage: '代码覆盖率', testResults: '测试结果', docsHome: '文档首页' },\n};\n\n/** Localized strings that power the sitemap hero, breadcrumb and section intros */\nexport interface SitemapCopy {\n  /** Intro paragraph rendered below the h1 hero heading */\n  intro: string;\n  /** Short subtitle rendered inside the hero block */\n  heroSubtitle: string;\n  /** Breadcrumb label for the Home link */\n  home: string;\n  /** Breadcrumb label for the current Site Map page */\n  breadcrumbCurrent: string;\n  /** ARIA label for the breadcrumb nav */\n  breadcrumbLabel: string;\n  /** Intro paragraph for the Pages section */\n  pagesDescription: string;\n  /** Intro paragraph for the Documentation section */\n  docsDescription: string;\n  /** Intro paragraph for the News Articles section */\n  newsDescription: string;\n  /** Stats: \"Articles\" label */\n  statArticlesLabel: string;\n  /** Stats: \"Languages\" label */\n  statLanguagesLabel: string;\n  /** Stats: \"Last updated\" label */\n  statLastUpdatedLabel: string;\n  /** Stats: \"Categories\" label */\n  statCategoriesLabel: string;\n  /** One-line description for the link to the Political Intelligence page */\n  politicalIntelligenceLinkDescription: string;\n}\n\n/** Per-language copy for the sitemap hero, breadcrumb, and section intros */\nexport const SITEMAP_COPY: Record<string, SitemapCopy> = {\n  en: {\n    intro:\n      'Complete overview of every page on EU Parliament Monitor — index pages, news articles, and technical documentation. Use this page to discover content and navigate directly to any article across all 14 languages.',\n    heroSubtitle: 'Complete site navigation',\n    home: 'Home',\n    breadcrumbCurrent: 'Site Map',\n    breadcrumbLabel: 'Breadcrumb',\n    pagesDescription:\n      'Primary landing pages in every supported language — the best starting point for each audience.',\n    docsDescription:\n      'Technical documentation including API reference, code coverage, and test results.',\n    newsDescription:\n      'Every published news article in this language, sorted newest first and grouped by editorial format.',\n    statArticlesLabel: 'Articles',\n    statLanguagesLabel: 'Languages',\n    statLastUpdatedLabel: 'Last updated',\n    statCategoriesLabel: 'Categories',\n    politicalIntelligenceLinkDescription:\n      'Index of every methodology, template, and daily analysis run — the transparent tradecraft behind every article.',\n  },\n  sv: {\n    intro:\n      'Komplett översikt över alla sidor på EU Parliament Monitor — startsidor, nyhetsartiklar och teknisk dokumentation. Använd sidan för att upptäcka innehåll och navigera direkt till valfri artikel på alla 14 språk.',\n    heroSubtitle: 'Komplett webbplatsnavigering',\n    home: 'Hem',\n    breadcrumbCurrent: 'Webbplatskarta',\n    breadcrumbLabel: 'Brödsmulor',\n    pagesDescription:\n      'Primära startsidor på varje språk som stöds — bästa utgångspunkten för varje målgrupp.',\n    docsDescription: 'Teknisk dokumentation inklusive API-referens, kodtäckning och testresultat.',\n    newsDescription:\n      'Alla publicerade nyhetsartiklar på detta språk, sorterade med nyaste överst och grupperade efter redaktionellt format.',\n    statArticlesLabel: 'Artiklar',\n    statLanguagesLabel: 'Språk',\n    statLastUpdatedLabel: 'Senast uppdaterad',\n    statCategoriesLabel: 'Kategorier',\n    politicalIntelligenceLinkDescription:\n      'Index över varje metodik, mall och daglig analyskörning — det transparenta hantverket bakom varje artikel.',\n  },\n  da: {\n    intro:\n      'Komplet oversigt over alle sider på EU Parliament Monitor — startsider, nyhedsartikler og teknisk dokumentation. Brug siden til at opdage indhold og navigere direkte til enhver artikel på alle 14 sprog.',\n    heroSubtitle: 'Komplet webstedsnavigation',\n    home: 'Hjem',\n    breadcrumbCurrent: 'Sitemap',\n    breadcrumbLabel: 'Brødkrummer',\n    pagesDescription:\n      'Primære startsider på hvert understøttet sprog — det bedste udgangspunkt for hver målgruppe.',\n    docsDescription:\n      'Teknisk dokumentation inklusive API-reference, kodedækning og testresultater.',\n    newsDescription:\n      'Alle offentliggjorte nyhedsartikler på dette sprog, sorteret nyeste først og grupperet efter redaktionelt format.',\n    statArticlesLabel: 'Artikler',\n    statLanguagesLabel: 'Sprog',\n    statLastUpdatedLabel: 'Sidst opdateret',\n    statCategoriesLabel: 'Kategorier',\n    politicalIntelligenceLinkDescription:\n      'Indeks over hver metode, skabelon og daglig analysekørsel — det gennemsigtige håndværk bag hver artikel.',\n  },\n  no: {\n    intro:\n      'Komplett oversikt over alle sider på EU Parliament Monitor — startsider, nyhetsartikler og teknisk dokumentasjon. Bruk siden for å oppdage innhold og navigere direkte til enhver artikkel på alle 14 språk.',\n    heroSubtitle: 'Komplett nettstedsnavigasjon',\n    home: 'Hjem',\n    breadcrumbCurrent: 'Nettstedskart',\n    breadcrumbLabel: 'Brødsmuler',\n    pagesDescription:\n      'Primære startsider på hvert støttet språk — det beste utgangspunktet for hver målgruppe.',\n    docsDescription:\n      'Teknisk dokumentasjon inkludert API-referanse, kodedekning og testresultater.',\n    newsDescription:\n      'Alle publiserte nyhetsartikler på dette språket, sortert med nyeste først og gruppert etter redaksjonelt format.',\n    statArticlesLabel: 'Artikler',\n    statLanguagesLabel: 'Språk',\n    statLastUpdatedLabel: 'Sist oppdatert',\n    statCategoriesLabel: 'Kategorier',\n    politicalIntelligenceLinkDescription:\n      'Indeks over hver metodologi, mal og daglige analysekjøring — det gjennomsiktige håndverket bak hver artikkel.',\n  },\n  fi: {\n    intro:\n      'Täydellinen yleiskatsaus kaikkiin EU Parliament Monitor -sivuston sivuihin — etusivuihin, uutisartikkeleihin ja tekniseen dokumentaatioon. Käytä tätä sivua löytääksesi sisältöä ja siirtyäksesi suoraan mihin tahansa artikkeliin kaikilla 14 kielellä.',\n    heroSubtitle: 'Täydellinen sivustonavigaatio',\n    home: 'Etusivu',\n    breadcrumbCurrent: 'Sivukartta',\n    breadcrumbLabel: 'Navigointipolku',\n    pagesDescription:\n      'Ensisijaiset aloitussivut jokaisella tuetulla kielellä — paras lähtökohta kullekin yleisölle.',\n    docsDescription:\n      'Tekninen dokumentaatio, mukaan lukien API-viite, koodikattavuus ja testitulokset.',\n    newsDescription:\n      'Kaikki julkaistut uutisartikkelit tällä kielellä, uusimmat ensin ja ryhmitellyt toimituksellisen muodon mukaan.',\n    statArticlesLabel: 'Artikkelit',\n    statLanguagesLabel: 'Kielet',\n    statLastUpdatedLabel: 'Viimeksi päivitetty',\n    statCategoriesLabel: 'Luokat',\n    politicalIntelligenceLinkDescription:\n      'Hakemisto jokaisesta metodologiasta, pohjasta ja päivittäisestä analyysiajoista — läpinäkyvä käsityötaito jokaisen artikkelin takana.',\n  },\n  de: {\n    intro:\n      'Vollständige Übersicht über alle Seiten von EU Parliament Monitor — Startseiten, Nachrichtenartikel und technische Dokumentation. Nutzen Sie diese Seite, um Inhalte zu entdecken und direkt zu jedem Artikel in allen 14 Sprachen zu navigieren.',\n    heroSubtitle: 'Vollständige Seitennavigation',\n    home: 'Startseite',\n    breadcrumbCurrent: 'Seitenübersicht',\n    breadcrumbLabel: 'Breadcrumb',\n    pagesDescription:\n      'Primäre Startseiten in jeder unterstützten Sprache — der beste Ausgangspunkt für jede Zielgruppe.',\n    docsDescription:\n      'Technische Dokumentation einschließlich API-Referenz, Codeabdeckung und Testergebnissen.',\n    newsDescription:\n      'Alle veröffentlichten Nachrichtenartikel in dieser Sprache, nach Datum absteigend sortiert und nach redaktionellem Format gruppiert.',\n    statArticlesLabel: 'Artikel',\n    statLanguagesLabel: 'Sprachen',\n    statLastUpdatedLabel: 'Zuletzt aktualisiert',\n    statCategoriesLabel: 'Kategorien',\n    politicalIntelligenceLinkDescription:\n      'Index jeder Methodologie, Vorlage und täglichen Analysedurchführung — die transparente Handwerkskunst hinter jedem Artikel.',\n  },\n  fr: {\n    intro:\n      'Vue d\\u2019ensemble complète de toutes les pages d\\u2019EU Parliament Monitor — pages d\\u2019accueil, articles d\\u2019actualité et documentation technique. Utilisez cette page pour découvrir du contenu et naviguer directement vers n\\u2019importe quel article dans les 14 langues.',\n    heroSubtitle: 'Navigation complète du site',\n    home: 'Accueil',\n    breadcrumbCurrent: 'Plan du site',\n    breadcrumbLabel: 'Fil d\\u2019Ariane',\n    pagesDescription:\n      'Pages d\\u2019accueil principales dans chaque langue prise en charge — le meilleur point de départ pour chaque audience.',\n    docsDescription:\n      'Documentation technique comprenant la référence API, la couverture de code et les résultats des tests.',\n    newsDescription:\n      'Tous les articles d\\u2019actualité publiés dans cette langue, triés du plus récent au plus ancien et groupés par format éditorial.',\n    statArticlesLabel: 'Articles',\n    statLanguagesLabel: 'Langues',\n    statLastUpdatedLabel: 'Dernière mise à jour',\n    statCategoriesLabel: 'Catégories',\n    politicalIntelligenceLinkDescription:\n      \"Index de chaque méthodologie, modèle et exécution d'analyse quotidienne — le savoir-faire transparent derrière chaque article.\",\n  },\n  es: {\n    intro:\n      'Vista general completa de todas las páginas de EU Parliament Monitor — páginas principales, artículos de noticias y documentación técnica. Usa esta página para descubrir contenido y navegar directamente a cualquier artículo en los 14 idiomas.',\n    heroSubtitle: 'Navegación completa del sitio',\n    home: 'Inicio',\n    breadcrumbCurrent: 'Mapa del sitio',\n    breadcrumbLabel: 'Ruta de navegación',\n    pagesDescription:\n      'Páginas principales en cada idioma soportado — el mejor punto de partida para cada audiencia.',\n    docsDescription:\n      'Documentación técnica, incluyendo referencia de API, cobertura de código y resultados de pruebas.',\n    newsDescription:\n      'Todos los artículos de noticias publicados en este idioma, ordenados del más reciente al más antiguo y agrupados por formato editorial.',\n    statArticlesLabel: 'Artículos',\n    statLanguagesLabel: 'Idiomas',\n    statLastUpdatedLabel: 'Última actualización',\n    statCategoriesLabel: 'Categorías',\n    politicalIntelligenceLinkDescription:\n      'Índice de cada metodología, plantilla y ejecución de análisis diario — el oficio transparente detrás de cada artículo.',\n  },\n  nl: {\n    intro:\n      'Volledig overzicht van elke pagina op EU Parliament Monitor — landingspagina\\u2019s, nieuwsartikelen en technische documentatie. Gebruik deze pagina om inhoud te ontdekken en direct naar elk artikel in alle 14 talen te navigeren.',\n    heroSubtitle: 'Volledige site-navigatie',\n    home: 'Home',\n    breadcrumbCurrent: 'Sitemap',\n    breadcrumbLabel: 'Broodkruimelpad',\n    pagesDescription:\n      'Primaire landingspagina\\u2019s in elke ondersteunde taal — het beste vertrekpunt voor elk publiek.',\n    docsDescription:\n      'Technische documentatie inclusief API-referentie, code-dekking en testresultaten.',\n    newsDescription:\n      'Alle gepubliceerde nieuwsartikelen in deze taal, nieuwste bovenaan en gegroepeerd op redactioneel formaat.',\n    statArticlesLabel: 'Artikelen',\n    statLanguagesLabel: 'Talen',\n    statLastUpdatedLabel: 'Laatst bijgewerkt',\n    statCategoriesLabel: 'Categorieën',\n    politicalIntelligenceLinkDescription:\n      'Index van elke methodologie, sjabloon en dagelijkse analyse-uitvoering — het transparante vakmanschap achter elk artikel.',\n  },\n  ar: {\n    intro:\n      'نظرة عامة كاملة على كل صفحة في EU Parliament Monitor — الصفحات الرئيسية والمقالات الإخبارية والوثائق التقنية. استخدم هذه الصفحة لاكتشاف المحتوى والانتقال مباشرة إلى أي مقال بجميع اللغات الـ14.',\n    heroSubtitle: 'التنقل الكامل في الموقع',\n    home: 'الرئيسية',\n    breadcrumbCurrent: 'خريطة الموقع',\n    breadcrumbLabel: 'مسار التنقل',\n    pagesDescription: 'الصفحات الرئيسية الأساسية بكل لغة مدعومة — أفضل نقطة انطلاق لكل جمهور.',\n    docsDescription: 'وثائق تقنية تشمل مرجع واجهة البرمجة وتغطية الكود ونتائج الاختبارات.',\n    newsDescription:\n      'جميع المقالات الإخبارية المنشورة بهذه اللغة، مرتبة من الأحدث إلى الأقدم ومصنفة حسب الصيغة التحريرية.',\n    statArticlesLabel: 'المقالات',\n    statLanguagesLabel: 'اللغات',\n    statLastUpdatedLabel: 'آخر تحديث',\n    statCategoriesLabel: 'الفئات',\n    politicalIntelligenceLinkDescription:\n      'فهرس لكل منهجية وقالب وتشغيل تحليل يومي — الحرفة الشفافة وراء كل مقال.',\n  },\n  he: {\n    intro:\n      'סקירה מלאה של כל עמוד ב-EU Parliament Monitor — עמודי בית, מאמרי חדשות ותיעוד טכני. השתמשו בעמוד זה כדי לגלות תוכן ולנווט ישירות לכל מאמר בכל 14 השפות.',\n    heroSubtitle: 'ניווט מלא באתר',\n    home: 'בית',\n    breadcrumbCurrent: 'מפת אתר',\n    breadcrumbLabel: 'נתיב ניווט',\n    pagesDescription: 'עמודי נחיתה ראשיים בכל שפה נתמכת — נקודת ההתחלה הטובה ביותר לכל קהל.',\n    docsDescription: 'תיעוד טכני כולל מקור API, כיסוי קוד ותוצאות בדיקות.',\n    newsDescription:\n      'כל מאמרי החדשות שפורסמו בשפה זו, ממוינים מהחדש לישן ומקובצים לפי פורמט מערכת.',\n    statArticlesLabel: 'מאמרים',\n    statLanguagesLabel: 'שפות',\n    statLastUpdatedLabel: 'עודכן לאחרונה',\n    statCategoriesLabel: 'קטגוריות',\n    politicalIntelligenceLinkDescription:\n      'אינדקס של כל מתודולוגיה, תבנית וריצת ניתוח יומית — המלאכה השקופה שמאחורי כל מאמר.',\n  },\n  ja: {\n    intro:\n      'EU Parliament Monitor の全ページの完全な一覧です — トップページ、ニュース記事、技術ドキュメント。このページを使って、14 言語すべての任意の記事を発見・直接閲覧できます。',\n    heroSubtitle: 'サイト全体のナビゲーション',\n    home: 'ホーム',\n    breadcrumbCurrent: 'サイトマップ',\n    breadcrumbLabel: 'パンくずリスト',\n    pagesDescription: '各対応言語のメインランディングページ — 各読者に最適な入り口。',\n    docsDescription: 'API リファレンス、コードカバレッジ、テスト結果を含む技術ドキュメント。',\n    newsDescription:\n      'この言語で公開された全ニュース記事を、新しい順に掲載し編集フォーマット別にグループ化しています。',\n    statArticlesLabel: '記事',\n    statLanguagesLabel: '言語',\n    statLastUpdatedLabel: '最終更新',\n    statCategoriesLabel: 'カテゴリ',\n    politicalIntelligenceLinkDescription:\n      'すべての方法論、テンプレート、日次分析実行のインデックス — 各記事の背後にある透明な手法。',\n  },\n  ko: {\n    intro:\n      'EU Parliament Monitor의 모든 페이지 전체 개요 — 홈 페이지, 뉴스 기사 및 기술 문서를 포함합니다. 이 페이지를 통해 14개 언어 전체의 어떤 기사든 직접 찾아 이동할 수 있습니다.',\n    heroSubtitle: '전체 사이트 내비게이션',\n    home: '홈',\n    breadcrumbCurrent: '사이트맵',\n    breadcrumbLabel: '이동 경로',\n    pagesDescription: '지원되는 각 언어의 주요 랜딩 페이지 — 각 독자를 위한 최적의 시작점입니다.',\n    docsDescription: 'API 레퍼런스, 코드 커버리지, 테스트 결과를 포함한 기술 문서입니다.',\n    newsDescription: '이 언어로 게시된 모든 뉴스 기사를 최신순으로 편집 형식별로 정리했습니다.',\n    statArticlesLabel: '기사',\n    statLanguagesLabel: '언어',\n    statLastUpdatedLabel: '마지막 업데이트',\n    statCategoriesLabel: '카테고리',\n    politicalIntelligenceLinkDescription:\n      '모든 방법론, 템플릿 및 일일 분석 실행의 색인 — 각 기사 뒤에 있는 투명한 기술.',\n  },\n  zh: {\n    intro:\n      '欧洲议会监测(EU Parliament Monitor)所有页面的完整概览 — 包括首页、新闻文章和技术文档。通过此页面可以发现内容并直接访问 14 种语言的任何文章。',\n    heroSubtitle: '完整站点导航',\n    home: '首页',\n    breadcrumbCurrent: '网站地图',\n    breadcrumbLabel: '面包屑导航',\n    pagesDescription: '每种受支持语言的主要落地页 — 每个受众的最佳起点。',\n    docsDescription: '技术文档,包括 API 参考、代码覆盖率和测试结果。',\n    newsDescription: '该语言发布的所有新闻文章,按最新优先排序,并按编辑格式分组。',\n    statArticlesLabel: '文章',\n    statLanguagesLabel: '语言',\n    statLastUpdatedLabel: '最近更新',\n    statCategoriesLabel: '分类',\n    politicalIntelligenceLinkDescription:\n      '所有方法论、模板和每日分析运行的索引 — 每篇文章背后透明的工艺。',\n  },\n};\n\n/**\n * Ordered list of article categories used for the News Articles section.\n * Matches the hero badge ordering used elsewhere in the site.\n */\nexport const CATEGORY_ORDER: readonly ArticleCategory[] = [\n  ArticleCategory.BREAKING_NEWS,\n  ArticleCategory.WEEK_AHEAD,\n  ArticleCategory.WEEK_IN_REVIEW,\n  ArticleCategory.MONTH_AHEAD,\n  ArticleCategory.MONTH_IN_REVIEW,\n  ArticleCategory.YEAR_AHEAD,\n  ArticleCategory.YEAR_IN_REVIEW,\n  ArticleCategory.MOTIONS,\n  ArticleCategory.PROPOSITIONS,\n  ArticleCategory.COMMITTEE_REPORTS,\n  ArticleCategory.DEEP_ANALYSIS,\n] as const;\n\n/**\n * Get localized sitemap copy (hero, breadcrumb, section intros).\n *\n * @param lang - Language code\n * @returns Localized copy object, falling back to English when missing\n */\nexport function getSitemapCopy(lang: string): SitemapCopy {\n  return SITEMAP_COPY[lang] ?? (SITEMAP_COPY['en'] as SitemapCopy);\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/sitemap/html.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":149,"column":24,"endLine":149,"endColumn":44},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":155,"column":21,"endLine":155,"endColumn":43},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":160,"column":23,"endLine":160,"endColumn":40},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":224,"column":27,"endLine":224,"endColumn":47}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Generators/Sitemap/Html\n * @description Generates the per-language `sitemap_<lang>.html` pages —\n * the human-friendly index of every news article and documentation\n * page, with category grouping, hreflang alternates, breadcrumb,\n * structured data, and the 14-language language switcher.\n *\n * Lifted out of the monolithic `sitemap.ts` so the HTML renderer can be\n * unit-tested in isolation, so the bounded context \"sitemap HTML\" is\n * clear, and so the lookup tables in `copy.ts` can be reused by any\n * future renderer (Atom-feed metadata, OG-card builder, etc.) without\n * having to import `sitemap.ts` and pull in the entire CLI surface.\n *\n * Output is byte-identical to the legacy in-line implementation that\n * lived in `sitemap.ts` between Apr-2026 and the bounded-context\n * refactor — verified by the regression test in\n * `test/unit/sitemap-byte-equality.test.js` (compares against the\n * golden snapshots taken from `npm run prebuild`).\n */\n\nimport { BASE_URL, THEME_TOGGLE_SCRIPT } from '../../constants/config.js';\nimport {\n  ALL_LANGUAGES,\n  LANGUAGE_NAMES,\n  LANGUAGE_FLAGS,\n  PAGE_TITLES,\n  PAGE_DESCRIPTIONS,\n  SKIP_LINK_TEXTS,\n  getLocalizedString,\n  getTextDirection,\n} from '../../constants/languages.js';\nimport { escapeHTML } from '../../utils/file-utils.js';\nimport { detectCategory } from '../../utils/article-category.js';\nimport {\n  ARTICLE_TYPE_LABELS,\n  FOOTER_POLITICAL_INTELLIGENCE_LABELS,\n} from '../../constants/language-ui.js';\nimport type { ArticleCategory, LanguageCode } from '../../types/index.js';\nimport {\n  buildSiteFooter,\n  buildSiteHeader,\n  buildPageBanner,\n} from '../../templates/section-builders.js';\nimport { getPoliticalIntelligenceFilename } from '../political-intelligence.js';\nimport {\n  SITEMAP_TITLES,\n  SITEMAP_SECTIONS,\n  DOCS_LABELS,\n  CATEGORY_ORDER,\n  DEFAULT_SITEMAP_TITLE,\n  getSitemapCopy,\n} from './copy.js';\n\n/**\n * Article info extracted for sitemap HTML display.\n *\n * `slug` is the article slug excluding the `YYYY-MM-DD-` prefix and the\n * `_<lang>` suffix — used only for editorial-category detection. When\n * absent, `filename` is used as the fallback signal.\n */\nexport interface SitemapArticleInfo {\n  /** Filename within the news/ directory (e.g. `2026-04-27-foo.en.html`) */\n  readonly filename: string;\n  /** ISO date (`YYYY-MM-DD`) parsed from the filename */\n  readonly date: string;\n  /** Article title (already-decoded plain text, NOT yet HTML-escaped) */\n  readonly title: string;\n  /** Article description (already-decoded plain text, NOT yet HTML-escaped) */\n  readonly description: string;\n  /** Original slug (excluding date and language suffix), used for category detection */\n  readonly slug?: string;\n}\n\n/**\n * Get the sitemap HTML filename for a given language code.\n *\n * @param lang - Language code (e.g. `en`, `sv`, `de`)\n * @returns `sitemap.html` for English, `sitemap_<lang>.html` for everything else\n */\nexport function getSitemapFilename(lang: string): string {\n  return lang === 'en' ? 'sitemap.html' : `sitemap_${lang}.html`;\n}\n\n/**\n * Get the index filename for a given language code. Mirrors the rule\n * used by `getIndexFilename()` in `news-indexes.ts`.\n *\n * @param lang - Language code\n * @returns `index.html` for English, `index-<lang>.html` for everything else\n */\nexport function getIndexFilename(lang: string): string {\n  return lang === 'en' ? 'index.html' : `index-${lang}.html`;\n}\n\n/**\n * Build the language switcher nav HTML for the sitemap pages.\n *\n * Each link points at the sibling `sitemap_<lang>.html`; the active\n * language gets `aria-current=\"page\"` and the `active` class so screen\n * readers and CSS can flag it.\n *\n * @param currentLang - Active language code\n * @returns HTML fragment to be embedded inside `<nav class=\"language-switcher\">`\n */\nfunction buildSitemapLangSwitcher(currentLang: string): string {\n  return ALL_LANGUAGES.map((code) => {\n    const flag = getLocalizedString(LANGUAGE_FLAGS, code);\n    const name = getLocalizedString(LANGUAGE_NAMES, code);\n    const active = code === currentLang ? ' active' : '';\n    const ariaCurrent = code === currentLang ? ' aria-current=\"page\"' : '';\n    const href = getSitemapFilename(code);\n    return `<a href=\"${href}\" class=\"lang-link${active}\" hreflang=\"${code}\" lang=\"${code}\" title=\"${escapeHTML(name)}\" aria-label=\"${escapeHTML(name)}\"${ariaCurrent}>${flag} ${code.toUpperCase()}</a>`;\n  }).join('\\n        ');\n}\n\n/**\n * Generate a sitemap HTML page for a specific language.\n *\n * Lists all articles for that language with titles and descriptions,\n * grouped by editorial category in {@link CATEGORY_ORDER}, plus a\n * high-level documentation section (only when `hasDocsDir` is true) and\n * a Pages section with one entry per supported language.\n *\n * The output document includes:\n * - `<head>` `<link rel=\"alternate\">` hreflang block covering every\n *   supported language plus `x-default` → English\n * - JSON-LD `CollectionPage` structured data (with `<` escaped as\n *   `\\u003c` to avoid breaking out of the `<script>` element)\n * - Skip link, header brand, theme toggle, language switcher\n * - Hero section with localized stats (article count, language count,\n *   category count, last-updated date)\n * - Breadcrumb nav\n * - Pages / Documentation / News sections\n * - Shared site footer via {@link buildSiteFooter}\n *\n * @param lang - Language code\n * @param articleInfos - Article info (title/description) for this language\n * @param hasDocsDir - Whether the docs/ directory exists (controls the Documentation section)\n * @returns Complete HTML document string\n */\nexport function generateSitemapHTML(\n  lang: string,\n  articleInfos: SitemapArticleInfo[],\n  hasDocsDir: boolean = false\n): string {\n  const sitemapTitle = SITEMAP_TITLES[lang] ?? SITEMAP_TITLES['en'] ?? DEFAULT_SITEMAP_TITLE;\n  const pageTitle = `${getLocalizedString(PAGE_TITLES, lang).split(' - ')[0]} - ${sitemapTitle}`;\n  const description = getLocalizedString(PAGE_DESCRIPTIONS, lang);\n  const skipLinkText = getLocalizedString(SKIP_LINK_TEXTS, lang);\n  const dir = getTextDirection(lang);\n  const today = new Date().toISOString().slice(0, 10);\n  const sections = (SITEMAP_SECTIONS[lang] ?? SITEMAP_SECTIONS['en']) as {\n    news: string;\n    docs: string;\n    pages: string;\n  };\n  const docsLabels = (DOCS_LABELS[lang] ?? DOCS_LABELS['en']) as {\n    api: string;\n    coverage: string;\n    testResults: string;\n    docsHome: string;\n  };\n  const copy = getSitemapCopy(lang);\n  const heroTitle = getLocalizedString(PAGE_TITLES, lang).split(' - ')[0] ?? '';\n  const typeLabels = getLocalizedString(ARTICLE_TYPE_LABELS, lang);\n  const canonicalUrl = `${BASE_URL}/${getSitemapFilename(lang)}`;\n  const header = buildSiteHeader({\n    lang: lang as LanguageCode,\n    pathPrefix: '',\n    homeHref: getIndexFilename(lang),\n    siteTitle: heroTitle,\n    languageSwitcherHtml: buildSitemapLangSwitcher(lang),\n  });\n\n  // ─── <head> hreflang alternates for all sitemap language variants ───\n  const hreflangLinks = [\n    ...ALL_LANGUAGES.map(\n      (code) =>\n        `  <link rel=\"alternate\" hreflang=\"${code}\" href=\"${BASE_URL}/${getSitemapFilename(code)}\">`\n    ),\n    `  <link rel=\"alternate\" hreflang=\"x-default\" href=\"${BASE_URL}/sitemap.html\">`,\n  ].join('\\n');\n\n  // ─── Pages section (one per supported language) ─────────────────────\n  const pagesSection = ALL_LANGUAGES.map((code) => {\n    const name = getLocalizedString(LANGUAGE_NAMES, code);\n    const flag = getLocalizedString(LANGUAGE_FLAGS, code);\n    const href = getIndexFilename(code);\n    const pageDesc = getLocalizedString(PAGE_DESCRIPTIONS, code);\n    return `          <li>\n            <a href=\"${href}\" hreflang=\"${code}\">${flag} ${escapeHTML(name)}</a>\n            <span class=\"link-description\">${escapeHTML(pageDesc)}</span>\n          </li>`;\n  }).join('\\n');\n\n  // ─── News articles grouped by editorial category ────────────────────\n  const articlesByCategory = new Map<ArticleCategory, SitemapArticleInfo[]>();\n  for (const article of articleInfos) {\n    const category = detectCategory(article.slug ?? article.filename);\n    let bucket = articlesByCategory.get(category);\n    if (!bucket) {\n      bucket = [];\n      articlesByCategory.set(category, bucket);\n    }\n    bucket.push(article);\n  }\n  // Render in the canonical category order, then any remaining categories\n  const orderedCategories: ArticleCategory[] = [\n    ...CATEGORY_ORDER.filter((c) => articlesByCategory.has(c)),\n    ...[...articlesByCategory.keys()].filter((c) => !CATEGORY_ORDER.includes(c)),\n  ];\n\n  const articlesSection =\n    articleInfos.length === 0\n      ? ''\n      : orderedCategories\n          .map((category) => {\n            const bucket = articlesByCategory.get(category) ?? [];\n            // Newest first within each category\n            bucket.sort((a, b) => b.date.localeCompare(a.date));\n            const label = typeLabels[category] ?? category;\n            const items = bucket\n              .map(\n                (a) =>\n                  `            <li>\n              <a href=\"news/${escapeHTML(a.filename)}\">${escapeHTML(a.title)}</a>\n              <span class=\"sitemap-date\">${escapeHTML(a.date)}</span>${a.description ? `\\n              <p class=\"sitemap-desc\">${escapeHTML(a.description)}</p>` : ''}\n            </li>`\n              )\n              .join('\\n');\n            return `        <section class=\"sitemap-category\" aria-labelledby=\"cat-${category}\">\n          <h3 id=\"cat-${category}\" class=\"sitemap-category__heading\">${escapeHTML(label)} <span class=\"sitemap-category__count\" aria-label=\"${bucket.length} ${escapeHTML(copy.statArticlesLabel)}\">${bucket.length}</span></h3>\n          <ul class=\"sitemap-list\">\n${items}\n          </ul>\n        </section>`;\n          })\n          .join('\\n');\n\n  // ─── Documentation section (high-level links) ───────────────────────\n  const docsSection = hasDocsDir\n    ? `\n      <section class=\"sitemap-section\">\n        <h2><span aria-hidden=\"true\">📚</span> ${escapeHTML(sections.docs)}</h2>\n        <p class=\"section-description\">${escapeHTML(copy.docsDescription)}</p>\n        <ul class=\"sitemap-list\">\n          <li><a href=\"docs/\">${escapeHTML(docsLabels.docsHome)}</a></li>\n          <li><a href=\"docs/api/\">${escapeHTML(docsLabels.api)}</a></li>\n          <li><a href=\"docs/coverage/index.html\">${escapeHTML(docsLabels.coverage)}</a></li>\n          <li><a href=\"docs/test-results/index.html\">${escapeHTML(docsLabels.testResults)}</a></li>\n        </ul>\n      </section>`\n    : '';\n\n  // ─── JSON-LD CollectionPage structured data for SEO ─────────────────\n  const jsonLd = {\n    '@context': 'https://schema.org',\n    '@type': 'CollectionPage',\n    name: sitemapTitle,\n    url: canonicalUrl,\n    description: copy.intro,\n    inLanguage: lang,\n    isPartOf: {\n      '@type': 'WebSite',\n      name: 'EU Parliament Monitor',\n      url: BASE_URL,\n    },\n    breadcrumb: {\n      '@type': 'BreadcrumbList',\n      itemListElement: [\n        {\n          '@type': 'ListItem',\n          position: 1,\n          name: copy.home,\n          item: `${BASE_URL}/${getIndexFilename(lang)}`,\n        },\n        {\n          '@type': 'ListItem',\n          position: 2,\n          name: copy.breadcrumbCurrent,\n          item: canonicalUrl,\n        },\n      ],\n    },\n    mainEntity: {\n      '@type': 'ItemList',\n      numberOfItems: articleInfos.length,\n      name: sections.news,\n    },\n  };\n  // Safely embed JSON-LD: escape the `<` that could start `</script>` sequences\n  const jsonLdString = JSON.stringify(jsonLd).replace(/</g, '\\\\u003c');\n\n  return `<!DOCTYPE html>\n<html lang=\"${lang}\" dir=\"${dir}\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <meta http-equiv=\"X-Content-Type-Options\" content=\"nosniff\">\n  <meta name=\"referrer\" content=\"no-referrer\">\n  <title>${escapeHTML(pageTitle)}</title>\n  <meta name=\"description\" content=\"${escapeHTML(description)}\">\n  <link rel=\"canonical\" href=\"${canonicalUrl}\">\n${hreflangLinks}\n  <meta property=\"og:type\" content=\"website\">\n  <meta property=\"og:title\" content=\"${escapeHTML(sitemapTitle)}\">\n  <meta property=\"og:description\" content=\"${escapeHTML(description)}\">\n  <meta property=\"og:url\" content=\"${canonicalUrl}\">\n  <meta property=\"og:site_name\" content=\"EU Parliament Monitor\">\n  <meta property=\"og:locale\" content=\"${lang}\">\n  <meta property=\"og:image\" content=\"https://hack23.github.io/euparliamentmonitor/images/og-image.jpg\">\n  <meta property=\"og:image:width\" content=\"1200\">\n  <meta property=\"og:image:height\" content=\"630\">\n  <!-- Favicons -->\n  <link rel=\"icon\" type=\"image/x-icon\" href=\"favicon.ico\">\n  <link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"images/favicon-32x32.png\">\n  <link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"images/favicon-16x16.png\">\n  <link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"images/apple-touch-icon.png\">\n  <link rel=\"manifest\" href=\"site.webmanifest\">\n  <meta name=\"theme-color\" content=\"#003399\">\n  <link rel=\"stylesheet\" href=\"styles.css\">\n  <script type=\"application/ld+json\">${jsonLdString}</script>\n</head>\n<body>\n  <a href=\"#main\" class=\"skip-link\">${escapeHTML(skipLinkText)}</a>\n\n  ${header}\n\n  ${buildPageBanner('')}\n\n  <main id=\"main\" class=\"site-main\">\n    <section class=\"sitemap-hero\" aria-labelledby=\"sitemap-heading\">\n      <h1 id=\"sitemap-heading\">🗺️ ${escapeHTML(sitemapTitle)}</h1>\n      <p class=\"sitemap-hero__subtitle\">${escapeHTML(copy.heroSubtitle)}</p>\n      <p class=\"sitemap-hero__intro\">${escapeHTML(copy.intro)}</p>\n      <dl class=\"sitemap-stats\" aria-label=\"${escapeHTML(sitemapTitle)}\">\n        <div class=\"sitemap-stats__item\">\n          <dt>${escapeHTML(copy.statArticlesLabel)}</dt>\n          <dd>${articleInfos.length}</dd>\n        </div>\n        <div class=\"sitemap-stats__item\">\n          <dt>${escapeHTML(copy.statLanguagesLabel)}</dt>\n          <dd>${ALL_LANGUAGES.length}</dd>\n        </div>\n        <div class=\"sitemap-stats__item\">\n          <dt>${escapeHTML(copy.statCategoriesLabel)}</dt>\n          <dd>${orderedCategories.length}</dd>\n        </div>\n        <div class=\"sitemap-stats__item\">\n          <dt>${escapeHTML(copy.statLastUpdatedLabel)}</dt>\n          <dd><time datetime=\"${today}\">${today}</time></dd>\n        </div>\n      </dl>\n    </section>\n\n    <nav class=\"breadcrumb\" aria-label=\"${escapeHTML(copy.breadcrumbLabel)}\">\n      <ol>\n        <li><a href=\"${getIndexFilename(lang)}\">${escapeHTML(copy.home)}</a></li>\n        <li aria-current=\"page\">${escapeHTML(copy.breadcrumbCurrent)}</li>\n      </ol>\n    </nav>\n\n    <div class=\"sitemap-grid\">\n      <section class=\"sitemap-section\">\n        <h2><span aria-hidden=\"true\">🏠</span> ${escapeHTML(sections.pages)}</h2>\n        <p class=\"section-description\">${escapeHTML(copy.pagesDescription)}</p>\n        <ul class=\"sitemap-list\">\n${pagesSection}\n          <li>\n            <a href=\"${getPoliticalIntelligenceFilename(lang)}\" hreflang=\"${lang}\">🧭 ${escapeHTML(getLocalizedString(FOOTER_POLITICAL_INTELLIGENCE_LABELS, lang))}</a>\n            <span class=\"link-description\">${escapeHTML(copy.politicalIntelligenceLinkDescription)}</span>\n          </li>\n        </ul>\n      </section>\n${docsSection}\n      <section class=\"sitemap-section sitemap-section--news\">\n        <h2><span aria-hidden=\"true\">📰</span> ${escapeHTML(sections.news)}</h2>\n        <p class=\"section-description\">${escapeHTML(copy.newsDescription)}</p>\n${articlesSection}\n      </section>\n    </div>\n  </main>\n\n  ${buildSiteFooter({ lang: lang as LanguageCode, pathPrefix: '', articleCount: articleInfos.length })}${THEME_TOGGLE_SCRIPT}\n</body>\n</html>`;\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/sitemap/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/sitemap/rss.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/sitemap/xml-utils.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/generators/sitemap/xml.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":150,"column":24,"endLine":150,"endColumn":41},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":169,"column":5,"endLine":169,"endColumn":21},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":201,"column":5,"endLine":201,"endColumn":21},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":222,"column":5,"endLine":222,"endColumn":21}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Generators/Sitemap/Xml\n * @description Generates the `sitemap.xml` document with hreflang\n * alternates per Google guidelines. Wraps the index pages, sitemap HTML\n * pages, political-intelligence pages, RSS feed, news articles, and\n * documentation files with appropriate `<changefreq>` / `<priority>`\n * defaults and `xhtml:link rel=\"alternate\"` blocks for multilingual\n * variants.\n *\n * Lifted out of the monolithic `sitemap.ts` so the XML emission can be\n * unit-tested in isolation, so the bounded context \"sitemap XML\" is\n * pure (no HTML chrome dependencies), and so future XML output formats\n * (news-sitemap, video-sitemap) can reuse the same URL builders.\n *\n * Output is byte-identical to the legacy in-line implementation that\n * lived in `sitemap.ts`, verified by the byte-equality regression test.\n */\n\nimport fs from 'fs';\nimport path from 'path';\nimport { BASE_URL, NEWS_DIR, PROJECT_ROOT } from '../../constants/config.js';\nimport { ALL_LANGUAGES } from '../../constants/languages.js';\nimport { getModifiedDate, parseArticleFilename } from '../../utils/file-utils.js';\nimport type { SitemapUrl } from '../../types/index.js';\nimport { getPoliticalIntelligenceFilename } from '../political-intelligence.js';\nimport { escapeXML } from './xml-utils.js';\nimport { getSitemapFilename, getIndexFilename } from './html.js';\n\n/**\n * Extended sitemap URL with optional `xhtml:link` alternate-language\n * entries. Used to emit Google-compliant hreflang blocks inside each\n * `<url>` element so multilingual variants of the same logical page are\n * cross-linked.\n */\nexport interface SitemapUrlWithAlternates extends SitemapUrl {\n  /** Map of hreflang code → absolute URL of the alternate language variant. */\n  alternates?: Record<string, string>;\n}\n\n/** Absolute docs directory under project root */\nconst DOCS_DIR: string = path.join(PROJECT_ROOT, 'docs');\n\n/**\n * Recursively collect all `.html` files under a directory, returning\n * paths relative to the project root with POSIX separators.\n *\n * Returns an empty array silently when `dir` does not exist — callers\n * (notably the sitemap generator) need not pre-check, and a missing\n * docs directory is a normal \"no docs published yet\" state.\n *\n * @param dir - Directory to scan\n * @param rootDir - Project root for computing relative paths\n * @returns Sorted array of relative paths (e.g. `docs/api/index.html`)\n */\nexport function collectDocsHtmlFiles(dir: string, rootDir: string = PROJECT_ROOT): string[] {\n  const results: string[] = [];\n  if (!fs.existsSync(dir)) {\n    return results;\n  }\n  const entries = fs.readdirSync(dir, { withFileTypes: true });\n  for (const entry of entries) {\n    const fullPath = path.join(dir, entry.name);\n    if (entry.isDirectory()) {\n      results.push(...collectDocsHtmlFiles(fullPath, rootDir));\n    } else if (entry.isFile() && entry.name.endsWith('.html')) {\n      results.push(path.relative(rootDir, fullPath).replace(/\\\\/g, '/'));\n    }\n  }\n  return results.sort();\n}\n\n/**\n * Generate sitemap XML including index pages, news articles, sitemap\n * HTML pages, political-intelligence pages, RSS feed, and documentation\n * files from the `docs/` folder.\n *\n * Multilingual pages (the 14 index pages, the 14 sitemap HTML pages,\n * the 14 political-intelligence pages, and any article whose base stem\n * exists in multiple languages) are enriched with `xhtml:link\n * rel=\"alternate\" hreflang=\"…\"` entries so Google and other search\n * engines can discover the full set of language variants.\n *\n * @param articles - List of article filenames (sourced from the `news/` directory)\n * @param docsFiles - Relative paths to docs HTML files (e.g. `docs/api/index.html`)\n * @returns Complete sitemap XML string\n */\nexport function generateSitemap(articles: string[], docsFiles: string[] = []): string {\n  const today = new Date().toISOString().slice(0, 10);\n  const urls: SitemapUrlWithAlternates[] = [\n    ...buildIndexUrls(today),\n    ...buildSitemapHtmlUrls(today),\n    ...buildPoliticalIntelligenceUrls(today),\n    {\n      loc: `${BASE_URL}/rss.xml`,\n      lastmod: today,\n      changefreq: 'daily',\n      priority: '0.5',\n    },\n    ...buildArticleUrls(articles),\n    ...buildDocsUrls(docsFiles, today),\n  ];\n\n  return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!-- SPDX-FileCopyrightText: 2024-2026 Hack23 AB -->\n<!-- SPDX-License-Identifier: Apache-2.0 -->\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n${urls.map(renderSitemapUrl).join('\\n')}\n</urlset>`;\n}\n\n/**\n * Build the absolute URL for a language-specific index page.\n *\n * @param lang - Language code\n * @returns Absolute URL\n */\nfunction indexUrlFor(lang: string): string {\n  return `${BASE_URL}/${getIndexFilename(lang)}`;\n}\n\n/**\n * Build the absolute URL for a language-specific sitemap HTML page.\n *\n * @param lang - Language code\n * @returns Absolute URL\n */\nfunction sitemapUrlFor(lang: string): string {\n  return `${BASE_URL}/${getSitemapFilename(lang)}`;\n}\n\n/**\n * Build hreflang alternates for a set of language→URL entries, adding\n * `x-default` pointing at the English variant (or, when English is\n * absent, the alphabetically-first available language).\n *\n * @param byLang - Mapping of language code to absolute URL\n * @returns Alternates map including `x-default`\n */\nfunction withXDefault(byLang: Record<string, string>): Record<string, string> {\n  const result = { ...byLang };\n  const enFallback = result['en'];\n  if (enFallback) {\n    result['x-default'] = enFallback;\n  } else {\n    const firstLang = Object.keys(result).sort()[0];\n    if (firstLang) {\n      const fallback = result[firstLang];\n      if (fallback) {\n        result['x-default'] = fallback;\n      }\n    }\n  }\n  return result;\n}\n\n/**\n * Build the 14 `<url>` entries for language index pages, each with a\n * shared hreflang-alternates block covering every supported language.\n *\n * @param today - ISO date string for `<lastmod>`\n * @returns Sitemap URL entries\n */\nfunction buildIndexUrls(today: string): SitemapUrlWithAlternates[] {\n  const alternates: Record<string, string> = {};\n  for (const lang of ALL_LANGUAGES) {\n    alternates[lang] = indexUrlFor(lang);\n  }\n  const full = withXDefault(alternates);\n  return ALL_LANGUAGES.map((lang) => ({\n    loc: indexUrlFor(lang),\n    lastmod: today,\n    changefreq: 'daily',\n    priority: '1.0',\n    alternates: full,\n  }));\n}\n\n/**\n * Build the absolute URL for a language-specific political-intelligence HTML page.\n *\n * @param lang - Language code\n * @returns Absolute URL\n */\nfunction politicalIntelligenceUrlFor(lang: string): string {\n  return `${BASE_URL}/${getPoliticalIntelligenceFilename(lang)}`;\n}\n\n/**\n * Build the 14 `<url>` entries for political-intelligence HTML pages\n * with hreflang alternates covering every supported language.\n *\n * @param today - ISO date string for `<lastmod>`\n * @returns Sitemap URL entries\n */\nfunction buildPoliticalIntelligenceUrls(today: string): SitemapUrlWithAlternates[] {\n  const alternates: Record<string, string> = {};\n  for (const lang of ALL_LANGUAGES) {\n    alternates[lang] = politicalIntelligenceUrlFor(lang);\n  }\n  const full = withXDefault(alternates);\n  return ALL_LANGUAGES.map((lang) => ({\n    loc: politicalIntelligenceUrlFor(lang),\n    lastmod: today,\n    changefreq: 'weekly',\n    priority: '0.6',\n    alternates: full,\n  }));\n}\n\n/**\n * Build the 14 `<url>` entries for sitemap HTML pages with hreflang alternates.\n *\n * @param today - ISO date string for `<lastmod>`\n * @returns Sitemap URL entries\n */\nfunction buildSitemapHtmlUrls(today: string): SitemapUrlWithAlternates[] {\n  const alternates: Record<string, string> = {};\n  for (const lang of ALL_LANGUAGES) {\n    alternates[lang] = sitemapUrlFor(lang);\n  }\n  const full = withXDefault(alternates);\n  return ALL_LANGUAGES.map((lang) => ({\n    loc: sitemapUrlFor(lang),\n    lastmod: today,\n    changefreq: 'daily',\n    priority: '0.5',\n    alternates: full,\n  }));\n}\n\n/**\n * Build `<url>` entries for every news article. Multi-language clusters\n * (articles that share the same `YYYY-MM-DD-slug` stem) receive\n * hreflang alternates so search engines can discover every variant.\n *\n * @param articles - Article filenames from the `news/` directory\n * @returns Sitemap URL entries\n */\nfunction buildArticleUrls(articles: string[]): SitemapUrlWithAlternates[] {\n  // Group language variants by stem\n  const byStem = new Map<string, Record<string, string>>();\n  for (const article of articles) {\n    const parsed = parseArticleFilename(article);\n    if (!parsed) continue;\n    const stem = `${parsed.date}-${parsed.slug}`;\n    let bucket = byStem.get(stem);\n    if (!bucket) {\n      bucket = {};\n      byStem.set(stem, bucket);\n    }\n    bucket[parsed.lang] = `${BASE_URL}/news/${article}`;\n  }\n\n  return articles.map((article) => {\n    const filepath = path.join(NEWS_DIR, article);\n    const lastmod = getModifiedDate(filepath);\n    const parsed = parseArticleFilename(article);\n    const stem = parsed ? `${parsed.date}-${parsed.slug}` : null;\n    const bucket = stem ? byStem.get(stem) : undefined;\n    // Only emit alternates when the stem has multiple language variants\n    const hasMultipleLocales = bucket && Object.keys(bucket).length > 1;\n    const alternates = hasMultipleLocales\n      ? withXDefault(bucket as Record<string, string>)\n      : undefined;\n\n    return {\n      loc: `${BASE_URL}/news/${article}`,\n      lastmod,\n      changefreq: 'monthly' as const,\n      priority: '0.8',\n      ...(alternates ? { alternates } : {}),\n    };\n  });\n}\n\n/**\n * Build `<url>` entries for documentation HTML files (no hreflang\n * alternates — docs are single-locale).\n *\n * @param docsFiles - Docs file paths relative to the project root\n * @param today - Fallback ISO date string when `fs.stat` fails\n * @returns Sitemap URL entries\n */\nfunction buildDocsUrls(docsFiles: string[], today: string): SitemapUrlWithAlternates[] {\n  return docsFiles.map((relPath) => {\n    const fullPath = path.join(PROJECT_ROOT, relPath);\n    let lastmod = today;\n    try {\n      lastmod = getModifiedDate(fullPath);\n    } catch {\n      // Use today if file stat fails\n    }\n    return {\n      loc: `${BASE_URL}/${canonicalDocsPath(relPath)}`,\n      lastmod,\n      changefreq: 'weekly',\n      priority: '0.3',\n    };\n  });\n}\n\n/**\n * Convert documentation file paths to their preferred public canonical URL path.\n *\n * @param relPath - Docs file path relative to the project root\n * @returns URL path with canonical directory forms for docs index pages\n */\nfunction canonicalDocsPath(relPath: string): string {\n  const normalized = relPath.replace(/\\\\/g, '/');\n  if (normalized === 'docs/index.html') {\n    return 'docs/';\n  }\n  if (normalized === 'docs/api/index.html') {\n    return 'docs/api/';\n  }\n  return normalized;\n}\n\n/**\n * Render a single `<url>` block, including any `xhtml:link` alternates.\n *\n * @param url - Sitemap URL entry with optional hreflang alternates\n * @returns XML fragment for the `<url>` block\n */\nfunction renderSitemapUrl(url: SitemapUrlWithAlternates): string {\n  const altLinks = url.alternates\n    ? Object.entries(url.alternates)\n        .map(\n          ([hreflang, href]) =>\n            `    <xhtml:link rel=\"alternate\" hreflang=\"${escapeXML(hreflang)}\" href=\"${escapeXML(href)}\"/>`\n        )\n        .join('\\n')\n    : '';\n  return `  <url>\n    <loc>${escapeXML(url.loc)}</loc>\n    <lastmod>${escapeXML(url.lastmod)}</lastmod>\n    <changefreq>${escapeXML(url.changefreq)}</changefreq>\n    <priority>${escapeXML(url.priority)}</priority>${altLinks ? `\\n${altLinks}` : ''}\n  </url>`;\n}\n\n/** Absolute path of the docs/ directory used by the sitemap CLI. */\nexport const SITEMAP_DOCS_DIR: string = DOCS_DIR;\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/ep-mcp-client.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/ep-open-data-client.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/imf-mcp-client.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/mcp-connection.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/mcp-health.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/mcp-retry.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/pending-documents.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":227,"column":20,"endLine":227,"endColumn":42},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":251,"column":3,"endLine":251,"endColumn":25},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":272,"column":15,"endLine":272,"endColumn":37}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module MCP/PendingDocuments\n * @description Persistence sidecar for EP adopted texts that are indexed but\n * not yet available (EP Open Data Portal 5–15-day indexing lag).\n *\n * When Stage B deep-fetch receives `UPSTREAM_404: document indexed but content\n * not yet available` from the MCP server, the document identifier is recorded\n * here with `{ docId, firstObservedAt, lastProbedAt, attempts }` so that\n * subsequent workflow runs can re-probe with exponential back-off instead of\n * treating the item as a permanent retrieval failure.\n *\n * Back-off schedule: initial 24 h, doubling each attempt, capped at 72 h.\n * Documents older than 14 days are escalated (status = ESCALATED) so the\n * wildcards-blackswans family can handle them.\n *\n * @see {@link https://data.europarl.europa.eu/en/developer-corner EP Open Data Portal — Developer Corner}\n */\n\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\n// ─── Types ───────────────────────────────────────────────────────────────────\n\n/** Lifecycle status of a pending document */\nexport type PendingDocumentStatus = 'PENDING' | 'ESCALATED' | 'RESOLVED';\n\n/**\n * Record for a single EP adopted-text identifier that is indexed but whose\n * content has not yet been populated by the EP Open Data Portal.\n */\nexport interface PendingDocument {\n  /** Document identifier (e.g., \"TA-10-2026-0104\") */\n  readonly docId: string;\n  /** ISO timestamp when the CONTENT_PENDING state was first observed */\n  firstObservedAt: string;\n  /** ISO timestamp of the most recent probe attempt */\n  lastProbedAt: string;\n  /** Total number of probe attempts including the initial observation */\n  attempts: number;\n  /** ISO timestamp after which the next probe may be issued */\n  nextProbeAfter: string;\n  /** Current lifecycle status */\n  status: PendingDocumentStatus;\n}\n\n/**\n * Root store format persisted to `data/pending-documents.json`.\n * Documents are keyed by docId for O(1) lookup.\n */\nexport interface PendingDocumentsStore {\n  /** Schema version for forward-compatibility */\n  version: string;\n  /** ISO timestamp of the last write */\n  lastUpdatedAt: string;\n  /** Map keyed by `docId` (e.g., `\"TA-10-2026-0104\"`) to the pending document record — O(1) lookup */\n  documents: Record<string, PendingDocument>;\n}\n\n// ─── Constants ───────────────────────────────────────────────────────────────\n\n/** Schema version written to every store file */\nexport const STORE_VERSION = '1.0';\n\n/** Initial back-off delay: 24 hours in milliseconds */\nexport const INITIAL_BACKOFF_MS = 24 * 60 * 60 * 1000;\n\n/** Maximum back-off delay: 72 hours in milliseconds */\nexport const MAX_BACKOFF_MS = 72 * 60 * 60 * 1000;\n\n/**\n * Maximum tracking age before escalation: 14 days in milliseconds.\n * After this period the document is escalated to the wildcards-blackswans\n * analysis family rather than continued re-probing.\n */\nexport const MAX_AGE_MS = 14 * 24 * 60 * 60 * 1000;\n\n// ─── Pure computation helpers ─────────────────────────────────────────────────\n\n/**\n * Compute the ISO timestamp after which the next probe is due.\n *\n * The delay doubles with each attempt (exponential back-off), capped at\n * {@link MAX_BACKOFF_MS}:\n * - attempt 1 → 24 h\n * - attempt 2 → 48 h\n * - attempt 3+ → 72 h (capped)\n *\n * @param fromTime - ISO timestamp used as the reference point (lastProbedAt)\n * @param attempts - Total probe attempts recorded so far (≥ 1)\n * @returns ISO timestamp after which the next probe should be issued\n */\nexport function computeNextProbeAfter(fromTime: string, attempts: number): string {\n  const backoffMs = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempts - 1), MAX_BACKOFF_MS);\n  return new Date(new Date(fromTime).getTime() + backoffMs).toISOString();\n}\n\n/**\n * Return `true` when a PENDING document is due for a re-probe.\n *\n * @param doc - Pending document record\n * @param now - Reference time (defaults to `new Date()`)\n * @returns `true` if `doc.status` is PENDING and `doc.nextProbeAfter` has passed\n */\nexport function isDueForProbe(doc: PendingDocument, now: Date = new Date()): boolean {\n  if (doc.status !== 'PENDING') return false;\n  return new Date(doc.nextProbeAfter) <= now;\n}\n\n/**\n * Return `true` when a PENDING document has exceeded the maximum tracking age\n * and should be escalated to the wildcards-blackswans family.\n *\n * @param doc - Pending document record\n * @param now - Reference time (defaults to `new Date()`)\n * @returns `true` if `doc.status` is PENDING and `firstObservedAt + MAX_AGE_MS` is in the past\n */\nexport function isExpiredPending(doc: PendingDocument, now: Date = new Date()): boolean {\n  if (doc.status !== 'PENDING') return false;\n  return new Date(doc.firstObservedAt).getTime() + MAX_AGE_MS < now.getTime();\n}\n\n// ─── I/O helpers ─────────────────────────────────────────────────────────────\n\n/**\n * Resolve the default sidecar path: `<cwd>/data/pending-documents.json`.\n * The caller may override this (e.g., for test isolation) via the optional\n * `storePath` parameter accepted by every exported function.\n *\n * @returns Absolute path to the pending-documents sidecar file\n */\nexport function defaultStorePath(): string {\n  return path.resolve(process.cwd(), 'data', 'pending-documents.json');\n}\n\n/**\n * Create an empty store with sensible defaults.\n *\n * @returns A fresh {@link PendingDocumentsStore} with no documents\n */\nfunction emptyStore(): PendingDocumentsStore {\n  return {\n    version: STORE_VERSION,\n    lastUpdatedAt: new Date().toISOString(),\n    documents: {},\n  };\n}\n\n/**\n * Load the pending documents store from disk.\n * Returns an empty store when the file does not exist.\n * Logs a warning and returns an empty store on any other read/parse error\n * so a corrupted sidecar never blocks the workflow.\n *\n * @param storePath - Path override (defaults to `data/pending-documents.json`)\n * @returns The loaded {@link PendingDocumentsStore}, or an empty store on ENOENT/parse error\n */\nexport async function loadPendingDocuments(storePath?: string): Promise<PendingDocumentsStore> {\n  const filePath = storePath ?? defaultStorePath();\n  try {\n    const raw = await fs.readFile(filePath, 'utf-8');\n    const parsed: unknown = JSON.parse(raw);\n    if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n      const obj = parsed as Record<string, unknown>;\n      // Validate required keys; merge defaults so a partially-written file never throws\n      const documents =\n        obj['documents'] && typeof obj['documents'] === 'object' && !Array.isArray(obj['documents'])\n          ? (obj['documents'] as Record<string, PendingDocument>)\n          : {};\n      const version = typeof obj['version'] === 'string' ? obj['version'] : STORE_VERSION;\n      const lastUpdatedAt =\n        typeof obj['lastUpdatedAt'] === 'string' ? obj['lastUpdatedAt'] : new Date().toISOString();\n      return { version, lastUpdatedAt, documents };\n    }\n    return emptyStore();\n  } catch (err) {\n    const code = (err as NodeJS.ErrnoException).code;\n    if (code !== 'ENOENT') {\n      console.warn('⚠️ pending-documents: failed to load store:', (err as Error).message);\n    }\n    return emptyStore();\n  }\n}\n\n/**\n * Persist the store to disk, creating the parent directory as needed.\n * Updates `store.lastUpdatedAt` before writing.\n *\n * @param store - Store object to write\n * @param storePath - Path override\n */\nexport async function savePendingDocuments(\n  store: PendingDocumentsStore,\n  storePath?: string\n): Promise<void> {\n  const filePath = storePath ?? defaultStorePath();\n  await fs.mkdir(path.dirname(filePath), { recursive: true });\n  store.lastUpdatedAt = new Date().toISOString();\n  await fs.writeFile(filePath, JSON.stringify(store, null, 2) + '\\n', 'utf-8');\n}\n\n// ─── Public API ───────────────────────────────────────────────────────────────\n\n/**\n * Record a document as CONTENT_PENDING.\n *\n * **Idempotent**: if the docId is already tracked as PENDING the function\n * increments `attempts`, updates `lastProbedAt`, and recomputes\n * `nextProbeAfter` — `firstObservedAt` is never overwritten.\n * If the docId already has a terminal status (RESOLVED, ESCALATED) it is\n * left unchanged.\n *\n * @param docId - Adopted-text identifier (e.g., \"TA-10-2026-0104\")\n * @param storePath - Path override (for test isolation)\n * @param now - Reference time (defaults to `new Date()`)\n * @returns The updated or newly created {@link PendingDocument}\n */\nexport async function recordPendingDocument(\n  docId: string,\n  storePath?: string,\n  now: Date = new Date()\n): Promise<PendingDocument> {\n  const store = await loadPendingDocuments(storePath);\n  const nowIso = now.toISOString();\n  const existing = store.documents[docId];\n\n  if (existing) {\n    if (existing.status === 'PENDING') {\n      // Update tracking fields; preserve firstObservedAt\n      existing.attempts += 1;\n      existing.lastProbedAt = nowIso;\n      existing.nextProbeAfter = computeNextProbeAfter(nowIso, existing.attempts);\n      await savePendingDocuments(store, storePath);\n      return existing;\n    }\n    // Terminal status — return as-is without write\n    return existing;\n  }\n\n  // New entry\n  const doc: PendingDocument = {\n    docId,\n    firstObservedAt: nowIso,\n    lastProbedAt: nowIso,\n    attempts: 1,\n    nextProbeAfter: computeNextProbeAfter(nowIso, 1),\n    status: 'PENDING',\n  };\n  store.documents[docId] = doc;\n  await savePendingDocuments(store, storePath);\n  return doc;\n}\n\n/**\n * Mark a pending document as RESOLVED (content successfully retrieved on\n * a subsequent probe).\n *\n * No-op when the docId is not in the store.\n *\n * @param docId - Adopted-text identifier\n * @param storePath - Path override\n * @param now - Reference time (defaults to `new Date()`)\n */\nexport async function markDocumentResolved(\n  docId: string,\n  storePath?: string,\n  now: Date = new Date()\n): Promise<void> {\n  const store = await loadPendingDocuments(storePath);\n  const doc = store.documents[docId];\n  if (!doc) return;\n  doc.status = 'RESOLVED';\n  doc.lastProbedAt = now.toISOString();\n  await savePendingDocuments(store, storePath);\n}\n\n/**\n * Return the docIds of PENDING documents whose `nextProbeAfter` has passed.\n *\n * @param storePath - Path override\n * @param now - Reference time (defaults to `new Date()`)\n * @returns Array of docIds due for reprobe (may be empty)\n */\nexport async function getPendingDocumentsForReprobe(\n  storePath?: string,\n  now: Date = new Date()\n): Promise<string[]> {\n  const store = await loadPendingDocuments(storePath);\n  return Object.values(store.documents)\n    .filter((doc) => isDueForProbe(doc, now))\n    .map((doc) => doc.docId);\n}\n\n/**\n * Escalate PENDING documents that have exceeded the 14-day maximum tracking\n * age. Escalated documents are no longer returned by\n * {@link getPendingDocumentsForReprobe} and should be handled by the\n * wildcards-blackswans family instead.\n *\n * @param storePath - Path override\n * @param now - Reference time (defaults to `new Date()`)\n * @returns Array of docIds that were escalated\n */\nexport async function escalateExpiredDocuments(\n  storePath?: string,\n  now: Date = new Date()\n): Promise<string[]> {\n  const store = await loadPendingDocuments(storePath);\n  const escalated: string[] = [];\n  for (const doc of Object.values(store.documents)) {\n    if (isExpiredPending(doc, now)) {\n      doc.status = 'ESCALATED';\n      escalated.push(doc.docId);\n    }\n  }\n  if (escalated.length > 0) {\n    await savePendingDocuments(store, storePath);\n  }\n  return escalated;\n}\n\n/**\n * Return a human-readable summary of the sidecar for Stage B observability\n * logging. Shows counts by status and lists docIds due for reprobe and\n * docIds that have been escalated.\n *\n * @param storePath - Path override\n * @param now - Reference time (defaults to `new Date()`)\n * @returns Human-readable summary string for Stage B observability logging\n */\nexport async function getPendingDocumentsSummary(\n  storePath?: string,\n  now: Date = new Date()\n): Promise<string> {\n  const store = await loadPendingDocuments(storePath);\n  const docs = Object.values(store.documents);\n  if (docs.length === 0) {\n    return 'Pending Documents: 0 tracked';\n  }\n  const pending = docs.filter((d) => d.status === 'PENDING');\n  const resolved = docs.filter((d) => d.status === 'RESOLVED');\n  const escalated = docs.filter((d) => d.status === 'ESCALATED');\n  const due = pending.filter((d) => isDueForProbe(d, now));\n  const lines: string[] = [\n    `Pending Documents: ${pending.length} pending, ${resolved.length} resolved, ${escalated.length} escalated`,\n  ];\n  if (due.length > 0) {\n    lines.push(`  Due for reprobe: ${due.map((d) => d.docId).join(', ')}`);\n  }\n  if (escalated.length > 0) {\n    lines.push(`  Escalated (>14d): ${escalated.map((d) => d.docId).join(', ')}`);\n  }\n  return lines.join('\\n');\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/procedure-seen-cache.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/mcp/wb-mcp-client.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/templates/section-builders.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":291,"column":35,"endLine":291,"endColumn":44},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":292,"column":34,"endLine":292,"endColumn":42}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":2,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Templates/SectionBuilders\n * @description Reusable section builder utilities for article template architecture.\n * Provides quality scoring, table of contents generation, quality badge rendering,\n * timeline sections, comparison tables, and key figures bars.\n */\n\nimport { escapeHTML } from '../utils/file-utils.js';\nimport type { ArticleQualityScore, TOCEntry, LanguageCode } from '../types/index.js';\nimport {\n  ALL_LANGUAGES,\n  LANGUAGE_FLAGS,\n  LANGUAGE_NAMES,\n  getLocalizedString,\n  TOC_ARIA_LABELS,\n  TIMELINE_HEADINGS,\n  COMPARISON_BEFORE_LABELS,\n  COMPARISON_AFTER_LABELS,\n  KEY_FIGURES_HEADINGS,\n  FOOTER_ABOUT_HEADING_LABELS,\n  FOOTER_ABOUT_TEXT_LABELS,\n  FOOTER_QUICK_LINKS_LABELS,\n  FOOTER_BUILT_BY_LABELS,\n  FOOTER_LANGUAGES_LABELS,\n  FOOTER_HOME_LABELS,\n  FOOTER_SITEMAP_LABELS,\n  FOOTER_RSS_LABELS,\n  FOOTER_GITHUB_REPO_LABELS,\n  FOOTER_LICENSE_LABELS,\n  FOOTER_EUROPARL_LABELS,\n  FOOTER_LINKEDIN_LABELS,\n  FOOTER_SECURITY_POLICY_LABELS,\n  FOOTER_CONTACT_LABELS,\n  FOOTER_DISCLAIMER_LABELS,\n  FOOTER_REPORT_ISSUES_LABELS,\n  FOOTER_ARTICLES_AVAILABLE_LABELS,\n  FOOTER_POLITICAL_INTELLIGENCE_LABELS,\n  HEADER_SUBTITLE_LABELS,\n  THEME_TOGGLE_LABELS,\n} from '../constants/languages.js';\nimport { APP_VERSION, createThemeToggleButton } from '../constants/config.js';\nimport { stripScriptBlocks, stripHtmlTags } from '../utils/html-sanitize.js';\n\n// ─── New section builder interfaces ─────────────────────────────────────────\n\n/**\n * A single item in a legislative or procedural timeline.\n */\nexport interface TimelineItem {\n  /** Date label (e.g. \"2026-03-15\" or human-readable) */\n  date: string;\n  /** Short event label */\n  label: string;\n  /** Optional extended description */\n  description?: string | undefined;\n}\n\n/**\n * A numeric highlight figure for a key-figures bar.\n */\nexport interface KeyFigure {\n  /** Descriptive label for the figure */\n  label: string;\n  /** Formatted value string (e.g. \"42\", \"78%\") */\n  value: string;\n  /** Optional unit suffix (e.g. \"votes\", \"days\", \"%\") */\n  unit?: string | undefined;\n  /** Optional longer description for screen readers / tooltips */\n  description?: string | undefined;\n}\n\n/**\n * Count occurrences of a regex pattern in a string.\n *\n * @param content - String to search.\n * @param pattern - Global regex pattern to match.\n * @returns Number of matches found.\n */\nfunction countMatches(content: string, pattern: RegExp): number {\n  const matches = content.match(pattern);\n  return matches !== null ? matches.length : 0;\n}\n\n/**\n * Count elements whose `class` attribute contains a given CSS class token.\n *\n * Extracts every `class=\"…\"` attribute, splits the value into tokens, and\n * checks for an exact match — so `\"dashboard\"` will NOT match nested\n * classes like `\"dashboard-grid\"` or `\"dashboard-panel\"`.\n *\n * @param content - HTML string to search.\n * @param token - Exact CSS class name to look for.\n * @returns Number of elements that have the given class token.\n */\nfunction countClassToken(content: string, token: string): number {\n  let count = 0;\n  for (const m of content.matchAll(/class=\"([^\"]*)\"/g)) {\n    const value = m[1] ?? '';\n    if (value.split(/\\s+/).includes(token)) {\n      count += 1;\n    }\n  }\n  return count;\n}\n\n// stripScriptBlocks is imported from html-sanitize.ts\n\n/**\n * Compute an article quality score by analysing the rendered HTML content.\n *\n * @param content - Full HTML content string of the article body.\n * @returns {@link ArticleQualityScore} with word count, section counts, and overall rating.\n */\nexport function computeArticleQualityScore(content: string): ArticleQualityScore {\n  // Remove script blocks before tag-stripping to avoid inflating word count.\n  // Uses iterative scanning instead of regex to avoid CodeQL js/bad-tag-filter.\n  const noScripts = stripScriptBlocks(content);\n  // Strip HTML tags to get plain text, then count words\n  const plainText = stripHtmlTags(noScripts).replace(/\\s+/g, ' ').trim();\n  const wordCount =\n    plainText.length > 0 ? plainText.split(' ').filter((w) => w.length > 0).length : 0;\n\n  // All further counting uses script-stripped HTML to avoid false positives\n  // from embedded JSON-LD or interactive script blocks.\n  const totalSections = countMatches(noScripts, /<section\\b/g);\n\n  // Count data visualizations using exact class-token matching.\n  // countClassToken splits the class attribute value into tokens, so nested\n  // classes like \"dashboard-grid\" or \"dashboard-panel\" are NOT counted.\n  const chartCount = countMatches(noScripts, /data-chart-config/g);\n  const dashboardCount = countClassToken(noScripts, 'dashboard');\n  const mindmapCount = countClassToken(noScripts, 'mindmap-section');\n  const swotCount = countClassToken(noScripts, 'swot-analysis');\n  const visualizationCount = chartCount + dashboardCount + mindmapCount + swotCount;\n\n  // Exclude visualization sections from analysis section count\n  const analysisSections = totalSections - dashboardCount - mindmapCount - swotCount;\n\n  // Count EP document links (with a real path, not just the bare homepage).\n  // This excludes the generic footer link `https://www.europarl.europa.eu/`\n  // while counting links to specific EP resources like /doceo/, /plenary/, etc.\n  const evidenceReferences = countMatches(\n    noScripts,\n    /href=\"https:\\/\\/www\\.europarl\\.europa\\.eu\\/\\w[^\"]*\"/g\n  );\n\n  // Determine overall quality score\n  let overallScore: ArticleQualityScore['overallScore'];\n  if (wordCount >= 800 && analysisSections >= 3 && visualizationCount >= 2) {\n    overallScore = 'excellent';\n  } else if (wordCount >= 500 && analysisSections >= 2) {\n    overallScore = 'good';\n  } else if (wordCount >= 200 && analysisSections >= 1) {\n    overallScore = 'adequate';\n  } else {\n    overallScore = 'needs-improvement';\n  }\n\n  return { wordCount, analysisSections, visualizationCount, evidenceReferences, overallScore };\n}\n\n/**\n * Build an HTML table of contents navigation element from a list of entries.\n *\n * @param entries - Ordered list of {@link TOCEntry} items to render.\n * @param lang - Language code used for the localised aria-label.\n * @returns HTML string for the TOC `<nav>` element, or empty string when entries is empty.\n */\nexport function buildTableOfContents(entries: TOCEntry[], lang: LanguageCode): string {\n  if (entries.length === 0) {\n    return '';\n  }\n\n  const ariaLabel = escapeHTML(getLocalizedString(TOC_ARIA_LABELS, lang));\n\n  const items = entries\n    .map((entry) => {\n      const safeLabel = escapeHTML(entry.label);\n      // Strip leading # to prevent href=\"##foo\"\n      const safeId = escapeHTML(entry.id.replace(/^#/, ''));\n      const classAttr = entry.level === 2 ? ' class=\"toc-sub\"' : '';\n      return `<li${classAttr}><a href=\"#${safeId}\">${safeLabel}</a></li>`;\n    })\n    .join('\\n      ');\n\n  return `<nav class=\"article-toc\" aria-label=\"${ariaLabel}\">\n  <ol>\n      ${items}\n  </ol>\n</nav>`;\n}\n\n/**\n * Build an HTML quality score badge element for an article.\n *\n * The badge is `aria-hidden` since it conveys metadata, not primary content.\n * Returns an empty string for articles with a 'needs-improvement' score to avoid\n * surfacing poor-quality signals to readers.\n *\n * @param score - {@link ArticleQualityScore} to render.\n * @returns HTML string for the badge `<div>`, or empty string for needs-improvement.\n */\nexport function buildQualityScoreBadge(score: ArticleQualityScore): string {\n  if (score.overallScore === 'needs-improvement') {\n    return '';\n  }\n\n  const safeScore = escapeHTML(score.overallScore);\n  return `<div class=\"article-quality-score\" data-score=\"${safeScore}\" aria-hidden=\"true\">\n  <span class=\"qs-words\">${score.wordCount}</span>\n  <span class=\"qs-sections\">${score.analysisSections}</span>\n  <span class=\"qs-visuals\">${score.visualizationCount}</span>\n  <span class=\"qs-evidence\">${score.evidenceReferences}</span>\n</div>`;\n}\n\n// ─── New section builders ────────────────────────────────────────────────────\n\n/**\n * Build an HTML timeline section for legislative or procedural events.\n *\n * Renders an ordered list of dated events. Each item includes a date badge\n * and a label. An optional description is included as visible text when\n * provided. Empty items array returns an empty string.\n *\n * @param items - Ordered list of {@link TimelineItem} events to render.\n * @param lang - Language code used for the section heading.\n * @returns HTML string for the timeline `<section>`, or empty string when items is empty.\n */\nexport function buildTimelineSection(\n  items: ReadonlyArray<TimelineItem>,\n  lang: LanguageCode\n): string {\n  if (items.length === 0) return '';\n\n  const heading = escapeHTML(getLocalizedString(TIMELINE_HEADINGS, lang));\n\n  const listItems = items\n    .map((item) => {\n      const safeDate = escapeHTML(item.date);\n      const safeLabel = escapeHTML(item.label);\n      const descPart = item.description\n        ? `<span class=\"timeline-description\">${escapeHTML(item.description)}</span>`\n        : '';\n      return (\n        `<li class=\"timeline-item\">` +\n        `<span class=\"timeline-date\">${safeDate}</span>` +\n        `<span class=\"timeline-label\">${safeLabel}</span>` +\n        descPart +\n        `</li>`\n      );\n    })\n    .join('\\n      ');\n\n  return `<section class=\"timeline-section\" aria-label=\"${heading}\">\n  <h2>${heading}</h2>\n  <ol class=\"timeline-list\" role=\"list\">\n      ${listItems}\n  </ol>\n</section>`;\n}\n\n/**\n * Build an HTML before/after comparison table for legislative changes.\n *\n * Renders a two-column table comparing the state of something before and after\n * a legislative action. When the input arrays have different lengths, the\n * table uses the longer length and renders missing cells as empty strings.\n * Returns an empty string when either array is empty.\n *\n * @param before - Array of \"before\" state descriptions for the first column.\n * @param after - Array of \"after\" state descriptions for the second column.\n * @param lang - Language code used for column headings.\n * @returns HTML string for the comparison `<table>`, or empty string when either array is empty.\n */\nexport function buildComparisonTable(\n  before: ReadonlyArray<string>,\n  after: ReadonlyArray<string>,\n  lang: LanguageCode\n): string {\n  if (before.length === 0 || after.length === 0) return '';\n\n  const beforeLabel = escapeHTML(getLocalizedString(COMPARISON_BEFORE_LABELS, lang));\n  const afterLabel = escapeHTML(getLocalizedString(COMPARISON_AFTER_LABELS, lang));\n  const maxRows = Math.max(before.length, after.length);\n\n  const rows = Array.from({ length: maxRows }, (_, i) => {\n    const beforeCell = escapeHTML(before[i] ?? '');\n    const afterCell = escapeHTML(after[i] ?? '');\n    return (\n      `<tr>` +\n      `<td class=\"comparison-before\">${beforeCell}</td>` +\n      `<td class=\"comparison-after\">${afterCell}</td>` +\n      `</tr>`\n    );\n  }).join('\\n      ');\n\n  return `<div class=\"comparison-table-wrapper\" role=\"region\" aria-label=\"${beforeLabel} / ${afterLabel}\">\n  <table class=\"comparison-table\">\n    <caption class=\"sr-only\">${beforeLabel} / ${afterLabel}</caption>\n    <thead>\n      <tr>\n        <th scope=\"col\">${beforeLabel}</th>\n        <th scope=\"col\">${afterLabel}</th>\n      </tr>\n    </thead>\n    <tbody>\n      ${rows}\n    </tbody>\n  </table>\n</div>`;\n}\n\n/**\n * Build an HTML key figures bar for quick-scan numeric highlights.\n *\n * Renders a horizontal strip of numeric summary cards. Each card shows a\n * value (with optional unit), a label, and an optional screen-reader-only\n * description. Empty figures array returns an empty string.\n *\n * @param figures - Array of {@link KeyFigure} items to render.\n * @param lang - Language code used for the section heading.\n * @returns HTML string for the key figures `<section>`, or empty string when figures is empty.\n */\nexport function buildKeyFiguresBar(figures: ReadonlyArray<KeyFigure>, lang: LanguageCode): string {\n  if (figures.length === 0) return '';\n\n  const heading = escapeHTML(getLocalizedString(KEY_FIGURES_HEADINGS, lang));\n\n  const cards = figures\n    .map((fig) => {\n      const safeLabel = escapeHTML(fig.label);\n      const safeValue = escapeHTML(fig.value);\n      const safeUnit = fig.unit ? escapeHTML(fig.unit) : '';\n      const unitSpan = safeUnit\n        ? ` <span class=\"kf-unit\" aria-hidden=\"true\">${safeUnit}</span>`\n        : '';\n      const descriptionPart = fig.description\n        ? `<span class=\"sr-only\">${escapeHTML(fig.description)}</span>`\n        : '';\n      return (\n        `<div class=\"key-figure-card\" role=\"listitem\" aria-label=\"${safeLabel}: ${safeValue}${safeUnit ? ' ' + safeUnit : ''}\">` +\n        `<span class=\"kf-value\">${safeValue}${unitSpan}</span>` +\n        `<span class=\"kf-label\">${safeLabel}</span>` +\n        descriptionPart +\n        `</div>`\n      );\n    })\n    .join('\\n      ');\n\n  return `<section class=\"key-figures-bar\" aria-label=\"${heading}\">\n  <h2 class=\"sr-only\">${heading}</h2>\n  <div class=\"key-figures-grid\" role=\"list\">\n      ${cards}\n  </div>\n</section>`;\n}\n\n/* ─── Shared site header/footer builders ─────────────────────────── */\n\n/**\n * Options for building the shared site header.\n */\nexport interface SiteHeaderOptions {\n  /** Language code used for localization. */\n  lang: LanguageCode;\n  /**\n   * URL path prefix prepended to relative asset and page links.\n   * Use `''` for root pages and `'../'` for pages inside `news/`.\n   */\n  pathPrefix: string;\n  /** Link target for the brand/logo. */\n  homeHref: string;\n  /** Accessible site title and visible brand title. */\n  siteTitle: string;\n  /** Pre-rendered language switcher links for the current page family. */\n  languageSwitcherHtml: string;\n}\n\n/**\n * Build the shared responsive site header used by every generated page family.\n *\n * @param options - {@link SiteHeaderOptions} controlling language, assets, and language links.\n * @returns HTML string for `<header class=\"site-header\">…</header>`.\n */\nexport function buildSiteHeader(options: SiteHeaderOptions): string {\n  const { lang, pathPrefix, homeHref, siteTitle, languageSwitcherHtml } = options;\n  const headerSubtitle = escapeHTML(getLocalizedString(HEADER_SUBTITLE_LABELS, lang));\n  const themeToggleLabel = escapeHTML(getLocalizedString(THEME_TOGGLE_LABELS, lang));\n  const safeTitle = escapeHTML(siteTitle);\n\n  return `<header class=\"site-header\" role=\"banner\">\n    <div class=\"site-header__inner site-header__inner--stacked\">\n      <a href=\"${escapeHTML(homeHref)}\" class=\"site-header__brand\" aria-label=\"${safeTitle}\">\n        <picture class=\"site-header__logo-picture\">\n          <source srcset=\"${pathPrefix}images/banner.webp\" type=\"image/webp\">\n          <img class=\"site-header__logo site-header__logo--banner\" src=\"${pathPrefix}images/banner.jpg\" alt=\"${safeTitle}\" width=\"240\" height=\"80\" loading=\"eager\">\n        </picture>\n        <span class=\"site-header__brand-text\">\n          <span class=\"site-header__title\">${safeTitle}</span>\n          <span class=\"site-header__subtitle\">${headerSubtitle}</span>\n        </span>\n      </a>\n      <div class=\"site-header__actions\">\n        <a class=\"site-header__cta site-header__cta--sponsor\" href=\"https://github.com/sponsors/Hack23\">💖 Sponsor Hack23</a>\n        <a class=\"site-header__cta\" href=\"https://www.hack23.com\">Become a sponsor</a>\n        <a class=\"site-header__cta site-header__cta--security\" href=\"https://github.com/Hack23/euparliamentmonitor/blob/main/SECURITY.md\">🔐 Commitment to Transparency and Security</a>\n        ${createThemeToggleButton(themeToggleLabel)}\n      </div>\n      <nav class=\"site-header__langs\" role=\"navigation\" aria-label=\"Language selection\">\n        ${languageSwitcherHtml}\n      </nav>\n    </div>\n  </header>`;\n}\n\n/**\n * Build the full-width page banner shown below the sticky site header on every page.\n *\n * The banner image (`banner.webp` / `banner.jpg`) is 1200×400. CSS renders it with\n * `object-fit: cover; object-position: center` so the middle 80% of the image is\n * always visible and the uninteresting top/bottom 10% may be cropped.\n *\n * @param pathPrefix - Asset path prefix: `''` for root pages, `'../'` for `news/` pages.\n * @returns HTML string for the `.page-banner` element.\n */\nexport function buildPageBanner(pathPrefix: string): string {\n  return `<div class=\"page-banner\" role=\"img\" aria-label=\"EU Parliament Monitor\">\n    <picture>\n      <source srcset=\"${pathPrefix}images/banner.webp\" type=\"image/webp\">\n      <img class=\"page-banner__img\" src=\"${pathPrefix}images/banner.jpg\" alt=\"\" aria-hidden=\"true\" width=\"1200\" height=\"400\" loading=\"eager\">\n    </picture>\n  </div>`;\n}\n\n/**\n * Options for building the shared site footer.\n */\nexport interface SiteFooterOptions {\n  /** Language code used for localization. */\n  lang: LanguageCode;\n  /**\n   * URL path prefix prepended to relative links.\n   * Use `''` for root (index) pages and `'../'` for pages inside `news/`.\n   */\n  pathPrefix: string;\n  /**\n   * Optional article count shown in the About section.\n   * When omitted the articles-available line is hidden.\n   */\n  articleCount?: number | undefined;\n}\n\n/**\n * Build the language grid links used inside the footer Languages section.\n *\n * @param currentLang - The currently active language code.\n * @param pathPrefix - Path prefix for index page hrefs ('' or '../').\n * @returns HTML string of anchor elements.\n */\nfunction buildFooterLangGrid(currentLang: LanguageCode, pathPrefix: string): string {\n  return ALL_LANGUAGES.map((code) => {\n    const flag = getLocalizedString(LANGUAGE_FLAGS, code);\n    const safeName = escapeHTML(getLocalizedString(LANGUAGE_NAMES, code));\n    const href = code === 'en' ? `${pathPrefix}index.html` : `${pathPrefix}index-${code}.html`;\n    const active = code === currentLang ? ' class=\"active\"' : '';\n    const current = code === currentLang ? ' aria-current=\"page\"' : '';\n    return `<a href=\"${escapeHTML(href)}\"${active} hreflang=\"${code}\" lang=\"${code}\" title=\"${safeName}\" aria-label=\"${safeName}\"${current}>${flag} ${code.toUpperCase()}</a>`;\n  }).join('\\n            ');\n}\n\n/**\n * Build the shared site footer HTML used by both article pages and index pages.\n *\n * Renders four sections (About, Quick Links, Built by Hack23, Languages) plus a\n * footer-bottom bar with copyright, version, and a localized disclaimer.\n *\n * @param options - {@link SiteFooterOptions} controlling lang, pathPrefix, and articleCount.\n * @returns HTML string for `<footer class=\"site-footer\">…</footer>`.\n */\nexport function buildSiteFooter(options: SiteFooterOptions): string {\n  const { lang, pathPrefix, articleCount } = options;\n  const year = new Date().getFullYear();\n\n  const aboutHeading = escapeHTML(getLocalizedString(FOOTER_ABOUT_HEADING_LABELS, lang));\n  const aboutText = escapeHTML(getLocalizedString(FOOTER_ABOUT_TEXT_LABELS, lang));\n  const quickLinksHeading = escapeHTML(getLocalizedString(FOOTER_QUICK_LINKS_LABELS, lang));\n  const builtByHeading = escapeHTML(getLocalizedString(FOOTER_BUILT_BY_LABELS, lang));\n  const languagesHeading = escapeHTML(getLocalizedString(FOOTER_LANGUAGES_LABELS, lang));\n\n  const homeLabel = escapeHTML(getLocalizedString(FOOTER_HOME_LABELS, lang));\n  const sitemapLabel = escapeHTML(getLocalizedString(FOOTER_SITEMAP_LABELS, lang));\n  const rssLabel = escapeHTML(getLocalizedString(FOOTER_RSS_LABELS, lang));\n  const politicalIntelligenceLabel = escapeHTML(\n    getLocalizedString(FOOTER_POLITICAL_INTELLIGENCE_LABELS, lang)\n  );\n  const githubLabel = escapeHTML(getLocalizedString(FOOTER_GITHUB_REPO_LABELS, lang));\n  const licenseLabel = escapeHTML(getLocalizedString(FOOTER_LICENSE_LABELS, lang));\n  const europarlLabel = escapeHTML(getLocalizedString(FOOTER_EUROPARL_LABELS, lang));\n  const linkedinLabel = escapeHTML(getLocalizedString(FOOTER_LINKEDIN_LABELS, lang));\n  // Security & Privacy Policy label already contains safe &amp; entities — do not double-escape\n  const securityLabel = getLocalizedString(FOOTER_SECURITY_POLICY_LABELS, lang);\n  const contactLabel = escapeHTML(getLocalizedString(FOOTER_CONTACT_LABELS, lang));\n  const disclaimerText = escapeHTML(getLocalizedString(FOOTER_DISCLAIMER_LABELS, lang));\n  const reportIssuesLabel = escapeHTML(getLocalizedString(FOOTER_REPORT_ISSUES_LABELS, lang));\n  const homeHref = `${pathPrefix}${lang === 'en' ? 'index.html' : `index-${lang}.html`}`;\n  const sitemapHref = `${pathPrefix}${lang === 'en' ? 'sitemap.html' : `sitemap_${lang}.html`}`;\n  const politicalIntelligenceHref = `${pathPrefix}${lang === 'en' ? 'political-intelligence.html' : `political-intelligence_${lang}.html`}`;\n  const apiDocsHref = `${pathPrefix}docs/api/`;\n  const analysisDocsHref = `${pathPrefix}docs/`;\n\n  const articlesLine =\n    typeof articleCount === 'number'\n      ? `\\n        <p class=\"footer-stats\">${escapeHTML(getLocalizedString(FOOTER_ARTICLES_AVAILABLE_LABELS, lang).replace('{count}', String(articleCount)))}</p>`\n      : '';\n\n  const langGrid = buildFooterLangGrid(lang, pathPrefix);\n\n  return `<footer class=\"site-footer\" role=\"contentinfo\">\n    <div class=\"footer-content\">\n      <div class=\"footer-section\">\n        <h3>${aboutHeading}</h3>\n        <p>${aboutText}</p>${articlesLine}\n        <p class=\"footer-company-summary\">Swedish cybersecurity consultancy specializing in political transparency and open-source intelligence.</p>\n      </div>\n      <div class=\"footer-section\">\n        <h3>${quickLinksHeading}</h3>\n        <ul>\n          <li><a href=\"${homeHref}\">${homeLabel}</a></li>\n          <li><a href=\"${homeHref}#main\">News</a></li>\n          <li><a href=\"${analysisDocsHref}\">📊 Analysis & Reports</a></li>\n          <li><a href=\"${pathPrefix}docs/index.html\">Dashboard</a></li>\n          <li><a href=\"${politicalIntelligenceHref}\">🧠 ${politicalIntelligenceLabel}</a></li>\n          <li><a href=\"${sitemapHref}\">🗺️ ${sitemapLabel}</a></li>\n          <li><a href=\"${apiDocsHref}\">📚 API Documentation (TypeDoc)</a></li>\n          <li><a href=\"${pathPrefix}rss.xml\">${rssLabel}</a></li>\n          <li><a href=\"https://hack23.com/euparliamentmonitor.html\">EU Parliament Monitor by Hack23</a></li>\n          <li><a href=\"https://hack23.com/euparliamentmonitor-features.html\">EU Parliament Monitor Features</a></li>\n          <li><a href=\"https://hack23.com/cia-features.html\">CIA Platform</a></li>\n          <li><a href=\"https://www.riksdagen.se/\">Sveriges Riksdag</a></li>\n          <li><a href=\"https://github.com/Hack23/euparliamentmonitor\">${githubLabel}</a></li>\n          <li><a href=\"https://github.com/Hack23/euparliamentmonitor/issues\">${reportIssuesLabel}</a></li>\n          <li><a href=\"https://github.com/Hack23/euparliamentmonitor/blob/main/LICENSE\">${licenseLabel}</a></li>\n          <li><a href=\"https://www.europarl.europa.eu/\">${europarlLabel}</a></li>\n        </ul>\n      </div>\n      <div class=\"footer-section\">\n        <h3>${builtByHeading}</h3>\n        <div class=\"footer-badges\" aria-label=\"Project trust badges\">\n          <a href=\"https://www.npmjs.com/package/euparliamentmonitor\" aria-label=\"npm package version\"><img src=\"https://img.shields.io/npm/v/euparliamentmonitor.svg\" alt=\"npm package version\"></a>\n          <a href=\"https://scorecard.dev/viewer/?uri=github.com/Hack23/euparliamentmonitor\" aria-label=\"OpenSSF Scorecard\"><img src=\"https://api.securityscorecards.dev/projects/github.com/Hack23/euparliamentmonitor/badge\" alt=\"OpenSSF Scorecard\"></a>\n          <a href=\"https://www.bestpractices.dev/projects/12068\" aria-label=\"OpenSSF Best Practices\"><img src=\"https://www.bestpractices.dev/projects/12068/badge\" alt=\"OpenSSF Best Practices\"></a>\n          <a href=\"https://github.com/Hack23/euparliamentmonitor/attestations\" aria-label=\"SLSA Level 3\"><img src=\"https://slsa.dev/images/gh-badge-level3.svg\" alt=\"SLSA Level 3\"></a>\n        </div>\n        <ul>\n          <li><a href=\"https://hack23.com\">Hack23.com</a></li>\n          <li><a href=\"https://github.com/sponsors/Hack23\">Sponsor Hack23 on GitHub</a></li>\n          <li><a href=\"https://www.linkedin.com/company/hack23\">${linkedinLabel}</a></li>\n          <li><a href=\"https://github.com/Hack23/ISMS-PUBLIC\">Public ISMS</a></li>\n          <li><a href=\"https://github.com/Hack23/ISMS-PUBLIC/blob/main/Information_Security_Policy.md\">${securityLabel}</a></li>\n          <li><a href=\"https://github.com/Hack23/ISMS-PUBLIC/blob/main/Secure_Development_Policy.md\">Secure Development Policy</a></li>\n          <li><a href=\"https://github.com/Hack23/ISMS-PUBLIC/blob/main/Open_Source_Policy.md\">Open Source Policy</a></li>\n          <li><a href=\"https://github.com/Hack23/ISMS-PUBLIC/blob/main/AI_Policy.md\">AI Policy</a></li>\n          <li><a href=\"https://github.com/Hack23/ISMS-PUBLIC/blob/main/Access_Control_Policy.md\">Access Control Policy</a></li>\n          <li><a href=\"https://github.com/Hack23/ISMS-PUBLIC/blob/main/Cryptography_Policy.md\">Cryptography Policy</a></li>\n          <li><a href=\"https://github.com/Hack23/euparliamentmonitor/blob/main/SECURITY.md\">Security Policy</a></li>\n          <li><a href=\"https://hack23.com/privacy.html\">Privacy Policy</a></li>\n          <li><a href=\"mailto:james@hack23.com\">Contact Us / ${contactLabel}</a></li>\n        </ul>\n      </div>\n      <div class=\"footer-section\">\n        <h3>${languagesHeading}</h3>\n        <div class=\"language-grid\">\n          ${langGrid}\n        </div>\n      </div>\n    </div>\n    <div class=\"footer-bottom\">\n      <p>&copy; 2008-${year} <a href=\"https://hack23.com\">Hack23 AB</a> (Org.nr 5595347807) | Gothenburg, Sweden | v${escapeHTML(APP_VERSION)}</p>\n      <p class=\"footer-disclaimer\"><span aria-hidden=\"true\">⚠️</span> ${disclaimerText} <a href=\"https://github.com/Hack23/euparliamentmonitor/issues\">${reportIssuesLabel}</a>.</p>\n    </div>\n  </footer>`;\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/analysis.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/common.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/generation.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/imf.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/intelligence.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/mcp.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/parliament.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/political-classification.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/political-risk.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/political-threats.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/quality.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/significance.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/stakeholder.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/visualization.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/types/world-bank.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/article-category.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/content-metadata.ts","messages":[{"ruleId":"security/detect-non-literal-regexp","severity":1,"message":"Found non-literal argument to RegExp Constructor","line":164,"column":25,"endLine":164,"endColumn":71}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Utils/ContentMetadata\n * @description Content-based metadata analysis for articles.\n *\n * Analyses the **rendered article HTML** to extract insightful titles,\n * descriptions, and keywords.  This runs *after* {@link buildContent}\n * produces the article body so that metadata truly reflects what the\n * reader will see — not mechanical counts from the raw data payload.\n *\n * The analysis extracts:\n * - Headings (h2/h3) as topic indicators\n * - The lede paragraph for a content-based description\n * - Key statistics (numbers, percentages) for title highlights\n * - Entity names (committees, legislation titles) for keywords\n * - Section counts for a structural overview\n */\n\nimport type { ArticleMetadata } from '../types/index.js';\n\n/** Maximum length for the enriched description */\nconst MAX_DESCRIPTION_LENGTH = 200;\n\n/**\n * Minimum position (as fraction of MAX_DESCRIPTION_LENGTH) for a\n * sentence-boundary truncation point.  If the last sentence break\n * is before this threshold, we fall back to hard truncation with `...`.\n * This ensures the truncated description retains at least half its\n * intended content.\n */\nconst MIN_SENTENCE_TRUNCATION_RATIO = 0.5;\n\n/** Maximum number of keywords to emit */\nconst MAX_KEYWORDS = 15;\n\n/** Minimum heading length to include as keyword */\nconst MIN_HEADING_KEYWORD_LENGTH = 4;\n\n/** Maximum heading length to include as keyword */\nconst MAX_HEADING_KEYWORD_LENGTH = 80;\n\n/**\n * Strip HTML tags and decode common HTML entities to plain text.\n *\n * @param html - HTML string\n * @returns Plain-text string\n */\nfunction stripHtml(html: string): string {\n  return html\n    .replace(/<[^>]+>/gu, ' ')\n    .replace(/&lt;/gu, '<')\n    .replace(/&gt;/gu, '>')\n    .replace(/&quot;/gu, '\"')\n    .replace(/&#39;/gu, \"'\")\n    .replace(/&mdash;/gu, '\\u2014')\n    .replace(/&ndash;/gu, '\\u2013')\n    .replace(/&amp;/gu, '&')\n    .replace(/\\s+/gu, ' ')\n    .trim();\n}\n\n/**\n * Extract all h2 and h3 heading texts from article content.\n *\n * @param content - Article HTML body\n * @returns Array of heading text strings\n */\nfunction extractHeadings(content: string): string[] {\n  const headingRegex = /<h([23])\\b[^>]*>([\\s\\S]*?)<\\/h\\1>/giu;\n  const headings: string[] = [];\n  let match: RegExpExecArray | null = headingRegex.exec(content);\n  while (match) {\n    const text = stripHtml(match[2] ?? '').trim();\n    if (text.length > 0) headings.push(text);\n    match = headingRegex.exec(content);\n  }\n  return headings;\n}\n\n/**\n * Extract the lede from article content as a plain-text description base.\n *\n * Prefers a <p class=\"lede\">...</p>, then a <section class=\"lede\">...</section>\n * (using its first paragraph or full text), and finally falls back to\n * the first <p> in the content if no lede-specific markup is found.\n *\n * @param content - Article HTML body\n * @returns Plain-text lede string, or empty string\n */\nfunction extractLede(content: string): string {\n  // Try explicit lede paragraph first: <p class=\"lede\">...</p>\n  const ledeParagraphMatch = /<p[^>]*class=\"[^\"]*\\blede\\b[^\"]*\"[^>]*>([\\s\\S]*?)<\\/p>/iu.exec(\n    content\n  );\n  if (ledeParagraphMatch?.[1]) {\n    const text = stripHtml(ledeParagraphMatch[1]).trim();\n    if (text.length > 20) return text;\n  }\n\n  // Try section-based lede: <section class=\"lede\"> ... <p>...</p> ... </section>\n  const ledeSectionMatch =\n    /<section[^>]*class=\"[^\"]*\\blede\\b[^\"]*\"[^>]*>([\\s\\S]*?)<\\/section>/iu.exec(content);\n  if (ledeSectionMatch?.[1]) {\n    const sectionParagraphMatch = /<p[^>]*>([\\s\\S]*?)<\\/p>/iu.exec(ledeSectionMatch[1]);\n    if (sectionParagraphMatch?.[1]) {\n      const text = stripHtml(sectionParagraphMatch[1]).trim();\n      if (text.length > 20) return text;\n    }\n    const sectionText = stripHtml(ledeSectionMatch[1]).trim();\n    if (sectionText.length > 20) return sectionText;\n  }\n\n  // Fall back to first paragraph in article-content\n  const paraMatch = /<p[^>]*>([\\s\\S]*?)<\\/p>/iu.exec(content);\n  if (paraMatch?.[1]) {\n    const text = stripHtml(paraMatch[1]).trim();\n    if (text.length > 20) return text;\n  }\n\n  return '';\n}\n\n/**\n * Extract key statistics (numbers with context) from article content.\n * Looks for patterns like \"42 adopted texts\", \"85% pipeline health\", etc.\n *\n * @param content - Article HTML body\n * @returns Array of statistic highlight strings\n */\nfunction extractStatistics(content: string): string[] {\n  const text = stripHtml(content);\n  const stats: string[] = [];\n\n  // Match \"N adopted texts\" / \"N documents\" / \"N procedures\" / \"N events\" etc.\n  // Use a simple alternation list — no nested quantifiers.\n  const countWords = [\n    'adopted texts',\n    'adopted text',\n    'documents',\n    'document',\n    'procedures',\n    'procedure',\n    'events',\n    'event',\n    'votes',\n    'vote',\n    'questions',\n    'question',\n    'anomalies',\n    'anomaly',\n    'committees',\n    'committee',\n    'resolutions',\n    'resolution',\n    'MEPs',\n    'MEP',\n    'sessions',\n    'session',\n    'meetings',\n    'meeting',\n  ].join('|');\n  const countPatterns = new RegExp(`(\\\\d+)\\\\s+(${countWords})`, 'giu');\n  let match: RegExpExecArray | null = countPatterns.exec(text);\n  while (match) {\n    stats.push(`${match[1]} ${match[2]}`);\n    match = countPatterns.exec(text);\n  }\n\n  // Match percentages — integer or decimal followed by %\n  const pctPatterns = /(\\d[\\d.]*\\d|\\d)%/gu;\n  match = pctPatterns.exec(text);\n  while (match) {\n    stats.push(`${match[1]}%`);\n    match = pctPatterns.exec(text);\n  }\n\n  // Deduplicate\n  return [...new Set(stats)].slice(0, 5);\n}\n\n/**\n * Extract content-derived keywords from headings and prominent terms.\n *\n * @param content - Article HTML body\n * @param baseKeywords - Keywords from the strategy (preserved)\n * @returns Deduplicated keyword array\n */\nfunction extractContentKeywords(content: string, baseKeywords: readonly string[]): string[] {\n  const keywords: string[] = [...baseKeywords];\n\n  // Add headings as keywords\n  const headings = extractHeadings(content);\n  for (const h of headings) {\n    if (h.length >= MIN_HEADING_KEYWORD_LENGTH && h.length <= MAX_HEADING_KEYWORD_LENGTH) {\n      keywords.push(h);\n    }\n  }\n\n  // Work against plain text for entity extraction to avoid false positives from markup\n  const plainText = stripHtml(content);\n\n  // Extract committee abbreviations (ENVI, ECON, AFET, etc.)\n  const abbrRegex =\n    /\\b(ENVI|ECON|AFET|LIBE|AGRI|ITRE|IMCO|TRAN|REGI|PECH|CULT|JURI|BUDG|CONT|EMPL|INTA|DEVE|DROI|SEDE)\\b/gu;\n  let match: RegExpExecArray | null = abbrRegex.exec(plainText);\n  while (match) {\n    keywords.push(match[1] ?? '');\n    match = abbrRegex.exec(plainText);\n  }\n\n  // Extract political group names\n  const groupRegex = /\\b(EPP|S&D|Renew|Greens\\/EFA|ECR|The Left|ID|PfE)\\b/gu;\n  match = groupRegex.exec(plainText);\n  while (match) {\n    keywords.push(match[1] ?? '');\n    match = groupRegex.exec(plainText);\n  }\n\n  return [...new Set(keywords)].slice(0, MAX_KEYWORDS);\n}\n\n/**\n * Patterns that indicate a heading is a generic section label (not\n * analytical content suitable for a title suffix).\n */\nconst GENERIC_HEADING_PATTERN =\n  /^(introduction|overview|analysis|conclusion|summary|background|context|key\\s+findings|methodology|data\\s+sources|voting\\s+records|parliamentary\\s+questions|about|feed\\s+health|analysis\\s+pipeline|analysis\\s+&\\s+transparency|stakeholder|dashboard|pipeline\\s+snapshot|political\\s+intelligence|further\\s+reading|related|appendix|table\\s+of\\s+contents|deep\\s+analysis)/iu;\n\n/**\n * Patterns indicating a heading contains analytical/political content\n * (e.g., specific legislation names, political dynamics, policy topics).\n */\nconst ANALYTICAL_HEADING_PATTERN =\n  /(?:directive|regulation|resolution|reform|crisis|alliance|coalition|division|bloc|breakthrough|deadlock|amendment|trilogue|committee|parliament|council|commission|veto|mandate|sovereignty|trade|climate|digital|security|defense|defence|budget|migration|energy|sanctions|treaty|accession|withdrawal|election|referendum|impeach|censure|confidence|no.confidence)/iu;\n\n/**\n * Build a content-aware title by extracting the most politically\n * significant heading or analytical finding from the article body.\n *\n * **Priority order** (per ai-driven-analysis-guide Rule 9):\n * 1. Analytical headings containing political/legislative substance\n * 2. Non-generic section headings with meaningful length\n * 3. Data statistics as a last resort only\n *\n * This ensures titles reflect AI-analysed political intelligence\n * rather than mechanical data counts like \"5 Votes, 2 Anomalies\".\n *\n * @param content - Article HTML body\n * @param baseTitle - Localized base title from the strategy\n * @returns Enriched title string\n */\nfunction buildContentTitle(content: string, baseTitle: string): string {\n  // If the strategy already appended a suffix (contains em-dash), do not double-suffix\n  if (baseTitle.includes('—')) return baseTitle;\n\n  const headings = extractHeadings(content);\n\n  // Priority 1: Find a heading with real political/legislative substance\n  const analyticalHeading = headings.find(\n    (h) =>\n      h.length > 12 &&\n      h.length <= 80 &&\n      ANALYTICAL_HEADING_PATTERN.test(h) &&\n      !GENERIC_HEADING_PATTERN.test(h)\n  );\n\n  if (analyticalHeading) {\n    return `${baseTitle} — ${analyticalHeading}`;\n  }\n\n  // Priority 2: Find any non-generic heading with meaningful length\n  const topHeading = headings.find(\n    (h) => h.length > 12 && h.length <= 80 && !GENERIC_HEADING_PATTERN.test(h)\n  );\n\n  if (topHeading) {\n    return `${baseTitle} — ${topHeading}`;\n  }\n\n  // Priority 3 (last resort): Use a key statistic — but only when no\n  // analytical heading is available\n  const stats = extractStatistics(content);\n  const topStat = stats[0];\n  if (topStat) {\n    return `${baseTitle} — ${topStat}`;\n  }\n\n  return baseTitle;\n}\n\n/**\n * Build a content-aware description by extracting the AI-written lede\n * paragraph from the article body.  The lede should contain the\n * political significance of the article content — not data counts.\n *\n * Falls back to the strategy-provided subtitle only when no\n * substantive lede paragraph is found.\n *\n * @param content - Article HTML body\n * @param baseSubtitle - Subtitle from the strategy as fallback\n * @returns SEO-friendly description string (≤ {@link MAX_DESCRIPTION_LENGTH} chars)\n */\nfunction buildContentDescription(content: string, baseSubtitle: string): string {\n  const lede = extractLede(content);\n  if (lede.length > 30) {\n    // Truncate at sentence boundary when possible for clean SEO descriptions\n    if (lede.length > MAX_DESCRIPTION_LENGTH) {\n      const truncated = lede.slice(0, MAX_DESCRIPTION_LENGTH - 3);\n      // Find the last sentence boundary (period, exclamation, or question mark followed by space)\n      const lastSentence = Math.max(\n        truncated.lastIndexOf('. '),\n        truncated.lastIndexOf('! '),\n        truncated.lastIndexOf('? ')\n      );\n      if (lastSentence > MAX_DESCRIPTION_LENGTH * MIN_SENTENCE_TRUNCATION_RATIO) {\n        return truncated.slice(0, lastSentence + 1);\n      }\n      return truncated + '...';\n    }\n    return lede;\n  }\n  return baseSubtitle;\n}\n\n/**\n * Enrich article metadata by analysing the rendered article content.\n *\n * This function is the main entry point — called by the generation pipeline\n * **after** {@link buildContent} produces the article HTML body but\n * **before** the HTML is wrapped in the full page template.\n *\n * It refines the strategy-provided base metadata with content-derived\n * insights so that titles, descriptions, and keywords reflect the\n * actual article coverage rather than generic template text.\n *\n * @param content - Rendered article HTML body (from strategy.buildContent)\n * @param baseMetadata - Base metadata from strategy.getMetadata\n * @returns Enriched metadata with content-aware title, description, and keywords\n */\nexport function enrichMetadataFromContent(\n  content: string,\n  baseMetadata: ArticleMetadata\n): ArticleMetadata {\n  const title = buildContentTitle(content, baseMetadata.title);\n  const subtitle = buildContentDescription(content, baseMetadata.subtitle);\n  const keywords = extractContentKeywords(content, baseMetadata.keywords);\n\n  return {\n    ...baseMetadata,\n    title,\n    subtitle,\n    keywords,\n  };\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/copy-test-reports.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":145,"column":5,"endLine":145,"endColumn":17}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"#!/usr/bin/env node\n\n// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Utils/CopyTestReports\n * @description Copies test reports and coverage data to the docs/ directory\n * for inclusion in the documentation bundle. Generates comprehensive HTML\n * index pages for test results with links to all available reports.\n */\n\nimport { promises as fs } from 'fs';\nimport { join, resolve } from 'path';\nimport { pathToFileURL } from 'url';\nimport { PROJECT_ROOT } from '../constants/config.js';\n\nconst DOCS_DIR = join(PROJECT_ROOT, 'docs');\nconst BUILDS_DIR = join(PROJECT_ROOT, 'builds');\nconst TEST_RESULTS_DIRNAME = 'test-results';\nconst INDEX_FILENAME = 'index.html';\nconst ESLINT_REPORT_BASE = 'eslint-report';\nconst E2E_PREFIX = 'e2e-';\nconst PLAYWRIGHT_REPORT_DIRNAME = 'playwright-report';\n\n/**\n * Recursively copy directory\n *\n * @param src - Source directory\n * @param dest - Destination directory\n */\nexport async function copyDirectory(src: string, dest: string): Promise<void> {\n  try {\n    await fs.mkdir(dest, { recursive: true });\n\n    const entries = await fs.readdir(src, { withFileTypes: true });\n\n    for (const entry of entries) {\n      const srcPath = join(src, entry.name);\n      const destPath = join(dest, entry.name);\n\n      if (entry.isDirectory()) {\n        await copyDirectory(srcPath, destPath);\n      } else {\n        await fs.copyFile(srcPath, destPath);\n      }\n    }\n  } catch (error) {\n    const nodeError = error as NodeJS.ErrnoException;\n    if (nodeError.code === 'ENOENT') {\n      console.warn(`  ⚠️  Source directory not found (skipped): ${src}`);\n    } else {\n      throw error;\n    }\n  }\n}\n\n/**\n * Copy a single file safely\n *\n * @param src - Source file path\n * @param dest - Destination file path\n * @returns Whether the copy succeeded\n */\nasync function copyFileSafe(src: string, dest: string): Promise<boolean> {\n  try {\n    await fs.copyFile(src, dest);\n    return true;\n  } catch {\n    return false;\n  }\n}\n\n/**\n * Check if a file or directory exists\n *\n * @param path - Path to check\n * @returns Whether the path exists\n */\nasync function pathExists(path: string): Promise<boolean> {\n  try {\n    await fs.access(path);\n    return true;\n  } catch {\n    return false;\n  }\n}\n\n/** Report file names within test-results directory */\nconst REPORT_FILES = {\n  vitestHtml: join('html', INDEX_FILENAME),\n  vitestJson: 'results.json',\n  vitestJunit: 'junit.xml',\n  e2eJson: `${E2E_PREFIX}results.json`,\n  e2eJunit: `${E2E_PREFIX}junit.xml`,\n  eslintHtml: `${ESLINT_REPORT_BASE}.html`,\n  eslintJson: `${ESLINT_REPORT_BASE}.json`,\n} as const;\n\n/** Shape of vitest JSON results (subset) */\ninterface VitestJsonResults {\n  numTotalTests?: number;\n  numPassedTests?: number;\n  numFailedTests?: number;\n  testResults?: Array<{ perfStats?: { end?: number; start?: number } }>;\n}\n\n/** Shape of Playwright JSON results (subset) */\ninterface PlaywrightJsonResults {\n  stats?: { expected?: number; unexpected?: number; flaky?: number; skipped?: number };\n}\n\n/** Summary of test run counts */\ninterface TestSummary {\n  tests: number;\n  passed: number;\n  failed: number;\n  duration?: number;\n}\n\n/** Report availability and summary data */\ninterface ReportInfo {\n  hasVitestHtml: boolean;\n  hasVitestJson: boolean;\n  hasVitestJunit: boolean;\n  hasE2eJson: boolean;\n  hasE2eJunit: boolean;\n  hasEslintHtml: boolean;\n  hasEslintJson: boolean;\n  hasCoverage: boolean;\n  hasPlaywright: boolean;\n  vitestSummary: TestSummary | null;\n  e2eSummary: TestSummary | null;\n}\n\n/**\n * Check which report files exist in the test-results directory\n *\n * @param testResultsDir - Path to test-results directory\n * @returns Map of report key to existence boolean\n */\nasync function checkReportFiles(testResultsDir: string): Promise<Record<string, boolean>> {\n  const results: Record<string, boolean> = {};\n  for (const [key, relativePath] of Object.entries(REPORT_FILES)) {\n    results[key] = await pathExists(join(testResultsDir, relativePath));\n  }\n  return results;\n}\n\n/**\n * Parse vitest JSON results file for summary data\n *\n * @param filePath - Path to vitest results.json\n * @returns Summary or null if unavailable\n */\nasync function parseVitestSummary(filePath: string): Promise<TestSummary | null> {\n  try {\n    const raw = await fs.readFile(filePath, 'utf8');\n    const data = JSON.parse(raw) as VitestJsonResults;\n    const total = data.numTotalTests ?? 0;\n    const passed = data.numPassedTests ?? 0;\n    const failed = data.numFailedTests ?? 0;\n    let duration = 0;\n    if (Array.isArray(data.testResults)) {\n      for (const r of data.testResults) {\n        if (r.perfStats?.end && r.perfStats?.start) {\n          duration += r.perfStats.end - r.perfStats.start;\n        }\n      }\n    }\n    return { tests: total, passed, failed, duration: Math.round(duration) };\n  } catch {\n    return null;\n  }\n}\n\n/**\n * Parse Playwright JSON results file for summary data\n *\n * @param filePath - Path to e2e-results.json\n * @returns Summary or null if unavailable\n */\nasync function parseE2eSummary(filePath: string): Promise<TestSummary | null> {\n  try {\n    const raw = await fs.readFile(filePath, 'utf8');\n    const data = JSON.parse(raw) as PlaywrightJsonResults;\n    if (data.stats) {\n      const passed = data.stats.expected ?? 0;\n      const failed = data.stats.unexpected ?? 0;\n      const flaky = data.stats.flaky ?? 0;\n      return { tests: passed + failed + flaky, passed, failed };\n    }\n    return null;\n  } catch {\n    return null;\n  }\n}\n\n/**\n * Gather report availability info for index generation\n *\n * @returns Object describing which reports are available\n */\nasync function gatherReportInfo(): Promise<ReportInfo> {\n  const testResultsDir = join(DOCS_DIR, TEST_RESULTS_DIRNAME);\n  const fileStatus = await checkReportFiles(testResultsDir);\n\n  const info: ReportInfo = {\n    hasVitestHtml: fileStatus['vitestHtml'] ?? false,\n    hasVitestJson: fileStatus['vitestJson'] ?? false,\n    hasVitestJunit: fileStatus['vitestJunit'] ?? false,\n    hasE2eJson: fileStatus['e2eJson'] ?? false,\n    hasE2eJunit: fileStatus['e2eJunit'] ?? false,\n    hasEslintHtml: fileStatus['eslintHtml'] ?? false,\n    hasEslintJson: fileStatus['eslintJson'] ?? false,\n    hasCoverage: await pathExists(join(DOCS_DIR, 'coverage', INDEX_FILENAME)),\n    hasPlaywright: await pathExists(join(DOCS_DIR, PLAYWRIGHT_REPORT_DIRNAME, INDEX_FILENAME)),\n    vitestSummary: null,\n    e2eSummary: null,\n  };\n\n  if (info.hasVitestJson) {\n    info.vitestSummary = await parseVitestSummary(join(testResultsDir, REPORT_FILES.vitestJson));\n  }\n\n  if (info.hasE2eJson) {\n    info.e2eSummary = await parseE2eSummary(join(testResultsDir, REPORT_FILES.e2eJson));\n  }\n\n  return info;\n}\n\n/**\n * Build stat-card HTML for a test summary\n *\n * @param summary - Test summary data\n * @param isE2e - Whether this is an E2E summary\n * @returns HTML string for stat cards\n */\nfunction buildStatCards(summary: TestSummary, isE2e: boolean): string {\n  const failedClass = summary.failed > 0 ? 'failed' : 'passed';\n  const durationCard =\n    summary.duration !== undefined\n      ? `<div class=\"stat-card\">\n        <div class=\"stat-number\">${(summary.duration / 1000).toFixed(1)}s</div>\n        <div class=\"stat-label\">Duration</div>\n      </div>`\n      : '';\n  const totalLabel = isE2e ? 'Total E2E' : 'Total Tests';\n  return `<div class=\"stat-card passed\">\n        <div class=\"stat-number\">${summary.passed}</div>\n        <div class=\"stat-label\">Passed</div>\n      </div>\n      <div class=\"stat-card ${failedClass}\">\n        <div class=\"stat-number\">${summary.failed}</div>\n        <div class=\"stat-label\">Failed</div>\n      </div>\n      <div class=\"stat-card\">\n        <div class=\"stat-number\">${summary.tests}</div>\n        <div class=\"stat-label\">${totalLabel}</div>\n      </div>${durationCard}`;\n}\n\n/**\n * Create a comprehensive HTML index for test results\n *\n * @param info - Report availability information\n * @returns HTML content\n */\nfunction createTestResultsIndex(info: ReportInfo): string {\n  const currentDate = new Date().toISOString().split('T')[0] ?? '';\n\n  const vitestStats = info.vitestSummary ? buildStatCards(info.vitestSummary, false) : '';\n\n  const e2eStats = info.e2eSummary ? buildStatCards(info.e2eSummary, true) : '';\n\n  return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <meta name=\"description\" content=\"EU Parliament Monitor - Comprehensive Test Results and Quality Reports\">\n  <title>Test Results - EU Parliament Monitor</title>\n  <style>\n    * { margin: 0; padding: 0; box-sizing: border-box; }\n    body {\n      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;\n      line-height: 1.6;\n      color: #333;\n      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n      min-height: 100vh;\n      padding: 2rem;\n    }\n    .container {\n      max-width: 1200px;\n      margin: 0 auto;\n      background: white;\n      border-radius: 12px;\n      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);\n      overflow: hidden;\n    }\n    header {\n      background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);\n      color: white;\n      padding: 2.5rem 2rem;\n      text-align: center;\n    }\n    h1 { font-size: 2.2rem; margin-bottom: 0.5rem; font-weight: 700; }\n    .subtitle { font-size: 1.1rem; opacity: 0.9; }\n    .last-updated { font-size: 0.85rem; opacity: 0.7; margin-top: 0.75rem; }\n    main { padding: 2rem; }\n    h2 { color: #1e3c72; font-size: 1.5rem; margin: 2rem 0 1rem; border-bottom: 2px solid #e9ecef; padding-bottom: 0.5rem; }\n    .stats-grid {\n      display: flex;\n      gap: 1rem;\n      flex-wrap: wrap;\n      margin-bottom: 1.5rem;\n    }\n    .stat-card {\n      background: #f8f9fa;\n      border: 2px solid #e9ecef;\n      border-radius: 8px;\n      padding: 1rem 1.5rem;\n      text-align: center;\n      min-width: 100px;\n      flex: 1;\n    }\n    .stat-card.passed { border-color: #28a745; background: #d4edda; }\n    .stat-card.failed { border-color: #dc3545; background: #f8d7da; }\n    .stat-number { font-size: 1.8rem; font-weight: 700; color: #1e3c72; }\n    .stat-label { font-size: 0.85rem; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }\n    .reports-grid {\n      display: grid;\n      grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));\n      gap: 1rem;\n      margin: 1rem 0;\n    }\n    .report-card {\n      background: #f8f9fa;\n      border: 2px solid #e9ecef;\n      border-radius: 8px;\n      padding: 1.25rem;\n      transition: all 0.3s ease;\n      text-decoration: none;\n      color: inherit;\n      display: block;\n    }\n    .report-card:hover {\n      transform: translateY(-3px);\n      box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);\n      border-color: #667eea;\n    }\n    .report-card.unavailable {\n      opacity: 0.5;\n      pointer-events: none;\n    }\n    .report-card h3 { color: #1e3c72; font-size: 1.1rem; margin-bottom: 0.25rem; }\n    .report-card .icon { font-size: 1.5rem; margin-bottom: 0.25rem; }\n    .report-card p { color: #666; font-size: 0.85rem; line-height: 1.4; }\n    .badge {\n      display: inline-block;\n      padding: 0.15rem 0.5rem;\n      border-radius: 10px;\n      font-size: 0.7rem;\n      font-weight: 600;\n      margin-top: 0.5rem;\n    }\n    .badge-html { background: #667eea; color: white; }\n    .badge-json { background: #28a745; color: white; }\n    .badge-xml { background: #fd7e14; color: white; }\n    .badge-vitest { background: #fcc72b; color: #333; }\n    .badge-playwright { background: #2ead33; color: white; }\n    .badge-eslint { background: #4b32c3; color: white; }\n    footer {\n      background: #f8f9fa;\n      padding: 1.5rem 2rem;\n      text-align: center;\n      color: #666;\n      border-top: 1px solid #e9ecef;\n    }\n    footer a { color: #667eea; text-decoration: none; }\n    footer a:hover { text-decoration: underline; }\n    @media (max-width: 768px) {\n      body { padding: 1rem; }\n      h1 { font-size: 1.8rem; }\n      .reports-grid { grid-template-columns: 1fr; }\n      .stats-grid { flex-direction: column; }\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <header>\n      <h1>📊 Test Results &amp; Quality Reports</h1>\n      <div class=\"subtitle\">EU Parliament Monitor - Comprehensive Test Dashboard</div>\n      <div class=\"last-updated\">Generated: ${currentDate}</div>\n    </header>\n\n    <main>\n      ${vitestStats ? `<h2>🧪 Unit &amp; Integration Tests (Vitest)</h2><div class=\"stats-grid\">${vitestStats}</div>` : ''}\n\n      ${e2eStats ? `<h2>🎭 End-to-End Tests (Playwright)</h2><div class=\"stats-grid\">${e2eStats}</div>` : ''}\n\n      <h2>📋 Interactive Reports</h2>\n      <div class=\"reports-grid\">\n        <a href=\"html/index.html\" class=\"report-card${info.hasVitestHtml ? '' : ' unavailable'}\">\n          <div class=\"icon\">🧪</div>\n          <h3>Vitest HTML Report</h3>\n          <p>Interactive test explorer with detailed results for all unit and integration tests.</p>\n          <span class=\"badge badge-vitest\">Vitest</span>\n          <span class=\"badge badge-html\">HTML</span>\n        </a>\n\n        <a href=\"../coverage/index.html\" class=\"report-card${info.hasCoverage ? '' : ' unavailable'}\">\n          <div class=\"icon\">📊</div>\n          <h3>Code Coverage Report</h3>\n          <p>Line, branch, function, and statement coverage with per-file drill-down.</p>\n          <span class=\"badge badge-vitest\">Vitest V8</span>\n          <span class=\"badge badge-html\">HTML</span>\n        </a>\n\n        <a href=\"../playwright-report/index.html\" class=\"report-card${info.hasPlaywright ? '' : ' unavailable'}\">\n          <div class=\"icon\">🎭</div>\n          <h3>Playwright E2E Report</h3>\n          <p>End-to-end test results with screenshots, traces, and accessibility checks.</p>\n          <span class=\"badge badge-playwright\">Playwright</span>\n          <span class=\"badge badge-html\">HTML</span>\n        </a>\n\n        <a href=\"eslint-report.html\" class=\"report-card${info.hasEslintHtml ? '' : ' unavailable'}\">\n          <div class=\"icon\">🔍</div>\n          <h3>ESLint Report</h3>\n          <p>Static analysis results showing code quality issues, warnings, and style compliance.</p>\n          <span class=\"badge badge-eslint\">ESLint</span>\n          <span class=\"badge badge-html\">HTML</span>\n        </a>\n      </div>\n\n      <h2>📁 Machine-Readable Reports</h2>\n      <div class=\"reports-grid\">\n        <a href=\"results.json\" class=\"report-card${info.hasVitestJson ? '' : ' unavailable'}\">\n          <div class=\"icon\">📄</div>\n          <h3>Vitest Results (JSON)</h3>\n          <p>Machine-readable unit test results in JSON format for CI/CD integration.</p>\n          <span class=\"badge badge-vitest\">Vitest</span>\n          <span class=\"badge badge-json\">JSON</span>\n        </a>\n\n        <a href=\"junit.xml\" class=\"report-card${info.hasVitestJunit ? '' : ' unavailable'}\">\n          <div class=\"icon\">📄</div>\n          <h3>Vitest Results (JUnit XML)</h3>\n          <p>JUnit XML format for CI dashboard integration and test trend analysis.</p>\n          <span class=\"badge badge-vitest\">Vitest</span>\n          <span class=\"badge badge-xml\">XML</span>\n        </a>\n\n        <a href=\"e2e-results.json\" class=\"report-card${info.hasE2eJson ? '' : ' unavailable'}\">\n          <div class=\"icon\">📄</div>\n          <h3>E2E Results (JSON)</h3>\n          <p>Playwright end-to-end test results in JSON format with detailed timing data.</p>\n          <span class=\"badge badge-playwright\">Playwright</span>\n          <span class=\"badge badge-json\">JSON</span>\n        </a>\n\n        <a href=\"e2e-junit.xml\" class=\"report-card${info.hasE2eJunit ? '' : ' unavailable'}\">\n          <div class=\"icon\">📄</div>\n          <h3>E2E Results (JUnit XML)</h3>\n          <p>E2E test results in JUnit XML format for cross-platform CI integration.</p>\n          <span class=\"badge badge-playwright\">Playwright</span>\n          <span class=\"badge badge-xml\">XML</span>\n        </a>\n\n        <a href=\"eslint-report.json\" class=\"report-card${info.hasEslintJson ? '' : ' unavailable'}\">\n          <div class=\"icon\">📄</div>\n          <h3>ESLint Report (JSON)</h3>\n          <p>Detailed linting results in JSON format for automated quality gates.</p>\n          <span class=\"badge badge-eslint\">ESLint</span>\n          <span class=\"badge badge-json\">JSON</span>\n        </a>\n      </div>\n    </main>\n\n    <footer>\n      <p><a href=\"../index.html\">← Back to Documentation Index</a></p>\n      <p style=\"margin-top: 0.5rem;\">\n        <strong>EU Parliament Monitor</strong> -\n        European Parliament Intelligence Platform\n      </p>\n    </footer>\n  </div>\n</body>\n</html>`;\n}\n\n/**\n * Main execution function\n */\nasync function main(): Promise<void> {\n  console.log('📋 Copying test reports to documentation directory...');\n\n  try {\n    await fs.mkdir(DOCS_DIR, { recursive: true });\n\n    // 1. Copy coverage report (from vitest)\n    const coverageSrc = join(BUILDS_DIR, 'coverage');\n    const coverageDest = join(DOCS_DIR, 'coverage');\n    console.log('  📊 Copying coverage report...');\n    await copyDirectory(coverageSrc, coverageDest);\n    console.log('  ✅ Coverage report copied');\n\n    // 2. Copy API documentation (from typedoc)\n    const apiSrc = join(BUILDS_DIR, 'api');\n    const apiDest = join(DOCS_DIR, 'api');\n    console.log('  📖 Copying API docs...');\n    await copyDirectory(apiSrc, apiDest);\n    console.log('  ✅ API docs copied');\n\n    // 3. Copy Playwright E2E report\n    const playwrightSrc = join(BUILDS_DIR, PLAYWRIGHT_REPORT_DIRNAME);\n    const playwrightDest = join(DOCS_DIR, PLAYWRIGHT_REPORT_DIRNAME);\n    console.log('  🎭 Copying Playwright report...');\n    await copyDirectory(playwrightSrc, playwrightDest);\n    console.log('  ✅ Playwright report copied');\n\n    // 4. Copy test results directory (vitest HTML, JSON, JUnit, ESLint reports)\n    const buildTestResultsDir = join(BUILDS_DIR, TEST_RESULTS_DIRNAME);\n    const docsTestResultsDir = join(DOCS_DIR, TEST_RESULTS_DIRNAME);\n    await fs.mkdir(docsTestResultsDir, { recursive: true });\n\n    // 4a. Copy vitest HTML test report\n    console.log('  🧪 Copying Vitest HTML report...');\n    await copyDirectory(join(buildTestResultsDir, 'html'), join(docsTestResultsDir, 'html'));\n    console.log('  ✅ Vitest HTML report copied');\n\n    // 4b-4g. Copy individual report files\n    const reportCopyTasks: ReadonlyArray<{ file: string; label: string; icon: string }> = [\n      { file: REPORT_FILES.vitestJson, label: 'Vitest JSON results', icon: '📄' },\n      { file: REPORT_FILES.vitestJunit, label: 'Vitest JUnit XML results', icon: '📄' },\n      { file: REPORT_FILES.e2eJson, label: 'E2E JSON results', icon: '📄' },\n      { file: REPORT_FILES.e2eJunit, label: 'E2E JUnit XML results', icon: '📄' },\n      { file: REPORT_FILES.eslintHtml, label: 'ESLint HTML report', icon: '🔍' },\n      { file: REPORT_FILES.eslintJson, label: 'ESLint JSON report', icon: '🔍' },\n    ];\n\n    for (const task of reportCopyTasks) {\n      console.log(`  ${task.icon} Copying ${task.label}...`);\n      if (\n        await copyFileSafe(\n          join(buildTestResultsDir, task.file),\n          join(docsTestResultsDir, task.file)\n        )\n      ) {\n        console.log(`  ✅ ${task.label} copied`);\n      } else {\n        console.warn(`  ⚠️  ${task.label} not found (skipped)`);\n      }\n    }\n\n    // 5. Gather report info and generate comprehensive index\n    console.log('  📊 Generating test results index...');\n    const reportInfo = await gatherReportInfo();\n    await fs.writeFile(\n      join(docsTestResultsDir, INDEX_FILENAME),\n      createTestResultsIndex(reportInfo),\n      'utf8'\n    );\n    console.log('  ✅ Test results index generated');\n\n    console.log('✅ All test reports copied successfully');\n  } catch (error) {\n    const message = error instanceof Error ? error.message : String(error);\n    console.error('❌ Error copying test reports:', message);\n    process.exit(1);\n  }\n}\n\n// Only run main when executed directly (not when imported)\nif (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {\n  main();\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/file-utils.ts","messages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":72,"column":5,"endLine":72,"endColumn":18},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":87,"column":20,"endLine":87,"endColumn":33},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":376,"column":21,"endLine":376,"endColumn":31},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":758,"column":10,"endLine":758,"endColumn":38}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":4,"fixableErrorCount":0,"fixableWarningCount":0,"source":"// SPDX-FileCopyrightText: 2024-2026 Hack23 AB\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * @module Utils/FileUtils\n * @description Shared file system utilities for news article operations\n */\n\nimport { randomUUID } from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\nimport { NEWS_DIR, ARTICLE_FILENAME_PATTERN } from '../constants/config.js';\nimport { ALL_LANGUAGES } from '../constants/language-core.js';\nimport type { AnalysisFileEntry, LanguageCode, ParsedArticle } from '../types/index.js';\n\n/**\n * Get all news article HTML files from the news directory\n *\n * @param newsDir - News directory path (defaults to NEWS_DIR)\n * @returns List of article filenames\n */\nexport function getNewsArticles(newsDir: string = NEWS_DIR): string[] {\n  if (!fs.existsSync(newsDir)) {\n    console.log('📁 News directory does not exist yet');\n    return [];\n  }\n\n  const files = fs.readdirSync(newsDir);\n  return files.filter((f) => f.endsWith('.html') && !f.startsWith('index-'));\n}\n\n/**\n * Parse article filename to extract metadata\n *\n * @param filename - Article filename (e.g., \"2025-01-15-week-ahead-en.html\")\n * @returns Parsed metadata or null if filename doesn't match pattern\n */\nexport function parseArticleFilename(filename: string): ParsedArticle | null {\n  const match = filename.match(ARTICLE_FILENAME_PATTERN);\n\n  if (!match) {\n    return null;\n  }\n\n  const langCandidate = match[3] as string;\n  if (!ALL_LANGUAGES.includes(langCandidate as LanguageCode)) {\n    return null;\n  }\n\n  return {\n    date: match[1] as string,\n    slug: match[2] as string,\n    lang: langCandidate as LanguageCode,\n    filename,\n  };\n}\n\n/**\n * Group articles by language code\n *\n * @param articles - List of article filenames\n * @param languages - Supported language codes\n * @returns Articles grouped by language, sorted newest first\n */\nexport function groupArticlesByLanguage(\n  articles: string[],\n  languages: readonly string[]\n): Record<string, ParsedArticle[]> {\n  const grouped: Record<string, ParsedArticle[]> = {};\n\n  for (const lang of languages) {\n    grouped[lang] = [];\n  }\n\n  for (const article of articles) {\n    const parsed = parseArticleFilename(article);\n    if (parsed) {\n      const bucket = grouped[parsed.lang];\n      if (bucket) {\n        bucket.push(parsed);\n      }\n    }\n  }\n\n  // Sort by date (newest first)\n  for (const lang in grouped) {\n    const bucket = grouped[lang];\n    if (bucket) {\n      bucket.sort((a, b) => b.date.localeCompare(a.date));\n    }\n  }\n\n  return grouped;\n}\n\n/**\n * Format slug for display (hyphen-separated to Title Case)\n *\n * @param slug - Hyphen-separated slug string\n * @returns Formatted title string\n */\nexport function formatSlug(slug: string): string {\n  return slug\n    .split('-')\n    .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n    .join(' ');\n}\n\n/**\n * Get file modification time as YYYY-MM-DD string\n *\n * @param filepath - Path to file\n * @returns Last modified date in YYYY-MM-DD format\n */\nexport function getModifiedDate(filepath: string): string {\n  const stats = fs.statSync(filepath);\n  return stats.mtime.toISOString().slice(0, 10);\n}\n\n/**\n * Format date for article slug\n *\n * @param date - Date to format (defaults to now)\n * @returns Formatted date string (YYYY-MM-DD)\n */\nexport function formatDateForSlug(date: Date = new Date()): string {\n  return date.toISOString().slice(0, 10);\n}\n\n/**\n * Calculate read time estimate from content\n *\n * @param content - Article content text\n * @param wordsPerMinute - Reading speed (default 250)\n * @returns Estimated read time in minutes\n */\nexport function calculateReadTime(content: string, wordsPerMinute: number = 250): number {\n  const words = content.split(/\\s+/).length;\n  return Math.ceil(words / wordsPerMinute);\n}\n\n/**\n * Ensure a directory exists, creating it recursively if needed\n *\n * @param dirPath - Directory path to ensure\n */\nexport function ensureDirectoryExists(dirPath: string): void {\n  if (!fs.existsSync(dirPath)) {\n    fs.mkdirSync(dirPath, { recursive: true });\n  }\n}\n\n/**\n * Attempt to atomically claim a directory by creating it non-recursively.\n *\n * @param dirPath - Directory path to claim\n * @returns `true` when the directory was created by this call, otherwise `false`\n */\nfunction claimDir(dirPath: string): boolean {\n  // Ensure parent exists (recursive: true never throws EEXIST)\n  fs.mkdirSync(path.dirname(dirPath), { recursive: true });\n  try {\n    // Non-recursive create: EEXIST means another run already claimed it\n    fs.mkdirSync(dirPath, { recursive: false });\n    return true;\n  } catch (err: unknown) {\n    if ((err as NodeJS.ErrnoException).code === 'EEXIST') {\n      return false;\n    }\n    throw err;\n  }\n}\n\n/**\n * Resolve a unique directory path by appending a numeric suffix (-2, -3, …)\n * when the preferred directory has already been claimed by a completed run.\n *\n * The base directory is treated as occupied when it contains `manifest.json`\n * (written at the end of a successful analysis run).  A directory without\n * `manifest.json` is considered available — this allows the `skipCompleted`\n * feature to resume an incomplete run in the same directory.\n *\n * Suffixed candidates (-2, -3, …) are claimed atomically via non-recursive\n * `mkdirSync`, preventing TOCTOU races when concurrent workflow runs\n * attempt to claim the same candidate.\n *\n * @param baseDir - The preferred directory path (e.g. `analysis/daily/2026-04-02/breaking`)\n * @returns The original `baseDir` when no completed run exists there, or a\n *          suffixed variant (e.g. `analysis/daily/2026-04-02/breaking-2`) otherwise.\n */\nexport function resolveUniqueAnalysisDir(baseDir: string): string {\n  // If the directory doesn't exist yet or has no manifest from a prior\n  // completed run, use it as-is.  This supports the skipCompleted feature\n  // which resumes an incomplete run in the same directory.\n  if (!fs.existsSync(path.join(baseDir, 'manifest.json'))) {\n    return baseDir;\n  }\n\n  // Directory already has a completed run — find the next available suffix.\n  // Use atomic mkdirSync to prevent TOCTOU races when parallel workflow\n  // runs attempt to claim the same suffixed candidate concurrently.\n  let suffix = 2;\n  const MAX_SUFFIX = 100;\n  while (suffix <= MAX_SUFFIX) {\n    const candidate = `${baseDir}-${suffix}`;\n    if (claimDir(candidate)) {\n      return candidate;\n    }\n    suffix++;\n  }\n\n  // Fallback: use UUID-suffixed directory to guarantee uniqueness\n  const candidate = `${baseDir}-${randomUUID().slice(0, 8)}`;\n  fs.mkdirSync(candidate, { recursive: true });\n  return candidate;\n}\n\n// ─── Manifest history (shared same-day folder support) ──────────────────────\n\n/**\n * Single entry in `manifest.json.history[]` recording one run that wrote\n * artifacts into a shared same-day analysis folder.\n *\n * When the analysis workflow re-runs against the same\n * `analysis/daily/${DATE}/${TYPE}/` directory, it appends a new entry\n * instead of triggering the `-2` suffix in {@link resolveUniqueAnalysisDir}.\n * The article workflow reads this history to decide whether to consume or\n * skip the folder.\n */\nexport interface AnalysisManifestHistoryEntry {\n  /** Stable identifier for this attempt (e.g. `breaking-run60-1729876543`) */\n  readonly runId: string;\n  /** ISO-8601 UTC timestamp when the run started */\n  readonly startedAt: string;\n  /** ISO-8601 UTC timestamp when the run finished (or last wrote) */\n  readonly finishedAt: string;\n  /** Short git SHA of the commit the run was produced against (optional) */\n  readonly commit?: string;\n  /** Stage-C result: GREEN | GREEN_WITH_WARNINGS | ANALYSIS_ONLY | PENDING */\n  readonly gateResult: 'GREEN' | 'GREEN_WITH_WARNINGS' | 'ANALYSIS_ONLY' | 'PENDING';\n  /** Relative-path list of analysis files written or refreshed during the run */\n  readonly filesWritten: readonly string[];\n}\n\n/**\n * Merge a new run entry into the `history[]` array of the manifest file at\n * `manifestPath`, creating the file if it doesn't exist.\n *\n * The merge is additive: existing history entries are preserved, and the new\n * entry is appended. When `manifestPath` already has a manifest with\n * top-level fields (runId, date, articleType, etc.), those fields are left\n * untouched — only `history[]` is appended to and the top-level\n * `updatedAt` timestamp is refreshed.\n *\n * This supports the stable same-day analysis folder layout\n * (`analysis/daily/${DATE}/${TYPE}/`) where repeated analysis runs\n * overwrite/upgrade artifacts but each attempt adds a history entry.\n *\n * @param manifestPath - Absolute path to the run's manifest.json.\n * @param entry - History entry describing this run.\n */\nexport function mergeManifestHistory(\n  manifestPath: string,\n  entry: AnalysisManifestHistoryEntry\n): void {\n  ensureDirectoryExists(path.dirname(manifestPath));\n  let manifest: Record<string, unknown> = {};\n  if (fs.existsSync(manifestPath)) {\n    try {\n      const raw = fs.readFileSync(manifestPath, 'utf-8');\n      const parsed: unknown = JSON.parse(raw);\n      if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {\n        manifest = parsed as Record<string, unknown>;\n      }\n    } catch {\n      // Corrupt manifest — start fresh but keep a diagnostic field.\n      manifest = { corruptManifestRecoveredAt: new Date().toISOString() };\n    }\n  }\n\n  const existingHistory = Array.isArray(manifest['history'])\n    ? (manifest['history'] as AnalysisManifestHistoryEntry[])\n    : [];\n\n  manifest['history'] = [...existingHistory, entry];\n  manifest['updatedAt'] = entry.finishedAt;\n\n  fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\\n`, 'utf-8');\n}\n\n/**\n * Read the `gateResult` from the most recent entry in the manifest's\n * `history[]` array.\n *\n * Used by the article workflow to decide whether to consume a committed\n * analysis folder: `GREEN` proceeds to Stage D, everything else exits noop.\n *\n * @param manifestPath - Absolute path to the run's manifest.json.\n * @returns The latest `gateResult`, or `'PENDING'` when the manifest is\n *          missing, unreadable, or contains no history entries.\n */\nexport function readLatestGateResult(\n  manifestPath: string\n): AnalysisManifestHistoryEntry['gateResult'] {\n  if (!fs.existsSync(manifestPath)) return 'PENDING';\n  try {\n    const raw = fs.readFileSync(manifestPath, 'utf-8');\n    const parsed: unknown = JSON.parse(raw);\n    if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return 'PENDING';\n    const history = (parsed as Record<string, unknown>)['history'];\n    if (!Array.isArray(history) || history.length === 0) {\n      // Back-compat: a manifest without a history[] might carry gateResult\n      // directly at the top level during the transition.\n      const direct = (parsed as Record<string, unknown>)['gateResult'];\n      if (\n        direct === 'GREEN' ||\n        direct === 'GREEN_WITH_WARNINGS' ||\n        direct === 'ANALYSIS_ONLY' ||\n        direct === 'PENDING'\n      ) {\n        return direct;\n      }\n      return 'PENDING';\n    }\n    const last = history[history.length - 1] as AnalysisManifestHistoryEntry | undefined;\n    const gate = last?.gateResult;\n    if (\n      gate === 'GREEN' ||\n      gate === 'GREEN_WITH_WARNINGS' ||\n      gate === 'ANALYSIS_ONLY' ||\n      gate === 'PENDING'\n    ) {\n      return gate;\n    }\n    return 'PENDING';\n  } catch {\n    return 'PENDING';\n  }\n}\n\n/**\n * Find the most-recent **resolved** (non-`PENDING`) `gateResult` in a\n * manifest's `history[]` array by searching backward from the end.\n *\n * Used by the `--analysis-only` wrap-up path to carry forward the Stage-C\n * result already written by the AI agent, so the discovery history entry\n * produced by `runAnalysisStage` preserves `GREEN` / `ANALYSIS_ONLY` instead\n * of clobbering it with the default `PENDING`.\n *\n * @param manifestPath - Absolute path to the run's manifest.json.\n * @returns The latest non-PENDING `gateResult`, or `'PENDING'` when none\n *          exists or the manifest is missing / unreadable.\n */\nexport function readLatestResolvedGateResult(\n  manifestPath: string\n): AnalysisManifestHistoryEntry['gateResult'] {\n  if (!fs.existsSync(manifestPath)) return 'PENDING';\n  try {\n    const raw = fs.readFileSync(manifestPath, 'utf-8');\n    const parsed: unknown = JSON.parse(raw);\n    if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return 'PENDING';\n    const history = (parsed as Record<string, unknown>)['history'];\n    if (!Array.isArray(history) || history.length === 0) {\n      // Back-compat: older manifests may carry a resolved gateResult directly\n      // at the top level without a history[] array.  Only honour non-PENDING\n      // values — a stale PENDING at the top level must not be treated as\n      // resolved, because that defeats the carry-forward purpose of this helper.\n      const direct = (parsed as Record<string, unknown>)['gateResult'];\n      if (direct === 'GREEN' || direct === 'GREEN_WITH_WARNINGS' || direct === 'ANALYSIS_ONLY') {\n        return direct;\n      }\n      return 'PENDING';\n    }\n    // Search from the end to find the most recent non-PENDING result.\n    for (let i = history.length - 1; i >= 0; i--) {\n      const entry = history[i] as AnalysisManifestHistoryEntry | undefined;\n      const gate = entry?.gateResult;\n      if (gate === 'GREEN' || gate === 'GREEN_WITH_WARNINGS' || gate === 'ANALYSIS_ONLY') {\n        return gate;\n      }\n    }\n    return 'PENDING';\n  } catch {\n    return 'PENDING';\n  }\n}\n\n/**\n * Resolve a unique filename by appending a numeric suffix (-2, -3, …) before\n * the file extension when the file already exists.\n *\n * This prevents repeated workflow runs from overwriting previously committed\n * news articles.\n *\n * @param filepath - The preferred file path (e.g. `news/2026-04-02-breaking-en.html`)\n * @returns The original path when the file doesn't exist, or a suffixed\n *          variant (e.g. `news/2026-04-02-breaking-en-2.html`) otherwise.\n */\nexport function resolveUniqueFilePath(filepath: string): string {\n  if (!fs.existsSync(filepath)) {\n    return filepath;\n  }\n\n  const dir = path.dirname(filepath);\n  const ext = path.extname(filepath);\n  const base = path.basename(filepath, ext);\n\n  let suffix = 2;\n  const MAX_SUFFIX = 100;\n  while (suffix <= MAX_SUFFIX) {\n    const candidate = path.join(dir, `${base}-${suffix}${ext}`);\n    if (!fs.existsSync(candidate)) {\n      return candidate;\n    }\n    suffix++;\n  }\n  return path.join(dir, `${base}-${randomUUID().slice(0, 8)}${ext}`);\n}\n\n/**\n * Write content to a file with UTF-8 encoding\n *\n * @param filepath - Output file path\n * @param content - File content\n */\nexport function writeFileContent(filepath: string, content: string): void {\n  const dir = path.dirname(filepath);\n  ensureDirectoryExists(dir);\n  fs.writeFileSync(filepath, content, 'utf-8');\n}\n\n/**\n * Remove a file, ignoring ENOENT (file already deleted by another writer).\n *\n * @param filepath - Path to the file to remove\n */\nfunction unlinkIfExists(filepath: string): void {\n  try {\n    fs.unlinkSync(filepath);\n  } catch (err: unknown) {\n    const code = err instanceof Error ? (err as NodeJS.ErrnoException).code : '';\n    if (code !== 'ENOENT') {\n      throw err;\n    }\n  }\n}\n\n/**\n * Attempt to rename `src` to `dest` with a bounded retry loop.\n *\n * On each attempt the existing destination is removed first, then\n * `renameSync` is retried.  `EEXIST`/`EPERM` failures from concurrent\n * writers are tolerated for up to `maxRetries` attempts.\n *\n * @param src - Source (temp) file path\n * @param dest - Final destination path\n * @param maxRetries - Maximum number of unlink-then-rename attempts\n */\nfunction renameWithRetry(src: string, dest: string, maxRetries: number): void {\n  for (let attempt = 0; attempt < maxRetries; attempt++) {\n    unlinkIfExists(dest);\n    try {\n      fs.renameSync(src, dest);\n      return;\n    } catch (retryErr: unknown) {\n      const retryCode = retryErr instanceof Error ? (retryErr as NodeJS.ErrnoException).code : '';\n      if ((retryCode === 'EEXIST' || retryCode === 'EPERM') && attempt < maxRetries - 1) {\n        continue;\n      }\n      throw retryErr;\n    }\n  }\n}\n\n/**\n * Best-effort removal of a temporary file.  Ignores ENOENT (the file was\n * already renamed or never created) but logs a warning for other errors\n * (e.g. EBUSY, EACCES) so operators can detect leaked temp files.\n *\n * @param tempPath - Path to the temp file to remove\n */\nfunction cleanupTempFile(tempPath: string): void {\n  try {\n    fs.unlinkSync(tempPath);\n  } catch (unlinkErr: unknown) {\n    const errno =\n      unlinkErr && typeof unlinkErr === 'object' ? (unlinkErr as NodeJS.ErrnoException) : undefined;\n    if (errno?.code !== 'ENOENT') {\n      const message =\n        errno && typeof errno.message === 'string' ? errno.message : String(unlinkErr);\n      const code = errno?.code ?? 'UNKNOWN';\n      console.warn(\n        `atomicWrite: failed to remove temporary file \"${tempPath}\" (code: ${code}): ${message}`\n      );\n    }\n  }\n}\n\n/**\n * Write content to a file atomically.\n *\n * Writes to a uniquely-named temporary file in the same directory first, then\n * renames it to the final path. The temp filename includes the PID and a random\n * UUID so that concurrent callers targeting the same destination never collide\n * on the intermediate file. If the rename fails the temp file is cleaned up in\n * a `finally` block. On platforms where `renameSync` does not overwrite an\n * existing destination (e.g. Windows), the error is caught and the target is\n * removed before retrying the rename.\n *\n * @param filepath - Final output file path\n * @param content - File content to write\n */\nexport function atomicWrite(filepath: string, content: string): void {\n  const dir = path.dirname(filepath);\n  ensureDirectoryExists(dir);\n  const uniqueSuffix = `${process.pid}-${randomUUID()}`;\n  const tempPath = `${filepath}.${uniqueSuffix}.tmp`;\n  try {\n    fs.writeFileSync(tempPath, content, 'utf-8');\n    try {\n      fs.renameSync(tempPath, filepath);\n    } catch (err: unknown) {\n      const code = err instanceof Error ? (err as NodeJS.ErrnoException).code : '';\n      if (code === 'EEXIST' || code === 'EPERM') {\n        renameWithRetry(tempPath, filepath, 3);\n      } else {\n        throw err;\n      }\n    }\n  } finally {\n    cleanupTempFile(tempPath);\n  }\n}\n\n/**\n * Check whether a news article file already exists on disk.\n *\n * This is used by generation pipelines to skip work when a prior workflow run\n * (or the same run) has already produced the article, avoiding unnecessary\n * regeneration and potential merge conflicts.\n *\n * @param slug - Article slug including date prefix (e.g. `\"2025-01-15-week-ahead\"`)\n * @param lang - Language code (e.g. `\"en\"`)\n * @param newsDir - Absolute path to the news output directory (defaults to NEWS_DIR)\n * @returns `true` when the article file exists\n */\nexport function checkArticleExists(\n  slug: string,\n  lang: string,\n  newsDir: string = NEWS_DIR\n): boolean {\n  const filename = `${slug}-${lang}.html`;\n  return fs.existsSync(path.join(newsDir, filename));\n}\n\n/**\n * Decode the 5 HTML entities produced by escapeHTML() back to plain text.\n * Used when extracting text from our own generated HTML to obtain unescaped values.\n *\n * IMPORTANT: `&amp;` MUST be decoded last. Decoding it first would convert\n * `&amp;lt;` to `&lt;` before the `&lt;` → `<` replacement runs, causing\n * double-decoding. The correct order is: decode all specific entities first,\n * then decode `&amp;` as the final step.\n *\n * @param str - HTML string with entities\n * @returns Plain text with entities decoded\n */\nfunction decodeHtmlEntities(str: string): string {\n  return str\n    .replace(/&quot;/g, '\"')\n    .replace(/&#39;/g, \"'\")\n    .replace(/&lt;/g, '<')\n    .replace(/&gt;/g, '>')\n    .replace(/&amp;/g, '&');\n}\n\n/**\n * Extract title and description from a generated article HTML file.\n * Reads the predictable template structure produced by the aggregator\n * article generator. Falls back to empty strings when the file cannot\n * be read. HTML entities from the template are decoded to produce\n * plain text.\n *\n * Title resolution order:\n *   1. `<head><title>` value with the trailing ` — EU Parliament Monitor`\n *      (or legacy ` | EU Parliament Monitor`) site-suffix stripped.\n *      This is where the editorial-highlights resolver + SEO backport\n *      script write their output, so using it as the primary source\n *      surfaces the strongest headline on index cards and sitemaps.\n *   2. First body `<h1>` — fallback for files whose `<title>` was never\n *      refreshed.\n *\n * NOTE: The meta description regex relies on the template's use of\n * escapeHTML(), which converts `\"` to `&quot;`. Because descriptions are\n * always stored with double-quote delimiters and inner quotes are\n * HTML-encoded, the `[^\"]+` pattern safely captures the full value.\n *\n * @param filepath - Path to the article HTML file\n * @returns Object with title (from head-title, else first body h1) and\n *          description (from meta description)\n */\nexport function extractArticleMeta(filepath: string): { title: string; description: string } {\n  let title = '';\n  let description = '';\n  try {\n    const content = fs.readFileSync(filepath, 'utf-8');\n    // Prefer the <head><title> value (with the \" — EU Parliament Monitor\"\n    // or \" | EU Parliament Monitor\" site-suffix stripped) — that is where\n    // the SEO-facing editorial headline resolver writes its output. Fall\n    // back to the first body <h1> for older files where <title> was\n    // never refreshed.\n    const headTitleMatch = content.match(/<title[^>]*>([^<]+)<\\/title>/u);\n    if (headTitleMatch?.[1]) {\n      const rawTitle = decodeHtmlEntities(headTitleMatch[1].trim());\n      const stripped = rawTitle\n        .replace(/\\s*—\\s*EU Parliament Monitor\\s*$/u, '')\n        .replace(/\\s*\\|\\s*EU Parliament Monitor\\s*$/u, '')\n        .trim();\n      if (stripped.length > 0) title = stripped;\n    }\n    if (!title) {\n      // Matches h1 with any attributes but only plain-text content (no\n      // nested tags). The template always writes plain escaped text in\n      // h1, so this is correct.\n      const titleMatch = content.match(/<h1[^>]*>([^<]+)<\\/h1>/u);\n      if (titleMatch?.[1]) {\n        title = decodeHtmlEntities(titleMatch[1].trim());\n      }\n    }\n    const descMatch = content.match(/<meta name=\"description\" content=\"([^\"]+)\"/u);\n    if (descMatch?.[1]) {\n      description = decodeHtmlEntities(descMatch[1]);\n    }\n  } catch {\n    // File not readable – return empty strings\n  }\n  return { title, description };\n}\n\n/**\n * Escape special HTML characters to prevent XSS\n *\n * @param str - Raw string to escape\n * @returns HTML-safe string\n */\nexport function escapeHTML(str: string): string {\n  return str\n    .replace(/&/g, '&amp;')\n    .replace(/</g, '&lt;')\n    .replace(/>/g, '&gt;')\n    .replace(/\"/g, '&quot;')\n    .replace(/'/g, '&#39;');\n}\n\n/**\n * Validate that a URL uses a safe scheme (http or https)\n *\n * @param url - URL string to validate\n * @returns true if URL has a safe scheme\n */\nexport function isSafeURL(url: string): boolean {\n  try {\n    const parsed = new URL(url);\n    return parsed.protocol === 'http:' || parsed.protocol === 'https:';\n  } catch {\n    return false;\n  }\n}\n\n/** Result of article HTML validation */\nexport interface ArticleValidationResult {\n  /** Whether the article passes all structural checks */\n  valid: boolean;\n  /** List of missing elements */\n  errors: readonly string[];\n}\n\n/** Required structural elements that every article must contain */\nconst REQUIRED_ARTICLE_ELEMENTS: ReadonlyArray<{\n  selector: string | readonly string[];\n  label: string;\n}> = [\n  {\n    selector: ['class=\"site-header__langs\"', 'class=\"language-switcher\"'],\n    label: 'language switcher nav',\n  },\n  { selector: 'class=\"article-top-nav\"', label: 'article-top-nav (back button)' },\n  { selector: 'class=\"site-header\"', label: 'site-header' },\n  { selector: 'class=\"skip-link\"', label: 'skip-link' },\n  { selector: 'class=\"reading-progress\"', label: 'reading-progress bar' },\n  { selector: '<main id=\"main\"', label: 'main content wrapper' },\n  { selector: 'class=\"site-footer\"', label: 'site-footer' },\n] as const;\n\n/**\n * Validate that generated article HTML includes all required structural elements.\n *\n * This is the primary validation gate — articles must be generated correctly\n * by the template. The fix-articles script is only a fallback for legacy articles.\n *\n * @param html - Complete HTML string of the article\n * @returns Validation result with errors list (empty if valid)\n */\nexport function validateArticleHTML(html: string): ArticleValidationResult {\n  const errors: string[] = [];\n\n  for (const element of REQUIRED_ARTICLE_ELEMENTS) {\n    const sel = element.selector;\n    const found = Array.isArray(sel)\n      ? sel.some((s) => html.includes(s))\n      : html.includes(sel as string);\n    if (!found) {\n      errors.push(`Missing required element: ${element.label}`);\n    }\n  }\n\n  return { valid: errors.length === 0, errors };\n}\n\n/**\n * Well-known analysis subdirectories scanned for transparency links.\n * Matches the subdirectory structure created by agentic workflows.\n */\nconst DISCOVERY_SUBDIRS = [\n  'classification',\n  'threat-assessment',\n  'risk-scoring',\n  'existing',\n  'documents',\n  'intelligence',\n] as const;\n\n/**\n * Maps canonical analysis filenames (without `.md`) to their canonical\n * analysis method IDs used by `METHOD_LABEL_MAP` in `article-template.ts`.\n *\n * Per `analysis/README.md`, some canonical filenames differ from the method\n * identifier (e.g. the `stakeholder-analysis` method produces\n * `stakeholder-impact.md`). This mapping ensures localized labels render\n * correctly in the analysis transparency section.\n */\nconst FILENAME_TO_METHOD: Readonly<Record<string, string>> = {\n  'stakeholder-impact': 'stakeholder-analysis',\n  'coalition-dynamics': 'coalition-analysis',\n  'document-analysis-index': 'document-analysis',\n};\n\n/**\n * Resolve the canonical analysis method ID for a given filename (without `.md`).\n *\n * Uses the {@link FILENAME_TO_METHOD} mapping for known mismatches; falls back\n * to the filename itself when no mapping exists.\n *\n * @param baseName - Filename without extension (e.g. `stakeholder-impact`)\n * @returns Canonical method ID (e.g. `stakeholder-analysis`)\n */\nfunction resolveCanonicalMethod(baseName: string): string {\n  return FILENAME_TO_METHOD[baseName] ?? baseName;\n}\n\n/**\n * Discover analysis file entries by scanning the analysis directory on disk.\n *\n * Scans known subdirectories plus root-level `.md` files to produce a\n * complete list of {@link AnalysisFileEntry} objects suitable for the\n * article template's dynamic analysis transparency section.\n *\n * This provides a robust fallback when the manifest.json doesn't contain\n * a standard `methods[]` array (e.g. manifests written by agentic workflows\n * use a different structure).\n *\n * @param analysisDirPath - Absolute path to the analysis directory on disk\n * @returns Array of discovered analysis file entries, or empty array when directory doesn't exist\n */\nexport function discoverAnalysisFileEntries(analysisDirPath: string): AnalysisFileEntry[] {\n  if (!fs.existsSync(analysisDirPath)) return [];\n\n  const entries: AnalysisFileEntry[] = [];\n\n  // Scan known subdirectories\n  for (const subdir of DISCOVERY_SUBDIRS) {\n    scanSubdirectory(path.join(analysisDirPath, subdir), subdir, entries);\n  }\n\n  // Scan root-level .md files (e.g. synthesis-summary.md, weekly-intelligence-brief.md)\n  scanRootMarkdownFiles(analysisDirPath, entries);\n\n  return entries;\n}\n\n/**\n * Scan a single subdirectory for .md files and add them to the entries list.\n *\n * @param subdirPath - Absolute path to the subdirectory\n * @param subdir - Subdirectory name for the output file path prefix\n * @param entries - Mutable array to push discovered entries into\n */\nfunction scanSubdirectory(subdirPath: string, subdir: string, entries: AnalysisFileEntry[]): void {\n  try {\n    if (!fs.existsSync(subdirPath) || !fs.statSync(subdirPath).isDirectory()) return;\n    const files = fs.readdirSync(subdirPath);\n    for (const file of files) {\n      if (!file.endsWith('.md')) continue;\n      const baseName = file.replace(/\\.md$/u, '');\n      entries.push({\n        method: resolveCanonicalMethod(baseName),\n        outputFile: `${subdir}/${file}`,\n      });\n    }\n  } catch {\n    // Skip unreadable directories\n  }\n}\n\n/**\n * Scan root-level .md files in the analysis directory.\n *\n * @param dirPath - Analysis directory path\n * @param entries - Mutable array to push discovered entries into\n */\nfunction scanRootMarkdownFiles(dirPath: string, entries: AnalysisFileEntry[]): void {\n  try {\n    const rootFiles = fs.readdirSync(dirPath);\n    for (const file of rootFiles) {\n      if (!file.endsWith('.md')) continue;\n      const filePath = path.join(dirPath, file);\n      if (!fs.statSync(filePath).isFile()) continue;\n      const baseName = file.replace(/\\.md$/u, '');\n      entries.push({\n        method: resolveCanonicalMethod(baseName),\n        outputFile: file,\n      });\n    }\n  } catch {\n    // Skip if unreadable\n  }\n}\n","usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/generate-docs-index.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/html-sanitize.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/intelligence-index.ts","messages":[],"suppressedMessages":[{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":104,"column":39,"endLine":104,"endColumn":66,"suppressions":[{"kind":"directive","justification":"existingIdx from findIndex"}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":586,"column":17,"endLine":586,"endColumn":28,"suppressions":[{"kind":"directive","justification":"key validated via isSafeKey"}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":589,"column":7,"endLine":589,"endColumn":16,"suppressions":[{"kind":"directive","justification":"key validated via isSafeKey"}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Variable Assigned to Object Injection Sink","line":752,"column":18,"endLine":752,"endColumn":26,"suppressions":[{"kind":"directive","justification":"key validated via isSafeKey"}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":757,"column":14,"endLine":757,"endColumn":22,"suppressions":[{"kind":"directive","justification":"key validated via isSafeKey"}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":760,"column":7,"endLine":760,"endColumn":15,"suppressions":[{"kind":"directive","justification":"key validated via isSafeKey"}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":781,"column":22,"endLine":781,"endColumn":30,"suppressions":[{"kind":"directive","justification":"key validated via isSafeKey"}]},{"ruleId":"security/detect-object-injection","severity":1,"message":"Generic Object Injection Sink","line":784,"column":7,"endLine":784,"endColumn":15,"suppressions":[{"kind":"directive","justification":"key validated via isSafeKey"}]}],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/metadata-utils.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/news-metadata.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]},{"filePath":"/home/runner/work/euparliamentmonitor/euparliamentmonitor/src/utils/validate-ep-api.ts","messages":[],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":[]}]