+
    5i                      a  R| tj0 t R t^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
HtHtHtHtHt ^ RIHt ^RIHtHtHtHt  ^ RIHt ^R	IHt ^R
IH t H!t!H"t"H#t#H$t$H%t%H&t&H't'H(t( ^RI)H*t*H+t+H,t,H-t-H.t.H/t/H0t0 ^RI1H2t2H3t3 ^RI4H5t5 ^RI6H7t7H8t8 ]'       d   ^ RIH9t9 ^RIH:t: ^RI;H<t< ^RI4H=t= ]P|                  ! ]?4      t@RRRR/tA]P                  ! R4      tC]P                  ! R4      tD]P                  ! R]P                  4      tF]P                  ! R4      tGR R ltH]0 ! R R]I4      4       tJ]P                  ! R4      tK0 R}mtLR ^HR!R~R"RR#^R$^R%R&R'R/tMR(]P                  R),          R*]P                  R+,          R,^R-]P                  /tO]0RR. R/ ll4       tP]0RR0 R1 ll4       tQ]0R2 R3 l4       tR]0R4 R5 l4       tS]0R6 R7 l4       tT]S! RR8R9R:R;R<R=4      tU]0R> R? l4       tV]0R@ RA l4       tW]0RB RC l4       tX]0RD RE l4       tY]0RF 3RG RH ll4       tZ]0RI 3RJ RK ll4       t[RLRM RNRO RPRQ RRRS RTRU RVRW RXRY RZR[ R\R] R^R_ R`Ra /t\] ^ k ]0RRb Rc ll4       t]Rd Re lt^RRf Rg llt_Rh Ri lt`RRj Rk lltaRRl Rm lltbRRn Ro lltcRp Rq ltd]0 ! Rr Rs4      4       te]0Rt Ru l4       tf]0Rv Rw l4       tg ! Rx Ry4      th ! Rz R{]4      tiR#   ] d    ]P6                  ! R4       ^ RIHt  ELi ; i)aA  
Utilities to parse SVG graphics into fpdf.drawing objects.

The contents of this module are internal to fpdf2, and not part of the public API.
They may change at any time without prior warning or any deprecation period,
in non-backward-compatible ways.

Usage documentation at: <https://py-pdf.github.io/fpdf2/SVG.html>
N)deepcopy)PathLike)TYPE_CHECKINGAnyCallable
NamedTupleOptional)
parse_path)GradientSpreadMethodGradientUnitsPathPaintRuleStrokeCapStyle)
fromstringzYdefusedxml could not be imported - fpdf2 will not be able to sanitize SVG images provided)html)	BoundingBoxClippingPathGradientPaintGraphicsContextGraphicsStylePaintedPathPathPenTextTextRun)
DeviceGray	DeviceRGBPoint	Transformcolor_from_hex_stringcolor_from_rgb_stringforce_nodocument)
ImageCacheVectorImageInfo)stream_content_for_raster_image)shape_linear_gradientshape_radial_gradient)Element)
Renderable)FPDF)ResourceCatalogsvgzhttp://www.w3.org/2000/svgxlinkzhttp://www.w3.org/1999/xlinkz(?:\s+,\s+|\s+,|,\s+|\s+|,)zf(matrix|rotate|scale|scaleX|scaleY|skew|skewX|skewY|translate|translateX|translateY)\(([\d\.,\s+-]+)\)z	/\*.*?\*/z(?s)([^{}]+)\{([^{}]*)\}c                \    V ^8  d   QhR\         \        ,          R\         \        ,          /#    valuereturnr   str)formats   "N/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fpdf/svg.py__annotate__r4   X   s"       (3-     c                 v    V f   R # \        V \        4      '       d   V P                  4       pV'       g   R # V# V # N)
isinstancer1   strip)r.   strippeds   & r3   _normalize_css_valuer;   X   s2    }%;;=Lr5   c                       ] tR t^ctRtRtR# )Percentz$class to represent percentage values N)__name__
__module____qualname____firstlineno____doc____static_attributes__r>   r5   r3   r=   r=   c   s    .r5   r=   z2\s*(?P<value>[-+]?[\d\.]+)\s*(?P<unit>%|[a-zA-Z]*)incmmmptpcpxg      ?Qdegih  gradi  radturnc                <    V ^8  d   QhR\         R\         R\        /# )r-   
length_strdefault_unitr/   r1   float)r2   s   "r3   r4   r4      s&     V Vs V# V Vr5   c                @   \         P                  V 4      pVf   \        RV  R24      RhVP                  4       w  r4V'       g   Tp \	        V4      \
        V,          ,          #   \         d/    T\        9   d   \        T  RT 24      Rh\        T  RT 24      Rhi ; i)z7Convert a length unit to our canonical length unit, pt.NzUnable to parse 'z' as a lengthz" uses unsupported relative length z contains unrecognized unit )unit_splittermatch
ValueErrorgroupsrT   absolute_length_unitsKeyErrorrelative_length_units)rQ   rR   rW   r.   units   &&   r3   resolve_lengthr^      s     
+E},ZLFGTQ,,.KEVU|3D999 V((,@G J<'CD6JKQUUVs   A$ $9Bc                <    V ^8  d   QhR\         R\         R\        /# )r-   	angle_strrR   r/   rS   )r2   s   "r3   r4   r4      s&     Q QS Q Q Qr5   c                    \         P                  V 4      pVe   VP                  4       w  r4MT pX'       g   Tp \        V4      \        V,          ,          #   \
         d    \        RT  RT 24      Rhi ; i)z;Convert an angle value to our canonical angle unit, radiansNzangle z has unknown unit )rV   rW   rY   rT   angle_unitsr[   rX   )r`   rR   mr.   r]   s   &&   r3   resolve_anglerd      s{     	I&A}hhjtQU|k$/// Q6),>tfEFDPQs   A A5c                <    V ^8  d   QhR\         R\         R\         /# )r-   spacenamer/   r1   )r2   s   "r3   r4   r4      s!       C C r5   c                X     R\         V ,           R2p V  V 2#   \         d    Rp  Li ; i)zECreate an XML namespace string representation for the given tag name.{} )_HANDY_NAMESPACESr[   )rf   rg   s   &&r3   xmlnsrn      sC    &u-.b1 WTF  s    ))c                ^    V ^8  d   QhR\         R\         R\        \         \         3,          /# )r-   rf   namesr/   )r1   dict)r2   s   "r3   r4   r4      s)       S T#s(^ r5   c                >    / pV F  pW2\        W4      &   W2V&   K  	  V# )z>Create a lookup for the given name in the given XML namespace.)rn   )rf   rp   resultrg   s   &*  r3   xmlns_lookuprt      s.     F%)uU!"t  Mr5   c                0    V ^8  d   QhR\         R\         /# )r-   qualified_tagr/   rh   )r2   s   "r3   r4   r4      s      c c r5   c                L    V P                  R4      pV^ 8  d   W^,           R # V # )z8Remove the xmlns namespace from a qualified XML tag namerk   N)index)rv   is   & r3   
without_nsrz      s0     	C AAvUW%%r5   rectcircleellipselinepolylinepolygonc                F    V ^8  d   QhR\         R\        \        ,          /# )r-   colorstrr/   )r1   r   r   )r2   s   "r3   r4   r4      s#     D Ds Dy:5 Dr5   c                      \         P                  V ,          p V P                  R 4      '       d   \	        V 4      # V P                  R4      '       d   \        V 4      # \        RV  24      h  \         d     L_i ; i)#rgbz unsupported color specification )r   
COLOR_DICTr[   
startswithr   r   rX   r   s   &r3   svgcolorr      sv    ??8, 3$X..5!!$X..
7zB
CC  s   A+ +A98A9c                F    V ^8  d   QhR\         R\        \        ,          /# r-   incomingr/   )r1   r   rT   )r2   s   "r3   r4   r4      s      3 8E? r5   c                 Z    \        V 4      pV^ 8  d   \        RV  R24      hV^ 8X  d   R# V# )    zstroke width z cannot be negativeN)r^   rX   r   vals   & r3   convert_stroke_widthr      s7    

"C
Qw=
2EFGG
axJr5   c                0    V ^8  d   QhR\         R\        /# r   rS   )r2   s   "r3   r4   r4      s        r5   c                 H    \        V 4      pVR 8  d   \        RV  R24      hV# )      ?zmiter limit z cannot be less than 1)rT   rX   r   s   & r3   convert_miterlimitr      s,    
/C
Sy<z1GHIIJr5   c                `    V ^8  d   QhR\         R\         R\        \        .\         3,          /# )r-   min_valmax_valr/   )rT   r   r1   )r2   s   "r3   r4   r4     s,     	 	 	 	8SE5L3I 	r5   c                    a a R  VV 3R llpV# )c                0    V ^8  d   QhR\         R\        /# r,   rS   )r2   s   "r3   r4   !clamp_float.<locals>.__annotate__  s        r5   c                 B   < \        V 4      pVS8  d   S# VS8  d   S# V# r7   rT   )r.   r   r   r   s   & r3   	converterclamp_float.<locals>.converter  s)    El=N=N
r5   r>   )r   r   r   s   ff r3   clamp_floatr     s      r5   c                     V # r7   r>   )r.   s   &r3   <lambda>r     s    r5   c                `    V ^8  d   QhR\         R\        \         .\        3,          R\        /# r-   r.   r   r/   )r1   r   r   )r2   s   "r3   r4   r4     s/      #SE3J/r5   c                 @    V R9   d   \         P                  # V! V 4      # )inherit)r   currentColor)r   INHERITr.   r   s   &&r3   inheritabler     s$     ++$$$Ur5   c                     V # r7   r>   )noops   &r3   r   r     s    r5   c                v    V ^8  d   QhR\         \        ,          R\        \        .\        3,          R\        /# r   )r   r1   r   r   )r2   s   "r3   r4   r4     s3     
) 
)C=
)%-seSj%9
)
)r5   c                     V f   R # \        V \        4      '       d   V P                  4       '       g   R # V R8X  d   R # \        W4      # )Nnone)r8   r1   r9   r   r   s   &&r3   optionalr     s;    
 }%ekkmmu((r5   fillc                 j    R V '       d   V P                  R4      '       g   \        V \        4      3# R3# )
fill_colorurl(Nr   r   r   r   s   &r3   r   r   .  s5     !4!4V!<!< Xx(
 r5   z	fill-rulec                     R \        V 4      3# )intersection_ruler   )fillrulestrs   &r3   r   r   7  s    &9;{;S%Tr5   zfill-opacityc                 2    R \        V \        RR4      4      3# )fill_opacity        r   r   r   )filopstrs   &r3   r   r   9  s    Hk#s34&r5   strokec                 j    R V '       d   V P                  R4      '       g   \        V \        4      3# R3# )stroke_colorr   Nr   r   s   &r3   r   r   >  s5     !4!4V!<!< Xx( 
  r5   zstroke-widthc                 &    R \        V \        4      3# )stroke_width)r   r   )valuestrs   &r3   r   r   G  s    H23&r5   zstroke-dasharrayc                      R \        V R 4      3# )stroke_dash_patternc                 z    \         P                  V 4       Uu. uF  q'       g   K  \        V4      NK  	  up# u upi r7   )NUMBER_SPLITsplitrT   )daitems   & r3   r   <lambda>.<locals>.<lambda>P  s+    0B0B20FO0F$d0FOOs   	88)r   )	dasharrays   &r3   r   r   L  s    O	
+r5   zstroke-dashoffsetc                 &    R \        V \        4      3# )stroke_dash_phase)r   rT   )dashoffs   &r3   r   r   U  s    GU#*r5   zstroke-linecapc                     R \        V 4      3# )stroke_cap_styler   )capstrs   &r3   r   r   Z  s    &8+f:M%Nr5   zstroke-linejoinc                     R \        V 4      3# )stroke_join_styler   )joinstrs   &r3   r   r   \  s    (;[=Q'Rr5   zstroke-miterlimitc                 &    R \        V \        4      3# )stroke_miter_limit)r   r   )limstrs   &r3   r   r   ^  s    F./)r5   zstroke-opacityc                 2    R \        V \        RR4      4      3# )stroke_opacityr   r   r   )stropstrs   &r3   r   r   c  s    Hk#s34(r5   c          	          V ^8  d   QhR\         \        ,          RRR\        \        \        \
        3,          ,          RR/# )r-   stylablesvg_elementr%   computed_styler/   N)r   r   r   rq   r1   r   )r2   s   "r3   r4   r4   k  sB     $7 $7O+$7$7 T#s(^,$7 
	$7r5   c                B   Ve   TpM^/ p\         P                  ! VP                  P                  RR4      4      P	                  4        F  w  rE\        V4      pVf   K  WcV&   K  	  RV P                  n        \        P	                  4        Fj  w  rx\        VP                  V4      4      p	V	f%   \        VP                  P                  V4      4      p	V	f   KM  \        V P                  .V! V	4      O5!   Kl  	  \        VP                  R4      4      p
V
f%   \        VP                  P                  R4      4      p
V
e,   \        V
4      pWP                  n        WP                  n        VP                  P                  R4      pV'       d   \        V4      V n        R# R# )zKApply the known styles from `svg_element` to the pdf path/group `stylable`.Nstylerl   Fopacity	transform)r   parse_css_styleattribgetitemsr;   r   
auto_closesvg_attr_mapsetattrrT   r   r   convert_transformsr   )r   r   r   r   keyr.   
norm_value	attr_namer   
attr_valueopacity_strr   tfstrs   &&&          r3   apply_stylesr   j  s_    !..""7B/

%'JC .e4J%'c
 !&HNN , 2 2 4	)%))I*>?
