Ë
    ò¦1hÐE  ã                  ó2  — d Z ddlmZ dZdgZddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZ ddlmZmZ dd	lmZmZm Z m!Z! dd
l"m#Z# erddl$m%Z% ddlm&Z& ddl'm(Z(m)Z)m*Z* dZ+e	ee,e,f   e,e,gdf   Z- G d„ dee«      Z. G d„ de «      Z/y)zCUse the HTMLParser library to parse HTML files that aren't too bad.é    )ÚannotationsÚMITÚHTMLParserTreeBuilder)Ú
HTMLParser)ÚAnyÚCallableÚcastÚDictÚIterableÚListÚOptionalÚTYPE_CHECKINGÚTupleÚTypeÚUnion)ÚAttributeDictÚCDataÚCommentÚDeclarationÚDoctypeÚProcessingInstruction)ÚEntitySubstitutionÚUnicodeDammit)ÚDetectsXMLParsedAsHTMLÚHTMLÚHTMLTreeBuilderÚSTRICT©ÚParserRejectedMarkup)ÚBeautifulSoup)ÚNavigableString)Ú	_EncodingÚ
_EncodingsÚ
_RawMarkupzhtml.parserNc                  óÞ   — e Zd ZU dZded<   dZded<   	 edœ	 	 	 	 	 	 	 dd„Zd
ed	<   ded<   ded<   dd„Z	 	 	 	 	 	 dd„Z	 d	 	 	 	 	 	 	 d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y)"ÚBeautifulSoupHTMLParserÚreplaceÚstrÚREPLACEÚignoreÚIGNORE©Úon_duplicate_attributeÚsoupr    r-   ú&Union[str, _DuplicateAttributeHandler]c               ó¶   — || _         || _        |j                  j                  | _        t	        j
                  | g|¢­i |¤Ž g | _        | j                  «        y ©N)r.   r-   ÚbuilderÚattribute_dict_classr   Ú__init__Úalready_closed_empty_elementÚ_initialize_xml_detector)Úselfr.   r-   ÚargsÚkwargss        úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/bs4/builder/_htmlparser.pyr4   z BeautifulSoupHTMLParser.__init__T   sS   € ð ˆŒ	Ø&<ˆÔ#Ø$(§L¡L×$EÑ$EˆÔ!Ü×Ñ˜DÐ2 4Ò2¨6Ò2ð -/ˆÔ)à×%Ñ%Õ'ó    z	List[str]r5   c                ó   — t        |«      ‚r1   r   )r7   Úmessages     r:   ÚerrorzBeautifulSoupHTMLParser.erroro   s   € ô # 7Ó+Ð+r;   c                óN   — | j                  ||d¬«       | j                  |«       y)z…Handle an incoming empty-element tag.

        html.parser only calls this method when the markup looks like
        <tag/>.
        F)Úhandle_empty_elementN)Úhandle_starttagÚhandle_endtag)r7   ÚnameÚattrss      r:   Úhandle_startendtagz*BeautifulSoupHTMLParser.handle_startendtag   s'   € ð 	×Ñ˜T 5¸uÐÔEØ×Ñ˜4Õ r;   c                óV  — | j                  «       }|D ]_  \  }}|€d}||v rM| j                  }|| j                  k(  rŒ*|d| j                  fv r|||<   Œ@t	        t
        |«      } ||||«       Œ[|||<   Œa | j                  j                  j                  r| j                  «       \  }}	ndx}}	| j                  j                  |dd|||	¬«      }
|
r<|
j                  r0|r.| j                  |d¬«       | j                  j                  |«       | j                  €| j!                  |«       yy)zÓHandle an opening tag, e.g. '<tag>'

        :param handle_empty_element: True if this tag is known to be
            an empty-element tag (i.e. there is not expected to be any
            closing tag).
        NÚ )Ú
