Ë
    ^ãj  ã                   ó¢   — d Z ddlZddlmZ dZdZdZdZ e e	d«      «      Z
 ej                  d	«      Zd
edefd„Zdededz  fd„Zdeddfd„Zy)aj  Stage 1d: UTF-8 structural validation.

Validation is decode-based: CPython's strict UTF-8 decoder enforces exactly
the rules the old hand-rolled loop checked (overlong encodings, surrogates,
codepoints above U+10FFFF) at C speed on every build flavor, where a per-byte
loop runs an order of magnitude slower even compiled.  See ADR-0006.

The input is fed to an incremental decoder in chunks so a large input never
allocates a matching ``str``; decoded output is discarded.  ``final=False``
reproduces the truncated-tail tolerance (an incomplete multi-byte sequence at
the very end is fine, the input is usually a prefix of a larger whole), the
same trick :func:`chardet._utils.decodes_without_error` uses.

Note: ``from __future__ import annotations`` is intentionally omitted because
this module is compiled with mypyc, which does not support PEP 563 string
annotations.
é    N)ÚDetectionResultgš™™™™™é?g®Gáz®ï?é   i   é€   úutf-8ÚbyteÚreturnc                 óT   — d| cxk  rdk  ry d| cxk  rdk  ry d| cxk  rdk  ry	 y
y
)z”Sequence length a UTF-8 lead byte declares, or 0 for a non-lead.

    0xC0-0xC1 are overlong 2-byte encodings of ASCII, so leads start at 0xC2.
    éÂ   éß   é   éà   éï   é   éð   éô   é   r   © )r   s    úW/var/www/html/metafoliadorv2/venv/lib/python3.12/site-packages/chardet/pipeline/utf8.pyÚ_expected_seq_lenr   *   sF   € ð
 ˆtÔ�tÒØð àˆtÔ�tÒØð àˆtÔ�tÒØð áó    Údatac                 ó   — t        | «      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``.
    é   )Ú	scan_utf8)r   s    r   Údetect_utf8r   8   s   € ô �T‹?˜1ÑÐr   z#tuple[bool, DetectionResult | None]c           	      ó¸  — | sy| j                  «       ryt        | «      }t        «       }d}d}d}|}d}||k  rŽ| ||t        z    }|t        |«      z   }	|	}|dk(  r|j                  «       r|	}Œ9|t        |j	                  dt
        «      «      z  }	 |j                  |d¬«       t        |j                  «       d   «      }|	}||k  rŒŽ||z
  }||k  r'| || }|t        |j	                  dt
        «      «      z  }|dk(  ry||z  }t        t        z
  }t        t        t        |t        |t         z  d«      z  z   «      }dt#        d|d¬«      fS # t        $ r…}
d}t        t        d|dz
  «      |«      D ]  }t        | |   «      }|sŒ||z   |kD  sŒ|} n ||z
  t        |
dd«      z   }t        t        |d«      |d	z
  «      }|dk  s||k  rY d}
~
y
|}Y d}
~
�Œd}
~
ww xY w)a‰  Validate UTF-8 structure, separating validity from evidence.

    ``None`` from :func:`detect_utf8` is two different verdicts: the data
    is *not* UTF-8, or it is valid UTF-8 carrying no multi-byte evidence
    (pure ASCII, ASCII plus control bytes, ASCII plus a truncated tail).
    Only the first justifies ruling UTF-8 out downstream, so callers that
    act on a rejection need both halves of the answer.

    :param data: The raw byte data to examine.
    :returns: ``(window_is_valid_utf8, result_or_None)``.  The flag covers
        the whole of *data*; the result is present only when complete
        multi-byte sequences were found.
    )TNr   NF)Úfinaléÿÿÿÿr   Ústartr   )FNg      ð?Tr   )ÚencodingÚ
confidenceÚlanguage)ÚisasciiÚlenÚ_utf8_decoderÚ_CHUNK_SIZEÚ	translateÚ_ASCII_DELETEÚdecodeÚUnicodeErrorÚrangeÚmaxr   ÚgetattrÚminÚgetstateÚ_MAX_CONFIDENCEÚ_BASE_CONFIDENCEÚ_MB_RATIO_SCALEr   )r   ÚlengthÚdecoderÚmultibyte_bytesÚpending_lenÚposÚ
tail_startÚcounted_endÚchunkÚ	chunk_endÚexcÚ	tail_leadÚkÚseq_lenÚ	err_startÚtailÚmb_ratioÚconfidence_ranger!   s                      r   r   r   D   s/  € ñ Øð ‡|�|„~Øä�‹Y€FÜ‹o€GØ€OØ€KØ
€Cð €JØ€KØ
�Š,Ø�S˜3¤Ñ,Ð-ˆØœ#˜e›*Ñ$ˆ	ØˆØ˜!Ò §¡¤ð ˆCØØœ3˜uŸ™¨t´]ÓCÓDÑDˆð	Ø�N‰N˜5¨ˆNÔ.ô4 ˜'×*Ñ*Ó,¨QÑ/Ó0ˆØˆðM �‹,ðT ˜kÑ)ˆ
ð �KÒØ�J˜{Ð+ˆØœ3˜tŸ~™~¨d´MÓBÓCÑCˆð ˜!ÒØð  Ñ'€HÜ&Ô)9Ñ9ÐÜÜÜÐ+¬c°(¼_Ñ2LÈcÓ.RÑRÑRó€Jð
 	Ü °ZÈ$ÔOðð øôo ò 	ð ˆIÜœ3˜q &¨1¡*Ó-¨vÓ6ò �Ü+¨D°©GÓ4�Ú˜q 7™{¨VÓ3Ø !�IÙð	ð
 ˜kÑ)¬G°C¸À!Ó,DÑDˆIÜœC 	¨1Ó-¨v¸©zÓ:ˆIØ˜1Š} 	¨IÒ 5ä$ð #ˆJÝûð1	ús*   ÂE Å	GÅ.GÆGÆ;GÇGÇG)Ú__doc__ÚcodecsÚchardet.pipeliner   r1   r0   r2   r&   Úbytesr+   r(   Úgetincrementaldecoderr%   Úintr   r   r   r   r   r   ú<module>rJ      s‘   ðñó$ å ,ð Ð Ø€ð €ð €ñ ‘e˜D“kÓ"€à,�×,Ñ,¨WÓ5€ð˜Cð  Có ð	�eð 	 °$Ñ 6ó 	ðh�Eð hÐCô hr   