/**
 * Reactive state for the consentful-role-grants offer flow.
 *
 * Maintains one offer cache keyed by id, seeded by the RPC list/history
 * actions and kept live by the six role-grant-offer WebSocket notifications.
 * `incoming` (recipient-side pending) and `outgoing` (grantor-side pending)
 * are derived views; `history` is the full cache ordered newest-first for
 * the grantor/admin history view.
 *
 * Wiring is transport-agnostic: the ctor accepts a narrow RPC interface
 * the consumer adapts from their typed client, plus an `account_id` /
 * `actor_id` getter pair (typically bound to `auth_state`). Notification
 * delivery is pull-only via `subscribe()` — the consumer plumbs their
 * `FrontendWebsocketClient` / `ActionPeer` receiver to `apply_notification`.
 *
 * Holds six `AsyncSlot`s — one per RPC verb. The cache `#offers` lives on
 * the class (multiple ops write into it via `#merge_offers` /
 * `#remove_offer`); the `create` slot is typed `AsyncSlot<RoleGrantOfferJson>`
 * so `submit_create` can return the new offer via the slot's
 * supersession-safe `data` path, but the other slots' `data` is unused
 * (no single op owns the cache). Method names use the `submit_*` prefix
 * to avoid slot-name collisions; the `history` view stayed natural by
 * naming the fetch slot `list_history`.
 *
 * @module
 */
import { AsyncSlot } from './async_slot.svelte.js';
import type { RoleGrantOfferJson } from '../auth/role_grant_offer_schema.js';
/**
 * Svelte context for `RoleGrantOffersState`.
 * Use `role_grant_offers_state_context.set(state)` in the provider and
 * `role_grant_offers_state_context.get()` to access.
 */
export declare const role_grant_offers_state_context: {
    get: (error_message?: string) => RoleGrantOffersState;
    get_maybe: () => RoleGrantOffersState | undefined;
    set: (value: RoleGrantOffersState) => RoleGrantOffersState;
};
/**
 * Narrow RPC surface consumed by `RoleGrantOffersState`. Consumers adapt their
 * typed client (e.g. a `create_rpc_client` Proxy) to this shape — the state
 * class stays decoupled from the client's `Result` return type so tests can
 * inject plain-function stubs.
 */
export interface RoleGrantOffersRpc {
    list: () => Promise<{
        offers: Array<RoleGrantOfferJson>;
    }>;
    history: (options?: {
        limit?: number;
        offset?: number;
    }) => Promise<{
        offers: Array<RoleGrantOfferJson>;
    }>;
    create: (params: {
        to_account_id: string;
        to_actor_id?: string | null;
        role: string;
        scope_id?: string | null;
        message?: string | null;
    }) => Promise<{
        offer: RoleGrantOfferJson;
    }>;
    accept: (offer_id: string) => Promise<{
        role_grant_id: string;
        offer: RoleGrantOfferJson;
        superseded_offer_ids: Array<string>;
    }>;
    decline: (offer_id: string, reason?: string | null) => Promise<{
        ok: true;
    }>;
    retract: (offer_id: string) => Promise<{
        ok: true;
    }>;
}
/** Narrow WS notification envelope — method + params, matching `JsonrpcNotification`. */
export interface RoleGrantOfferNotification {
    method: string;
    params: unknown;
}
/** Subscription primitive — consumer wires their WS receiver; returns a disposer. */
export type RoleGrantOfferSubscribe = (handler: (notification: RoleGrantOfferNotification) => void) => () => void;
export interface RoleGrantOffersStateOptions {
    rpc: RoleGrantOffersRpc;
    /** Reactive accessor for the current account id; returns `null` when logged out. */
    account_id: () => string | null;
    /**
     * Reactive accessor for the current actor id — required to classify
     * offers as outgoing. Returns `null` when unknown.
     */
    actor_id: () => string | null;
}
export declare class RoleGrantOffersState {
    #private;
    readonly list: AsyncSlot<void, string>;
    readonly list_history: AsyncSlot<void, string>;
    readonly create: AsyncSlot<{
        id: string & import("zod").$brand<"Uuid">;
        from_actor_id: string & import("zod").$brand<"Uuid">;
        to_account_id: string & import("zod").$brand<"Uuid">;
        to_actor_id: (string & import("zod").$brand<"Uuid">) | null;
        role: string;
        scope_kind: string | null;
        scope_id: (string & import("zod").$brand<"Uuid">) | null;
        message: string | null;
        created_at: string;
        expires_at: string;
        accepted_at: string | null;
        declined_at: string | null;
        decline_reason: string | null;
        retracted_at: string | null;
        superseded_at: string | null;
        resulting_role_grant_id: (string & import("zod").$brand<"Uuid">) | null;
    }, string>;
    readonly accept: AsyncSlot<void, string>;
    readonly decline: AsyncSlot<void, string>;
    readonly retract: AsyncSlot<void, string>;
    /** Pending offers for the current account, soonest-expiring first. */
    readonly incoming: Array<RoleGrantOfferJson>;
    /** Pending offers from the current actor, newest-created first. */
    readonly outgoing: Array<RoleGrantOfferJson>;
    /** Every offer known to this state, newest-created first. Feeds the history view. */
    readonly history: Array<RoleGrantOfferJson>;
    readonly incoming_count: number;
    constructor(options: RoleGrantOffersStateOptions);
    /** Seed the cache with the recipient-side pending inbox. */
    fetch(): Promise<void>;
    /** Seed both-directions history (includes terminal rows). */
    fetch_history(options?: {
        limit?: number;
        offset?: number;
    }): Promise<void>;
    /**
     * Issue a new offer; merges the returned offer into the cache on success.
     *
     * `to_actor_id` (optional) narrows the offer to a specific actor on
     * `to_account_id`; omit / null for the account-grain default (any actor
     * on the recipient account may accept).
     */
    submit_create(params: {
        to_account_id: string;
        to_actor_id?: string | null;
        role: string;
        scope_id?: string | null;
        message?: string | null;
    }): Promise<RoleGrantOfferJson | undefined>;
    /** Accept an offer; stamps it terminal in the cache and drops any siblings the server superseded. */
    submit_accept(offer_id: string): Promise<void>;
    submit_decline(offer_id: string, reason?: string | null): Promise<void>;
    submit_retract(offer_id: string): Promise<void>;
    /**
     * Wire a notification subscription. The handler dispatches each matching
     * notification into `apply_notification`; the returned disposer unwires.
     */
    subscribe(subscribe_fn: RoleGrantOfferSubscribe): () => void;
    /**
     * Reduce a single WS notification into the cache. Exposed so consumers
     * wiring their WS receiver directly (without `subscribe`) and tests can
     * drive the reducer without allocating a subscription.
     *
     * @mutates `this`
     */
    apply_notification(notification: RoleGrantOfferNotification): void;
    /** Clear the cache and reset every slot. */
    reset(): void;
}
//# sourceMappingURL=role_grant_offers_state.svelte.d.ts.map