+
    	iq5                     2   R t ^ RIt^ RIt^ RIHt ^ RIHt ^RIHtH	t	 ^RI
HtHt ^RIHt ^RIHt ^RIHt ^R	IHt ^R
IHt ^RIHt ^RIHt ^RIHtHt ^RIH t  ^RI!H"t" ^RI#H$t$H%t% ^RI&H't' ^RI(H)t)  ! R R4      t* ! R R4      t+ ! R R4      t,R# )zDocument generation management.N)md5)Path)CSSDEFAULT_OPTIONS)gather_anchorsmake_page_bookmark_tree)get_all_computed_styles)CounterStyle)TargetCollector)	draw_page)build_formatting_structure)get_html_metadata)get_image_from_uri)LayoutContextlayout_document)PROGRESS_LOGGER)Matrix)VARIANTSgenerate_pdf)DocumentMetadata)FontConfigurationc                   4   a  ] tR t^t o RtR tRR ltRtV tR# )PagezsRepresents a single rendered page.

Should be obtained from :attr:`Document.pages` but not
instantiated directly.

c                   VP                  4       V n        VP                  4       V n        R Uu/ uF#  pW!P                  RV 2,          P
                  bK%  	  upV n        . V n        . V n        / V n	        R. /V n
        \        WP                  V P                  V P                  V P                  4       Wn        R# u upi )topbleed_N)r   rightbottomleft)margin_widthwidthmargin_heightheightstylevaluebleed	bookmarkslinksanchorsformsr   	_page_box)selfpage_boxsides   && Y/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/weasyprint/document.py__init__Page.__init__!   s    **,
 ,,. ;<: ..6$1777:<
  
  BZ
xtzz4>>4::V!O<s   )B<c                    VP                  4       ;_uu_ 4        VP                  W"R7       \        V P                  V4       RRR4       R#   + '       g   i     R# ; i)z!Paint the page into the PDF file.adN)stacked	transformr   r*   )r+   streamscales   &&&r.   paint
Page.paintS   s=    ^^u.dnnf- s   )AA	)r*   r(   r%   r&   r)   r"   r'   r    N)   )	__name__
__module____qualname____firstlineno____doc__r/   r9   __static_attributes____classdictcell____classdict__s   @r.   r   r      s     0"d. .    r   c                   H   a  ] tR t^Zt o RtR tR tR tR tR t	R t
RtV tR	# )
	DiskCachezDict-like storing images content on disk.

Bytestring values are stored on disk. Other lightweight Python objects
(i.e. RasterImage instances) are still stored in memory.

c                    \        V4      V n        V P                  P                  R R R7       / V n        \	        4       V n        R# )T)parentsexist_okN)r   _pathmkdir_memory_cacheset_disk_paths)r+   folders   &&r.   r/   DiskCache.__init__b   s6    &\


55rE   c                z    \        VP                  4       R R7      P                  4       pV P                  V,          # )F)usedforsecurity)r   encode	hexdigestrK   )r+   keydigests   && r.   _path_from_keyDiskCache._path_from_keyh   s,    SZZ\59CCEzzF""rE   c                    WP                   9   d   V P                   V,          # V P                  V4      P                  4       # N)rM   rX   
read_bytesr+   rV   s   &&r.   __getitem__DiskCache.__getitem__l   s9    $$$%%c**&&s+6688rE   c                    \        V\        4      '       d@   V P                  V4      pV P                  P	                  V4       VP                  V4       R # W P                  V&   R # r[   )
isinstancebytesrX   rO   addwrite_bytesrM   )r+   rV   r$   paths   &&& r.   __setitem__DiskCache.__setitem__r   sO    eU##&&s+D  &U#&+s#rE   c                l    WP                   9   ;'       g     V P                  V4      P                  4       # r[   )rM   rX   existsr]   s   &&r.   __contains__DiskCache.__contains__z   s4    %%% . .$++-	/rE   c                     V P                    F  pVP                  R R7       K  	  V P                  P                  4        R#   \         d     R# i ; i)T)
missing_okN)rO   unlinkrK   rmdir	Exception)r+   re   s   & r.   __del__DiskCache.__del__   sG    	((t, )JJ 		s   ?A AA)rO   rM   rK   N)r<   r=   r>   r?   r@   r/   rX   r^   rf   rj   rq   rA   rB   rC   s   @r.   rG   rG   Z   s-     !#9,/
 rE   rG   c                   h   a  ] tR t^t o Rt]R 4       t]R 4       tR tR
