Ë
    ‹`g°!  ã                   óŒ   — d Z ddlmZ ddlZddlmZ ddlmZ  G d„ de«      Z	 G d„ d	e«      Z
 G d
„ de
«      Z G d„ de
«      Zy)z7
The **BaseElement** is the root for all SVG elements.
é    )ÚetreeN)Ú	Parameter)ÚAutoIDc                   óâ   — e Zd ZdZdZd„ Zd„ Zd„ Zed„ «       Z	ed„ «       Z
ed„ «       Zej                  d	„ «       Zed
„ «       Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zy)ÚBaseElementzª
    The **BaseElement** is the root for all SVG elements. The SVG attributes
    are stored in **attribs**, and the SVG subelements are stored in
    **elements**.

    ÚbaseElementc                 ó`  — |j                  dd«      }|�|j                  | _        nt        «       | _        |j                  dd«      }|�|| j                  _        |j                  dd«      }|�|| j                  _        t        «       | _        | j                  |«       t        «       | _	        y)aÿ  
        :param extra: extra SVG attributes (keyword arguments)

          * add trailing '_' to reserved keywords: ``'class_'``, ``'from_'``
          * replace inner '-' by '_': ``'stroke_width'``


        SVG attribute names will be checked, if **debug** is `True`.

        workaround for removed **attribs** parameter in Version 0.2.2::

            # replace
            element = BaseElement(attribs=adict)

            #by
            element = BaseElement()
            element.update(adict)

        ÚfactoryNÚdebugÚprofile)
