Ë
    o]j•"  ã                   ó^   — d Z ddlZddlmZ  G d„ d«      Z G d„ d«      Zd	„ Z G d
„ d«      Zy)zðHandle target-counter, target-counters and target-text.

The TargetCollector is a structure providing required targets' counter_values
and stuff needed to build pending targets later, when the layout of all
targeted anchors has been done.

é    Né   )ÚLOGGERc                   ó   — e Zd ZdZdd„Zy)ÚTargetLookupItemz‡Item controlling pending targets and page based target counters.

    Collected in the TargetCollector's ``target_lookup_items``.

    c                 óJ   — || _         d | _        i | _        d | _        i | _        y )N)ÚstateÚ
target_boxÚparse_again_functionsÚpage_maker_indexÚcached_page_counter_values)Úselfr   s     úM/var/www/zogu/zoguvenv/lib/python3.12/site-packages/weasyprint/css/targets.pyÚ__init__zTargetLookupItem.__init__   s0   € ØˆŒ
ð
 ˆŒð &(ˆÔ"ð !%ˆÔð +-ˆÕ'ó    N)Úpending©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r      s   „ ñô
-r   r   c                   ó   — e Zd ZdZd„ Zy)ÚCounterLookupItemzmItem controlling page based counters.

    Collected in the TargetCollector's ``counter_lookup_items``.

    c                 óX   — || _         || _        || _        d | _        d| _        i | _        y )NF)Úparse_againÚmissing_countersÚmissing_target_countersr   r   r   )r   r   r   r   s       r   r   zCounterLookupItem.__init__-   s9   € à&ˆÔð !1ˆÔØ'>ˆÔ$ð !%ˆÔð ˆŒð +-ˆÕ'r   Nr   r   r   r   r   r   '   s   „ ñó
