import '../types';
import { SetUiAjaxConfigurationType } from '../types';
/**
 * Retry policy configuration for AJAX requests.
 */
export type RetryPolicy = {
    /** Maximum number of retry attempts (default: 0 — no retries). */
    maxRetries?: number;
    /** Base delay in ms between retries (default: 1000). Doubled on each attempt. */
    baseDelay?: number;
    /** HTTP status codes that should trigger a retry (default: [502, 503, 504]). Timeouts and network errors always retry regardless of this list. */
    retryOn?: number[];
};
/**
 * Options for {@link getAjaxSubmit}. Passed explicitly so that the helper can
 * stay a plain function — callers forward the values they already obtained
 * from {@link usePieConfig} instead of the helper calling hooks on its own.
 */
export type GetAjaxSubmitOptions = {
    /** Base URL of the PieUI API server (must end with `/`). */
    apiServer?: string | null;
    /** When `true`, the helper will log registration and error details. */
    renderingLogEnabled?: boolean;
    /** Request timeout in milliseconds. No timeout if omitted. */
    timeout?: number;
    /** Retry policy for failed requests. No retries if omitted. */
    retryPolicy?: RetryPolicy;
};
/**
 * Reads the value(s) for a single dep name from the DOM, following the same
 * convention used by Ajax cards. Returns an array because file inputs can
 * contribute multiple values for the same key.
 *
 * - `'sid'` resolves to `window.sid`. The caller must ensure SocketIO is
 *   ready (e.g. via {@link waitForSidAvailable}) before calling this.
 * - Other names are looked up via `document.getElementsByName`; only the
 *   first match is read.
 * - `<input type="file">` returns every selected `File`.
 * - Other `<input>` / `<textarea>` returns the current `.value`.
 * - Missing inputs return `[]` (and emit a warning when `renderingLogEnabled`).
 *
 * Must run in a browser environment — relies on `document` and `window`.
 *
 * @throws if `depName === 'sid'` and `window.sid` is not initialized.
 */
export declare const readAjaxKey: (depName: string, renderingLogEnabled?: boolean) => Array<string | File>;
/**
 * Builds an async "submit" function that issues an AJAX request to
 * `api/ajax_content{pathname}` and streams (or JSON-decodes) the response
 * into a `setUiAjaxConfiguration` callback supplied by an Ajax container.
 *
 * The returned function collects form data from:
 * 1. the static `kwargs` object,
 * 2. any `extraKwargs` passed at call time,
 * 3. named inputs from the DOM listed in `depsNames` (including `sid`,
 *    which is resolved via {@link waitForSidAvailable}), and
 * 4. file inputs (multiple files supported).
 *
 * If the server streams NDJSON, each line is parsed as a `UIEventType` and
 * applied incrementally; otherwise the full JSON body replaces the current
 * Ajax configuration.
 *
 * On missing `apiServer`, `pathname` or `setUiAjaxConfiguration` the helper
 * returns a no-op function so call sites do not need to null-check.
 *
 * @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card.
 * @param kwargs                 Static key/value pairs appended to the request.
 * @param depsNames              Names of DOM inputs whose current values should
 *                               also be sent.
 * @param pathname               Path segment appended to `api/ajax_content`.
 * @param options                See {@link GetAjaxSubmitOptions}.
 * @returns An `async (extraKwargs?) => Promise<any>` submit function.
 */
export declare const getAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: GetAjaxSubmitOptions) => (extraKwargs?: Record<string, any>) => Promise<any>;
/**
 * React hook wrapper around {@link getAjaxSubmit}. Reads `apiServer` and
 * `enableRenderingLog` from {@link usePieConfig} and memoizes the submit
 * function so that stable inline literals from server-driven UIConfig don't
 * cause a new function identity on every render — memoization is keyed on
 * the stringified `kwargs`/`depsNames` rather than their reference.
 *
 * @param setUiAjaxConfiguration Setter provided by the enclosing Ajax card.
 * @param kwargs                 Static key/value pairs appended to the request.
 * @param depsNames              Names of DOM inputs whose current values should
 *                               be sent alongside the request.
 * @param pathname               Path segment appended to `api/ajax_content`.
 * @param options                Optional `timeout` (ms) and `retryPolicy`.
 * @returns A memoized submit function; see {@link getAjaxSubmit}.
 */
export declare const useAjaxSubmit: (setUiAjaxConfiguration?: SetUiAjaxConfigurationType, kwargs?: Record<string, any>, depsNames?: Array<string>, pathname?: string, options?: {
    timeout?: number;
    retryPolicy?: RetryPolicy;
}) => (extraKwargs?: Record<string, any>) => Promise<any>;
//# sourceMappingURL=ajaxCommonUtils.d.ts.map