import { JSX as JSX_2 } from 'react/jsx-runtime';

export declare interface AppearanceVariables {
    colorPrimary?: string;
    colorBackground?: string;
    colorText?: string;
    colorTextSecondary?: string;
    colorBorder?: string;
    colorSuccess?: string;
    colorError?: string;
    fontFamily?: string;
    borderRadius?: string;
}

/**
 * All customizable CSS variables for the Stableyard widget.
 * Use these with custom widget styling.
 */
export declare type CSSVariableKey = '--sy-color-bg-primary' | '--sy-color-bg-secondary' | '--sy-color-bg-tertiary' | '--sy-color-bg-hover' | '--sy-color-text-primary' | '--sy-color-text-secondary' | '--sy-color-text-tertiary' | '--sy-color-accent' | '--sy-color-accent-hover' | '--sy-color-accent-muted' | '--sy-color-accent-text' | '--sy-color-button-primary' | '--sy-color-button-primary-hover' | '--sy-color-success' | '--sy-color-success-muted' | '--sy-color-error' | '--sy-color-error-muted' | '--sy-color-warning' | '--sy-color-warning-muted' | '--sy-color-border' | '--sy-color-border-hover' | '--sy-color-overlay' | '--sy-font-family-display' | '--sy-font-family-body' | '--sy-font-family-mono' | '--sy-radius-sm' | '--sy-radius-md' | '--sy-radius-lg' | '--sy-radius-xl' | '--sy-radius-2xl' | '--sy-radius-full' | '--sy-shadow-sm' | '--sy-shadow-md' | '--sy-shadow-lg' | '--sy-shadow-glow';

/**
 * Partial map of CSS variable keys to their values.
 * Only include the variables you want to override.
 */
export declare type CustomCSSVariables = Partial<Record<CSSVariableKey, string>>;

export declare const darkTheme: Theme;

export declare function getTheme(mode: 'light' | 'dark' | 'auto', variablesOrAccent?: ThemeVariables | string): Theme;

export declare const lightTheme: Theme;

export declare interface PaymentResult {
    sessionId: string;
    status: 'settled';
    amount: number;
    amountFormatted: string;
    currency: string;
    destination: SessionDestination;
    source: SessionSource | null;
    fees: SessionFees;
    settledAt: number;
    txHash?: string;
}

declare interface RoutingActionTransaction {
    stepNumber: number;
    to: string;
    data: string;
    value: string;
    chainId: number;
    gasLimit?: string;
    description: string;
}

declare interface RoutingAmount {
    raw: string;
    formatted: string;
    usd?: string;
}

declare interface RoutingChainInfo {
    chainId: number;
    networkChainId: number;
    name: string;
    displayName?: string;
    baseToken?: string;
    logoURL?: string;
    explorerUrl?: string;
}

export declare interface RoutingChainsResponse {
    success: true;
    count: number;
    chains: RoutingConfigChain[];
}

export declare interface RoutingConfigChain extends RoutingChainInfo {
    chainType?: 'evm' | 'solana' | 'move' | 'movement' | 'tron';
    isEvm?: boolean;
    tokenCount?: number;
}

export declare interface RoutingConfigRoute {
    from: {
        chainId: number;
        chain: string;
        token: string;
        symbol: string;
        decimals: number;
    };
    to: {
        chainId: number;
        chain: string;
        token: string;
        symbol: string;
        decimals: number;
    };
    providers: string[];
    estimatedTime?: unknown;
}

export declare interface RoutingConfigToken {
    address: string;
    symbol: string;
    decimals: number;
    name?: string;
    logoURL?: string;
}

export declare type RoutingExecutionMode = 'standard' | 'atomic' | 'deposit_address' | 'boosted';

declare interface RoutingMovePayload {
    function: string;
    typeArguments?: string[];
    functionArguments?: unknown[];
}

