
    M j9                       S SK Jr  S SKrS SKrS SKrS SKrS SKr\R                  S:  a  S SKr\R                  r	O\R                  r	S SK
Jr  \R                  S:  a	  \" S5      rO\R                  r\R                  " SSS9r\R                  " S	5      r\R                  " S
\	S9r\R$                  " SS9 " S S\R&                  \\4   5      5       r\R*                  r\R,                  rSS jr      SS jr      SS jr      S S jr    S!S jrS"S jrS"S jr\R                  S:  a1  \R<                  " SS9S#S j5       r\R<                  " SS9S#S j5       r O0\R<                  " SS9S#S j5       r\R<                  " SS9S#S j5       r \R$                  " SS9 " S S\R&                  \   5      5       r!\RD                  r"\RF                  RH                  r$\RF                  RJ                  r%\RL                  r&\RN                  r'\RP                  r(\RR                  r)\RT                  r*\RV                  r+\RX                  r-\R\                  r.g)$    )annotationsN)      )declarative_asn1r   
   TT)	covariantUTag)bound)frozenc                  .    \ rS rSr% SrS\S'   S\S'   Srg)	Variant    a  
A tagged variant for CHOICE fields with the same underlying type.

Use this when you have multiple CHOICE alternatives with the same type
and need to distinguish between them:

    foo: (
        Annotated[Variant[int, typing.Literal["IntA"]], Implicit(0)]
        | Annotated[Variant[int, typing.Literal["IntB"]], Implicit(1)]
    )

Usage:
    example = Example(foo=Variant(5, "IntA"))
    decoded.foo.value  # The int value
    decoded.foo.tag    # "IntA" or "IntB"
r   valuestrtag N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__r       n/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/cryptography/hazmat/asn1/asn1.pyr   r       s    " H	Hr   r   c                    [        [        S5      (       a   [        R                  [        R                  4O[        R                  4n[        R
                  " U 5      U;   $ )N	UnionType)hasattrtypesr    typingUnion
