
    ?f	              	       (   d dl Z d dlmZmZmZmZ d dlmZ ddlm	Z	 ddl
mZ ddlmZmZ  ed          Zd	ed
ee         dee         fdZd
ee         d	edeee                  fdZdee         d
ee         deee         ee         f         fdZdS )    N)AsyncIterableListTupleTypeVar)maybe_await   )iter)islice)AnyIterable	PredicateTniterablereturnc                 p   K   | dk     rt          d          d t          ||           2              d{V S )a	  
    Return the first n items of iterable as a list.

    If there are too few items in iterable, all of them are returned.
    n needs to be at least 0. If it is 0, an empty list is returned.

    Example::

        first_two = await take(2, [1, 2, 3, 4, 5])

    r   z(take's first parameter can't be negativec                 "   K   g | 3 d {V }|
6 S N ).0items     j/home/panchajanya/Development/work/volatility3/lib/python3.11/site-packages/aioitertools/more_itertools.py
<listcomp>ztake.<locals>.<listcomp>   s.      777777774D7777s   N)
ValueErrorr
   )r   r   s     r   taker      sP       	1uuCDDD776(A#6#67777777777    c                   K   t          |           }t          ||           d{V }|g k    r#|W V  t          ||           d{V }|g k    !dS dS )a#  
    Break iterable into chunks of length n.

    The last chunk will be shorter if the total number of items is not
    divisible by n.

    Example::

        async for chunk in chunked([1, 2, 3, 4, 5], n=2):
            ...  # first iteration: chunk == [1, 2]; last one: chunk == [5]
    N)r	   r   )r   r   itchunks       r   chunkedr   "   sx       
hBq"++E
2++1bkk!!!!!! 2++++++r   	predicatec                     K   t          |          t          j                                                     fd}fd} |             |            fS )a  
    A variant of :func:`aioitertools.takewhile` that allows complete access to the
    remainder of the iterator.

         >>> it = iter('ABCdEfGhI')
         >>> all_upper, remainder = await before_and_after(str.isupper, it)
         >>> ''.join([char async for char in all_upper])
         'ABC'
         >>> ''.join([char async for char in remainder])
         'dEfGhI'

    Note that the first iterator must be fully consumed before the second
    iterator can generate valid results.
    c                    K   2 3 d {V } t           |                      d {V r| W V  +                    |             d S 6                     t                     d S r   )r   
set_resultset_exceptionStopAsyncIteration)elemr   r    
transitions    r   true_iteratorz'before_and_after.<locals>.true_iteratorK   s       	 	 	 	 	 	 	$ 411111111 




%%d+++  	  !344444s   A	c                 h   K   	  d {V W V  n# t           $ r Y d S w xY w2 3 d {V } | W V  6 d S r   )r%   )elmr   r'   s    r   remainder_iteratorz,before_and_after.<locals>.remainder_iteratorU   s      	#######$$$$$! 	 	 	FF	  	 	 	 	 	 	 	#IIIII s    
1)r	   asyncioget_event_loopcreate_future)r    r   r(   r+   r   r'   s   `   @@r   before_and_afterr/   5   s      $ 
hB'))7799J5 5 5 5 5 5 5      =??..0000r   )r,   typingr   r   r   r   aioitertools.helpersr   builtinsr	   	itertoolsr
   typesr   r   r   intr   r   r/   r   r   r   <module>r6      sJ    6 6 6 6 6 6 6 6 6 6 6 6 , , , , , ,             ) ) ) ) ) ) ) ) GCLL8# 8Q 8DG 8 8 8 8""KN "s "}T!W7M " " " "&)1|)1'21~)1
=]1--.)1 )1 )1 )1 )1 )1r   