-r   r   c                 ó„   — | d   dk(  r| d   j                  d«      r| d   dd S | d   dk(  r| d   d   dk(  r| d   d   S yy)z)Get anchor name from string or uri token.r   Ústringé   ú#NÚurlÚinternal)Ú
startswith)Úanchor_tokens    r   Úanchor_name_from_tokenr&   ?   sd   € à�A�˜(Ò" |°A¡×'AÑ'AÀ#Ô'FØ˜A‰˜q˜rÐ"Ð"Ø	�a‰˜EÒ	! l°1¡o°aÑ&8¸JÒ&FØ˜A‰˜qÑ!Ð!ð 'GÐ	!r   c                   ó:   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
y	)
ÚTargetCollectorz@Collector of HTML targets used by CSS content with ``target-*``.c                 ó<   — i | _         i | _        d| _        d| _        y )NTF)Útarget_lookup_itemsÚcounter_lookup_itemsÚ
collectingÚhad_pending_targets)r   s    r   r   zTargetCollector.__init__J   s%   € à#%ˆÔ Ø$&ˆÔ!ð ˆŒð
 $)ˆÕ r   c                 óÒ   — t        |t        «      rW| j                  j                  |«      �t	        j
                  d|«       y| j                  j                  |t        «       «       yy)z7Create a TargetLookupItem for the given `anchor_name``.NzAnchor defined twice: %r)Ú
isinstanceÚstrr*   Úgetr   ÚwarningÚ
setdefaultr   )r   Úanchor_names     r   Úcollect_anchorzTargetCollector.collect_anchorZ   sT   € ä�k¤3Ô'Ø×'Ñ'×+Ñ+¨KÓ8ÐDÜ—‘Ð9¸;ÕGà×(Ñ(×3Ñ3ØÔ!1Ó!3õ5ð	 (r   c                 ó  — t        |«      }| j                  j                  |t        d«      «      }|j                  dk(  r%d| _        |j                  j                  ||f|«       |j                  dk(  rt        j                  d|«       |S )zîGet a TargetLookupItem corresponding to ``anchor_token``.

        If it is already filled by a previous anchor-element, the status is
        'up-to-date'. Otherwise, it is 'pending', we must parse the whole
        tree again.

        Ú	undefinedr   Tz7Content discarded: target points to undefined anchor %r)
r&   r*   r1   r   r   r-   r
   r3   r   Úerror)r   r%   Ú
source_boxÚ	css_tokenr   r4   Úitems          r   Úlookup_targetzTargetCollector.lookup_targetc   sŠ   € ô -¨\Ó:ˆØ×'Ñ'×+Ñ+ØÔ)¨+Ó6ó8ˆð �:‰:˜Ò"Ø'+ˆDÔ$Ø×&Ñ&×1Ñ1Ø˜YÐ'¨ô6ð �:‰:˜Ò$Ü�L‰LØIØôð ˆr   c                 ó  — | j                   j                  |«      }|rc|j                  dk(  rSd|_        ||_        |j                  €8|j                  «       D ��ci c]  \  }}||j                  «       “Œ c}}|_        yyyyc c}}w )z¦Store a target called ``anchor_name``.

        If there is a pending TargetLookupItem, it is updated. Only previously
        collected anchors are stored.

        r   ú
up-to-dateN)r*   r1   r   r	   Úcached_counter_valuesÚitemsÚcopy)r   r4   Útarget_counter_valuesr	   r;   ÚkeyÚvalues          r   Ústore_targetzTargetCollector.store_target{   s‡   € ð ×'Ñ'×+Ñ+¨KÓ8ˆÙ�D—J‘J )Ò+Ø%ˆDŒJØ(ˆDŒOð ×/Ñ/Ð7ð -×2Ñ2Ó4÷46Ù*4¨#¨u�C˜Ÿ™›Ñ%ó46�
Õ0ð 8ð ,ˆ4ùó46s   ÁBc                 ó¤   — | j                   sy|s|r?|j                  €||_        t        |||«      }| j                  j	                  ||f|«       yy)a$  Collect missing (probably page-based) counters during formatting.

        The ``missing_counters`` are re-used during pagination.

        The ``missing_link`` attribute added to the parent_box is required to
        connect the paginated boxes to their originating ``parent_box``.

        N)r,   Úmissing_linkr   r+   r3   )r   Ú
parent_boxr:   Úparse_again_functionr   r   Úcounter_lookup_items          r   Úcollect_missing_countersz(TargetCollector.collect_missing_counters�   sd   € ð �ŠØñ Ñ6Ø×&Ñ&Ð.Ø*4�
Ô'Ü"3Ø$Ð&6Ø'ó#)Ðð ×%Ñ%×0Ñ0Ø˜YÐ'Ð)<õ>ð  7r   c                 óÂ   — | j                   rL| j                  j                  «       D ](  }|j                  j                  «       D ]	  } |«        Œ Œ* d| _         d| _        y)z Check pending targets if needed.FN)r-   r*   Úvaluesr
   r,   )r   r;   Úfunctions      r   Úcheck_pending_targetsz%TargetCollector.check_pending_targets¦   s]   € à×#Ò#Ø×0Ñ0×7Ñ7Ó9ò �Ø $× :Ñ :× AÑ AÓ Cò �HÙ•Jñðð (-ˆDÔ$àˆ�r   c                 ód  — | j                   ry| j                  j                  |«      }|�r|j                  dk(  rõ||_        |j
                  |k7  rÞt        j                  |«      |_        | j                  j                  «       D ]¦  \  \  }}}|dk7  rŒ|j                  j                  |«      }|€Œ-|j                  �|j                  t        |«      k\  rd|_        ŒY|D ]I  }	|j                  |	«      }
|
€Œ||j                     d   }d|d<   |j                  |j
                  «        Œ¦ Œ¨ yyyy)z…Store target's current ``page_maker_index`` and page counter values.

        Eventually update associated targeting boxes.

        Nr>   ÚcontentTéÿÿÿÿÚcontent_changed)r,   r*   r1   r   r   r   rA   Údeepcopyr+   r@   r   Úlenr   r   )r   r4   Úpage_counter_valuesr   Ú
page_makerr;   Ú_r:   r   Úcounter_nameÚcounter_valueÚremake_states               r   Úcache_target_page_countersz*TargetCollector.cache_target_page_counters°   sN  € ð �?Š?Øà×'Ñ'×+Ñ+¨KÓ8ˆÚ�D—J‘J ,Ò.Ø$4ˆDÔ!Ø×.Ñ.Ð2EÒEÜ26·-±-Ø'ó3)�Ô/ð
 -1×,EÑ,E×,KÑ,KÓ,Mò "Ñ(‘N�Q˜	 Dà  IÒ-Ø ð (,×'CÑ'C×'GÑ'GØ#ó(%Ð$à'Ð/Ø ð ×-Ñ-Ð5Ø ×1Ñ1´S¸³_ÒDØ'+˜œØ ð
 )9ò "˜Ø(;×(?Ñ(?ÀÓ(M˜Ø(Ñ4à *¨4×+@Ñ+@Ñ AÀ"Ñ Eð )à>B˜LÐ):Ñ;Ø ×,Ñ,¨T×-LÑ-LÔMÙ!ñ"ñ)"ð Fð /ˆ4r   N)r   r   r   r   r   r5   r<   rE   rK   rO   r\   r   r   r   r(   r(   G   s(   „ ÙJò)ò 5òò06ò$>ò2 ó/"r   r(   )r   rA   Úloggerr   r   r   r&   r(   r   r   r   ú<module>r^      s7   ðñó å ÷-ñ -÷2-ñ -ò0"÷X"ò X"r   