get_origin)
field_typeunion_typess     r   	_is_unionr(   ;   sI     5+&& 
&,,'ll_ 
 Z(K77r   c                   S nS nS nU  H  n[        U[        5      (       a   Ub  [        SU S35      eUR                  nM8  [        U[        R
                  5      (       a  Ub  [        SU S35      eUnMm  [        U[        R                  5      (       a  Ub  [        SU S35      eUnM  [        SU 35      e   [        R                  " X#US9$ )Nz-multiple DEFAULT annotations found in field ''z7multiple IMPLICIT/EXPLICIT annotations found in field 'z*multiple SIZE annotations found in field 'zunsupported annotation: )defaultencodingsize)
isinstanceDefault	TypeErrorr   r   EncodingSize
Annotation)metadata
field_namer+   r,   r-   raw_annotations         r   _extract_annotationr7   G   s    GHD"ng..""|1&  %**G(8(A(ABB#"|1&  &H(8(=(=>>@AN  "D6~6FGHH- #0 && r   c                
  ^ [         R                  " U 5      [         R                  L a.  [        U R                  U5      n[         R
                  " U 5      tpO[        R                  " 5       nUR                  bp  [         R                  " U 5      [        R                  [        4;  aB  U [        R                  [        R                  [        [        [         4;  a  [#        SU S35      eU [$        L aJ  ['        UR(                  [*        5      (       a  [#        SU S35      eUR,                  b  [#        SU S35      e[/        U S5      (       a  U R0                  n['        U[        R2                  R4                  [        R2                  R6                  45      (       d  [#        SU 35      e[        R8                  " [         R:                  " [        R2                  U5      U5      $ [=        U 5      (       Ga  [         R
                  " U 5      n[?        U5      S:X  a  [@        U;   a  US   [C        S 5      L a  US	   OUS   nU[$        L a  [#        S
5      e[E        Xa5      nURF                  RI                  5       (       d  [#        S5      eUR,                  b  [#        S5      e[        R2                  RK                  U5      nGO#['        UR(                  [*        5      (       a  [#        S5      eU V	s/ s H  n	U	[C        S 5      Ld  M  [M        X5      PM      n
n	U
S	   RN                  S Lm[Q        U4S jU
 5       5      (       a  [#        S5      eT(       a>  U
 Vs1 s H  oRN                  iM     nn[?        U
5      [?        U5      :w  a  [#        S5      e[        R2                  RS                  U
5      n[@        U;   aG  [        R2                  RK                  [        R8                  " U[        R                  " 5       5      5      OUnO[         R                  " U 5      [        R                  L aC  [E        [         R
                  " U 5      S	   U5      n[        R2                  RU                  U5      nOv[         R                  " U 5      [        L aC  [E        [         R
                  " U 5      S	   U5      n[        R2                  R                  U5      nO[        RV                  " U 5      n[        R8                  " X5      $ s  sn	f s  snf )Nzfield 'z' has a SIZE annotation, but SIZE annotations are only supported for fields of types: [SEQUENCE OF, SET OF, BIT STRING, OCTET STRING, UTF8String, PrintableString, IA5String]zW' has an IMPLICIT annotation, but IMPLICIT annotations are not supported for TLV types.zT' has a DEFAULT annotation, but DEFAULT annotations are not supported for TLV types.__asn1_root__zunsupported root type:       r   z=optional TLV types (`TLV | None`) are not currently supportedzoptional (`X | None`) types cannot have `X` annotated: annotations must apply to the union (i.e: `Annotated[X | None, annotation]`)z@optional (`X | None`) types should not have a DEFAULT annotationzCCHOICE (`X | Y | ...`) types should not have an IMPLICIT annotationc              3  F   >#    U  H  nUR                   S LT:g  v   M     g 7fN)tag_name).0vare_union_types_taggeds     r   	<genexpr>(_normalize_field_type.<locals>.<genexpr>   s'      !A 4',BB!s   !zbWhen using `asn1.Variant` in a union, all the other types in the union must also be `asn1.Variant`zBWhen using `asn1.Variant` in a union, the tags used must be unique),r#   r%   	Annotatedr7   __metadata__get_argsr   r3   r-   builtinslistSetOfbytesr   	BitString	IA5StringPrintableStringr0   TLVr.   r,   Implicitr+   r!   r9   TypeSequenceSetAnnotatedTypecastr(   lenNoneTypetype_normalize_field_type
annotationis_emptyOption_type_to_variantr>   anyChoice
SequenceOfnon_root_python_to_rust)r&   r5   rY   _	root_type
union_argsoptional_typeannotated_typerust_field_typeargvariantsr@   tagsrust_choice_type
inner_typerA   s                  @r   rX   rX   j   s   
 $(8(88()@)@*M
4
Q%002
"*%hmmU-CCNNLL

 j\ "* *
 	
 Sj))844* &H H  +* &G G 
 z?++,,	""++-=-B-B-F-FG
 
 5i[ABB--KK(--y9:
 	
 
:		__Z0
z?aH
$: ",A$t*!<
1*Q-  #*  3=MN!,,5577?  !!-! 
 /33::>JO *--x88!  &%Cd4j( 2 1%   &.a[%9%9%E" !    E 
 &,45Hq

H5x=CI-#) 
  044;;HE z) !%%,,$22(*:*E*E*G &  
		:	&(--	7*OOJ'*J

 +//:::F			:	&%	/*OOJ'*J

 +//55jA*BB:N))/FFg& 6s   /S:S:S?c                .   [         R                  " U 5      [         R                  L nU(       a  [         R                  " U 5      S   OU n[         R                  " U5      [        L Ga  [         R                  " U5      u  pE[         R                  " U5      [         R
                  La  [        S5      e[         R                  " U5      S   n[        US5      (       a  UR                  nO[        R                  " U5      nU(       a,  [        R                  " U[        U R                  U5      5      nO*[        R                  " U[        R                  " 5       5      n[        R                  " [        X5      $ [        R                  " U[        X5      S 5      $ )Nr   zWhen using `asn1.Variant` in a type annotation, the second type parameter must be a `typing.Literal` type. E.g: `Variant[int, typing.Literal["MyInt"]]`.r9   )r#   r%   rD   rF   r   Literalr0   r!   r9   r   r`   rS   r7   rE   r3   rX   )	tr5   is_annotatedrk   
value_typetag_literalr>   	rust_typeann_types	            r   r\   r\      s?    $$Q'6+;+;;L*6#A&AJ $/"(//*"=
[)?; 
 ??;/2://"00I(@@LI'55#ANNJ?H
 (55 ++-H
  ''DD  ''!!0
 	
r   c                Z    0 nU R                  5        H  u  p#[        X25      nXAU'   M     U$ r=   )itemsrX   )
raw_fieldsfieldsr5   r&   annotated_field_types        r   _annotate_fieldsry   %  s;     F","2"2"4
  5ZL1z	 #5 Mr   c                    [         R                  " U SS9n[        R                  R	                  U [        U5      5      n[        U SU5        g NT)include_extrasr9   )r#   get_type_hintsr   rP   rQ   ry   setattrclsrv   roots      r   _register_asn1_sequencer   2  s>    &&s4@J  ))#/?
/KLDC$'r   c                    [         R                  " U SS9n[        R                  R	                  U [        U5      5      n[        U SU5        g r{   )r#   r}   r   rP   rR   ry   r~   r   s      r   _register_asn1_setr   9  s>    &&s4@J  $$S*::*FGDC$'r   )kw_only_defaultc                    [         R                  S:  a  [        R                  " SSSSS9" U 5      nO[        R                  " SSS9" U 5      n[	        U5        U$ Nr   FTrepreq
match_argskw_only)r   r   )sysversion_infodataclasses	dataclassr   r   dataclass_clss     r   sequencer   F  sn     w&'11 ! 	 	M (11 M 	 .r   c                    [         R                  S:  a  [        R                  " SSSSS9" U 5      nO[        R                  " SSS9" U 5      n[	        U5        U$ r   )r   r   r   r   r   r   s     r   setr   ]  sn     w&'11 ! 	 	M (11 M 	=)r   c                V    [         R                  " SSSSS9" U 5      n[        U5        U$ NFTr   )r   r   r   r   s     r   r   r   v  s:     $--	

  	 .r   c                V    [         R                  " SSSSS9" U 5      n[        U5        U$ r   )r   r   r   r   s     r   r   r     s:     $--	

  	=)r   c                       \ rS rSr% S\S'   Srg)r/   i  r   r   r   N)r   r   r   r   r   r   r   r   r   r/   r/     s    Hr   r/   )r&   rW   returnbool)r4   tupler5   r   r   zdeclarative_asn1.Annotation)r&   
typing.Anyr5   r   r   zdeclarative_asn1.AnnotatedType)rn   r   r5   r   r   zdeclarative_asn1.Variant)rv   zdict[str, type]r   z)dict[str, declarative_asn1.AnnotatedType])r   type[U]r   None)r   r   r   r   )/
__future__r   rG   r   r   r"   r#   r   typing_extensionsLiteralString"cryptography.hazmat.bindings._rustr   rW   rV   TypeVarr	   r   r   r   Genericr   
decode_der
encode_derr(   r7   rX   r\   ry   r   r   dataclass_transformr   r   r/   rI   r1   ExplicitrO   r2   rM   rL   UTCTimeGeneralizedTimerK   TlvrN   Nullr   r   r   <module>r      s  
 #   
  g%33M((M ?gDzH~~H
NN3$'
NN3nnU-0 d#fnnQV$  $, ((
((
	8  !$   FKGKG(+KG#KG`(
(
"(
(
V

.
(( g**4@ A, **4@ A0 5
 6
 5
 6
 d#fnnQ  $ 	$$--$$--"22&&	

"
""22&&	r   