
    	`iX)                     4   d dl Z d dlZd dlZd dlmZ 	 d dlmZ n# e$ r	 d dlmZ Y nw xY w	 d dlmZm	Z	 n$# e$ r 	 d dlmZm	Z	 n# e$ r dxZ	ZY nw xY wY nw xY wd Z	  ej
        dd           d	 Zn# e$ r d
 ZY nw xY wej        dk    rd Znej        dk     rd Znej        Zej        dk    rd dlmZ nd Zd Zd Zd Zi eeeeeeeeeeej        eej        eej        eej        eej        eej        eej         eej!        eej"        eej#        eej$        eej%        ee j&        j        ee j&        j         ee j&        j!        ee j&        j$        ee j&        j        ee j&        j"        ee j&        j#        eiZ'd Z(d Z)d Z*d Z+dS )    N)_AnnotatedAlias)get_type_hints)NotRequiredRequiredc                 $    t          | d          S )NT)include_extras)_get_type_hints)objs    b/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/msgspec/_utils.pyr   r      s    3t4444    FooT)is_classc                 0    t          j        | dd          S )NFT)is_argumentr   typing
ForwardRefvalues    r   _forward_refr   &   s     EDIIIIr   c                 .    t          j        | d          S )NF)r   r   r   s    r   r   r   !   s     E::::r   )      c                 0    t          j        | ||d          S )N )r   
_eval_type)tglobalnslocalnss      r   r   r   -   s     Hgr:::r   )r   
   c                     	 t          j        | ||          S # t          $ rH}	 ddlm} n'# t          $ r t          d| j        d          |w xY w || ||d          cY d }~S d }~ww xY w)Nr   )eval_type_backportz#Unable to evaluate type annotation a  . If you are making use of the new typing syntax (unions using `|` since Python 3.10 or builtins subscripting since Python 3.9), you should either replace the use of new syntax with the existing `typing` constructs or install the `eval_type_backport` package.F)try_default)r   r   	TypeErrorr"   ImportError__forward_arg__)r   r   r   er"   s        r   r   r   1   s    	$Q'::: 	 	 	AAAAAAA   W!:K W W W 
  &%!	        	s)    
A**A%$AA%A*%A*)r      )get_annotationsc                 8    | j                             di           S )N__annotations__)__dict__get)clss    r   _get_class_annotationsr/   M   s    | 12666r   c                    t          | t          j                  r                    | |           S 	 t	          | j                  }n# t          $ r | cY S w xY w|s| S t	          fd|D                       }| |         S )Nc              3   D   K   | ]}                     ||          V  d S N)r-   ).0pmappings     r   	<genexpr>z _apply_params.<locals>.<genexpr>`   s1      77qQ""777777r   )
isinstancer   TypeVarr-   tuple__parameters__	Exception)r
   r5   
parametersargss    `  r   _apply_paramsr>   Q   s    #v~&& %{{3$$$3-..

   


  
 7777J77777Dt9s   A AAc                 ~    i t          | t                    r| }n| j        }fd | i            |j        fS )Nc                    t          | t                    r| }i }nt          | dd           }|d t          t          j        fv s|	v rd S |j        }t          fd| j        D                       }t          |          t          |          k    sJ t          t          ||                    x	|<   }t          |t          j                  r't          |d|j                  }|D ]} ||           d S d S )N
__origin__c              3   8   K   | ]}t          |          V  d S r2   )r>   )r3   ascopes     r   r6   zE_get_class_mro_and_typevar_mappings.<locals>.inner.<locals>.<genexpr>u   s-      EEQq%00EEEEEEr   __orig_bases__)r7   typegetattrobjectr   Genericr:   r9   __args__lendictzip
issubclass	__bases__)
crD   r.   	new_scopeparamsr=   basesbinnerr5   s
    `      r   rU   z2_get_class_mro_and_typevar_mappings.<locals>.innerl   s   a 
	?CII!\400CtVV^444w'FEEEE!*EEEEEDv;;#d))++++'+C,=,='>'>>GCL9c6>** 	$C!13=AAE $ $a####	$ 	$$ $r   )r7   rF   rA   __mro__)r
   r.   rU   r5   s     @@r   #_get_class_mro_and_typevar_mappingsrW   d   se    G#t n$ $ $ $ $ $$ 
E#rNNN;r   c                 H   i }t          |           \  }}|D ]	}|t          j        t          fv r|                    |          }t          t          |                    }t          t          j	                            |j
        d          di           }t          |          }|                                D ]g\  }	}
|	|v r
t          |
t                    rt          |
          }
t!          |
||          }
|t#          |
|          }
|
t%          d          }
|
||	<   h|S )a  Get the annotations for a class.

    This is similar to ``typing.get_type_hints``, except:

    - We maintain it
    - It leaves extras like ``Annotated``/``ClassVar`` alone
    - It resolves any parametrized generics in the class mro. The returned
      mapping may still include ``TypeVar`` values, but those should be treated
      as their unparametrized variants (i.e. equal to ``Any`` for the common case).

    Note that this function doesn't check that Generic types are being used
    properly - invalid uses of `Generic` may slip through without complaint.

    The assumption here is that the user is making use of a static analysis
    tool like ``mypy``/``pyright`` already, which would catch misuse of these
    APIs.
    Nr,   )rW   r   rI   rH   r-   rL   varsrG   sysmodules
