§
    ´eîi|&  ã                   ó"  — d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	 erd dl
mZ d dlmZ dZ G d„ d	e	¦  «        Z G d
„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        ZdS )é    )Úabsolute_import)ÚTYPE_CHECKINGÚList)ÚImageÚ	ImageDraw)ÚQRModuleDrawer)ÚStyledPilImage)ÚActiveWithNeighborsé   c                   ó   — e Zd ZU dZded<   dS )ÚStyledPilQRModuleDrawerzù
    A base class for StyledPilImage module drawers.

    NOTE: the color that this draws in should be whatever is equivalent to
    black in the color space, and the specified QRColorMask will handle adding
    colors as necessary to the image
    r	   ÚimgN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    úi/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/qrcode/image/styles/moduledrawers/pil.pyr   r      s*   € € € € € € ðð ð 
ÐÐÑÐÐr   r   c                   ó.   ‡ — e Zd ZdZˆ fd„Zdefd„Zˆ xZS )ÚSquareModuleDrawerz-
    Draws the modules as simple squares
    c                 ó€   •—  t          ¦   «         j        |i |¤Ž t          j        | j        j        ¦  «        | _        d S ©N)ÚsuperÚ
initializer   ÚDrawr   Ú_imgÚimgDraw©ÚselfÚargsÚkwargsÚ	__class__s      €r   r   zSquareModuleDrawer.initialize#   s8   ø€ Ø�‰ŒÔ˜DÐ+ FÐ+Ð+Ð+Ý ”~ d¤h¤mÑ4Ô4ˆŒˆˆr   Ú	is_activec                 óZ   — |r(| j                              || j        j        ¬¦  «         d S d S )N©Úfill)r   Ú	rectangler   Úpaint_color©r!   Úboxr%   s      r   ÚdrawrectzSquareModuleDrawer.drawrect'   s=   € Øð 	CØŒL×"Ò" 3¨T¬XÔ-AÐ"ÑBÔBÐBÐBÐBð	Cð 	Cr   )r   r   r   r   r   Úboolr-   Ú__classcell__©r$   s   @r   r   r      sf   ø€ € € € € ðð ð5ð 5ð 5ð 5ð 5ðC tð Cð Cð Cð Cð Cð Cð Cð Cr   r   c                   ó6   ‡ — e Zd ZdZdd„Zˆ fd„Zdefd„Zˆ xZS )ÚGappedSquareModuleDrawerz¹
    Draws the modules as simple squares that are not contiguous.

    The size_ratio determines how wide the squares are relative to the width of
    the space they are printed in
    çš™™™™™é?c                 ó   — || _         d S r   )Ú
size_ratio)r!   r5   s     r   Ú__init__z!GappedSquareModuleDrawer.__init__4   s   € Ø$ˆŒˆˆr   c                 ó¾   •—  t          ¦   «         j        |i |¤Ž t          j        | j        j        ¦  «        | _        d| j        z
  | j        j        z  dz  | _	        d S )Né   é   )
r   r   r   r   r   r   r   r5   Úbox_sizeÚdeltar    s      €r   r   z#GappedSquareModuleDrawer.initialize7   sU   ø€ Ø�‰ŒÔ˜DÐ+ FÐ+Ð+Ð+Ý ”~ d¤h¤mÑ4Ô4ˆŒØ˜$œ/Ñ)¨T¬XÔ->Ñ>ÀÑBˆŒ
ˆ
ˆ
r   r%   c                 ó  — |r~|d         d         | j         z   |d         d         | j         z   |d         d         | j         z
  |d         d         | j         z
  f}| j                             || j        j        ¬¦  «         d S d S )Nr   r8   r'   )r;   r   r)   r   r*   )r!   r,   r%   Úsmaller_boxs       r   r-   z!GappedSquareModuleDrawer.drawrect<   sŽ   € Øð 	Kà�A”�q”	˜DœJÑ&Ø�A”�q”	˜DœJÑ&Ø�A”�q”	˜DœJÑ&Ø�A”�q”	˜DœJÑ&ð	ˆKð ŒL×"Ò" ;°T´XÔ5IÐ"ÑJÔJÐJÐJÐJð	Kð 	Kr   ©r3   )	r   r   r   r   r6   r   r.   r-   r/   r0   s   @r   r2   r2   ,   s   ø€ € € € € ðð ð%ð %ð %ð %ðCð Cð Cð Cð Cð
