
    i!                    "   d Z ddlmZ ddlmZ ddlZddlZddlZ	ddl
mZmZmZmZmZ ddlmZmZ dZ ej(                  d	      Z ej(                  d
      Z ej(                  d      Z ej(                  d      Zej2                  dd       Zej2                  dd       Zej2                  dd       Zej2                  dd       Zd Zej2                  ddd       Zej2                  	 	 	 	 	 	 dd       Zej2                  	 	 	 	 	 	 dd       Zej2                  	 	 	 	 	 	 dd       Zej2                  ddd       Zej2                  	 	 	 	 	 	 dd       Zej2                  dd       Zej2                  dd       ZddZ	 d	 	 	 	 	 ddZej2                  	 d	 	 	 	 	 dd       Zej2                  	 d	 	 	 	 	 dd       Zej2                  	 d	 	 	 	 	 dd       Zej2                  	 d	 	 	 	 	 dd       Zej2                  	 d	 	 	 	 	 dd        Zej2                  	 d	 	 	 	 	 dd!       Zdd"Zej2                  	 d	 	 	 	 	 dd#       Zej2                  	 d	 	 	 	 	 dd$       Zej2                  	 d	 	 	 	 	 dd%       Zej2                  	 d	 	 	 	 	 dd&       Zej2                  	 d	 	 	 	 	 dd'       Zej2                  	 d	 	 	 	 	 dd(       Zdd)Zej2                  	 d	 	 	 	 	 dd*       Zej2                  	 d	 	 	 	 	 dd+       Zej2                  	 d	 	 	 	 	 dd,       Zej2                  	 d	 	 	 	 	 dd-       Zej2                  	 d	 	 	 	 	 dd.       Zej2                  	 d	 	 	 	 	 dd/       Zdd0Zej2                  	 	 	 	 	 	 dd1       Z ej2                  	 	 	 	 	 	 dd2       Z ej2                  	 	 	 	 	 	 dd3       Z ej2                  	 	 	 	 	 	 dd4       Z ej2                  dd5       Z ej2                  dd6       Z ej2                  ddd7       Z ej2                  ddd8       Z ej2                  	 	 	 	 	 	 dd9       Z ej2                  	 	 	 	 	 	 dd:       Z ej2                  	 	 	 	 	 	 dd;       Z ej2                  	 	 	 	 	 	 dd<       Z ej2                  dd=       Z ej2                  dd>       Z ej2                  ddd?       Z ej2                  ddd@       Z ddAZ ej2                  	 d	 	 	 	 	 ddB       Z!ej2                  	 d	 	 	 	 	 ddC       Z!ej2                  	 d	 	 	 	 	 ddD       Z!ej2                  	 d	 	 	 	 	 ddE       Z!ej2                  	 d	 	 	 	 	 ddF       Z!ej2                  	 d	 	 	 	 	 ddG       Z!ddHZ!ej2                  	 	 d	 	 	 	 	 	 	 ddI       Z"ej2                  	 	 d	 	 	 	 	 	 	 ddJ       Z"ej2                  	 	 d	 	 	 	 	 	 	 ddK       Z"ej2                  	 	 d	 	 	 	 	 	 	 ddL       Z"ej2                  	 	 d	 	 	 	 	 	 	 ddM       Z"ej2                  	 	 d	 	 	 	 	 	 	 ddN       Z"ddOZ"ej2                  	 d	 	 	 	 	 d dP       Z#ej2                  	 d	 	 	 	 	 ddQ       Z#ej2                  	 d	 	 	 	 	 ddR       Z#ej2                  	 d	 	 	 	 	 ddS       Z#ej2                  	 d	 	 	 	 	 ddT       Z#ej2                  	 d	 	 	 	 	 ddU       Z#ddVZ#ej2                  	 	 	 	 	 	 ddW       Z$ej2                  	 	 	 	 	 	 ddX       Z$ej2                  	 	 	 	 	 	 ddY       Z$ej2                  	 	 	 	 	 	 d	dZ       Z$ej2                  	 	 	 	 	 	 d
d[       Z$ej2                  	 	 	 	 	 	 dd\       Z$d] Z$ej2                  dd^       Z%ej2                  	 d	 	 	 	 	 dd_       Z%dd`Z%	 d	 	 	 	 	 	 	 ddaZ&	 	 	 	 	 	 	 	 	 	 ddbZ'ej2                  ddc       Z(ej2                  	 d	 	 	 	 	 ddd       Z(ddeZ(ej2                  ddf       Z)ej2                  ddg       Z)ej2                  	 	 	 	 	 	 ddh       Z)ej2                  ddi       Z)ej2                  ddj       Z)ej2                  	 	 	 	 	 	 ddk       Z)ej2                  	 d	 	 	 	 	 ddl       Z)ddmZ)ddnZ*ej2                  	 d	 	 	 	 	 	 	 	 	 ddo       Z+ej2                  	 	 d	 	 	 	 	 	 	 	 	 ddp       Z+ej2                  	 d	 	 	 	 	 	 	 	 	 ddq       Z+ej2                  	 	 d	 	 	 	 	 	 	 	 	 ddr       Z+ddsZ+ej2                  	 	 	 	 	 	 ddt       Z,ej2                  	 	 	 	 	 	 ddu       Z,ej2                  	 	 	 	 	 	 ddv       Z,ej2                  	 d	 	 	 	 	 ddw       Z,ej2                  	 	 	 	 	 	 ddx       Z,ej2                  	 	 	 	 	 	 d dy       Z,ej2                  	 	 	 	 	 	 d!dz       Z,ej2                  	 d	 	 	 	 	 d"d{       Z,dd|Z,d#d}Z-ej2                  	 	 	 	 	 	 	 	 d$d~       Z.ej2                  	 	 	 	 	 	 	 	 d%d       Z.ej2                  	 	 	 	 	 	 	 	 d&d       Z.ej2                  	 d	 	 	 	 	 	 	 d'd       Z.ej2                  	 d	 	 	 	 	 	 	 d(d       Z.ej2                  	 d	 	 	 	 	 	 	 d)d       Z.ej2                  	 	 	 	 	 	 	 	 d*d       Z.ej2                  	 	 	 	 	 	 	 	 d+d       Z.ej2                  	 	 	 	 	 	 	 	 d,d       Z.ej2                  	 d	 	 	 	 	 	 	 d-d       Z.ej2                  	 d	 	 	 	 	 	 	 d.d       Z.ej2                  	 d	 	 	 	 	 	 	 d/d       Z.ej2                  	 d0	 	 	 	 	 	 	 d1d       Z.d0dZ.ej2                  	 	 	 	 	 	 	 	 d$d       Z/ej2                  	 	 	 	 	 	 	 	 d%d       Z/ej2                  	 	 	 	 	 	 	 	 d&d       Z/ej2                  	 d	 	 	 	 	 	 	 d'd       Z/ej2                  	 d	 	 	 	 	 	 	 d(d       Z/ej2                  	 d	 	 	 	 	 	 	 d)d       Z/ej2                  	 	 	 	 	 	 	 	 d*d       Z/ej2                  	 	 	 	 	 	 	 	 d+d       Z/ej2                  	 	 	 	 	 	 	 	 d,d       Z/ej2                  	 d	 	 	 	 	 	 	 d-d       Z/ej2                  	 d	 	 	 	 	 	 	 d.d       Z/ej2                  	 d	 	 	 	 	 	 	 d/d       Z/ej2                  	 d0	 	 	 	 	 	 	 d1d       Z/d0dZ/ej2                  	 d	 	 	 	 	 	 	 	 	 d2d       Z0ej2                  	 d	 	 	 	 	 	 	 	 	 d3d       Z0ej2                  	 d	 	 	 	 	 	 	 	 	 d4d       Z0ej2                  	 	 d	 	 	 	 	 	 	 	 	 d5d       Z0ej2                  	 	 d	 	 	 	 	 	 	 	 	 d6d       Z0ej2                  	 	 d	 	 	 	 	 	 	 	 	 d7d       Z0ej2                  	 d	 	 	 	 	 	 	 	 	 d8d       Z0ej2                  	 d	 	 	 	 	 	 	 	 	 d9d       Z0ej2                  	 d	 	 	 	 	 	 	 	 	 d:d       Z0ej2                  	 	 d	 	 	 	 	 	 	 	 	 d;d       Z0ej2                  	 	 d	 	 	 	 	 	 	 	 	 d<d       Z0ej2                  	 	 d	 	 	 	 	 	 	 	 	 d=d       Z0ej2                  	 	 	 d>	 	 	 	 	 	 	 	 	 d?d       Z0d>dZ0ej2                  	 	 	 	 	 	 	 	 d@d       Z1ej2                  	 	 	 	 	 	 	 	 dAd       Z1ej2                  	 	 	 	 	 	 	 	 dBd       Z1ej2                  	 d	 	 	 	 	 	 	 dCd       Z1ej2                  	 d	 	 	 	 	 	 	 dDd       Z1ej2                  	 d	 	 	 	 	 	 	 dEd       Z1ej2                  	 	 	 	 	 	 	 	 dFd       Z1ej2                  	 	 	 	 	 	 	 	 dGd       Z1ej2                  	 	 	 	 	 	 	 	 dHd       Z1ej2                  	 d	 	 	 	 	 	 	 dId       Z1ej2                  	 d	 	 	 	 	 	 	 dJd       Z1ej2                  	 d	 	 	 	 	 	 	 dKd       Z1ej2                  	 d0	 	 	 	 	 	 	 dLd       Z1d0dZ1ej2                  	 d	 	 	 	 	 dd       Z2ej2                  	 d	 	 	 	 	 dd       Z2ej2                  	 d	 	 	 	 	 dd       Z2ej2                  	 d	 	 	 	 	 dd       Z2ej2                  	 d	 	 	 	 	 dd       Z2ej2                  	 d	 	 	 	 	 dd       Z2ddZ2dMdZ3d̐dNdZ4ej2                  dOd       Z5ej2                  dPd       Z5d Z5dQdZ6	 d	 	 	 	 	 dRdÄZ7ej2                  	 	 d	 	 	 	 	 	 	 dSdĄ       Z8ej2                  	 	 d	 	 	 	 	 	 	 dTdń       Z8ddƄZ8	 d	 	 	 	 	 dUdǄZ9y(V  zE
Functions that operate on lists and dicts.

.. versionadded:: 1.0.0
    )annotations)
cmp_to_keyN   )callitcmpgetargcountiteratoriteriteratee)IterateeObjTPathT)atcount_byeveryfilter_find	find_lastflat_mapflat_map_deepflat_map_depthfor_eachfor_each_rightgroup_byincludes
invoke_mapkey_bymap_nestorder_by	partitionpluckreduce_reduce_right
reductionsreductions_rightrejectsamplesample_sizeshufflesizesomesort_byTT2T3T4c                     y N 
collectionpathss     J/home/Script/Script_env/lib/python3.12/site-packages/pydash/collections.pyr   r   ;   s    NQ    c                     y r1   r2   r3   s     r6   r   r   ?       ]`r7   c                     y r1   r2   r3   s     r6   r   r   C   s    LOr7   c                     y r1   r2   r3   s     r6   r   r   G   s    _br7   c                2     t        j                  | |       S )a  
    Creates a list of elements from the specified indexes, or keys, of the collection. Indexes may
    be specified as individual arguments or as arrays of indexes.

    Args:
        collection: Collection to iterate over.
        *paths: The indexes of `collection` to retrieve, specified as individual indexes or
            arrays of indexes.

    Returns:
        filtered list

    Example:

        >>> at([1, 2, 3, 4], 0, 2)
        [1, 3]
        >>> at({"a": 1, "b": 2, "c": 3, "d": 4}, "a", "c")
        [1, 3]
        >>> at({"a": 1, "b": 2, "c": {"d": {"e": 3}}}, "a", ["c", "d", "e"])
        [1, 3]

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.1.0
        Support deep path access.
    )pyd
propertiesr3   s     r6   r   r   K   s    6 "3>>5!*--r7   c                     y r1   r2   r4   iteratees     r6   r   r   i       Z]r7   c                     y r1   r2   r@   s     r6   r   r   m        r7   c                     y r1   r2   r@   s     r6   r   r   s   rD   r7   c                     y r1   r2   r@   s     r6   r   r   y   rD   r7   c                     y r1   r2   r@   s     r6   r   r          RUr7   c                     y r1   r2   r@   s     r6   r   r      rD   r7   c                     y r1   r2   r@   s     r6   r   r      s    `cr7   c                     y r1   r2   r@   s     r6   r   r          [^r7   c                v    i }t        | |      D ]'  }|j                  |d   d       ||d   xx   dz  cc<   ) |S )a  
    Creates an object composed of keys generated from the results of running each element of
    `collection` through the iteratee.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        Dict containing counts by key.

    Example:

        >>> results = count_by([1, 2, 1, 2, 3, 4])
        >>> assert results == {1: 2, 2: 2, 3: 1, 4: 1}
        >>> results = count_by(["a", "A", "B", "b"], lambda x: x.lower())
        >>> assert results == {"a": 2, "b": 2}
        >>> results = count_by({"a": 1, "b": 1, "c": 3, "d": 3})
        >>> assert results == {1: 2, 3: 2}

    .. versionadded:: 1.0.0
    r   r   )r
   
setdefault)r4   rA   retresults       r6   r   r      sJ    . Cz84 vay!$F1I! Jr7   c                ^    |r t        j                  |      fd| D        } t        |       S )a  
    Checks if the predicate returns a truthy value for all elements of a collection. The predicate
    is invoked with three arguments: ``(value, index|key, collection)``. If a property name is
    passed for predicate, the created :func:`pluck` style predicate will return the property value
    of the given element. If an object is passed for predicate, the created :func:`.matches` style
    predicate will return ``True`` for elements that have the properties of the given object, else
    ``False``.

    Args:
        collection: Collection to iterate over.
        predicate: Predicate applied per iteration.

    Returns:
        Whether all elements are truthy.

    Example:

        >>> every([1, True, "hello"])
        True
        >>> every([1, False, "hello"])
        False
        >>> every([{"a": 1}, {"a": True}, {"a": "hello"}], "a")
        True
        >>> every([{"a": 1}, {"a": False}, {"a": "hello"}], "a")
        False
        >>> every([{"a": 1}, {"a": 1}], {"a": 1})
        True
        >>> every([{"a": 1}, {"a": 2}], {"a": 1})
        False

    .. versionadded:: 1.0.0

    .. versionchanged: 4.0.0
        Removed alias ``all_``.
    c              3  .   K   | ]  } |        y wr1   r2   .0itemcbks     r6   	<genexpr>zevery.<locals>.<genexpr>        7Dc$i7   )r=   rA   allr4   	predicaterV   s     @r6   r   r      s+    L ll9%7J7
