Ë
    \Rðiè  ã                  ó‚   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZmZ  G d
„ de
«      Zy)z<Styles object, container for all objects in the styles part.é    )Úannotations)Úwarn)ÚWD_STYLE_TYPE)Ú	CT_Styles)ÚElementProxy)Ú	BabelFish)ÚLatentStyles)Ú	BaseStyleÚStyleFactoryc                  ó„   ‡ — e Zd ZdZdˆ fd„Zd„ Zdd„Zd„ Zd„ Zdd„Z	dd„Z
dd	„Zd
„ Zed„ «       Zdd„Zdd„Zdd„Zˆ xZS )ÚStyleszÂProvides access to the styles defined in a document.

    Accessed using the :attr:`.Document.styles` property. Supports ``len()``, iteration,
    and dictionary-style access by style name.
    c                ó2   •— t         ‰| �  |«       || _        y ©N)ÚsuperÚ__init__Ú_element)ÚselfÚstylesÚ	__class__s     €úM/var/www/html/Extract/venv/lib/python3.12/site-packages/docx/styles/styles.pyr   zStyles.__init__   s   ø€ Ü‰Ñ˜Ô Øˆ�ó    c                ó~   ‡— t        j                  |«      Št        ˆfd„| j                  j                  D «       «      S )z$Enables `in` operator on style name.c              3  ó<   •K  — | ]  }|j                   ‰k(  –— Œ y ­wr   )Úname_val)Ú.0ÚstyleÚinternal_names     €r   ú	<genexpr>z&Styles.__contains__.<locals>.<genexpr>   s   øè ø€ ÒX°u�5—>‘> ]Õ2ÑXùs   ƒ)r   Úui2internalÚanyr   Ú	style_lst)r   Únamer   s     @r   Ú__contains__zStyles.__contains__   s.   ø€ ä!×-Ñ-¨dÓ3ˆÜÓXÀÇÁ×@WÑ@WÔXÓXÐXr   c                ó  — | j                   j                  t        j                  |«      «      }|�t	        |«      S | j                   j                  |«      }|�d}t        |t        d¬«       t	        |«      S t        d|z  «      ‚)z©Enables dictionary-style access by UI name.

        Lookup by style id is deprecated, triggers a warning, and will be removed in a
        near-future release.
        zFstyle lookup by style_id is deprecated. Use style name as key instead.é   )Ú
stacklevelzno style with name '%s')	r   Úget_by_namer   r   r   Ú	get_by_idr   ÚUserWarningÚKeyError)r   ÚkeyÚ	style_elmÚmsgs       r   Ú__getitem__zStyles.__getitem__   s{   € ð —M‘M×-Ñ-¬i×.CÑ.CÀCÓ.HÓIˆ	ØÐ Ü 	Ó*Ð*à—M‘M×+Ñ+¨CÓ0ˆ	ØÐ ØZˆCÜ�”k¨aÕ0Ü 	Ó*Ð*äÐ0°3Ñ6Ó7Ð7r   c                ó<   — d„ | j                   j                  D «       S )Nc              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr   )r   )r   r   s     r   r   z"Styles.__iter__.<locals>.<genexpr>2   s   è ø€ ÒI¨”˜U×#ÑIùs   ‚)r   r!   ©r   s    r   Ú__iter__zStyles.__iter__1   s   € ÙI°·±×1HÑ1HÔIÐIr   c                ó@   — t        | j                  j                  «      S r   )Úlenr   r!   r1   s    r   Ú__len__zStyles.__len__4   s   € Ü�4—=‘=×*Ñ*Ó+Ð+r   c                ó    — t        j                  |«      }|| v rt        d|z  «      ‚| j                  j	                  |||«      }t        |«      S )z¹Return a newly added style object of `style_type` and identified by `name`.

        A builtin style can be defined by passing True for the optional `builtin`
        argument.
        z$document already contains style '%s')r   r   Ú
ValueErrorr   Úadd_style_of_typer   )r   r"   Ú
style_typeÚbuiltinÚ
style_namer   s         r   Ú	add_stylezStyles.add_style7   sP   € ô ×*Ñ*¨4Ó0ˆ
Ø˜ÑÜÐCÀdÑJÓKÐKØ—‘×/Ñ/°
¸JÈÓPˆÜ˜EÓ"Ð"r   c                óT   — | j                   j                  |«      }|€yt        |«      S )zpReturn the default style for `style_type` or |None| if no default is defined
        for that type (not common).N)r   Údefault_forr   )r   r9   r   s      r   ÚdefaultzStyles.defaultC   s+   € ð —‘×)Ñ)¨*Ó5ˆØˆ=ØÜ˜EÓ"Ð"r   c                óL   — |€| j                  |«      S | j                  ||«      S )z×Return the style of `style_type` matching `style_id`.

        Returns the default for `style_type` if `style_id` is not found or is |None|, or
        if the style having `style_id` is not of `style_type`.
        )r?   Ú
