
    /_im                        d dl mZ d dlZd dl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
lmZ ddZ	 	 d	 	 	 	 	 	 	 ddZ G d d      Zy)    )annotationsN)Path)TYPE_CHECKING)config)CustomComponent)get_instance)get_script_run_ctx)	FrameType)BaseComponentRegistryc                   t        j                  |       }|t        d      |j                  }|dk(  rVt        j                  |       }t
        j                  j                  |      }t
        j                  j                  |      \  }}|S )Nz)module is None. This should never happen.__main__)	inspect	getmoduleRuntimeError__name__getfileospathbasenamesplitext)caller_framemodulemodule_name	file_pathfilename_s         i/var/www/html/land_sniper/venv/lib/python3.12/site-packages/streamlit/components/v1/component_registry.py_get_module_namer   !   sx     |,F~FGG//K j OOL1	77##I.))(3Q    c                   |t        |t              rt        |      }t        j                         }|t        d      |j                  }|t        d      t        |      }| d|  }|st        j                  d      x}r| d| d}t        ||||      }t               }	|	#t               j                  j                  |       |S )a  Create a custom component and register it if there is a ``ScriptRunContext``.

    The component is not registered when there is no ``ScriptRunContext``.
    This can happen when a ``CustomComponent`` is executed as standalone
    command (e.g. for testing).

    To use this function, import it from the ``streamlit.components.v1``
    module.

    .. warning::
        Using ``st.components.v1.declare_component`` directly (instead of
        importing its module) is deprecated and will be disallowed in a later
        version.

    Parameters
    ----------
    name : str
        A short, descriptive name for the component, like "slider".

    path: str, Path, or None
        The path to serve the component's frontend files from. The path should
        be absolute. If ``path`` is ``None`` (default), Streamlit will serve
        the component from the location in ``url``. Either ``path`` or ``url``
        must be specified. If both are specified, then ``url`` will take
        precedence.

    url: str or None
        The URL that the component is served from. If ``url`` is ``None``
        (default), Streamlit will serve the component from the location in
        ``path``. Either ``path`` or ``url`` must be specified. If both are
        specified, then ``url`` will take precedence.


    Returns
    -------
    CustomComponent
        A ``CustomComponent`` that can be called like a function.
        Calling the component will create a new instance of the component
        in the Streamlit app.

    z0current_frame is None. This should never happen.z/caller_frame is None. This should never happen..z!server.customComponentBaseUrlPath/)namer   urlr   )
isinstancer   strr   currentframer   f_backr   r   
get_optionr   r	   r   component_registryregister_component)
r#   r   r$   current_framer   r   component_namecomponent_base_path	componentctxs
             r   declare_componentr1   5   s    \ JtT24y '.&:&:&<MMNN ''LLMM"<0K $}AdV,N %001TUUU$%Q~&6a8  $C[I 
C
))<<YGr   c                      e Zd Zedd       Zy)ComponentRegistryc                *    t               j                  S )z6Returns the ComponentRegistry of the runtime instance.)r   r*   )clss    r   instancezComponentRegistry.instance   s     ~000r   N)returnr   )r   
__module____qualname__classmethodr6    r   r   r3   r3      s    1 1r   r3   )r   r
   r7   r&   )NN)r#   r&   r   zstr | Path | Noner$   z
str | Noner7   r   )
__future__r   r   r   pathlibr   typingr   	streamlitr   (streamlit.components.v1.custom_componentr   streamlit.runtimer   7streamlit.runtime.scriptrunner_utils.script_run_contextr	   typesr
   2streamlit.components.types.base_component_registryr   r   r1   r3   r;   r   r   <module>rE      sq    #  	     D * VX, #P
P
P 
P 	Pr1 1r   