
    jj	                    (    d Z ddlmZ  G d d      Zy)z
An implementation of a bitwise prefix tree specially built for decoding
Huffman-coded content where we already know the Huffman table.
    )annotationsc                       e Zd ZdZddZddZy)HuffmanEncoderzj
    Encodes a string according to the Huffman encoding table defined in the
    HPACK specification.
    c                     || _         || _        y )N)huffman_code_listhuffman_code_list_lengths)selfr   r   s      V/home/ubuntu/.cache/pipx/cdb5059130eadca/lib/python3.12/site-packages/hpack/huffman.py__init__zHuffmanEncoder.__init__   s    !2)B&    c                   |syd}d}|D ];  }| j                   |   }| j                  |   d|dz   z  dz
  z  }||z  }||z  }||z  }= d|dz  z
  dz  }||z  }|d|z  dz
  z  }|d}t        |      dz  dk7  rd|z   n|}||z   dz  }	|	dz  }
t        |      |
k7  r|
t        |      z
  }d|z  |z   }t        j	                  |      S )zm
        Given a string of bytes, encodes them according to the HPACK Huffman
        specification.
        r   r            x0)r   r   lenbytesfromhex)r	   bytes_to_encode	final_numfinal_int_lenbytebin_int_lenbin_intbits_to_be_paddedstotal_bytesexpected_digitsmissing_digitss               r
   encodezHuffmanEncoder.encode   s+    	
 $ 	)D88>K,,T2kAo&*G +%I I[(M	) -!"349''	a,,11	 m 1vzQC!GA
 %'88Q>%/q6_$,s1v5N~%*A}}Qr   N)r   	list[int]r   r"   returnNone)r   zbytes | Noner#   r   )__name__
__module____qualname____doc__r   r!    r   r
   r   r      s    
C- r   r   N)r(   
__future__r   r   r)   r   r
   <module>r+      s    #7  7 r   