// Planu — HTML wrapper for per-spec reports (shared CSS + portal navbar)
import { getPortalThemeCSS } from '../portal/portal-theme.js';
import { buildNavbar } from '../portal/portal-navbar.js';
import { buildBreadcrumbs } from '../portal/portal-breadcrumbs.js';
const CSS = `
  @page { margin: 2cm; size: A4; }
  @media print { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: #1f2937; max-width: 960px; margin: 0 auto; padding: 24px; background: #fff; }
  .header { border-bottom: 3px solid #4F46E5; padding-bottom: 16px; margin-bottom: 24px; }
  .header h1 { font-size: 1.1em; color: #6b7280; font-weight: 400; margin-bottom: 4px; }
  .header h2 { font-size: 1.8em; color: #111827; font-weight: 700; }
  .header .meta { margin-top: 8px; font-size: 0.85em; color: #6b7280; }
  .badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.78em; font-weight: 600; }
  .badge-draft { background: #e5e7eb; color: #374151; }
  .section { margin-bottom: 28px; }
  .section h2 { font-size: 1.15em; color: #4F46E5; border-left: 4px solid #4F46E5; padding-left: 10px; margin-bottom: 14px; }
  .section h3 { font-size: 1em; color: #374151; margin: 12px 0 6px; }
  .metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
  .metric-card { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px; text-align: center; }
  .metric-value { font-size: 1.8em; font-weight: 700; color: #4F46E5; line-height: 1; }
  .metric-label { font-size: 0.78em; color: #6b7280; margin-top: 4px; }
  ul { padding-left: 20px; }
  li { margin: 4px 0; }
  code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 0.9em; }
  .diagram-section { margin: 16px 0; }
  .diagram-desc { font-size: 0.85em; color: #6b7280; margin-bottom: 8px; }
  .mermaid { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; }
  .empty { color: #9ca3af; font-style: italic; }
  svg { max-width: 100%; height: auto; }
  .footer { margin-top: 32px; padding-top: 16px; border-top: 1px solid #e5e7eb; font-size: 0.78em; color: #9ca3af; text-align: center; }
`;
/**
 * Wrap body content in a full HTML document with per-spec report CSS + portal navbar.
 * basePath is always "../../" because per-spec reports live in planu/specs/SPEC-XXX/.
 */
export function wrapPerSpecHtml(title, bodyContent, extraScriptsOrOptions) {
    // Backward-compatible: accept plain string (extraScripts) or options object
    let extraScripts;
    let options = {};
    if (typeof extraScriptsOrOptions === 'string') {
        extraScripts = extraScriptsOrOptions;
    }
    else if (extraScriptsOrOptions !== undefined) {
        options = extraScriptsOrOptions;
        extraScripts = options.extraScripts;
    }
    const escapedTitle = title
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;');
    // Per-spec reports are always 2 levels deep: planu/specs/SPEC-XXX/report.html
    const basePath = '../../';
    const navbar = buildNavbar(options.activePage ?? 'dashboard', basePath, options.availablePages);
    const breadcrumbsHtml = options.breadcrumbs && options.breadcrumbs.length > 0
        ? buildBreadcrumbs(options.breadcrumbs)
        : '';
    return `<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>${escapedTitle}</title>
  <style>${getPortalThemeCSS()}${CSS}</style>
</head>
<body>
${navbar}
${breadcrumbsHtml}
${bodyContent}
${extraScripts ?? ''}
</body>
</html>`;
}
//# sourceMappingURL=html-wrapper.js.map