z?r7   c                     y r1   r2   r4   r\   s     r6   r   r           r7   c                     y r1   r2   r^   s     r6   r   r      r_   r7   c                     y r1   r2   r^   s     r6   r   r      r_   r7   c                     y r1   r2   r^   s     r6   r   r           r7   c                     y r1   r2   r^   s     r6   r   r      rc   r7   c                     y r1   r2   r^   s     r6   r   r     rc   r7   c           	     \    t        | |      D cg c]  \  }}}}|s| c}}}S c c}}}w )aG  
    Iterates over elements of a collection, returning a list of all elements the predicate returns
    truthy for.

    Args:
        collection: Collection to iterate over.
        predicate: Predicate applied per iteration.

    Returns:
        Filtered list.

    Example:

        >>> results = filter_([{"a": 1}, {"b": 2}, {"a": 1, "b": 3}], {"a": 1})
        >>> assert results == [{"a": 1}, {"a": 1, "b": 3}]
        >>> filter_([1, 2, 3, 4], lambda x: x >= 3)
        [3, 4]

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Removed alias ``select``.
    r
   r4   r\   is_truevalue_s        r6   r   r     s.    0 /;:y.Q]]*guaU\E]]]   ''c                     y r1   r2   r^   s     r6   r   r   #       r7   c                     y r1   r2   r^   s     r6   r   r   *  rn   r7   c                     y r1   r2   r^   s     r6   r   r   1  rn   r7   c                     y r1   r2   r^   s     r6   r   r   8       r7   c                     y r1   r2   r^   s     r6   r   r   ?  rr   r7   c                     y r1   r2   r^   s     r6   r   r   F  rr   r7   c                @    d t        | |      D        }t        |d      S )a/  
    Iterates over elements of a collection, returning the first element that the predicate returns
    truthy for.

    Args:
        collection: Collection to iterate over.
        predicate: Predicate applied per iteration.

    Returns:
        First element found or ``None``.

    Example:

        >>> find([1, 2, 3, 4], lambda x: x >= 3)
        3
        >>> find([{"a": 1}, {"b": 2}, {"a": 1, "b": 2}], {"a": 1})
        {'a': 1}

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Removed aliases ``detect`` and ``find_where``.
    c              3  0   K   | ]  \  }}}}|s|  y wr1   r2   rT   ri   rj   rk   s       r6   rW   zfind.<locals>.<genexpr>e  s     _,1W^e_s   Nr
   nextr4   r\   searchs      r6   r   r   M  s#    0 `Z0S_Fr7   c                     y r1   r2   r^   s     r6   r   r   i  rn   r7   c                     y r1   r2   r^   s     r6   r   r   p  rn   r7   c                     y r1   r2   r^   s     r6   r   r   w  rn   r7   c                     y r1   r2   r^   s     r6   r   r   ~  rr   r7   c                     y r1   r2   r^   s     r6   r   r     rr   r7   c                     y r1   r2   r^   s     r6   r   r     rr   r7   c                D    d t        | |d      D        }t        |d      S )a,  
    This method is like :func:`find` except that it iterates over elements of a `collection` from
    right to left.

    Args:
        collection: Collection to iterate over.
        predicate: Predicate applied per iteration.

    Returns:
        Last element found or ``None``.

    Example:

        >>> find_last([1, 2, 3, 4], lambda x: x >= 3)
        4
        >>> results = find_last([{'a': 1}, {'b': 2}, {'a': 1, 'b': 2}],                                 {'a': 1})
        >>> assert results == {'a': 1, 'b': 2}

    .. versionadded:: 1.0.0
    c              3  .   K   | ]  \  }}}}|r|  y wr1   r2   rw   s       r6   rW   zfind_last.<locals>.<genexpr>  s#       GUAq 	s   TreverseNrx   rz   s      r6   r   r     s*    ,$0YPT$UF
 r7   c                     y r1   r2   r@   s     r6   r   r          r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r9   r7   c                     y r1   r2   r@   s     r6   r   r     s    ^ar7   c                     y r1   r2   r@   s     r6   r   r         adr7   c                     y r1   r2   r@   s     r6   r   r     s    UXr7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     rL   r7   c                     y r1   r2   r@   s     r6   r   r     s    VYr7   c                     y r1   r2   r@   s     r6   r   r         Y\r7   c                     y r1   r2   r@   s     r6   r   r     s    MPr7   c                B    t        j                  t        | |            S )a  
    Creates a flattened list of values by running each element in collection through `iteratee` and
    flattening the mapped results. The `iteratee` is invoked with three arguments: ``(value,
    index|key, collection)``.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        Flattened mapped list.

    Example:

        >>> duplicate = lambda n: [[n, n]]
        >>> flat_map([1, 2], duplicate)
        [[1, 1], [2, 2]]

    .. versionadded:: 4.0.0
    rA   )r=   flattenitermapr@   s     r6   r   r     s    * ;;wzH=>>r7   c                     y r1   r2   r@   s     r6   r   r          r7   c                     y r1   r2   r@   s     r6   r   r           r7   c                     y r1   r2   r@   s     r6   r   r   &  r   r7   c                     y r1   r2   r@   s     r6   r   r   ,  r   r7   c                     y r1   r2   r@   s     r6   r   r   3  r   r7   c                     y r1   r2   r@   s     r6   r   r   9  r   r7   c                B    t        j                  t        | |            S )a  
    This method is like :func:`flat_map` except that it recursively flattens the mapped results.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        Flattened mapped list.

    Example:

        >>> duplicate = lambda n: [[n, n]]
        >>> flat_map_deep([1, 2], duplicate)
        [1, 1, 2, 2]

    .. versionadded:: 4.0.0
    r   )r=   flatten_deepr   r@   s     r6   r   r   ?  s    & GJBCCr7   c                     y r1   r2   r4   rA   depths      r6   r   r   U      
 r7   c                     y r1   r2   r   s      r6   r   r   ]  r   r7   c                     y r1   r2   r   s      r6   r   r   e  r   r7   c                     y r1   r2   r   s      r6   r   r   m  r   r7   c                     y r1   r2   r   s      r6   r   r   u  r   r7   c                     y r1   r2   r   s      r6   r   r   }  r   r7   c                F    t        j                  t        | |      |      S )a  
    This method is like :func:`flat_map` except that it recursively flattens the mapped results up
    to `depth` times.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        Flattened mapped list.

    Example:

        >>> duplicate = lambda n: [[n, n]]
        >>> flat_map_depth([1, 2], duplicate, 1)
        [[1, 1], [2, 2]]
        >>> flat_map_depth([1, 2], duplicate, 2)
        [1, 1, 2, 2]

    .. versionadded:: 4.0.0
    r   )r   )r=   flatten_depthr   r   s      r6   r   r     s    , WZ(C5QQr7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     rc   r7   c                     y r1   r2   r@   s     r6   r   r     rc   r7   c                     y r1   r2   r@   s     r6   r   r     rc   r7   c                @    t        d t        | |      D        d       | S )a  
    Iterates over elements of a collection, executing the iteratee for each element.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        `collection`

    Example:

        >>> results = {}
        >>> def cb(x):
        ...     results[x] = x**2
        >>> for_each([1, 2, 3, 4], cb)
        [1, 2, 3, 4]
        >>> assert results == {1: 1, 2: 4, 3: 9, 4: 16}

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Removed alias ``each``.
    c              3  4   K   | ]  \  }}}}|d u sd  ywFNr2   rT   rO   rk   s      r6   rW   zfor_each.<locals>.<genexpr>  s     	V<31aPU$	V   Nry   r
   r@   s     r6   r   r     s"    2 		V<
