"use client";
import { useEffect } from "react";
import { initScrollRestoration } from "../scroll-restoration.js";
/**
 * ScrollRestoration component
 *
 * Enables scroll position restoration across navigations:
 * - Saves scroll positions to sessionStorage
 * - Restores scroll on back/forward navigation
 * - Scrolls to top on new navigation
 * - Supports hash link scrolling
 *
 * Should be rendered once in your app, typically in the root layout.
 *
 * @example
 * ```tsx
 * // In your root layout
 * export default function RootLayout({ children }) {
 *   return (
 *     <html>
 *       <body>
 *         <ScrollRestoration />
 *         {children}
 *       </body>
 *     </html>
 *   );
 * }
 * ```
 */
export function ScrollRestoration({ getKey }) {
    useEffect(() => {
        const cleanup = initScrollRestoration({ getKey });
        return cleanup;
    }, [getKey]);
    // This component doesn't render anything
    return null;
}
/**
 * Hook to initialize scroll restoration
 *
 * Alternative to the ScrollRestoration component for more control.
 *
 * @example
 * ```tsx
 * function App() {
 *   useScrollRestoration();
 *   return <div>...</div>;
 * }
 * ```
 */
export function useScrollRestoration(options) {
    useEffect(() => {
        const cleanup = initScrollRestoration({ getKey: options?.getKey });
        return cleanup;
    }, [options?.getKey]);
}
//# sourceMappingURL=ScrollRestoration.js.map