"use client";
import { useWindowSize } from "../useWindowSize.js";
import { useWindowSplitter } from "../window-splitter/useWindowSplitter.js";
/**
 * A custom window splitter implementation to be used with the
 * `LayoutWindowSplitter` that will dynamically configure the max width to be a
 * percentage of the current window's width.
 *
 * Note: This will automatically save the width in local storage as
 * `"navWidth"`. See the example below if you do not want to use local storage.
 *
 * @example
 * Without this hook
 * ```tsx
 * import { useWindowSize, useWindowSplitter } from "@react-md/core";
 * import type { ProvidedLayoutWindowSplitterProps } from "@react-md/core";
 *
 * export function useMyLayoutWindowSplitter(): ProvidedLayoutWindowSplitterProps {
 *   const { width } = useWindowSize({ disableHeight: true });
 *   const { splitterProps, value } = useWindowSplitter({
 *     min: 96,
 *     max: Math.max(maxMinimum, width * 0.45),
 *     maxMinimum: 600,
 *   });
 *
 *   return {
 *     ...splitterProps,
 *     navWidth: value,
 *   };
 * }
 *
 * function MyLayout() {
 *   const splitterProps = useMyLayoutWindowSplitter();
 *
 *   return (
 *     <LayoutWindowSplitter
 *       {...splitterProps}
 *       aria-controls="layout-nav-id"
 *     />
 *   );
 * }
 * ```
 *
 * @see {@link useResizableLayout} For a pre-built solution.
 * @remarks \@since 6.0.0
 */ export function useLayoutWindowSplitter(options = {}) {
    const { min = 96, maxMinimum = 600, windowPercentage = 0.45, defaultValue = 256, ...remaining } = options;
    const { width } = useWindowSize({
        disableHeight: true
    });
    const implementation = useWindowSplitter({
        min,
        max: Math.max(maxMinimum, width * windowPercentage),
        defaultValue,
        // type cast so it doesn't complain about defaultValue being provided with
        // value. That's mostly for public api usage
        ...remaining
    });
    return {
        ...implementation,
        splitterProps: {
            ...implementation.splitterProps,
            navWidth: implementation.value
        }
    };
}

//# sourceMappingURL=useLayoutWindowSplitter.js.map