H#E	VX\]r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     rc   r7   c                     y r1   r2   r@   s     r6   r   r     rc   r7   c                     y r1   r2   r@   s     r6   r   r     rc   r7   c                D    t        d t        | |d      D        d       | S )a_  
    This method is like :func:`for_each` except that it iterates over elements of a `collection`
    from right to left.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        `collection`

    Example:

        >>> results = {"total": 1}
        >>> def cb(x):
        ...     results["total"] = x * results["total"]
        >>> for_each_right([1, 2, 3, 4], cb)
        [1, 2, 3, 4]
        >>> assert results == {"total": 24}

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Removed alias ``each_right``.
    c              3  4   K   | ]  \  }}}}|d u sd  ywr   r2   r   s      r6   rW   z!for_each_right.<locals>.<genexpr>*  s!     c,#q!QVY]bVbcr   Tr   Nr   r@   s     r6   r   r     s(    4 	c,z8T"Rc r7   c                     y r1   r2   r@   s     r6   r   r   0  r   r7   c                     y r1   r2   r@   s     r6   r   r   4  s      #r7   c                    i }t        j                  |      }| D ]0  } ||      }|j                  |g        ||   j                  |       2 |S )a  
    Creates an object composed of keys generated from the results of running each element of a
    `collection` through the iteratee.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        Results of grouping by `iteratee`.

    Example:

        >>> results = group_by([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}], 'a')
        >>> assert results == {1: [{'a': 1, 'b': 2}], 3: [{'a': 3, 'b': 4}]}
        >>> results = group_by([{'a': 1, 'b': 2}, {'a': 3, 'b': 4}], {'a': 1})
        >>> assert results == {False: [{'a': 3, 'b': 4}],                               True: [{'a': 1, 'b': 2}]}

    .. versionadded:: 1.0.0
    )r=   rA   rN   append)r4   rA   rO   rV   rj   keys         r6   r   r   :  sT    , C
