Ë
    úmxi~  ã                  ó€   — 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 erddlmZ 	 	 	 	 	 	 	 	 	 	 	 	 dd	„Zy
)aG  Shared resolver for building component definitions with path validation.

This module centralizes the logic for interpreting js/css inputs as inline
content vs path/glob strings, validating them against a component's asset
directory, and producing a BidiComponentDefinition with correct asset-relative
URLs used by the server.
é    )Úannotations)ÚPath)ÚTYPE_CHECKING)ÚComponentPathUtils)ÚBidiComponentDefinition)ÚStreamlitAPIException)ÚBidiComponentManagerc                ó˜   ‡‡
— | j                  ‰«      Š
	 	 	 	 	 	 dˆ
ˆfd„} ||d¬«      \  }} ||d¬«      \  }}	t        ‰|||||	¬«      S )aW  Construct a definition and validate ``js``/``css`` inputs against ``asset_dir``.

    Parameters
    ----------
    manager : BidiComponentManager
        Component manager used to resolve the component's ``asset_dir`` and
        related metadata.
    component_key : str
        Fully-qualified name of the component to build a definition for.
    html : str | None
        Inline HTML content to include in the definition. If ``None``, the
        component will not include HTML content.
    css : str | None
        Either inline CSS content or a path/glob to a CSS file inside the
        component's ``asset_dir``. Inline strings are kept as-is; file-backed
        inputs are validated and converted to an ``asset_dir``-relative URL.
    js : str | None
        Either inline JavaScript content or a path/glob to a JS file inside the
        component's ``asset_dir``. Inline strings are kept as-is; file-backed
        inputs are validated and converted to an ``asset_dir``-relative URL.

    Returns
    -------
    BidiComponentDefinition
        A component definition with inline content preserved and file-backed
        entries resolved to absolute filesystem paths plus their
        ``asset_dir``-relative URLs.

    Raises
    ------
    StreamlitAPIException
        If a path/glob is provided but the component has no declared
        ``asset_dir``, if a glob resolves to zero or multiple files, or if any
        resolved path escapes the declared ``asset_dir``.

    Notes
    -----
    - Inline strings are treated as content (no manifest required).
    - Path-like strings require the component to be declared in the package
      manifest with an ``asset_dir``.
    - Globs are supported only within ``asset_dir`` and must resolve to exactly
      one file.
    - Relative paths are resolved strictly against the component's ``asset_dir``
      and must remain within it after resolution. Absolute paths are not
      allowed.
    - For file-backed entries, the URL sent to the frontend is the
      ``asset_dir``-relative path, served under
      ``/_stcore/bidi-components/<component>/<relative_path>``.
    c               ó¬  •— | €yt        j                  | «      r| d fS ‰€t        d‰› d|› d�«      ‚| }t        j                  |«      rt        j                  |‰«      }t        j
                  |‰|¬«       t        |j                  «       j                  ‰j                  «       «      j                  «       «      }t        |«      |fS t        j                  |«       ‰t        |«      z  }t        j
                  |‰|¬«       |j                  «       }t        |j                  ‰j                  «       «      j                  «       «      }t        |«      |fS )N)NNzComponent 'zG' must be declared in pyproject.toml with asset_dir to use file-backed ú.©Úkind)r   Úlooks_like_inline_contentr   Úhas_glob_charactersÚresolve_glob_patternÚensure_within_rootÚstrÚresolveÚrelative_toÚas_posixÚvalidate_path_securityr   )	Úvaluer   Ú	value_strÚresolvedÚrel_urlÚ	candidateÚresolved_candidateÚ
asset_rootÚcomponent_keys	          €€úl/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/components/v2/component_definition_resolver.pyÚ_resolve_entryz8build_definition_with_validation.<locals>._resolve_entry`   sI  ø€ ð ˆ=ØÜ×7Ñ7¸Ô>Ø˜$�;Ðð ÐÜ'Ø˜m˜_ð -&Ø&* V¨1ð.óð ð
 ˆ	ô ×1Ñ1°)Ô<Ü)×>Ñ>¸yÈ*ÓUˆHÜ×1Ñ1°(¸JÈTÕRäØ× Ñ Ó"×.Ñ.¨z×/AÑ/AÓ/CÓD×MÑMÓOóˆGô �x“= 'Ð)Ð)ô 	×1Ñ1°)Ô<Ø¤ i£Ñ0ˆ	Ü×-Ñ-¨i¸È$ÕOØ&×.Ñ.Ó0ÐÜÐ(×4Ñ4°Z×5GÑ5GÓ5IÓJ×SÑSÓUÓVˆÜÐ%Ó&¨Ð/Ð/ó    Úcssr   Újs)ÚnameÚhtmlr#   r$   Úcss_asset_relative_pathÚjs_asset_relative_path)r   ú
str | Noner   r   Úreturnztuple[str | None, str | None])Úget_component_asset_rootr   )Úmanagerr   r&   r#   r$   r!   Ú	css_valueÚcss_relÚjs_valueÚjs_relr   s    `        @r    Ú build_definition_with_validationr1   $   sy   ù€ ðt ×1Ñ1°-Ó@€Jð"0Øð"0Ø$'ð"0à	&ö"0ñH (¨°%Ô8Ñ€IˆwÙ% b¨tÔ4Ñ€Hˆfô #ØØØØØ 'Ø%ôð r"   N)r,   r	   r   r   r&   r)   r#   r)   r$   r)   r*   r   )Ú__doc__Ú
__future__r   Úpathlibr   Útypingr   Ú,streamlit.components.v2.component_path_utilsr   Ú*streamlit.components.v2.component_registryr   Ústreamlit.errorsr   Ú)streamlit.components.v2.component_managerr	   r1   © r"   r    ú<module>r;      sj   ðñõ #å Ý  å KÝ NÝ 2áÝNðkà!ðkð ðkð ð	kð
 
ðkð 	ðkð ôkr"   