_get_by_id)r   Ústyle_idr9   s      r   r(   zStyles.get_by_idK   s*   € ð ÐØ—<‘< 
Ó+Ð+Ø�‰˜x¨Ó4Ð4r   c                óp   — |€yt        |t        «      r| j                  ||«      S | j                  ||«      S )ar  Return the id of the style corresponding to `style_or_name`, or |None| if
        `style_or_name` is |None|.

        If `style_or_name` is not a style object, the style is looked up using
        `style_or_name` as a style name, raising |ValueError| if no style with that name
        is defined. Raises |ValueError| if the target style is not of `style_type`.
        N)Ú
isinstancer
   Ú_get_style_id_from_styleÚ_get_style_id_from_name)r   Ústyle_or_namer9   s      r   Úget_style_idzStyles.get_style_idU   s=   € ð Ð ØÜ˜¤yÔ1Ø×0Ñ0°À
ÓKÐKà×/Ñ/°¸zÓJÐJr   c                óH   — t        | j                  j                  «       «      S )zÝA |LatentStyles| object providing access to the default behaviors for latent
        styles and the collection of |_LatentStyle| objects that define overrides of
        those defaults for a particular named latent style.)r	   r   Úget_or_add_latentStylesr1   s    r   Úlatent_styleszStyles.latent_stylesd   s   € ô
 ˜DŸM™M×AÑAÓCÓDÐDr   c                óš   — |r| j                   j                  |«      nd}|�|j                  |k7  r| j                  |«      S t	        |«      S )zÉReturn the style of `style_type` matching `style_id`.

        Returns the default for `style_type` if `style_id` is not found or if the style
        having `style_id` is not of `style_type`.
        N)r   r(   Útyper?   r   )r   rB   r9   r   s       r   rA   zStyles._get_by_idk   sF   € ñ 6>�—‘×'Ñ'¨Ô1À4ˆØˆ=˜EŸJ™J¨*Ò4Ø—<‘< 
Ó+Ð+Ü˜EÓ"Ð"r   c                ó,   — | j                  | |   |«      S )a  Return the id of the style of `style_type` corresponding to `style_name`.

        Returns |None| if that style is the default style for `style_type`. Raises
        |ValueError| if the named style is not found in the document or does not match
        `style_type`.
        )rE   )r   r;   r9   s      r   rF   zStyles._get_style_id_from_namev   s   € ð ×,Ñ,¨T°*Ñ-=¸zÓJÐJr   c                ó˜   — |j                   |k7  rt        d|j                   ›d|›�«      ‚|| j                  |«      k(  ry|j                  S )z‹Id of `style`, or |None| if it is the default style of `style_type`.

        Raises |ValueError| if style is not of `style_type`.
        zassigned style is type z, need type N)rM   r7   r?   rB   )r   r   r9   s      r   rE   zStyles._get_style_id_from_style   sC   € ð
 �:‰:˜Ò#ÝÈ%Ï*Ë*ÑV`ÐaÓbÐbØ�D—L‘L Ó,Ò,ØØ�~‰~Ðr   )r   r   )r+   Ústr)F)r9   r   )rB   ú
str | Noner9   r   )r;   rP   r9   r   ÚreturnrQ   )r   r
   r9   r   rR   rQ   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r#   r.   r2   r5   r<   r?   r(   rH   ÚpropertyrK   rA   rF   rE   Ú__classcell__)r   s   @r   r   r      s^   ø„ ñõòYó
8ò$Jò,ó
#ó#ó5òKð ñEó ðEó	#óK÷	r   r   N)rV   Ú
__future__r   Úwarningsr   Údocx.enum.styler   Údocx.oxml.stylesr   Údocx.sharedr   Údocx.stylesr   Údocx.styles.latentr	   Údocx.styles.styler
   r   r   © r   r   ú<module>rb      s.   ðÙ Bå "å å )Ý &Ý $Ý !Ý +ß 5ôyˆ\õ yr   