,,x
 C %jsBC
 Jr7   c                \    t        | t              r| j                         }||v S | |d }||v S )a  
    Checks if a given value is present in a collection. If `from_index` is negative, it is used as
    the offset from the end of the collection.

    Args:
        collection: Collection to iterate over.
        target: Target value to compare to.
        from_index: Offset to start search from.

    Returns:
        Whether `target` is in `collection`.

    Example:

        >>> includes([1, 2, 3, 4], 2)
        True
        >>> includes([1, 2, 3, 4], 2, from_index=2)
        False
        >>> includes({"a": 1, "b": 2, "c": 3, "d": 4}, 2)
        True

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Renamed from ``contains`` to ``includes`` and removed alias
        ``include``.
    N)
isinstancedictvalues)r4   target
from_indexcollection_valuess       r6   r   r   [  sF    > *d#&--/
 &&& 'z{3&&&r7   c                *    t        | fd      S )aS  
    Invokes the method at `path` of each element in `collection`, returning a list of the results of
    each invoked method. Any additional arguments are provided to each invoked method. If `path` is
    a function, it's invoked for each element in `collection`.

    Args:
        collection: Collection to iterate over.
        path: String path to method to invoke or callable to invoke for each element in
            `collection`.
        args: Arguments to pass to method call.
        kwargs: Keyword arguments to pass to method call.

    Returns:
        List of results of invoking method of each item.

    Example:

        >>> items = [{"a": [{"b": 1}]}, {"a": [{"c": 2}]}]
        >>> expected = [{"b": 1}.items(), {"c": 2}.items()]
        >>> invoke_map(items, "a[0].items") == expected
        True

    .. versionadded:: 4.0.0
    c                8    t        j                  | gi S r1   )r=   invoke)rU   argskwargspaths    r6   <lambda>zinvoke_map.<locals>.<lambda>  s    D$)P)P)P r7   )r   )r4   r   r   r   s    ```r6   r   r     s    6 
PQQr7   c                     y r1   r2   r@   s     r6   r   r         WZr7   c                     y r1   r2   r@   s     r6   r   r     s     r7   c                X    i }t        j                  |      }| D ]  }|| ||      <    |S )aE  
    Creates an object composed of keys generated from the results of running each element of the
    collection through the given iteratee.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        Results of indexing by `iteratee`.

    Example:

        >>> results = key_by([{"a": 1, "b": 2}, {"a": 3, "b": 4}], "a")
        >>> assert results == {1: {"a": 1, "b": 2}, 3: {"a": 3, "b": 4}}


    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Renamed from ``index_by`` to ``key_by``.
    )r=   rA   )r4   rA   rO   rV   rj   s        r6   r   r     s:    . C
,,x
 C  CJ  Jr7   c                     y r1   r2   r@   s     r6   r   r     rB   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     rH   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                     y r1   r2   r@   s     r6   r   r     r   r7   c                ,    t        t        | |            S )a  
    Creates an array of values by running each element in the collection through the iteratee. The
    iteratee is invoked with three arguments: ``(value, index|key, collection)``. If a property name
    is passed for iteratee, the created :func:`pluck` style iteratee will return the property value
    of the given element. If an object is passed for iteratee, the created :func:`.matches` style
    iteratee will return ``True`` for elements that have the properties of the given object, else
    ``False``.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.

    Returns:
        Mapped list.

    Example:

        >>> map_([1, 2, 3, 4], str)
        ['1', '2', '3', '4']
        >>> map_([{"a": 1, "b": 2}, {"a": 3, "b": 4}, {"a": 5, "b": 6}], "a")
        [1, 3, 5]
        >>> map_([[[0, 1]], [[2, 3]], [[4, 5]]], "0.1")
        [1, 3, 5]
        >>> map_([{"a": {"b": 1}}, {"a": {"b": 2}}], "a.b")
        [1, 2]
        >>> map_([{"a": {"b": [0, 1]}}, {"a": {"b": [2, 3]}}], "a.b[1]")
        [1, 3]

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Removed alias ``collect``.
    )listr   r@   s     r6   r   r     s    D 
H-..r7   c                    |s| S t        j                  |      }|d   |dd c}t        j                  t        | |      fd      S )a  
    This method is like :func:`group_by` except that it supports nested grouping by multiple string
    `properties`. If only a single key is given, it is like calling ``group_by(collection, prop)``.

    Args:
        collection: Collection to iterate over.
        *properties: Properties to nest by.

    Returns:
        Results of nested grouping by `properties`.

    Example:

        >>> results = nest([{'shape': 'square', 'color': 'red', 'qty': 5},                            {'shape': 'square', 'color': 'blue', 'qty': 10},                            {'shape': 'square', 'color': 'orange', 'qty': 5},                            {'shape': 'circle', 'color': 'yellow', 'qty': 5},                            {'shape': 'circle', 'color': 'pink', 'qty': 10},                            {'shape': 'oval', 'color': 'purple', 'qty': 5}],                           'shape', 'qty')
        >>> expected = {            'square': {5: [{'shape': 'square', 'color': 'red', 'qty': 5},                           {'shape': 'square', 'color': 'orange', 'qty': 5}],                       10: [{'shape': 'square', 'color': 'blue', 'qty': 10}]},            'circle': {5: [{'shape': 'circle', 'color': 'yellow', 'qty': 5}],                       10: [{'shape': 'circle', 'color': 'pink', 'qty': 10}]},            'oval': {5: [{'shape': 'oval', 'color': 'purple', 'qty': 5}]}}
        >>> results == expected
        True

    .. versionadded:: 4.3.0
    r   r   Nc                    t        | g S r1   )r   )rj   rests    r6   r   znest.<locals>.<lambda>9  s    T%EWRVEW r7   )r=   r   
map_valuesr   )r4   r>   flat_propertiesfirstr   s       @r6   r   r     sM    B kk*-O!!$oab&9KE4>>(:u57WXXr7   c                     y r1   r2   r4   keysordersr   s       r6   r   r   <       r7   c                     y r1   r2   r   s       r6   r   r   E  r   r7   c                     y r1   r2   r   s       r6   r   r   N       r7   c                     y r1   r2   r   s       r6   r   r   W  r   r7   c                   t        | t              r| j                         } t        j                  |      r|}d}g |r\t        |      D ]M  \  }}t        j                  ||      r
||   rdnd}nd}j                  t        j                  |      |f       O nH|D ]C  }|j                  d      rd}|dd }nd}j                  t        j                  |      |f       E fd}t        | t        |      |      S )ax  
    This method is like :func:`sort_by` except that it sorts by key names instead of an iteratee
    function. Keys can be sorted in descending order by prepending a ``"-"`` to the key name (e.g.
    ``"name"`` would become ``"-name"``) or by passing a list of boolean sort options via `orders`
    where ``True`` is ascending and ``False`` is descending.

    Args:
        collection: Collection to iterate over.
        keys: List of keys to sort by. By default, keys will be sorted in ascending order. To
            sort a key in descending order, prepend a ``"-"`` to the key name. For example, to sort
            the key value for ``"name"`` in descending order, use ``"-name"``.
        orders: List of boolean sort orders to apply for each key. ``True``
            corresponds to ascending order while ``False`` is descending. Defaults to ``None``.
        reverse (bool, optional): Whether to reverse the sort. Defaults to ``False``.

    Returns:
        Sorted list.

    Example:

        >>> items = [{'a': 2, 'b': 1}, {'a': 3, 'b': 2}, {'a': 1, 'b': 3}]
        >>> results = order_by(items, ['b', 'a'])
        >>> assert results == [{'a': 2, 'b': 1},                               {'a': 3, 'b': 2},                               {'a': 1, 'b': 3}]
        >>> results = order_by(items, ['a', 'b'])
        >>> assert results == [{'a': 1, 'b': 3},                               {'a': 2, 'b': 1},                               {'a': 3, 'b': 2}]
        >>> results = order_by(items, ['-a', 'b'])
        >>> assert results == [{'a': 3, 'b': 2},                               {'a': 2, 'b': 1},                               {'a': 1, 'b': 3}]
        >>> results = order_by(items, ['a', 'b'], [False, True])
        >>> assert results == [{'a': 3, 'b': 2},                               {'a': 2, 'b': 1},                               {'a': 1, 'b': 3}]

    .. versionadded:: 3.0.0

    .. versionchanged:: 3.2.0
        Added `orders` argument.

    .. versionchanged:: 3.2.0
        Added :func:`sort_by_order` as alias.

    .. versionchanged:: 4.0.0
        Renamed from ``order_by`` to ``order_by`` and removed alias
        ``sort_by_order``.
    Nr   -c                \    D ]&  \  }}t         ||        ||            }|s!||z  c S  y)Nr   )r   )leftrightfuncmultrP   	comparerss        r6   
comparisonzorder_by.<locals>.comparison  s<    # 	%JD$dT%[1Ff}$	% r7   r   r   )r   r   r   r=   
is_boolean	enumeratehasr   	property_
startswithsortedr   )	r4   r   r   r   ir   orderr   r   s	           @r6   r   r   `  s    f *d#&&(
 ~~fIo 	:FAswwvq!#AYBcmmC0%89	:  	:C~~c"!"gcmmC0%89	: **Z"8'JJr7   c                     y r1   r2   r^   s     r6   r   r          r7   c                     y r1   r2   r^   s     r6   r   r     r	  r7   c                     y r1   r2   r^   s     r6   r   r     r	  r7   c                     y r1   r2   r^   s     r6   r   r     r	  r7   c                     y r1   r2   r^   s     r6   r   r          r7   c                     y r1   r2   r^   s     r6   r   r     r  r7   c                     y r1   r2   r^   s     r6   r   r     r  r7   c                     y r1   r2   r^   s     r6   r   r     r  r7   c                    g }g }t        | |      D ],  \  }}}}|r|j                  |       |j                  |       . ||gS )a  
    Creates an array of elements split into two groups, the first of which contains elements the
    `predicate` returns truthy for, while the second of which contains elements the `predicate`
    returns falsey for. The `predicate` is invoked with three arguments: ``(value, index|key,
    collection)``.

    If a property name is provided for `predicate` the created :func:`pluck` style predicate returns
    the property value of the given element.

    If an object is provided for `predicate` the created :func:`.matches` style predicate returns
    ``True`` for elements that have the properties of the given object, else ``False``.

    Args:
        collection: Collection to iterate over.
        predicate: Predicate applied per iteration.

    Returns:
        List of grouped elements.

    Example:

        >>> partition([1, 2, 3, 4], lambda x: x >= 3)
        [[3, 4], [1, 2]]

    .. versionadded:: 1.1.0
    )r
   r   )r4   r\   truesfalsesri   rj   rk   s          r6   r   r     sT    6 EF ,Z C !1LLMM% 	! 6?r7   c                @    t        | t        j                  |            S )a*  
    Retrieves the value of a specified property from all elements in the collection.

    Args:
        collection: List of dicts.
        path: Collection's path to pluck

    Returns:
        Plucked list.

    Example:

        >>> pluck([{"a": 1, "b": 2}, {"a": 3, "b": 4}, {"a": 5, "b": 6}], "a")
        [1, 3, 5]
        >>> pluck([[[0, 1]], [[2, 3]], [[4, 5]]], "0.1")
        [1, 3, 5]
        >>> pluck([{"a": {"b": 1}}, {"a": {"b": 2}}], "a.b")
        [1, 2]
        >>> pluck([{"a": {"b": [0, 1]}}, {"a": {"b": [2, 3]}}], "a.b.1")
        [1, 3]
        >>> pluck([{"a": {"b": [0, 1]}}, {"a": {"b": [2, 3]}}], ["a", "b", 1])
        [1, 3]

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Function removed.

    .. versionchanged:: 4.0.1
        Made property access deep.
    )r   r=   r  )r4   r   s     r6   r    r      s    @ 
