import { c as stringEnum, i as jsonResult, r as errorResult, s as readStringParam, u as Type } from "../../tool-helpers-CVAcqiCy.mjs";
import { hasBankrApi } from "../services/bankr-api.mjs";
//#region extensions/crypto/src/tools/bankr-launch.ts
/**
* Bankr Launch Tool — deploy tokens on Base and Solana via Bankr Agent API.
*
* Uses POST /token-launches/deploy for deploy/simulate (direct REST),
* and prompt API for fee checking and claiming.
*
* Separate from clawnch_launch because: different API, different chains
* (Base + Solana vs Base-only), different fee structure (57/36/5 vs 80/20).
*
* Rate limits: 50 deploys/day (100 with Bankr Club).
*/
const BankrLaunchSchema = Type.Object({
	action: stringEnum([
		"deploy",
		"simulate",
		"fees",
		"claim"
	], { description: "deploy: launch a token on-chain. simulate: dry run (no broadcast). fees: check earned fees for your tokens. claim: claim earned fees." }),
	name: Type.Optional(Type.String({ description: "Token name (1-100 chars). Required for deploy/simulate." })),
	symbol: Type.Optional(Type.String({ description: "Token ticker symbol (1-10 chars). Defaults to first 4 chars of name." })),
	description: Type.Optional(Type.String({ description: "Token description (max 500 chars)." })),
	image: Type.Optional(Type.String({ description: "Logo image URL (uploaded to IPFS by Bankr)." })),
	chain: Type.Optional(stringEnum(["base", "solana"], { description: "Chain to deploy on (default: base). Solana uses Raydium LaunchLab." })),
	fee_recipient: Type.Optional(Type.String({ description: "Fee recipient — address, ENS name, X handle, or Farcaster handle." })),
	tweet_url: Type.Optional(Type.String({ description: "Promotion tweet URL." })),
	website_url: Type.Optional(Type.String({ description: "Token website URL." }))
});
function createBankrLaunchTool() {
	return {
		name: "bankr_launch",
		label: "Bankr Launch",
		ownerOnly: true,
		description: "Deploy tokens on Base (Uniswap V4) or Solana (Raydium LaunchLab) via Bankr. Fee split: 57% creator / 36.1% Bankr / 5% protocol on Base. 0.5% bonding curve fee on Solana. Gas is sponsored. Rate limit: 50 deploys/day (100 with Bankr Club). Use \"simulate\" for a dry run without broadcasting.",
		parameters: BankrLaunchSchema,
		execute: async (_toolCallId, args) => {
			const params = args;
			const action = readStringParam(params, "action", { required: true });
			if (!hasBankrApi()) return errorResult("Bankr API key not configured. Connect via /connect_bankr first, or set BANKR_API_KEY env var.");
			switch (action) {
				case "deploy":
				case "simulate": return handleDeploy(params, action === "simulate");
				case "fees": return handleFees(params);
				case "claim": return handleClaim(params);
				default: return errorResult(`Unknown action: ${action}`);
			}
		}
	};
}
async function handleDeploy(params, simulateOnly) {
	const name = readStringParam(params, "name");
	if (!name) return errorResult("Token name is required for deploy/simulate.");
	if (name.length > 100) return errorResult("Token name must be 100 characters or less.");
	const symbol = readStringParam(params, "symbol");
	const description = readStringParam(params, "description");
	const image = readStringParam(params, "image");
	const chain = readStringParam(params, "chain") || "base";
	const feeRecipient = readStringParam(params, "fee_recipient");
	const tweetUrl = readStringParam(params, "tweet_url");
	const websiteUrl = readStringParam(params, "website_url");
	if (description && description.length > 500) return errorResult("Description must be 500 characters or less.");
	if (symbol && symbol.length > 10) return errorResult("Symbol must be 10 characters or less.");
	try {
		const { bankrDeployToken } = await import("../services/bankr-api.mjs");
		const result = await bankrDeployToken({
			name,
			symbol: symbol || void 0,
			description: description || void 0,
			imageUrl: image || void 0,
			chain,
			feeRecipient: feeRecipient || void 0,
			tweetUrl: tweetUrl || void 0,
			websiteUrl: websiteUrl || void 0,
			simulateOnly
		});
		if (simulateOnly) return jsonResult({
			status: "simulated",
			chain,
			tokenAddress: result.tokenAddress,
			feeDistribution: result.feeDistribution,
			note: "Dry run — no transaction was broadcast. Use action \"deploy\" to launch for real."
		});
		return jsonResult({
			status: "deployed",
			chain,
			tokenAddress: result.tokenAddress,
			poolId: result.poolId,
			txHash: result.txHash,
			feeDistribution: result.feeDistribution,
			note: !feeRecipient ? "Fees default to your Bankr wallet. Set fee_recipient to redirect." : void 0
		});
	} catch (err) {
		return errorResult(`Token deploy failed: ${err instanceof Error ? err.message : String(err)}`);
	}
}
async function handleFees(params) {
	try {
		const { bankrPromptAndPoll } = await import("../services/bankr-api.mjs");
		const name = readStringParam(params, "name");
		const result = await bankrPromptAndPoll(name ? `check fees for ${name}` : "how much fees have I earned?", { timeoutMs: 3e4 });
		if (result.status === "failed") return errorResult(`Fee check failed: ${result.error ?? "Unknown error"}`);
		return jsonResult({
			status: "success",
			response: result.response,
			richData: result.richData
		});
	} catch (err) {
		return errorResult(`Fee check failed: ${err instanceof Error ? err.message : String(err)}`);
	}
}
async function handleClaim(params) {
	try {
		const { bankrPromptAndPoll } = await import("../services/bankr-api.mjs");
		const name = readStringParam(params, "name");
		const result = await bankrPromptAndPoll(name ? `claim my fees for ${name}` : "claim all my earned fees", { timeoutMs: 6e4 });
		if (result.status === "failed") return errorResult(`Fee claim failed: ${result.error ?? "Unknown error"}`);
		const txData = result.transactions?.find((t) => t.type === "claim");
		return jsonResult({
			status: "success",
			txHash: txData?.hash,
			response: result.response,
			richData: result.richData
		});
	} catch (err) {
		return errorResult(`Fee claim failed: ${err instanceof Error ? err.message : String(err)}`);
	}
}
//#endregion
export { createBankrLaunchTool };

//# sourceMappingURL=bankr-launch.mjs.map