sourcelineÚ	sourceposF)Úcheck_already_closed)r3   r-   r+   r)   r	   Ú_DuplicateAttributeHandlerr.   r2   Ústore_line_numbersÚgetposrA   Úis_empty_elementrB   r5   ÚappendÚ_root_tag_nameÚ_root_tag_encountered)r7   rC   rD   r@   Ú	attr_dictÚkeyÚvalueÚon_duperH   rI   Útags              r:   rA   z'BeautifulSoupHTMLParser.handle_starttagŽ   s@  € ð $(×#<Ñ#<Ó#>ˆ	Øò 	'‰JˆC�ð ˆ}Ø�Ø�iÑð ×5Ñ5�Ø˜dŸk™kÒ)ØØ  t§|¡|Ð 4Ñ4Ø%*�I˜c’Nä"Ô#=¸wÓG�GÙ˜I s¨EÕ2à!&�	˜#’ð%	'ð, �9‰9×Ñ×/Ò/Ø$(§K¡K£MÑ!ˆJ™	à%)Ð)ˆJ˜Ø�i‰i×'Ñ'Ø�$˜˜i°JÈ)ð (ó 
ˆñ �3×'Ò'Ñ,@ð ×Ñ˜t¸%ÐÔ@ð ×-Ñ-×4Ñ4°TÔ:à×ÑÐ&Ø×&Ñ& tÕ,ð 'r;   c                ó’   — |r*|| j                   v r| j                   j                  |«       y| j                  j                  |«       y)zíHandle a closing tag, e.g. '</tag>'

        :param name: A tag name.
        :param check_already_closed: True if this tag is expected to
           be the closing portion of an empty-element tag,
           e.g. '<tag></tag>'.
        N)r5   Úremover.   rB   )r7   rC   rJ   s      r:   rB   z%BeautifulSoupHTMLParser.handle_endtagÌ   s<   € ñ   D¨D×,MÑ,MÑ$Mð
 ×-Ñ-×4Ñ4°TÕ:à�I‰I×#Ñ# DÕ)r;   c                ó:   — | j                   j                  |«       y)z4Handle some textual data that shows up between tags.N)r.   Úhandle_data©r7   Údatas     r:   rZ   z#BeautifulSoupHTMLParser.handle_dataÞ   s   € à�	‰	×Ñ˜dÕ#r;   c                óæ  — |j                  d«      rt        |j                  d«      d«      }n8|j                  d«      rt        |j                  d«      d«      }nt        |«      }d}|dk  r<| j                  j                  dfD ]!  }|sŒ	 t        |g«      j                  |«      }Œ# |s	 t        |«      }|xs d}| j                  |«       y# t        $ r Y ŒUw xY w# t        t        f$ r Y Œ8w xY w)z×Handle a numeric character reference by converting it to the
        corresponding Unicode character and treating it as textual
        data.

        :param name: Character number, possibly in hexadecimal.
        Úxé   ÚXNé   zwindows-1252u   ï¿½)Ú
