const IR_D = [
  ["product", "Product", .2, ["Truly Unique, Disruptive or 10X Better", "Solves a Big Problem or Pain Point for Customers", "Wanted or Needed NOW", "Significant Competitive Advantages", "Proof of Customer Traction", "Early Adopters are Evangelists", "Enables or Improves Other Products/Services", "Scalable with Good Margins", "3-5 Year Written Product Roadmap", "Launch Lead and Make vs Buy Analysis"]],
  ["market", "Market", .2, ["Total Addressable Market (TAM) > $100M", "Serviceable Addressable Market (SAM) Clearly Identified", "Demographics, Geographics, Psychographics are Mapped", "Unique Insight of Market Opportunity Articulated", "Entire Market Landscape Researched", "Top Competitors Researched and Shopped", "Enables or Improves Other Products/Services", "Key Influencers Identified and Consulted", "Customer Acquisition and Retention Metrics Created", "Go-to-Market and Grow Market Plan Written"]],
  ["team", "Team", .3, ["Core Team is Full-Time", "Core Team has Identified Skill and Talent Gaps", "Team Has Engaged Professional Advisers and Mentors", "Core Team and New Hires Have Breadth and Depth", "Team is Driven", "Team Has History Together", "Team is Balanced", "All Core Team Has Signed Restricted Stock and Vesting Agreement", "Team is Coalescing Around a Special Culture", "Core Team Can Pass Background Check"]],
  ["strategy", "Strategy", .1, ["Clear Strategy for Gaining and Maintaining a Foothold", "Strategy Captures Market Share that Can be Defended", "Motivates Customers to Switch from Competitive Solutions", "Easy Adoption is Central to the Strategy", "Leverages Growth Hacking and Actionable Metrics", "Creates Product Evangelists and Brand Ambassadors", "Creates Continuous Product/Service Innovation", "Has a Strong Branding Component", "Leverages Existing Sales and Distribution Channels", "Invites Strategic Partnerships"]],
  ["economics", "Economics", .2, ["One Crystal Clear Flagship Business Model", "Business Model Canvas Charted", "Revenue Stream is Scalable and Repeatable", "Top Line Revenue Assumptions are Achievable", "Costs are Mostly Variable", "Capital Required to Reach Breakeven is Charted", "Valuation and Terms of Investment are Reasonable", "Founders Focused on Approaching the Right Investors", "Founders Understand Investor ROI and Timeline Requirements", "Company Leadership Prepared for Investor Relations"]],
];

