import * as _sanity_client4 from "@sanity/client";
import { ClientPerspective, ContentSourceMap, ContentSourceMap as ContentSourceMap$1, QueryParams, ResponseQueryOptions } from "@sanity/client";
import * as _sanity_client_stega0 from "@sanity/client/stega";
import * as _sanity_core_loader1 from "@sanity/core-loader";
import { CreateQueryStoreOptions, EnableLiveModeOptions, QueryStoreState, createQueryStore as createQueryStore$1 } from "@sanity/core-loader";
import { ResolveStudioUrl, ResolveStudioUrl as ResolveStudioUrl$1, StudioPathLike, StudioPathLike as StudioPathLike$1, StudioUrl, StudioUrl as StudioUrl$1 } from "@sanity/client/csm";
export * from "@sanity/core-loader";
/**
 * @public
 */
type EncodeDataAttributeFunction = {
  (path: StudioPathLike$1): string | undefined;
  scope: (path: StudioPathLike$1) => EncodeDataAttributeFunction;
};
/**
 * @public
 */
type WithEncodeDataAttribute = {
  encodeDataAttribute: EncodeDataAttributeFunction;
};
type UseQueryHook = <QueryResponseResult = unknown, QueryResponseError = unknown>(query: string, params?: QueryParams, options?: UseQueryOptions<QueryResponseResult>) => QueryStoreState<QueryResponseResult, QueryResponseError> & WithEncodeDataAttribute;
interface QueryResponseInitial<QueryResponseResult> {
  data: QueryResponseResult;
  sourceMap: ContentSourceMap$1 | undefined;
  /**
   * The perspective used to fetch the data, if not provided it'll assume 'published'
   */
  perspective?: ClientPerspective;
}
interface UseQueryOptions<QueryResponseResult = unknown> {
  /**
   * Initial `data` and `sourceMap`, used with SSR hydration and is required if `ssr: true`
   * and an optional speed optimization if `ssr: false`.
   * It's recommended to set `initial` to the return value of `loadQuery()`.
   * @example
   * ```ts
   * const query = `*[_type == "author" && slug.current == $slug][0]`
   * export const getServerSideProps = async ({params}) => {
   *   const initial = await loadQuery<AuhthorType>(query, params)
   *   return { props: { params, initial } }
   * }
   * export default function Page({params, initial}) {
   *   const {data} = useQuery<AuthorType>(query, params, {initial})
   * }
   * ```
   */
  initial?: QueryResponseInitial<QueryResponseResult>;
}
interface UseQueryOptionsUndefinedInitial {
  /**
   * Initial `data` and `sourceMap`, used with SSR hydration and is required if `ssr: true`
   * and an optional speed optimization if `ssr: false`.
   * It's recommended to set `initial` to the return value of `loadQuery()`.
   * @example
   * ```ts
   * const query = `*[_type == "author" && slug.current == $slug][0]`
   * export const getServerSideProps = async ({params}) => {
   *   const initial = await loadQuery<AuhthorType>(query, params)
   *   return { props: { params, initial } }
   * }
   * export default function Page({params, initial}) {
   *   const {data} = useQuery<AuthorType>(query, params, {initial})
   * }
   * ```
   */
  initial?: undefined;
}
type NonUndefinedGuard<T> = T extends undefined ? never : T;
interface UseQueryOptionsDefinedInitial<QueryResponseResult = unknown> {
  /**
   * Initial `data` and `sourceMap`, used with SSR hydration and is required if `ssr: true`
   * and an optional speed optimization if `ssr: false`.
   * It's recommended to set `initial` to the return value of `loadQuery()`.
   * @example
   * ```ts
   * const query = `*[_type == "author" && slug.current == $slug][0]`
   * export const getServerSideProps = async ({params}) => {
   *   const initial = await loadQuery<AuhthorType>(query, params)
   *   return { props: { params, initial } }
   * }
   * export default function Page({params, initial}) {
   *   const {data} = useQuery<AuthorType>(query, params, {initial})
   * }
   * ```
   */
  initial: NonUndefinedGuard<QueryResponseInitial<QueryResponseResult>>;
}
type UseLiveModeHook = (options: EnableLiveModeOptions & {
  /**
   * Set this option to activate `encodeDataAttribute` on `useQuery` hooks when stega isn't used.
   */
  studioUrl?: StudioUrl$1 | ResolveStudioUrl$1 | undefined;
}) => void;
interface QueryStore {
  loadQuery: <QueryResponseResult>(query: string, params?: QueryParams, options?: Pick<ResponseQueryOptions, 'perspective' | 'cache' | 'next' | 'useCdn' | 'stega' | 'tag' | 'headers'>) => Promise<QueryResponseInitial<QueryResponseResult>>;
  setServerClient: ReturnType<typeof createQueryStore$1>['setServerClient'];
  useQuery: {
    <QueryResponseResult = unknown, QueryResponseError = unknown>(query: string, params?: QueryParams, options?: UseQueryOptionsUndefinedInitial): QueryStoreState<QueryResponseResult, QueryResponseError> & WithEncodeDataAttribute;
    <QueryResponseResult = unknown, QueryResponseError = unknown>(query: string, params?: QueryParams, options?: UseQueryOptionsDefinedInitial<QueryResponseResult>): Omit<QueryStoreState<QueryResponseResult, QueryResponseError>, 'data'> & {
      data: QueryResponseResult;
    } & WithEncodeDataAttribute;
  };
  useLiveMode: UseLiveModeHook;
}
declare namespace client_only_d_exports {
  export { NonUndefinedGuard, QueryResponseInitial, QueryStore, UseLiveModeHook, UseQueryHook, UseQueryOptions, UseQueryOptionsDefinedInitial, UseQueryOptionsUndefinedInitial, createQueryStore, loadQuery, setServerClient, useLiveMode, useQuery };
}
declare const createQueryStore: (options: CreateQueryStoreOptions) => QueryStore;
/**
 * Shortcut setup for the main SSR use-case.
 * @public
 */