startswithÚintÚlstripr.   Úoriginal_encodingÚ	bytearrayÚdecodeÚUnicodeDecodeErrorÚchrÚ
ValueErrorÚOverflowErrorrZ   )r7   rC   Ú	real_namer\   Úencodings        r:   Úhandle_charrefz&BeautifulSoupHTMLParser.handle_charrefâ   s÷   € ð �?‰?˜3ÔÜ˜DŸK™K¨Ó,¨bÓ1‰IØ�_‰_˜SÔ!Ü˜DŸK™K¨Ó,¨bÓ1‰Iä˜D›	ˆIàˆØ�sŠ?ð "ŸY™Y×8Ñ8¸.ÐIò �ÙØðÜ$ i [Ó1×8Ñ8¸ÓB‘Dð	ñ ðÜ˜9“~�ð Ò2Ð2ˆØ×Ñ˜Õøô *ò Ùðûô
 ¤Ð.ò Ùðús$   ÂCÂ,C Ã	CÃCÃC0Ã/C0c                óx   — t         j                  j                  |«      }|�|}nd|z  }| j                  |«       y)zÈHandle a named entity reference by converting it to the
        corresponding Unicode character(s) and treating it as textual
        data.

        :param name: Name of the entity reference.
        Nz&%s)r   ÚHTML_ENTITY_TO_CHARACTERÚgetrZ   )r7   rC   Ú	characterr\   s       r:   Úhandle_entityrefz(BeautifulSoupHTMLParser.handle_entityref
  s>   € ô '×?Ñ?×CÑCÀDÓIˆ	ØÐ Ø‰Dð ˜4‘<ˆDØ×Ñ˜Õr;   c                ó¬   — | j                   j                  «        | j                   j                  |«       | j                   j                  t        «       y)zOHandle an HTML comment.

        :param data: The text of the comment.
        N)r.   ÚendDatarZ   r   r[   s     r:   Úhandle_commentz&BeautifulSoupHTMLParser.handle_comment  s8   € ð
 	�	‰	×ÑÔØ�	‰	×Ñ˜dÔ#Ø�	‰	×Ñœ'Õ"r;   c                óÈ   — | j                   j                  «        |t        d«      d }| j                   j                  |«       | j                   j                  t        «       y)zYHandle a DOCTYPE declaration.

        :param data: The text of the declaration.
        zDOCTYPE N)r.   ru   ÚlenrZ   r   r[   s     r:   Úhandle_declz#BeautifulSoupHTMLParser.handle_decl&  sI   € ð
 	�	‰	×ÑÔØ”C˜
“OÐ%Ð&ˆØ�	‰	×Ñ˜dÔ#Ø�	‰	×Ñœ'Õ"r;   c                ó  — |j                  «       j                  d«      rt        }|t        d«      d }nt        }| j
                  j                  «        | j
                  j                  |«       | j
                  j                  |«       y)z{Handle a declaration of unknown type -- probably a CDATA block.

        :param data: The text of the declaration.
        zCDATA[N)Úupperrb   r   rx   r   r.   ru   rZ   )r7   r\   Úclss      r:   Úunknown_declz$BeautifulSoupHTMLParser.unknown_decl0  sf   € ð �:‰:‹<×"Ñ" 8Ô,ÜˆCØœ˜H›˜Ð(‰DäˆCØ�	‰	×ÑÔØ�	‰	×Ñ˜dÔ#Ø�	‰	×Ñ˜#Õr;   c                óÎ   — | j                   j                  «        | j                   j                  |«       | j                  |«       | j                   j                  t        «       y)z\Handle a processing instruction.

        :param data: The text of the instruction.
        N)r.   ru   rZ   Ú_document_might_be_xmlr   r[   s     r:   Ú	handle_piz!BeautifulSoupHTMLParser.handle_pi?  sG   € ð
 	�	‰	×ÑÔØ�	‰	×Ñ˜dÔ#Ø×#Ñ# DÔ)Ø�	‰	×ÑÔ/Õ0r;   N)r.   r    r8   r   r-   r/   r9   r   )r=   r(   ÚreturnÚNone)rC   r(   rD   úList[Tuple[str, Optional[str]]]r�   r‚   )T)rC   r(   rD   rƒ   r@   Úboolr�   r‚   )rC   r(   rJ   r„   r�   r‚   )r\   r(   r�   r‚   )rC   r(   r�   r‚   )Ú__name__Ú
__module__Ú__qualname__r)   Ú__annotations__r+   r4   r>   rE   rA   rB   rZ   rn   rs   rv   ry   r}   r€   © r;   r:   r&   r&   =   sã   … ð €GˆSÓð €FˆCÓðð$ JQñ	(àð(ð ð(ð !Gð	(ð
 ó(ð. CÓBØ"+Ó+Ø
Óó,ð !Øð!Ø ?ð!à	ó!ð& &*ð	<-àð<-ð /ð<-ð #ð	<-ð
 
ó<-ô|*ó$$ó&óPó&#ó#óô1r;   r&   c                  ó¶   ‡ — e Zd ZU dZdZded<   dZded<   eZded<   ee	e
gZd	ed
<   ded<   dZded<   	 	 d	 	 	 	 	 dˆ fd„Z	 	 	 d	 	 	 	 	 	 	 	 	 dd„Zdd„Zˆ xZS )r   z—A Beautiful soup `bs4.builder.TreeBuilder` that uses the
    :py:class:`html.parser.HTMLParser` parser, found in the Python
    standard library.

    Fr„   Úis_xmlTÚ	picklabler(   ÚNAMEzIterable[str]Úfeaturesz$Tuple[Iterable[Any], Dict[str, Any]]Úparser_argsÚTRACKS_LINE_NUMBERSc                óÚ   •— t        «       }dD ]  }||v sŒ|j                  |«      }|||<   Œ t        t        | �  di |¤Ž |xs g }|xs i }|j                  |«       d|d<   ||f| _        y)a‚  Constructor.

        :param parser_args: Positional arguments to pass into
            the BeautifulSoupHTMLParser constructor, once it's
            invoked.
        :param parser_kwargs: Keyword arguments to pass into
            the BeautifulSoupHTMLParser constructor, once it's
            invoked.
        :param kwargs: Keyword arguments for the superclass constructor.
        r,   FÚconvert_charrefsNr‰   )ÚdictÚpopÚsuperr   r4   Úupdater�   )r7   r�   Úparser_kwargsr9   Úextra_parser_kwargsÚargrT   Ú	__class__s          €r:   r4   zHTMLParserTreeBuilder.__init__[  s‹   ø€ ô$ #›fÐØ.ò 	1ˆCØ�fŠ}ØŸ
™
 3›�Ø+0Ð# CÒ(ð	1ô 	Ô# TÑ3Ñ=°fÒ=Ø!Ò' RˆØ%Ò+¨ˆØ×ÑÐ0Ô1Ø,1ˆÐ(Ñ)Ø'¨Ð7ˆÕr;   c              #  ó@  K  — t        |t        «      r	|dddf–— yg }|r|j                  |«       g }|r|j                  |«       t        |||d|¬«      }|j                  €t        d«      ‚|j                  |j                  |j                  |j                  f–— y­w)a2  Run any preliminary steps necessary to make incoming markup
        acceptable to the parser.

        :param markup: Some markup -- probably a bytestring.
        :param user_specified_encoding: The user asked to try this encoding.
        :param document_declared_encoding: The markup itself claims to be
            in this encoding.
        :param exclude_encodings: The user asked _not_ to try any of
            these encodings.

        :yield: A series of 4-tuples: (markup, encoding, declared encoding,
             has undergone character replacement)

            Each 4-tuple represents a strategy for parsing the document.
            This TreeBuilder uses Unicode, Dammit to convert the markup
            into Unicode, so the ``markup`` element of the tuple will
            always be a string.
        NFT)Úknown_definite_encodingsÚuser_encodingsÚis_htmlÚexclude_encodingszPCould not convert input to Unicode, and html.parser will not accept bytestrings.)	Ú
