import type { SchemaIndex } from '../../utils/schema-index.js';
export interface FormulaValidationResult {
    isValid: boolean;
    errors: string[];
    warnings: string[];
    references: string[];
    unusedContextKeys: string[];
}
export interface FormulaValidationOptions {
    /** Whether to warn about unused context keys (default: true) */
    warnUnusedContext?: boolean;
    /** Whether to treat unused context keys as errors instead of warnings (default: true) */
    errorOnUnusedContext?: boolean;
    /** Whether to allow empty formulas (default: false) */
    allowEmptyFormula?: boolean;
    /** Custom error message prefix for better context */
    errorPrefix?: string;
    /** When provided, xdiff args are validated as datetime dimensions and level-matched */
    schemaIndex?: SchemaIndex;
}
export interface TimeDiffCall {
    functionName: string;
    ref1: string;
    ref2: string;
}
/**
 * Extracts xdiff (or other two-arg bracket) calls from a formula string.
 * Matches FUNC([ref1], [ref2]) for each function name in the set (case-insensitive).
 */
export declare function parseXDiffCalls(formula: string, functionNames: readonly string[]): TimeDiffCall[];
export interface FormulaParenCall {
    readonly name: string;
    readonly argCount: number;
}
/**
 * Finds all `IDENT(` calls in a formula, outside quoted strings, with comma-separated arg counts
 * (nesting-aware, same rules as {@link splitAtDepthZero}). Recurses into argument lists so nested
 * calls (e.g. `SUM(MAX([a]))`) are included.
 *
 * @internal Exported for unit tests
 */
export declare function extractParenFunctionCalls(formula: string): FormulaParenCall[];
/**
 * Validates that all bracket references in a custom formula exist in the provided context
 * and provides helpful error messages for debugging.
 *
 * Empty context is allowed when the formula contains no bracket references (e.g., MOD(10, 7)).
 * Context is required only when the formula contains bracket references.
 *
 * @example
 * ```typescript
 * const result = validateFormulaReferences(
 *   '([totalRevenue] - SUM([cost])) / [totalRevenue]',
 *   { totalRevenue: measureFactory.sum(DM.Revenue), cost: DM.Cost }
 * );
 *
 * if (!result.isValid) {
 *   throw new Error(result.errors.join('; '));
 * }
 * ```
 *
 * @example
 * ```typescript
 * // Empty context is allowed when no bracket references exist
 * const result = validateFormulaReferences('MOD(10, 7)', {});
 * // result.isValid === true
 * ```
 *
 * @param formula - The formula string containing bracket references
 * @param context - The context object mapping keys to attributes/measures/filters
 * @param options - Additional validation options
 * @returns Validation result with errors, warnings, and analysis
 */
export declare function validateFormulaReferences(formula: string, context: Record<string, unknown>, options?: FormulaValidationOptions): FormulaValidationResult;
/**
 * Wrapper validation function that throws on validation errors.
 * Useful for cases where you want to fail fast with clear error messages.
 *
 * @param formula - The formula string to validate
 * @param context - The context object to validate against
 * @param options - Validation options
 * @throws Error if validation fails
 */
export declare function validateCustomFormula(formula: string, context: Record<string, unknown>, options?: FormulaValidationOptions): void;
