
    &ex"                     X   d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
 d dl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 d dlmZmZ d dlmZm Z m!Z!m"Z" d dl#m$Z$ d dl%m&Z&m'Z' d dl(m)Z)m*Z*m+Z+m,Z, erd dl-m.Z. ee'e&df         Z/e G d d                      Z0 G d d          Z1dS )    )	dataclass)dedent)TYPE_CHECKINGOptionalUnioncast)current_form_id)check_callback_rulescheck_session_state_rules get_label_visibility_proto_value)_get_upload_files)CameraInput)FileUploaderState)UploadedFileInfo)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsregister_widget)compute_widget_id)DeletedFileUploadedFile)KeyLabelVisibilitymaybe_raise_label_warningsto_key)DeltaGeneratorNc                   >    e Zd ZdedefdZdee         dedefdZdS )CameraInputSerdesnapshotreturnc                    t                      }|t          |t                    r|S |j                                        }|j        |_        |j        |_        |j        |_        |j        	                    |j
                   |S )N)FileUploaderStateProto
isinstancer   uploaded_file_infoaddfile_idnamesize	file_urlsCopyFrom
_file_urls)selfr"   state_proto	file_infos       Glib/python3.11/site-packages/streamlit/elements/widgets/camera_input.py	serializezCameraInputSerde.serialize1   s{     -..z(K@@+6+I+M+M+O+O	$,	!	!	$$X%8999    ui_value	widget_idc                 `    t          |          }t          |          dk    rd }n|d         }|S )Nr   )r   len)r/   r5   r6   upload_filesreturn_values        r2   deserializezCameraInputSerde.deserializeB   s:     )22|!!LL'?Lr4   N)	__name__
__module____qualname__SomeUploadedSnapshotFiler%   r3   r   strr;    r4   r2   r!   r!   /   sl        * 
    " !78EH	!     r4   r!   c                   j   e Zd Z ed          	 	 	 	 	 dddddedee         dee         d	ee         d
ee         dee	         de
dedee         fd            Z	 	 	 	 	 ddddddedee         dee         d	ee         d
ee         dee	         de
dedee         dee         fdZedd            ZdS )CameraInputMixincamera_inputNFvisible)disabledlabel_visibilitylabelkeyhelp	on_changeargskwargsrF   rG   r#   c                Z    t                      }	|                     |||||||||		  	        S )a&  Display a widget that returns pictures from the user's webcam.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this widget is used for.
            The label can optionally contain Markdown and supports the following
            elements: Bold, Italics, Strikethroughs, Inline Code, Emojis, and Links.

            This also supports:

            * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
              For a list of all supported codes,
              see https://share.streamlit.io/streamlit/emoji-shortcodes.

            * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
              must be on their own lines). Supported LaTeX functions are listed
              at https://katex.org/docs/supported.html.

            * Colored text, using the syntax ``:color[text to be colored]``,
              where ``color`` needs to be replaced with any of the following
              supported colors: blue, green, orange, red, violet, gray/grey, rainbow.

            Unsupported elements are unwrapped so only their children (text contents) render.
            Display unsupported elements as literal characters by
            backslash-escaping them. E.g. ``1\. Not an ordered list``.

            For accessibility reasons, you should never set an empty label (label="")
            but hide it with label_visibility if needed. In the future, we may disallow
            empty labels by raising an exception.

        key : str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. Multiple widgets of the same type may
            not share the same key.

        help : str
            A tooltip that gets displayed next to the camera input.

        on_change : callable
            An optional callback invoked when this camera_input's value
            changes.

        args : tuple
            An optional tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        disabled : bool
            An optional boolean, which disables the camera input if set to
            True. Default is False.
        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. If "hidden", the label doesn't show but there
            is still empty space for it above the widget (equivalent to label="").
            If "collapsed", both the label and the space are removed. Default is
            "visible".

        Returns
        -------
        None or UploadedFile
            The UploadedFile class is a subclass of BytesIO, and therefore
            it is "file-like". This means you can pass them anywhere where
            a file is expected.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> picture = st.camera_input("Take a picture")
        >>>
        >>> if picture:
        ...     st.image(picture)

        )	rH   rI   rJ   rK   rL   rM   rF   rG   ctx)r   _camera_input)
r/   rH   rI   rJ   rK   rL   rM   rF   rG   rO   s
             r2   rD   zCameraInputMixin.camera_inputN   sH    r !""!!- " 

 

 
	
r4   )rF   rG   rO   rO   c                   t          |          }t          | j        |           t          d |d           t	          ||           t          d||||t          | j                  |	r|	j        nd           }
t                      }|
|_	        ||_
        t          | j                  |_        ||_        t          |          |j        _        |t!          |          |_        t%                      }t'          d||||||j        |j        |		  	        }| j                            d|           t/          |j        t0                    rd S |j        S )NF)default_valuerI   writes_allowedrD   )user_keyrH   rI   rJ   form_idpage)rT   on_change_handlerrL   rM   deserializer
serializerrO   )r   r
   dgr   r   r   r	   page_script_hashCameraInputProtoidrH   rU   rF   r   rG   valuer   rJ   r!   r   r;   r3   _enqueuer&   r   )r/   rH   rI   rJ   rK   rL   rM   rF   rG   rO   r]   camera_input_protoserdecamera_input_states                 r2   rP   zCameraInputMixin._camera_input   sr    SkkTWi000!#eTTTT"5*:;;;#DG,,),6%%$
 
 
 .// "#( %4TW%=%="&.#4T5
 5
+1 &,Tll# "",'*

 

 

 	);<<<(.<< 	4!''r4   r   c                 "    t          d|           S )zGet our DeltaGenerator.r   )r   )r/   s    r2   rZ   zCameraInputMixin.dg   s     $d+++r4   )NNNNN)r#   r   )r<   r=   r>   r   r@   r   r   r   r   r   boolr   r   rD   r   rP   propertyrZ   rA   r4   r2   rC   rC   M   s       ^N## "".2%))-c
 ,5c
 c
 c
c
 c]c
 sm	c

 N+c
 z"c
 &c
 c
 *c
 
,	c
 c
 c
 $#c
P "".2%))-:( ,5*.:( :( :(:( c]:( sm	:(
 N+:( z":( &:( :( *:( &':( 
,	:( :( :( :(x , , , X, , ,r4   rC   )2dataclassesr   textwrapr   typingr   r   r   r   streamlit.elements.formr	   streamlit.elements.utilsr
   r   r   (streamlit.elements.widgets.file_uploaderr   streamlit.proto.CameraInput_pb2r   r\   streamlit.proto.Common_pb2r   r%   r   UploadedFileInfoProtostreamlit.runtime.metrics_utilr   streamlit.runtime.scriptrunnerr   r   streamlit.runtime.stater   r   r   r   streamlit.runtime.state.commonr   'streamlit.runtime.uploaded_file_managerr   r   streamlit.type_utilr   r   r   r   streamlit.delta_generatorr   r?   r!   rC   rA   r4   r2   <module>rv      s0   " ! ! ! ! !       7 7 7 7 7 7 7 7 7 7 7 7 3 3 3 3 3 3         
 G F F F F F K K K K K K R R R R R R P P P P P P 9 9 9 9 9 9 O O O O O O O O            = < < < < < M M M M M M M M X X X X X X X X X X X X 9888888 {D!@A         :f, f, f, f, f, f, f, f, f, f,r4   