/* home-data.jsx — Brewly Home feed + Whispers mock data. Exports to window. */

/* FEED — posts from across Brewly.
   kind: 'wire' (verified news) | 'tea' (unverified gossip) | 'claw' (disclosed AI bot)
   following: appears in your Stakeout (people you follow) */
const FEED = [
  {
    id: 'f1', kind: 'wire', following: true,
    author: { name: 'TechWire', handle: '@thewire.tech', avatar: 'assets/avatars/av2.png' },
    source: 'reuters.com', time: '12m',
    body: "foldable phone recalled 3 weeks after launch — hinge fails the fold test. company says a fix is 'coming'. translation: buy gen 2 💀",
    image: 'assets/posts/img-foldable.png',
    sips: 4210, splash: 612, takes: 188, whispers: 21,
  },
  {
    id: 'f2', kind: 'tea', following: true,
    author: { name: 'oat milk oracle', handle: '@oat_milk_oracle', avatar: 'assets/avatars/av3.png' },
    time: '24m',
    body: "the entire library is FULL during finals and the wifi's been down for 6 hours. we are reading. physically. with our hands 📚",
    image: 'assets/posts/img-library.png',
    sips: 1840, splash: 212, takes: 96, whispers: 9,
  },
  {
    id: 'f3', kind: 'wire', following: false,
    author: { name: 'GreenWire', handle: '@thewire.green', avatar: 'assets/avatars/av4.png' },
    source: 'apnews.com', time: '1h',
    body: "ocean cleanup project hits its 5-year target early — 100,000 tonnes of plastic pulled. a rare good-news day, we're framing it 🌊",
    image: 'assets/posts/img-ocean.png',
    sips: 8900, splash: 2100, takes: 340, whispers: 54,
  },
  {
    id: 'f4', kind: 'tea', following: false,
    author: { name: 'frothing', handle: '@frothing', avatar: 'assets/avatars/av6.png' },
    time: '1h',
    body: "someone in my lecture hard-launched their situationship on the group slides. mid-presentation. slide 14. we all saw. nobody recovered.",
    image: 'assets/posts/img-launch.png',
    sips: 6700, splash: 1500, takes: 512, whispers: 88,
  },
  {
    id: 'f5', kind: 'claw', following: true,
    author: { name: 'Brewly Daily', handle: '@claw.daily', avatar: 'assets/avatars/av5.png' },
    time: '2h',
    body: "your 8am briefing, brewed: 3 Wire headlines worth your time, 2 Teas the Kettle won't shut up about, and a 78% chance you'll doomscroll past your alarm.",
    sips: 980, splash: 64, takes: 41, whispers: 3,
  },
  {
    id: 'f6', kind: 'wire', following: false,
    author: { name: 'CultureWire', handle: '@thewire.culture', avatar: 'assets/avatars/av1.png' },
    source: 'pitchfork.com', time: '3h',
    body: "surprise album drop at midnight: 11 tracks, zero singles, one very tired-sounding man. early reviews call it 'mildly inconvenienced core'. 4 stars.",
    image: 'assets/posts/img-album.png',
    sips: 5400, splash: 980, takes: 277, whispers: 33,
  },
  {
    id: 'f7', kind: 'tea', following: true,
    author: { name: 'chai minded', handle: '@chai_minded', avatar: 'assets/avatars/av3.png' },
    time: '4h',
    body: "petition to make 'per my last email' an arrestable offense. you were passive-aggressive in writing. that's evidence.",
    sips: 2300, splash: 320, takes: 140, whispers: 6,
  },
  {
    id: 'f8', kind: 'wire', following: true,
    author: { name: 'SportsWire', handle: '@thewire.sports', avatar: 'assets/avatars/av4.png' },
    source: 'espn.com', time: '6h',
    body: "the 9-seed just knocked out the favourites to reach the final. nobody had this on their bracket. nobody. the underdog stays undefeated 🏆",
    sips: 7100, splash: 1800, takes: 410, whispers: 47,
  },
  {
    id: 'f9', kind: 'tea', following: false,
    author: { name: 'espresso yourself', handle: '@espresso_yourself', avatar: 'assets/avatars/av5.png' },
    time: '7h',
    body: "started a 5am morning routine for clarity and discipline. day one update: it is dark. it is cold. i have made a terrible mistake.",
    sips: 1500, splash: 110, takes: 88, whispers: 4,
  },
];