CMM$/00r7   c                     y r1   r2   r4   rA   accumulators      r6   r!   r!   4      
 
r7   c                     y r1   r2   r  s      r6   r!   r!   <  r  r7   c                     y r1   r2   r  s      r6   r!   r!   D  r  r7   c                     y r1   r2   r  s      r6   r!   r!   L  r  r7   c                     y r1   r2   r  s      r6   r!   r!   T  r  r7   c                     y r1   r2   r  s      r6   r!   r!   \      
 	r7   c                     y r1   r2   r  s      r6   r!   r!   d  r  r7   c                     y r1   r2   r  s      r6   r!   r!   l  r  r7   c                     y r1   r2   r  s      r6   r!   r!   t  r  r7   c                     y r1   r2   r  s      r6   r!   r!   |  r  r7   c                     y r1   r2   r  s      r6   r!   r!     r  r7   c                     y r1   r2   r  s      r6   r!   r!     r  r7   c                     y r1   r2   r  s      r6   r!   r!          	r7   c                    t        |       }|	 t        |      \  }}|}|t        j
                  }d}nt        |d      }|D ]  \  }}	t        |||	||      } |S # t        $ r}t        d      |d}~ww xY w)a  
    Reduces a collection to a value which is the accumulated result of running each element in the
    collection through the iteratee, where each successive iteratee execution consumes the return
    value of the previous execution.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.
        accumulator: Initial value of aggregator. Default is to use the result of
            the first iteration.

    Returns:
        Accumulator object containing results of reduction.

    Example:

        >>> reduce_([1, 2, 3, 4], lambda total, x: total * x)
        24

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Removed aliases ``foldl`` and ``inject``.
    Nz1reduce_() of empty sequence with no initial valuer      maxargsargcount)r	   ry   StopIteration	TypeErrorr=   identityr   r   )
