import Ajv from 'ajv/dist/2020.js';
import { JsonObject } from './json-pointer';
import { DefaultErrorMessages, Path } from '../types';
import { FormError } from './FormError';
import type { ErrorObject } from 'ajv/dist/2020.js';
import type { FormsTranslation } from '../hooks/useTranslation';
export { Ajv };
/**
 * Creates or enhances an Ajv instance.
 * If no instance is provided, a new one is created with allErrors option enabled.
 * The ajv-errors plugin is added to the instance if it hasn't been added yet.
 */
export declare function makeAjvInstance(instance?: Ajv): Ajv;
/**
 * Enhances an Ajv instance by adding the ajv-errors plugin if it hasn't been added yet.
 *
 * @param instance - Optional custom instance of Ajv.
 * @returns The created or provided instance of Ajv.
 */
export declare function enhanceAjvInstance(instance?: Ajv): Ajv;
/**
 * Returns the instance path of the given Ajv error.
 * If the error is of type 'required', it is considered an object error and the missing property is shown under the relevant field.
 * If the error is of type 'errorMessage', it is a wrapped error and the instance path is found from the original error to avoid issues like required-errors pointing at the parent object.
 * @param ajvError - The Ajv error object.
 * @returns The instance path of the error.
 */
export declare function getInstancePath(ajvError: ErrorObject): Path;
/**
 * Retrieves the validation rule from an AJV error object.
 * If the error object has an 'errorMessage' keyword, it unwraps the original error
 * to avoid issues like required-errors pointing at the parent object.
 * @param ajvError - The AJV error object.
 * @returns The validation rule.
 */
export declare function getValidationRule(ajvError: ErrorObject): string;
/**
 * Retrieves the message values from an AJV error object.
 * @param ajvError The AJV error object.
 * @returns The message values extracted from the error object.
 */
export declare function getMessageValues(ajvError: ErrorObject): FormError['messageValues'];
/**
 * Overwrite the internal translation messages with given messaged that uses the Ajv keywords.
 *
 * @deprecated – can be removed in v11
 */
export declare function overwriteErrorMessagesWithGivenAjvKeys(messages: DefaultErrorMessages): DefaultErrorMessages;
/**
 * Extend the error messages with relevant translation messages.
 */
export declare function extendErrorMessagesWithTranslationMessages(messages: DefaultErrorMessages, translation: FormsTranslation): DefaultErrorMessages;
/**
 * Get the translation key from the Ajv validation rule
 */
export declare function getTranslationKeyFromValidationRule(validationRule: string): string;
/**
 * Converts an AJV error object to a FormError object.
 *
 * @param ajvError - The AJV error object to convert.
 * @returns The converted FormError object.
 */
export declare function ajvErrorToFormError(ajvError: ErrorObject): FormError;
/**
 * Converts an array of Ajv errors to a single FormError.
 * @param errors - An array of Ajv errors.
 * @returns A single FormError or undefined if there are no errors.
 */
export declare function ajvErrorsToOneFormError(errors?: ErrorObject[] | null, value?: unknown): FormError | undefined;
/**
 * Converts AJV validation errors to form errors.
 *
 * @param errors - The array of AJV validation errors.
 * @param data - The data object being validated.
 * @returns The converted form errors as a record of path and form error pairs.
 */
export declare const ajvErrorsToFormErrors: (errors?: ErrorObject[] | null, data?: JsonObject) => Record<string, FormError>;
