o
    j                     @   s6   d Z ddlmZ dZdZdZdededB fd	d
ZdS )zStage 1d: UTF-8 structural validation.

Note: ``from __future__ import annotations`` is intentionally omitted because
this module is compiled with mypyc, which does not support PEP 563 string
annotations.
    )DetectionResultg?gGz?   datareturnNc                 C   s  | sdS d}t | }d}d}||k r| | }|dk r|d7 }qd|  kr)dkr.n nd}n!d|  kr8d	kr=n nd
}nd|  krGdkrMn dS d}ndS || |krVnmtd|D ]}d| ||    krmdksq dS   dS q[|d
kr|dkr| |d  dk rdS |dkr| |d  dkrdS n |dkr|dkr| |d  dk rdS |dkr| |d  dkrdS |d7 }||7 }||7 }||k s|dkrdS || }tt }	ttt|	t|t d  }
td|
ddS )a  Validate UTF-8 byte structure.

    Returns a result only if multi-byte sequences are found (pure ASCII
    is handled by the ASCII stage).

    :param data: The raw byte data to examine.
    :returns: A :class:`DetectionResult` for UTF-8, or ``None``.
    Nr                                                      g      ?zutf-8)encoding
confidencelanguage)lenrange_MAX_CONFIDENCE_BASE_CONFIDENCEmin_MB_RATIO_SCALEr   )r   ilengthmultibyte_sequencesmultibyte_bytesbyteseq_lenjmb_ratioconfidence_ranger    r)   [/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/chardet/pipeline/utf8.pydetect_utf8   sf   	2r+   )__doc__chardet.pipeliner   r   r   r   bytesr+   r)   r)   r)   r*   <module>   s    