r4   rA   r  iterablerk   excrP   r-  indexrU   s
             r6   r!   r!     s    2 
#H	Z!(^NA{ F<<x3 Jt&$IJ M  	ZOPVYY	Zs   A 	A7&A22A7c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"   	  r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"     r  r7   c                     y r1   r2   r  s      r6   r"   r"   !  r  r7   c                     y r1   r2   r  s      r6   r"   r"   )  r'  r7   c                ^    t        | t              st        |       ddd   } t        | ||      S )a  
    This method is like :func:`reduce_` except that it iterates over elements of a `collection` from
    right to left.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.
        accumulator: Initial value of aggregator. Default is to use the result of
            the first iteration.

    Returns:
        Accumulator object containing results of reduction.

    Example:

        >>> reduce_right([1, 2, 3, 4], lambda total, x: total**x)
        4096

    .. versionadded:: 1.0.0

    .. versionchanged:: 3.2.1
        Fix bug where collection was not reversed correctly.

    .. versionchanged:: 4.0.0
        Removed alias ``foldr``.
    Nr   )r   r   r   r!   r  s      r6   r"   r"   /  s0    6 j$'*%dd+
:x55r7   c                     y r1   r2   r4   rA   r  
from_rights       r6   r#   r#   P  r   r7   c                     y r1   r2   rC  s       r6   r#   r#   Y  r   r7   c                     y r1   r2   rC  s       r6   r#   r#   b  r   r7   c                     y r1   r2   rC  s       r6   r#   r#   k  r   r7   c                     y r1   r2   rC  s       r6   r#   r#   t  r   r7   c                     y r1   r2   rC  s       r6   r#   r#   }  r   r7   c                     y r1   r2   rC  s       r6   r#   r#     r   r7   c                     y r1   r2   rC  s       r6   r#   r#     r   r7   c                     y r1   r2   rC  s       r6   r#   r#     r   r7   c                     y r1   r2   rC  s       r6   r#   r#     r   r7   c                     y r1   r2   rC  s       r6   r#   r#     r   r7   c                     y r1   r2   rC  s       r6   r#   r#     r   r7   c                     y r1   r2   rC  s       r6   r#   r#     r   r7   c                    t         j                  dnt        d      g fd}|rt        nt        } || ||       S )a  
    This function is like :func:`reduce_` except that it returns a list of every intermediate value
    in the reduction operation.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.
        accumulator: Initial value of aggregator. Default is to use the result of
            the first iteration.

    Returns:
        Results of each reduction operation.

    Example:

        >>> reductions([1, 2, 3, 4], lambda total, x: total * x)
        [2, 6, 24]

    Note:
        The last element of the returned list would be the result of using
        :func:`reduce_`.

    .. versionadded:: 2.0.0
    r   r)  r*  c                J    t        | ||      } j                  |        | S )Nr,  )r   r   )rP   rU   r3  r-  rA   resultss      r6   interceptorzreductions.<locals>.interceptor  s&    &$Ivr7   )r=   r0  r   r"   r!   )r4   rA   r  rD  rT  reducerr-  rS  s    `    @@r6   r#   r#     sK    2 <<x3G
 )lgGJ[1Nr7   c                     y r1   r2   r  s      r6   r$   r$         
 r7   c                     y r1   r2   r  s      r6   r$   r$     rW  r7   c                     y r1   r2   r  s      r6   r$   r$     rW  r7   c                     y r1   r2   r  s      r6   r$   r$   	  rW  r7   c                     y r1   r2   r  s      r6   r$   r$     rW  r7   c                     y r1   r2   r  s      r6   r$   r$         
 r7   c                     y r1   r2   r  s      r6   r$   r$   !  rW  r7   c                     y r1   r2   r  s      r6   r$   r$   )  rW  r7   c                     y r1   r2   r  s      r6   r$   r$   1  rW  r7   c                     y r1   r2   r  s      r6   r$   r$   9  r]  r7   c                     y r1   r2   r  s      r6   r$   r$   A  r]  r7   c                     y r1   r2   r  s      r6   r$   r$   I  r]  r7   c                     y r1   r2   r  s      r6   r$   r$   Q  s     r7   c                     t        | ||d      S )a  
    This method is like :func:`reductions` except that it iterates over elements of a `collection`
    from right to left.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.
        accumulator: Initial value of aggregator. Default is to use the result of
            the first iteration.

    Returns:
        Results of each reduction operation.

    Example:

        >>> reductions_right([1, 2, 3, 4], lambda total, x: total**x)
        [64, 4096, 4096]

    Note:
        The last element of the returned list would be the result of using
        :func:`reduce_`.

    .. versionadded:: 2.0.0
    T)rD  )r#   r  s      r6   r$   r$   W  s    2 j(KDIIr7   c                     y r1   r2   r^   s     r6   r%   r%   s  r_   r7   c                     y r1   r2   r^   s     r6   r%   r%   z  r_   r7   c                     y r1   r2   r^   s     r6   r%   r%     r_   r7   c                     y r1   r2   r^   s     r6   r%   r%     rc   r7   c                     y r1   r2   r^   s     r6   r%   r%     rc   r7   c                     y r1   r2   r^   s     r6   r%   r%     rc   r7   c           	     \    t        | |      D cg c]  \  }}}}|r| c}}}S c c}}}w )aL  
    The opposite of :func:`filter_` this method returns the elements of a collection that the
    predicate does **not** return truthy for.

    Args:
        collection: Collection to iterate over.
        predicate: Predicate applied per iteration.

    Returns:
        Rejected elements of `collection`.

    Example:

        >>> reject([1, 2, 3, 4], lambda x: x >= 3)
        [1, 2]
        >>> reject([{"a": 0}, {"a": 1}, {"a": 2}], "a")
        [{'a': 0}]
        >>> reject([{"a": 0}, {"a": 1}, {"a": 2}], {"a": 1})
        [{'a': 0}, {'a': 2}]

    .. versionadded:: 1.0.0
    rg   rh   s        r6   r%   r%     s.    . /;:y.Qaa*guaY`Eaaarl   c                ,    t        j                  |       S )a  
    Retrieves a random element from a given `collection`.

    Args:
        collection: Collection to iterate over.

    Returns:
        Random element from the given collection.

    Example:

        >>> items = [1, 2, 3, 4, 5]
        >>> results = sample(items)
        >>> assert results in items

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Moved multiple samples functionality to :func:`sample_size`. This
        function now only returns a single random sample.
    )randomchoicer4   s    r6   r&   r&     s    , ==$$r7   c                `    t        |xs dt        |             }t        j                  | |      S )a  
    Retrieves list of `n` random elements from a collection.

    Args:
        collection: Collection to iterate over.
        n: Number of random samples to return.

    Returns:
        List of `n` sampled collection values.

    Examples:

        >>> items = [1, 2, 3, 4, 5]
        >>> results = sample_size(items, 2)
        >>> assert len(results) == 2
        >>> assert set(items).intersection(results) == set(results)

    .. versionadded:: 4.0.0
    r   )minlenrn  r&   )r4   nnums      r6   r'   r'     s)    ( af1c*o
&C==S))r7   c                     y r1   r2   rp  s    r6   r(   r(     s    ;>r7   c                     y r1   r2   rp  s    r6   r(   r(     s    58r7   c                    t        | t              r| j                         } t        |       } t	        j
                  |        | S )a  
    Creates a list of shuffled values, using a version of the Fisher-Yates shuffle.

    Args:
        collection: Collection to iterate over.

    Returns:
        Shuffled list of values.

    Example:

        >>> items = [1, 2, 3, 4]
        >>> results = shuffle(items)
        >>> assert len(results) == len(items)
        >>> assert set(results) == set(items)

    .. versionadded:: 1.0.0
    )r   r   r   r   rn  r(   rp  s    r6   r(   r(     s<    & *d#&&(
 j!J NN:r7   c                    t        |       S )a  
    Gets the size of the `collection` by returning `len(collection)` for iterable objects.

    Args:
        collection: Collection to iterate over.

    Returns:
        Collection length.

    Example:

        >>> size([1, 2, 3, 4])
        4

    .. versionadded:: 1.0.0
    )rs  rp  s    r6   r)   r)     s    " z?r7   c                ^    |r t        j                  |      fd| D        } t        |       S )a  
    Checks if the predicate returns a truthy value for any element of a collection. The predicate is
    invoked with three arguments: ``(value, index|key, collection)``. If a property name is passed
    for predicate, the created :func:`map_` style predicate will return the property value of the
    given element. If an object is passed for predicate, the created :func:`.matches` style
    predicate will return ``True`` for elements that have the properties of the given object, else
    ``False``.

    Args:
        collection: Collection to iterate over.
        predicate: Predicate applied per iteration.

    Returns:
        Whether any of the elements are truthy.

    Example:

        >>> some([False, True, 0])
        True
        >>> some([False, 0, None])
        False
        >>> some([1, 2, 3, 4], lambda x: x >= 3)
        True
        >>> some([1, 2, 3, 4], lambda x: x == 0)
        False

    .. versionadded:: 1.0.0

    .. versionchanged:: 4.0.0
        Removed alias ``any_``.
    c              3  .   K   | ]  } |        y wr1   r2   rS   s     r6   rW   zsome.<locals>.<genexpr>G  rX   rY   )r=   rA   anyr[   s     @r6   r*   r*   #  s+    D ll9%7J7
z?r7   c                     y r1   r2   r4   rA   r   s      r6   r+   r+   L  rW  r7   c                     y r1   r2   r~  s      r6   r+   r+   T  r]  r7   c                    t        | t              r| j                         } t        | t	        j
                  |      |      S )a  
    Creates a list of elements, sorted in ascending order by the results of running each element in
    a `collection` through the iteratee.

    Args:
        collection: Collection to iterate over.
        iteratee: Iteratee applied per iteration.
        reverse: Whether to reverse the sort. Defaults to ``False``.

    Returns:
        Sorted list.

    Example:

        >>> sort_by({"a": 2, "b": 3, "c": 1})
        [1, 2, 3]
        >>> sort_by({"a": 2, "b": 3, "c": 1}, reverse=True)
        [3, 2, 1]
        >>> sort_by([{"a": 2}, {"a": 3}, {"a": 1}], "a")
        [{'a': 1}, {'a': 2}, {'a': 3}]

    .. versionadded:: 1.0.0
    r   )r   r   r   r  r=   rA   r~  s      r6   r+   r+   \  s4    0 *d#&&(
