import { useQuery, } from '@tanstack/react-query';
import { useSeamClient } from '../../lib/seam/use-seam-client.js';
export function useSeamQuery(endpointPath, parameters, options = {}) {
    const { endpointClient: client, queryKeyPrefixes } = useSeamClient();
    return useQuery({
        enabled: client != null,
        ...options,
        queryKey: [
            ...queryKeyPrefixes,
            ...endpointPath.split('/').filter((v) => v !== ''),
            parameters,
        ],
        queryFn: async () => {
            if (client == null)
                return null;
            // Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
            // Type assertion is needed here for performance reasons. The types are correct at runtime.
            const endpoint = client[endpointPath];
            return await endpoint(parameters, options);
        },
    });
}
//# sourceMappingURL=use-seam-query.js.map