ÚpopÚ
_parameterr   r   r   ÚdictÚattribsÚupdateÚlistÚelements)ÚselfÚextrar
   r   r   s        ú^/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/svgwrite/base.pyÚ__init__zBaseElement.__init__   s˜   € ð* —)‘)˜I tÓ,ˆØÐà%×0Ñ0ˆD�Oô (›kˆDŒOð —	‘	˜' 4Ó(ˆØÐØ$)ˆD�O‰OÔ!ð —)‘)˜I tÓ,ˆØÐØ&-ˆD�O‰OÔ#ä“vˆŒØ�‰�EÔÜ›ˆ�ó    c                 óš   — |j                  «       D ]8  \  }}|j                  d«      j                  dd«      }| j                  ||«       Œ: y)zí Update SVG Attributes from `dict` attribs.

        Rules for keys:

        1. trailing '_' will be removed (``'class_'`` -> ``'class'``)
        2. inner '_' will be replaced by '-' (``'stroke_width'`` -> ``'stroke-width'``)

        Ú_Ú-N)ÚitemsÚrstripÚreplaceÚ__setitem__)r   r   ÚkeyÚvalues       r   r   zBaseElement.updateH   sD   € ð "Ÿ-™-ž/‰JˆC�ð —*‘*˜S“/×)Ñ)¨#¨sÓ3ˆCØ×Ñ˜S %Õ(ñ	 *r   c                 ó  — t        j                   | «      }t        j                   | j                  «      |_        t        j                   | j                  «      |_        d|j                  v r|j                  «       |d<   |S )NÚid)Úcopyr   r   Únext_id)r   Únewobjs     r   r$   zBaseElement.copyW   sX   € Ü—‘˜4“ˆÜŸ™ 4§<¡<Ó0ˆŒÜŸ)™) D§M¡MÓ2ˆŒØ�6—>‘>Ñ!Ø!Ÿ>™>Ó+ˆF�4‰LØˆr   c                 ó.   — | j                   j                  S ©N)r   r   ©r   s    r   r   zBaseElement.debug_   s   € à�‰×$Ñ$Ð$r   c                 ó.   — | j                   j                  S r(   )r   r   r)   s    r   r   zBaseElement.profilec   s   € à�‰×&Ñ&Ð&r   c                 ó.   — | j                   j                  S r(   ©r   Ú	validatorr)   s    r   r-   zBaseElement.validatorg   s   € à�‰×(Ñ(Ð(r   c                 ó&   — || j                   _        y r(   r,   ©r   r!   s     r   r-   zBaseElement.validatork   s   € à$)ˆ�‰Õ!r   c                 ó6   — | j                   j                  «       S r(   )r   Úget_versionr)   s    r   ÚversionzBaseElement.versiono   s   € à�‰×*Ñ*Ó,Ð,r   c                 ó   — || _         y r(   )r   )r   Ú	parameters     r   Úset_parameterzBaseElement.set_parameters   s	   € Ø#ˆ�r   Nc                 ó,   — t        j                  |«      S r(   )r   r%   r/   s     r   r%   zBaseElement.next_idv   s   € Ü�~‰~˜eÓ$Ð$r   c                 óv   — d| j                   vr| j                  «       | j                   d<   | j                   d   S )zŠ Get the object `id` string, if the object does not have an `id`,
        a new `id` will be created.

        :returns: `string`
        r#   )r   r%   r)   s    r   Úget_idzBaseElement.get_idy   s3   € ð �t—|‘|Ñ#Ø!%§¡£ˆD�L‰L˜ÑØ�|‰|˜DÑ!Ð!r   c                 ó(   — d| j                  «       z  S )zn
        Get the `IRI` reference string of the object. (i.e., ``'#id'``).

        :returns: `string`
        z#%s)r8   r)   s    r   Úget_irizBaseElement.get_iriƒ   s   € ð �t—{‘{“}Ñ$Ð$r   c                 ó(   — d| j                  «       z  S )zv
        Get the `FuncIRI` reference string of the object. (i.e. ``'url(#id)'``).

        :returns: `string`
        zurl(%s))r:   r)   s    r   Úget_funcirizBaseElement.get_funciri‹   s   € ð ˜4Ÿ<™<›>Ñ)Ð)r   c                 ó    — | j                   |   S )zz Get SVG attribute by `key`.

        :param string key: SVG attribute name
        :return: SVG attribute value

        )r   )r   r    s     r   Ú__getitem__zBaseElement.__getitem__“   s   € ð �|‰|˜CÑ Ð r   c                 óˆ   — | j                   r'| j                  j                  | j                  ||«       || j                  |<   y)z‘ Set SVG attribute by `key` to `value`.

        :param string key: SVG attribute name
        :param object value: SVG attribute value

        N)r   r-   Úcheck_svg_attribute_valueÚelementnamer   )r   r    r!   s      r   r   zBaseElement.__setitem__œ   s5   € ð �:Š:Ø�N‰N×4Ñ4°T×5EÑ5EÀsÈEÔRØ!ˆ�‰�SÒr   c                 ó´   — | j                   r0| j                  j                  | j                  |j                  «       | j                  j                  |«       |S )z� Add an SVG element as subelement.

        :param element: append this SVG element
        :returns: the added element

        )r   r-   Úcheck_valid_childrenrA   r   Úappend)r   Úelements     r   ÚaddzBaseElement.add©   sB   € ð �:Š:Ø�N‰N×/Ñ/°×0@Ñ0@À'×BUÑBUÔVØ�‰×Ñ˜WÔ%Øˆr   c                 ór   — | j                  «       }t        j                  |d¬«      }|j                  d«      S )z† Get the XML representation as unicode `string`.

        :return: unicode XML string of this object and all its subelements

        zutf-8)Úencoding)Úget_xmlr   ÚtostringÚdecode)r   ÚxmlÚxml_utf8_strs      r   rJ   zBaseElement.tostringµ   s0   € ð �l‰l‹nˆä—~‘~ c°GÔ<ˆØ×"Ñ" 7Ó+Ð+r   c                 ó"   — | j                  «       S )z� Show SVG in IPython, Jupyter Notebook, and Jupyter Lab

        :return: unicode XML string of this object and all its subelements

        )rJ   r)   s    r   Ú
_repr_svg_zBaseElement._repr_svg_Á   s   € ð �}‰}‹Ðr   c                 óÄ  — t        j                  | j                  «      }| j                  r0| j                  j                  | j                  | j                  «       t        | j                  j                  «       «      D ].  \  }}|€Œ	| j                  |«      }|sŒ|j                  ||«       Œ0 | j                  D ]!  }|j                  |j                  «       «       Œ# |S )z‰ Get the XML representation as `ElementTree` object.

        :return: XML `ElementTree` of this object and all its subelements

        )r   ÚElementrA   r   r-   Úcheck_all_svg_attribute_valuesr   Úsortedr   Úvalue_to_stringÚsetr   rD   rI   )r   rL   Ú	attributer!   rE   s        r   rI   zBaseElement.get_xmlÉ   s­   € ô �m‰m˜D×,Ñ,Ó-ˆØ�:Š:Ø�N‰N×9Ñ9¸$×:JÑ:JÈDÏLÉLÔYÜ & t§|¡|×'9Ñ'9Ó';Ö <ÑˆI�uàÑ Ø×,Ñ,¨UÓ3�ÚØ—G‘G˜I uÕ-ð !=ð —}”}ˆGØ�J‰J�w—‘Ó(Õ)ð %àˆ
