/* global React */
// ============================================================
// Get introduced — sample data for the OfferRoom Network feature.
// Provider-agnostic, OfferRoom-shaped objects (the graph engine is
// swappable). Conceptual shapes: PathTarget, IntroPath, OutreachThread.
//
// Path strength is a 0-100 score. Degrees: 1 = direct, 2 = one-hop warm
// intro, 3 = two-person individual chain, 0 = no path. The four personas are
// hiring manager, recruiter, peer, senior leader.
// ============================================================

// ---- Connected accounts (the sync prerequisite, case G1) ----
const NET_ACCOUNTS = [
  { id: "linkedin", label: "LinkedIn", sub: "1,284 connections mapped", icon: "link", tone: "slate" },
  { id: "gmail", label: "Gmail", sub: "Threads and meetings scanned", icon: "inbox", tone: "cardinal" },
  { id: "calendar", label: "Calendar", sub: "Past meetings matched to people", icon: "calendar", tone: "ochre" },
];

// Two network postures, toggled by the Tweaks "Network" control.
const NET_STRENGTH = {
  strong: {
    label: "Strong", tone: "sage",
    connections: 1284, companies: 4, alumni: 213,
    note: "Your network reaches 4 of your 6 target companies. Most paths are one warm intro away.",
  },
  weak: {
    label: "Thin", tone: "ochre",
    connections: 86, companies: 1, alumni: 12,
    note: "Too few paths yet. Connect another account or invite a few people to widen your reach.",
  },
};

// ---- The four persona slots (the product opinion: who's worth reaching) ----
const PERSONA_DEFS = [
  { key: "hm", label: "Hiring manager", icon: "target", blurb: "Likely owner of this role" },
  { key: "recruiter", label: "Recruiter", icon: "inbox", blurb: "Talent partner for the team" },
  { key: "peer", label: "Peer in the role", icon: "contacts", blurb: "Same team, your level" },
  { key: "leader", label: "Senior leader", icon: "briefcase", blurb: "Skip-level, sets the bar" },
];

// Proof copy is rendered verbatim. type drives icon + tone.
//   overlap (shared employer) · alumni (school) · connection (LinkedIn) · meetings (gmail/cal) · group
const mkProof = (type, text) => ({ type, text });

// ---- Stripe: the hero target. Persona board with best path + alternates. ----
// hm is intentionally UNCERTAIN -> falls back to "Department leaders" (the
// decided behaviour when the exact hiring manager can't be inferred).
const STRIPE_PERSONAS = {
  hm: {
    uncertain: true,
    note: "Exact hiring manager unconfirmed for this role. These two lead the Payments product org.",
    leaders: [
      {
        target: { name: "Priya Raman", title: "Director of Product, Payments", co: "Stripe", tone: "slate" },
        degree: 2, score: 78, introducer: { name: "Jordan Mehta", title: "PM at Ramp, ex-Plaid" },
        proof: [mkProof("connection", "You and Jordan Mehta have been 1st-degree since 2021"), mkProof("meetings", "Jordan and Priya worked together at Square")],
        alternates: 1,
        draft: {
          channel: "Intro request to Jordan Mehta",
          note: "Hi Jordan, hope the new role's going well. I'm focused on senior payments PM roles and Stripe's team is top of my list. You're connected to Priya Raman, who leads product there. Would you be up for a quick intro? Happy to send a short note you can forward.",
          blurb: "Maya is a senior PM with six years on checkout conversion, most recently at Plaid (40+ experiments, +18% conversion). She's looking at Stripe's payments org and would value 15 minutes with Priya.",
        },
      },
      {
        target: { name: "Daniel Levy", title: "Group PM, Checkout", co: "Stripe", tone: "slate" },
        degree: 2, score: 61, bridge: "Marcus Webb",
        proof: [mkProof("connection", "Marcus Webb can pass you on to Daniel")],
        alternates: 0,
      },
    ],
  },
  recruiter: {
    target: { name: "Sofia Nunes", title: "Technical Recruiter, Product", co: "Stripe", tone: "ochre" },
    degree: 2, score: 72, introducer: { name: "Elena Park", title: "Recruiter, ex-Plaid" },
    proof: [mkProof("overlap", "You and Elena Park overlapped at Plaid for 2 years"), mkProof("connection", "Elena and Sofia are 1st-degree")],
    alternates: 2,
    draft: {
      channel: "Intro request to Elena Park",
      note: "Hi Elena, good to be back in touch. I'm applying for the Senior PM, Payments role at Stripe and saw you're connected to Sofia Nunes on the recruiting side. Would you be open to a quick intro? I can send a short note you can forward.",
      blurb: "Maya, senior payments PM, ex-Plaid, applying to the Senior PM, Payments role. Six years on checkout, strong experimentation background. Would value a few minutes with Sofia.",
    },
  },
  peer: {
    target: { name: "Marcus Webb", title: "PM, Payments", co: "Stripe", tone: "sage" },
    degree: 1, score: 94,
    proof: [mkProof("overlap", "You and Marcus overlapped at Plaid for 19 months"), mkProof("meetings", "You've met 4 times, last in February")],
    alternates: 0,
    draft: {
      channel: "Direct message to Marcus Webb",
      note: "Hi Marcus, it's been a while since Plaid. I'm looking hard at senior payments PM roles and Stripe's checkout team is right at the top. Saw you're on Payments there now. Could I borrow 15 minutes to hear how you're finding it, and whether the team's hiring? No pressure either way.",
    },
  },
  leader: {
    target: { name: "Aisha Bello", title: "VP Product", co: "Stripe", tone: "cardinal" },
    degree: 2, score: 58, bridge: "Marcus Webb",
    proof: [mkProof("alumni", "Both Carnegie Mellon, 3 years apart"), mkProof("connection", "Marcus Webb can introduce you to Aisha")],
    alternates: 1,
    draft: {
      channel: "Intro request through Marcus Webb",
      note: "Hi Marcus, hope Stripe's treating you well. I'm focused on senior payments roles and would love to learn how Aisha's org thinks about checkout. Would you feel comfortable introducing us, or pointing me the right way? Happy to send a blurb you can forward.",
      blurb: "Maya is a senior PM, six years on checkout conversion, ex-Plaid. She's exploring Stripe's payments org and would value 15 minutes with Aisha.",
    },
  },
};