isinstancer(   rO   r   Úunicode_markupr   re   Údeclared_html_encodingÚcontains_replacement_characters)r7   ÚmarkupÚuser_specified_encodingÚdocument_declared_encodingrŸ   rœ   r�   Údammits           r:   Úprepare_markupz$HTMLParserTreeBuilder.prepare_markupy  sÂ   è ø€ ô2 �fœcÔ"à˜4  uÐ-Ò-Øð 57Ð Ù"ð
 %×+Ñ+Ð,CÔDà*,ˆÙ%ð ×!Ñ!Ð"<Ô=äØØ%=Ø)ØØ/ô
ˆð × Ñ Ð(ô 'Øbóð ð
 ×%Ñ%Ø×(Ñ(Ø×-Ñ-Ø×6Ñ6ð	ó ùs   ‚BBc                ó  — | j                   \  }}t        |t        «      sJ ‚| j                  €J ‚t	        | j                  g|¢­i |¤Ž}	 |j                  |«       |j                  «        g |_	        y # t        $ r}t        |«      ‚d }~ww xY wr1   )
r�   r    r(   r.   r&   ÚfeedÚcloseÚAssertionErrorr   r5   )r7   r¤   r8   r9   ÚparserÚes         r:   rª   zHTMLParserTreeBuilder.feedÁ  s�   € Ø×'Ñ'‰ˆˆfô ˜&¤#Ô&Ð&Ð&ð
 �y‰yÐ$Ð$Ð$Ü(¨¯©ÐD°TÒD¸VÑDˆð	*Ø�K‰K˜ÔØ�L‰LŒNð /1ˆÕ+øô ò 	*ô ' qÓ)Ð)ûð		*ús   Á
!A3 Á3	BÁ<BÂB)NN)r�   zOptional[Iterable[Any]]r—   zOptional[Dict[str, Any]]r9   r   )NNN)
r¤   r$   r¥   úOptional[_Encoding]r¦   r¯   rŸ   zOptional[_Encodings]r�   zDIterable[Tuple[str, Optional[_Encoding], Optional[_Encoding], bool]])r¤   r$   r�   r‚   )r…   r†   r‡   Ú__doc__r‹   rˆ   rŒ   Ú
HTMLPARSERr�   r   r   rŽ   r�   r4   r¨   rª   Ú__classcell__)rš   s   @r:   r   r   J  sÃ   ø… ñð €FˆDÓØ€IˆtÓØ€Dˆ#ÓØ# T¨6Ð2€HˆmÓ2Ø5Ó5ð !%Ð˜Ó$ð 04Ø26ð8à,ð8ð 0ð8ð õ	8ðB 8<Ø:>Ø26ðFàðFð "5ðFð %8ð	Fð
 0ðFð 
NóF÷P1r;   )0r°   Ú
__future__r   Ú__license__Ú__all__Úhtml.parserr   Útypingr   r   r	   r
   r   r   r   r   r   r   r   Úbs4.elementr   r   r   r   r   r   Ú
bs4.dammitr   r   Úbs4.builderr   r   r   r   Úbs4.exceptionsr   Úbs4r    r!   Úbs4._typingr"   r#   r$   r±   r(   rK   r&   r   r‰   r;   r:   ú<module>r¾      s®   ðá IÝ "ð €ð ð€õ #÷÷ ÷ ñ ÷÷ ÷ 9÷ó õ 0áÝ!Ý+÷ñ ð €
à% t¨C°¨H¡~°s¸CÐ&@À$Ð&FÑGÐ ôJ1˜jÐ*@ô J1ôZP1˜Oõ P1r;   