import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useSeamClient } from '../../../lib/seam/use-seam-client.js';
export function useAccessCodes(params) {
    const { client } = useSeamClient();
    const queryClient = useQueryClient();
    const { data, ...rest } = useQuery({
        enabled: client != null,
        queryKey: ['access_codes', 'list', params],
        queryFn: async () => {
            if (client == null)
                return [];
            const accessCodes = await client.accessCodes.list(params);
            for (const accessCode of accessCodes) {
                queryClient.setQueryData([
                    'access_codes',
                    'get',
                    { access_code_id: accessCode.access_code_id },
                ], accessCode);
            }
            return accessCodes;
        },
    });
    return { ...rest, accessCodes: data };
}
//# sourceMappingURL=use-access-codes.js.map