// Optimal Trade App UI Kit — mock data store
const DEMO_ACCOUNTS = [
  { id: "ng", name: "Adaeze Okafor", company: "Okafor Imports Ltd", country: "Nigeria", flag: "ng", ccy: "NGN", sym: "\u20A6", balance: 12480500, role: "Importer" },
  { id: "ke", name: "Daniel Mwangi", company: "Mwangi Trading Co.", country: "Kenya", flag: "ke", ccy: "KES", sym: "KSh", balance: 4120000, role: "Importer" },
  { id: "za", name: "Thabo Nkosi", company: "Nkosi Wholesale", country: "South Africa", flag: "za", ccy: "ZAR", sym: "R", balance: 1875400, role: "Importer" },
];

// indicative rates: 1 unit of local ccy -> USD
const FX = {
  NGN: { usd: 1 / 1512.4, label: "USD / NGN", rate: 1512.4, trend: +0.4 },
  KES: { usd: 1 / 129.2, label: "USD / KES", rate: 129.2, trend: -0.2 },
  ZAR: { usd: 1 / 18.34, label: "USD / ZAR", rate: 18.34, trend: +0.6 },
};
const RATE_PAIRS = [
  { pair: "USD / NGN", rate: 1512.40, trend: +0.4, ccy: "NGN" },
  { pair: "CNY / NGN", rate: 208.65, trend: -0.1, ccy: "NGN" },
  { pair: "AED / NGN", rate: 411.78, trend: +0.2, ccy: "NGN" },
  { pair: "EUR / NGN", rate: 1635.10, trend: +0.5, ccy: "NGN" },
];

const SUPPLIERS = [
  { id: "s1", name: "Shenzhen Optics Co.", country: "China", flag: "cn", cat: "Electronics", rating: 4.9, orders: 218, authorized: true, min: 3000, lead: "18–24 days", img: "warehouse", tags: ["Lenses", "Cameras", "Sensors"], blurb: "OEM optical components & camera modules. Verified exporter since 2016." },
  { id: "s2", name: "Guangzhou Textile Group", country: "China", flag: "cn", cat: "Textiles", rating: 4.7, orders: 540, authorized: true, min: 1500, lead: "20–28 days", tags: ["Cotton", "Apparel", "Fabric"], blurb: "Bulk fabric & finished apparel. MOQ-friendly for African retail." },
  { id: "s3", name: "Dubai AutoParts FZE", country: "UAE", flag: "ae", cat: "Automotive", rating: 4.8, orders: 132, authorized: true, min: 5000, lead: "10–16 days", tags: ["Spares", "Tyres", "Filters"], blurb: "Genuine & aftermarket parts re-exported from Jebel Ali free zone." },
  { id: "s4", name: "Istanbul Home & Living", country: "Turkey", flag: "tr", cat: "Homeware", rating: 4.6, orders: 89, authorized: true, min: 2000, lead: "14–20 days", tags: ["Kitchen", "Decor", "Linens"], blurb: "Premium homeware manufacturer, Bursa & Istanbul facilities." },
  { id: "s5", name: "Ural Steel Export", country: "Russia", flag: "ru", cat: "Industrial", rating: 4.5, orders: 47, authorized: false, min: 12000, lead: "25–35 days", tags: ["Steel", "Pipes", "Alloy"], blurb: "Structural steel & alloy. Awaiting platform authorization." },
  { id: "s6", name: "Rotterdam Agri Trade", country: "Netherlands", flag: "nl", cat: "Agriculture", rating: 4.8, orders: 156, authorized: true, min: 4000, lead: "12–18 days", tags: ["Fertilizer", "Seeds", "Feed"], blurb: "EU-certified agricultural inputs, shipped from Port of Rotterdam." },
];

