import { z } from 'zod'; import { P as Placement } from '../config-DfZMwC7R.cjs'; /** * One condition inside the array form of `AudienceDefinition`. JSON-safe subset * of the runtime `AudienceCondition` (no `type` discriminator — consumers attach * it after parsing if they need to bridge to the runtime shape). */ declare const audienceConditionSchema: z.ZodObject<{ key: z.ZodString; operator: z.ZodEnum<{ equals: "equals"; not_equals: "not_equals"; contains: "contains"; not_contains: "not_contains"; in: "in"; not_in: "not_in"; exists: "exists"; not_exists: "not_exists"; }>; value: z.ZodOptional; }, z.core.$strip>; /** * Audience filter — accepts either the legacy condition-array form or the * named-segment object form. Mirrors `AudienceProp` from `types/step.ts` but * skips the runtime `type` discriminator on each condition. */ declare const audienceSchema: z.ZodUnion; value: z.ZodOptional; }, z.core.$strip>>, z.ZodObject<{ segment: z.ZodString; }, z.core.$strip>]>; /** * JSON-safe step shape. Mirrors `TourStepDefinition` 1:1 — when a new key is * added to `TourStepDefinition`, add it here AND update `TourStepJsonSafeKeys` * in `parity.test-d.ts`, or the compile-time parity assertion will fail. */ declare const tourStepDefinitionSchema: z.ZodObject<{ id: z.ZodString; kind: z.ZodOptional>; target: z.ZodString; title: z.ZodOptional; description: z.ZodOptional; content: z.ZodUnknown; audience: z.ZodOptional; value: z.ZodOptional; }, z.core.$strip>>, z.ZodObject<{ segment: z.ZodString; }, z.core.$strip>]>>; placement: z.ZodOptional>; }, z.core.$strip>; /** * Top-level JSON-safe tour shape. Mirrors `TourDefinition` 1:1 — when a new * key is added to `TourDefinition`, add it here AND update `TourJsonSafeKeys` * in `parity.test-d.ts`, or the compile-time parity assertion will fail. */ declare const tourDefinitionSchema: z.ZodObject<{ id: z.ZodString; steps: z.ZodArray>; target: z.ZodString; title: z.ZodOptional; description: z.ZodOptional; content: z.ZodUnknown; audience: z.ZodOptional; value: z.ZodOptional; }, z.core.$strip>>, z.ZodObject<{ segment: z.ZodString; }, z.core.$strip>]>>; placement: z.ZodOptional>; }, z.core.$strip>>; audience: z.ZodOptional; value: z.ZodOptional; }, z.core.$strip>>, z.ZodObject<{ segment: z.ZodString; }, z.core.$strip>]>>; autoStart: z.ZodOptional; startAt: z.ZodOptional; }, z.core.$strip>; /** * Top-level container shape for a JSON file or CMS payload that ships multiple * tours at once: `{ "tours": [...] }`. */ declare const flowSourceSchema: z.ZodObject<{ tours: z.ZodArray>; target: z.ZodString; title: z.ZodOptional; description: z.ZodOptional; content: z.ZodUnknown; audience: z.ZodOptional; value: z.ZodOptional; }, z.core.$strip>>, z.ZodObject<{ segment: z.ZodString; }, z.core.$strip>]>>; placement: z.ZodOptional>; }, z.core.$strip>>; audience: z.ZodOptional; value: z.ZodOptional; }, z.core.$strip>>, z.ZodObject<{ segment: z.ZodString; }, z.core.$strip>]>>; autoStart: z.ZodOptional; startAt: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>; /** * Recursive JSON-safe value. Used to type `audience.value` and any other * primitive payload that round-trips through a JSON file or CMS response. */ type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue; }; /** * Single condition inside the audience array form. * * This is a JSON-safe SUBSET of the runtime `AudienceCondition`: the runtime * `type` discriminator (`'user_property' | 'segment' | 'feature_flag' | 'custom'`) * is omitted because JSON-authored audiences don't need it — consumers attach * the discriminator at runtime when they bridge to `AudienceCondition[]`. */ interface AudienceConditionDefinition { key: string; operator: 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'in' | 'not_in' | 'exists' | 'not_exists'; value?: JsonValue; } /** * Audience filter shape — discriminated by `Array.isArray()`. * * - Array branch: legacy inline conditions. * - Object branch: named segment lookup resolved by `useSegment`/`useSegments`. */ type AudienceDefinition = AudienceConditionDefinition[] | { segment: string; }; /** * JSON-authorable subset of `TourStep`. Fields excluded: * - `target` accepts only `string` (refs are not JSON-serializable) * - `title`/`description`/`content` are `unknown` — `ReactNode` at runtime, * but the schema guarantees presence/optionality, not React-element shape * - lifecycle callbacks (`when`, `onShow`, `onEnter`, etc.) — runtime-only * - branching/advanceOn handlers — runtime-only * * Consumers parse JSON into `TourStepDefinition` and attach runtime-only * fields (refs, callbacks) before handing the result to `TourProvider`. */ interface TourStepDefinition { id: string; kind?: 'visible' | 'hidden'; target: string; title?: unknown; description?: unknown; content: unknown; audience?: AudienceDefinition; placement?: Placement; } /** * JSON-authorable subset of `Tour`. Excludes lifecycle callbacks * (`onStart`, `onComplete`, `onStepChange`, `onBranchAction`, `onTourBranch`) * and the rich `keyboard`/`spotlight`/`persistence`/`a11y`/`scroll` configs — * those are attached at runtime by the consumer. */ interface TourDefinition { id: string; steps: TourStepDefinition[]; audience?: AudienceDefinition; autoStart?: boolean; startAt?: number; } /** * Parse a JSON-authored tour definition. Throws `ZodError` on invalid input. * * The runtime parse result has the same key shape as `TourDefinition`, but * the inferred Zod type is slightly different (e.g. `content: unknown`). We * cast once at the boundary so consumers see a clean `TourDefinition` type. */ declare function parseTourDefinition(input: unknown): TourDefinition; /** * Non-throwing parse. Returns Zod's tagged union: * `{ success: true, data } | { success: false, error: ZodError }`. */ declare function safeParseTourDefinition(input: unknown): z.ZodSafeParseResult<{ id: string; steps: { id: string; target: string; content: unknown; kind?: "visible" | "hidden" | undefined; title?: unknown; description?: unknown; audience?: { key: string; operator: "equals" | "not_equals" | "contains" | "not_contains" | "in" | "not_in" | "exists" | "not_exists"; value?: unknown; }[] | { segment: string; } | undefined; placement?: "top" | "bottom" | "left" | "right" | "top-start" | "top-center" | "top-end" | "bottom-start" | "bottom-center" | "bottom-end" | "left-start" | "left-center" | "left-end" | "right-start" | "right-center" | "right-end" | undefined; }[]; audience?: { key: string; operator: "equals" | "not_equals" | "contains" | "not_contains" | "in" | "not_in" | "exists" | "not_exists"; value?: unknown; }[] | { segment: string; } | undefined; autoStart?: boolean | undefined; startAt?: number | undefined; }>; /** * Build a stricter STEP schema where `content` is validated by the caller's * schema (e.g. a CMS content-block shape). Useful when the JSON payload has * a known content discriminator and you want full-tree validation. * * Returns a step-level schema — wrap it in `z.array(...).min(1)` and feed it * to a custom tour schema if you want a full validation pipeline. */ declare function createTourStepDefinitionSchema(opts: { contentSchema: TContent; }): z.ZodObject<{ id: z.ZodString; kind: z.ZodOptional>; target: z.ZodString; title: z.ZodOptional; description: z.ZodOptional; audience: z.ZodOptional; value: z.ZodOptional; }, z.core.$strip>>, z.ZodObject<{ segment: z.ZodString; }, z.core.$strip>]>>; placement: z.ZodOptional>; content: TContent; }, z.core.$strip>; export { type AudienceConditionDefinition, type AudienceDefinition, type JsonValue, type TourDefinition, type TourStepDefinition, audienceConditionSchema, audienceSchema, createTourStepDefinitionSchema, flowSourceSchema, parseTourDefinition, safeParseTourDefinition, tourDefinitionSchema, tourStepDefinitionSchema };