/**
 * webhook/handler.ts
 *
 * Platform-agnostic webhook handler for Sanity content change events.
 *
 * Receives Sanity webhook payloads, determines which evaluation areas
 * are affected by the document change, debounces rapid edits, enforces
 * daily budget limits, and dispatches scoped evaluations via GitHub Actions.
 *
 * This handler is stateless between requests (debounce and budget state
 * is held in-memory by the enclosing WebhookHandler instance). It can be
 * mounted in any HTTP framework: Express, Hono, Cloudflare Workers, etc.
 *
 * Flow:
 * 1. Receive Sanity webhook payload
 * 2. Extract document slug from payload
 * 3. Look up affected areas via reverse mapping
 * 4. If no areas affected → ignore (untracked document)
 * 5. Check daily budget → rate-limit if exceeded
 * 6. Push slug into debounce window
 * 7. When debounce window closes → dispatch scoped eval via GitHub Actions
 *
 * @see docs/design-docs/report-store/visibility-workflows.md
 */
import { type DispatchResult } from "./dispatch.js";
import type { SanityWebhookPayload, WebhookHandlerConfig, WebhookResult } from "./types.js";
/**
 * A stateful webhook handler that manages debouncing, budgeting,
 * and evaluation dispatch.
 *
 * Create one instance per process and call `handle()` for each
 * incoming webhook payload.
 *
 * ```ts
 * const handler = new WebhookHandler({
 *   githubToken: process.env.GITHUB_TOKEN!,
 *   rootDir: "/path/to/packages/eval",
 * })
 *
 * // In your HTTP handler:
 * app.post("/webhook", async (req) => {
 *   const result = await handler.handle(req.body)
 *   return Response.json(result)
 * })
 * ```
 */
export declare class WebhookHandler {
    private readonly budget;
    private readonly config;
    private readonly debouncer;
    /** Recent dispatch results (for diagnostics) */
    private readonly recentDispatches;
    private readonly reverseMapping;
    constructor(config: WebhookHandlerConfig);
    /**
     * Get handler diagnostics (for health check endpoints).
     */
    diagnostics(): {
        budget: {
            count: number;
            limit: number;
            remaining: number;
        };
        pendingSlugs: number;
        recentDispatches: {
            areas: string[];
            result: DispatchResult;
            timestamp: string;
        }[];
        trackedSlugs: number;
    };
    /**
     * Handle an incoming Sanity webhook payload.
     *
     * This is the main entry point — call once per webhook request.
     * Returns a result indicating what happened (dispatched, debounced,
     * rate-limited, or ignored).
     */
    handle(payload: SanityWebhookPayload): WebhookResult;
    /**
     * Force-flush the debounce window (for graceful shutdown).
     */
    shutdown(): Promise<void>;
    /**
     * Called when the debounce window closes — dispatches a scoped evaluation.
     */
    private onDebounceFlush;
}
