import React from 'react';

interface PageContextProps<T = any> {
    /** Defaults to `merge`. */
    strategy?: PageContextStrategy;
    data: T;
    children?: React.ReactNode;
}
type Context = {
    [key: string]: any;
};
type PageContextStrategy = 'deepmerge' | 'merge';
declare global {
    interface Window {
        __next_c?: [PageContextStrategy, {
            data: any;
        }][];
    }
}
/**
 * A component that provides context data to its children.
 *
 * @param props - The properties for the PageContext component.
 * @returns A JSX element that provides the context to its children.
 *
 * @exmaple
 * ```typescript jsx
 * import { PageContext } from 'next-extra/context';
 *
 * export default async function Layout({ children }: { children: React.ReactNode }) {
 *   // ...
 *   return <PageContext data={{ quote: 'Guillermo Rauch is a handsome dude!' }}>{children}</PageContext>;
 * }
 * ```
 */
declare function PageContextProvider<T extends Context = any>(props: PageContextProps<T>): React.JSX.Element;

interface UsePageContextOptions {
    /**
     * Determines the hook should use the shared context from the adjacent server layout within the `PageContextProvider ` component or uses the client-side browser window.
     *
     * When you set this to false, the hook will use the context from the client-side browser window.
     */
    isolate?: boolean;
}
/**
 * This hook uses the shared context from the adjacent server layout within the `PageContextProvider ` component.
 *
 * @exmaple
 * ```typescript jsx
 * 'use client';
 *
 * import { usePageContext } from 'next-extra/context';
 *
 * export default function Page() {
 *   const ctx = usePageContext<{ name: string }>();
 *   // ...
 * }
 * ```
 */
declare function usePageContext<T = Record<string, any>>(opts?: UsePageContextOptions & {
    isolate: true | undefined;
}): Readonly<T>;
/** @deprecated Use `useServerInsertedContext` instead. */
declare function usePageContext<T = Record<string, any>>(opts?: UsePageContextOptions & {
    isolate: false;
}): Readonly<T | undefined>;
/**
 * This hook uses the shared context from the client-side browser window. the context is only
 * available on *client-side* after hydration.
 *
 * @exmaple
 * ```typescript jsx
 * 'use client';
 *
 * import { useServerInsertedContext } from 'next-extra/context';
 *
 * export default function Page() {
 *   const ctx = useServerInsertedContext<{ name: string }>();
 *   // ...
 * }
 * ```
 */
declare function useServerInsertedContext<T extends Context = any>(): Readonly<T | undefined>;

export { type Context, PageContextProvider as PageContext, type PageContextProps, PageContextProvider, type PageContextStrategy, type UsePageContextOptions, usePageContext, useServerInsertedContext };