__module__r/   itemsr7   strr   r   r>   rF   )r
   hintsmrotypevar_mappingsr.   r5   
cls_localscls_globalsannnamer   s              r   get_class_annotationsrf      s(   $ E?DDC	    6>6***"&&s++$s))__
ckoocndCCZQSTT$S))99;; 
	  
	 KD%u}}%%% ,$U++uj+>>E"%eW55}T

E$KK
	  Lr   c                    t          | t                    r| }n| j        }t          |           }t	          |d          rt          |j                  }n%|j        rt          |          }nt                      }i |                                D ]y\  }}t          |dd          }|t          u r&|                    |           |j        d         |<   E|t          u r&|                    |           |j        d         |<   t||<   zt          fd|D                       s't!          d| d                                           |fS )N__required_keys__rA   Fr   c              3       K   | ]}|v V  	d S r2   r   )r3   kr_   s     r   r6   z%get_typeddict_info.<locals>.<genexpr>   s'      ,,aqEz,,,,,,r   zRequired set z% contains keys that are no in hints: )r7   rF   rA   rf   hasattrsetrh   	__total__r]   rG   r   addrJ   r   discardallRuntimeErrorkeys)r
   r.   	raw_hintsrequiredrj   voriginr_   s          @r   get_typeddict_inforw      sp   #t n%c**Is'(( s,--	 y>>55 E!! 	 	1L%00XLLOOOz!}E!HH{""Qz!}E!HHE!HH ,,,,8,,,,, 
YHYY5::<<YY
 
 	
 (?r   c                 T   t          | t                    r| }n| j        }t          |           }g }g }g }t	          |d          rddlm}m}m} |j	        
                                D ]}	|	j        |ur|	j        |u rt          d          $|	j        }
||
         }|	j        |ur3|                    |	j                   |                    |
|df           o|	j        |ur3|                    |	j                   |                    |
|df           |                    |
|df           |                    |           d }t%          |dd           }n2ddlm}m} g }|j        D ]}	|	j        }
||
         }|	j        }||urt          ||          rI|j        rt1          d	          |                    |j                   |                    |
|df           nF|                    |           |                    |
|df           n|                    |
|df           |	j        |                    |	           |                    |           t%          |d
d           }t%          |dd           }|rt7          ||          }|t9          |          t9          |          ||fS )N__dataclass_fields__r   )_FIELD_FIELD_INITVARMISSINGz3dataclasses with `InitVar` fields are not supportedFT__post_init__)NOTHINGFactoryzvSupport for default factories with `takes_self=True` is not implemented. File a GitHub issue if you need this feature!__attrs_pre_init____attrs_post_init__)r7   rF   rA   rf   rk   dataclassesrz   r{   r|   ry   values_field_typer$   re   defaultappenddefault_factoryextendrG   attrsr~   r   __attrs_attrs__
takes_selfNotImplementedErrorfactory	validator_wrap_attrs_validatorsr9   )r
   r.   r_   rt   optionaldefaultsrz   r{   r|   fieldre   typpre_init	post_initr~   r   fields_with_validatorsr   s                     r   get_dataclass_infor      s   #t n!#&&EHHHs*++ ;R??????????-4466 	4 	4E ..$66#M   :D+C}G++...sE 23333&g55 5666sD 12222sE 23333!!!C$77		********!#( 	5 	5E:D+CmGg%%gw// 8) 1,  
 OOGO444OOT3$56666OOG,,,OOT3$67777sE 2333*&--e444!!!3 4d;;C!6==	! 	R./EyQQIhx(IEEr   c                       fd}|S )Nc           	          D ],}|                     | |t          | |j                             - |            d S d S r2   )r   rG   re   )r
   r   fieldsr   s     r   rU   z%_wrap_attrs_validators.<locals>.innerB  sX     	B 	BEOOCUZ(@(@AAAA IcNNNNN ! r   r   )r   r   rU   s   `` r   r   r   A  s)          Lr   c                      | di |S )z1Used to unpickle Structs with keyword-only fieldsr   r   )r.   kwargss     r   rebuildr   K  s    3====r   ),collectionsrZ   r   r   typing_extensionsr   r	   r;   r   r   r   r   r$   version_infor   annotationlibr)   r/   r>   rW   rf   listr9   rl   	frozensetrL   ListTupleSet	FrozenSetDict
CollectionMutableSequenceSequenceMutableMappingMapping
MutableSetAbstractSetabc_CONCRETE_TYPESrw   r   r   r   r   r   r   <module>r      s       



  " " " " " "9CCCCCCC 9 9 9888888889&777777777 & & &&000000000 & & &!%%;;;&&5 5 5
JFed++++J J J J  ; ; ;; ; ; ; ;; w; ; ; ;   * "J wGGGGGGG7 7 7  &     <) ) )^$	5  y	
 	$ K L% J i K t D OT 4 ND  s!" #$ OO#TOdOOO"DOT1 8' ' 'TGF GF GFT      sP    ))6 AAA	AAAAAA4 4A?>A?