function ReadinessCalc() {
  const [sc, setSc] = React.useState(() => Object.fromEntries(IR_D.map(d => [d[0], Array(10).fill(null)])));
  const [tab, setTab] = React.useState("product");
  const done = IR_D.reduce((a, d) => a + sc[d[0]].filter(x => x !== null).length, 0);
  const r = React.useMemo(() => {
    if (done < 50) return null;
    let fin = 0; const dims = {};
    for (const [k, name, w, cr] of IR_D) {
      const s = sc[k], avg = s.reduce((a, b) => a + b, 0) / 10, wt = avg * w; fin += wt;
      const c = cr.map((n, i) => ({ n, s: s[i] })), so = [...c].sort((a, b) => a.s - b.s);
      dims[k] = { name, w, avg: Math.round(avg * 100) / 100, wt: Math.round(wt * 100) / 100, c, weak: so.slice(0, 2), strong: so.slice(-2).reverse() };
    }
    const assess = fin >= 8.5 ? "Exceptional — likely to attract top-tier investors" : fin >= 7 ? "Strong — well-positioned for fundraising" : fin >= 5.5 ? "Moderate — address key gaps before raising" : fin >= 4 ? "Weak — significant preparation needed" : "Not ready — fundamental gaps to address first";
    const arr = Object.values(dims);
    return { fin: Math.round(fin * 100) / 100, assess, dims, low: [...arr].sort((a, b) => a.avg - b.avg)[0].name, high: [...arr].sort((a, b) => b.avg - a.avg)[0].name };
  }, [sc, done]);
  const cur = IR_D.find(d => d[0] === tab);
  return (
    <div className="cx-stack">
      <div className="cx-split">
        <Box title="Score Your Startup" sub={'Score each criterion from 1 (poor) to 10 (very strong). Avoid giving scores of 5 and 6 — they are "fudge numbers."'}>
          <div className="ir-tabs" role="tablist">{IR_D.map(([k, n, w]) => { const c = sc[k].filter(x => x !== null).length; return <button key={k} type="button" role="tab" aria-selected={tab === k} className={tab === k ? "on" : c === 10 ? "done" : ""} onClick={() => setTab(k)}><b>{n}</b><small>{(w * 100).toFixed(0)}% · {c}/10</small></button>; })}</div>
          <ul className="cx-list">{cur[3].map((q, i) => <li key={tab + i} className="q"><p>{q}</p><Rate max={10} label={q} value={sc[tab][i]} set={n => setSc(p => ({ ...p, [tab]: p[tab].map((x, j) => j === i ? n : x) }))} /></li>)}</ul>
          <div className="cx-pad ir-nav" style={{ borderTop: "1px solid var(--border-subtle)" }}>
            <span className="cx-lb">{done} / 50 scored</span>
            {IR_D.findIndex(d => d[0] === tab) < 4 && <button type="button" className="cx-btn-s" onClick={() => setTab(IR_D[IR_D.findIndex(d => d[0] === tab) + 1][0])}>Next: {IR_D[IR_D.findIndex(d => d[0] === tab) + 1][1]}<Icon name="ArrowRight" size={15} /></button>}
          </div>
        </Box>
        <div className="cx-stick">
          <Box title="Results" right={<PdfButton ready={!!r} />}>
            {!r ? <Empty>Enter scores (1-10) for all 50 criteria to see the calculated results.<br /><b style={{ color: "var(--accent-primary)" }}>{done} / 50 scored</b></Empty> : <>
              <div className="cx-sum"><Gauge pct={r.fin / 10} label={r.fin + ""} sub="out of 10" /><div className="t"><span className="cx-lb">Assessment</span><b>{r.assess}</b></div></div>
              <div className="cx-mini"><span className="cx-lb">Dimension Scores</span>{IR_D.map(([k]) => { const d = r.dims[k]; return <div key={k} className="row"><span>{d.name} ({(d.w * 100).toFixed(0)}%)</span><span className="tr"><i style={{ width: d.avg * 10 + "%" }}></i></span><b>{d.avg} → {d.wt}</b></div>; })}</div>
              <Cells cols={2}><Res label="Strongest Dimension" value={r.high} /><Res label="Weakest Dimension" value={r.low} /></Cells>
            </>}
          </Box>
        </div>
      </div>
      {r && <div className="ir-grid">{IR_D.map(([k]) => { const d = r.dims[k]; return (
        <Box key={k} title={d.name + " Criteria"} right={<span className="fs-pct">{d.avg} / 10</span>}>
          <ul className="cx-list ir-c">{d.c.map((c, i) => <li key={i}><span>{c.n}</span><b className={c.s >= 8 ? "g" : c.s <= 3 ? "r" : ""}>{c.s}</b></li>)}</ul>
          <Cells cols={2}>
            <div className="cx-res"><span className="cx-lb">Weakest</span><div className="cx-tags">{d.weak.map((w, i) => <span key={i} className="cx-tag r">{w.n}: {w.s}</span>)}</div></div>
            <div className="cx-res"><span className="cx-lb">Strongest</span><div className="cx-tags">{d.strong.map((w, i) => <span key={i} className="cx-tag g">{w.n}: {w.s}</span>)}</div></div>
          </Cells>
        </Box>
      ); })}</div>}
    </div>
  );
}

mountCalc(
  <CalcPage slug="investor-readiness-scorecard" title="Investor Readiness" hl="Scorecard"
    lead={<><strong>Investor readiness</strong> goes beyond having a pitch deck. This comprehensive scorecard evaluates your startup across 5 weighted dimensions — Product (20%), Market (20%), Team (30%), Strategy (10%), and Economics (20%) — with 10 criteria each, for a total of 50 scoring points. Based on the proven Startup Scorecard methodology used by angel groups and VCs.</>}
    how={<>
      <h2>Understanding the Investor Readiness Scorecard</h2>
      <p><strong>The Startup Scorecard</strong> is a structured evaluation framework used by angel investor groups and VCs to objectively assess startup investment readiness. It breaks down the assessment into 5 weighted dimensions with 10 criteria each, producing a final score on a 1-10 scale.</p>
      <p><strong>Team (30% weight)</strong> is the most heavily weighted dimension because investors consistently cite the founding team as the single most important factor in early-stage investing. Criteria include full-time commitment, skill gaps identification, advisor engagement, team depth, drive, shared history, balance, vesting agreements, culture, and background check readiness.</p>
      <p><strong>Product and Market (20% each)</strong> evaluate whether you have built something truly differentiated that addresses a large, well-understood market. Product criteria include uniqueness, problem-solution fit, urgency, competitive advantages, traction, evangelism, platform potential, scalability, roadmap, and build-vs-buy analysis. Market criteria cover TAM, SAM, demographics, market insight, landscape research, competitor analysis, influencer engagement, acquisition metrics, and go-to-market plans.</p>
      <p><strong>Economics (20% weight)</strong> assesses business model clarity, canvas documentation, revenue scalability, achievable assumptions, cost structure, breakeven planning, reasonable valuations, investor targeting, ROI understanding, and investor relations preparedness.</p>
      <p><strong>Strategy (10% weight)</strong> evaluates your go-to-market approach including foothold strategy, market defense, switching motivation, adoption ease, growth hacking, evangelism, innovation pipeline, branding, channel leverage, and partnership strategy.</p>
    </>}>
    <ReadinessCalc />
  </CalcPage>
);
