
    i`(                    B   S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  SSK
JrJrJrJrJrJr  SSKJrJrJr  SS	KJrJrJrJrJrJrJrJrJrJrJ r   SS
KJ!r"  SSK#J$r$J%r%  SSK&J'r'J(r(  SSK)J*r*  SSK+J,r,J-r-J.r.J/r/J0r0J1r1J2r2  SSK+J3r4  \(       a  SSK5J6r6  / SQr7S!S jr8S!S jr9S"S jr:S#S jr;\" S5      r<S$S jr=      S$S jr> S%       S&S jjr?      S'S jr@S(S jrA   S)             S*S jjrB  S+           S,S jjrCS"S jrD\4       S-S  jjrEg).z"Utility functions for collections.    )annotations)defaultdict)CallableIterable)partial)TYPE_CHECKINGAnyDefaultDictLiteral
NamedTupleTypeVar)NOTHING	AttributeNothingType   )ANIESAbcSetget_argsget_full_type_hints
get_originis_bareis_frozenset
is_mappingis_mutable_sequenceis_sequenceis_subclass)is_mutable_set)StructureHookUnstructureHook)IterableValidationErrorIterableValidationNote)identity)AttributeOverridealready_generating!make_dict_structure_fn_from_attrs#make_dict_unstructure_fn_from_attrs make_hetero_tuple_unstructure_fnmapping_structure_factorymapping_unstructure_factory)make_iterable_unstructure_fn)BaseConverter)defaultdict_structure_factory"homogenous_tuple_structure_factoryis_abstract_set
is_any_setis_defaultdictr   r   r   is_namedtupler   is_setiterable_unstructure_factorylist_structure_factoryr(   r)   !namedtuple_dict_structure_factory#namedtuple_dict_unstructure_factorynamedtuple_structure_factorynamedtuple_unstructure_factoryc                <    [        U 5      =(       d    [        U 5      $ )z5A predicate function for both mutable and frozensets.)r2   r   types    J/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/cattrs/cols.pyr/   r/   B   s    $<-<--    c                F    U [         L =(       d    [        U SS5      [         L $ )z8A predicate function for abstract (collection.abc) sets.
__origin__N)r   getattrr:   s    r<   r.   r.   G   s    6>JgdL$?6IJr=   c                    [        U [        5      (       a?  U R                  5        H+  nUR                  R	                  SS5      n[
        U;   d  M+    g   g)z&A predicate function for named tuples.__orig_bases__ TF)r   tuplemro__dict__getr   )r;   cl
orig_basess      r<   r1   r1   L   sF     4((*B)92>JZ'  r=   c                ^   ^ [        U4S jU R                  R                  5        5       5      $ )zRIf all fields would be passed through, this class should not be processed
either.
c              3  T   >#    U  H  nTR                  U5      [        :H  v   M     g 7fN)get_unstructure_hookr"   ).0t	converters     r<   	<genexpr>"_is_passthrough.<locals>.<genexpr>[   s(      .A 	&&q)X5.s   %()all__annotations__values)r;   rP   s    `r<   _is_passthroughrV   W   s.      %%,,.  r=   Tc                T  ^ ^^ [        T 5      (       d  T R                  S   [        ;   a
  T 4SS jjnU$ T R                  S   m UR                  T5      mUR                  (       a  T TT4     SUUU 4S jjjnU$ T TT4     SS jjnU$ ! [         a    UR
                  m NPf = f)zPA hook factory for structuring lists.

Converts any given iterable into a list.
r   c                    [        U 5      $ rL   )listobj_s     r<   structure_list.list_structure_factory.<locals>.structure_listl   s    9r=   c                F  > / n/ nSnU  H   n UR                  T
" Xs5      5        US-  nM"     U(       a  [        ST< 3UT5      eU$ ! [         aD  n[        ST SU 3UT	5      n/ [        US/ 5      QUPUl        UR                  U5         S nANlS nAff = f! US-  nf = f)Nr   zStructuring z	 @ index 	__notes__r   zWhile structuring )append	Exceptionr!   r@   ra   r    )r\   r]   _handler
_elem_typeerrorsresixemsg	elem_typehandlerr;   s            r<   r^   r_   {   s     FCB	JJwq56 !GB  -(164  J ! %0&tfIbT:B	C #FGA{B$?"E"EAKMM!$$% !GBs)   A
B:BBBBB c                <    U  Vs/ s H
  oB" XC5      PM     sn$ s  snf rL   rC   r\   r]   rd   re   ri   s        r<   r^   r_      s!     699SHQ+S999s   )r\   Iterable[T]r]   r;   returnzlist[T])r   __args__r   get_structure_hookRecursionError	structuredetailed_validation)r;   rP   r^   rk   rl   s   `  @@r<   r4   r4   d   s     t}}a(E17; 	 a I&..y9
 $$ )-w9		!%		 	> 	 )-w9	:	:!%	:	:
 K  &%%&s   B B'&B'c                R  ^ [        U 5      (       d  U R                  S   [        ;   a
  U 4SS jjnU$ U R                  S   n UR                  U5      nUR                  (       a  [        X5      mU 4SU4S jjjnU$ XU4     SS jjnU$ ! [         a    UR
                  n NQf = f)zA hook factory for homogenous (all elements the same, indeterminate length) tuples.

Converts any given iterable into a tuple.
r   c                    [        U 5      $ rL   rD   r[   s     r<   structure_tuple;homogenous_tuple_structure_factory.<locals>.structure_tuple   s    :r=   c                &   > [        T" X5      5      $ rL   rx   )r\   r]   list_structures     r<   ry   rz      s    /00r=   c           	     N    [        U  Vs/ s H
  oB" XC5      PM     sn5      $ s  snf rL   rx   rn   s        r<   ry   rz      s&     3?3a(113?@@?s   ")r\   ro   r]   r;   rp   ztuple[T, ...])r   rq   r   rr   rs   rt   ru   r4   )r;   rP   ry   rk   rl   r|   s        @r<   r-   r-      s     t}}a(E18< 	 a I&..y9
 $$ 0@8< 	1 	1 	 )-9	A	A!%	A	A
 '  &%%&s   B B&%B&Nc           	         Uc  [        X5      (       a  [        $ [        U UUc  [        OU[        U R                  R                  5       5      S9$ )zuA hook factory for unstructuring namedtuples.

:param unstructure_to: Force unstructuring to this type, if provided.
)unstructure_to	type_args)rV   r"   r'   rD   rT   rU   )rH   rP   r   s      r<   r8   r8      sM     /""@"@+
 . 6uN**1134	 r=   c                   ^ ^^ [         [        T R                  R                  5       5         mUR                  T5      mUU U4S j$ )z:A hook factory for structuring namedtuples from iterables.c                   > T" T" U T5      6 $ rL   rC   )vr]   	base_hookrH   hetero_tuple_types     r<   <lambda>.namedtuple_structure_factory.<locals>.<lambda>   s    Ia):;<r=   )rD   rT   rU   rr   )rH   rP   r   r   s   ` @@r<   r7   r7      s;    
 eB$6$6$=$=$?@A,,->?I<<r=   c                    [        U 5      R                  5        VVs/ s H5  u  p[        UU R                  R	                  U[
        5      SSSSSSUUS9
PM7     snn$ s  snnf )z,Generate pseudo attributes for a namedtuple.NFT)r;   alias)r   itemsr   _field_defaultsrG   r   )rH   nameas      r<   _namedtuple_to_attrsr      ss     +2.446 7GD 	""41	
 7  s   <Ac               n    [         R                  nX;   a
  [        5       e UR                  U 5         [        [        U 5      U U4UUUS.UD6UR                  U 5        U(       d  [         ?$ $ ! [         a    [	        5       nU[         l         Nmf = f! UR                  U 5        U(       d  [         ?f f = f)a(  A hook factory for hooks structuring namedtuples from dictionaries.

:param forbid_extra_keys: Whether the hook should raise a `ForbiddenExtraKeysError`
    if unknown keys are encountered.
:param use_linecache: Whether to store the source code in the Python linecache.

.. versionadded:: 24.1.0
)_cattrs_forbid_extra_keys_cattrs_use_detailed_validation_cattrs_use_linecache)	r$   working_setrs   AttributeErrorsetaddr%   r   remove)rH   rP   ru   forbid_extra_keysuse_linecachekwargsr   s          r<   r5   r5      s    "#(44
  ""  OOB/0 $
 '8,?"/
 
 	2". +  5e)4&5( 	2". s   A. B .BB!B4c               j    [         R                  nX;   a
  [	        5       eUR                  U 5         [        [        U 5      U U4UUS.UD6UR                  U 5        U(       d  [         ?$ $ ! [         a    [        5       nU[         l         N{f = f! UR                  U 5        U(       d  [         ?f f = f)a)  A hook factory for hooks unstructuring namedtuples to dictionaries.

:param omit_if_default: When true, attributes equal to their default values
    will be omitted in the result dictionary.
:param use_linecache: Whether to store the source code in the Python linecache.

.. versionadded:: 24.1.0
)_cattrs_omit_if_defaultr   )	r$   r   r   r   rs   r   r&   r   r   )rH   rP   omit_if_defaultr   r   r   s         r<   r6   r6   "  s     5(44 
OOB/2 $
 %4"/
 
 	2". '  5e)4&5$ 	2". s   A, B ,BB!B2c                @    [        [        U 5      [        [        45      $ )zIs this type a defaultdict?

Bare defaultdicts (defaultdicts with no type arguments) are not supported
since there's no way to discover their _default_factory_.
)r   r   r   r
   r:   s    r<   r0   r0   K  s     z$'+{)CDDr=   c                d    U[         L a  [        U 5      S   n[        X[        [        U5      5      $ )zlA structure hook factory for defaultdicts.

The value type parameter will be used as the _default factory_.
r   )r   r   r(   r   r   )r;   rP   default_factorys      r<   r,   r,   T  s3     '!"4.+$o> r=   )rp   bool)r;   r	   rp   r   )r;   type[tuple]rP   r+   rp   r   )r;   r;   rP   r+   rp   r   rL   )rH   r   rP   r+   r   r	   rp   r   )rH   r   rP   r+   rp   r   )rH   r   rp   zlist[Attribute])from_converterFT)rH   r   rP   r+   ru   z bool | Literal['from_converter']r   r   r   r   r   r#   rp   r   )FT)rH   r   rP   r+   r   r   r   r   r   r#   rp   r   )r;   ztype[defaultdict]rP   r+   r   zCallable[[], Any] | NothingTyperp   r   )F__doc__
__future__r   collectionsr   collections.abcr   r   	functoolsr   typingr   r	   r
   r   r   r   attrsr   r   r   _compatr   r   r   r   r   r   r   r   r   r   r   r   r2   dispatchr   r   rf   r    r!   fnsr"   genr#   r$   r%   r&   r'   r(   r)   r*   r3   
convertersr+   __all__r/   r.   r1   rV   rW   r4   r-   r8   r7   r   r5   r6   r0   r,   rC   r=   r<   <module>r      s   ( " # .  P P 1 1    . 4 C    N)..
K
 CL6r&
&(&&T FJ -?B&== -==, =M#)/)/)/ :)/ 	)/
 )/  )/ )/^ "	&/&/&/ &/ 	&/  &/ &/RE 8?
 5 	r=   