import type { ValidateFunction } from 'ajv';
import type { JSONSchema } from '../schema-context';
import { type CrossFieldValidationRule } from './cross-field-validation';
import type { ControllerValidation } from '../../form';
/**
 * Conditional validation configuration from x:ui
 */
export interface ConditionalValidationConfig {
    /** Validation rules that apply conditionally */
    when?: ConditionalRule[];
    /** Cross-field validation rules (legacy - use cross-field-validation.ts) */
    crossField?: CrossFieldRule[];
    /** Async validation rules */
    async?: AsyncValidationRule[];
    /** Modern cross-field validation rules */
    crossFieldRules?: CrossFieldValidationRule[];
}
/**
 * A conditional validation rule
 */
export interface ConditionalRule {
    /** JSONPath or property name to watch */
    watch: string | string[];
    /** Condition to evaluate (JSONPath expression or function) */
    condition: string | ((value: unknown, formData: unknown) => boolean);
    /** Schema to apply when condition is true */
    then?: JSONSchema;
    /** Schema to apply when condition is false */
    else?: JSONSchema;
    /** Additional validation function */
    validate?: (value: unknown, formData: unknown) => string | null;
}
/**
 * Cross-field validation rule
 */
export interface CrossFieldRule {
    /** Fields involved in the validation */
    fields: string[];
    /** Validation function */
    validate: (values: Record<string, unknown>, formData: unknown) => string | null;
    /** Error message template */
    message?: string;
    /** Which field to attach the error to (defaults to first field) */
    target?: string;
}
/**
 * Async validation rule
 */
export interface AsyncValidationRule {
    /** Debounce delay in milliseconds */
    debounce?: number;
    /** Validation function */
    validate: (value: unknown, formData: unknown) => Promise<string | null>;
    /** Loading message */
    loadingMessage?: string;
}
/**
 * Extract conditional validation configuration from schema x:ui
 */
export declare function getConditionalValidation(schema: JSONSchema): ConditionalValidationConfig | undefined;
/**
 * Apply conditional validation rules to a value
 */
export declare function applyConditionalValidation(value: unknown, formData: unknown, config: ConditionalValidationConfig, baseValidate?: ValidateFunction): ControllerValidation;
/**
 * Create a debounced async validator
 */
export declare function createAsyncValidator(rule: AsyncValidationRule, onValidation: (result: ControllerValidation) => void): (value: unknown, formData: unknown) => void;
/**
 * Watch for changes in conditional validation dependencies
 */
export declare function createConditionalWatcher(config: ConditionalValidationConfig, _onRevalidate: () => void): {
    watchedPaths: string[];
    shouldRevalidate: (changedPath: string) => boolean;
};