const CONTRACTS = [
  { id: "OT-2049", supplier: "Shenzhen Optics Co.", flag: "cn", amount: 8200, ccy: "USD", status: "transit", goods: "Camera modules ×400", created: "May 28", incoterm: "FOB Shenzhen" },
  { id: "OT-2041", supplier: "Dubai AutoParts FZE", flag: "ae", amount: 5400, ccy: "USD", status: "pending", goods: "Brake kits ×120", created: "May 30", incoterm: "CIF Lagos" },
  { id: "OT-2033", supplier: "Guangzhou Textile Group", flag: "cn", amount: 3120, ccy: "USD", status: "paid", goods: "Cotton fabric 2,000m", created: "May 21", incoterm: "FOB Guangzhou" },
];

const TX = [
  { id: "t1", type: "invoice", title: "Shenzhen Optics Co.", sub: "Contract OT-2049", amount: -8200, sym: "$", status: "transit", date: "Jun 2" },
  { id: "t2", type: "topup", title: "Top up · Mobile money", sub: "MTN · ****4821", amount: 2000000, sym: "\u20A6", status: "paid", date: "Jun 2" },
  { id: "t3", type: "convert", title: "NGN \u2192 USD", sub: "Rate 1,512.40 · fee 1.2%", amount: 1322, sym: "$", status: "paid", date: "Jun 1" },
  { id: "t4", type: "invoice", title: "Guangzhou Textile Group", sub: "Contract OT-2033", amount: -3120, sym: "$", status: "paid", date: "May 21" },
  { id: "t5", type: "topup", title: "Top up · Bank transfer", sub: "GTBank · ref 99X2", amount: 5000000, sym: "\u20A6", status: "paid", date: "May 20" },
  { id: "t6", type: "convert", title: "NGN \u2192 CNY", sub: "Rate 208.65 · fee 1.0%", amount: 41200, sym: "\u00A5", status: "paid", date: "May 19" },
];

const SHIPMENT_STAGES = [
  { key: "ordered", label: "Contract paid", place: "Lagos · Optimal Trade", icon: "file-text", done: true, ts: "May 28, 14:20" },
  { key: "picked", label: "Picked up at factory", place: "Shenzhen, China", icon: "warehouse", done: true, ts: "May 30, 09:05" },
  { key: "origin-port", label: "Departed origin port", place: "Yantian Port", icon: "ship", done: true, ts: "Jun 1, 22:40" },
  { key: "transit", label: "In ocean transit", place: "Indian Ocean", icon: "ship", done: false, active: true, ts: "ETA Jun 18" },
  { key: "customs", label: "Customs clearance", place: "Apapa, Lagos", icon: "shield-check", done: false, ts: "—" },
  { key: "delivered", label: "Delivered", place: "Your warehouse", icon: "package", done: false, ts: "—" },
];

const TOPUP_METHODS = [
  { id: "bank", label: "Bank transfer", sub: "Local bank · 1–2 hrs", icon: "landmark" },
  { id: "momo", label: "Mobile money", sub: "MTN, Airtel, M-Pesa · instant", icon: "smartphone" },
  { id: "crypto", label: "Crypto / stablecoin", sub: "USDT, USDC · ~10 min", icon: "bitcoin" },
];

const CONVERT_TARGETS = [
  { ccy: "USD", sym: "$", flag: "us", rate: 1512.40, fee: 1.2 },
  { ccy: "CNY", sym: "\u00A5", flag: "cn", rate: 208.65, fee: 1.0 },
  { ccy: "AED", sym: "\u062F.\u0625", flag: "ae", rate: 411.78, fee: 1.1 },
  { ccy: "EUR", sym: "\u20AC", flag: "eu", rate: 1635.10, fee: 1.3 },
];

// Invoice that surfaces as the "To pay" card on home
const TO_PAY = { id: "OT-2041", supplier: "Dubai AutoParts FZE", flag: "ae", amount: 5400, ccy: "USD", sym: "$", goods: "Brake kits \u00D7120", incoterm: "CIF Lagos", due: "Due in 2 days" };