r   c                 óê   — t        |t        t        f«      rS| j                  r| j                  j                  |d«       t        |t        «      r| j                  dk(  rt        |d«      }t        |«      S )z�
        Converts *value* into a <string> includes a value check, depending
        on :attr:`self.debug` and :attr:`self.profile`.

        ÚnumberÚtinyé   )	Ú
isinstanceÚintÚfloatr   r-   Úcheck_svg_typer   ÚroundÚstrr/   s     r   rT   zBaseElement.value_to_stringÝ   sW   € ô �eœc¤5˜\Ô*Ø�zŠzØ—‘×-Ñ-¨e°XÔ>Ü˜%¤Ô'¨D¯L©L¸FÒ,BÜ˜e Q›�Ü�5‹zÐr   c                 ó¢   — |�%| j                   j                  dt        |«      «       |�&| j                   j                  dt        |«      «       yy)zK Insert a **title** and/or a **desc** element as first subelement.
        Nr   )r   ÚinsertÚDescÚTitle)r   ÚtitleÚdescs      r   Úset_desczBaseElement.set_descê   sE   € ð ÐØ�M‰M× Ñ  ¤D¨£JÔ/ØÐØ�M‰M× Ñ  ¤E¨%£LÕ1ð r   c                 ó(  — t        |«      }t        | j                  «      dk(  r| j                  j                  |«       yd}| j                  |   j                  dv rU|dz  }|t        | j                  «      k(  r| j                  j                  |«       y| j                  |   j                  dv rŒU| j                  |   j                  dk(  r)| j                  |   j
                  j                  |«       y| j                  j                  ||«       y)úN
        :param xmldata: an xml.etree.ElementTree - Element() object.
        r   )re   rf   é   NÚmetadata)ÚMetadataÚlenr   rD   rA   rL   rb   )r   Úxmldatark   Úposs       r   Úset_metadatazBaseElement.set_metadataò   sá   € ô ˜GÓ$ˆÜˆt�}‰}Ó Ò"Ø�M‰M× Ñ  Õ*àˆCØ—-‘- Ñ$×0Ñ0Ð4EÑEØ�q‘�Øœ#˜dŸm™mÓ,Ò,Ø—M‘M×(Ñ(¨Ô2Øð	 —-‘- Ñ$×0Ñ0Ð4EÒEð
 �}‰}˜SÑ!×-Ñ-°Ò;Ø—‘˜cÑ"×&Ñ&×-Ñ-¨gÕ6à—‘×$Ñ$ S¨(Õ3r   r(   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rA   r   r   r$   Úpropertyr   r   r-   Úsetterr2   r5   r%   r8   r:   r<   r>   r   rF   rJ   rO   rI   rT   rg   rp   © r   r   r   r      sÎ   „ ñð  €Kò)òV)òð ñ%ó ð%ð ñ'ó ð'ð ñ)ó ð)ð ×Ññ*ó ð*ð ñ-ó ð-ò$ó%ò"ò%ò*ò!ò"ò
ò	,òòò(ó2ó4r   r   c                   ó   — e Zd ZdZd„ Zd„ Zy)rd   re   c                 ó€   — t        j                  | j                  «      | _        t	        |«      | j                  _        y r(   )r   rQ   rA   rL   r`   Útext)r   rz   s     r   r   zTitle.__init__	  s'   € Ü—=‘= ×!1Ñ!1Ó2ˆŒÜ˜D›	ˆ�‰�r   c                 ó   — | j                   S r(   )rL   r)   s    r   rI   zTitle.get_xml  s   € Ø�x‰xˆr   N)rq   rr   rs   rA   r   rI   rw   r   r   rd   rd     s   „ Ø€Kò"ór   rd   c                   ó   — e Zd ZdZy)rc   rf   N)rq   rr   rs   rA   rw   r   r   rc   rc     s   „ Ø�Kr   rc   c                   ó   — e Zd ZdZd„ Zy)rl   rk   c                 ón   — t        j                  d«      | _        | j                  j                  |«       y)ri   rk   N)r   rQ   rL   rD   )r   rn   s     r   r   zMetadata.__init__  s$   € ô —=‘= Ó,ˆŒØ�‰�‰˜Õ r   N)rq   rr   rs   rA   r   rw   r   r   rl   rl     s   „ Ø€Kó!r   rl   )rt   Úsvgwrite.etreer   r$   Úsvgwrite.paramsr   Úsvgwrite.utilsr   Úobjectr   rd   rc   rl   rw   r   r   Ú<module>rƒ      sK   ðñõ !ã å %Ý !ôo4�&ô o4ôdˆFô ôˆ5ô ô!ˆuõ !r   