declare interface RoutingOrderAction {
    kind: 'deposit_address' | 'transaction' | 'gateway';
    subtype?: string;
    provider: string;
    providerDisplayName?: string;
    chainId: number;
    chain: RoutingChainInfo;
    token: {
        address: string;
        symbol: string;
        decimals: number;
        logoURL?: string;
    };
    amount: RoutingAmount;
    instructions?: string[];
    requirements?: {
        needsApproval: boolean;
        transactionCount: number;
        estimatedSeconds: number;
        gaslessAvailable: boolean;
        userActionRequired: 'sign_tx' | 'send_to_address' | 'none';
    };
    address?: string | null;
    gatewayAddress?: string;
    transactions?: RoutingActionTransaction[] | null;
    movePayload?: RoutingMovePayload | null;
    solanaParams?: RoutingSolanaParams | null;
    expiresAt?: number | null;
}

export declare interface RoutingOrderResponse {
    success: true;
    quoteId: string;
    orderId?: string;
    status: 'awaiting_deposit' | 'ready_to_execute' | 'awaiting_source_swap';
    statusMessage?: string;
    route?: {
        provider: string;
        providerDisplayName?: string;
        isNative?: boolean;
        type?: string;
    };
    recipient?: {
        address: string;
        chain: RoutingChainInfo;
    };
    quote?: {
        expiresAt: number;
        expiresIn: number;
        tokenIn?: RoutingQuoteResponse['tokenIn'];
        tokenOut?: RoutingQuoteResponse['tokenOut'];
        estimatedTime: {
            seconds: number;
            display: string;
        };
    };
    action: RoutingOrderAction;
}

export declare interface RoutingOrderStatusResponse {
    success: true;
    orderId: string;
    quoteId?: string;
    status: {
        code: 'pending' | 'in_progress' | 'completed' | 'failed' | 'refunded';
        display: string;
        isTerminal: boolean;
        progress: number;
        description?: string;
    };
    tokenIn?: {
        address: string;
        symbol: string;
        decimals: number;
        chain?: RoutingChainInfo;
        amount?: {
            raw: string;
            formatted: string;
            usd?: string | null;
        };
    };
    tokenOut?: {
        address: string;
        symbol: string;
        decimals: number;
        chain?: RoutingChainInfo;
        amount?: {
            expected?: RoutingAmount;
            quoted?: RoutingAmount;
            actual?: RoutingAmount | null;
        };
    };
    fees?: {
        reliable: boolean;
        quoted: {
            usd: string;
        } | null;
        actual: {
            usd: string;
            deltaUsd: string;
            inferred: boolean;
        } | null;
    };
    addresses?: {
        deposit?: string | null;
        depositor?: string | null;
        recipient?: string;
        solver?: string | null;
    };
    transactions?: {
        deposit?: unknown;
        execution?: unknown;
        destination?: unknown;
        refund?: unknown;
    };
    timing?: {
        estimatedSeconds: number;
        settlementSeconds: number | null;
        totalSeconds: number | null;
        display: string;
    };
}

declare interface RoutingPortfolioBalance {
    chainId: number;
    chainName: string;
    family: 'evm' | 'solana' | 'movement';
    token: RoutingPortfolioToken;
    rawBalance: string;
    formattedBalance: string;
    /** USD value in 6-decimal raw units, or null for native tokens. */
    usdValue: string | null;
    eligible: boolean;
}

declare interface RoutingPortfolioChainError {
    chainId: number;
    reason: string;
}

declare interface RoutingPortfolioResponse {
    success: true;
    address: string;
    family: 'evm' | 'solana' | 'movement';
    chains: number[];
    minUsdRaw6: string | null;
    totalUsdRaw6: string;
    totalUsd: string;
    balances: RoutingPortfolioBalance[];
    eligibleCount: number;
    errors: RoutingPortfolioChainError[];
    meta?: {
        version: string;
        timestamp: number;
        requestId: string;
    };
}

declare interface RoutingPortfolioToken {
    address: string;
    symbol: string;
    name: string;
    decimals: number;
    logoURL: string;
    isNative: boolean;
    isStablecoin: boolean;
}

export declare type RoutingQuoteMode = 'exact_input' | 'exact_output';

export declare interface RoutingQuoteRequest {
    sourceChainId: number;
    destChainId: number;
    sourceToken: string;
    destToken: string;
    sourceAmount?: string;
    destAmount?: string;
    mode?: RoutingQuoteMode;
    recipient: string;
    slippageBps?: number;
    providers?: string[];
    executionMode?: RoutingExecutionMode;
    sourceAddress?: string;
}