-k.@.@.D.DY.OPJ!HNN;Yz%:; !5 'uyy';<K*;+=+=+A+A)+LM$&-#(/%"";/E/6 r5   c                V    V ^8  d   QhR\         \        \        3,          RRR\        /# )r-   	style_maptagr%   r/   )rq   r1   r   bool)r2   s   "r3   r4   r4     s)     ) )DcN ) )t )r5   c                     V P                  R 4      ;'       g    RP                  4       pVR9   d   R# VP                  P                  R4      p\        VR8H  4      # )white-spacerl   Tz+{http://www.w3.org/XML/1998/namespace}spacepreserve)prezpre-wrapzbreak-spaces)r   r9   r   r   )r   r   ws	xml_spaces   &&  r3   _preserve_wsr     sP    
--
&
,
,"	3	3	5B	00

LMI	Z'((r5   c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r-   sr   r/   )r   r1   r   )r2   s   "r3   r4   r4     s%     	" 	"HSM 	"T 	"c 	"r5   c                R    V f   R# V'       d   V # \         P                  ! RRV 4      # )z
Collapse sequences of whitespace characters (spaces, tabs, etc.) to a single space
In some cases, like with `pre` tags, whitespace should be preserved.
rl   z\s+ )resub)r   r   s   &&r3   _collapse_wsr    s'    
 	y66&#q!!r5   c                R    V ^8  d   QhR\         \        ,          R\        R\        /# )r-   
font_stylefont_weightr/   r0   )r2   s   "r3   r4   r4     s&      HSM  PS r5   c                 b   R pR pV'       dR   VP                  4       P                  4       pVR9   ;'       g'    VP                  4       ;'       d    \        V4      R8  pV '       d$   V P                  4       P                  4       pVR9   pV'       d   V'       d   R# V'       d   R# V'       d   R# R# )FiX  BIBIrl   )boldbolder)italicoblique)r9   lowerisdigitint)r  r  bry   fwfss   &&    r3   _svg_font_style_to_emphasisr    s    AA &&($$II)H)H#b'S.%%'''Qr5   c          	          V ^8  d   QhRRR\         R\        \        \         \        3,          ,          R\        \         ,          /# )r-   r   r%   rg   r   r/   )r1   r   rq   r   )r2   s   "r3   r4   r4     s=     6 6	66*24S>*B6c]6r5   c                :   Ve!   \        VP                  V4      4      pVe   V# VfQ   \        P                  ! V P                  P                  RR4      4      p\        VP                  V4      4      pVe   V# \        V P                  P                  V4      4      # )zJReturn the value for a given attribute, honoring computed style overrides.r   rl   )r;   r   r   r   r   )r   rg   r   r.   inlines   &&&  r3   _get_attr_or_styler    s     $Y]]4%89L%%cjjnnWb&AB$VZZ%56L

t 455r5   c          
          V ^8  d   QhRRR\         \        \        \        3,          ,          R\        \         \        ,          \        \         \
        ,          \        3,          /# )r-   r   r%   r   r/   )r   rq   r1   r   tuplerT   )r2   s   "r3   r4   r4     sL     Q Q	Q'S#X7Q
8C=#x34Qr5   c                   \        V RV4      pV'       d   . pVP                  R4       FN  pVP                  4       P                  RR4      P                  RR4      pV'       g   K=  VP	                  V4       KP  	  V'       d   RP                  V4      MRpMRp\        V RV4      ;'       g    Rp\        V RV4      ;'       g    Rp\        Wx4      p	\        V R	V4      p
V
e   \        V
4      MRp\        V R
V4      ;'       g    RP                  4       P                  4       pVR9  d   RpYiVe   \        V4      V3# RV3# )zUReturns (font_family or None, font_style_emphasis, font_size_pt or None, text_anchor)font-family,"rl   'N
font-stylefont-weight	font-sizetext-anchorstart)r'  middleend)
r  r   r9   replaceappendjoinr  r^   r  rT   )r   r   family_valuecleanedr   r:   familyr  r  emphasisr  size_pttas   &&           r3   _parse_font_attrsr3    s1    &c=)DL &&s+Dzz|++C4<<S"EHxx( , '.'"4 $CyAGGRJ$S-CIIrK*:CH 
Ci	8B nr$ 
 S-
;
F
Fw	M	M	O	U	U	WB	++w/BU7^bPPbPPr5   c                    V ^8  d   QhRRR\         \        \        \        3,          ,          R\         \        ,          R\
        \        \        \        \        3,          /# )r-   r   r%   r   	font_sizer/   )r   rq   r1   r   rT   r  )r2   s   "r3   r4   r4     sU     D D	DS#X'D D 5%%&	Dr5   c                ~   a aa R\         3R VVV 3R lllpV! RR4      pV! RR4      pV! RR4      pV! RR4      pWEWg3# )z0x,y (default 0,0) and optional dx,dy (default 0)r   c                l    V ^8  d   QhR\         R\        R\        \         .\        3,          R\        /# )r-   rg   defaultresolverr/   )r1   rT   r   )r2   s   "r3   r4   %_parse_xy_delta.<locals>.__annotate__  s;     6 666 C5%<(6 
	6r5   c                   < R pS