*#,,x"8'JJr7   c              #  <   K   t        | |      D ]	  }|d     yw)zGenerative mapper.r   Nrg   )r4   rA   rP   s      r6   r   r     s'     
 z84 Qis   )r4   t.Mapping[T, T2]r5   r,   returnzt.List[t.Union[T2, None]])r4   zt.Mapping[T, t.Any]r5   zt.Union[T, t.Iterable[T]]r  t.List[t.Any])r4   t.Iterable[T]r5   intr  zt.List[t.Union[T, None]])r4   t.Iterable[t.Any]r5   zt.Union[int, t.Iterable[int]]r  r  r1   )r4   t.Mapping[t.Any, T2]rA   Noner  t.Dict[T2, int])r4   r  rA   &t.Callable[[T2, T, t.Dict[T, T2]], T3]r  t.Dict[T3, int])r4   r  rA   t.Callable[[T2, T], T3]r  r  )r4   r  rA   t.Callable[[T2], T3]r  r  )r4   r  rA   r  r  zt.Dict[T, int])r4   r  rA   #t.Callable[[T, int, t.List[T]], T2]r  r  )r4   r  rA   t.Callable[[T, int], T2]r  r  )r4   r  rA   t.Callable[[T], T2]r  r  )r4   r  r\   3t.Union[t.Callable[[T], t.Any], IterateeObjT, None]r  bool)r4   r  r\   Ft.Union[t.Callable[[T2, T, t.Dict[T, T2]], t.Any], IterateeObjT, None]r  
