/* global window */
// Argyle Partners — mock data
// Strings pulled from argyle-partners/brand/strings.json ontology for fidelity.

const POSITIONS = [
  { id: 'cell-01', name: 'Sonora Lithium Carbonate', cls: 'Mining', jx: 'MX · Fideicomiso', symbol: 'SONLI',
    tokens: 12400, nav: 1_489_320, cost: 1_240_000, yieldPct: 8.4, coupon: 31_250, next: 'May 15',
    standing: 'Registered', status: 'Live', trend: [1.00,1.02,1.03,1.06,1.09,1.14,1.16,1.19,1.20] },
  { id: 'cell-02', name: 'Medellín Industrial Park A-3', cls: 'Real Estate', jx: 'CO · Patrimonio Autónomo', symbol: 'MIP3A',
    tokens: 8200, nav: 862_100, cost: 820_000, yieldPct: 7.1, coupon: 14_612, next: 'May 30',
    standing: 'Registered', status: 'Live', trend: [1.00,1.00,1.01,1.02,1.03,1.04,1.04,1.05,1.05] },
  { id: 'cell-03', name: 'Copper Prepay Facility II', cls: 'Commodities', jx: 'MX · Fideicomiso', symbol: 'CUPP2',
    tokens: 5600, nav: 611_240, cost: 560_000, yieldPct: 9.9, coupon: 13_860, next: 'Jun 01',
    standing: 'Registered', status: 'Live', trend: [1.00,1.04,1.06,1.08,1.10,1.07,1.09,1.08,1.09] },
  { id: 'cell-04', name: 'Oaxaca Wind Farm — Phase II', cls: 'Real Estate', jx: 'MX · Fideicomiso', symbol: 'OWF2',
    tokens: 3000, nav: 298_500, cost: 300_000, yieldPct: 6.2, coupon: 4_650, next: 'Jun 15',
    standing: 'Registered', status: 'Dispute Window', trend: [1.00,1.01,1.02,1.01,1.00,0.99,0.99,0.99,1.00] },
  { id: 'cell-05', name: 'Bogotá Pre-IPO Bridge', cls: 'Pre-IPO', jx: 'CO · Patrimonio Autónomo', symbol: 'BPIB',
    tokens: 0, nav: 0, cost: 0, yieldPct: 12.0, coupon: 0, next: '—',
    standing: 'Pending accreditation uplift', status: 'Subscription Open', trend: [1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00,1.00] },
];

const ALLOC_CLASS = [
  { k: 'Mining', v: 45.2, c: 'var(--viz-1)' },
  { k: 'Real Estate', v: 33.1, c: 'var(--viz-4)' },
  { k: 'Commodities', v: 18.5, c: 'var(--viz-3)' },
  { k: 'Pre-IPO Equity', v: 3.2, c: 'var(--viz-5)' },
];
const ALLOC_JX = [
  { k: 'Mexico · Fideicomiso', v: 62.4, c: 'var(--viz-1)' },
  { k: 'Colombia · Patrimonio', v: 33.1, c: 'var(--viz-4)' },
  { k: 'Cayman · SPC', v: 4.5, c: 'var(--viz-6)' },
];
const ALLOC_MATURITY = [
  { k: '< 1 yr',  v: 12.0, c: 'var(--viz-2)' },
  { k: '1–3 yr',  v: 34.0, c: 'var(--viz-1)' },
  { k: '3–5 yr',  v: 28.5, c: 'var(--viz-4)' },
  { k: '5–7 yr',  v: 16.0, c: 'var(--viz-3)' },
  { k: '7+ yr',   v:  9.5, c: 'var(--viz-6)' },
];

// 18 months of NAV, 4 asset classes stacked
const NAV_HISTORY = (() => {
  const months = ['Nov','Dec','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec','Jan','Feb','Mar','Apr'];
  return months.map((m, i) => {
    const base = 2.2 + i * 0.08;
    return {
      m,
      mining:      +(base * 0.45 + Math.sin(i/3) * 0.05).toFixed(2),
      realestate:  +(base * 0.33 + Math.cos(i/4) * 0.03).toFixed(2),
      commodities: +(base * 0.18 + Math.sin(i/2.5) * 0.04).toFixed(2),
      preipo:      +(base * 0.04 + Math.cos(i/5) * 0.02).toFixed(2),
    };
  });
})();

