/**
 * Mock visualization data for demo mode (TEC Commons Fund).
 */

import type { TimelineEntry, SankeyData, MultichainData, FlowEntry, TransferRecord } from "./data-transform";
import type { YieldOpportunity } from "./yield-protocols";

// ── Demo yield rates for sandbox mode ──

export const DEMO_YIELD_RATES: YieldOpportunity[] = [
	{ protocol: "morpho-blue", chainId: "8453", asset: "USDC", assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", vaultAddress: "0xc1256Ae5FF1cf2719D4937adb3bbCCab2E00A2Ca", apy: 5.52, tvl: 420_000_000, vaultName: "Moonwell Flagship USDC" },
	{ protocol: "morpho-blue", chainId: "1", asset: "USDC", assetAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", vaultAddress: "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB", apy: 5.23, tvl: 680_000_000, vaultName: "Steakhouse USDC" },
	{ protocol: "morpho-blue", chainId: "1", asset: "USDT", assetAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7", vaultAddress: "0x2371e134e3455e0593363cBF89d3b6cf53740618", apy: 4.87, tvl: 310_000_000, vaultName: "Steakhouse USDT" },
	{ protocol: "aave-v3", chainId: "8453", asset: "USDC", assetAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", vaultAddress: "0x4e65fE4DbA92790696d040ac24Aa414708F5c0AB", apy: 4.12, tvl: 290_000_000 },
	{ protocol: "aave-v3", chainId: "1", asset: "DAI", assetAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F", vaultAddress: "0x018008bfb33d285247A21d44E50697654f754e63", apy: 3.95, tvl: 520_000_000 },
	{ protocol: "aave-v3", chainId: "1", asset: "USDC", assetAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", vaultAddress: "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c", apy: 3.82, tvl: 1_200_000_000 },
	{ protocol: "aave-v3", chainId: "1", asset: "USDT", assetAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7", vaultAddress: "0x23878914EFE38d27C4D67Ab83ed1b93A74D4086a", apy: 3.61, tvl: 890_000_000 },
];

// ── Timeline: ~30 entries over ~2 years ──

function d(y: number, m: number, day: number): Date {
	return new Date(y, m - 1, day);
}

export const DEMO_TIMELINE_DATA: TimelineEntry[] = [
	{ date: d(2024, 1, 15), type: "in", amount: 50000, token: "WXDAI", usd: 50000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", from: "0x1234...abcd", fromFull: "0x1234567890abcdef1234567890abcdef12345678" },
	{ date: d(2024, 1, 28), type: "in", amount: 15, token: "WETH", usd: 37500, hasUsdEstimate: false, chain: "gnosis", chainId: "100", from: "0x2345...bcde", fromFull: "0x234567890abcdef1234567890abcdef123456789" },
	{ date: d(2024, 2, 10), type: "out", amount: 12000, token: "WXDAI", usd: 12000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x3456...cdef", toFull: "0x34567890abcdef1234567890abcdef1234567890" },
	{ date: d(2024, 2, 22), type: "in", amount: 100000, token: "TEC", usd: 1000, hasUsdEstimate: false, chain: "gnosis", chainId: "100", from: "0x4567...def0", fromFull: "0x4567890abcdef1234567890abcdef12345678901" },
	{ date: d(2024, 3, 5), type: "out", amount: 8500, token: "USDC", usd: 8500, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x5678...ef01", toFull: "0x567890abcdef1234567890abcdef123456789012" },
	{ date: d(2024, 3, 18), type: "in", amount: 25000, token: "WXDAI", usd: 25000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", from: "0x6789...f012", fromFull: "0x67890abcdef1234567890abcdef1234567890123" },
	{ date: d(2024, 4, 2), type: "out", amount: 5000, token: "WXDAI", usd: 5000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x7890...0123", toFull: "0x7890abcdef1234567890abcdef12345678901234" },
	{ date: d(2024, 4, 15), type: "in", amount: 3, token: "ETH", usd: 9000, hasUsdEstimate: false, chain: "ethereum", chainId: "1", from: "0x8901...1234", fromFull: "0x890abcdef1234567890abcdef123456789012345" },
	{ date: d(2024, 5, 1), type: "out", amount: 15000, token: "WXDAI", usd: 15000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x9012...2345", toFull: "0x90abcdef1234567890abcdef1234567890123456" },
	{ date: d(2024, 5, 20), type: "in", amount: 200000, token: "GIV", usd: 1000, hasUsdEstimate: false, chain: "gnosis", chainId: "100", from: "0xa012...3456", fromFull: "0xa0abcdef1234567890abcdef1234567890123456" },
	{ date: d(2024, 6, 8), type: "out", amount: 2, token: "WETH", usd: 6000, hasUsdEstimate: false, chain: "gnosis", chainId: "100", to: "0xb123...4567", toFull: "0xb1234567890abcdef1234567890abcdef12345678" },
	{ date: d(2024, 6, 25), type: "in", amount: 30000, token: "WXDAI", usd: 30000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", from: "0xc234...5678", fromFull: "0xc234567890abcdef1234567890abcdef123456789" },
	{ date: d(2024, 7, 10), type: "out", amount: 20000, token: "WXDAI", usd: 20000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0xd345...6789", toFull: "0xd34567890abcdef1234567890abcdef1234567890" },
	{ date: d(2024, 7, 28), type: "in", amount: 10000, token: "USDC", usd: 10000, hasUsdEstimate: true, chain: "optimism", chainId: "10", from: "0xe456...7890", fromFull: "0xe4567890abcdef1234567890abcdef12345678901" },
	{ date: d(2024, 8, 14), type: "out", amount: 7500, token: "USDC", usd: 7500, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0xf567...8901", toFull: "0xf567890abcdef1234567890abcdef123456789012" },
	{ date: d(2024, 9, 1), type: "in", amount: 45000, token: "WXDAI", usd: 45000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", from: "0x1234...abcd", fromFull: "0x1234567890abcdef1234567890abcdef12345678" },
	{ date: d(2024, 9, 18), type: "out", amount: 10000, token: "WXDAI", usd: 10000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x3456...cdef", toFull: "0x34567890abcdef1234567890abcdef1234567890" },
	{ date: d(2024, 10, 5), type: "in", amount: 5, token: "ETH", usd: 12500, hasUsdEstimate: false, chain: "ethereum", chainId: "1", from: "0x8901...1234", fromFull: "0x890abcdef1234567890abcdef123456789012345" },
	{ date: d(2024, 10, 22), type: "out", amount: 18000, token: "WXDAI", usd: 18000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x5678...ef01", toFull: "0x567890abcdef1234567890abcdef123456789012" },
	{ date: d(2024, 11, 8), type: "in", amount: 20000, token: "DAI", usd: 20000, hasUsdEstimate: true, chain: "ethereum", chainId: "1", from: "0x2345...bcde", fromFull: "0x234567890abcdef1234567890abcdef123456789" },
	{ date: d(2024, 11, 25), type: "out", amount: 6000, token: "WXDAI", usd: 6000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x7890...0123", toFull: "0x7890abcdef1234567890abcdef12345678901234" },
	{ date: d(2024, 12, 10), type: "in", amount: 35000, token: "WXDAI", usd: 35000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", from: "0xc234...5678", fromFull: "0xc234567890abcdef1234567890abcdef123456789" },
	{ date: d(2024, 12, 28), type: "out", amount: 22000, token: "WXDAI", usd: 22000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0xd345...6789", toFull: "0xd34567890abcdef1234567890abcdef1234567890" },
	{ date: d(2025, 1, 12), type: "in", amount: 15000, token: "USDC", usd: 15000, hasUsdEstimate: true, chain: "base", chainId: "8453", from: "0xe456...7890", fromFull: "0xe4567890abcdef1234567890abcdef12345678901" },
	{ date: d(2025, 1, 30), type: "out", amount: 9000, token: "WXDAI", usd: 9000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0x9012...2345", toFull: "0x90abcdef1234567890abcdef1234567890123456" },
	{ date: d(2025, 2, 14), type: "in", amount: 40000, token: "WXDAI", usd: 40000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", from: "0x6789...f012", fromFull: "0x67890abcdef1234567890abcdef1234567890123" },
	{ date: d(2025, 2, 28), type: "out", amount: 14000, token: "WXDAI", usd: 14000, hasUsdEstimate: true, chain: "gnosis", chainId: "100", to: "0xf567...8901", toFull: "0xf567890abcdef1234567890abcdef123456789012" },
	{ date: d(2025, 3, 5), type: "in", amount: 8000, token: "USDC", usd: 8000, hasUsdEstimate: true, chain: "arbitrum", chainId: "42161", from: "0xa012...3456", fromFull: "0xa0abcdef1234567890abcdef1234567890123456" },
];

// ── Sankey: mock DAO fund distribution ──

export const DEMO_SANKEY_DATA: SankeyData = {
	nodes: [
		{ name: "Gitcoin Grants", type: "source", address: "0x1234567890abcdef1234567890abcdef12345678" },
		{ name: "Token Bonding", type: "source", address: "0x234567890abcdef1234567890abcdef123456789" },
		{ name: "Community Donations", type: "source", address: "0x34567890abcdef1234567890abcdef1234567890" },
		{ name: "Safe Wallet", type: "wallet", address: "0x29567BdBcC92aCF37AC6B56B69180857bB69f7D1" },
		{ name: "Dev Fund", type: "target", address: "0x4567890abcdef1234567890abcdef12345678901" },
		{ name: "Research Grants", type: "target", address: "0x567890abcdef1234567890abcdef123456789012" },
		{ name: "Operations", type: "target", address: "0x67890abcdef1234567890abcdef1234567890123" },
		{ name: "Community Events", type: "target", address: "0x7890abcdef1234567890abcdef12345678901234" },
	],
	links: [
		{ source: 0, target: 3, value: 85000, token: "WXDAI" },
		{ source: 1, target: 3, value: 120000, token: "TEC" },
		{ source: 2, target: 3, value: 45000, token: "WXDAI" },
		{ source: 3, target: 4, value: 75000, token: "WXDAI" },
		{ source: 3, target: 5, value: 55000, token: "WXDAI" },
		{ source: 3, target: 6, value: 30000, token: "WXDAI" },
		{ source: 3, target: 7, value: 15000, token: "WXDAI" },
	],
};

// ── Multi-chain: mock stats + flows ──

const demoFlowsGnosis: FlowEntry[] = [
	{ from: "0x1234...abcd", to: "Safe Wallet", value: 85000, token: "WXDAI", chain: "gnosis" },
	{ from: "0x2345...bcde", to: "Safe Wallet", value: 37500, token: "WETH", chain: "gnosis" },
	{ from: "0x6789...f012", to: "Safe Wallet", value: 65000, token: "WXDAI", chain: "gnosis" },
	{ from: "Safe Wallet", to: "0x3456...cdef", value: 22000, token: "WXDAI", chain: "gnosis" },
	{ from: "Safe Wallet", to: "0x5678...ef01", value: 26500, token: "USDC", chain: "gnosis" },
	{ from: "Safe Wallet", to: "0xd345...6789", value: 42000, token: "WXDAI", chain: "gnosis" },
];

const demoFlowsEthereum: FlowEntry[] = [
	{ from: "0x8901...1234", to: "Safe Wallet", value: 21500, token: "ETH", chain: "ethereum" },
	{ from: "0x2345...bcde", to: "Safe Wallet", value: 20000, token: "DAI", chain: "ethereum" },
];

export const DEMO_MULTICHAIN_DATA: MultichainData = {
	chainStats: {
		all: { transfers: 28, inflow: "~$330K", outflow: "~$153K", addresses: "14", period: "Jan 2024 - Mar 2025" },
		gnosis: { transfers: 20, inflow: "~$247K", outflow: "~$120K", addresses: "10", period: "Jan 2024 - Feb 2025" },
		ethereum: { transfers: 5, inflow: "~$59K", outflow: "~$0", addresses: "3", period: "Apr 2024 - Nov 2024" },
		optimism: { transfers: 1, inflow: "~$10K", outflow: "~$0", addresses: "1", period: "Jul 2024" },
		base: { transfers: 1, inflow: "~$15K", outflow: "~$0", addresses: "1", period: "Jan 2025" },
		arbitrum: { transfers: 1, inflow: "~$8K", outflow: "~$0", addresses: "1", period: "Mar 2025" },
	},
	flowData: {
		all: [...demoFlowsGnosis, ...demoFlowsEthereum].sort((a, b) => b.value - a.value).slice(0, 15),
		gnosis: demoFlowsGnosis,
		ethereum: demoFlowsEthereum,
		optimism: [{ from: "0xe456...7890", to: "Safe Wallet", value: 10000, token: "USDC", chain: "optimism" }],
		base: [{ from: "0xe456...7890", to: "Safe Wallet", value: 15000, token: "USDC", chain: "base" }],
		arbitrum: [{ from: "0xa012...3456", to: "Safe Wallet", value: 8000, token: "USDC", chain: "arbitrum" }],
	},
	allTransfers: {
		incoming: DEMO_TIMELINE_DATA.filter(t => t.type === "in").map(t => ({
			chainId: t.chainId, chainName: t.chain, date: t.date.toISOString(),
			from: t.fromFull || "", fromShort: t.from || "", token: t.token, amount: t.amount, usd: t.usd,
		})) as TransferRecord[],
		outgoing: DEMO_TIMELINE_DATA.filter(t => t.type === "out").map(t => ({
			chainId: t.chainId, chainName: t.chain, date: t.date.toISOString(),
			to: t.toFull || "", toShort: t.to || "", token: t.token, amount: t.amount, usd: t.usd,
		})) as TransferRecord[],
	},
};