// Unified deals feed (quotes + orders share one thread). kind: quote | order
const ORDERS = [
  { id: "RFQ-118", kind: "quote", title: "Industrial water pumps \u00D750", flag: "cn", status: "offers", statusLabel: "3 offers", sub: "Sent to 4 suppliers \u00B7 2h ago", offers: 3 },
  { id: "RFQ-117", kind: "quote", title: "LED panel lights \u00D7600", flag: "tr", status: "waiting", statusLabel: "Awaiting offers", sub: "Sent to 6 suppliers \u00B7 5h ago", offers: 0 },
  { id: "OT-2041", kind: "order", title: "Brake kits \u00D7120", supplier: "Dubai AutoParts FZE", flag: "ae", amount: 5400, sym: "$", status: "topay", statusLabel: "Awaiting payment", sub: "Pay to start shipment", next: "Pay now \u00B7 due 2 days" },
  { id: "OT-2049", kind: "order", title: "Camera modules \u00D7400", supplier: "Shenzhen Optics Co.", flag: "cn", amount: 8200, sym: "$", status: "transit", statusLabel: "In transit", sub: "Yantian \u2192 Lagos", next: "ETA Jun 18 \u00B7 ocean" },
  { id: "OT-2033", kind: "order", title: "Cotton fabric 2,000m", supplier: "Guangzhou Textile Group", flag: "cn", amount: 3120, sym: "$", status: "delivered", statusLabel: "Delivered", sub: "Apapa, Lagos", next: "Completed May 21" },
];

// AI agent negotiation — three supplier agents responding to one sourcing mission
const AGENT_SUPPLIERS = [
  { id: "a1", name: "Ningbo Pump Works", short: "Ningbo", flag: "cn", rating: 4.9, verified: true, match: 96,
    verdict: "Closest analog", verdictKind: "analog",
    nuance: "Cast-iron impeller upgraded to stainless in negotiation \u00b7 3 minor spec notes",
    offer: { unit: 168, total: 8400, lead: 21, moq: 50, terms: "FOB Ningbo", was: 9000, best: true } },
  { id: "a2", name: "Jebel Ali Industrial FZE", short: "Jebel Ali", flag: "ae", rating: 4.8, verified: true, match: 99,
    verdict: "1:1 match", verdictKind: "exact",
    nuance: "Exact reference model in stock \u00b7 fastest lead, highest price",
    offer: { unit: 189, total: 9450, lead: 12, moq: 40, terms: "CIF Lagos", was: 9450, best: false } },
  { id: "a3", name: "Bursa Makina", short: "Bursa", flag: "tr", rating: 4.6, verified: true, match: 90,
    verdict: "EU-spec analog", verdictKind: "analog",
    nuance: "Higher-efficiency motor (IE3) \u00b7 longer 24-day lead time",
    offer: { unit: 178, total: 8900, lead: 24, moq: 50, terms: "FOB Istanbul", was: 8900, best: false } },
];
const AGENT_MARKET = { scanned: 1240, regions: ["China", "UAE", "Turkey", "EU"], matchedLines: 38, analogs: 2, exact: 1 };

const PROFILE_MENU = [
  { icon: "users", label: "Counterparties", sub: "Your suppliers & directory", to: "counterparties" },
  { icon: "file-text", label: "Documents & receipts", sub: "Contracts, invoices, KYC" },
  { icon: "badge-check", label: "Verification", sub: "Business KYC \u00B7 Verified", badge: "Verified" },
  { icon: "shield", label: "Security", sub: "Biometrics, PIN, devices" },
  { icon: "globe", label: "Language & region", sub: "English \u00B7 Nigeria" },
  { icon: "headphones", label: "Help & support", sub: "Chat with a human" },
];

Object.assign(window, { DEMO_ACCOUNTS, FX, RATE_PAIRS, SUPPLIERS, CONTRACTS, TX, SHIPMENT_STAGES, TOPUP_METHODS, CONVERT_TARGETS, TO_PAY, ORDERS, AGENT_SUPPLIERS, AGENT_MARKET, PROFILE_MENU });