t.List[T2])r4   r  r\   7t.Union[t.Callable[[T2, T], t.Any], IterateeObjT, None]r  r  )r4   r  r\   4t.Union[t.Callable[[T2], t.Any], IterateeObjT, None]r  r  )r4   r  r\   Ct.Union[t.Callable[[T, int, t.List[T]], t.Any], IterateeObjT, None]r  	t.List[T])r4   r  r\   8t.Union[t.Callable[[T, int], t.Any], IterateeObjT, None]r  r  )r4   r  r\   r  r  r  )r4   t.Dict[T, T2]r\   r  r  t.Union[T2, None])r4   r  r\   r  r  r  )r4   r  r\   r  r  r  )r4   r  r\   r  r  t.Union[T, None])r4   r  r\   r  r  r  )r4   r  r\   r  r  r  )r4   zt.Dict[t.Any, T2]r\   r  r  r  )r4   r  rA   z2t.Callable[[T2, T, t.Dict[T, T2]], t.Iterable[T3]]r  
t.List[T3])r4   r  rA   z#t.Callable[[T2, T], t.Iterable[T3]]r  r  )r4   r  rA   z t.Callable[[T2], t.Iterable[T3]]r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   z t.Mapping[t.Any, t.Iterable[T2]]rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   z/t.Callable[[T, int, t.List[T]], t.Iterable[T2]]r  r  )r4   r  rA   z$t.Callable[[T, int], t.Iterable[T2]]r  r  )r4   r  rA   zt.Callable[[T], t.Iterable[T2]]r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   zt.Iterable[t.Iterable[T]]rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   8t.Union[t.Callable[[T2, T, t.Dict[T, T2]], t.Any], None]r  r  )r4   r  rA   )t.Union[t.Callable[[T2, T], t.Any], None]r  r  )r4   r  rA   &t.Union[t.Callable[[T2], t.Any], None]r  r  )r4   r  rA   5t.Union[t.Callable[[T, int, t.List[T]], t.Any], None]r  r  )r4   r  rA   *t.Union[t.Callable[[T, int], t.Any], None]r  r  )r4   r  rA   %t.Union[t.Callable[[T], t.Any], None]r  r  )Nr   )r4   r  rA   r  r   r  r  r  )r4   r  rA   r  r   r  r  r  )r4   r  rA   r  r   r  r  r  )r4   r  rA   r  r   r  r  r  )r4   r  rA   r  r   r  r  r  )r4   r  rA   r  r   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   r  r  r  )r4   r  rA   z@t.Union[t.Callable[[T2, T, t.Dict[T, T2]], t.Any], IterateeObjT]r  r  )r4   r  rA   z1t.Union[t.Callable[[T2, T], t.Any], IterateeObjT]r  r  )r4   r  rA   z.t.Union[t.Callable[[T2], t.Any], IterateeObjT]r  r  )r4   r  rA   z=t.Union[t.Callable[[T, int, t.List[T]], t.Any], IterateeObjT]r  r  )r4   r  rA   z2t.Union[t.Callable[[T, int], t.Any], IterateeObjT]r  r  )r4   r  rA   z-t.Union[t.Callable[[T], t.Any], IterateeObjT]r  r  )r4   r  rA   r  r  zt.Dict[T2, t.List[T]])r4   r  rA   t.Union[IterateeObjT, None]r  zt.Dict[t.Any, t.List[T]])r   )r4   z0t.Union[t.Sequence[t.Any], t.Dict[t.Any, t.Any]]r   t.Anyr   r  r  r  )
r4   r  r   r   r   r  r   r  r  r  )r4   r  rA   r  r  zt.Dict[T2, T])r4   r  rA   r  r  zt.Dict[t.Any, t.Any])r4   r  rA   r  r  r  )r4   r  r>   r  r  r  )F)
r4   r  r   t.Iterable[t.Union[str, int]]r   t.Union[t.Iterable[bool], bool]r   r  r  r  )NF)
r4   r  r   t.Iterable[str]r   r  r   r  r  r  )
r4   r  r   r  r   r  r   r  r  r  )
r4   r  r   r  r   r  r   r  r  r  )r4   r  r\   z)t.Callable[[T2, T, t.Dict[T, T2]], t.Any]r  t.List[t.List[T2]])r4   r  r\   zt.Callable[[T2, T], t.Any]r  r  )r4   r  r\   zt.Callable[[T2], t.Any]r  r  )r4   r  r\   r  r  r  )r4   r  r\   z&t.Callable[[T, int, t.List[T]], t.Any]r  t.List[t.List[T]])r4   r  r\   zt.Callable[[T, int], t.Any]r  r  )r4   r  r\   zt.Callable[[T], t.Any]r  r  )r4   r  r\   r  r  r  )r4   r  r   r   r  r  )r4   r  rA   t.Callable[[T3, T2, T], T3]r  r.   r  r.   )r4   r  rA   t.Callable[[T3, T2], T3]r  r.   r  r.   )r4   t.Mapping[t.Any, t.Any]rA   t.Callable[[T3], T3]r  r.   r  r.   )r4   r  rA   t.Callable[[T2, T2, T], T2]r  r  r  r-   )r4   r  rA   t.Callable[[T2, T2], T2]r  r  r  r-   )r4   r  rA   t.Callable[[T], T]r  r  r  r,   )r4   r  rA   t.Callable[[T2, T, int], T2]r  r-   r  r-   )r4   r  rA   t.Callable[[T2, T], T2]r  r-   r  r-   )r4   r  rA   t.Callable[[T2], T2]r  r-   r  r-   )r4   r  rA   t.Callable[[T, T, int], T]r  r  r  r,   )r4   r  rA   t.Callable[[T, T], T]r  r  r  r,   )r4   r  rA   r  r  r  r  r,   )NN)r4   r  rA   r  r  r  r  r,   )
r4   r  rA   r  r  r.   rD  r  r  r  )
r4   r  rA   r  r  r.   rD  r  r  r  )
r4   r  rA   r  r  r.   rD  r  r  r  )
r4   r  rA   r  r  r  rD  r  r  r  )
r4   r  rA   r  r  r  rD  r  r  r  )
r4   r  rA   r  r  r  rD  r  r  r  )
r4   r  rA   r  r  r-   rD  r  r  r  )
r4   r  rA   r  r  r-   rD  r  r  r  )
r4   r  rA   r  r  r-   rD  r  r  r  )
r4   r  rA   r  r  r  rD  r  r  r  )
r4   r  rA   r  r  r  rD  r  r  r  )
r4   r  rA   r  r  r  rD  r  r  r  )NNF)
r4   r  rA   r  r  r  rD  r  r  r  )r4   r  rA   r  r  r.   r  r  )r4   r  rA   r  r  r.   r  r  )r4   r  rA   r  r  r.   r  r  )r4   r  rA   r  r  r  r  r  )r4   r  rA   r  r  r  r  r  )r4   r  rA   r  r  r  r  r  )r4   r  rA   r  r  r-   r  r  )r4   r  rA   r  r  r-   r  r  )r4   r  rA   r  r  r-   r  r  )r4   r  rA   r  r  r  r  r  )r4   r  rA   r  r  r  r  r  )r4   r  rA   r  r  r  r  r  )r4   r  rA   r  r  r  r  r  )r4   t.Sequence[T]r  r,   )r4   r  rt  zt.Union[int, None]r  r  )r4   zt.Mapping[t.Any, T]r  r  )r4   r  r  r  )r4   zt.Sizedr  r  )r4   r  r\   r  r  r  )r4   r  rA   r  r   r  r  r  )r4   r  rA   r  r   r  r  r  )r4   r  rA   z3t.Union[t.Callable[..., t.Any], IterateeObjT, None]r  zt.Generator[t.Any, None, None]):__doc__
__future__r   	functoolsr   rn  typingtpydashr=   helpersr   r   r   r	   r
   typesr   r   __all__TypeVarr,   r-   r.   r/   overloadr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r   r2   r7   r6   <module>r     sK"   #      E E & D AIIcNQYYt_QYYt_QYYt_  Q  Q  `  `  O  O  b  b.<  ]  ]  ,R 
  ,C 
 $0D 
  U  U )L 
  c  c  ^  ^B ae***]*	*Z  Y] U    JN F    GK$C    VZR    KOG    FJB  ^6  Y]U    JNF    GKC    VZR    KOG    FJB  8  Y]U    JNF    GK!C    VZR    KOG    FJB  <  ,^ 
  ,O 
 $0P 
  ,R 
  `  `  a  a  d  d  X  X )X 
 )M 
 )H 
 )L 
  ^  ^  Y  Y  \  \  P  P?0  JN F   X\ ,U 
 Y]$0V 
  GKC   VZ)S 
 QU)N 
D,  JN F  	   ;? 7  	   8<$4  	   GKC  	   <@8  	   7;3  	 R2  X\T    IME    FJB    UYQ    JNF    EIA  : N   ?   <   K   @   ;  B  d  d GK##)D## #
D de%'@%'JO%']`%'	%'PR!R).R7<RHMRR<  Z  Z KO!-H 
@  ]  ]  \  \  ,R 
  U  U  Z  Z )L 
 KO!-H 
"/J'YT 
 	$
' , 	
    	$
  	
   
 	
' , 	
    	
  	
  WKt  -V 
  -G 
 $1H 
 OS$1L 
 *P 
 *E 
 *@ 
 HL*E 
$N 1F  )  	  $&  	  '"  	    )  	   $&  	   '   	  *  	  %  	  !"  	   (  	   #  	   !   	  VZ)-CS 
,^  )  	  $&  	  '"  	    )  	   $&  	   '   	  *  	  %  	  !"  	   (  	   #  	   !   	  VZ)-CS 
6B 
 	 )  	
   
 	$&  	
   
 	'"  	
    	 )  	
    	$&  	
    	'   	
   
 	*  	
   
 	%  	
   
 	!"  	
    	(  	
    	#  	
    	!   	
    $(	 " 	
  )X  )  	  $&  	  '"  	    )  	   $&  	   '   	  *  	  %  	  !"  	   (  	   #  	   !   	  VZ)-CS 
J8  Y] U    JN F    GK$C    VZR    KOG    FJB  b4%2*0  >  >  8  8>* SW&&*O&	&R  FJ$B  	   EIA  	 KJ EI!A $r7   