K tð Kð Kð Kð Kð Kð Kð Kð Kr   r2   c                   ó2   ‡ — e Zd ZdZdZˆ fd„Zdefd„Zˆ xZS )ÚCircleModuleDrawerz&
    Draws the modules as circles
    Nc                 ó¬  •—  t          ¦   «         j        |i |¤Ž | j        j        }|t          z  }t          j        | j        j        ||f| j        j        j	        ¦  «        | _
        t          j        | j
        ¦  «                             dd||f| j        j        ¬¦  «         | j
                             ||ft
          j        j        ¦  «        | _
        d S )Nr   r'   )r   r   r   r:   ÚANTIALIASING_FACTORr   ÚnewÚmodeÚ
color_maskÚ
back_colorÚcircler   r   Úellipser*   ÚresizeÚ
ResamplingÚLANCZOS)r!   r"   r#   r:   Ú	fake_sizer$   s        €r   r   zCircleModuleDrawer.initializeN   sÉ   ø€ Ø�‰ŒÔ˜DÐ+ FÐ+Ð+Ð+Ø”8Ô$ˆØÕ2Ñ2ˆ	Ý”iØŒHŒMØ˜	Ð"ØŒHÔÔ*ñ
ô 
ˆŒõ
 	Œ�t”{Ñ#Ô#×+Ò+Ø��9˜iÐ(¨t¬xÔ/Cð 	,ñ 	
ô 	
ð 	
ð ”k×(Ò(¨(°HÐ)=½uÔ?OÔ?WÑXÔXˆŒˆˆr   r%   c                 óŒ   — |rA| j         j                             | j        |d         d         |d         d         f¦  «         d S d S ©Nr   r8   )r   r   ÚpasterG   r+   s      r   r-   zCircleModuleDrawer.drawrect\   sN   € Øð 	EØŒHŒM×Ò ¤¨c°!¬f°Q¬i¸¸Q¼À¼Ð-CÑDÔDÐDÐDÐDð	Eð 	Er   )	r   r   r   r   rG   r   r.   r-   r/   r0   s   @r   r@   r@   G   sr   ø€ € € € € ðð ð €FðYð Yð Yð Yð YðE tð Eð Eð Eð Eð Eð Eð Eð Er   r@   c                   ó\   ‡ — e Zd ZdZdZdd„Zˆ fd„Zd„ Zdeee	                  dd	fd
„Z
ˆ xZS )ÚRoundedModuleDraweraP  
    Draws the modules with all 90 degree corners replaced with rounded edges.

    radius_ratio determines the radius of the rounded edges - a value of 1
    means that an isolated module will be drawn as a circle, while a value of 0
    means that the radius of the rounded edge will be 0 (and thus back to 90
    degrees again).
    Tr8   c                 ó   — || _         d S r   )Úradius_ratio)r!   rS   s     r   r6   zRoundedModuleDrawer.__init__m   s   € Ø(ˆÔÐÐr   c                 ó¤   •—  t          ¦   «         j        |i |¤Ž t          | j        j        dz  ¦  «        | _        |                      ¦   «          d S )Nr9   )r   r   Úintr   r:   Úcorner_widthÚsetup_cornersr    s      €r   r   zRoundedModuleDrawer.initializep   sQ   ø€ Ø�‰ŒÔ˜DÐ+ FÐ+Ð+Ð+Ý ¤Ô 1°AÑ 5Ñ6Ô6ˆÔØ×ÒÑÔÐÐÐr   c                 ó\  — | j         j        }| j         j        j        }| j         j        }t          j        || j        | j        f|¦  «        | _        | j        t          z  }| j
        |z  }|dz  }t          j        |||f|¦  «        }t          j        |¦  «        }|                     dd||f|¬¦  «         |                     |d||f|¬¦  «         |                     d|||f|¬¦  «         |                     | j        | j        ft
          j        j        ¦  «        | _        | j                             t
          j        j        ¦  «        | _        | j                             t
          j        j        ¦  «        | _        | j                             t
          j        j        ¦  «        | _        d S ©Nr9   r   r'   )r   rD   rE   rF   r*   r   rC   rV   ÚSQUARErB   rS   r   r   rH   r)   rI   rJ   rK   ÚNW_ROUNDÚ	transposeÚ	TransposeÚFLIP_TOP_BOTTOMÚSW_ROUNDÚ
