// Changelog — platform release notes

const CL_ENTRIES = [
  {
    date: '2026-04-22', tag: 'PLATFORM', kind: 'shipped',
    title: 'Cross-product entity resolution v2',
    body: 'Lockheed Martin in EdgarWatch now resolves to the same entity_id as Lockheed Martin in SamWatch and LobbyWatch. 2.4M entities canonicalized via CIK, EIN, DUNS, UEI crosswalk. Available on /v1/entity/:id endpoint and via the entity_dossier MCP tool.',
    products: ['platform'],
  },
  {
    date: '2026-04-18', tag: 'EDGARWATCH', kind: 'shipped',
    title: 'Form 4 (insider transactions) coverage',
    body: 'EdgarWatch now ingests Form 4 filings — corporate insider transactions across all reporting issuers. Median latency from SEC publication to enriched record: 38 seconds. New MCP tool: search_form4. Schema added to /docs.',
    products: ['edgarwatch'],
  },
  {
    date: '2026-04-14', tag: 'API', kind: 'changed',
    title: 'Webhook signature scheme upgraded to v2',
    body: 'Webhooks now signed with HMAC-SHA256 (was SHA1). v1 signatures continue to validate until 2026-07-01. New header: X-Firmhound-Signature-256. Verification snippets added in /docs/webhooks for Node, Python, Go.',
    products: ['platform'],
  },
  {
    date: '2026-04-09', tag: 'GRANTSWATCH', kind: 'shipped',
    title: 'Grants.gov v2 endpoint migration',
    body: 'Switched ingest to Grants.gov v2 forecast endpoint. Forecasted opportunities now appear up to 90 days before posting (previously 30). Backfill complete for FY2024-FY2026.',
    products: ['grantswatch'],
  },
  {
    date: '2026-04-02', tag: 'MCP', kind: 'shipped',
    title: 'Streamable HTTP transport',
    body: 'All Firmhound MCP servers now support both stdio and streamable HTTP transports per MCP spec rev 2025-03. HTTP transport unlocks Claude Desktop on iOS and remote agent deployments. Config snippets updated in /mcp.',
    products: ['platform'],
  },
  {
    date: '2026-03-28', tag: 'IRSWATCH', kind: 'shipped',
    title: 'Form 990 enrichment v3',
    body: 'New enrichment pass extracts board members, executive comp top-5, related-org transactions, and program-service revenue line items into structured fields. Backfill complete for tax years 2018-2024.',
    products: ['irswatch'],
  },
  {
    date: '2026-03-21', tag: 'PRICING', kind: 'changed',
    title: 'Annual plans live (-15%)',
    body: 'All standard plans now offer an annual billing toggle with a 15% discount vs. monthly. Existing customers can switch from /pricing or by emailing sales@firmhound.com — no proration headaches.',
    products: ['platform'],
  },
  {
    date: '2026-03-15', tag: 'API', kind: 'fixed',
    title: 'Pagination cursor stability',
    body: 'Fixed an issue where /v1/alerts cursors could return duplicates near the end of result windows when a new alert landed mid-pagination. Cursors are now snapshot-stable for 5 minutes.',
    products: ['platform'],
  },
  {
    date: '2026-03-10', tag: 'CLINICAL', kind: 'shipped',
    title: 'ClinicalTrials.gov full ingest',
    body: 'New product: ClinicalWatch. Full ingest of ClinicalTrials.gov, real-time updates on enrollment changes, status flips, results posting. 487k active trials indexed at launch. clinicalwatch.firmhound.com is live.',
    products: ['clinicalwatch'],
  },
  {
    date: '2026-03-04', tag: 'PLATFORM', kind: 'shipped',
    title: 'Status page with per-product scraper health',
    body: 'New /status page surfaces per-product scrape latency, last successful run, and 30-day uptime. Status feed available as RSS at /status.rss. Also: machine-readable health JSON at /status.json.',
    products: ['platform'],
  },
  {
    date: '2026-02-25', tag: 'EDGARWATCH', kind: 'fixed',
    title: 'Item 5.02 false positive rate down 41%',
    body: 'Re-trained the 8-K Item 5.02 (departure/election/appointment of directors) classifier on 12k labeled examples. Precision improved from 0.86 to 0.94. Recall holds at 0.97.',
    products: ['edgarwatch'],
  },
  {
    date: '2026-02-18', tag: 'API', kind: 'shipped',
    title: 'Bulk Parquet exports (closed beta)',
    body: 'Enterprise customers can now request bulk Parquet exports per product and date range, delivered as presigned R2 URLs. 30-day rolling retention. Email sales@firmhound.com to enable.',
    products: ['platform'],
  },
];

