Ë
    úmxi­  ã                  ó€   — d dl mZ d dlmZ d dlmZ d dlmZ erd dlm	Z	 	 	 	 	 	 	 d
d„Z
dd„Z	 	 	 	 	 	 	 	 	 	 	 	 dd„Zy	)é    )Úannotations)ÚTYPE_CHECKING)ÚStreamlitAPIException)Úis_url)ÚCustomThemeConfigc                ó<  — | sy| j                  «       } d| vr| dfS | j                  dd«      \  }}|j                  «       }|j                  «       }|j                  d«      }|dkD  rt        d|› d�«      ‚t	        |«      }|r|st        d|› d	�«      ‚|r||fS |dfS )
ai  Parse a single font configuration string.

    Args:
        font_config: The font configuration string (e.g., "Inter" or "Inter:https://...")
        property_name: The property name for error messages ("font", "codeFont", "headingFont")

    Returns
    -------
        A tuple of (font_name, source_url). source_url is None if not provided or not valid.
    )Ú Nú:Né   zfamily=z The source URL specified in the za property of config.toml contains multiple fonts. Please specify only one font in the source URL.zDA font family name is required when specifying a source URL for the z property in config.toml.)ÚstripÚsplitÚcountr   r   )Úfont_configÚproperty_nameÚ	font_nameÚ
source_urlÚfamily_occurrencesÚis_valid_urls         úS/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/runtime/theme_util.pyÚ_parse_font_configr      sæ   € ñ Øð ×#Ñ#Ó%€Kà
�+Ñà˜DÐ Ð ð (×-Ñ-¨c°1Ó5Ñ€Iˆzà—‘Ó!€IØ×!Ñ!Ó#€Jð $×)Ñ)¨)Ó4ÐØ˜AÒÜ#Ø.¨}¨oð >>ð >ó
ð 	
ô
 ˜*Ó%€Lñ ™IÜ#ðØ$�oÐ%>ð@ó
ð 	
ñ
 Ø˜*Ð$Ð$à�dˆ?Ðó    c                ó   — |dk(  r| S | › d�S )z˜Get the config name for font sources based on property and section. This is used on the FE
    as the id for the font source link in the html head.
    Úthemez-sidebar© )r   Úsections     r   Ú_get_font_source_config_namer   Q   s   € ð �'ÒØÐØˆ_˜HÐ%Ð%r   c                ó˜  — t        |d«      \  }}|r|| _        |r)t        d|«      }| j                  j	                  ||¬«       t        |d«      \  }}	|r|| _        |	r)t        d|«      }| j                  j	                  ||	¬«       t        |d«      \  }
}|
r|
| _        |r)t        d|«      }| j                  j	                  ||¬«       | S )a  Populate the CustomThemeConfig message with the font, codeFont, and headingFont fields set,
    as well as the font_sources field to be added to the html head.

    Args:
        msg: CustomThemeConfig message to be populated.
        body_font_config: A string with just the font name (e.g., "Inter") or in the format
            "<font_family_name_here>:<source_url_here>".
        code_font_config: A string with just the font name (e.g., "Roboto Mono") or in the format
            "<code_font_family_name_here>:<source_url_here>".
        heading_font_config: A string with just the font name (e.g., "Inter Bold") or in the format
            "<heading_font_family_name_here>:<source_url_here>".
        section: The section of the config.toml file to parse the fonts from.

    Examples
    --------
    body_font_config: "Inter" (just font name)
    code_font_config: "Tagesschrift:https://fonts.googleapis.com/css2?family=Tagesschrift&display=swap" (with source)
    heading_font_config: "playwrite-cc-za:https://use.typekit.net/xxs7euo.css"

    Returns
    -------
        Updated CustomThemeConfig message with the font, codeFont, and headingFont fields set.
        Also sets sources in font_sources field to be added to the html (only when source URLs are provided).
    Úfont)Úconfig_namer   ÚcodeFontÚheadingFont)r   Ú	body_fontr   Úfont_sourcesÚaddÚ	code_fontÚheading_font)ÚmsgÚbody_font_configÚcode_font_configÚheading_font_configr   Úbody_font_nameÚbody_font_sourcer   Úcode_font_nameÚcode_font_sourceÚheading_font_nameÚheading_font_sources               r   Úparse_fonts_with_sourcer1   Z   sç   € ôB (:Ð:JÈFÓ'SÑ$€NÐ$ÙØ&ˆŒÙÜ2°6¸7ÓCˆØ×Ñ×Ñ¨ÐAQÐÔRô (:Ð:JÈJÓ'WÑ$€NÐ$ÙØ&ˆŒÙÜ2°:¸wÓGˆØ×Ñ×Ñ¨ÐAQÐÔRô .@Ø˜]ó.Ñ*ÐÐ*ñ Ø,ˆÔÙÜ2°=À'ÓJˆØ×Ñ×Ñ¨ÐATÐÔUà€Jr   N)r   ú
str | Noner   ÚstrÚreturnztuple[str, str | None])r   r3   r   r3   r4   r3   )r'   r   r(   r2   r)   r2   r*   r2   r   r3   r4   r   )Ú
__future__r   Útypingr   Ústreamlit.errorsr   Ústreamlit.url_utilr   Ústreamlit.proto.NewSession_pb2r   r   r   r1   r   r   r   ú<module>r:      s{   ðõ  #å  å 2Ý %áÝ@ð3Øð3àð3ð ó3ól&ð:Ø	ð:à ð:ð !ð:ð $ð	:ð
 ð:ð ô:r   