§
    Æ‡tj2  ã                  óØ   — d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
 ddlmZmZ ddlmZmZmZ  G d„ d	¦  «        Z G d
„ d¦  «        Ze
eef         Ze	e         Z G d„ d¦  «        ZdS )é    )Úannotations)Úaliases)Úsub)ÚAnyÚIteratorÚListÚTupleé   )ÚRE_POSSIBLE_ENCODING_INDICATIONÚTOO_BIG_SEQUENCE)Ú	iana_nameÚis_multi_byte_encodingÚunicode_rangec                  óæ  — e Zd Z	 	 d1d2d„Zd3d„Zd3d„Zed4d„¦   «         Zd5d„Zd5d„Z	d6d„Z
ed5d„¦   «         Zed7d„¦   «         Zed8d„¦   «         Zed8d„¦   «         Zed7d„¦   «         Zed5d „¦   «         Zed4d!„¦   «         Zed4d"„¦   «         Zed4d#„¦   «         Zed4d$„¦   «         Zed9d%„¦   «         Zed:d'„¦   «         Zed8d(„¦   «         Zed7d)„¦   «         Zed7d*„¦   «         Zd;d<d.„Zed=d0„¦   «         ZdS )>ÚCharsetMatchNÚpayloadúbytes | bytearrayÚguessed_encodingÚstrÚmean_mess_ratioÚfloatÚhas_sig_or_bomÚboolÚ	languagesÚCoherenceMatchesÚdecoded_payloadú
str | NoneÚpreemptive_declarationc                ó®   — || _         || _        || _        || _        || _        d | _        g | _        d| _        d | _        d | _	        || _
        || _        d S )Nç        )Ú_payloadÚ	_encodingÚ_mean_mess_ratioÚ