const KIND_COLOR = {
  shipped: { color: 'var(--fh-accent)', glyph: '+' },
  changed: { color: 'var(--fh-ink-2)', glyph: '~' },
  fixed:   { color: 'var(--fh-red)',   glyph: '✓' },
};

const ChangelogPage = () => (
  <PageShell active="About">
    <SectionHead
      kicker="CHANGELOG · WHAT'S NEW"
      title="Every shipped change,"
      em="every fixed bug."
      right="Firmhound versions semver. Anything that affects API contract gets called out. RSS available at firmhound.com/changelog.rss for the patient agents in your system."
    />

    {/* Filter chips */}
    <div style={{ padding: '32px 32px 0', borderBottom: `1px solid ${FH.border}` }}>
      <div style={{ display: 'flex', gap: 24, flexWrap: 'wrap', paddingBottom: 24 }}>
        {[
          ['ALL', null],
          ['SHIPPED', 'shipped'],
          ['CHANGED', 'changed'],
          ['FIXED', 'fixed'],
        ].map(([l, k], i) => (
          <div key={l} style={{
            fontSize: 11, padding: '6px 12px',
            border: `1px solid ${i === 0 ? FH.borderHi : FH.border}`,
            color: i === 0 ? FH.ink : FH.ink2,
            background: i === 0 ? FH.bg2 : 'transparent',
            letterSpacing: '0.14em',
            cursor: 'pointer',
            display: 'inline-flex', gap: 8, alignItems: 'center',
          }}>
            {k && <span style={{color: KIND_COLOR[k]?.color}}>{KIND_COLOR[k]?.glyph}</span>}
            {l}
          </div>
        ))}
        <div style={{ flex: 1 }} />
        <a href="#" style={{
          fontSize: 11, color: FH.accent, letterSpacing: '0.14em', textDecoration: 'none',
          padding: '6px 12px', border: `1px solid ${FH.accent}`,
        }}>RSS ↗</a>
      </div>
    </div>

    {/* Entries — left rail timeline */}
    <div style={{ padding: '0 32px' }}>
      {CL_ENTRIES.map((e, i) => {
        const k = KIND_COLOR[e.kind];
        return (
          <div key={i} style={{
            display: 'grid', gridTemplateColumns: '180px 1fr 280px',
            gap: 32, padding: '36px 0',
            borderBottom: i < CL_ENTRIES.length - 1 ? `1px solid ${FH.border}` : 'none',
          }}>
            {/* Left rail */}
            <div>
              <div style={{ fontFamily: '"JetBrains Mono", monospace', fontSize: 14, color: FH.ink, fontVariantNumeric: 'tabular-nums' }}>{e.date}</div>
              <div style={{ marginTop: 10, display: 'inline-flex', alignItems: 'center', gap: 6,
                fontFamily: '"JetBrains Mono", monospace', fontSize: 10, letterSpacing: '0.18em',
                color: k.color,
              }}>
                <span style={{
                  width: 22, height: 22,
                  border: `1px solid ${k.color}`,
                  display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
                  fontSize: 13,
                }}>{k.glyph}</span>
                {e.kind.toUpperCase()}
              </div>
              <div style={{ marginTop: 10, fontSize: 10, color: FH.ink3, letterSpacing: '0.16em' }}>
                {e.tag}
              </div>
            </div>

            {/* Body */}
            <div>
              <div style={{
                fontFamily: '"Instrument Serif", Georgia, serif',
                fontSize: 32, lineHeight: 1.15, letterSpacing: '-0.015em', color: FH.ink,
                textWrap: 'balance', maxWidth: 600,
              }}>{e.title}</div>
              <div style={{ marginTop: 16, fontSize: 14, color: FH.ink2, lineHeight: 1.65, maxWidth: 640 }}>
                {e.body}
              </div>
            </div>

            {/* Right meta */}
            <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
              {e.products.map(p => (
                <div key={p} style={{
                  fontFamily: '"JetBrains Mono", monospace', fontSize: 11,
                  color: FH.ink2, padding: '6px 10px',
                  border: `1px solid ${FH.border}`, background: FH.bg2,
                  letterSpacing: '0.04em', alignSelf: 'flex-start',
                }}>{p}</div>
              ))}
            </div>
          </div>
        );
      })}
    </div>

    {/* Footer pager */}
    <div style={{ padding: '32px', borderTop: `1px solid ${FH.border}`, display: 'flex', justifyContent: 'space-between' }}>
      <div style={{ fontSize: 11, color: FH.ink3, letterSpacing: '0.16em' }}>
        SHOWING 12 OF 247 ENTRIES · Q1-Q2 2026
      </div>
      <a href="#" style={{ fontSize: 11, color: FH.accent, letterSpacing: '0.16em', textDecoration: 'none' }}>
        OLDER ENTRIES →
      </a>
    </div>
  </PageShell>
);

window.ChangelogPage = ChangelogPage;