// Ramp — Group PM, Payments (drafts generated at runtime via makeDraft).
const RAMP_PERSONAS = {
  hm: {
    target: { name: "Lena Ortiz", title: "Director of Product, Spend", co: "Ramp", tone: "slate" },
    degree: 2, score: 84, introducer: { name: "Jordan Mehta", title: "PM at Ramp, ex-Plaid" },
    proof: [mkProof("overlap", "You and Jordan Mehta overlapped at Plaid for 11 months"), mkProof("connection", "Jordan works closely with Lena")], alternates: 1,
  },
  recruiter: {
    target: { name: "Marco Reyes", title: "Recruiter, Product", co: "Ramp", tone: "ochre" },
    degree: 2, score: 70, introducer: { name: "Jordan Mehta" },
    proof: [mkProof("connection", "Jordan Mehta and Marco are 1st-degree")], alternates: 2,
  },
  peer: {
    target: { name: "Tara Singh", title: "PM, Payments", co: "Ramp", tone: "sage" },
    degree: 1, score: 90,
    proof: [mkProof("connection", "1st-degree since 2020, you've met twice"), mkProof("overlap", "You served on a payments panel together")], alternates: 0,
  },
  leader: {
    target: { name: "Will Chen", title: "VP Product", co: "Ramp", tone: "cardinal" },
    degree: 2, score: 55, bridge: "Tara Singh",
    proof: [mkProof("alumni", "Both Carnegie Mellon"), mkProof("connection", "Tara Singh can introduce you to Will")], alternates: 1,
  },
};

// Linear — Senior PM (HM uncertain -> Department leaders fallback again).
const LINEAR_PERSONAS = {
  hm: {
    uncertain: true,
    note: "Exact hiring manager unconfirmed. These two lead product at Linear.",
    leaders: [
      { target: { name: "Robin Patel", title: "Head of Product", co: "Linear", tone: "slate" }, degree: 2, score: 74, introducer: { name: "Sam Lee", title: "Designer, ex-colleague" }, proof: [mkProof("connection", "You and Sam Lee are 1st-degree"), mkProof("group", "Sam works under Robin")], alternates: 1 },
      { target: { name: "Casey Wu", title: "Group PM", co: "Linear", tone: "slate" }, degree: 2, score: 58, bridge: "Theo Marsh", proof: [mkProof("connection", "Via Theo Marsh, who works with Casey")], alternates: 0 },
    ],
  },
  recruiter: {
    target: { name: "Dana Cole", title: "Talent Partner", co: "Linear", tone: "ochre" },
    degree: 2, score: 52, bridge: "Sam Lee",
    proof: [mkProof("connection", "Sam Lee can introduce you to Dana")], alternates: 1,
  },
  peer: {
    target: { name: "Theo Marsh", title: "Product Manager", co: "Linear", tone: "sage" },
    degree: 2, score: 80, introducer: { name: "Sam Lee" },
    proof: [mkProof("connection", "Sam Lee knows you both well and can introduce you")], alternates: 1,
  },
  leader: {
    target: { name: "Noor Haddad", title: "VP Product", co: "Linear", tone: "cardinal" },
    degree: 2, score: 48, bridge: "Theo Marsh",
    proof: [mkProof("alumni", "Shared a product bootcamp cohort"), mkProof("connection", "Via Theo Marsh, who knows Noor")], alternates: 0,
  },
};