const DISTRIBUTIONS = [
  { date: '2026-04-15', cell: 'SONLI', amount: 31_250, kind: 'Coupon', status: 'Settled', tx: '0x9ac1…4f2b' },
  { date: '2026-04-01', cell: 'MIP3A', amount: 14_612, kind: 'Coupon', status: 'Settled', tx: '0x71e4…a801' },
  { date: '2026-03-15', cell: 'CUPP2', amount: 13_860, kind: 'Coupon', status: 'Settled', tx: '0x3fb8…c220' },
  { date: '2026-03-01', cell: 'OWF2',  amount:  4_650, kind: 'Coupon', status: 'Settled', tx: '0xa904…d1e7' },
  { date: '2026-05-15', cell: 'SONLI', amount: 32_140, kind: 'Coupon', status: 'Scheduled', tx: '—' },
  { date: '2026-05-30', cell: 'MIP3A', amount: 15_012, kind: 'Coupon', status: 'Scheduled', tx: '—' },
  { date: '2026-06-01', cell: 'CUPP2', amount: 14_120, kind: 'Coupon', status: 'Scheduled', tx: '—' },
];

const MILESTONES = [
  { id: 'gate-0341', cell: 'SONLI', title: 'Q2 Production Audit — Sonora', stage: 'Ratification', window: '42h 12m',
    legal: 'signed', treasury: 'signed', tech: 'pending', evidence: 'ipfs://bafy…a3q2', amount: 340_000 },
  { id: 'gate-0339', cell: 'MIP3A', title: 'Tenant Registry Attestation — A-3', stage: 'Evidence Posted', window: '—',
    legal: 'signed', treasury: 'pending', tech: 'pending', evidence: 'ipfs://bafy…kr17', amount: 86_500 },
  { id: 'gate-0337', cell: 'CUPP2', title: 'Copper Prepay — Shipment 4 of 12', stage: 'Ratification', window: '11h 40m',
    legal: 'signed', treasury: 'signed', tech: 'signed', evidence: 'ipfs://bafy…9cz3', amount: 112_000 },
  { id: 'gate-0336', cell: 'OWF2',  title: 'Turbine 11 Commissioning', stage: 'Dispute Window', window: '18h 05m',
    legal: 'signed', treasury: 'signed', tech: 'signed', evidence: 'ipfs://bafy…m8q4', amount: 62_000 },
  { id: 'gate-0335', cell: 'BPIB',  title: 'CIMA Registration — Bogotá Bridge', stage: 'Evidence Posted', window: '—',
    legal: 'pending', treasury: 'pending', tech: 'pending', evidence: 'ipfs://bafy…11nw', amount: 0 },
];

const AUDIT_LOG = [
  { block: 18_440_219, ts: '16:04:22', tx: '0x9ac1…4f2b', kind: 'distribute', actor: 'CouponDistributor', target: 'SONLI', amt: '$31,250' },
  { block: 18_440_218, ts: '16:04:01', tx: '0x71e4…a801', kind: 'attest',     actor: 'Oracle(Tech)',      target: 'gate-0337', amt: '—' },
  { block: 18_440_217, ts: '16:03:52', tx: '0x3fb8…c220', kind: 'attest',     actor: 'Oracle(Treasury)',  target: 'gate-0337', amt: '—' },
  { block: 18_440_217, ts: '16:03:52', tx: '0x3fb8…c221', kind: 'attest',     actor: 'Oracle(Legal)',     target: 'gate-0337', amt: '—' },
  { block: 18_440_216, ts: '16:03:30', tx: '0xa904…d1e7', kind: 'transfer',   actor: 'Wallet(0x34…)',     target: 'MIP3A', amt: '2,400' },
  { block: 18_440_215, ts: '16:03:12', tx: '0x1b22…7e09', kind: 'propose',    actor: 'Partner(0x12…)',    target: 'prop-0104', amt: 'SHARD 1,000' },
  { block: 18_440_212, ts: '16:02:45', tx: '0xc03a…44ee', kind: 'kyc-grant',  actor: 'ParticipantRegistry', target: '0x8a…e1', amt: '—' },
  { block: 18_440_210, ts: '16:02:19', tx: '0xd81f…0ab2', kind: 'subscribe',  actor: 'SubscriptionEscrow', target: 'BPIB', amt: '$250,000' },
  { block: 18_440_208, ts: '16:01:59', tx: '0xe7c2…5f42', kind: 'evidence',   actor: 'Oracle(Legal)',     target: 'gate-0336', amt: 'ipfs://bafy…m8q4' },
  { block: 18_440_205, ts: '16:01:21', tx: '0x0a5b…aa01', kind: 'vote',       actor: 'Partner(0x09…)',    target: 'prop-0103', amt: 'Yes' },
];

