import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useSeamClient } from '../../../lib/seam/use-seam-client.js';
export function useEvents(params, { refetchInterval } = {}) {
    const { client } = useSeamClient();
    const queryClient = useQueryClient();
    const { data, ...rest } = useQuery({
        enabled: client != null,
        queryKey: ['events', 'list', params],
        queryFn: async () => {
            if (client == null)
                return [];
            const events = await client.events.list(params);
            for (const event of events) {
                queryClient.setQueryData(['events', 'get', { event_id: event.event_id }], event);
            }
            // UPSTREAM: Response type does not match SeamEvent[].
            return events;
        },
        refetchInterval,
    });
    return { ...rest, events: data };
}
//# sourceMappingURL=use-events.js.map