/**
 * Reactive state for database table pagination and data fetching.
 *
 * Holds one `AsyncSlot` — `list` (the paginated row fetch). Per-row delete
 * uses plain try/catch + scalar `deleting` / `delete_error` fields (no slot
 * — `delete_error` must persist past `list.run()` retries so the failure
 * message stays visible while the user refetches).
 *
 * @example
 * ```ts
 * const table = new TableState();
 * await table.fetch('accounts', 0, 50);
 *
 * // pagination
 * if (table.has_next) table.go_next();
 * await table.fetch(table.table_name, table.offset, table.limit);
 *
 * // deletion
 * const deleted = await table.delete_row(table.rows[0]);
 * ```
 *
 * @example
 * ```svelte
 * <script lang="ts">
 * 	import {TableState} from '@fuzdev/fuz_app/ui/table_state.svelte.js';
 *
 * 	const table = new TableState();
 * 	table.fetch('accounts');
 * </script>
 *
 * {#if table.list.loading}
 * 	<p>loading…</p>
 * {:else if table.list.error}
 * 	<p>{table.list.error}</p>
 * {:else}
 * 	<p>showing {table.showing_start}–{table.showing_end} of {table.total}</p>
 * {/if}
 * ```
 *
 * @module
 */
import { AsyncSlot } from './async_slot.svelte.js';
import type { ColumnInfo } from '../http/db_routes.js';
/** Maximum number of rows that can be fetched in a single page. */
export declare const TABLE_LIMIT_MAX = 1000;
export declare class TableState {
    readonly list: AsyncSlot<void, string>;
    table_name: string;
    columns: Array<ColumnInfo>;
    rows: Array<Record<string, unknown>>;
    total: number;
    offset: number;
    limit: number;
    primary_key: string | null;
    deleting: string | null;
    delete_error: string | null;
    readonly showing_start: number;
    readonly showing_end: number;
    readonly has_prev: boolean;
    readonly has_next: boolean;
    /**
     * Fetch a page of rows for `table_name` from `GET /api/db/tables/{table_name}`.
     * `limit` is clamped to `[1, TABLE_LIMIT_MAX]`.
     *
     * @mutates `this`
     */
    fetch(table_name: string, offset?: number, limit?: number): Promise<void>;
    go_prev(): void;
    go_next(): void;
    /**
     * Delete a row by its primary key via `DELETE /api/db/tables/{table_name}/rows/{pk}`.
     * Optimistically drops it from `rows` and decrements `total` on success;
     * surfaces server errors on `delete_error`.
     *
     * @returns `true` when the row was removed; `false` on missing primary key or server error
     * @mutates `this`
     */
    delete_row(row: Record<string, unknown>): Promise<boolean>;
}
//# sourceMappingURL=table_state.svelte.d.ts.map