import { ClientConfig, ClientPerspective, SanityClient, StackablePerspective } from "@sanity/client";
/**
 * Configuration for an authentication provider
 * @public
 */
interface AuthProvider {
  /**
   * Unique identifier for the auth provider (e.g., 'google', 'github')
   */
  name: string;
  /**
   * Display name for the auth provider in the UI
   */
  title: string;
  /**
   * Complete authentication URL including callback and token parameters
   */
  url: string;
  /**
   * Optional URL for direct sign-up flow
   */
  signUpUrl?: string;
}
/**
 * Configuration options for creating an auth store.
 *
 * @public
 */
interface AuthConfig {
  /**
   * The initial location href to use when handling auth callbacks.
   * Defaults to the current window location if available.
   */
  initialLocationHref?: string;
  /**
   * Factory function to create a SanityClient instance.
   * Defaults to the standard Sanity client factory if not provided.
   */
  clientFactory?: (config: ClientConfig) => SanityClient;
  /**
   * Custom authentication providers to use instead of or in addition to the default ones.
   * Can be an array of providers or a function that takes the default providers and returns
   * a modified array or a Promise resolving to one.
   */
  providers?: AuthProvider[] | ((prev: AuthProvider[]) => AuthProvider[] | Promise<AuthProvider[]>);
  /**
   * The API hostname for requests. Usually leave this undefined, but it can be set
   * if using a custom domain or CNAME for the API endpoint.
   */
  apiHost?: string;
  /**
   * Storage implementation to persist authentication state.
   * Defaults to `localStorage` if available.
   */
  storageArea?: Storage;
  /**
   * A callback URL for your application.
   * If none is provided, the auth API will redirect back to the current location (`location.href`).
   * When handling callbacks, this URL's pathname is checked to ensure it matches the callback.
   */
  callbackUrl?: string;
  /**
   * A static authentication token to use instead of handling the OAuth flow.
   * When provided, the auth store will remain in a logged-in state with this token,
   * ignoring any storage or callback handling.
   */
  token?: string;
  oauth?: {
    /**
     * Opaque OAuth `client_id`.
     */
    clientId: string;
    /**
     * The redirect URI registered for this client. The OAuth provider
     * redirects back here with the authorization `code` and `state`.
     */
    redirectUri: string;
    /**
     * Organisation id used for RFC 8707 resource scoping. Optional: when
     * omitted, the `resource` parameter is left off the authorize and token
     * requests, so the issued tokens are not restricted to a single
     * organisation.
     */
    organizationId?: string;
  };
}
/**
 * A minimal Observable-compatible interface for subscribing to token changes.
 * Any object with a `subscribe` method that follows this contract will work,
 * including RxJS Observables. This avoids coupling the SDK to a specific
 * reactive library.
 *
 * @public
 */
interface TokenSource {
  /** Subscribe to token emissions. Emits `null` when logged out. */
  subscribe(observer: {
    next: (token: string | null) => void;
  }): {
    unsubscribe(): void;
  };
}
/**
 * Studio-specific configuration for the SDK.
 * When present, the SDK operates in studio mode and derives auth from the
 * provided token source instead of discovering tokens independently.
 *
 * @public
 */
interface StudioConfig {
  /**
   * Whether the Studio has already determined the user is authenticated.
   * When `true` and the token source emits `null`, the SDK infers
   * cookie-based auth is in use rather than transitioning to logged-out.
   */
  authenticated?: boolean;
  /** Reactive auth token source from the Studio's auth store. */
  auth?: {
    /**
     * A reactive token source. The SDK subscribes and stays in sync — the
     * Studio is the single authority for auth and handles token refresh.
     *
     * Optional because older Studios may not expose it. When absent, the
     * SDK falls back to localStorage/cookie discovery.
     */
    token?: TokenSource;
  };
}
/**
 * Represents the minimal configuration required to identify a Sanity project.
 * @public
 */
interface ProjectHandle<TProjectId extends string = string> {
  projectId?: TProjectId;
}
/**
 * @public
 */
type ReleasePerspective = {
  releaseName: string;
  excludedPerspectives?: StackablePerspective[];
};
/**
 * @public
 */
interface PerspectiveHandle {
  perspective?: ClientPerspective | ReleasePerspective;
}
/**
 * @public
 */
interface DatasetHandle<TDataset extends string = string, TProjectId extends string = string> extends ProjectHandle<TProjectId>, PerspectiveHandle {
  dataset?: TDataset;
  /**
   * @beta
   * Explicit resource to use. On an individual operation this overrides any default;
   * on a `SanityConfig` it becomes the instance's default resource. Unlike
   * `projectId`/`dataset`, this can also be a media library or canvas resource.
   */
  resource?: DocumentResource;
}
/**
 * Identifies a specific document type within a Sanity dataset and project.
 * Includes `projectId`, `dataset`, and `documentType`.
 * Optionally includes a `documentId` and `liveEdit` flag.
 * @public
 */