_languagesÚ_has_sig_or_bomÚ_unicode_rangesÚ_leavesÚ_mean_coherence_ratioÚ_output_payloadÚ_output_encodingÚ_stringÚ_preemptive_declaration)Úselfr   r   r   r   r   r   r   s           úW/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/charset_normalizer/models.pyÚ__init__zCharsetMatch.__init__   se   € ð ,3ˆŒà.ˆŒØ'6ˆÔØ,5ˆŒØ%3ˆÔØ15ˆÔà+-ˆŒØ,/ˆÔ"à-1ˆÔØ,0ˆÔà#2ˆŒà3IˆÔ$Ð$Ð$ó    ÚotherÚobjectÚreturnc                óÊ   — t          |t          ¦  «        s/t          |t          ¦  «        rt          |¦  «        | j        k    S dS | j        |j        k    o| j        |j        k    S )NF)Ú
isinstancer   r   r   ÚencodingÚfingerprint©r-   r1   s     r.   Ú__eq__zCharsetMatch.__eq__(   s_   € Ý˜%¥Ñ.Ô.ð 	Ý˜%¥Ñ%Ô%ð 9Ý  Ñ'Ô'¨4¬=Ò8Ð8Ø�5ØŒ} ¤Ò.ÐX°4Ô3CÀuÔGXÒ3XÐXr0   c                ó”  — t          |t          ¦  «        st          ‚t          | j        |j        z
  ¦  «        }t          | j        |j        z
  ¦  «        }|dk     r|dk    r| j        |j        k    S |dk     rC|dk    r=t          | j        ¦  «        t          k    r| j        |j        k     S | j	        |j	        k    S | j        |j        k     S )zQ
        Implemented to make sorted available upon CharsetMatches items.
        g{®Gázt?g{®Gáz”?)
r5   r   Ú
ValueErrorÚabsÚchaosÚ	coherenceÚlenr!   r   Úmulti_byte_usage)r-   r1   Úchaos_differenceÚcoherence_differences       r.   Ú__lt__zCharsetMatch.__lt__/   sÎ   € õ ˜%¥Ñ.Ô.ð 	ÝÐå"% d¤j°5´;Ñ&>Ñ"?Ô"?ÐÝ&)¨$¬.¸5¼?Ñ*JÑ&KÔ&KÐð ˜eÒ#Ð#Ð(<¸tÒ(CÐ(CØ”> E¤OÒ3Ð3Ø Ò%Ð%Ð*>À$Ò*FÐ*Fõ �4”=Ñ!Ô!Õ%5Ò5Ð5Ø”z E¤KÒ/Ð/ØÔ(¨5Ô+AÒAÐAàŒz˜EœKÒ'Ð'r0   c                ój   — dt          t          | ¦  «        ¦  «        t          | j        ¦  «        z  z
  S )Ng      ð?)r?   r   Úraw©r-   s    r.   r@   zCharsetMatch.multi_byte_usageE   s&   € à•c�#˜d™)œ)‘n”n¥s¨4¬8¡}¤}Ñ4Ñ5Ð5r0   c                óÚ   — | j         €^t          | j        | j        d¦  «        | _         | j        r7| j        dk    r,| j         r%| j         d         dk    r| j         dd …         | _         | j         S )NÚstrictÚutf_7r   u   ï»¿r
   )r+   r   r!   r"   r%   rF   s    r.   Ú__str__zCharsetMatch.__str__I   sp   € àŒ<ÐÝ˜tœ}¨d¬n¸hÑGÔGˆDŒLð
 Ô$ð0à”N gÒ-Ð-Ø”Lð .à”L ”O xÒ/Ð/à#œ|¨A¨B¨BÔ/�”ØŒ|Ðr0   c                ó(   — d| j         › d| j        › d�S )Nz<CharsetMatch 'z' fp(z)>)r6   r7   rF   s    r.   Ú__repr__zCharsetMatch.__repr__Y   s    € ØI ¤ÐIÐI°TÔ5EÐIÐIÐIÐIr0   ÚNonec                óÌ   — t          |t          ¦  «        r|| k    r't          d                     |j        ¦  «        ¦  «        ‚d |_        | j                             |¦  «         d S )Nz;Unable to add instance <{}> as a submatch of a CharsetMatch)r5   r   r;   ÚformatÚ	__class__r+   r'   Úappendr8   s     r.   Úadd_submatchzCharsetMatch.add_submatch\   sk   € Ý˜%¥Ñ.Ô.ð 	°%¸4²-°-ÝØM×TÒTØ”Oñô ñô ð ð ˆŒØŒ×Ò˜EÑ"Ô"Ð"Ð"Ð"r0   c                ó   — | j         S ©N)r"   rF   s    r.   r6   zCharsetMatch.encodingg   s
   € àŒ~Ðr0   ú	list[str]c                ó¾   — g }t          j        ¦   «         D ]F\  }}| j        |k    r|                     |¦  «         Œ&| j        |k    r|                     |¦  «         ŒG|S )z‚
        Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
        )r   Úitemsr6   rQ   )r-   Úalso_known_asÚuÚps       r.   Úencoding_aliaseszCharsetMatch.encoding_aliasesk   sn   € ð
 $&ˆÝ”M‘O”Oð 	(ð 	(‰DˆAˆqØŒ} Ò!Ð!Ø×$Ò$ QÑ'Ô'Ð'Ð'Ø” !Ò#Ð#Ø×$Ò$ QÑ'Ô'Ð'øØÐr0   c                ó   — | j         S rT   ©r%   rF   s    r.   ÚbomzCharsetMatch.bomx   ó   € àÔ#Ð#r0   c                ó   — | j         S rT   r]   rF   s    r.   Úbyte_order_markzCharsetMatch.byte_order_mark|   r_   r0   c                ó$   — d„ | j         D ¦   «         S )zÔ
        Return the complete list of possible languages found in decoded sequence.
        Usually not really useful. Returned list may be empty even if 'language' property return something != 'Unknown'.
        c                ó   — g | ]
}|d          ‘ŒS )r   © )Ú.0Úes     r.   ú
<listcomp>z*CharsetMatch.languages.<locals>.<listcomp>†   s   € Ð.Ð.Ð.˜��!”Ð.Ð.Ð.r0   ©r$   rF   s    r.   r   zCharsetMatch.languages€   s   € ð /Ð.˜dœoÐ.Ñ.Ô.Ð.r0   c                ó  — | j         shd| j        v rdS ddlm}m} t          | j        ¦  «        r || j        ¦  «        n || j        ¦  «        }t          |¦  «        dk    sd|v rdS |d         S | j         d         d         S )z’
        Most probable language found in decoded sequence. If none were detected or inferred, the property will return
        "Unknown".
        ÚasciiÚEnglishr   )Úencoding_languagesÚmb_encoding_languageszLatin BasedÚUnknown)r$   Úcould_be_from_charsetÚcharset_normalizer.cdrl   rm   r   r6   r?   )r-   rl   rm   r   s       r.   ÚlanguagezCharsetMatch.languageˆ   s¸   € ð Œð 	 ð ˜$Ô4Ð4Ð4Ø �yð XÐWÐWÐWÐWÐWÐWÐWõ *¨$¬-Ñ8Ô8ð7Ð%Ð% d¤mÑ4Ô4Ð4à'Ð'¨¬Ñ6Ô6ð õ �9‰~Œ~ Ò"Ð" m°yÐ&@Ð&@Ø �yà˜Q”<ÐàŒ˜qÔ! !Ô$Ð$r0   c                ó   — | j         S rT   )r#   rF   s    r.   r=   zCharsetMatch.chaos¤   s   € àÔ$Ð$r0   c                ó:   — | j         sdS | j         d         d         S )Nr    r   r
   rh   rF   s    r.   r>   zCharsetMatch.coherence¨   s#   € àŒð 	Ø�3ØŒ˜qÔ! !Ô$Ð$r0   c                ó4   — t          | j        dz  d¬¦  «        S ©Néd   é   )Úndigits)Úroundr=   rF   s    r.   Úpercent_chaoszCharsetMatch.percent_chaos®   s   € å�T”Z #Ñ%¨qÐ1Ñ1Ô1Ð1r0   c                ó4   — t          | j        dz  d¬¦  «        S ru   )ry   r>   rF   s    r.   Úpercent_coherencezCharsetMatch.percent_coherence²   s   € å�T”^ cÑ)°1Ð5Ñ5Ô5Ð5r0   c                ó   — | j         S )z+
        Original untouched bytes.
        )r!   rF   s    r.   rE   zCharsetMatch.raw¶   s   € ð
 Œ}Ðr0   úlist[CharsetMatch]c                ó   — | j         S rT   )r'   rF   s    r.   ÚsubmatchzCharsetMatch.submatch½   s
   € àŒ|Ðr0   c                ó2   — t          | j        ¦  «        dk    S ©Nr   )r?   r'   rF   s    r.   Úhas_submatchzCharsetMatch.has_submatchÁ   s   € å�4”<Ñ Ô  1Ò$Ð$r0   c                ó´   — | j         �| j         S d„ t          | ¦  «        D ¦   «         }t          t          d„ |D ¦   «         ¦  «        ¦  «        | _         | j         S )Nc                ó,   — g | ]}t          |¦  «        ‘ŒS rd   )r   )re   Úchars     r.   rg   z*CharsetMatch.alphabets.<locals>.<listcomp>Ê   s    € Ð,WÐ,WÐ,WÀT­]¸4Ñ-@Ô-@Ð,WÐ,WÐ,Wr0   c                ó   — h | ]}|¯|’ŒS rd   rd   )re   Úrs     r.   ú	<setcomp>z)CharsetMatch.alphabets.<locals>.<setcomp>Ì   s   € Ð+LÐ+LÐ+L°!È!Ð+L¨AÐ+LÐ+LÐ+Lr0   )r&   r   ÚsortedÚlist)r-   Údetected_rangess     r.   Ú	alphabetszCharsetMatch.alphabetsÅ   s^   € àÔÐ+ØÔ'Ð'à,WÐ,WÍSÐQUÉYÌYÐ,WÑ,WÔ,Wˆå%¥dÐ+LÐ+L°Ð+LÑ+LÔ+LÑ&MÔ&MÑNÔNˆÔØÔ#Ð#r0   c                ó6   — | j         gd„ | j        D ¦   «         z   S )zÜ
        The complete list of encoding that output the exact SAME str result and therefore could be the originating
        encoding.
        This list does include the encoding available in property 'encoding'.
        c                ó   — g | ]	}|j         ‘Œ