e   V S
9   d   S
V ,          pM$V SP                   9   d   SP                   V ,          pV'       g   V# \        P                  VP                  4       4      pV'       d   V^ ,          '       g   V# V^ ,          p\        P                  V4      pV'       d   VP                  R4      pVP                  R4      ;'       g    RP                  4       pVP                  4       R	9   d<   S	f%   \        P                  RVSP                  V 4       V#  \        V4      S	,          # VP                  4       R8X  dB   S	f$   \        P                  RSP                  V 4       V#  \        V4      S	,          R,          #  \        V! V4      4      #   \        \        3 d    Tu # i ; i  \        \        3 d    Tu # i ; i  \         d(    \        P                  RTSP                  T 4       Tu # i ; i)
Nr.   r]   rl   zCIgnoring relative %s length on <%s %s> because font size is unknownexzCIgnoring relative ex length on <%s %s> because font size is unknowng      ?z+Ignoring unsupported length '%s' on <%s %s>>   emrem)r   r   r   r9   rV   	fullmatchgroupr  LOGGERwarningr   rT   	TypeErrorrX   )rg   r8  r9  attrpartstokenrW   	value_strr]   r5  r   r   s   &&&      r3   first_number%_parse_xy_delta.<locals>.first_number  s   
  TY%6T?DSZZ::d#DN""4::<0E!HHNa''.G,IKK'--2446Dzz|},$NN]	 #N# +i77 zz|t#$NN]
 #N# +i7#==		%)) ":. #"N# ":. #"N#  	NN=	 N	s6   !F 0F4 
G F10F14G
	G
