// ReturnScribe — mock data (interactive prototype)
// `cat` is the CategoryIcon symbol used for the merchant-logo fallback.

const RSData = {
  account: { name: 'Daniel Reyes', email: 'dan@reyes.example', plan: 'Max', mailboxes: 2, stores: 12, cards: 2 },

  heroStates: [
    { key: 'saved',  label: 'Saved this year', amount: 1247.83, caption: 'across 23 refunds + 14 cancellations', tone: 'success' },
    { key: 'risk',   label: 'At risk',               amount:  536.90, caption: '3 items · deadlines this week',       tone: 'warning' },
    { key: 'flight', label: 'Active refunds',        amount:  606.00, count: 4, caption: '$606 in flight',            tone: 'accent' },
  ],

  deadlines: [
    { id: 'd1', merchant: 'Patagonia', item: 'Houdini Air Jacket',      amount: 159.00, daysLeft: 2, cat: 'tshirt.fill' },
    { id: 'd2', merchant: 'Best Buy',  item: 'Sony WH-1000XM5',         amount: 348.00, daysLeft: 4, cat: 'headphones' },
    { id: 'd3', merchant: 'Uniqlo',    item: 'Heattech crew (3-pack)',  amount:  29.90, daysLeft: 6, cat: 'tshirt.fill' },
  ],

  inFlight: { count: 4, total: 606.00, recent: ['Allbirds', 'Bose', 'Sephora'] },

  recent: [
    { id: 'r1', merchant: 'Apple',     item: 'AirPods Pro (2nd gen)', amount: 249.00, when: 'Today',     status: 'returnable', cat: 'headphones' },
    { id: 'r2', merchant: 'Patagonia', item: 'Houdini Air Jacket',    amount: 159.00, when: 'Yesterday', status: 'closing',    cat: 'tshirt.fill' },
    { id: 'r3', merchant: 'Allbirds',  item: 'Tree Runners',          amount:  98.00, when: '2d ago',    status: 'in-flight',  cat: 'shoe.fill' },
    { id: 'r4', merchant: 'Uniqlo',    item: 'Heattech crew',         amount:  29.90, when: '3d ago',    status: 'returnable', cat: 'tshirt.fill' },
    { id: 'r5', merchant: 'Sephora',   item: 'Tatcha set',            amount:  89.00, when: '4d ago',    status: 'completed',  cat: 'drop.fill' },
  ],

  // Purchases (Inbox) — each carries full detail for the detail screen
  inbox: [
    { id: 'p1',  merchant: 'Apple',         item: 'AirPods Pro (2nd gen)',          amount: 249.00, currency: 'USD', when: 'Today 4:12 PM',  purchaseDate: 'Jun 7, 2026', returnBy: 'Jul 7, 2026',  windowDaysLeft: 30, windowTotal: 30, status: 'returnable', refundType: 'Original payment', orderId: 'W1234567890', payment: 'Apple Card ••8821', source: 'no_reply@apple.com', cat: 'headphones',
      items: [{ name: 'AirPods Pro (2nd gen)', qty: 1, unit: 249.00 }] },
    { id: 'p2',  merchant: 'Patagonia',     item: 'Houdini Air Jacket — M, Forge',  amount: 159.00, currency: 'USD', when: 'Yesterday',      purchaseDate: 'Jun 1, 2026', returnBy: 'Jun 9, 2026',  windowDaysLeft: 2,  windowTotal: 14, status: 'closing',    refundType: 'Original payment', orderId: 'PAT-4521-8829', payment: 'Visa ••3492', source: 'orders@patagonia.com', cat: 'tshirt.fill',
      items: [{ name: 'Houdini Air Jacket — M, Forge', qty: 1, unit: 159.00 }] },
    { id: 'p3',  merchant: 'Best Buy',      item: 'Sony WH-1000XM5 Headphones',     amount: 348.00, currency: 'USD', when: 'Yesterday',      purchaseDate: 'May 30, 2026', returnBy: 'Jun 14, 2026', windowDaysLeft: 4, windowTotal: 15, status: 'returnable', refundType: 'Store credit', orderId: 'BBY01-806', payment: 'Visa ••3492', source: 'BestBuyInfo@emailinfo.bestbuy.com', cat: 'headphones',
      items: [{ name: 'Sony WH-1000XM5', qty: 1, unit: 348.00 }] },
    { id: 'p4',  merchant: 'Allbirds',      item: 'Tree Runners — 10.5, Charcoal',  amount:  98.00, currency: 'USD', when: '2d ago',         purchaseDate: 'May 20, 2026', returnBy: 'Jun 19, 2026', windowDaysLeft: 5, windowTotal: 30, status: 'in-flight',  refundType: 'Original payment', orderId: 'AB-559210', payment: 'Amex ••1007', source: 'help@allbirds.com', cat: 'shoe.fill',
      items: [{ name: 'Tree Runners — 10.5, Charcoal', qty: 1, unit: 98.00 }] },
    { id: 'p5',  merchant: 'Uniqlo',        item: 'Heattech crew (3-pack)',         amount:  29.90, currency: 'USD', when: '3d ago',         purchaseDate: 'May 18, 2026', returnBy: 'Jun 17, 2026', windowDaysLeft: 23, windowTotal: 30, status: 'returnable', refundType: 'Original payment', orderId: 'UQ-22841', payment: 'Visa ••3492', source: 'order@uniqlo.com', cat: 'tshirt.fill',
      items: [{ name: 'Heattech Crew Neck T', qty: 3, unit: 9.97 }] },
    { id: 'p6',  merchant: 'Sephora',       item: 'Tatcha Dewy Skin set',           amount:  89.00, currency: 'USD', when: '4d ago',         purchaseDate: 'May 15, 2026', returnBy: 'Jun 14, 2026', windowDaysLeft: 20, windowTotal: 30, status: 'refunded',   refundType: 'Original payment', orderId: 'SEP-99120', payment: 'Amex ••1007', source: 'sephora@email.sephora.com', cat: 'drop.fill',
      items: [{ name: 'Tatcha Dewy Skin Cream', qty: 1, unit: 68.00 }, { name: 'The Essence', qty: 1, unit: 21.00 }] },
    { id: 'p7',  merchant: 'REI',           item: 'Yeti Rambler 20 oz',             amount:  35.00, currency: 'USD', when: '5d ago',         purchaseDate: 'May 12, 2026', returnBy: 'Aug 10, 2026', windowDaysLeft: 64, windowTotal: 90, status: 'returnable', refundType: 'Original payment', orderId: 'REI-71820', payment: 'Visa ••3492', source: 'noreply@rei.com', cat: 'cup.and.saucer.fill',
      items: [{ name: 'Yeti Rambler 20 oz', qty: 1, unit: 35.00 }] },
    { id: 'p8',  merchant: 'Trader Joe\u2019s', item: 'Grocery order #4218',        amount:  72.40, currency: 'USD', when: '5d ago',         purchaseDate: 'May 12, 2026', returnBy: '—',            windowDaysLeft: 0,  windowTotal: 0,  status: 'final-sale', refundType: 'Final sale', orderId: 'TJ-4218', payment: 'Visa ••3492', source: 'receipts@traderjoes.com', cat: 'cart.fill',
      items: [{ name: 'Grocery order #4218', qty: 1, unit: 72.40 }] },
    { id: 'p9',  merchant: 'Bose',          item: 'QuietComfort Earbuds II',        amount: 279.00, currency: 'USD', when: '1w ago',         purchaseDate: 'May 5, 2026',  returnBy: 'Jun 4, 2026',  windowDaysLeft: 0,  windowTotal: 30, status: 'in-flight',  refundType: 'Original payment', orderId: 'BOSE-5521', payment: 'Amex ••1007', source: 'orders@bose.com', cat: 'headphones',
      items: [{ name: 'QuietComfort Earbuds II', qty: 1, unit: 279.00 }] },
    { id: 'p10', merchant: 'Glossier',      item: 'You Solid + Generation G',       amount:  46.00, currency: 'USD', when: '1w ago',         purchaseDate: 'May 4, 2026',  returnBy: 'Jun 3, 2026',  windowDaysLeft: 0,  windowTotal: 30, status: 'refunded',   refundType: 'Original payment', orderId: 'GL-88210', payment: 'Visa ••3492', source: 'hello@glossier.com', cat: 'face.smiling.fill',
      items: [{ name: 'You Solid Perfume', qty: 1, unit: 30.00 }, { name: 'Generation G', qty: 1, unit: 16.00 }] },
    { id: 'p11', merchant: 'Amazon',        item: 'Anker 737 Power Bank',           amount:  89.99, currency: 'USD', when: '2w ago',         purchaseDate: 'Apr 24, 2026', returnBy: 'May 24, 2026', windowDaysLeft: 0,  windowTotal: 30, status: 'expired',    refundType: 'Expired', orderId: '112-558210', payment: 'Visa ••3492', source: 'auto-confirm@amazon.com', cat: 'cpu.fill',
      items: [{ name: 'Anker 737 Power Bank (24K mAh)', qty: 1, unit: 89.99 }] },
    { id: 'p12', merchant: 'Chewy',         item: 'Purina Pro Plan (24lb)',         amount:  54.00, currency: 'USD', when: '2w ago',         purchaseDate: 'Apr 22, 2026', returnBy: 'Jul 21, 2026', windowDaysLeft: 44, windowTotal: 90, status: 'returnable', refundType: 'Original payment', orderId: 'CHW-44120', payment: 'Amex ••1007', source: 'service@chewy.com', cat: 'pawprint.fill',
      items: [{ name: 'Purina Pro Plan Adult (24lb)', qty: 1, unit: 54.00 }] },
  ],

  // Subscriptions — tappable rows → detail
  subs: {
    monthly: 247.13,
    annual: 2965.56,
    activeCount: 9,
    groups: [
      { freq: 'MONTHLY', items: [
        { id: 's1', name: 'Spotify Family',     price: 16.99, cadence: 'monthly', next: 'Jun 18', kind: 'active', cat: 'cup.and.saucer.fill', started: 'Mar 2024' },
        { id: 's2', name: 'iCloud+ 2TB',        price:  9.99, cadence: 'monthly', next: 'Jun 22', kind: 'active', cat: 'cpu.fill', started: 'Jan 2023' },
        { id: 's3', name: 'Notion Plus',        price: 12.00, cadence: 'monthly', next: 'Jun 24', kind: 'active', cat: 'book.fill', started: 'Sep 2024' },
        { id: 's4', name: 'ChatGPT Plus',       price: 20.00, cadence: 'monthly', next: 'Jul 2',  kind: 'active', cat: 'sparkles', started: 'Feb 2024' },
        { id: 's5', name: 'Adobe Creative',     price: 59.99, cadence: 'monthly', next: 'Jul 4',  kind: 'trial', trialDaysLeft: 6, cat: 'puzzlepiece.fill', started: 'Jun 2026' },
        { id: 's6', name: 'Figma Pro',          price: 15.00, cadence: 'monthly', next: 'Jul 8',  kind: 'active', cat: 'pencil.and.ruler.fill', started: 'Nov 2024' },
      ]},
      { freq: 'YEARLY', items: [
        { id: 's7', name: 'Things 3',           price: 49.99, cadence: 'yearly', next: 'Aug 11', kind: 'active', cat: 'book.fill', started: 'Aug 2022' },
        { id: 's8', name: '1Password Families', price: 59.88, cadence: 'yearly', next: 'Nov 02', kind: 'active', cat: 'lock', started: 'Nov 2021' },
      ]},
      { freq: 'CANCELLED', items: [
        { id: 's9', name: 'Hulu (No Ads)',      price: 17.99, cadence: 'monthly', next: 'Ended Apr 12', kind: 'cancelled', cat: 'play', started: 'Jan 2023' },
      ]},
    ],
  },

  refunds: [
    { id: 'rf1', merchant: 'Allbirds',  item: 'Tree Runners — 10.5',     amount:  98.00, status: 'ACCEPTED',   step: 3, total: 4, days: 5, cat: 'shoe.fill' },
    { id: 'rf2', merchant: 'Bose',      item: 'QuietComfort Earbuds II', amount: 279.00, status: 'IN TRANSIT', step: 2, total: 4, days: 3, cat: 'headphones' },
    { id: 'rf3', merchant: 'Sephora',   item: 'Tatcha Dewy Skin set',    amount:  89.00, status: 'PROCESSING', step: 4, total: 4, days: 8, cat: 'drop.fill' },
    { id: 'rf4', merchant: 'Nike',      item: 'Pegasus 41 — 11',         amount: 140.00, status: 'INITIATED',  step: 1, total: 4, days: 1, cat: 'figure.run' },
  ],

  refundTypes: ['Original payment', 'Store credit', 'Gift card', 'Exchange'],
  currencies: ['USD', 'EUR', 'GBP', 'CAD'],

  // Two-tier paywall
  plans: {
    max: { id: 'max', name: 'Max',  monthly: 9.99, annual: 99.99, line: 'Unlimited mailboxes · 120-day history', trial: true,  history: '120-day', mailboxes: 'Unlimited' },
    pro: { id: 'pro', name: 'Pro',  monthly: 4.99, annual: 49.99, line: '1 mailbox · 90-day history',           trial: false, history: '90-day',  mailboxes: '1' },
  },

  // mailboxes for the downgrade picker
  mailboxList: [
    { id: 'm1', address: 'dan@reyes.example',        provider: 'Gmail',   count: 84 },
    { id: 'm2', address: 'daniel.work@acme.example', provider: 'Outlook', count: 31 },
  ],
};

window.RSData = RSData;

// Resolve any home/refund row into a full purchase object for the detail screen
window.resolvePurchase = (o) => RSData.inbox.find(p => p.merchant === o.merchant) || {
  id: o.id || 'tmp', merchant: o.merchant, item: o.item, amount: o.amount, currency: 'USD',
  purchaseDate: '—', returnBy: '—', windowDaysLeft: o.daysLeft || 0, windowTotal: o.daysLeft ? 30 : 0,
  status: o.status || 'returnable', refundType: 'Original payment', orderId: '—',
  payment: '—', source: '—', cat: o.cat,
  items: [{ name: o.item, qty: 1, unit: o.amount }],
};