export declare interface RoutingQuoteResponse {
    success: true;
    quoteId: string;
    mode: RoutingQuoteMode;
    route?: {
        provider: string;
        providerDisplayName?: string;
        isNative?: boolean;
        type?: string;
    };
    tokenIn: {
        chain: RoutingChainInfo;
        address: string;
        symbol: string;
        decimals: number;
        amount: RoutingAmount;
    };
    tokenOut: {
        chain: RoutingChainInfo;
        address: string;
        symbol: string;
        decimals: number;
        amount: RoutingAmount | {
            expected?: RoutingAmount;
            minimum?: RoutingAmount;
        };
    };
    estimatedTime: {
        seconds: number;
        display: string;
    };
    fees: {
        total: RoutingAmount;
        networkFee?: RoutingAmount;
        platformFee?: RoutingAmount;
        solverIncentive?: RoutingAmount;
    };
    expiresAt: number;
    expiresIn?: number;
    action: RoutingOrderAction;
}

export declare interface RoutingRoutesResponse {
    success: true;
    totalRoutes: number;
    routes: RoutingConfigRoute[];
}

declare interface RoutingSolanaParams {
    kind?: 'native_transfer' | 'spl_transfer' | 'cctp_v2_burn_with_hook' | string;
    mint?: string;
    usdcMint?: string;
    recipient?: string;
    amount?: string;
    decimals?: number;
    programId?: string;
    messageTransmitterProgramId?: string;
    destinationDomain?: number;
    mintRecipient?: string;
    destinationCaller?: string;
    maxFee?: string;
    minFinalityThreshold?: number;
    hookData?: string;
    [key: string]: unknown;
}

export declare interface RoutingTokensResponse {
    success: true;
    chainId?: number;
    chain?: string;
    count: number;
    tokens: RoutingConfigToken[];
}

declare interface SessionDestination {
    accountId?: string;
    paymentAddress?: string | null;
    wallet: string;
    chain: string;
    token: string;
}

declare interface SessionFees {
    total: number;
    totalFormatted: string;
    stableyard: number;
    partner: number;
}

declare interface SessionSource {
    wallet: string;
    chain: string;
    token: string;
}

declare type SessionStatus = 'open' | 'pending' | 'routing' | 'settled' | 'failed' | 'expired' | 'refunded';

export declare class StableyardApiError extends Error {
    readonly statusCode: number;
    readonly code: string;
    constructor(message: string, statusCode: number, code: string);
}

export declare interface StableyardDestination {
    chainId: number;
    token: string;
    tokenAddress?: string;
    decimals?: number;
    amount?: string | number;
}

export declare interface StableyardSource {
    chainId?: number;
    token?: string;
    tokenAddress?: string;
    decimals?: number;
    amount?: string | number;
}

declare class StableyardV2Client {
    private readonly routingBaseUrl;
    constructor(config: StableyardV2Config);
    routingQuote(params: RoutingQuoteRequest): Promise<RoutingQuoteResponse>;
    routingOrder(params: RoutingQuoteRequest & {
        quoteId?: string;
        preferredProvider?: string;
        private?: boolean;
    }): Promise<RoutingOrderResponse>;
    getRoutingOrder(id: string): Promise<RoutingOrderStatusResponse>;
    submitRoutingTx(orderId: string, txHash: string): Promise<RoutingOrderStatusResponse>;
    routingChains(): Promise<RoutingChainsResponse>;
    routingTokens(chainId?: number): Promise<RoutingTokensResponse>;
    routingRoutes(sourceChainId?: number): Promise<RoutingRoutesResponse>;
    routingPortfolio(params: {
        address: string;
        chainIds?: number[];
        minUsd?: number | string;
    }): Promise<RoutingPortfolioResponse>;
    private getRouting;
    private postRouting;
    private handleResponse;
}
export { StableyardV2Client as StableyardRoutingClient }
export { StableyardV2Client }

declare interface StableyardV2Config {
    routingBaseUrl?: string;
}
export { StableyardV2Config as StableyardRoutingConfig }
export { StableyardV2Config }

export declare function StableyardWidget(props: StableyardWidgetProps): JSX_2.Element;

