import { type Dispatch, type SetStateAction } from 'react'; import type { FunnelContextValue } from '../components/FunnelContext.js'; import type { FunnelManifestExperiment } from '../config/funnel.manifest.types.js'; import type { FunnelUserAnswers } from '../sdk/userAnswers.js'; import { apiService } from '../services/api.service.js'; import { type FunnelUserAttribution } from './funnel-attribution.js'; import type { FunnelStepMeta, FunnelStepType } from '../steps/types.js'; import { type FunnelStepLifecycleIntent } from './funnel-step-lifecycle.js'; export type FunnelFlowControllerExperiment = FunnelManifestExperiment & { stepId: StepId; variants: readonly (FunnelManifestExperiment['variants'][number] & { routeToStepId: StepId; })[]; }; type StepComponentRegistry = Record; type FunnelFlowAnalyticsAdapter = { flush?: () => unknown | Promise; trackEmailCapturedBrowserDestinations?: (input: { eventId: string; stepId: string; stepName: string; stepType: FunnelStepType; }) => void; trackStepStarted?: (input: { userId?: string; environment?: 'test' | 'live'; stepId: string; stepName: string; stepType: FunnelStepType; startedAt: string; stepContractVersion: number; metadata?: Record; featureFlags?: Record; }) => string | null; trackStepCompleted?: (input: { userId?: string; environment?: 'test' | 'live'; stepId: string; stepName: string; stepType: FunnelStepType; startedAt: string; endedAt: string; stepContractVersion: number; selected?: Record; metadata?: Record; featureFlags?: Record; }) => string | null; trackStepExited?: (input: { userId?: string; environment?: 'test' | 'live'; stepId: string; stepName: string; stepType: FunnelStepType; startedAt: string; endedAt: string; exitReason: Extract['reason']; stepContractVersion: number; metadata?: Record; featureFlags?: Record; }) => string | null; trackFunnelStarted?: (input: { userId?: string; environment?: 'test' | 'live'; stepId: string; stepName: string; stepType?: string; stepContractVersion: number; occurredAt: string; metadata?: Record; featureFlags?: Record; }) => string | null; trackFunnelCompleted?: (input: { userId?: string; environment?: 'test' | 'live'; stepId: string; stepName: string; stepType: FunnelStepType; stepContractVersion: number; occurredAt: string; metadata?: Record; featureFlags?: Record; }) => string | null; trackFirstStepViewed?: (input: { userId?: string; environment?: 'test' | 'live'; stepId: string; stepName: string; stepType: FunnelStepType; stepContractVersion: number; occurredAt: string; metadata?: Record; featureFlags?: Record; }) => string | null; trackFirstStepClicked?: (input: { userId?: string; environment?: 'test' | 'live'; stepId: string; stepName: string; stepType: FunnelStepType; stepContractVersion: number; occurredAt: string; metadata?: Record; featureFlags?: Record; }) => string | null; }; export type FunnelFlowApiAdapter = Pick; type UseFunnelFlowControllerInput = { api?: FunnelFlowApiAdapter; analytics?: FunnelFlowAnalyticsAdapter; stepContractVersion: number; initialStepId?: StepId; initialAttributes?: FunnelUserAnswers; lockToInitialStep?: boolean; defaultStepId: StepId; stepSequence: readonly StepId[]; stepById: Record; stepComponentById: StepComponentRegistry; funnelExperiments: readonly FunnelFlowControllerExperiment[]; getPathForStep: (stepId: StepId) => string; getStepIdFromPath: (pathname: string) => StepId | null; getSequentialNextStepId: (stepId: StepId) => StepId | null; getChoiceTargetsForStep: (stepId: StepId) => { yes?: StepId; no?: StepId; } | null; isFunnelStepId: (value: string) => value is StepId; resolveConfiguredNextStep: (stepId: StepId, context: { attributes: Record; ignoreExperiment?: boolean; resolveExperimentVariantKey: (experiment: FunnelManifestExperiment) => string | null; }) => StepId | null; resolveRuntimeInitialStepId: (input: { requestedStepId?: string | null; }) => StepId; }; type UseFunnelFlowControllerResult = { activeStepComponent: unknown; activeStepId: StepId; activeStepMeta: FunnelStepMeta | undefined; buttonText: string; buttonVariant: 'muted' | null; contextValue: FunnelContextValue; editorModeEnabled: boolean; editorPanelExpanded: boolean; experimentAssignmentForEditor: (experiment: FunnelFlowControllerExperiment) => string; funnelExperiments: readonly FunnelFlowControllerExperiment[]; handleContinue: () => void; postHogReady: boolean; renderSuspended: boolean; renderedStepId: StepId; renderedStepMeta: FunnelStepMeta | undefined; runtimeMode: 'test' | 'live'; setEditorPanelExpanded: Dispatch>; setEditorVariantSelection: (experiment: FunnelFlowControllerExperiment, variantKey: string) => void; showShellContinue: boolean; }; export declare function resolveFunnelEventAttribution(document: unknown, provisionalAttribution: FunnelUserAttribution | null): FunnelUserAttribution | null; export declare function buildReadyFunnelAttributionEventMetadata(attributionReady: boolean, attribution: FunnelUserAttribution | null): Record | null; export declare function scheduleAttributionFailOpen(onReady: () => void, timeoutMs: number): () => void; export declare function takeInitialFunnelAttributionMetadata(tracked: boolean, attributionReady: boolean, attribution: FunnelUserAttribution | null): { tracked: boolean; metadata: Record | null; }; export declare function computeRenderSuspended(input: { activeStepId: string; attributionReady?: boolean; postHogReady: boolean; experiments: ReadonlyArray<{ stepId: string; } & Partial>>; isPreviewRuntime?: boolean; }): boolean; export declare function resolveRenderedExperimentStepId(input: { activeExperiment: FunnelManifestExperiment | null; editorVariantOverrides: Record; postHogReady: boolean; resolveRenderableStepId: (stepId: string | null | undefined) => string | null; safeActiveStepId: string; featureFlags?: Readonly>; search?: string; }): string; export declare function useFunnelFlowController({ api, analytics, stepContractVersion, initialStepId, initialAttributes, lockToInitialStep, defaultStepId, stepSequence, stepById, stepComponentById, funnelExperiments, getPathForStep, getStepIdFromPath, getSequentialNextStepId, getChoiceTargetsForStep, isFunnelStepId, resolveConfiguredNextStep, resolveRuntimeInitialStepId, }: UseFunnelFlowControllerInput): UseFunnelFlowControllerResult; export {};