// Per-company "way in" probe summary (the cheap check behind the badge).
// avatars are initials + tone for the stacked faces.
const NET_COMPANIES = {
  stripe: {
    id: "stripe", name: "Stripe", role: "Senior PM, Payments", loc: "SF · Hybrid",
    hasPaths: true, bestScore: 94, count: 9,
    avatars: [{ i: "MW", tone: "sage" }, { i: "SN", tone: "ochre" }, { i: "PR", tone: "slate" }],
    personas: STRIPE_PERSONAS,
  },
  linear: {
    id: "linear", name: "Linear", role: "Senior PM", loc: "Remote",
    hasPaths: true, bestScore: 80, count: 5,
    avatars: [{ i: "TM", tone: "sage" }, { i: "RP", tone: "slate" }],
    personas: LINEAR_PERSONAS,
  },
  ramp: {
    id: "ramp", name: "Ramp", role: "Group PM, Payments", loc: "NYC · Hybrid",
    hasPaths: true, bestScore: 90, count: 6,
    avatars: [{ i: "TS", tone: "sage" }, { i: "LO", tone: "slate" }, { i: "MR", tone: "ochre" }],
    personas: RAMP_PERSONAS,
  },
  figma: {
    id: "figma", name: "Figma", role: "PM, Editor", loc: "SF",
    hasPaths: false, bestScore: 0, count: 0, avatars: [],
  },
};

// Top companies shown on the hub (ranked by best path).
const NET_TOP_COMPANIES = ["stripe", "ramp", "linear", "figma"];

// ---- Person mode directory (Reach a person) ----
const NET_PEOPLE = [
  { name: "Marcus Webb", title: "PM, Payments", co: "Stripe", tone: "sage", degree: 1, score: 94, proof: "Overlapped at Plaid, 19 months" },
  { name: "Devin Ross", title: "Group PM, Checkout", co: "Shopify", tone: "slate", degree: 2, score: 81, proof: "Via Marcus Webb" },
  { name: "Priya Raman", title: "Director of Product, Payments", co: "Stripe", tone: "slate", degree: 2, score: 78, proof: "Via Jordan Mehta" },
  { name: "Sofia Nunes", title: "Technical Recruiter, Product", co: "Stripe", tone: "ochre", degree: 2, score: 72, proof: "Via Elena Park" },
  { name: "Aisha Bello", title: "VP Product", co: "Stripe", tone: "cardinal", degree: 2, score: 58, proof: "Via Marcus Webb" },
  { name: "Hana Kim", title: "Senior PM, Risk", co: "Mercury", tone: "neutral", degree: 0, score: 0, proof: "No path in your network yet" },
];

// ---- Outreach: status flow F4 ----
// requested -> accepted -> intro made -> connected -> replied   (warm intro)
// sent -> opened -> replied                                     (direct / cold)
const INTRO_STEPS = ["Requested", "Accepted", "Intro made", "Connected", "Replied"];
const DIRECT_STEPS = ["Sent", "Opened", "Replied"];

const NET_THREADS = [
  {
    id: "th-aisha", kind: "intro", statusIndex: 2,
    target: { name: "Aisha Bello", title: "VP Product", co: "Stripe", tone: "cardinal" },
    introducer: { name: "Marcus Webb" },
    job: "Senior PM, Payments · Stripe", updated: "1d ago", next: "Follow up Tue if no reply",
    steps: INTRO_STEPS, score: 58,
    timeline: [
      { who: "you", label: "You asked Marcus for an intro", time: "4d ago" },
      { who: "them", label: "Marcus agreed and forwarded your blurb", time: "3d ago" },
      { who: "agent", label: "Offerroom sent Aisha the intro, logged it to Stripe", time: "1d ago" },
    ],
  },
  {
    id: "th-marcus", kind: "direct", statusIndex: 2,
    target: { name: "Marcus Webb", title: "PM, Payments", co: "Stripe", tone: "sage" },
    job: "Senior PM, Payments · Stripe", updated: "3h ago", next: "Marcus replied, draft a response?",
    steps: DIRECT_STEPS, score: 94,
    reply: "Good to hear from you. We're hiring on Payments, let me put you in front of the right people. Free Thursday?",
    timeline: [
      { who: "agent", label: "Offerroom sent your message", time: "2d ago" },
      { who: "them", label: "Marcus opened it", time: "2d ago" },
      { who: "them", label: "Marcus replied", time: "3h ago" },
    ],
  },
  {
    id: "th-sofia", kind: "intro", statusIndex: 0,
    target: { name: "Sofia Nunes", title: "Technical Recruiter", co: "Stripe", tone: "ochre" },
    introducer: { name: "Elena Park" },
    job: "Senior PM, Payments · Stripe", updated: "2h ago", next: "Auto follow-up in 4 days",
    steps: INTRO_STEPS, score: 72,
    timeline: [
      { who: "agent", label: "Offerroom sent Elena the intro request", time: "2h ago" },
    ],
  },
];