declare const loadQuery: <QueryResponseResult>(query: string, params?: _sanity_client4.QueryParams, options?: Pick<_sanity_client4.ResponseQueryOptions, "perspective" | "cache" | "next" | "useCdn" | "stega" | "tag" | "headers">) => Promise<QueryResponseInitial<QueryResponseResult>>, setServerClient: (client: _sanity_client4.SanityClient | _sanity_client_stega0.SanityStegaClient) => void, useLiveMode: UseLiveModeHook, useQuery: {
    <QueryResponseResult = unknown, QueryResponseError = unknown>(query: string, params?: _sanity_client4.QueryParams, options?: UseQueryOptionsUndefinedInitial): _sanity_core_loader1.QueryStoreState<QueryResponseResult, QueryResponseError> & {
      encodeDataAttribute: EncodeDataAttributeFunction;
    };
    <QueryResponseResult = unknown, QueryResponseError = unknown>(query: string, params?: _sanity_client4.QueryParams, options?: UseQueryOptionsDefinedInitial<QueryResponseResult>): Omit<_sanity_core_loader1.QueryStoreState<QueryResponseResult, QueryResponseError>, "data"> & {
      data: QueryResponseResult;
    } & {
      encodeDataAttribute: EncodeDataAttributeFunction;
    };
  };
/** @public */
type EncodeDataAttributeCallback = (path: StudioPathLike) => string | undefined;
/** @public */
declare function useEncodeDataAttribute<QueryResponseResult = unknown>(result: QueryResponseResult, sourceMap: ContentSourceMap | undefined, studioUrl: StudioUrl | ResolveStudioUrl | undefined): EncodeDataAttributeFunction;
declare namespace index_browser_d_exports {
  export { ContentSourceMap, EncodeDataAttributeCallback, NonUndefinedGuard, QueryResponseInitial, QueryStore, ResolveStudioUrl, StudioPathLike, StudioUrl, UseLiveModeHook, UseQueryHook, UseQueryOptions, UseQueryOptionsDefinedInitial, UseQueryOptionsUndefinedInitial, createQueryStore, loadQuery, setServerClient, useEncodeDataAttribute, useLiveMode, useQuery };
}
export { type ContentSourceMap, EncodeDataAttributeCallback, type NonUndefinedGuard, type QueryResponseInitial, type QueryStore, type ResolveStudioUrl, type StudioPathLike, type StudioUrl, type UseLiveModeHook, UseQueryHook, UseQueryOptions, type UseQueryOptionsDefinedInitial, type UseQueryOptionsUndefinedInitial, createQueryStore, loadQuery, setServerClient, useEncodeDataAttribute, useLiveMode, useQuery };
//# sourceMappingURL=index.browser.d.cts.map