R lt	RR lt
RR ltR	tV tR# )Documenta{  A rendered document ready to be painted in a pydyf stream.

Typically obtained from :meth:`HTML.render() <weasyprint.HTML.render>`, but
can also be instantiated directly with a list of :class:`pages <Page>`, a
set of :class:`metadata <DocumentMetadata>`, a :class:`url_fetcher
<weasyprint.urls.URLFetcher>`, and a :class:`font_config
<weasyprint.text.fonts.FontConfiguration>`.

c                   \        4       p. p. p. p	VR ,          p
V
f   / p
M'\        V
\        \        34      '       g   \        V
4      p
VR,          ;'       g    .  F>  p\	        VR4      '       g   \        WP                  W#VR7      pV	P                  V4       K@  	  \        WVR,          VW4WxVVR,          4
      p\        P                  ! \        V
VP                  VR7      p\        P                  ! R4       \        WW#V4      pV# )cachestylesheetsmatcher)guess
media_typefont_configcounter_stylecolor_profilespresentational_hints	pdf_forms)rv   url_fetcheroptionsz&Step 4 - Creating formatting structure)r
   ra   dictrG   hasattrr   rz   appendr   	functoolspartialoriginal_get_image_from_urir   r   infor   )clshtmlr{   r|   r}   r   target_collector
page_ruleslayersuser_stylesheetsrv   css	style_forr   contexts   &&&&&&         r.   _build_layout_contextDocument._build_layout_context   s    +,
 =EED)#455e$E=)//R/C3	**// +#13 ##C( 0 ,G,B$C[:?OK "	 '..'u(('; 	EF; rE   c           
        Vf   \        4       pVf   \        4       pVf   / pV P                  WW4V4      p\        VP                  VP
                  VP                  VP                  VP                  VVP                  4      p\        WV4      pT ! V U	u. uF  p	\        V	4      NK  	  up	\        R/ \        V4      B VP                  W$4      p
Wn        V
# u up	i )N )r   r	   r   r   etree_elementr   r   base_urlr   	footnotesr   r   r   r   r   _html)r   r   r{   r|   r}   r   r   root_box
page_boxesr,   	renderings   &&&&&&     r.   _renderDocument._render   s    +-K (NM!N++}gG . 1 173M3MMM733]
 %TW=
