/**
 * Flow types — framework-agnostic (ported from rfunds-online, @xyflow removed).
 */

export interface IntegrationSource {
	type: "rvote" | "safe" | "manual";
	safeAddress?: string;
	safeChainId?: number;
	tokenAddress?: string | null;
	tokenSymbol?: string;
	tokenDecimals?: number;
	rvoteSpaceSlug?: string;
	rvoteProposalId?: string;
	rvoteProposalStatus?: string;
	rvoteProposalScore?: number;
	lastFetchedAt?: number;
}

export interface OverflowAllocation {
	targetId: string;
	percentage: number;
	color: string;
}

export interface SpendingAllocation {
	targetId: string;
	percentage: number;
	color: string;
}

export interface SourceAllocation {
	targetId: string;
	percentage: number;
	color: string;
}

export type SufficiencyState = "seeking" | "sufficient" | "abundant";

export interface FunnelNodeData {
	label: string;
	currentValue: number;
	minThreshold: number;
	maxThreshold: number;
	maxCapacity: number;
	inflowRate: number;
	sufficientThreshold?: number;
	dynamicOverflow?: boolean;
	overflowAllocations: OverflowAllocation[];
	spendingAllocations: SpendingAllocation[];
	source?: IntegrationSource;
	[key: string]: unknown;
}

export interface PhaseTask {
	label: string;
	completed: boolean;
}

export interface OutcomePhase {
	name: string;
	fundingThreshold: number;
	tasks: PhaseTask[];
}

export interface OutcomeNodeData {
	label: string;
	description?: string;
	fundingReceived: number;
	fundingTarget: number;
	status: "not-started" | "in-progress" | "completed" | "blocked";
	phases?: OutcomePhase[];
	source?: IntegrationSource;
	[key: string]: unknown;
}

export interface SourceNodeData {
	label: string;
	flowRate: number;
	sourceType: "card" | "safe_wallet" | "ridentity" | "unconfigured";
	targetAllocations: SourceAllocation[];
	walletAddress?: string;
	chainId?: number;
	safeAddress?: string;
	[key: string]: unknown;
}

/** Lightweight node (replaces @xyflow/react Node) */
export interface FlowNode {
	id: string;
	type: "funnel" | "outcome" | "source";
	position: { x: number; y: number };
	data: FunnelNodeData | OutcomeNodeData | SourceNodeData;
}