ROTATE_180ÚSE_ROUNDÚFLIP_LEFT_RIGHTÚNE_ROUND)	r!   rD   rF   Úfront_colorÚ
fake_widthÚradiusÚdiameterÚbaseÚ	base_draws	            r   rW   z!RoundedModuleDrawer.setup_cornersu   s†  € ØŒxŒ}ˆØ”XÔ(Ô3ˆ
Ø”hÔ*ˆÝ”iØ�4Ô$ dÔ&7Ð8¸+ñ
ô 
ˆŒð Ô&Õ)<Ñ<ˆ
ØÔ" ZÑ/ˆØ˜A‘:ˆÝŒyØ�:˜zÐ*¨Jñ
ô 
ˆõ ”N 4Ñ(Ô(ˆ	Ø×Ò˜1˜a ¨8Ð4¸;ÐÑGÔGÐGØ×Ò˜V Q¨
°JÐ?ÀkÐÑRÔRÐRØ×Ò˜Q ¨
°JÐ?ÀkÐÑRÔRÐRØŸšØÔ Ô 1Ð2µEÔ4DÔ4Lñ
ô 
ˆŒð œ×/Ò/µ´Ô0OÑPÔPˆŒØœ×/Ò/µ´Ô0JÑKÔKˆŒØœ×/Ò/µ´Ô0OÑPÔPˆŒˆˆr   r,   r%   r
   c                 ó  — |sd S |j          o|j         }|j         o|j         }|j         o|j         }|j         o|j          }|r| j        n| j        }|r| j        n| j        }|r| j        n| j        }	|r| j        n| j        }
| j	        j
                             ||d         d         |d         d         f¦  «         | j	        j
                             ||d         d         | j        z   |d         d         f¦  «         | j	        j
                             |	|d         d         | j        z   |d         d         | j        z   f¦  «         | j	        j
                             |
|d         d         |d         d         | j        z   f¦  «         d S rN   )ÚWÚNÚEÚSr[   rZ   rc   ra   r_   r   r   rO   rV   )r!   r,   r%   Ú
nw_roundedÚ
ne_roundedÚ
se_roundedÚ
sw_roundedÚnwÚneÚseÚsws              r   r-   zRoundedModuleDrawer.drawrectŽ   sŠ  € Øð 	ØˆFà"œ�_Ð8¨Y¬[¨ˆ
Ø"œ�_Ð8¨Y¬[¨ˆ
Ø"œ�_Ð8¨Y¬[¨ˆ
Ø"œ�_Ð8¨Y¬[¨ˆ
à(Ð9ˆTŒ]ˆ]¨d¬kˆØ(Ð9ˆTŒ]ˆ]¨d¬kˆØ(Ð9ˆTŒ]ˆ]¨d¬kˆØ(Ð9ˆTŒ]ˆ]¨d¬kˆØŒŒ×Ò˜B  Q¤¨¤¨C°¬F°1¬IÐ 6Ñ7Ô7Ð7ØŒŒ×Ò˜B  Q¤¨¤¨TÔ->Ñ!>ÀÀAÄÀqÄ	Ð JÑKÔKÐKØŒŒ×ÒØ��Q”˜”˜TÔ.Ñ.°°A´°q´	¸DÔ<MÑ0MÐNñ	
ô 	
ð 	
ð 	ŒŒ×Ò˜B  Q¤¨¤¨C°¬F°1¬I¸Ô8IÑ,IÐ JÑKÔKÐKÐKÐKr   )r8   )r   r   r   r   Úneeds_neighborsr6   r   rW   r   rU   r-   r/   r0   s   @r   rQ   rQ   a   s¤   ø€ € € € € ðð ð €Oð)ð )ð )ð )ðð ð ð ð ð
Qð Qð Qð2L˜D  c¤œOð LÐ8Mð Lð Lð Lð Lð Lð Lð Lð Lr   rQ   c                   ó<   ‡ — e Zd ZdZdZd
d„Zˆ fd„Zd„ Zdd	„Zˆ xZ	S )ÚVerticalBarsDrawerzÌ
    Draws vertically contiguous groups of modules as long rounded rectangles,
    with gaps between neighboring bands (the size of these gaps is inversely
    proportional to the horizontal_shrink).
    Tr3   c                 ó   — || _         d S r   )Úhorizontal_shrink)r!   r{   s     r   r6   zVerticalBarsDrawer.__init__¬   s   € Ø!2ˆÔÐÐr   c                 óì   •—  t          ¦   «         j        |i |¤Ž t          | j        j        dz  ¦  «        | _        t          d| j        z
  | j        z  ¦  «        | _        |                      ¦   «          d S ©Nr9   r8   )	r   r   rU   r   r:   Úhalf_heightr{   r;   Úsetup_edgesr    s      €r   r   zVerticalBarsDrawer.initialize¯   sp   ø€ Ø�‰ŒÔ˜DÐ+ FÐ+Ð+Ð+Ý˜tœxÔ0°1Ñ4Ñ5Ô5ˆÔÝ˜!˜dÔ4Ñ4¸Ô8HÑHÑIÔIˆŒ
Ø×ÒÑÔÐÐÐr   c                 óH  — | j         j        }| j         j        j        }| j         j        }| j        }|dz  }t          || j        z  ¦  «        }t          j	        |||f|¦  «        | _
        |t          z  }|t          z  }t          j	        |||f|¦  «        }	t          j        |	¦  «        }