const MARKET_CELLS = [
  { sym: 'SONLI', name: 'Sonora Lithium',          nav: 1.201, last: 1.205, ch: +0.012, vol: '412k', bid: 1.203, ask: 1.207, spread: 4 },
  { sym: 'MIP3A', name: 'Medellín Ind. Park A-3',  nav: 1.051, last: 1.048, ch: -0.003, vol: '88k',  bid: 1.046, ask: 1.052, spread: 6 },
  { sym: 'CUPP2', name: 'Copper Prepay II',        nav: 1.091, last: 1.098, ch: +0.022, vol: '210k', bid: 1.095, ask: 1.101, spread: 6 },
  { sym: 'OWF2',  name: 'Oaxaca Wind II',          nav: 0.995, last: 0.991, ch: -0.011, vol: '44k',  bid: 0.989, ask: 0.993, spread: 4 },
  { sym: 'BPIB',  name: 'Bogotá Pre-IPO Bridge',   nav: 1.000, last: 1.004, ch: +0.004, vol: '14k',  bid: 1.000, ask: 1.008, spread: 8 },
];

const ORDERBOOK = {
  bids: [
    { p: 1.203, s: 18_400, t: 18_400 },
    { p: 1.202, s: 12_100, t: 30_500 },
    { p: 1.201, s:  9_800, t: 40_300 },
    { p: 1.200, s: 24_600, t: 64_900 },
    { p: 1.198, s:  6_200, t: 71_100 },
    { p: 1.195, s: 11_400, t: 82_500 },
  ],
  asks: [
    { p: 1.207, s: 14_200, t: 14_200 },
    { p: 1.208, s:  8_700, t: 22_900 },
    { p: 1.210, s: 22_400, t: 45_300 },
    { p: 1.212, s:  5_100, t: 50_400 },
    { p: 1.215, s: 17_800, t: 68_200 },
    { p: 1.220, s:  9_600, t: 77_800 },
  ],
};

const PARTNERS = [
  { name: 'E. Valdés',  role: 'Managing Partner', seniority: 14, units: 1850, vested: 0.92 },
  { name: 'M. Arroyo',  role: 'Origination',      seniority:  9, units: 1200, vested: 0.78 },
  { name: 'R. Cheng',   role: 'Legal · Counsel',  seniority:  7, units:  900, vested: 0.65 },
  { name: 'S. Okafor',  role: 'Treasury',         seniority:  5, units:  700, vested: 0.48 },
  { name: 'L. Moreau',  role: 'Tech · Protocol',  seniority:  3, units:  450, vested: 0.22 },
];

const PROPOSALS = [
  { id: 'prop-0104', title: 'Ratify Q2 Distribution Schedule (SONLI, MIP3A, CUPP2)', tier: 'Strategic', yes: 68, no: 4, quorum: 51, ends: '2d 4h' },
  { id: 'prop-0103', title: 'Admit Founder Token allocation — OWF2 Phase III', tier: 'Strategic', yes: 44, no: 12, quorum: 51, ends: '6d 2h' },
  { id: 'prop-0102', title: 'Waterfall amendment: revise carry gate to 8% preferred', tier: 'Fundamental', yes: 72, no: 18, quorum: 75, ends: '4d 11h' },
];

Object.assign(window, {
  POSITIONS, ALLOC_CLASS, ALLOC_JX, ALLOC_MATURITY, NAV_HISTORY,
  DISTRIBUTIONS, MILESTONES, AUDIT_LOG, MARKET_CELLS, ORDERBOOK,
  PARTNERS, PROPOSALS,
});