interface DocumentTypeHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DatasetHandle<TDataset, TProjectId> {
  documentId?: string;
  documentType: TDocumentType;
  /**
   * Indicates whether this document uses liveEdit mode.
   * When `true`, the document does not use the draft/published model and edits are applied directly to the document.
   * @see https://www.sanity.io/docs/content-lake/drafts#ca0663a8f002
   */
  liveEdit?: boolean;
}
/**
 * Uniquely identifies a specific document within a Sanity dataset and project.
 * Includes `projectId`, `dataset`, `documentType`, and the required `documentId`.
 * Commonly used by document-related hooks and components to reference a document without fetching its full content initially.
 * @public
 */
interface DocumentHandle<TDocumentType extends string = string, TDataset extends string = string, TProjectId extends string = string> extends DocumentTypeHandle<TDocumentType, TDataset, TProjectId> {
  documentId: string;
}
/**
 * Identifies a release within a Sanity dataset and project. `releaseId` is the
 * `name` parameter on the release document (e.g. `{name: 'r41035a4'}`).
 * The underlying release document ID is `_.releases.<releaseId>`.
 * It's also the `id` parameter sent to the Actions API.
 * (This type doesn't need to have ProjectId / Dataset generics since it's always the same shape)
 * @beta
 */
interface ReleaseHandle extends DatasetHandle {
  releaseId: string;
}
/**
 * Represents the complete configuration for a Sanity SDK instance
 * @public
 */
interface SanityConfig extends DatasetHandle, PerspectiveHandle {
  /**
   * Authentication configuration for the instance
   */
  auth?: AuthConfig;
  /**
   * Studio configuration provided by a Sanity Studio workspace.
   * When present, the SDK operates in studio mode and derives auth from the
   * workspace's reactive token source — no manual configuration needed.
   *
   * @remarks Typically set automatically by `SanityApp` when it detects an
   * `SDKStudioContext` provider. Can also be set explicitly for programmatic use.
   */
  studio?: StudioConfig;
}
/**
 * A document resource can be used for querying.
 * This will soon be the default way to identify where you are querying from.
 *
 * @beta
 */
type DocumentResource = DatasetResource | MediaLibraryResource | CanvasResource;
/**
 * @beta
 */
type DatasetResource = {
  projectId: string;
  dataset: string;
};
/**
 * @beta
 */
type MediaLibraryResource = {
  mediaLibraryId: string;
};
/**
 * @beta
 */
type CanvasResource = {
  canvasId: string;
};
/**
 * @beta
 */
declare function isDatasetResource(resource: DocumentResource): resource is DatasetResource;
/**
 * @beta
 */
declare function isMediaLibraryResource(resource: DocumentResource): resource is MediaLibraryResource;
/**
 * @beta
 */
declare function isCanvasResource(resource: DocumentResource): resource is CanvasResource;
/**
 * Represents a Sanity.io resource instance with its own configuration and lifecycle
 *
 * @public
 */
interface SanityInstance {
  /**
   * Unique identifier for this instance
   * @remarks Generated as a random 16-character alphanumeric ID
   */
  readonly instanceId: string;
  /**
   * Resolved configuration for this instance
   */
  readonly config: SanityConfig;
  /**
   * Checks if the instance has been disposed
   * @returns true if dispose() has been called
   */
  isDisposed(): boolean;
  /**
   * Disposes the instance and cleans up associated resources
   * @remarks Triggers all registered onDispose callbacks
   */
  dispose(): void;
  /**
   * Registers a callback to be invoked when the instance is disposed
   * @param cb - Callback to execute on disposal
   * @returns Function to unsubscribe the callback
   */
  onDispose(cb: () => void): () => void;
}
/**
 * Creates a new Sanity resource instance
 * @param config - Configuration for the instance (optional)
 * @returns A configured SanityInstance
 *
 * @public
 */
declare function createSanityInstance(config?: SanityConfig): SanityInstance;
export { isCanvasResource as _, DatasetResource as a, AuthConfig as b, DocumentTypeHandle as c, ProjectHandle as d, ReleaseHandle as f, TokenSource as g, StudioConfig as h, DatasetHandle as i, MediaLibraryResource as l, SanityConfig as m, createSanityInstance as n, DocumentHandle as o, ReleasePerspective as p, CanvasResource as r, DocumentResource as s, SanityInstance as t, PerspectiveHandle as u, isDatasetResource as v, AuthProvider as x, isMediaLibraryResource as y };
//# sourceMappingURL=createSanityInstance--Lrldto8.d.ts.map