// =========================================================
// Home page — custom hero + agent grid + stats + graph teaser
// =========================================================

const homeAgents = [
  { code: "N25", title: "Pace Agent",          tag: "Specialist", desc: "Predicts the next lap delta given current stint state and tire age.",                    model: "XGBoost · MAE 0.41 s" },
  { code: "N26", title: "Tire Agent",          tag: "Specialist", desc: "Forecasts compound degradation curves with uncertainty bands.",                        model: "TireDegTCN · MC Dropout" },
  { code: "N27", title: "Race Situation",      tag: "Specialist", desc: "Reads the field and estimates overtake / defence probabilities.",                       model: "LightGBM · AUC-PR 0.55" },
  { code: "N28", title: "Pit Strategy",        tag: "Conditional",desc: "Scores undercut and overcut feasibility, estimates pit-stop duration.",                model: "HistGBT · LightGBM" },
  { code: "N29", title: "Radio Agent",         tag: "Specialist", desc: "Parses team radio + race-control messages into structured intents.",                   model: "RoBERTa · SetFit · BERT NER" },
  { code: "N30", title: "RAG Agent",           tag: "Knowledge",  desc: "Retrieves rule-book passages and historical reference races.",                          model: "Qdrant · BGE-M3" },
];

const homeStats = [
  { num: "7",   label: "ML models shipped",         unit: "" },
  { num: "6",   label: "LangGraph sub-agents",       unit: "" },
  { num: "33",  label: "Production notebooks · N06–N34", unit: "" },
  { num: "21",  label: "Thousand laps · 2025 holdout", unit: "k" },
  { num: "0.41", label: "MAE seconds · N06 Pace",     unit: "s" },
  { num: "1",   label: "Thesis · Final-Degree Project", unit: "" },
];

