"use client";
import { useCallback, useState } from "react";
import { DEFAULT_TOOLTIP_POSITION, DEFAULT_TOOLTIP_THRESHOLD } from "./constants.js";
import { getPosition } from "./utils.js";
/** @internal */ const noop = ()=>{
// do nothing
};
/**
 * A hook that's used to determine the "best" position to render the tooltip
 * within the viewport.
 *
 * @internal
 * @remarks \@since 2.8.0
 */ export function useTooltipPosition(options) {
    const { position: determinedPosition, threshold = DEFAULT_TOOLTIP_THRESHOLD, defaultPosition = DEFAULT_TOOLTIP_POSITION } = options;
    const [position, setPosition] = useState(defaultPosition);
    const updatePosition = useCallback((container)=>{
        setPosition(getPosition({
            container,
            threshold,
            defaultPosition
        }));
    }, [
        defaultPosition,
        threshold
    ]);
    if (typeof determinedPosition !== "undefined") {
        return [
            determinedPosition,
            noop
        ];
    }
    return [
        position,
        updatePosition
    ];
}

//# sourceMappingURL=useTooltipPosition.js.map