import type { OrderData } from "@hooks/apis/auto/useAutoHistory";

export const AutoData: InflightInfo = {
	title: {
		isExpired: "Searching Timed Out",
		isPending: "Finding the best price",
		inProgress: (_, gasless) =>
			gasless ? "Gasless Swap via Bungee Auto" : "Swapping via Bungee Auto",
		isCompleted: () => {
			return "Swap Completed via Bungee Auto";
		},
		isReverted: "Swap Reverted On-Chain",
	},
	/** Subtitles are the rotating texts */
	subTitle: {
		isExpired: ["Your tokens are safe and still in your wallet."],
		isPending: [
			"Looking for the best price to fill your order",
			"Your funds are safe in your wallet while we search",
			"Bungee Auctions are competing for the best execution rate",
		],
		inProgress: (input: Details, output: Details) => {
			return [
				// biome-ignore format:
				`Swapping ${input.tokenSymbol} on ${input.chainName} to receive ${output.tokenSymbol} on ${output.chainName}`,
			];
		},
		isCompleted: () => ["Your swap was successful with zero gas fee."],
		isReverted: ["Swap failed on-chain. No funds left your wallet."],
	},
	info: {} as OrderData,
};

export const ManualData: InflightInfo = {
	title: {
		isExpired: "Swap Request Expired",
		isPending: "Preparing your Swap",
		inProgress: (protocolName?: string) => "Swapping via Bungee Manual",
		isCompleted: (protocolName?: string) => {
			if (protocolName) {
				// biome-ignore format:
				return `Swap Completed via ${protocolName}`;
			}
			return "Swap Completed";
		},
		isReverted: "Swap Reverted On-Chain",
	},
	/** Subtitles are the rotating texts */
	subTitle: {
		isExpired: [
			"We couldn't pick up your request. Set a higher slippage and try again. Your funds are safe.",
		],
		isPending: ["Waiting for your transaction confirmation on destinaion chain"],
		inProgress: (input: Details, output: Details) => {
			return [
				// biome-ignore format:
				`Swapping ${input.tokenSymbol} on ${input.chainName} to receive ${output.tokenSymbol} on ${output.chainName}`,
			];
		},
		isCompleted: (destChainName?: string) => {
			// biome-ignore format:
			if(destChainName) return [`Your swap has been confirmed successfully on ${destChainName}.`]
			return ["Your swap has been confirmed successfully"];
		},
		isReverted: ["Swap failed on-chain. No funds left your wallet."],
	},
	info: {} as OrderData,
};

export interface InflightInfo {
	title: {
		isExpired: string;
		isPending: string;
		inProgress: (protocolName?: string, gasless?: boolean) => string;
		isCompleted: (protocolName?: string) => string;
		isReverted: string;
	};
	subTitle: {
		isExpired: string[];
		isPending: string[];
		inProgress: (input: Details, output: Details) => string[];
		isCompleted: (destChainName?: string) => string[];
		isReverted: string[];
	};
	info: OrderData;
}

type Details = {
	tokenSymbol: string;
	chainName: string;
};