export declare interface StableyardWidgetProps {
    /** Routing Engine base URL (default: https://routing-api.stableyard.fi) */
    routingApiUrl?: string;
    /** Destination payment address or wallet */
    to?: string;
    /** Alias for `to`, preferred for routing-engine deposit mode. */
    recipient?: string;
    /** Destination chain/token config for routing-engine mode. */
    destination?: StableyardDestination;
    /** Optional preselected source chain/token config for routing-engine mode. */
    source?: StableyardSource;
    /** Integrator-side reference for deposits or POS receipts. */
    reference?: string;
    /** Extra integrator metadata retained client-side for callbacks. */
    metadata?: Record<string, string | number | boolean>;
    /** Hide the routing order from public order listings when supported by the routing API. */
    private?: boolean;
    /** Preferred routing action shape. Defaults to deposit_address. */
    executionMode?: RoutingExecutionMode;
    /** Quote mode for routing. Defaults to exact_output when amount is fixed, otherwise exact_input. */
    routeMode?: RoutingQuoteMode;
    /** Slippage in basis points for routing quotes. */
    slippageBps?: number;
    /** Optional Privy app id override. Defaults to Stableyard's widget app. */
    privyAppId?: string;
    /** Amount in display currency (omit for open/donation) */
    amount?: number;
    /** Stablecoin to settle in (default: USDC) */
    currency?: 'USDC' | 'USDT';
    /**
     * Display currency for the user (default: USD).
     * Since USDC/USDT = $1 USD, the amount is 1:1 for USD.
     * For other currencies (INR, EUR, GBP), provide exchangeRate or
     * the widget will fetch it.
     */
    displayCurrency?: string;
    /** Symbol to show (default: $ for USD, ₹ for INR, € for EUR, etc.) */
    currencySymbol?: string;
    /** Appearance */
    theme?: 'light' | 'dark' | 'auto';
    appearance?: {
        variables?: AppearanceVariables;
    };
    /**
     * Display mode:
     * - 'inline' — renders the widget directly (default)
     * - 'modal' — renders a button, opens widget in a popup overlay on click
     */
    mode?: 'inline' | 'modal';
    /**
     * Header close button visibility.
     * Defaults to true in modal mode and false in inline mode.
     */
    showCloseButton?: boolean;
    /** Button text for modal mode (default: "Pay $X" or "Pay") */
    buttonText?: string;
    /** Callbacks */
    onReady?: () => void;
    onSuccess?: (result: PaymentResult) => void;
    onError?: (error: Error) => void;
    /** Fired when the widget is dismissed after completion. */
    onClose?: () => void;
    /** Fired when the user abandons an unfinished payment. */
    onCancel?: () => void;
    onStatusChange?: (status: SessionStatus) => void;
    /** Labels */
    title?: string;
    description?: string;
}

export declare interface Theme {
    colors: {
        bgPrimary: string;
        bgSecondary: string;
        bgTertiary: string;
        bgHover: string;
        bgElevated: string;
        bgGlass: string;
        bgGlassHover: string;
        textPrimary: string;
        textSecondary: string;
        textTertiary: string;
        accent: string;
        accentHover: string;
        accentMuted: string;
        accentGlow: string;
        accentText: string;
        buttonPrimary: string;
        buttonPrimaryHover: string;
        buttonPrimaryText: string;
        success: string;
        successMuted: string;
        error: string;
        errorMuted: string;
        warning: string;
        warningMuted: string;
        secure: string;
        secureMuted: string;
        border: string;
        borderHover: string;
        borderGlow: string;
        overlay: string;
        gradientPrimary: string;
        gradientAccent: string;
        gradientMesh: string;
    };
    radii: {
        xs: string;
        sm: string;
        md: string;
        lg: string;
        xl: string;
        '2xl': string;
        full: string;
    };
    shadows: {
        sm: string;
        md: string;
        lg: string;
        glow: string;
        glowStrong: string;
        inner: string;
    };
    fonts: {
        display: string;
        body: string;
        mono: string;
    };
}

declare interface ThemeVariables {
    colorPrimary?: string;
    colorBackground?: string;
    colorText?: string;
    colorTextSecondary?: string;
    colorBorder?: string;
    colorSuccess?: string;
    colorError?: string;
    fontFamily?: string;
    borderRadius?: string;
}

export { }