function HomePage({ onNav, onOpenGraph, pagesReady }) {
  return React.createElement("div", { className: "article-enter" },
    // -------------------- HERO --------------------
    React.createElement("section", { className: "home-hero" },
      React.createElement("div", { className: "home-eyebrow" },
        React.createElement("span", { className: "home-eyebrow-bar" }),
        "F1 StratLab · Documentation",
      ),
      React.createElement("h1", { className: "home-h1" },
        "AI for ",
        React.createElement("span", { className: "accent" }, "real-time"),
        " F1 race strategy.",
      ),
      React.createElement("p", { className: "home-sub" },
        "Open-source multi-agent system that fuses seven machine-learning models, six LangGraph sub-agents and one strategy orchestrator into a single Formula 1 strategy recommender. The canonical technical reference for the F1 StratLab codebase, hand-curated alongside ",
        React.createElement("a", { href: "https://deepwiki.com/VforVitorio/F1-StratLab", target: "_blank", rel: "noopener noreferrer", style: { color: "var(--purple-300)" } }, "DeepWiki"),
        " and ",
        React.createElement("a", { href: "https://f1stratlab.com/", target: "_blank", rel: "noopener noreferrer", style: { color: "var(--purple-300)" } }, "the landing site"),
        ".",
      ),
      React.createElement("div", { className: "home-cta-row" },
        React.createElement("button", {
          className: "btn btn-primary",
          onClick: () => onNav("getting-started"),
        },
          "Get started",
          React.createElement(window.Icon, { name: "arrow-right" }),
        ),
        React.createElement("button", {
          className: "btn btn-ghost",
          onClick: () => onNav("architecture"),
        },
          "Architecture tour",
        ),
        React.createElement("a", {
          className: "btn btn-ghost",
          href: "https://github.com/VforVitorio/F1-StratLab",
          target: "_blank",
          rel: "noopener noreferrer",
        },
          React.createElement(window.Icon, { name: "github" }),
          "GitHub",
        ),
      ),
      React.createElement("div", { className: "home-meta" },
        React.createElement("span", null, React.createElement("strong", null, "v1.5.5"), " current release"),
        React.createElement("span", null, "Apache-2.0"),
        React.createElement("span", null, React.createElement("strong", null, "Python 3.10+")),
        React.createElement("span", { style: { display: "inline-flex", alignItems: "center", gap: 6 } },
          React.createElement("span", { className: "pill pill-live" },
            React.createElement("span", { className: "pill-dot" }),
            "Site live",
          ),
        ),
      ),
    ),

    // -------------------- GRAPH TEASER --------------------
    React.createElement("section", { className: "home-section" },
      React.createElement("div", { className: "section-eyebrow" }, "// Knowledge graph"),
      React.createElement("h2", { className: "section-title" }, "Every page, every link"),
      React.createElement("p", { className: "section-sub" },
        "Pages are connected by the cross-references inside them. Click the canvas to open the full Obsidian-style graph view; drag nodes to rearrange; hover to highlight neighbours."),
      React.createElement(window.GraphView, {
        key: pagesReady ? "ready" : "pending",
        mode: "mini",
        onNav: () => onOpenGraph(),
      }),
    ),

    // -------------------- LAYER GRID --------------------
    React.createElement("section", { className: "home-section" },
      React.createElement("div", { className: "section-eyebrow" }, "// The system at a glance"),
      React.createElement("h2", { className: "section-title" }, "Three layers, one race strategy"),
      React.createElement("p", { className: "section-sub" },
        "From raw telemetry to a strategy call. Each layer lives behind a documented contract, so any one can be swapped without disturbing the others."),
      React.createElement("div", { className: "layer-grid" },
        React.createElement("div", { className: "layer-card" },
          React.createElement("div", { className: "layer-card-num" }, "Layer 01"),
          React.createElement("h3", null, "Machine-learning core"),
          React.createElement("p", null, "Seven specialised models cover lap-time prediction, tire degradation, overtake probability, safety-car detection, pit-stop duration, undercut feasibility and circuit clustering."),
        ),
        React.createElement("div", { className: "layer-card" },
          React.createElement("div", { className: "layer-card-num" }, "Layer 02"),
          React.createElement("h3", null, "Multi-agent reasoning"),
          React.createElement("p", null, "Six LangGraph ReAct agents call those models and exchange structured outputs with the N31 Strategy Orchestrator. The orchestrator runs a Monte-Carlo simulation, scores candidate strategies and synthesises a final recommendation."),
        ),
        React.createElement("div", { className: "layer-card" },
          React.createElement("div", { className: "layer-card-num" }, "Layer 03"),
          React.createElement("h3", null, "Operator surfaces"),
          React.createElement("p", null, "Three independent UIs consume the orchestrator: the headless CLI for batch races, the three-window Arcade dashboard for live racing, and the Streamlit web app for race analysis."),
        ),
      ),
    ),

    // -------------------- AGENT GRID --------------------
    React.createElement("section", { className: "home-section" },
      React.createElement("div", { className: "section-eyebrow" }, "// Meet the agents"),
      React.createElement("h2", { className: "section-title" }, "Six specialists feed the orchestrator"),
      React.createElement("p", { className: "section-sub" },
        "Each one wraps a single ML model behind a LangGraph ReAct loop and emits a strictly-typed payload the orchestrator can fuse."),
      React.createElement("div", { className: "agent-grid" },
        homeAgents.map(a =>
          React.createElement("div", {
            key: a.code,
            className: "agent-card",
            onClick: () => onNav("multi-agent"),
          },
            React.createElement("div", { className: "agent-card-tag" },
              React.createElement("span", { className: "agent-card-code" }, a.code),
              React.createElement("span", null, a.tag),
            ),
            React.createElement("h4", null, a.title),
            React.createElement("p", null, a.desc),
            React.createElement("div", { className: "agent-card-meta" },
              React.createElement("strong", null, "Model"),
              "  ·  " + a.model,
            ),
          )
        )
      ),
    ),

    // -------------------- STAT GRID --------------------
    React.createElement("section", { className: "home-section" },
      React.createElement("div", { className: "section-eyebrow" }, "// By the numbers"),
      React.createElement("h2", { className: "section-title" }, "Evidence over adjectives"),
      React.createElement("p", { className: "section-sub" },
        "Every capability ships with a metric or an artifact path. See ",
        React.createElement("a", {
          href: "#/thesis", onClick: e => { e.preventDefault(); onNav("thesis"); },
          style: { color: "var(--purple-300)" },
        }, "Thesis results"),
        " for the full benchmark table."),
      React.createElement("div", { className: "stat-grid" },
        homeStats.map((s, i) =>
          React.createElement("div", { key: i, className: "stat-cell" },
            React.createElement("div", { className: "stat-cell-num" },
              s.num,
              s.unit && React.createElement("span", { className: "unit" }, s.unit),
            ),
            React.createElement("div", { className: "stat-cell-label" }, s.label),
          )
        )
      ),
    ),

    // -------------------- CTA STRIP --------------------
    React.createElement("section", { className: "cta-strip" },
      React.createElement("div", { className: "cta-strip-text" },
        React.createElement("h3", null, "Three console scripts. One wheel. No GPU required."),
        React.createElement("p", null, "Install the release wheel and pick the surface that fits your workflow — headless CLI, Arcade dashboard, or Streamlit. First boot caches the models locally; subsequent runs are offline."),
      ),
      React.createElement("button", {
        className: "btn btn-primary",
        onClick: () => onNav("getting-started"),
      },
        "Read the install guide",
        React.createElement(window.Icon, { name: "arrow-right" }),
      ),
    ),

    // -------------------- MEET THE AUTHOR --------------------
    React.createElement("section", { className: "stratlab-author" },
      React.createElement("div", { className: "stratlab-author-row" },
        React.createElement("img", {
          className: "stratlab-author-avatar",
          src: "https://avatars.githubusercontent.com/u/117594428?v=4",
          alt: "VforVitorio",
          width: 88,
          height: 88,
          loading: "lazy",
        }),
        React.createElement("div", { className: "stratlab-author-body" },
          React.createElement("div", { className: "section-eyebrow" }, "// Meet the author"),
          React.createElement("h3", { className: "stratlab-author-name" }, "VforVitorio"),
          React.createElement("p", { className: "stratlab-author-bio" },
            "AI & Data Intern at NTT DATA Spain. 4th-year Intelligent Systems Engineering at UIE Campus Coruña. Building AI for Formula 1 — from telemetry modelling to multi-agent reasoning."
          ),
          React.createElement("div", { className: "stratlab-author-links" },
            React.createElement("a", {
              className: "stratlab-author-card",
              href: "https://victorvegasobral.com",
              target: "_blank",
              rel: "noopener noreferrer",
            },
              React.createElement(window.Icon, { name: "external", width: 14, height: 14 }),
              React.createElement("span", null, "Portfolio"),
            ),
            React.createElement("a", {
              className: "stratlab-author-card",
              href: "https://github.com/VforVitorio",
              target: "_blank",
              rel: "noopener noreferrer",
            },
              React.createElement(window.Icon, { name: "github", width: 14, height: 14 }),
              React.createElement("span", null, "GitHub"),
            ),
            React.createElement("a", {
              className: "stratlab-author-card",
              href: "https://www.linkedin.com/in/victorvegasobral/",
              target: "_blank",
              rel: "noopener noreferrer",
            },
              React.createElement(window.Icon, { name: "external", width: 14, height: 14 }),
              React.createElement("span", null, "LinkedIn"),
            ),
            React.createElement("a", {
              className: "stratlab-author-card stratlab-author-card-primary",
              href: "#/meet-the-author",
              onClick: e => { e.preventDefault(); onNav("meet-the-author"); },
            },
              React.createElement("span", null, "Full bio"),
              React.createElement(window.Icon, { name: "arrow-right", width: 14, height: 14 }),
            ),
          ),
        ),
      ),
    ),
  );
}

window.HomePage = HomePage;
