o
    ,&]i&                     @  s  U d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	m
Z
mZmZmZmZ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ed
 B Zded< eed B Zded< eed
 B Zded< eed B Zded< eed B Z ded< ed Z!ded< ed Z"ded< ed Z#ded< ed Z$ded< ddddZ%eG dd dZ&d\d]d&d'Z'	 	(	)d^d_d/d0Z(d`d2d3Z)dad6d7Z*dbd:d;Z+dcdAdBZ,dddDdEZ-dedGdHZ.dfdJdKZ/dLdMdNdLdNdOdPZ0dgdTdUZ1dhdWdXZ2didZd[Z3d)S )j    )annotations)	dataclass)Literal	TypeAliascast)StreamlitInvalidColumnGapErrorStreamlitInvalidHeightError(StreamlitInvalidHorizontalAlignmentErrorStreamlitInvalidSizeError"StreamlitInvalidTextAlignmentError&StreamlitInvalidVerticalAlignmentErrorStreamlitInvalidWidthError)Block)GapSize)HeightConfig)TextAlignmentConfig)WidthConfigstretchr   WidthWithoutContent)r   contentWidthHeightWithoutContentHeightr   smallmediumlarge	SpaceSizer   r   r   Gapleftcenterright
distributeHorizontalAlignmenttopr"   bottomr$   VerticalAlignmentr!   r"   r#   justifyTextAlignmentg      ?g      @g      @c                   @  s2   e Zd ZU dZded< dZded< dZded< dS )LayoutConfigNzWidth | SpaceSize | NonewidthzHeight | SpaceSize | NoneheightzTextAlignment | Nonetext_alignment)__name__
__module____qualname__r.   __annotations__r/   r0    r5   r5   a/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/streamlit/elements/lib/layout_utils.pyr-   6   s   
 r-   Fr.   allow_contentboolreturnNonec                 C  sb   t | ttfst| |t | tr&dg}|r|d | |vr$t| |dS | dkr/t| |dS )a'  Validate the width parameter.

    Parameters
    ----------
    width : Any
        The width value to validate.
    allow_content : bool
        Whether to allow "content" as a valid width value.

    Raises
    ------
    StreamlitInvalidWidthError
        If the width value is invalid.
    r   r   r   N)
isinstanceintstrr   append)r.   r7   valid_stringsr5   r5   r6   validate_width=   s   




r@   TNr/   Height | Literal['auto']allow_stretchadditional_allowedlist[str] | Nonec                 C  s|   t | ttfst| |t | tr3g }|r|d |r!|d |r(|| | |vr1t| |dS | dkr<t| |dS )a  Validate the height parameter.

    Parameters
    ----------
    height : Any
        The height value to validate.
    allow_content : bool
        Whether to allow "content" as a valid height value.
    allow_stretch : bool
        Whether to allow "stretch" as a valid height value.
    additional_allowed : list[str] or None
        Additional string values to allow beyond the base allowed values.

    Raises
    ------
    StreamlitInvalidHeightError
        If the height value is invalid.
    r   r   r   N)r;   r<   r=   r   r>   extend)r/   r7   rB   rC   r?   r5   r5   r6   validate_heightZ   s    






rF   sizec                 C  s^   t | ttfst| t | trg d}| |vrt| dS t | tr+| dkr-t| dS dS )zValidate the size parameter for st.space.

    Parameters
    ----------
    size : Any
        The size value to validate.

    Raises
    ------
    StreamlitInvalidSizeError
        If the size value is invalid.
    r   r   N)r;   r<   r=   r
   )rG   r?   r5   r5   r6   validate_space_size   s   
rH   Width | SpaceSizer   c                 C  ^   t  }t| tr| tv rt|  |_|S t| ttfr!t| |_|S | dkr*d|_|S d|_	|S Nr   T)
r   r;   r=   SIZE_TO_REM_MAPPING	rem_widthr<   floatpixel_widthuse_contentuse_stretch)r.   width_configr5   r5   r6   get_width_config      