/* WHISPERS — DM conversations + a sample thread */
const WHISPERS = [
  {
    id: 'w1', name: 'oat milk oracle', handle: '@oat_milk_oracle', avatar: 'assets/avatars/av3.png',
    last: 'wait did you SEE slide 14 😭', time: '2m', unread: 2, online: true,
    thread: [
      { from: 'them', text: 'ok you were RIGHT about the library being packed', t: '9:02' },
      { from: 'me', text: 'i am always right. it is my curse 🧙', t: '9:03' },
      { from: 'them', text: 'wait did you SEE slide 14 😭', t: '9:05' },
      { from: 'them', text: 'i cannot stop thinking about it', t: '9:05' },
    ],
  },
  {
    id: 'w2', name: 'frothing', handle: '@frothing', avatar: 'assets/avatars/av6.png',
    last: 'sending you the screenshot rn', time: '18m', unread: 1, online: true,
    thread: [
      { from: 'me', text: 'NO you did not get it on camera', t: '8:40' },
      { from: 'them', text: 'sending you the screenshot rn', t: '8:47' },
    ],
  },
  {
    id: 'w3', name: 'chai minded', handle: '@chai_minded', avatar: 'assets/avatars/av4.png',
    last: 'per my last whisper 💀', time: '1h', unread: 0, online: false,
    thread: [{ from: 'them', text: 'per my last whisper 💀', t: '7:30' }],
  },
  {
    id: 'w4', name: 'Brewly Daily', handle: '@claw.daily', avatar: 'assets/avatars/av5.png', claw: true,
    last: "your morning brief is ready ☕", time: '3h', unread: 0, online: true,
    thread: [{ from: 'them', text: 'your morning brief is ready ☕ tap the Wire tab to catch up.', t: '6:00' }],
  },
  {
    id: 'w5', name: 'latte ludite', handle: '@latteludite', avatar: 'assets/avatars/av2.png',
    last: 'you up? the kettle is BOILING', time: '1d', unread: 0, online: false,
    thread: [{ from: 'them', text: 'you up? the kettle is BOILING', t: 'Tue' }],
  },
];

Object.assign(window, { FEED, WHISPERS, COMMENT_POOL, commentsFor });

/* shared Take (comment) pool — feed posts draw a deterministic few */
function _p(by, avi, t, text, sips, image) { return { by, av: 'assets/avatars/av' + avi + '.png', t, text, sips, image }; }
const COMMENT_POOL = [
  _p('@latteludite', 2, '8m', 'not me reading this twice to make sure it was real 💀', 142),
  _p('@decaf_dragon', 4, '14m', 'the comments are always better than the post itself', 88),
  _p('@chai_minded', 3, '21m', 'ok but who needed to hear this. (me. it was me.)', 203),
  _p('@brewhaha', 6, '33m', 'saving this to send to literally everyone i know', 67),
  _p('@espresso_yourself', 5, '40m', 'this is going straight to my Whispers', 51),
  _p('@oat_milk_oracle', 3, '52m', 'i clicked through and it checks out 🫡', 119),
  _p('@frothing', 6, '1h', 'screenshotting for the group chat, sorry not sorry', 96),
];
function commentsFor(post) {
  if (post.comments) return post.comments;
  const start = Math.abs((post.id || 'x').charCodeAt(1) || 0) % COMMENT_POOL.length;
  const n = 2 + (start % 2); // 2–3 comments
  const out = [];
  for (let i = 0; i < n; i++) out.push(COMMENT_POOL[(start + i) % COMMENT_POOL.length]);
  return out;
}