|
                     dd||dz  f|¬¦  «         |	                     ||ft          j        j        ¦  «        | _        | j                             t          j        j        ¦  «        | _        d S rY   )r   rD   rE   rF   r*   r~   rU   r{   r   rC   rZ   rB   r   r   rH   rI   rJ   rK   Ú	ROUND_TOPr\   r]   r^   ÚROUND_BOTTOM)r!   rD   rF   rd   ÚheightÚwidthÚshrunken_widthre   Úfake_heightrh   ri   s              r   r   zVerticalBarsDrawer.setup_edgesµ   s  € ØŒxŒ}ˆØ”XÔ(Ô3ˆ
Ø”hÔ*ˆàÔ!ˆØ˜‘
ˆÝ˜U TÔ%;Ñ;Ñ<Ô<ˆÝ”i  ~°vÐ&>ÀÑLÔLˆŒàÕ0Ñ0ˆ
ØÕ2Ñ2ˆÝŒyØ�:˜{Ð+¨Zñ
ô 
ˆõ ”N 4Ñ(Ô(ˆ	Ø×Ò˜1˜a ¨[¸1©_Ð=ÀKÐÑPÔPÐPàŸš n°fÐ%=½uÔ?OÔ?WÑXÔXˆŒØ œN×4Ò4µU´_Ô5TÑUÔUˆÔÐÐr   r%   r
   c                 ó†  — |r¾|j          }|j         }|r| j        n| j        }|r| j        n| j        }| j        j                             ||d         d         | j        z   |d         d         f¦  «         | j        j                             ||d         d         | j        z   |d         d         | j	        z   f¦  «         d S d S rN   )
rl   rn   r�   rZ   r‚   r   r   rO   r;   r~   )r!   r,   r%   Útop_roundedÚbottom_roundedÚtopÚbottoms          r   r-   zVerticalBarsDrawer.drawrectÊ   sÑ   € Øð 
	à'œk˜/ˆKØ!*¤˜_ˆNà$/Ð@�$”.�.°T´[ˆCØ*8ÐI�TÔ&Ð&¸d¼kˆFØŒHŒM×Ò  c¨!¤f¨Q¤i°$´*Ñ&<¸cÀ!¼fÀQ¼iÐ%HÑIÔIÐIØŒHŒM×ÒØ˜˜Qœ œ T¤ZÑ/°°Q´¸´¸TÔ=MÑ1MÐNñô ð ð ð ð
	ð 
	r   r>   ©r%   r
   ©
r   r   r   r   rw   r6   r   r   r-   r/   r0   s   @r   ry   ry   £   sƒ   ø€ € € € € ðð ð €Oð3ð 3ð 3ð 3ðð ð ð ð ðVð Vð Vð*ð ð ð ð ð ð ð r   ry   c                   ó<   ‡ — e Zd ZdZdZd
d„Zˆ fd„Zd„ Zdd	„Zˆ xZ	S )ÚHorizontalBarsDrawerzÌ
    Draws horizontally contiguous groups of modules as long rounded rectangles,
    with gaps between neighboring bands (the size of these gaps is inversely
    proportional to the vertical_shrink).
    Tr3   c                 ó   — || _         d S r   )Úvertical_shrink)r!   r‘   s     r   r6   zHorizontalBarsDrawer.__init__á   s   € Ø.ˆÔÐÐr   c                 óì   •—  t          ¦   «         j        |i |¤Ž t          | j        j        dz  ¦  «        | _        t          d| j        z
  | j        z  ¦  «        | _        |                      ¦   «          d S r}   )	r   r   rU   r   r:   Ú
