import { Paginator } from "./utils/paginator.js";
import { SnapshotMetadata } from "./api-client/validators.js";
import { APIClient, WithFetchOptions } from "./api-client/api-client.js";
import "./api-client/index.js";
import { Credentials } from "./utils/get-credentials.js";
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "./_workflow-serde.js";

//#region src/snapshot.d.ts
interface SerializedSnapshot {
  snapshot: SnapshotMetadata;
}
/** @inline */
interface GetSnapshotParams {
  /**
   * Unique identifier of the snapshot.
   */
  snapshotId: string;
  /**
   * An AbortSignal to cancel the operation.
   */
  signal?: AbortSignal;
}
/**
 * A Snapshot is a saved state of a Sandbox that can be used to create new Sandboxes
 *
 * Use {@link Sandbox.snapshot} or {@link Snapshot.get} to construct.
 * @hideconstructor
 */
declare class Snapshot {
  private _client;
  /**
   * Lazily resolve credentials and construct an API client.
   * This is used in step contexts where the Snapshot was deserialized
   * without a client (e.g. when crossing workflow/step boundaries).
   * @internal
   */
  private ensureClient;
  /**
   * Unique ID of this snapshot.
   */
  get snapshotId(): string;
  /**
   * The ID of the session from which this snapshot was created.
   */
  get sourceSessionId(): string;
  /**
   * The status of the snapshot.
   */
  get status(): SnapshotMetadata["status"];
  /**
   * The size of the snapshot in bytes, or null if not available.
   */
  get sizeBytes(): number;
  /**
   * The creation date of this snapshot.
   */
  get createdAt(): Date;
  /**
   * When this snapshot was last updated.
   */
  get updatedAt(): Date;
  /**
   * The expiration date of this snapshot, or undefined if it does not expire.
   */
  get expiresAt(): Date | undefined;
  /**
   * Internal metadata about this snapshot.
   */
  private snapshot;
  /**
   * Serialize a Snapshot instance to plain data for @workflow/serde.
   *
   * @param instance - The Snapshot instance to serialize
   * @returns A plain object containing snapshot metadata
   */
  static [WORKFLOW_SERIALIZE](instance: Snapshot): SerializedSnapshot;
  /**
   * Deserialize a Snapshot from serialized data.
   *
   * The deserialized instance uses the serialized metadata synchronously and
   * lazily creates an API client only when methods perform API requests.
   *
   * @param data - The serialized snapshot data
   * @returns The reconstructed Snapshot instance
   */
  static [WORKFLOW_DESERIALIZE](data: SerializedSnapshot): Snapshot;
  constructor({
    client,
    snapshot
  }: {
    client?: APIClient;
    snapshot: SnapshotMetadata;
  });
  /**
   * Allow to get a list of snapshots for a team narrowed to the given params.
   * It returns both the snapshots and the pagination metadata to allow getting
   * the next page of results.
   *
   * The returned object is async-iterable to auto-paginate through all pages:
   *
   * ```ts
   * const result = await Snapshot.list({ name: "my-sandbox" });
   * for await (const snapshot of result) { ... }
   * // or: await result.toArray();
   * // or: for await (const page of result.pages()) { ... }
   * ```
   */
  static list(params?: Partial<Parameters<APIClient["listSnapshots"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<Paginator<{
    snapshots: {
      id: string;
      sourceSessionId: string;
      region: string;
      status: "created" | "deleted" | "failed";
      sizeBytes: number;
      createdAt: number;
      updatedAt: number;
      expiresAt?: number | undefined;
      lastUsedAt?: number | undefined;
      creationMethod?: string | undefined;
      parentId?: string | undefined;
    }[];
    pagination: {
      count: number;
      next: string | null;
    };
  }, "snapshots">>;
  /**
   * Fetch the snapshot ancestry tree anchored on a given snapshot.
   * It returns both the tree nodes and the pagination metadata to allow
   * walking the next page of results in the same direction.
   *
   * The returned object is async-iterable to auto-paginate through all pages
   * in the direction set by `sortOrder` (`"desc"` walks ancestors, `"asc"`
   * walks descendants):
   *
   * ```ts
   * const result = await Snapshot.tree({ snapshotId: "snap_abc", sortOrder: "desc" });
   * for await (const node of result) { ... }
   * // or: await result.toArray();
   * // or: for await (const page of result.pages()) { ... }
   * ```
   */
  static tree(params: {
    snapshotId: string;
  } & Partial<Parameters<APIClient["getSnapshotTree"]>[0]> & Partial<Credentials> & WithFetchOptions): Promise<Paginator<{
    snapshots: {
      snapshot: {
        id: string;
        sourceSessionId: string;
        region: string;
        status: "created" | "deleted" | "failed";
        sizeBytes: number;
        createdAt: number;
        updatedAt: number;
        expiresAt?: number | undefined;
        lastUsedAt?: number | undefined;
        creationMethod?: string | undefined;
        parentId?: string | undefined;
      };
      siblings: {
        id: string;
        sourceSessionId: string;
        region: string;
        status: "created" | "deleted" | "failed";
        sizeBytes: number;
        createdAt: number;
        updatedAt: number;
        expiresAt?: number | undefined;
        lastUsedAt?: number | undefined;
        creationMethod?: string | undefined;
        parentId?: string | undefined;
      }[];
      count: string;
    }[];
    pagination: {
      count: number;
      next: string | null;
    };
    anchor?: {
      snapshot: {
        id: string;
        sourceSessionId: string;
        region: string;
        status: "created" | "deleted" | "failed";
        sizeBytes: number;
        createdAt: number;
        updatedAt: number;
        expiresAt?: number | undefined;
        lastUsedAt?: number | undefined;
        creationMethod?: string | undefined;
        parentId?: string | undefined;
      };
      siblings: {
        id: string;
        sourceSessionId: string;
        region: string;
        status: "created" | "deleted" | "failed";
        sizeBytes: number;
        createdAt: number;
        updatedAt: number;
        expiresAt?: number | undefined;
        lastUsedAt?: number | undefined;
        creationMethod?: string | undefined;
        parentId?: string | undefined;
      }[];
      count: string;
    } | undefined;
  }, "snapshots">>;
  /**
   * Retrieve an existing snapshot.
   *
   * @param params - Get parameters and optional credentials.
   * @returns A promise resolving to the {@link Sandbox}.
   */
  static get(params: GetSnapshotParams | (GetSnapshotParams & Credentials)): Promise<Snapshot>;
  /**
   * Delete this snapshot.
   *
   * @param opts - Optional parameters.
   * @param opts.signal - An AbortSignal to cancel the operation.
   * @returns A promise that resolves once the snapshot has been deleted.
   */
  delete(opts?: {
    signal?: AbortSignal;
  }): Promise<void>;
}
//#endregion
export { SerializedSnapshot, Snapshot };
//# sourceMappingURL=snapshot.d.ts.map