
    dh                        d dl Z d dlmZ d dlmZ d dlmZmZmZm	Z	 d dl
mZ  G d de	      Zded	eeeef   ddf   fd
Zded	eeeef   ddf   fdZ G d de      Z edi  ed       G d d             Zded	eeeef   ddf   fdZy)    N)	dataclass)
itemgetter)Any	Generator
NamedTupleProtocol)dataclass_kwargsc                   2    e Zd Zdedeeeef   ddf   fdZy)ClassAttrsResolverclsreturnNc                      y N )selfr   s     \/var/www/netwell/bot/venv/lib/python3.12/site-packages/aiogram/utils/class_attrs_resolver.py__call__zClassAttrsResolver.__call__
   s        )	__name__
__module____qualname__typer   tuplestrr   r   r   r   r   r   r   	   s#    PDPYuS#Xd/J%KPr   r   r   r   c              #   J   K   t        j                  |       E d{    y7 w)a7  
    Inspects and resolves attributes of a given class.

    This function uses the `inspect.getmembers` utility to yield all attributes of
    a provided class. The output is a generator that produces tuples containing
    attribute names and their corresponding values. This function is suitable for
    analyzing class attributes dynamically. However, it guarantees alphabetical
    order of attributes.

    :param cls: The class for which the attributes will be resolved.
    :return: A generator yielding tuples containing attribute names and their values.
    N)inspect
getmembers)r   s    r   inspect_members_resolverr      s      !!#&&&s   #!#c              #      K   t               }t        t        j                  |             D ]@  }|j                  j                         D ]!  \  }}||v r||f |j                  |       # B yw)a  
    Resolve and yield attributes from the reversed method resolution order (MRO) of a given class.

    This function iterates through the reversed MRO of a class and yields attributes
    that have not yet been encountered. It avoids duplicates by keeping track of
    attribute names that have already been processed.

    :param cls: The class for which the attributes will be resolved.
    :return: A generator yielding tuples containing attribute names and their values.
    N)setreversedr   getmro__dict__itemsadd)r   known_attrsbasenamevalues        r   &get_reversed_mro_unique_attrs_resolverr*      sm      %K,- "==..0 	"KD%{"+OOD!	""s   A-A/c                   "    e Zd ZU eed<   eed<   y)	_Positionin_mroin_classN)r   r   r   int__annotations__r   r   r   r,   r,   2   s    KMr   r,   T)slotsc                   2    e Zd ZU eed<   eed<   dd defdZy)_AttributeContainerpositionr)   otherr   c                 4    | j                   |j                   k  S r   )r4   )r   r5   s     r   __lt__z_AttributeContainer.__lt__<   s    }}u~~--r   N)r   r   r   r,   r0   r   boolr7   r   r   r   r3   r3   7   s!    J.1 .d .r   r3   c              #     K   i }t        t        j                  |             D ]i  \  }}t        t        |      j	                               D ]?  \  }\  }}t        ||      }|j                  |      x}r||_        0t        ||      ||<   A k t        |j	                         t        d            D ]  \  }}||j                  f  yw)a  
    Resolve and yield attributes from the method resolution order (MRO) of a given class.

    Iterates through a class's method resolution order (MRO) and collects its attributes
    along with their respective positions in the MRO and the class hierarchy. This generator
    yields a tuple containing the name of each attribute and its associated value.

    :param cls: The class for which the attributes will be resolved.
    :return: A generator yielding tuples containing attribute names and their values.
    )r)   r4      )keyN)	enumerater   r"   varsr$   r,   getr4   r3   sortedr   r)   )	r   
attributesposition_in_mror'   position_in_classr(   r)   r4   	attributes	            r   get_sorted_mro_attrs_resolverrD   @   s      24J!*7>>#+>!? S09$t*:J:J:L0M 	S,}e 2CDH&NN400y0%-	"2RJt	SS "*"2"2"4*Q-H $iIOO##$s   C
Cr   )r   dataclassesr   operatorr   typingr   r   r   r   aiogram.utils.dataclassr	   r   r   r   r   r   r*   r,   r3   rD   r   r   r   <module>rI      s     !  7 7 4Q Q'$ '9U38_dD5P+Q ' " "5c?TXZ^C^9_ "*
 
 *D)*. . +.$t $	%S/4QU:U0V $r   