half_widthr‘   r;   r   r    s      €r   r   zHorizontalBarsDrawer.initializeä   sn   ø€ Ø�‰ŒÔ˜DÐ+ FÐ+Ð+Ð+Ý˜dœhÔ/°!Ñ3Ñ4Ô4ˆŒÝ˜!˜dÔ2Ñ2°d´oÑEÑFÔFˆŒ
Ø×ÒÑÔÐÐÐr   c                 óH  — | j         j        }| j         j        j        }| j         j        }| j        }|dz  }t          || j        z  ¦  «        }t          j	        |||f|¦  «        | _
        |t          z  }|t          z  }t          j	        |||f|¦  «        }	t          j        |	¦  «        }
|
                     dd|dz  |f|¬¦  «         |	                     ||ft          j        j        ¦  «        | _        | j                             t          j        j        ¦  «        | _        d S rY   )r   rD   rE   rF   r*   r“   rU   r‘   r   rC   rZ   rB   r   r   rH   rI   rJ   rK   Ú
ROUND_LEFTr\   r]   rb   ÚROUND_RIGHT)r!   rD   rF   rd   r„   rƒ   Úshrunken_heightre   r†   rh   ri   s              r   r   z HorizontalBarsDrawer.setup_edgesê   s  € ØŒxŒ}ˆØ”XÔ(Ô3ˆ
Ø”hÔ*ˆà”ˆØ˜‘ˆÝ˜f tÔ';Ñ;Ñ<Ô<ˆÝ”i  u¨oÐ&>ÀÑLÔLˆŒàÕ0Ñ0ˆ
ØÕ2Ñ2ˆÝŒyØ�:˜{Ð+¨Zñ
ô 
ˆõ ”N 4Ñ(Ô(ˆ	Ø×Ò˜1˜a ¨a¡°Ð=ÀKÐÑPÔPÐPàŸ+š+ u¨oÐ&>ÅÔ@PÔ@XÑYÔYˆŒØœ?×4Ò4µU´_Ô5TÑUÔUˆÔÐÐr   r%   r
   c                 ó†  — |r¾|j          }|j         }|r| j        n| j        }|r| j        n| j        }| j        j                             ||d         d         |d         d         | j        z   f¦  «         | j        j                             ||d         d         | j	        z   |d         d         | j        z   f¦  «         d S d S rN   )
rk   rm   r•   rZ   r–   r   r   rO   r;   r“   )r!   r,   r%   Úleft_roundedÚright_roundedÚleftÚrights          r   r-   zHorizontalBarsDrawer.drawrectÿ   sÐ   € Øð 
	à(œ{˜?ˆLØ )¤˜OˆMà&2ÐC�4”?�?¸¼ˆDØ(5ÐF�DÔ$Ð$¸4¼;ˆEØŒHŒM×Ò  s¨1¤v¨a¤y°#°a´&¸´)¸d¼jÑ2HÐ&IÑJÔJÐJØŒHŒM×ÒØ˜˜Aœ˜qœ	 D¤OÑ3°S¸´V¸A´YÀÄÑ5KÐLñô ð ð ð ð
	ð 
	r   r>   rŒ   r�   r0   s   @r   r�   r�   Ø   sƒ   ø€ € € € € ðð ð €Oð/ð /ð /ð /ðð ð ð ð ðVð Vð Vð*ð ð ð ð ð ð ð r   r�   N)Ú
__future__r   Útypingr   r   Úqrcode.compat.pilr   r   Ú&qrcode.image.styles.moduledrawers.baser   Úqrcode.image.styledpilr	   Úqrcode.mainr
   rB   r   r   r2   r@   rQ   ry   r�   r   r   r   ú<module>r£      så  ðà &Ð &Ð &Ð &Ð &Ð &à &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø AÐ AÐ AÐ AÐ AÐ Aàð 0Ø5Ð5Ð5Ð5Ð5Ð5Ø/Ð/Ð/Ð/Ð/Ð/ð Ð ð	ð 	ð 	ð 	ð 	˜nñ 	ô 	ð 	ðCð Cð Cð Cð CÐ0ñ Cô Cð CðKð Kð Kð Kð KÐ6ñ Kô Kð Kð6Eð Eð Eð Eð EÐ0ñ Eô Eð Eð4?Lð ?Lð ?Lð ?Lð ?LÐ1ñ ?Lô ?Lð ?LðD2ð 2ð 2ð 2ð 2Ð0ñ 2ô 2ð 2ðj2ð 2ð 2ð 2ð 2Ð2ñ 2ô 2ð 2ð 2ð 2r   