rS   Height | SpaceSizer   c                 C  rJ   rK   )
r   r;   r=   rL   
rem_heightr<   rN   pixel_heightrP   rQ   )r/   height_configr5   r5   r6   get_height_config   rT   rY   gap
str | Noneelement_typer=   GapSize.ValueTypec                 C  sX   t jt jt jd}t| tr|  }| }||v r|| S n| du r&t jS t	| |d)z6Convert a gap string or None to a GapSize proto value.r   N)rZ   r\   )
r   SMALLMEDIUMLARGEr;   r=   lowerkeysNONEr   )rZ   r\   gap_mappinggap_sizevalid_sizesr5   r5   r6   get_gap_size   s   
rg   horizontal_alignmentc                 C     g d}| |vrt | dd S )Nr    st.container)r	   )rh   valid_horizontal_alignmentsr5   r5   r6   validate_horizontal_alignment   s   rl   vertical_alignmentc                 C  ri   )Nr&   rj   )r   )rm   valid_vertical_alignmentsr5   r5   r6   validate_vertical_alignment   s   
ro   r0   c                 C  s   g d}| |vrt | dS )a	  Validate the text_alignment parameter.

    Parameters
    ----------
    text_alignment : TextAlignment
        The text alignment value to validate.

    Raises
    ------
    StreamlitInvalidTextAlignmentError
        If the text_alignment value is invalid.
    r*   N)r   )r0   valid_alignmentsr5   r5   r6   validate_text_alignment   s   rq   startr"   endspace_between)r!   r"   r#   r'   r(   r$   	alignment'HorizontalAlignment | VerticalAlignment%Block.FlexContainer.Justify.ValueTypec                 C  sb   g d}t |  }||vrtjjjS |dv r$tdttjjd|  S tdttjj|  S )N)rr   r"   rs   rt   rr   rs   r"   rw   JUSTIFY_)map_to_flex_terminologyr   FlexContainerJustifyJUSTIFY_UNDEFINEDr   getattrupper)ru   valid_justifyr+   r5   r5   r6   get_justify   s   
r   #Block.FlexContainer.Align.ValueTypec                 C  s@   g d}t |  }||vrtjjjS tdttjjd|  S )Nrx   r   ALIGN_)rz   r   r{   AlignALIGN_UNDEFINEDr   r~   r   )ru   valid_alignalignr5   r5   r6   	get_align  s   
r   r   c                 C  s2   t jjt jjt jjt jjd}t  }||  |_|S )a  Convert text alignment string to proto config.

    Parameters
    ----------
    text_alignment : TextAlignment
        The text alignment value ("left", "center", "right", "justify").

    Returns
    -------
    TextAlignmentConfig
        Proto message with alignment set.
    r*   )r   	AlignmentLEFTCENTERRIGHTJUSTIFYru   )r0   alignment_mappingconfigr5   r5   r6   get_text_alignment_config  s   
r   )F)r.   r   r7   r8   r9   r:   )FTN)
r/   rA   r7   r8   rB   r8   rC   rD   r9   r:   )rG   r   r9   r:   )r.   rI   r9   r   )r/   rU   r9   r   )rZ   r[   r\   r=   r9   r]   )rh   r%   r9   r:   )rm   r)   r9   r:   )r0   r,   r9   r:   )ru   rv   r9   rw   )ru   rv   r9   r   )r0   r,   r9   r   )4
__future__r   dataclassesr   typingr   r   r   streamlit.errorsr   r   r	   r
   r   r   r   streamlit.proto.Block_pb2r   streamlit.proto.GapSize_pb2r    streamlit.proto.HeightConfig_pb2r   'streamlit.proto.TextAlignmentConfig_pb2r   streamlit.proto.WidthConfig_pb2r   r<   r   r4   r   r   r   r   r   r%   r)   r,   rL   r-   r@   rF   rH   rS   rY   rg   rl   ro   rq   rz   r   r   r   r5   r5   r5   r6   <module>   s\   $	
+