/G?>G?xydxdy)r^   )r   r   r5  rH  rJ  rK  rL  rM  s   fff     r3   _parse_xy_deltarN    sR     +96 6p 	S#AS#A	dC	 B	dC	 B<r5   c          	          V ^8  d   QhR\         R\        \        \         \        \         \        3,          3,          ,          /# )r-   css_textr/   )r1   listr  rq   r   )r2   s   "r3   r4   r4   4  s1       U3S#X;N5O0P r5   c                    . pV '       g   V# \         P                  R V 4      p\        P                  V4       EF  w  r4\        P
                  ! V4      pV'       g   K&  / pVP                  4        F  w  rx\        V4      p	V	f   K  WV&   K  	  V'       g   K`  VP                  R4       U
u. uF  qP                  4       NK  	  pp
V Fp  p
V
P                  R4      '       g   K  V
R,          P                  R^4      ^ ,          P                  4       pV'       g   KT  VP                  V\        V4      34       Kr  	  EK  	  V# u up
i )rl   r   .:   NN:)CSS_COMMENT_REr  CSS_BLOCK_REfindallr   r   r   r;   r   r9   r   r+  rq   )rP  stylesr.  selector_blockbodydeclarations
normalizedr   r.   r   selector	selectors
class_names   &            r3   _extract_css_class_stylesra  4  s   /1F  X.G , 4 4W =++D1
&,,.JC-e4J%",3 / 6D6J6J36OP6O(^^%6O	P!H&&s++!"++C3A6<<>JMM:tJ'789 " !>& M Qs   +Ec                      a  ] tR tRt o Rt]RV 3R lR ll4       t]RV 3R lR ll4       t]RV 3R lR ll4       t	]RV 3R	 lR
 ll4       t
]V 3R lR l4       t]V 3R lR l4       t]RV 3R lR ll4       tRtV tR# )ShapeBuilderiP  zNA namespace within which methods for converting basic shapes can be looked up.c                *   < V ^8  d   QhRRRS[ RS[/# r-   r   r%   clipping_pathr/   r   r   )r2   __classdict__s   "r3   r4   ShapeBuilder.__annotate__U  s"      i   r5   c                T    \        4       pV'       d   \        4       p\        W 4       V# )z.Create a new path with the appropriate styles.)r   r   r   )r   rf  paths   && r3   new_pathShapeBuilder.new_pathT  s"     }>DTr5   c                *   < V ^8  d   QhRRRS[ RS[/# re  rg  )r2   rh  s   "r3   r4   ri  ^  s"     1 1y 1 1+ 1r5   c                t   \        VP                  P                  RR4      4      p\        VP                  P                  RR4      4      pVP                  P                  R4      ;'       g    RpVP                  R4      '       d   \	        VRR 4      pM\        V4      pVP                  P                  R4      ;'       g    RpVP                  R4      '       d   \	        VRR 4      pM\        V4      pVP                  P                  R4      ;'       g    R	p	VP                  P                  R
4      ;'       g    R	p
V	R8X  d   Rp	V
R8X  d   Rp
Yu;8X  d   R	8X  d   M M^ ;rM>V	R	8X  d   \        V
4      ;rM*V
R	8X  d   \        V	4      ;rM\        V	4      p\        V
4      pV^ 8  g   V^ 8  g   V^ 8  g   V^ 8  d   \        RV 24      hV^ 8X  g   V^ 8X  d   \        4       # W^,          8  d
   V^,          pW^,          8  d
   V^,          pV P                  W4      pVP                  W4WhW4       V# )z&Convert an SVG <rect> into a PDF path.rJ  0rK  width%Nheightrxautoryr   z	bad rect )
r^   r   r   endswithr=   rT   rX   r   rl  	rectangle)clsr   rf  rJ  rK  	width_strrq  
height_strrs  rx_strry_strrt  rv  rk  s   &&&           r3   r{   ShapeBuilder.rect]  s    3::>>#s343::>>#s34JJNN7+22s	c""%,Ys^%<E"9-EZZ^^H-44
s##&-j"o&>F#J/F%//%//VFVF
 %v%KBvFm#BvFm#BvBvBAI6A:26rAvy.//QJFaK= B!!B||C/qUB3r5   c                *   < V ^8  d   QhRRRS[ RS[/# re  rg  )r2   rh  s   "r3   r4   ri    s"       4 K r5   c                   \        VP                  P                  R^ 4      4      p\        VP                  P                  R^ 4      4      p\        VP                  R,          4      pV P                  W4      pVP	                  W4V4       V# )z(Convert an SVG <circle> into a PDF path.cxcyr)rT   r   r   rl  r|   )rz  r   rf  r  r  r  rk  s   &&&    r3   r|   ShapeBuilder.circle  si     3::>>$*+3::>>$*+#**S/"||C/BAr5   c                *   < V ^8  d   QhRRRS[ RS[/# re  rg  )r2   rh  s   "r3   r4   ri    s"      ) D [ r5   c                0   \        VP                  P                  R^ 4      4      p\        VP                  P                  R^ 4      4      pVP                  P                  R4      ;'       g    RpVP                  P                  R4      ;'       g    RpV P                  W4      pYVu;8X  d   R8X  g   M VR8X  g   VR8X  d   V# VR8X  d   \        V4      ;rM*VR8X  d   \        V4      ;rM\        V4      p\        V4      p	VP	                  W4W4       V# )z)Convert an SVG <ellipse> into a PDF path.r  r  rt  ru  rv  rp  )rT   r   r   rl  r}   )
rz  r   rf  r  r  r}  r~  rk  rt  rv  s
   &&&       r3   r}   ShapeBuilder.ellipse  s     3::>>$*+3::>>$*+%//%//||C/&&FcMv}KVFm#BvFm#BvBvBRR$r5   c                $   < V ^8  d   QhRRRS[ /# r-   r   r%   r/   r   )r2   rh  s   "r3   r4   ri    s     
 
y 
[ 
r5   c                L   \        VP                  R,          4      p\        VP                  R,          4      p\        VP                  R,          4      p\        VP                  R,          4      pV P                  V4      pVP                  W#4       VP	                  WE4       V# )z&Convert an SVG <line> into a PDF path.x1y1x2y2)rT   r   rl  move_toline_to)rz  r   r  r  r  r  rk  s   &&     r3   r~   ShapeBuilder.line  s{     3::d#$3::d#$3::d#$3::d#$||C RRr5   c                $   < V ^8  d   QhRRRS[ /# r  r  )r2   rh  s   "r3   r4   ri    s      9  r5   c                r    V P                  V4      pRVP                  R,          ,           p\        W#4       V# )z*Convert an SVG <polyline> into a PDF path.Mpointsrl  r   svg_path_converter)rz  r   rk  r  s   &&  r3   r   ShapeBuilder.polyline  s2     ||C szz(++4(r5   c                *   < V ^8  d   QhRRRS[ RS[/# re  rg  )r2   rh  s   "r3   r4   ri    s"      ) D [ r5   c                    V P                  W4      pRVP                  R,          ,           R,           p\        W44       V# )z)Convert an SVG <polygon> into a PDF path.r  r  Zr  )rz  r   rf  rk  r  s   &&&  r3   r   ShapeBuilder.polygon  s7     ||C/szz(++c14(r5   r>   NF)r?   r@   rA   rB   rC   staticmethodrl  classmethodr{   r|   r}   r~   r   r   rD   __classdictcell__rh  s   @r3   rc  rc  P  s     X   1 1 1f      0 
 
     r5   rc  c                0    V ^8  d   QhR\         R\        /# )r-   r   r/   )r1   r   )r2   s   "r3   r4   r4     s     ` `c `i `r5   c           	     	   \         P                  V 4      p\        P                  ! 4       pV EF  w  r4VP	                  4       pVR8X  dm   \
        ;QJ d'    . R \        P                  V4       4       F  NK  	  5M ! R \        P                  V4       4       4      w  rVrxr\        WVWxW4      V,          pK  VR8X  d   \        P                  V4      vr\        V4      p\        P                  ! VR7      pV'       dV   \        V4      ^8X  d4   VP                  \        V^ ,          4      \        V^,          4      4      pM\        RV RV R24      hW,          pEK0  VR8X  d   \        P                  V4      p\        V4      ^8X  d&   \        V^ ,          4      p\        V^,          4      pM2\        V4      ^8X  d   \        V^ ,          4      ;rM\        R	V  24      h\        P                  ! WR
7      V,          pEK  VR8X  d,   \        P                  ! \        V4      ^R
7      V,          pEK  VR8X  d,   \        P                  ! ^\        V4      R
7      V,          pEK8  VR8X  d   \        P                  V4      p\        V4      ^8X  d&   \        V^ ,          4      p\        V^,          4      pM3\        V4      ^8X  d   \        V^ ,          4      p^ pM\        RV  24      h\        P                  ! \         P"                  ! V4      \         P"                  ! V4      R
7      V,          pEK  VR8X  d@   \        P                  ! \         P"                  ! \        V4      4      ^ R
7      V,          pEKL  VR8X  d@   \        P                  ! ^ \         P"                  ! \        V4      4      R
7      V,          pEK  VR8X  d   \        P                  V4      p\        V4      ^8X  d&   \%        V^ ,          4      p\%        V^,          4      pM3\        V4      ^8X  d   \%        V^ ,          4      p^ pM\        RV  24      h\        P&                  ! VVR
7      V,          pEK8  VR8X  d,   \        P&                  ! \%        V4      ^ R
7      V,          pEKj  VR8X  g   EKt  \        P&                  ! ^ \%        V4      R
7      V,          pEK  	  V# )z8Convert SVG/CSS transform functions into PDF transforms.matrixc              3   8   "   T F  p\        V4      x  K  	  R # 5ir7   r   ).0ns   & r3   	<genexpr>%convert_transforms.<locals>.<genexpr>  s     $P7O!U1XX7Os   rotate)thetazrotation transform (z) is malformedscalezbad scale transform rJ  rK  scaleXscaleYskewzbad skew transform skewXskewY	translatezbad translation transform 
translateX
translateY)TRANSFORM_GETTERrX  r   identityr9   r  r   r   rd   rotationlenaboutrT   rX   scalingshearingmathtanr^   translation)r   parsedr   tf_typeargsar  cdefr  r  r  sxsyrJ  rK  s   &                 r3   r   r     s    %%e,F""$Izz|h$u$P|7I7I$7O$Puu$P|7I7I$7O$PPA!!!a3i?I (..t4ME!%(E ))6H u:?'~~eE!HouU1XOH$-gYav^L  !,I%%d+D4yA~47^47^TaQ.(R #7w!?@@!))B5	AI !))E$K1=	II !))At=	II%%d+D4yA~"47+"47+Ta"47+ #6ug!>??!**TXXb\TXXb\JYVI""TXXmD.A%BaH9T  ""Q$((=3F*GH9T  #%%d+D4yA~"47+"47+Ta"47+ #=eW!EFF!--Q7)CI$!--t0DJYVI$!--^D5IJYVIg  j r5   c                4    V ^8  d   QhR\         R\        RR/# )r-   pdf_pathsvg_pathr/   N)r   r1   )r2   s   "r3   r4   r4   8  s!     ? ? ? ? ?r5   c                 l    \        V 4      p\        W4       VP                  '       g   \        R 4      hR# )z"Path does not start with move itemN)r   r	   first_is_moverX   )r  r  pens   && r3   r  r  7  s1    
(
Cx=>> r5   c                     a  ] tR tRt o Rt]RR/V 3R lR ll4       tR9V 3R lR	 llt]V 3R
 lR l4       t	V 3R lR lt
V 3R lR lt]]R:V 3R lR ll4       4       t]]V 3R lR l4       4       t]]V 3R lR l4       4       t]V 3R lR l4       t]V 3R lR l4       t]R9V 3R lR ll4       t]V 3R lR l4       t]V 3R lR l4       tR;V 3R  lR! lltR<V 3R" lR# lltR=V 3R$ lR% llt]V 3R& lR' l4       t]V 3R( lR) l4       t]R>V 3R* lR+ ll4       t]V 3R, lR- l4       t]V 3R. lR/ l4       t]V 3R0 lR1 l4       t]R9V 3R2 lR3 ll4       t]V 3R4 lR5 l4       t]R9V 3R6 lR7 ll4       t R8t!V t"R# )?	SVGObjecti?  zM
A representation of an SVG that has been converted to a PDF representation.
encodingzutf-8c          
      V   < V ^8  d   QhRS[ S[S[ ,          ,          RS[RS[ RS[RR/# )r-   filenamer  r  kwargsr/   r  )r1   r   r   )r2   rh  s   "r3   r4   SVGObject.__annotate__E  sF     8 8%8 8 	8
 8 
8r5   c                   \        VRVR7      ;_uu_ 4       pV ! VP                  4       .VO5/ VB uuRRR4       #   + '       g   i     R# ; i)a  
Create an `SVGObject` from the contents of the file at `filename`.

Args:
    filename (path-like): the path to a file containing SVG data.
    *args: forwarded directly to the SVGObject initializer. For subclass use.
    encoding (str): optional charset encoding to use when reading the file.
    **kwargs: forwarded directly to the SVGObject initializer. For subclass use.

Returns:
    A converted `SVGObject`.
r  )r  N)openread)rz  r  r  r  r  svgfiles   &&$*, r3   	from_fileSVGObject.from_fileD  s<    ( (C(33ww||~777 4333s	   <A	Nc                J   < V ^8  d   QhRS[ S[,          RS[S[,          RR/# )r-   svg_textimage_cacher/   N)r1   bytesr   r    )r2   rh  s   "r3   r4   r  [  s.     ( (e(2::2F(	(r5   c                :   W n         / V n        / V n        / V n        R V n        R V n        \        V4      pVP                  \        RR4      9  d   \        RVP                   24      hV P                  V4       V P                  V4       V P                  V4       R # )Nr)   zroot tag must be svg, not )r  cross_referencescss_class_stylesgradient_definitionsrq  rs  parse_xml_strr   rt   rX   _collect_css_stylesextract_shape_infoconvert_graphics)selfr  r  svg_trees   &&& r3   __init__SVGObject.__init__[  s     '02;= 	! 15
15+H5<<|E5999(,,HII  *)h'r5   c                :   < V ^8  d   QhRS[ S[,          RS[RR/# )r-   r   
referencedr/   N)r   r1   r   )r2   rh  s   "r3   r4   r  q  s&     4 4x} 4# 4$ 4r5   c                z    V'       d3   VP                  R 4      '       g
   R V,           MTpW P                  V&   R# R# )r   N)r   r  )r  r   r  s   &&&r3   update_xrefSVGObject.update_xrefp  s1    #&>>##6#6#)CC)3!!#& r5   c                "   < V ^8  d   QhRRRR/# r-   root_tagr%   r/   Nr>   )r2   rh  s   "r3   r4   r  v  s     2 2I 2$ 2r5   c                B   VP                  4        F  pVP                  \        R R4      9   g   K   RP                  VP	                  4       ;'       g    . 4      p\        V4       F2  w  rEV P                  P                  V/ 4      pVP                  V4       K4  	  K  	  R# )r)   r   rl   N)	iterr   rt   r,  itertextra  r  
setdefaultupdate)r  r  noderP  r`  r\  existings   &&     r3   r  SVGObject._collect_css_stylesv  sx    MMODxx<w77774==?#8#8b90I(0S,J#44??
BOHOOL1 1T $r5   c                :   < V ^8  d   QhRRRS[ S[S[3,          /# r  )rq   r1   r   )r2   rh  s   "r3   r4   r  ~  s#      ) S#X r5   c                   / pV P                   '       dq   VP                  P                  R 4      pV'       dN   VP                  4        F9  pV P                   P                  V4      pV'       g   K(  VP	                  V4       K;  	  \
        P                  ! VP                  P                  RR4      4      pVP                  4        F4  w  rx\        V4      p	V	e   WV&   K  Wr9   g   K"  VP                  VR4       K6  	  Rp
V
 FP  pWP                  9   g   K  \        VP                  P                  V4      4      p	V	f   K?  VP                  W4       KR  	  V# )classr   rl   N)r  r%  r#  r$  r&  r   )r  r   r   r   r  r   r   r   r;   popr  )r  r   r   
class_attrr`  class_stylesr  r   r.   r   inheritable_attrsrD  s   &&          r3   _style_map_forSVGObject._style_map_for~  s   $&	   0J","2"2"4J#'#8#8#<#<Z#HL#|!((6 #5 %%cjjnnWb&AB ,,.JC-e4J%!+#!c4( )
 &Dzz!1#**..2FG
)((:	 &
 r5   c                ,   < V ^8  d   QhRS[ RS[ RS[/# )r-   r.   r8  r/   rS   )r2   rh  s   "r3   r4   r    s"      C #  r5   c                8   V e   V R8X  d   Tp V P                  4       p V P                  R4      '       d   \        V RR 4      R,          #  \        V 4      #   \         d9     \	        T 4      u #   \         d    \
        P                  RT 4         R# i ; ii ; i)z@Convert SVG gradient coordinate (percentage or number) to float.Nrl   rr        Y@z1Could not parse gradient coordinate '%s', using 0r   rw  )r9   rx  rT   rX   r^   rA  rB  )r.   r8  s   &&r3   _convert_gradient_coordinate&SVGObject._convert_gradient_coordinate  s     =ERKE>>#s$u,,		< 	%e,, G 		s0   
A B"
A/,B/!BBBBc                Z   < V ^8  d   QhRRRS[ S[S[S[S[,          3,          ,          /# )r-   gradient_elementr%   r/   )rQ  r  rT   r   r   )r2   rh  s   "r3   r4   r    s5     A A#A	eE9z112	3Ar5   c                0   . pV  EF  p\        VP                  4      pVR8w  d   K"  VP                  P                  R4      pVf   \        P                  R4       KX  VP                  4       pVP                  R4      '       d   \        VRR 4      R,          pM\        V4      p\        R\        RV4      4      pRpRpVP                  P                  R	R
4      pV'       dM   \        P                  ! V4      p	V	P                  R4      pV	P                  R4      p
V
'       d    \        V
4      pVf   VP                  P                  RR4      pRVP                  9   d0    \        VP                  P                  R4      ;'       g    R4      p \        V4      pVR8  do   \        V\         4      '       d-   \!        VP"                  VP$                  VP&                  V4      p\        V\(        4      '       d   \)        VP$                  V4      pVP+                  W[34       EK   	  V#   \         d    \        P                  RT
4        ELi ; i  \         d     Li ; i  \        \,        3 d#   p\        P                  RYl4        Rp?EK  Rp?ii ; i)z,Parse <stop> children of a gradient element.stopoffsetNz%Found <stop> without offset, skippingrr  r  r   r   r   rl   z
stop-colorzstop-opacityzInvalid stop-opacity value: %sblack1z#Could not parse stop color '%s': %srw  )rz   r   r   r   rA  rB  r9   rx  rT   maxminr   r   rX   r   r8   r   r  gr  r   r+  r[   )r  stopsstop_elementtag_name
offset_strr  
stop_colorstop_opacityr   
style_dictstop_opacity_str	color_objr  s   &            r3   _parse_gradient_stopsSVGObject._parse_gradient_stops  s?    =?,L!,"2"23H6!%,,00:J!FG#))+J""3''z#2/%7z*c#v./FJL ''++GR8E!11%8
'^^L9
#->>.#A #',-='> !)0044\7K
!4!44#()<)<)@)@)P)W)WTW#XL$Z0	#%!)Y77$-%KKikk<%	 ")Z88$.y{{L$I	f01k -v = & <>N "  ) DjTsC   $H)!&IIBI")!IIII"J3JJc                F   < V ^8  d   QhRS[ S[,          RS[ S[,          /# )r-   	url_valuer/   r0   )r2   rh  s   "r3   r4   r    s#       (3- r5   c                    V '       d   \        V \        4      '       g   R# \        P                  ! RV 4      pV'       d   RVP	                  ^4      ,           # R# )z)Extract gradient ID from url(#id) format.Nzurl\(\s*["\']?\s*#([^)"\'\s]+)r   )r8   r1   r  searchr@  )r$  rW   s   & r3   _extract_gradient_idSVGObject._extract_gradient_id  s@     
9c : :		;YGQ''r5   c                "   < V ^8  d   QhRRRR/# r-   grad_elementr%   r/   Nr>   )r2   rh  s   "r3   r4   r    s#     AW AW9 AW AWr5   c           	        VP                   P                  R4      pV'       g   \        P                  R4       R# VP	                  R4      '       g
   RV,           pVP                   P                  RR4      pVP                   P                  RR4      pVP                   P                  RR	4      pVP                   P                  R
R4      pV P                  VR4      pV P                  VR4      pV P                  VR4      p	V P                  VR4      p
VP                   P                  RR4      pVR8X  d   \        P                  pM\        P                  pVP                   P                  RR4      p \        P                  ! V4      pRpVP                   P                  R4      pV'       d    \        V4      pV P!                  V4      pV'       g   \        P                  RV4       R# \#        VVV	V
VVR7      p\%        TTT;'       g    \&        P(                  ! 4       VR7      pVV P*                  V&   \        P-                  RV\/        V4      4       R#   \        \        3 d+    \        P                  p\        P                  RT4        EL
i ; i  \        \        \        3 d"   p\        P                  RT4        Rp?ELRp?ii ; i)zFParse a <linearGradient> element and store it in gradient_definitions.idz5Found <linearGradient> without id attribute, skippingNr   r  0%r  r  z100%r  rp  r  gradientUnitsobjectBoundingBoxuserSpaceOnUsespreadMethodpadz$Invalid spreadMethod '%s', using PADgradientTransform%Could not parse gradientTransform: %sz1Linear gradient '%s' has no valid stops, skipping)r  r  r  r  r  spread_methodgradientunitsgradient_transformr6  z)Parsed linear gradient '%s' with %d stops)r   r   rA  rB  r   r  r   USER_SPACE_ON_USEOBJECT_BOUNDING_BOXr
   coercerX   AttributeErrorPADr   rC  r!  r#   r   r   r  r  debugr  )r  r+  grad_idr  r  r  r  x1_valy1_valx2_valy2_val	units_strr9  
spread_strr6  r   transform_strr  r  r8  gradient_paints   &&                   r3   _parse_linear_gradient SVGObject._parse_linear_gradient  sy    ".!4!4!8!8!>NNRS!!#&&GmG  $$T40  $$T40  $$T62  $$T40222s;222s;222s;222s; ''++O=PQ	((!33E!55E!((,,^UC
	O077
CM
 	$++//0CDK.}=	 **<8NNNPWX('
 '(@@I,>,>,@'	
 .<!!'*@'3u:VI N+ 	O044MNNA:N	O 	: KFJJKs*   4I 0J 7JJK.K

Kc                "   < V ^8  d   QhRRRR/# r*  r>   )r2   rh  s   "r3   r4   r  I  s#     KW KW9 KW KWr5   c                   VP                   P                  R4      pV'       g   \        P                  R4       R# VP	                  R4      '       g
   RV,           pVP                   P                  RR4      pVP                   P                  RR4      pVP                   P                  RR4      pVP                   P                  R	V4      pVP                   P                  R
V4      pVP                   P                  RR4      pV P                  VR4      p	V P                  VR4      p
V P                  VR4      pV P                  V\        V	4      4      pV P                  V\        V
4      4      pV P                  VR4      pV^ 8:  d   \        P                  RW+4       R# VP                   P                  RR4      pVR8X  d   \        P                  M\        P                  pVP                   P                  RR4      p \        P                  ! V4      pRpVP                   P                  R4      pV'       d    \        V4      pV P#                  V4      pV'       g   \        P                  RV4       R# \%        V	V
VVVVVVR7      p\'        TTT;'       g    \(        P*                  ! 4       VR7      pVV P,                  V&   \        P/                  RV\1        V4      4       R#   \        \        3 d    \        P                  p Li ; i  \        \        \         3 d!   p\        P                  RT4        Rp?LRp?ii ; i)zFParse a <radialGradient> element and store it in gradient_definitions.r-  z5Found <radialGradient> without id attribute, skippingNr   r  z50%r  r  fxfyfrr.  z0.5rp  z4Radial gradient '%s' has invalid radius %s, skippingr/  r0  r1  r2  r3  r4  r5  z1Radial gradient '%s' has no valid stops, skipping)r  r  r  r  rN  rO  rP  r6  r7  z)Parsed radial gradient '%s' with %d stops)r   r   rA  rB  r   r  r1   r   r;  r<  r
   r=  rX   r>  r?  r   rC  r!  r$   r   r   r  r  r@  r  )r  r+  rA  r  r  r  rN  rO  rP  cx_valcy_valr_valfx_valfy_valfr_valrF  r9  rG  r6  r   rH  r  r  r8  rI  s   &&                       r3   _parse_radial_gradient SVGObject._parse_radial_gradientH  s    %%))$/NNRS!!#&&GmG  $$T51  $$T51##C/  $$T2.  $$T2.  $$T40222u=222u=11!U;222s6{C222s6{C222s;A:NNF  ''++O=PQ	 ,, ++22 	 "((,,^UC
	5077
CM 	$++//0CDK.}=	 **<8NNNPWX('	
 '(@@I,>,>,@'	
 .<!!'*@'3u:VG N+ 	5044M	5 	: KFJJKs*    K( <L (!LLM%M  Mc          	      T   < V ^8  d   QhRS[ RRRS[S[S[S[3,          ,          RR/# r-   r   r   r%   r   r/   Nr   r   rq   r1   r   )r2   rh  s   "r3   r4   r    sF     G GG G DcN+	G
 
Gr5   c                   \        VRV4      pV'       db   V P                  V4      pV'       dI   WPP                  9   d9   V P                  V,          VP                  n        \
        P                  RV4       \        VRV4      pV'       dh   V P                  V4      pV'       dM   WPP                  9   d;   V P                  V,          VP                  n        \
        P                  RV4       R# R# R# R# )zPApply gradient paint to fill or stroke if a url(#gradientId) reference is found.r   zApplied gradient %s to fillr   zApplied gradient %s to strokeN)r  r'  r  r   r   rA  r@  r   )r  r   r   r   
fill_valuerA  stroke_values   &&&&   r3   _apply_gradient_paintSVGObject._apply_gradient_paint  s     (VYG
//
;G7&?&??,0,E,Eg,N):GD)+xK//=G7&?&??.2.G.G.P+<gF @w r5   c                "   < V ^8  d   QhRRRR/# r  r>   )r2   rh  s   "r3   r4   r    s     %, %,9 %, %,r5   c                   VP                  R4      pVP                  R4      pVP                  R4      pVP                  RR4      pVR8X  d	   RV n        MRV n        RV n        VeL   VP                  4        VP	                  R4      '       d   \        VRR
 4      V n        M\        V4      V n        RV n        VeL   VP                  4        VP	                  R4      '       d   \        VRR
 4      V n        M\        V4      V n        Vf
   RV n        R# VP                  4       p\        P                  V4       Uu. uF  p\        V4      NK  	  upw  rxrV	^ 8  g   V
^ 8  d   \        R	V 24      hWxW.V n        R# u upi )z&Collect shape info from the given SVG.rq  rs  viewBoxpreserveAspectRatioTr   Nrr  z)invalid negative width/height in viewbox rw  )r   preserve_arrq  r9   rx  r=   r^   rs  viewboxr   r   rT   rX   )r  r  r{  r|  rf  re  numvxvyvwvhs   &&         r3   r  SVGObject.extract_shape_info  sW    LL)	\\(+
,,y)ll#8$?& #D#D
 OO!!#&&$Ys^4
+I6
!""3''%j"o6,Z8?DLmmoG4@4F4Fw4OP4OSeCj4OPNBBQBF #LWI!VWWB+DL	 Qs   <E=c                "   < V ^8  d   QhRRRR/# r  r>   )r2   rh  s   "r3   r4   r    s     	% 	% 	%t 	%r5   c                    \        4       pRVP                  n        RVP                  n        \        P
                  VP                  n        V P                  W4       W n        R# )zFConvert the graphics contained in the SVG into the PDF representation.NF)	r   r   r   r   r   BUTTr   build_group
base_group)r  r  rq  s   && r3   r  SVGObject.convert_graphics  sO     %&
(,
%&+
#,:,?,?
).$r5   c          	      D   < V ^8  d   QhRRRS[ RS[S[S[S[3,          /# )r-   pdfr'   align_viewboxr/   )r   r  rT   r   )r2   rh  s   "r3   r4   r    s6     W WW*.W	ue_,	-Wr5   c                f    V P                  VP                  VP                  VP                  V4      # )a  
Size the converted SVG paths to the page viewport.

The SVG document size can be specified relative to the rendering viewport
(e.g. width=50%). If the converted SVG sizes are relative units, then this
computes the appropriate scale transform to size the SVG to the correct
dimensions for a page in the current PDF document.

If the SVG document size is specified in absolute units, then it is not scaled.

Args:
    pdf (fpdf.fpdf.FPDF): the pdf to use the page size of.
    align_viewbox (bool): if True, mimic some of the SVG alignment rules if the
        viewbox aspect ratio does not match that of the viewport.

Returns:
    The same thing as `SVGObject.transform_to_rect_viewport`.
)transform_to_rect_viewportkepweph)r  rt  ru  s   &&&r3   transform_to_page_viewport$SVGObject.transform_to_page_viewport  s'    , ..suucggswwVVr5   c                x   < V ^8  d   QhRS[ RS[ S[,          RS[ S[,          RS[RS[RS[S[ S[ S[3,          /# )r-   r  rq  rs  ru  ignore_svg_top_attrsr/   )rT   r=   r   r  r   )r2   rh  s   "r3   r4   r    sk     `D `D`D w`D 	`D
 `D #`D 
ue_,	-`Dr5   c                ^   V'       d/   \        V\        4      '       d   \        V4      pMp\        V4      pMd\        V P                  \        4      '       d/   V'       g   \	        R4      hV P                  V,          ^d,          pMV P                  ;'       g    TpV'       d/   \        V\        4      '       d   \        V4      pMp\        V4      pMd\        V P
                  \        4      '       d/   V'       g   \	        R4      hV P
                  V,          ^d,          pMV P
                  ;'       g    TpV^8X  d   \        P                  ! 4       pM\        P                  ! ^V,          4      pV P                  '       Ed   V P                  w  rrV^ 8X  g   V^ 8X  d   ^ ^ \        4       3# Wk,          pW|,          pV'       g%   V P                  '       d   W8w  d   \        W4      ;rV\        P                  ! V	) V
) R7      ,          \        P                  ! WR7      ,          pV'       dX   V\        P                  ! V^,          V^,          V,          ,
          V^,          V^,          V,          ,
          R7      ,          pWP                  n        Wa,          Wq,          V P                  3# )a  
Size the converted SVG paths to an arbitrarily sized viewport.

The SVG document size can be specified relative to the rendering viewport
(e.g. width=50%). If the converted SVG sizes are relative units, then this
computes the appropriate scale transform to size the SVG to the correct
dimensions for a page in the current PDF document.

Args:
    scale (Number): the scale factor from document units to PDF points.
    width (Number): the width of the viewport to scale to in document units.
    height (Number): the height of the viewport to scale to in document units.
    align_viewbox (bool): if True, mimic some of the SVG alignment rules if the
        viewbox aspect ratio does not match that of the viewport.
    ignore_svg_top_attrs (bool): ignore <svg> top attributes like "width", "height"
        or "preserveAspectRatio" when figuring the image dimensions.
        Require width & height to be provided as parameters.

Returns:
    A tuple of (width, height, `fpdf.drawing.GraphicsContext`), where width and
    height are the resolved width and height (they may be 0. If 0, the returned
    `fpdf.drawing.GraphicsContext` will be empty). The
    `fpdf.drawing.GraphicsContext` contains all of the paths that were
    converted from the SVG, scaled to the given viewport size.
z?SVG "width" is a percentage, hence a viewport width is requiredzASVG "height" is a percentage, hence a viewport height is requiredr  )r8   r=   rT   rq  rX   rs  r   r  r  rf  r   re  r  r  rq  r   )r  r  rq  rs  ru  r~  vp_width	vp_heightr   rh  ri  rj  rk  w_ratioh_ratios   &&&&&&         r3   rw  $SVGObject.transform_to_rect_viewport  s   H  %)) < <

G,, U  zzE)C/Hzz**UH&'**!&M	!&M	W-- W  f,s2I--vIA:!**,I!))!e)4I<<<!\\NBBaR1W!_...mGnG'D,<,<,<'BT$'$99 ''2#"56##g9:  %	(=(=lb1f%77!mrAv&88) 	
 %.!!2DOOCCr5   c          
      d   < V ^8  d   QhRRRS[ S[,          RS[ S[,          RS[ S[,          RR/# )r-   rt  r'   rJ  rK  debug_streamr/   N)r   rT   r   )r2   rh  s   "r3   r4   r  Z  sI      %  % % E? % E?	 %
 tn % 
 %r5   c                   VP                   V n         V P                  V4      w   rVVP                  VP                  r VeS   VeO   VP	                  ^ ^ 4       VP
                  f   Q hVP
                  \        P                  ! W#4      ,          Vn        VP                  Wd4       VP	                  Wx4       R#   TP	                  Yx4       i ; i)a  
Directly draw the converted SVG to the given PDF's current page.

The page viewport is used for sizing the SVG.

Args:
    pdf (fpdf.fpdf.FPDF): the document to which the converted SVG is rendered.
    x (Number): abscissa of the converted SVG's top-left corner.
    y (Number): ordinate of the converted SVG's top-left corner.
    debug_stream (io.TextIO): *DEPRECATED* the stream to which rendering debug info will be
        written.
N)	r  r{  rJ  rK  set_xyr   r   r  	draw_path)	r  rt  rJ  rK  r  _rk  old_xold_ys	   &&&&&    r3   draw_to_pageSVGObject.draw_to_pageZ  s    & ??44S9
1uuceeu		%}

1a ~~111!%)2G2G2M!MMM$- JJu$CJJu$s   A'B8 8Cc                "   < V ^8  d   QhRRRR/# )r-   defsr%   r/   Nr>   )r2   rh  s   "r3   r4   r    s     $ $	 $d $r5   c                   V EF  pVP                   \        RR4      9   d   V P                  V4       K2  VP                   \        RR4      9   d)   \        P	                  R4       V P                  V4       Ku  VP                   \        RR4      9   d   V P                  V4       K  VP                   \        RR4      9   d   V P                  V4       K  VP                   \        9   d   V P                  V4       K  VP                   \        RR4      9   d   V P                  V4       EK(  VP                   \        RR4      9   d   V P                  V4       EKW  VP                   \        RR	4      9   d2    VP                  R
,          pV F  pV P                  WC4       K  	  EK  VP                   \        RR4      9   d   EK  \        P	                  R\        VP                   4      4       EK  	  R#   \         d    Rp Lzi ; i)z:Produce lookups for groups and paths inside the <defs> tagr)   r  r  SIgnoring unsupported SVG tag: <a> (contributions are welcome to add support for it)rk  imagelinearGradientradialGradientclipPathr-  Nr   TIgnoring unsupported SVG tag: <%s> (contributions are welcome to add support for it))r   rt   rp  rA  rB  
build_pathbuild_image
shape_tagsbuild_shaperJ  rW  r   r[   build_clipping_pathrz   )r  r  childclip_idchild_s   &&   r3   handle_defsSVGObject.handle_defs~  s    EyyL44  'l5#66 i   'l5&99&l5'::  'j(  'l52BCC++E2l52BCC++E2l5*==##ll40G $F,,V= $l5'::juyy)? .   #"G#s   6G44HHc                $   < V ^8  d   QhRRRS[ /# )r-   xrefr%   r/   )r   )r2   rh  s   "r3   r4   r    s      y _ r5   c                |   V P                  V4      p\        4       p\        W1V4       \        RRR4       F  p VP                  V,          p M	  \        RV R24      h VP                  V P                  V,          4       RTP                  9   g   R	TP                  9   df   \        TP                  P                  R^ 4      4      \        TP                  P                  R	^ 4      4      rv\        P                  ! YgR
7      Tn        T#   \
         d     K  i ; i  \
         d    \        RT RT 24      Rhi ; i)z?Resolve a cross-reference to an already-seen SVG element by ID.r*   hrefr-  zuse z% doesn't contain known xref attributez references nonexistent ref id NrJ  rK  r  )r  r   r   rt   r   r[   rX   add_itemr  rT   r   r   r  r   )r  r  r   	pdf_group	candidaterefrJ  rK  s   &&      r3   
build_xrefSVGObject.build_xref  s.    ''-	#%	Yi0%gvt<Ikk), = tD6)NOPP	t44S9: $++!3 a015a9P3Qq"+"7"7!"AI '    	tf;C5A	s   D "D DDD;c          	      f   < V ^8  d   QhRRRS[ S[,          RS[ S[S[S[3,          ,          RS[/# )r-   r@  r%   r  inherited_styler/   )r   r   rq   r1   r   )r2   rh  s   "r3   r4   r    sE     7 77 O,7 "$sCx.1	7
 
7r5   c                @   V P                  V4      p\        T;'       g    / 4      pVP                  V4       Vf   \        4       p\	        W!V4       V Uu. uF!  qfP
                  \        RR4      9   g   K  VNK#  	  up F  pV P                  V4       K  	  V EFO  pVP
                  \        RR4      9   d   V P                  V4       K2  VP
                  \        RR4      9   d   KO  VP
                  \        RR4      9   d&   VP                  V P                  VRV4      R4       K  VP
                  \        RR4      9   d;   \        P                  R4       VP                  V P                  VRV4      R4       K  VP
                  \        RR	4      9   d%   VP                  V P                  V4      R4       EK#  VP
                  \        9   d%   VP                  V P                  V4      R4       EK\  VP
                  \        RR
4      9   d%   VP                  V P                  V4      R4       EK  VP
                  \        RR4      9   d%   VP                  V P!                  V4      R4       EK  VP
                  \        RR4      9   d2   V P#                  We4      pV'       d   VP                  VR4       EK#  EK&  \        P                  R\%        VP
                  4      4       EKR  	  V P'                  VP(                  P+                  R4      V4       V# u upi )z+Handle nested items within a group <g> tag.Nr)   r  r   r  Fr  r  rk  user  textr  r-  )r  rq   r  r   r   r   rt   r  r  rp  rA  rB  r  r  r  r  r  
build_textrz   r  r   r   )r  r@  r  r  local_stylemerged_styler  	text_paths   &&&&    r3   rp  SVGObject.build_group  s{    ))%0O11r2K(')IY|4  %
$e		\%5P(PEEu
E U#

 EyyL77  'l5'::l5#66""4#3#3E4#NPUVl5#66 i ""4#3#3E4#NPUVl5&99""4??5#95Aj(""4#3#3E#:EBl5%88""4??5#95Al5'::""4#3#3E#:EBl5&99 OOE@	&&y%8  juyy)9 B 	))$/;Q
s   L7Lc                $   < V ^8  d   QhRRRS[ /# )r-   rk  r%   r/   r  )r2   rh  s   "r3   r4   r    s      y [ r5   c                F   V P                  V4      p\        4       p\        W1V4       V P                  W1V4       V P	                  W1V4       VP
                  P                  R4      pVe   \        W44       V P                  VP
                  P                  R4      V4       V# )z1Convert an SVG <path> tag into a PDF path object.r  r-  )	r  r   r   r_  apply_clipping_pathr   r   r  r  )r  rk  r   r  r  s   &&   r3   r  SVGObject.build_path  s     ''-	=XY/""89=  ;;;??3'x2.9r5   c                $   < V ^8  d   QhRRRS[ /# )r-   shaper%   r/   r  )r2   rh  s   "r3   r4   r    s     
 
 
{ 
r5   c                h   V P                  V4      p\        \        \        VP                  ,          4      pV! V4      p\        V\        4      '       g   Q h\        WAV4       V P                  WAV4       V P                  WAV4       V P                  VP                  P                  R4      V4       V# )zConvert an SVG shape tag into a PDF path object. Necessary to make xref (because ShapeBuilder doesn't have access to this object.)r-  )r  getattrrc  r  r   r8   r   r   r_  r  r  r   r   )r  r  r   shape_builder
shape_paths   &&   r3   r  SVGObject.build_shape  s     ''.	j.CD"5)
*k2222Z	2"":i@  I>))$/<r5   c                8   < V ^8  d   QhRRRS[ S[,          RR/# )r-   r  r%   r  r/   Nr0   )r2   rh  s   "r3   r4   r    s&     7 7 7Xc] 7t 7r5   c                D   VP                   \        9   dM   V P                  V4      p\        \        \        VP                   ,          4      pV! VR 4      p\        WQV4       MVP                   \        RR4      9   dh   V P                  V4      p\        4       p\        WQV4       \        P                  Vn
        VP                  P                  R4      pVe   \        WV4       M+\        P                  R\!        VP                   4      4       R# V P#                  W%4       R# )Tr)   rk  r  NzaIgnoring unsupported <clipPath> child tag: <%s> (contributions are welcome to add support for it))r   r  r  r  rc  r   rt   r   r   
DONT_PAINT
paint_ruler   r   r  rA  rB  rz   r  )r  r  r  r   r  clipping_path_shaper  s   &&&    r3   r  SVGObject.build_clipping_path  s    99
"++E2I#L*UYY2GHM"/t"<,Y?YY,uf55++E2I"--,Y?-:-E-E*||'',H#"#6ANNs599% 6r5   c          	      T   < V ^8  d   QhRS[ RRRS[S[S[S[3,          ,          RR/# rZ  r[  )r2   rh  s   "r3   r4   r  4  sF     P PP P DcN+	P
 
Pr5   c                   R pV'       d   RV9   d
   VR,          pVf   VP                   P                  R4      pV'       d?   \        P                  ! RV4      pVf   Q hV P                  V^,          ,          Vn        R # R # )Nz	clip-pathzurl\((\#\w+)\))r   r   r  r&  r  rf  )r  r   r   r   
clip_valueclipping_path_ids   &&&&  r3   r  SVGObject.apply_clipping_path3  sx     
	1";/J$++//<J!yy):JG#///%)%:%:;KA;N%OH" r5   c                "   < V ^8  d   QhRRRR/# )r-   r  r%   r/   SVGImager>   )r2   rh  s   "r3   r4   r  E  s          z  r5   c           
        R p\        RR4       F(  pW1P                  9   g   K  VP                  V,          p M	  V'       g   \        R4      h\        VP                  P	                  R^ 4      4      p\        VP                  P	                  R^ 4      4      pRVP                  9   d   \
        P                  R4       RVP                  9   d   \
        P                  R	4       R
VP                  9   d   \
        P                  R4       \        V\        VP                  P	                  RR4      4      \        VP                  P	                  RR4      4      VVV R7      pV P                  VP                  P	                  R4      V4       V# )Nr*   r  z#<image> is missing a href attributerq  rs  rd  zu"preserveAspectRatio" defined on <image> is currently not supported (contributions are welcome to add support for it)r   zg"style" defined on <image> is currently not supported (contributions are welcome to add support for it)r   zk"transform" defined on <image> is currently not supported (contributions are welcome to add support for it)rJ  rp  rK  r  rJ  rK  rq  rs  svg_objr-  )	rt   r   rX   rT   r   rA  rB  r  r  )r  r  r  r   rq  rs  	svg_images   &&     r3   r  SVGObject.build_imageD  sC   0Cll"||C( 1 BCCell&&w23u||''!45 ELL0NN H ell"NNy %,,&NN} ELL$$S#./ELL$$S#./
	 	))$/;r5   c                `   < V ^8  d   QhRRRS[ S[S[S[3,          ,          RS[ S[,          /# )r-   text_tagr%   r  r/   )r   rq   r1   r   r   )r2   rh  s   "r3   r4   r  h  s<     A A!A4<T#s(^4LA	+	Ar5   c                  a"a#a$a%a&a'a( V P                  V4      p\        T;'       g    / 4      pVP                  V4       \        4       p\	        WQV4       V P                  WQV4       \        WA4      p\        W4      w  o$o#rxS$f   Ro$Ve   TM
\        R4      o%\        WS%R7      w  rrW,           pW,           p. o(Ro&Ro'R R lo"RR V"V#V$V%V&V'V(3R	 lllpT! VP                  ;'       g    R
S$S#VVRRR7       V EFd  pVP                  \        RR4      9   EdE   V P                  V4      p\        V4      pVP                  V4       \        VV4      w  ppppVe   TMS%p\        VVVR7      w  pppp\        VV4      pR
P                  VP                  4       4      pVP                  ;'       g    R
pV'       d(   VP!                  V4      '       d   VR\#        V4      )  pMTpRp Rp!RVP$                  9   g   Ve
   RV9   d   Tp RVP$                  9   g   Ve
   RV9   d   Tp!V! VVVVVVVV V!VVR7       T! VP                  ;'       g    R
S$S#VVRRR7       EKd  EKg  	  S('       d*   VP'                  \)        VV\+        S(4      VR7      RR7       V P-                  VP$                  P/                  R4      V4       V# )z
Convert <text> (and simple <tspan>) into a PaintedPath with Text runs.
- Uses Text baseline at (x,y)
- Honors x/y and dx/dy on <text> and direct child <tspan>
- Flattens nested tspans; advanced per-character positioning is not implemented
N
sans-serif16px)r5  r   c                    V ^8  d   QhR\         R,          R\         \        \        \        3,          ,          R\         \        ,          /# )r-   r   r%   style_map_for_tagr/   )r   rq   r1   r   r   )r2   s   "r3   r4   *SVGObject.build_text.<locals>.__annotate__  s;     	+ 	+)$	+9A$sCx.9Q	+m$	+r5   c                 l  a V e   Vf   R # \        4       o\        SW4       \        P                  SP                  n        \        ;QJ d-    V3R l\        P                   4       F  '       g   K   RM"	  RM! V3R l\        P                   4       4      pV'       g   R # \        SP                  4      # )Nc              3   p   <"   T F+  p\        SP                  V4      \        P                  Jx  K-  	  R # 5ir7   )r  r   r   r   )r  propcontexts   & r3   r  ?SVGObject.build_text.<locals>._style_for_run.<locals>.<genexpr>  s.      :D t,M4I4II:s   36TF)	r   r   r   r   r   r   anyMERGE_PROPERTIESr   )r   r  	overridesr  s   && @r3   _style_for_run,SVGObject.build_text.<locals>._style_for_run  s     {/7%'G#9'4'<'<GMM$ ):: ):: I GMM**r5   c                T   V ^8  d   QhR\         R\        \         ,          R\        \         ,          R\        \        ,          R\        R\        R\        R\        \        ,          R	\        \        ,          R
\        R,          R\        \        \         \
        3,          ,          RR/# )r-   raw_textr/  r0  sizer   dx_extrady_extraabs_xabs_y	style_tagr%   r  r/   N)r1   r   rT   r   rq   r   )r2   s   "r3   r4   r    s     9	 9	9	SM9	 sm9	 5/	9	
 9	 9	 9	 E?9	 E?9	  	*9	  (S#X79	 9	r5   c                   < T ;'       g    R p\        WR7      pV'       d   TpMVP                  4       pV'       dL   TpVR,          P                  4       '       d
   RV,           pVRR P                  4       '       d
   VR,           pMCVR,          P                  4       '       g   VRR P                  4       '       d   S'       d   RpMR pV'       g   SV,          oSV,          oR# Ve   TMSpT;'       g    S;'       g    RpVe   TMS;'       g    R pSV,           pSV,           pRoRoS! W4      pSP                  \	        VVVVVVVVVR7	      4       R# )	rl   )r   :NrT  Nr  Nr  r   )	r  r/  r0  r  rL  rM  r  r  	run_stylerw  )r  r9   isspacer+  r   )r  r/  r0  r  r   r  r  r  r  r  r  raw	collapsedcontenttrimmedrun_size
run_familyrun_emphasisrun_dxrun_dyr  r  	base_emphbase_familydefault_font_size
pending_dx
pending_dy	text_runss   &&&&&&&&&&&          r3   _add_run&SVGObject.build_text.<locals>._add_run  sJ    ..bC$S<I##//+%G2w(("%-23x''))")C-B))SX-=-=-?-?Y"%"$h&
h&
#/t5FH>>;>>,J(0(<H)RRPRL(*F(*FJJ&yDI %)!'
r5   rl   )r   r  r  r)   tspanrJ  rK  )r   r  r  r  r  r  r  )rJ  rK  r  text_anchorF)cloner-  )r   r   NNNN)r  rq   r  r   r   r  r   r3  r^   rN  r  r   rt   r,  r  tailrx  r  r   add_path_elementr   r  r  r   ))r  r  r  r  effective_stylerk  preserve_parent	base_sizebase_anchorbase_xbase_ybase_dxbase_dyanchor_xanchor_yr  r  child_local_stylechild_effective_stylefamemphr  _anchorrun_font_sizerJ  rK  rL  rM  child_preserveraw_itertext	tail_textrun_textr  r  r  r  r  r  r  r  r  s)   &&&                               @@@@@@@r3   r  SVGObject.build_textg  s    ))(344"5{+}T[1  A&A9J:
6Y	 &K".IN64J 	 ,;1B,
( ###%	

	+ 9	 9	 9	x 	MMR$"	
 EyyL88$($7$7$>!(,_(=%%,,->?+<0,(T4 )-(8>O.0M 1b" "..CU!K!wwu~~'78!JJ,,"	!6!6y!A!A+,=s9~o>H+H%,,&%1c=N6NE%,,&%1c=N6NE+#&7 JJ$$","&*  s v !!#I. +	  "  	,,T2D9r5   )	rq  r  r  r  rs  r  re  rf  rq  r7   )rp  )T)TF)NNNNN)#r?   r@   rA   rB   rC   r  r  r  r   r  r  r  r  r  r!  r'  rJ  rW  r_  r  r  r{  rw  r  r  r  rp  r  r  r  r  r  r  rD   r  r  s   @r3   r  r  ?  s$     8  	8 8 8,( (* 4 4
2 2 >    * A  AF    AW AWF KW KWZ G G G* %, %,N 	% 	%W W0`D `DD %  %H $ $P  > 7 7 7r   
 
 7 7, P P P     D A A Ar5   r  c                      a  ] tR tRt o V 3R lR lt]V 3R lR l4       t]V 3R lR l4       tV 3R lR	 lt	V 3R
 lt
RtV tR# )r  i,  c                >   < V ^8  d   QhRRRS[ S[S[3,          RR/# )r-   r  r  _memor/   )rq   r  r   )r2   rh  s   "r3   r4   SVGImage.__annotate__4  s*     	
 	
: 	
d38n 	
 	
r5   c           	         \        V P                  V P                  V P                  V P                  V P
                  V P                  R 7      # )r  )r  r  rJ  rK  rq  rs  r  )r  r  s   &&r3   __deepcopy__SVGImage.__deepcopy__4  s9    ffff**;;LL
 	
r5   c                L   < V ^8  d   QhRRRS[ RRRS[RS[S[RS[3,          /# )r-   resource_registryr(   r   	last_itemr&   initial_pointr/   )r   r   r  r1   )r2   rh  s   "r3   r4   r  A  sI      8  8, 8  8  	 8
  8 
sL%'	( 8r5   c           	        V P                   ;'       d    V P                   P                  pV'       g   \        R 4      h^RIHp V! WPP
                  4      w   rx\        V\        4      '       d   \        P                  R4       RW43# VP                  V P                  V P                  4      w  r\        VV P                  V P                  V	V
RR7      pWV3# )zHfpdf2 bug - Cannot render a raster image without a SVGObject.image_cache)preload_imagez{Inserting .svg vector graphics in <image> tags is currently not supported (contributions are welcome to add support for it)rl   T)inforJ  rK  whkeep_aspect_ratio)r  r  AssertionErrorimage_parsingr(  r  r8   r!   rA  rB  size_in_document_unitsrq  rs  r"   rJ  rK  )r  r$  r   r%  r&  r  r(  r  r)  r*  r+  stream_contents   &&&&&       r3   renderSVGImage.render@  s     ll??t||'?'? Z  	1";		:
1dO,,NN N y//**4::t{{C8ffff"
 -77r5   c                    < V ^8  d   QhRS[ /# )r-   r/   )r   )r2   rh  s   "r3   r4   r  d  s     % %5 %r5   c                B    \        V P                  V P                  4      # r7   )r   rJ  rK  )r  s   &r3   	end_pointSVGImage.end_pointc  s    TVVTVV$$r5   c                <   < V ^8  d   QhRS[ RS[S[S[ 3,          /# )r-   r'  r/   )r   r  r   )r2   rh  s   "r3   r4   r  h  s%     + +% +E+u2D,E +r5   c           	     f   V P                   pV P                  pV P                   V P                  ,           pV P                  V P                  ,           p\        P
                  ! \        W#4      \        WC4      \        W%4      \        WE4      .4      pV\        V P                   V P                  4      3# r7   )rJ  rK  rq  rs  r   from_pointsr   )r  r'  x0y0r  r  bboxs   &&     r3   bounding_boxSVGImage.bounding_boxh  s    VVVVVVdjj VVdkk!&&bbbb	
 U466466***r5   c                b   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[;R&   # )r-   r  rJ  rK  rq  rs  r  )r1   rT   r  )r2   rh  s   "r3   r4   r  ,  sJ     
I H  H  L	 
 M   r5   r>   N)r?   r@   rA   rB   r!  r   r1  propertyr5  r=  __annotate_func__rD   r  r  s   @r3   r  r  ,  sJ     	
 	
  8  8D % %+ +y  r5   r  c                b    V ^8  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   # )r-   r   )__conditional_annotations__rq   r1   r   )r2   s   "r3   r4   r4      s,      V	; ;d38n ;W	r5   >   rr  chr=  r<  iclhvbrk  virj  capr>  rlhvmaxvmingbX<@gjZ@gjZ?)rH   )rL   r7   r  r  )krC  rC   loggingr  r  warningscopyr   osr   typingr   r   r   r   r   fontTools.svgLib.pathr	   enumsr
   r   r   r   defusedxml.ElementTreer   r  ImportErrorwarnxml.etree.ElementTreerl   r   drawingr   r   r   r   r   r   r   r   r   drawing_primitivesr   r   r   r   r   r   r   image_datastructuresr    r!   outputr"   patternr#   r$   r%   r&   fpdfr'   r(   	getLoggerr?   rA  rm   compiler   r  DOTALLrV  rW  r;   rT   r=   rV   r\   rZ   taurb   r^   rd   rn   rt   rz   r  r   r   r   r   r   r   r   r   r   r  r  r  r3  rN  ra  rc  r   r  r  r  r4   )rC  s   @r3   <module>rb     s     	    E E V UBB 
 
 
   > 3 A-#' 
		8	$ 
'+ 
 zz89::m  L"))4zz56 /e / / 

PQ * 	"))!"$	  
488c>
DHHsN	1
DHH	 V V( Q Q"       	68Y
I

 D D     	 	 2E  <M
) 
)"   T 
    
    
 NR 
  o;  ;| $7 $7N)	"(6 QDDN8   D ` `F ? ?j jZJ+z J+_8  BMMc BABs   K K%$K%