L iddlmZddlmZddlmZddlmZerddlm Z  d dZ d dZ d dZ y ) ) annotations) TYPE_CHECKING)StreamlitAPIException)is_url)CustomThemeConfigc<|sy|j}d|vr|dfS|jdd\}}|j}|j}|jd}|dkDrtd|dt |}|r|std|d |r||fS|dfS) aiParse 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:Nzfamily=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.)stripsplitcountrr) font_config property_name font_name source_urlfamily_occurrences is_valid_urls b/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/runtime/theme_util.py_parse_font_configrs ##%K +D  (--c15Iz!I!!#J$)))4A#.}o>> >  *%LI#$o%> @  *$$ d?c|dk(r|S|dS)zGet 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)rsections r_get_font_source_config_namerQs'_H %%rct|d\}}|r||_|r)td|}|jj ||t|d\}} |r||_| r)td|}|jj || t|d\} } | r| |_| r)td|}|jj || |S)aPopulate 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 ":". code_font_config: A string with just the font name (e.g., "Roboto Mono") or in the format ":". heading_font_config: A string with just the font name (e.g., "Inter Bold") or in the format ":". 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_namercodeFont headingFont)r body_fontr font_sourcesadd code_font heading_font) msgbody_font_configcode_font_configheading_font_configrbody_font_namebody_font_sourcercode_font_namecode_font_sourceheading_font_nameheading_font_sources rparse_fonts_with_sourcer1ZsB(::JF'S$N$& 267C  AQR(::JJ'W$N$& 2:wG  AQR.@].**,2='J  ATU JrN)r str | Nonerstrreturnztuple[str, str | None])rr3rr3r4r3) r'rr(r2r)r2r*r2rr3r4r) __future__rtypingrstreamlit.errorsrstreamlit.url_utilrstreamlit.proto.NewSession_pb2rrrr1rrrr:s{ # 2%@3333l&: : :!:$ :  :  :r