
    @OOf                     r    d dl Z d dl mZ  ee dd      dk  r ede j                  z         G d de      Zy)    N)KaitaiStructAPI_VERSION)r   	   zPIncompatible Kaitai Struct Python API: 0.9 or later is required, but you have %sc                   t    e Zd ZdZddZd Z G d de      Zed        Z	ed        Z
ed	        Zed
        Zy)VlqBase128Lea,  A variable-length unsigned/signed integer using base128 encoding. 1-byte groups
    consist of 1-bit flag of continuation and 7-bit value chunk, and are ordered
    "least significant group first", i.e. in "little-endian" manner.
    
    This particular encoding is specified and used in:
    
    * DWARF debug file format, where it's dubbed "unsigned LEB128" or "ULEB128".
      http://dwarfstd.org/doc/dwarf-2.0.0.pdf - page 139
    * Google Protocol Buffers, where it's called "Base 128 Varints".
      https://developers.google.com/protocol-buffers/docs/encoding?csw=1#varints
    * Apache Lucene, where it's called "VInt"
      https://lucene.apache.org/core/3_5_0/fileformats.html#VInt
    * Apache Avro uses this as a basis for integer encoding, adding ZigZag on
      top of it for signed ints
      https://avro.apache.org/docs/current/spec.html#binary_encode_primitive
    
    More information on this encoding is available at https://en.wikipedia.org/wiki/LEB128
    
    This particular implementation supports serialized values to up 8 bytes long.
    Nc                 V    || _         || _        |r|n| | _        | j                          y N_io_parent_root_readselfr   r   r   s       n/var/www/premiumrankchecker/venv/lib/python3.12/site-packages/mitmproxy/contrib/kaitaistruct/vlq_base128_le.py__init__zVlqBase128Le.__init__   s$    #U


    c                     g | _         d}	 t        j                  | j                  | | j                        }| j                   j                  |       |j                  sy |dz  }Y)Nr      )groupsr   Groupr   r   appendhas_next)r   i_s      r   r   zVlqBase128Le._read%   sW    ""488T4::>AKKq!JJFA r   c                   >    e Zd ZdZddZd Zed        Zed        Zy)VlqBase128Le.Groupz`One byte group, clearly divided into 7-bit "value" chunk and 1-bit "continuation" flag.
        Nc                 V    || _         || _        |r|n| | _        | j                          y r	   r
   r   s       r   r   zVlqBase128Le.Group.__init__2   s$    DH"DL"'TDJJJLr   c                 B    | j                   j                         | _        y r	   )r   read_u1br   s    r   r   zVlqBase128Le.Group._read8   s    XX%%'DFr   c                 z    t        | d      r| j                  S | j                  dz  dk7  | _        t        | dd      S )z)If true, then we have more bytes to read._m_has_next   r   N)hasattrr$   r!   getattrr"   s    r   r   zVlqBase128Le.Group.has_next;   s>     t]+''' $2D455r   c                 t    t        | d      r| j                  S | j                  dz  | _        t        | dd      S )z6The 7-bit (base128) numeric value chunk of this group._m_value   N)r&   r)   r!   r'   r"   s    r   valuezVlqBase128Le.Group.valueD   s6     tZ(}}$!VVc\DM4T22r   NN)	__name__
__module____qualname____doc__r   r   propertyr   r+    r   r   r   r   /   s9    			( 
	6 
	6 
	3 
	3r   r   c                     t        | d      r| j                  S t        | j                        | _        t	        | dd       S )N_m_len)r&   r4   lenr   r'   r"   s    r   r5   zVlqBase128Le.lenN   s5    4";;$++&tXt,,r   c                    t        | d      r| j                  S | j                  d   j                  | j                  dk\  r| j                  d   j                  dz  ndz   | j                  dk\  r| j                  d   j                  dz  ndz   | j                  dk\  r| j                  d   j                  d	z  ndz   | j                  d
k\  r| j                  d   j                  dz  ndz   | j                  dk\  r| j                  d
   j                  dz  ndz   | j                  dk\  r| j                  d   j                  dz  ndz   | j                  dk\  r| j                  d   j                  dz  ndz   | _        t        | dd      S )z+Resulting unsigned value as normal integer.r)   r      r                           #   *      1   N)r&   r)   r   r+   r5   r'   r"   s    r   r+   zVlqBase128Le.valueV   s    4$== #{{1~33VZV^V^bcVcA8L8LPQ8Qijk  QU  QY  QY  ]^  Q^quq|q|}~q  rF  rF  JL  rL  de  f  KO  KS  KS  WX  KX  lp  lw  lw  xy  lz  l@  l@  DF  lF  ^_  `  EI  EM  EM  QR  ER  fj  fq  fq  rs  ft  fz  fz  ~@  f@  XY  Z  C  G  G  KL  L  `d  `k  `k  lm  `n  `t  `t  xz  `z  RS  T  y}  yA  yA  EF  yF  Z^  Ze  Ze  fg  Zh  Zn  Zn  rt  Zt  LM  N  sw  s{  s{  @  s@  TX  T_  T_  `a  Tb  Th  Th  ln  Tn  FG  HtZ..r   c                     t        | d      r| j                  S dd| j                  z  dz
  z  | _        t        | dd       S )N_m_sign_bitr   r8   )r&   rE   r5   r'   r"   s    r   sign_bitzVlqBase128Le.sign_bit_   sA    4'###1txx<1"45t]D11r   c                     t        | d      r| j                  S | j                  | j                  z  | j                  z
  | _        t	        | dd      S )zz
        .. seealso::
           Source - https://graphics.stanford.edu/~seander/bithacks.html#VariableSignExtend
        _m_value_signedN)r&   rH   r+   rF   r'   r"   s    r   value_signedzVlqBase128Le.value_signedg   sI     4*+'''!%dmm!;t}} Lt.55r   r,   )r-   r.   r/   r0   r   r   r   r   r1   r5   r+   rF   rI   r2   r   r   r   r   
   sm    (3 3> - - / / 2 2 	6 	6r   r   )kaitaistructr   r'   	Exception__version__r   r2   r   r   <module>rM      sW     % </&8
fjv  kC  kC  D  E  Eg6< g6r   