import { Effect } from 'effect';
import type { ComputedRef, Ref } from 'vue';
import { type LocaleValue } from '../../../share/locale.js';
export type Severity = 'error' | 'warning';
export type FieldValidationResult = {
    severity: Severity;
    /** Already i18n-resolved and `{{ }}`-interpolated — ready to render. */
    message: string;
    /** Index in the field's `validations[]`; `-1` for the implicit required rule. */
    ruleIndex: number;
};
/** The slice of a field's config the validation engine reads. */
export type ValidatableConfig = {
    required?: string;
    validations?: ReadonlyArray<{
        when: string;
        warning?: boolean;
        message: LocaleValue;
    }>;
    binding?: string | readonly [string, string];
};
type Registration = () => ReadonlyArray<FieldValidationResult>;
export type ValidationProvider = {
    /**
     * Global reveal gate. Errors on a pristine field stay hidden until that
     * field's binding is dirtied (first blur) or `reveal()` flips this true.
     * Once true it never retracts during the form's life — only a full unmount
     * resets it. `undo`/`redo` do not touch it (they roll back state, not the
     * gate).
     */
    revealed: Ref<boolean>;
    reveal: () => void;
    /** Register a mounted field's id + live results thunk; returns an unregister fn. */
    register: (fieldId: () => string, results: Registration) => () => void;
    /**
     * Drain pending drafts, await the seed and derived-value settlement, then
     * read every registered field's results. `true` ⇒ no `error`-severity
     * result anywhere. Always calls `reveal()` so the failing fields surface.
     */
    validate: () => Promise<boolean>;
    /** Union of results across the given field ids — used by collapsible aggregation. */
    resultsFor: (fieldIds: ReadonlyArray<string>) => ReadonlyArray<FieldValidationResult>;
};
export type ValidationHost = {
    /** Drain pending field commits (the form's commit bus). */
    flush: () => void;
    /** Resolves once the initial seed has landed. */
    seeded: Promise<void>;
    /** Resolves once every derived value — cascades included — has settled. */
    settled: () => Promise<void>;
};
/**
 * Provide the form-wide validation registry. Called once at the top-level form
 * host, after the commit bus / quiescence are available; nested list rows
 * inherit it through `inject`, so every field in the form — at any nesting
 * depth — registers into this single provider.
 */
export declare function provideValidation(host: ValidationHost): ValidationProvider;
/**
 * Inject the form's validation provider. Returns `undefined` when used outside
 * a `<Form>` host (e.g. a submit button placed on a bare page) — callers treat
 * that as "no validation".
 */
export declare function useValidationProvider(): ValidationProvider | undefined;
/**
 * Field-level validation. Called inside an input field's `runtime.vue`. Reads
 * the field's `required` / `validations` config, evaluates them synchronously
 * against the field's CEL context (`form`, plus a list row's `item`/`index`),
 * registers the live results into the form-wide provider for as long as the
 * field is mounted, and returns the bits the field renders: the required star,
 * the error/warning message lists, and the dirty-gated `visible` flag.
 */
export declare function useFieldValidation(options: {
    fieldId: () => string;
    config: () => ValidatableConfig;
    $cel: <T>(expression: string, context?: Record<string, unknown>) => Effect.Effect<T, any>;
    /** Current i18n locale, for resolving the message `Locale`. */
    locale: () => string;
}): {
    isRequired: ComputedRef<boolean>;
    errors: ComputedRef<ReadonlyArray<string>>;
    warnings: ComputedRef<ReadonlyArray<string>>;
    visible: ComputedRef<boolean>;
};
export {};
