import { ClientPerspective, ContentSourceMap, ContentSourceMap as ContentSourceMap$2, QueryParams, ResponseQueryOptions } from "@sanity/client";
import { EnableLiveModeOptions, QueryStoreState, createQueryStore } from "@sanity/core-loader";
import { ContentSourceMap as ContentSourceMap$1, ResolveStudioUrl, ResolveStudioUrl as ResolveStudioUrl$1, StudioPathLike, StudioPathLike as StudioPathLike$1, StudioUrl, StudioUrl as StudioUrl$1 } from "@sanity/client/csm";
/**
 * @public
 */
type EncodeDataAttributeFunction = {
  (path: StudioPathLike): string | undefined;
  scope: (path: StudioPathLike) => 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 | 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 | ResolveStudioUrl | 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>['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;
}
/** @public */
type EncodeDataAttributeCallback = (path: StudioPathLike$1) => string | undefined;
/** @public */
declare function useEncodeDataAttribute<QueryResponseResult = unknown>(result: QueryResponseResult, sourceMap: ContentSourceMap$2 | undefined, studioUrl: StudioUrl$1 | ResolveStudioUrl$1 | undefined): EncodeDataAttributeFunction;
export { __reExport as _, StudioUrl$1 as a, QueryResponseInitial as c, UseQueryHook as d, UseQueryOptions as f, __exportAll as g, EncodeDataAttributeFunction as h, StudioPathLike$1 as i, QueryStore as l, UseQueryOptionsUndefinedInitial as m, EncodeDataAttributeCallback as n, useEncodeDataAttribute as o, UseQueryOptionsDefinedInitial as p, ResolveStudioUrl$1 as r, NonUndefinedGuard as s, ContentSourceMap$2 as t, UseLiveModeHook as u };
//# sourceMappingURL=useEncodeDataAttribute.d.cts.map