o
    @Bi(                     @   s   d Z dZdZdZz	dd lmZ W dS  eyC   ddlZejr.e	eZ
G dd deZY dS ddd	 eD Z
G d
d deZY dS w ))Utf8Validator(      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      r      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
      r	   r	   r	   r	   r	   r	   r	   r	   r	   r	   r	      r	   r	         r   r      r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r   r	   r   r   r   r   r   r   r   r	   r   r   r   r   r   r	   r   r	   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Nc                   @   4   e Zd ZdZdZdd Zdd Zdd Zd	d
 ZdS )r     
            Incremental UTF-8 validator with constant memory consumption (minimal state).

            Implements the algorithm "Flexible and Economical UTF-8 Decoder" by
            Bjoern Hoehrmann (http://bjoern.hoehrmann.de/utf-8/decoder/dfa/).
            
_codepoint_state_indexc                 C      d | _ d | _d | _|   d S Nr   r   r   resetself r   `/var/www/html/Trade-python/venv/lib/python3.10/site-packages/autobahn/websocket/utf8validator.py__init__Z      Utf8Validator.__init__c                 C   sT   t | }| jtkr|d@ | jd> B | _nd|? |@ | _t d| jd  |  | _| jS a  
                Eat one UTF-8 octet, and validate on the fly.

                Returns ``UTF8_ACCEPT`` when enough octets have been consumed, in which case
                ``self.codepoint`` contains the decoded Unicode code point.

                Returns ``UTF8_REJECT`` when invalid UTF-8 was encountered.

                Returns some other positive integer when more octets need to be eaten.
                ?   r            )UTF8VALIDATOR_DFA_Sr   UTF8_ACCEPTr   r   bttr   r   r   decode`   s   
Utf8Validator.decodec                 C      t | _d| _d| _dS zc
                Reset validator to start new incremental UTF-8 decode/validation.
                r   Nr%   r   r   r   r   r   r   r   r   s      
Utf8Validator.resetc                 C   s   t |}d}| j}||k r8td|d>  t||    }|tkr0|| _|  j|7  _dd|| jfS |d7 }||k s|| _|  j|7  _d|tk|| jfS a  
                Incrementally validate a chunk of bytes provided as string.

                Will return a quad ``(valid?, endsOnCodePoint?, currentIndex, totalIndex)``.

                As soon as an octet is encountered which renders the octet sequence
                invalid, a quad with ``valid? == False`` is returned. ``currentIndex`` returns
                the index within the currently consumed chunk, and ``totalIndex`` the
                index within the total consumed sequence that was the point of bail out.
                When ``valid? == True``, currentIndex will be ``len(ba)`` and ``totalIndex`` the
                total amount of consumed bytes.
                r   r"   r
   Fr   T)lenr   r$   UTF8_REJECTr   r%   r   balistater   r   r   validate{   s   Utf8Validator.validateN	__name__
__module____qualname____doc__	__slots__r   r)   r   r8   r   r   r   r   r   L       r    c                 C   s   g | ]}t |qS r   )chr).0cr   r   r   
<listcomp>   s    rE   c                   @   r   )r   r   r   c                 C   r   r   r   r   r   r   r   r      r   r   c                 C   s\   t t| }| jtkr|d@ | jd> B | _nd|? |@ | _t td| jd  |  | _| jS r   )ordr$   r   r%   r   r&   r   r   r   r)      s   
r*   c                 C   r+   r,   r-   r   r   r   r   r      r.   r/   c                 C   s   t |}d}| j}||k r>ttd|d>  ttt||    }|tkr6|| _|  j|7  _dd|| jfS |d7 }||k s|| _|  j|7  _d|tk|| jfS r0   )r1   r   rF   r$   r2   r   r%   r3   r   r   r   r8      s   (r9   Nr:   r   r   r   r   r      r@   )__all__UTF8VALIDATOR_DFAr%   r2   wsaccel.utf8validatorr   ImportErrorsixPY3bytesr$   objectjoinr   r   r   r   <module>   s   R