,67JT(^J77067k;	 	 8s   Cc                P    Wn         W n        W0n        / V n        W@n        WPn        R # r[   )pagesmetadatar   fontsr{   r}   )r+   r   r   r   r{   r}   s   &&&&&&r.   r/   Document.__init__   s+    
 !& 

 ',rE   c                    VR8X  d   V P                   pM!\        V\        4      '       g   \        V4      p\        V 4      ! WP                  V P
                  V P                  V P                  4      # )a  Take a subset of the pages.

:type pages: :term:`iterable`
:param pages:
    An iterable of :class:`Page` objects from :attr:`pages`.
:return:
    A new :class:`Document` object.

Examples:

Write two PDF files for odd-numbered and even-numbered pages::

    # Python lists count from 0 but pages are numbered from 1.
    # [::2] is a slice of even list indexes but odd-numbered pages.
    document.copy(document.pages[::2]).write_pdf('odd_pages.pdf')
    document.copy(document.pages[1::2]).write_pdf('even_pages.pdf')

Combine multiple documents into one PDF file,
using metadata from the first::

    all_pages = [p for doc in documents for p in doc.pages]
    documents[0].copy(all_pages).write_pdf('combined.pdf')

all)r   ra   listtyper   r   r{   r}   )r+   r   s   &&r.   copyDocument.copy   s[    2 E>JJEE4((KEDz==$"2"2D4D4D! 	!rE   c           	         . p. pV.p^ p\        V P                  4       FF  w  rxV'       d!   \        W) VP                  V,          R7      p	M\        WR7      p	\	        WWVWy4      pKH  	  V# )a  Make a tree of all bookmarks in the document.

:param float scale:
    Zoom scale.
:param bool transform_pages:
    A boolean defining whether the default PDF page transformation
    matrix has to be applied to bookmark coordinates, setting the
    bottom-left corner as the origin.
:return: A list of bookmark subtrees.
    A subtree is ``(label, target, children, state)``. ``label`` is
    a string, ``target`` is ``(page_number, x, y)``  and ``children``
    is a list of child subtrees.

)r3   r4   fr2   )	enumerater   r   r"   r   )
r+   r8   transform_pagesrootskipped_levelslast_by_depthprevious_levelpage_numberpagematrixs
   &&&       r.   make_bookmark_treeDocument.make_bookmark_tree  so     
 !*4::!6K%6T[[55HI%14m%N "7 rE   Nc                   \         P                  ! 4       pVP                  V4       TpVR,          ;p'       dT   \        V,          w  rxRV9   d   VR,          '       g   VR,          VR&   RV9   d   VR,          '       g   VR,          VR&   \	        WV3/ VB p	V'       d	   V! W	4       VR,          p
VR,          '       * pVR,          pVf8   \
        P                  ! 4       pV	P                  WW4       VP                  4       # \        VR4      '       d   V	P                  WW4       R# \        VR	4      ;_uu_ 4       pV	P                  WW4       RRR4       R#   + '       g   i     R# ; i)
a  Paint the pages in a PDF file, with metadata.

:type target:
    :class:`str`, :class:`pathlib.Path` or :term:`file object`
:param target:
    A filename where the PDF file is generated, a file object, or
    :obj:`None`.
:param float zoom:
    The zoom factor in PDF units per CSS units.  **Warning**:
    All CSS units are affected, including physical units like
    ``cm`` and named sizes like ``A4``.  For values other than
    1, the physical CSS units will thus be "wrong".
:type finisher: :term:`callable`
:param finisher:
    A finisher function or callable that accepts the document and a
    :class:`pydyf.PDF` object as parameters. Can be passed to perform
    post-processing on the PDF right before the trailer is written.
:param options:
    The ``options`` parameter includes by default the
    :data:`weasyprint.DEFAULT_OPTIONS` values.
:returns:
    The PDF as :obj:`bytes` if ``target`` is not provided or
    :obj:`None`, otherwise :obj:`None` (the PDF is written to
    ``target``).

pdf_variantversionpdf_version
identifierpdf_identifieruncompressed_pdfNwritewb)r   r   updater   r   ioBytesIOr   getvaluer   open)r+   targetzoomfinisherr   new_optionsvariant_
propertiespdfr   compressr   outputfds   &&&&,          r.   	write_pdfDocument.write_pdf%  s8   6 &**,7# m,,7,$W-MAJ&w}/E/E)3I)>&z)':J2K2K,6|,D()499T-.
122-(>ZZ\FIIfz<??$$67##IIfz<fd##r		"z< $###s   ?EE-	)r}   r{   r   r   r   r   )r   )r;   F)Nr;   N)r<   r=   r>   r?   r@   classmethodr   r   r/   r   r   r   rA   rB   rC   s   @r.   rt   rt      sM       >  4-(!BB9= 9=rE   rt   )-r@   r   r   hashlibr   pathlibr    r   r   r(   r   r   r   r   css.countersr	   css.targetsr
   drawr   formatting_structure.buildr   r   r   imagesr   r   layoutr   r   loggerr   r   r   r   r   r   pdf.metadatar   
text.fontsr   r   rG   rt   r   rE   r.   <module>r      sc    %  	   " < ( & (  B # E 2 #  ' * )>. >.B, ,^U= U=rE   