// Hub stats (active outreach across all jobs).
const NET_OUTREACH_STATS = [
  { n: "3", label: "active threads", tone: "#4A5868" },
  { n: "2", label: "intros in motion", tone: "#8C1515" },
  { n: "1", label: "reply waiting", tone: "#5A7150" },
  { n: "9", label: "paths found", tone: "#B08A3E" },
];

// Default follow-up cadence (sequence settings F3).
const NET_SEQUENCE = [
  { label: "Initial send", detail: "On your approval", when: "now" },
  { label: "Follow-up 1", detail: "If no reply", when: "in 4 days" },
  { label: "Follow-up 2", detail: "If still no reply", when: "in 9 days" },
];

// No-path fallback angles (case E), shown when a target has degree 0.
const NET_FALLBACKS = [
  { key: "alumni", icon: "graduation", title: "Alumni angle", sub: "Join the Stripe alumni and Carnegie Mellon groups to surface a shared path.", cta: "See alumni groups" },
  { key: "overlap", icon: "layers", title: "Work-overlap angle", sub: "3 people you overlapped with at Plaid are now one step from this team.", cta: "Show overlaps" },
  { key: "cold", icon: "sparkles", title: "Cold, but warmed", sub: "Offerroom drafts a personalized note using shared context, no mutual needed.", cta: "Draft a note" },
  { key: "grow", icon: "userPlus", title: "Grow your network", sub: "Invite 3 former colleagues or sync another account to widen your reach.", cta: "Invite people" },
];

// Per-company "way in" probe for the contextual badge on job-board / tracker
// cards (the cheap check: has_paths, score, count, avatars). Keyed by display
// name. Only Stripe has a full persona board built; the rest tease + route to
// the hub. id is set where a deep-link to a persona board exists.
const NET_PROBES = {
  Stripe:  { name: "Stripe", id: "stripe", hasPaths: true, count: 9, bestScore: 94, avatars: [{ i: "MW", tone: "sage" }, { i: "SN", tone: "ochre" }, { i: "PR", tone: "slate" }] },
  Ramp:    { name: "Ramp", hasPaths: true, count: 6, bestScore: 88, avatars: [{ i: "JM", tone: "sage" }, { i: "AD", tone: "slate" }, { i: "LO", tone: "ochre" }] },
  Brex:    { name: "Brex", hasPaths: true, count: 4, bestScore: 86, avatars: [{ i: "KO", tone: "slate" }, { i: "RT", tone: "sage" }] },
  Linear:  { name: "Linear", hasPaths: true, count: 5, bestScore: 83, avatars: [{ i: "TC", tone: "slate" }, { i: "RK", tone: "sage" }] },
  Shopify: { name: "Shopify", hasPaths: true, count: 3, bestScore: 81, avatars: [{ i: "DR", tone: "slate" }, { i: "EM", tone: "ochre" }] },
  Vercel:  { name: "Vercel", hasPaths: true, count: 3, bestScore: 72, avatars: [{ i: "NG", tone: "sage" }, { i: "SB", tone: "slate" }] },
  Adyen:   { name: "Adyen", hasPaths: true, count: 2, bestScore: 64, avatars: [{ i: "PV", tone: "ochre" }] },
  Mercury: { name: "Mercury", hasPaths: false, count: 0, bestScore: 0, avatars: [] },
  Figma:   { name: "Figma", hasPaths: false, count: 0, bestScore: 0, avatars: [] },
};

Object.assign(window, {
  NET_ACCOUNTS, NET_STRENGTH, PERSONA_DEFS, NET_COMPANIES, NET_TOP_COMPANIES,
  NET_PEOPLE, INTRO_STEPS, DIRECT_STEPS, NET_THREADS, NET_OUTREACH_STATS,
  NET_SEQUENCE, NET_FALLBACKS, NET_PROBES,
});
