// Shared data + helpers — Day Trader persona
const INSTRUMENTS = [
  { sym: 'GOLD',   bid: 2641.10, ask: 2641.30, pct:  1.14, pctDir: 'up',   atr: 18.4, trend: 'up',   newsCount: 4 },
  { sym: 'SILVER', bid: 32.48,   ask: 32.50,   pct:  1.70, pctDir: 'up',   atr: 0.62, trend: 'up',   newsCount: 2 },
  { sym: 'US30',   bid: 42384,   ask: 42386,   pct: -0.29, pctDir: 'down', atr: 312,  trend: 'flat',  newsCount: 6 },
  { sym: 'EUR/USD',bid: 1.0842,  ask: 1.0844,  pct: -0.18, pctDir: 'down', atr: 0.0058, trend: 'down', newsCount: 3 },
];

// Economic calendar events — high impact, today
const CALENDAR_EVENTS = [
  { time: '13:30', label: 'NFP',   impact: 'high',   countdown: '2h 14m', desc: 'US Non-Farm Payrolls · Forecast: 185k · Prior: 177k' },
  { time: '15:00', label: 'FOMC',  impact: 'high',   countdown: '4h 44m', desc: 'FOMC Member Speech · Powell at Chicago Fed' },
  { time: '10:30', label: 'EIA',   impact: 'medium', countdown: 'done',   desc: 'EIA Crude Oil Inventories · Actual: -2.1M bbls' },
];

// Pre-market overnight summary
const OVERNIGHT = [
  { sym: 'GOLD',   move: +1.14, note: 'Broke above 2,630 on weak ADP data' },
  { sym: 'US30',   move: -0.29, note: 'Futures under pressure ahead of NFP' },
  { sym: 'SILVER', move: +1.70, note: 'Following gold, industrial demand bid' },
  { sym: 'EUR/USD',move: -0.18, note: 'USD strength pre-NFP' },
];

// Day Trader feed cards (planning narrative, not PnL flashes)
const TRADERS = [
  { handle: '@rahul_fx',     time: '8m',   sym: 'GOLD',   side: 'buy',  plan: 'Watching GOLD for breakout above 2,650 on NFP. Buy stop 2,652, SL 2,625, TP 2,690. Risking 1%.', sessions: 4, avatar: 'R', avBg: 'linear-gradient(135deg,#F59E0B,#DC2626)' },
  { handle: '@priya_trades', time: '23m',  sym: 'US30',   side: 'sell', plan: 'US30 short setup — rejection at 42,500 resistance. Waiting for confirmation. No trade before NFP.', sessions: 6, avatar: 'P', avBg: 'linear-gradient(135deg,#8B5CF6,#3B82F6)' },
  { handle: '@carlos_xm',   time: '1h',   sym: 'GOLD',   side: 'buy',  plan: 'Same NFP setup worked yesterday. +2.1%. Setting up same structure today, here\'s my chart.', sessions: 5, avatar: 'C', avBg: 'linear-gradient(135deg,#10B981,#059669)' },
];

// Macro channels (read + occasional execute)
const CHANNELS = [
  { name: 'GoldMacro Daily',  type: 'macro',  action: 'plan',    entry: 2652, sl: 2625, tp: 2690, raw: 'XAUUSD buy stop 2652 SL 2625 TP 2690 — NFP breakout play', winRate: 61, avgHold: '2h 20m', subs: 2140, bg: 'linear-gradient(135deg,#F59E0B,#B45309)' },
  { name: 'ForexMacro Pro',   type: 'macro',  action: 'read',    note: 'Bearish bias on strong NFP. Watch 2,620 as support. No trade until data.', winRate: 58, avgHold: '3h 10m', subs: 1840, bg: 'linear-gradient(135deg,#3B82F6,#1E3A8A)' },
  { name: 'DXYWatch',         type: 'macro',  action: 'read',    note: 'DXY breaks 104 = gold bullish. Below 103.5 = gold could run to 2,680.', winRate: 54, avgHold: '4h', subs: 1240, bg: 'linear-gradient(135deg,#8B5CF6,#3B82F6)' },
];

// AI card bullets — "why is gold moving today"
const AI_GOLD_BULLETS = [
  { icon: '📅', text: 'NFP in 2h 14m — gold +0.8% avg on weak NFP historically' },
  { icon: '📉', text: 'DXY at 103.8, near 3-week support — dollar weakness bid' },
  { icon: '🏦', text: 'Powell speech at 15:00 — markets watching for rate cut signals' },
  { icon: '📊', text: 'ADP missed yesterday (+119k vs 145k forecast) — weak jobs trend' },
];

function genSpark(direction = 'up', n = 30) {
  const out = []; let v = 50;
  for (let i = 0; i < n; i++) {
    const bias = direction === 'up' ? 0.6 : 0.4;
    v += (Math.random() - (1 - bias)) * 6;
    out.push(v);
  }
  return out;
}

const fmtMoney = (n, sign = true) => {
  const s = n < 0 ? '-' : (sign ? '+' : '');
  return `${s}$${Math.abs(n).toFixed(2)}`;
};

window.INSTRUMENTS = INSTRUMENTS;
window.CALENDAR_EVENTS = CALENDAR_EVENTS;
window.OVERNIGHT = OVERNIGHT;
window.TRADERS = TRADERS;
window.CHANNELS = CHANNELS;
window.AI_GOLD_BULLETS = AI_GOLD_BULLETS;
window.genSpark = genSpark;
window.fmtMoney = fmtMoney;