S rd   )r6   )re   Úms     r.   rg   z6CharsetMatch.could_be_from_charset.<locals>.<listcomp>Ö   s   € Ð"DÐ"DÐ"D°! 1¤:Ð"DÐ"DÐ"Dr0   )r"   r'   rF   s    r.   ro   z"CharsetMatch.could_be_from_charsetÏ   s%   € ð ”ÐÐ"DÐ"D°t´|Ð"DÑ"DÔ"DÑDÐDr0   Úutf_8r6   Úbytesc                ó<  ‡ — ‰ j         �‰ j         |k    rƒ|‰ _         t          ‰ ¦  «        }‰ j        �K‰ j                             ¦   «         dvr0t	          t
          ˆ fd„|dd…         d¬¦  «        }||dd…         z   }|                     |d¦  «        ‰ _        ‰ j        S )z®
        Method to get re-encoded bytes payload using given target encoding. Default to UTF-8.
        Any errors will be simply ignored by the encoder NOT replaced.
        N)zutf-8Úutf8r‘   c                ó&  •— | j         |                      ¦   «         d         |                      ¦   «         d         …                              |                      ¦   «         d         t	          ‰j        ¦  «                             dd¦  «        ¦  «        S )Nr   r
   Ú_ú-)ÚstringÚspanÚreplaceÚgroupsr   r*   )r�   r-   s    €r.   ú<lambda>z%CharsetMatch.output.<locals>.<lambda>ç   sh   ø€ ˜aœh q§v¢v¡x¤x°¤{°Q·V²V±X´X¸a´[Ð'@ÔA×IÒIØŸš™
œ
 1œÝ! $Ô"7Ñ8Ô8×@Ò@ÀÀcÑJÔJñô € r0   i    r
   )Úcountrš   )r*   r   r,   Úlowerr   r   Úencoder)   )r-   r6   Údecoded_stringÚpatched_headers   `   r.   ÚoutputzCharsetMatch.outputØ   sÊ   ø€ ð
 Ô Ð(¨DÔ,AÀXÒ,MÐ,MØ$,ˆDÔ!Ý  ™YœYˆNàÔ,Ð8ØÔ0×6Ò6Ñ8Ô8Ø1ð2ð 2õ "%Ý3ðð ð ð ð # 5 D 5Ô)Øð"ñ "ô "�ð "0°.ÀÀÀÔ2GÑ!G�à#1×#8Ò#8¸À9Ñ#MÔ#MˆDÔ àÔ#Ð#r0   Úintc                ó:   — t          t          | ¦  «        ¦  «        S )z]
        Retrieve a hash fingerprint of the decoded payload, used for deduplication.
        )Úhashr   rF   s    r.   r7   zCharsetMatch.fingerprintõ   s   € õ
 •C˜‘I”I‰ŒÐr0   )NN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r1   r2   r3   r   )r3   r   ©r3   r   )r1   r   r3   rM   )r3   rU   ©r3   r   )r3   r   )r3   r~   )r‘   )r6   r   r3   r’   ©r3   r£   )Ú__name__Ú
__module__Ú__qualname__r/   r9   rC   Úpropertyr@   rJ   rL   rR   r6   r[   r^   ra   r   rq   r=   r>   rz   r|   rE   r€   rƒ   r�   ro   r¢   r7   rd   r0   r.   r   r      sã  € € € € € ð '+Ø-1ðJð Jð Jð Jð Jð8Yð Yð Yð Yð(ð (ð (ð (ð, ð6ð 6ð 6ñ „Xð6ðð ð ð ð Jð Jð Jð Jð	#ð 	#ð 	#ð 	#ð ðð ð ñ „Xðð ð
ð 
ð 
ñ „Xð
ð ð$ð $ð $ñ „Xð$ð ð$ð $ð $ñ „Xð$ð ð/ð /ð /ñ „Xð/ð ð%ð %ð %ñ „Xð%ð6 ð%ð %ð %ñ „Xð%ð ð%ð %ð %ñ „Xð%ð
 ð2ð 2ð 2ñ „Xð2ð ð6ð 6ð 6ñ „Xð6ð ðð ð ñ „Xðð ðð ð ñ „Xðð ð%ð %ð %ñ „Xð%ð ð$ð $ð $ñ „Xð$ð ðEð Eð Eñ „XðEð$ð $ð $ð $ð $ð: ðð ð ñ „Xðð ð r0   r   c                  óT   — e Zd ZdZddd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd„ZdS )ÚCharsetMatchesz³
    Container with every CharsetMatch items ordered by default from most probable to the less one.
    Act like a list(iterable) but does not implements all related methods.
    NÚresultsúlist[CharsetMatch] | Nonec                ó6   — |rt          |¦  «        ng | _        d S rT   )rŠ   Ú_results)r-   r¯   s     r.   r/   zCharsetMatches.__init__  s   € Ø?FÐ,N­F°7©O¬O¨OÈBˆŒˆˆr0   r3   úIterator[CharsetMatch]c              #  ó$   K  — | j         E d {V —† d S rT   ©r²   rF   s    r.   Ú__iter__zCharsetMatches.__iter__  s&   è è € Ø”=Ð Ð Ð Ð Ð Ð Ð Ð Ð r0   Úitemú	int | strr   c                óÌ   — t          |t          ¦  «        r| j        |         S t          |t          ¦  «        r't	          |d¦  «        }| j        D ]}||j        v r|c S Œt          ‚)z¸
        Retrieve a single item either by its position or encoding name (alias may be used here).
        Raise KeyError upon invalid index or encoding not present in results.
        F)r5   r£   r²   r   r   ro   ÚKeyError)r-   r·   Úresults      r.   Ú__getitem__zCharsetMatches.__getitem__	  sv   € õ
 �d�CÑ Ô ð 	'Ø”= Ô&Ð&Ý�d�CÑ Ô ð 	"Ý˜T 5Ñ)Ô)ˆDØœ-ð "ð "�Ø˜6Ô7Ð7Ð7Ø!�M�M�Mð 8åˆr0   r£   c                ó*   — t          | j        ¦  «        S rT   ©r?   r²   rF   s    r.   Ú__len__zCharsetMatches.__len__  s   € Ý�4”=Ñ!Ô!Ð!r0   r   c                ó2   — t          | j        ¦  «        dk    S r‚   r¾   rF   s    r.   Ú__bool__zCharsetMatches.__bool__  s   € Ý�4”=Ñ!Ô! AÒ%Ð%r0   rM   c                ó¼  — t          |t          ¦  «        s4t          d                     t	          |j        ¦  «        ¦  «        ¦  «        ‚t          |j        ¦  «        t          k     rB| j	        D ]:}|j
        |j
        k    r(|j        |j        k    r|                     |¦  «          dS Œ;| j	                             |¦  «         t          | j	        ¦  «        | _	        dS )z~
        Insert a single match. Will be inserted accordingly to preserve sort.
        Can be inserted as a submatch.
        z-Cannot append instance '{}' to CharsetMatchesN)r5   r   r;   rO   r   rP   r?   rE   r   r²   r7   r=   rR   rQ   rŠ   )r-   r·   Úmatchs      r.   rQ   zCharsetMatches.append  sÕ   € õ
 ˜$¥Ñ-Ô-ð 	ÝØ?×FÒFÝ˜œÑ'Ô'ñô ñô ð õ ˆtŒx‰=Œ=Õ+Ò+Ð+Øœð ð �ØÔ$¨Ô(8Ò8Ð8¸U¼[ÈDÌJÒ=VÐ=VØ×&Ò& tÑ,Ô,Ð,Ø�F�FøØŒ×Ò˜TÑ"Ô"Ð"Ý˜tœ}Ñ-Ô-ˆŒˆˆr0   úCharsetMatch | Nonec                ó.   — | j         sdS | j         d         S )zQ
        Simply return the first match. Strict equivalent to matches[0].
        Nr   rµ   rF   s    r.   ÚbestzCharsetMatches.best1  s    € ð Œ}ð 	Ø�4ØŒ}˜QÔÐr0   c                ó*   — |                       ¦   «         S )zP
        Redundant method, call the method best(). Kept for BC reasons.
        )rÆ   rF   s    r.   ÚfirstzCharsetMatches.first9  s   € ð �yŠy‰{Œ{Ðr0   rT   )r¯   r°   )r3   r³   )r·   r¸   r3   r   r¨   r§   )r·   r   r3   rM   )r3   rÄ   )r©   rª   r«   Ú__doc__r/   r¶   r¼   r¿   rÁ   rQ   rÆ   rÈ   rd   r0   r.   r®   r®   ý   sÈ   € € € € € ðð ð
Oð Oð Oð Oð Oð!ð !ð !ð !ðð ð ð ð"ð "ð "ð "ð&ð &ð &ð &ð.ð .ð .ð .ð( ð  ð  ð  ðð ð ð ð ð r0   r®   c                  ó6   — e Zd Zdd„Zedd„¦   «         Zdd„ZdS )ÚCliDetectionResultÚpathr   r6   r   r[   rU   Úalternative_encodingsrq   r�   r   r   r=   r   r>   Úunicode_pathÚis_preferredc                ó    — || _         |
| _        || _        || _        || _        || _        || _        || _        || _        |	| _	        || _
        d S rT   )rÌ   rÎ   r6   r[   rÍ   rq   r�   r   r=   r>   rÏ   )r-   rÌ   r6   r[   rÍ   rq   r�   r   r=   r>   rÎ   rÏ   s               r.   r/   zCliDetectionResult.__init__E  s\   € ð ˆŒ	Ø(4ˆÔØ$,ˆŒØ+;ˆÔØ0EˆÔ"Ø%ˆŒØ$-ˆŒØ$2ˆÔØ!ˆŒ
Ø )ˆŒØ".ˆÔÐÐr0   r3   údict[str, Any]c                óŒ   — | j         | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        dœS )N©rÌ   r6   r[   rÍ   rq   r�   r   r=   r>   rÎ   rÏ   rÓ   rF   s    r.   Ú__dict__zCliDetectionResult.__dict___  sO   € ð ”IØœØ $Ô 5Ø%)Ô%?ØœØœØ"Ô1Ø”ZØœØ Ô-Ø Ô-ð
ð 
ð 	
r0   c                ó4   — ddl m}  || j        dd¬¦  «        S )Nr   )ÚdumpsTé   )Úensure_asciiÚindent)ÚjsonrÖ   rÔ   )r-   rÖ   s     r.   Úto_jsonzCliDetectionResult.to_jsono  s-   € ØÐÐÐÐÐàˆu�T”]°¸aÐ@Ñ@Ô@Ð@r0   N)rÌ   r   r6   r   r[   rU   rÍ   rU   rq   r   r�   rU   r   r   r=   r   r>   r   rÎ   r   rÏ   r   )r3   rÑ   r¦   )r©   rª   r«   r/   r¬   rÔ   rÛ   rd   r0   r.   rË   rË   D  sb   € € € € € ð/ð /ð /ð /ð4 ð
ð 
ð 
ñ „Xð
ðAð Að Að Að Að Ar0   rË   N)Ú
__future__r   Úencodings.aliasesr   Úrer   Útypingr   r   r   r	   Úconstantr   r   Úutilsr   r   r   r   r®   r   r   ÚCoherenceMatchr   rË   rd   r0   r.   ú<module>rã      sN  ðØ "Ð "Ð "Ð "Ð "Ð "à %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -à GÐ GÐ GÐ GÐ GÐ GÐ GÐ GØ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ Cðoð oð oð oð oñ oô oð oðd@ð @ð @ð @ð @ñ @ô @ð @ðF �s˜E�zÔ"€Ø˜Ô'Ð ð.Að .Að .Að .Að .Añ .Aô .Að .Að .Að .Ar0   