import { ReactNode } from 'react'; import { ApiService } from '../../../react/services/apiService'; import { convertCurrency, formatMoney, formatMoneyWithoutSymbol, formatSimpleMoney, getCurrencyInfo, minorUnitsToMajorUnits, moneyStringOrNumberToMinorUnits } from '../../../react/utils/money'; import { TagadaClient, TagadaClientConfig, TagadaState } from '../../core/client'; import { FunnelState } from '../../core/funnelClient'; import { FunnelAction, FunnelNavigationResult, SimpleFunnelContext } from '../../core/resources/funnel'; import { Environment, EnvironmentConfig } from '../../core/types'; import { RawPluginConfig } from '../../core/utils/pluginConfig'; /** * Debug Script Definition * Templates can provide debug scripts that will appear in the Debug Drawer "Scripts" tab */ export interface DebugScript { /** Unique identifier for the script */ id: string; /** Display name shown in the Scripts tab */ name: string; /** Optional description of what the script does */ description?: string; /** The function to execute when the script is run */ run: (context: TagadaContextValue) => void | Promise; /** Optional category to group scripts */ category?: string; } interface TagadaContextValue extends TagadaState { client: TagadaClient; apiService: ApiService; pendingRedirect: boolean; funnel: FunnelState & { currentStep: { id: string; } | null; next: (event: FunnelAction) => Promise; goToStep: (stepId: string) => Promise; updateContext: (updates: Partial) => Promise; initializeSession: (entryStepId?: string) => Promise; endSession: () => Promise; retryInitialization: () => Promise; refetch: () => Promise; }; debugCheckout: { isActive: boolean; data: any; error: Error | null; isLoading: boolean; lastUpdated: Date | null; }; updateCheckoutDebugData: (data: any, error?: Error | null, isLoading?: boolean) => void; debugFunnel: { isActive: boolean; data: any; error: Error | null; isLoading: boolean; lastUpdated: Date | null; }; updateFunnelDebugData: (data: any, error?: Error | null, isLoading?: boolean) => void; debugScripts: DebugScript[]; refreshCoordinator: { registerCheckoutRefresh: (refreshFn: () => Promise, name?: string) => void; registerOrderBumpRefresh: (refreshFn: () => Promise) => void; notifyCheckoutChanged: () => Promise; notifyOrderBumpChanged: () => Promise; unregisterCheckoutRefresh: (refreshFn?: () => Promise) => void; unregisterOrderBumpRefresh: (refreshFn?: () => Promise) => void; }; money: { formatMoney: typeof formatMoney; getCurrencyInfo: typeof getCurrencyInfo; moneyStringOrNumberToMinorUnits: typeof moneyStringOrNumberToMinorUnits; minorUnitsToMajorUnits: typeof minorUnitsToMajorUnits; formatMoneyWithoutSymbol: typeof formatMoneyWithoutSymbol; convertCurrency: typeof convertCurrency; formatSimpleMoney: typeof formatSimpleMoney; }; } interface TagadaProviderProps { children: ReactNode; /** * Optional environment override. * ⚠️ Leave undefined for automatic runtime detection (recommended). * Only set this if you need to force a specific environment for testing. */ environment?: Environment; customApiConfig?: Partial; debugMode?: boolean; localConfig?: string; blockUntilSessionReady?: boolean; rawPluginConfig?: RawPluginConfig; /** * Optional feature flags to enable/disable subsystems (e.g. funnel). * By default all features are enabled. */ features?: TagadaClientConfig['features']; /** * Funnel ID to initialize. If not provided, will be detected from URL query param. */ funnelId?: string; /** * Auto-initialize funnel session when auth and store are ready. * Default: true */ autoInitializeFunnel?: boolean; /** * Callback fired after funnel navigation */ onNavigate?: (result: FunnelNavigationResult) => void | boolean; /** * Callback fired on funnel errors */ onFunnelError?: (error: Error) => void; /** * Debug scripts provided by the template. * These will appear in the Debug Drawer "Scripts" tab when debugMode is enabled. * Only shown if the array is not empty. */ debugScripts?: DebugScript[]; } export declare function TagadaProvider({ children, environment, customApiConfig, debugMode, localConfig, blockUntilSessionReady, rawPluginConfig, features, funnelId, autoInitializeFunnel, onNavigate, onFunnelError, debugScripts, }: TagadaProviderProps): import("react/jsx-runtime").JSX.Element; export declare function useTagadaContext(): TagadaContextValue; export {};