import { useEffect, useMemo, useRef, useState } from "react"; import { categorySummary, evidenceUrl, type ResearchEvidence, type ResearchSnapshot, } from "@/lib/ai-research"; const pageSize = 12; const revenueLabels = { self: "公司披露,待核口径", estimate: "仅第三方估算", unknown: "本轮未找到收入数字" }; const useLabels: Record = { signal: "公司披露信号", estimate: "第三方估算", historical: "历史里程碑", "historical-estimate": "历史估算", excluded: "排除收入比较", scale: "团队规模", funding: "融资", crosscheck: "同一里程碑的其他资料", }; const money = (value: number, unit = "USD") => unit === "USD" ? new Intl.NumberFormat("zh-CN", { style: "currency", currency: "USD", maximumFractionDigits: 0 }).format(value) : `${new Intl.NumberFormat("zh-CN").format(value)} ${unit}`; function External({ url, children }: { url: string; children: React.ReactNode }) { const safe = evidenceUrl(url); return safe ? {children} ↗ : {children}; } function Evidence({ item, prefix = "evidence" }: { item: ResearchEvidence; prefix?: string }) { return
  • {item.id}{item.kind}
    {item.title}

    {item.summary}

    {item.limitation}

    发布:{item.publishedAt ?? "未注明"} 读取:{item.accessedAt}
  • ; } export default function AICompanyResearch() { const [data, setData] = useState(null); const [error, setError] = useState(false); const [attempt, setAttempt] = useState(0); const [query, setQuery] = useState(""); const [category, setCategory] = useState(""); const [cohort, setCohort] = useState(""); const [income, setIncome] = useState(""); const [page, setPage] = useState(0); const [selected, setSelected] = useState(null); const [tab, setTab] = useState<"companies" | "revenue" | "sources" | "reviews">("companies"); const companySection = useRef(null); const detailSection = useRef(null); useEffect(() => { const controller = new AbortController(); fetch("/api/research/ai-companies", { signal: controller.signal, cache: "no-store" }) .then(async (response) => { if (!response.ok) throw new Error("Research unavailable"); const snapshot: ResearchSnapshot = await response.json(); setData(snapshot); }).catch(() => { if (!controller.signal.aborted) setError(true); }); return () => controller.abort(); }, [attempt]); useEffect(() => { if (selected) detailSection.current?.focus(); }, [selected]); const summaries = useMemo(() => data ? categorySummary(data) : [], [data]); const filtered = useMemo(() => data?.companies.filter((c) => { const search = `${c.name} ${c.business} ${c.location ?? ""} ${c.buyer}`.toLocaleLowerCase(); const yearMatch = !cohort || (cohort === "other" ? ![2025, 2026].includes(c.year ?? 0) : c.year === Number(cohort)); return (!category || c.cat === category) && yearMatch && (!income || c.revenueStatus === income) && search.includes(query.trim().toLocaleLowerCase()); }) ?? [], [data, query, category, cohort, income]); if (error) return
    研究数据库暂时不可用。
    ; if (!data) return

    正在读取研究数据库…

    ; const categories = new Map(data.categories.map((c) => [c.id, c])); const selectedCompany = data.companies.find((c) => c.id === selected); const observed = data.observations.filter((o) => ["signal", "estimate"].includes(o.selection)); const revenueCompanies = new Set(observed.map((o) => o.company)).size; const selectedObservations = data.observations.filter((o) => o.company === selected); const selectedEvidenceIds = new Set([ ...(selectedCompany?.evidenceIds ?? []), ...(selectedCompany?.pricingEvidence ? [selectedCompany.pricingEvidence] : []), ...selectedObservations.map((o) => o.evidence), ]); const selectedEvidence = data.evidence.filter((e) => e.companyId === selected || selectedEvidenceIds.has(e.id)); function chooseCategory(id: string) { setCategory(id); setPage(0); setTab("companies"); companySection.current?.scrollIntoView({ behavior: "smooth", block: "start" }); } return
    资料截至 {data.asOf}首批研究 · 持续补全
    {data.companies.length}已收录公司
    {data.categories.length}业务类别
    {revenueCompanies}找到收入信号的公司
    {data.evidence.length}证据记录

    {data.scope}

    数据口径与覆盖限制
      {data.limitations.map((note) =>
    • {note}
    • )}

    来源以 YC、公司官网、投资机构名录与经营案例为主。同一披露的转载不构成独立验证。团队人数包含公司自报的 Team Size,与正式员工口径可能不同。

    业务分类

    点击类别查看对应公司。数量反映本次采集覆盖,不是市场份额。

    {summaries.map((c) => )}

    研究数据

    {([['companies','公司数据'],['revenue','收入观测'],['sources','原始证据'],['reviews','核查记录']] as const).map(([id,label]) => )}
    {tab === "companies" && <>
    {filtered.length} 家匹配公司
    {filtered.slice(page * pageSize, (page + 1) * pageSize).map((c) => )}
    公司分类与经营资料。选择公司名称查看指标和原始证据。
    公司 / 地区业务与买家成立 / 发布组别团队规模收入资料
    {c.location ?? "地区未注明"} {categories.get(c.cat)?.name}

    {c.business}

    买家:{c.buyer}
    {c.cohort}{c.team ?? "未披露"}{c.team !== null && " 人"}{revenueLabels[c.revenueStatus]}
    {!filtered.length &&

    没有匹配公司,请调整筛选条件。

    } {filtered.length > pageSize && } } {tab === "revenue" && <>

    目前找到 {revenueCompanies} 家公司的收入信号。大多是缺少日历时点的历史里程碑,且 ARR 与年化收入尚未统一。领域均值和离散度暂不计算。

    {observed.map((o) =>
    {money(o.value, o.unit)}
    {o.kind} · {useLabels[o.selection]} · {o.timing}
    )}
    {summaries.map((c) => )}
    各领域收入可得性;未建立同期、同龄、同口径比较组
    业务分类公司披露数仅估算数本轮未找到数字同期均值 / 离散度
    {c.self}{c.estimate}{c.unknown}条件不足

    离散度用于筛选值得核查的异常,还需排除公司年龄、口径和披露偏差;不能据此认定财务造假。

    } {tab === "sources" && <>

    来源链接保留原始位置。相同 URL 的记录可能属于同一披露,不能按记录数计算独立证据数量。

      {data.evidence.map((e) => )}
    } {tab === "reviews" &&
      {data.reviews.map((r) =>
    • {r.type}

      {r.company}

      {r.summary}

      {r.handling}

      {r.evidenceIds.map((id) => { const e=data.evidence.find((item) => item.id === id); return e ? {id} : null; })}
    • )}
    }
    {selectedCompany &&

    {selectedCompany.name}

    公司资料入口 {selectedCompany.extraUrl && 额外核验入口}

    主营业务
    {selectedCompany.business}
    样本组别
    {selectedCompany.cohort}
    买家
    {selectedCompany.buyer}
    收费方式
    {selectedCompany.price}
    交付证据
    {selectedCompany.delivery}
    团队口径
    {selectedCompany.teamBasis ?? "本轮未核验人数"}
    技术水平
    尚未独立测试,不据融资或收入作能力排名。
    身份与限制
    {selectedCompany.notes}

    经营指标与排除记录

    {selectedObservations.length ?
    {selectedObservations.map((o) => )}
    指标 / 归属原始数值数据时点用途及限制证据
    {o.kind}{o.scope}{o.bound !== "=" && o.bound}{money(o.value,o.unit)}{o.timing}{useLabels[o.selection] ?? o.selection}{o.reason}{o.evidence}
    :

    本轮尚未找到可记录的量化经营指标。收入保持未知。

    }

    原始证据

      {selectedEvidence.map((e) => )}
    }

    数据版本 {data.version}。当前为首批资料,覆盖、收入定义、财务透明度与商业模式评估将随核验补充。

    ; }