
    ȯei                    $   U d dl mZ d dlZ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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mZ d dl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/m0Z0 d dl1m2Z2m3Z3 d dl4m5Z5m6Z6m7Z7m8Z8m9Z9 d dl:m;Z; erd dl<m=Z= e	ez  e>z  ed   z  Z?de@d<   eez  e	z  e>z  ed   z  ZAde@d<   eAdz  ZBde@d<   eez  e>z  ed   z  dz  ZCde@d<   eCeeC   z  ZDde@d<   eEd   eEe   z  eEeef   z  ZFde@d<   eeFz  dz  ZGde@d<   d ZHd!e@d"<    ej                  d#      ZJd!e@d$<   d%ZKd!e@d&<    e	d d '      ZLd!e@d(<    e	d)d*'      ZMd!e@d+<   dGd,ZN	 	 	 	 dHd-ZOdId.ZP	 	 	 	 	 	 dJd/ZQ	 	 	 	 	 	 dKd0ZRdLd1ZSdMd2ZTdNd3ZUdOd4ZV	 	 	 	 	 	 	 	 dPd5ZWdQd6ZXdQd7ZYdRd8ZZ ed9:       G d; d<             Z[ ed9:       G d= d>             Z\e G d? d@             Z]e G dA dB             Z^e G dC dD             Z_ G dE dF      Z`y)S    )annotationsN)Sequence)	dataclass)datedatetimetime	timedelta)dedent)TYPE_CHECKINGAnyFinalLiteral	TypeAliascastoverload)current_form_id)LayoutConfigWidthWithoutContentvalidate_width)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)StreamlitAPIException)	DateInput)DateTimeInput)	TimeInput)gather_metrics)ScriptRunContextget_script_run_ctx)
WidgetArgsWidgetCallbackWidgetKwargsget_session_stateregister_widget)adjust_years)DeltaGeneratornowr   	TimeValueDateTimeScalarValueDateTimeValuetodayNullableScalarDateValue	DateValue DateWidgetRangeReturnDateWidgetReturn   r   DEFAULT_STEP_MINUTESzB^(YYYY[/.\-]MM[/.\-]DD|DD[/.\-]MM[/.\-]YYYY|MM[/.\-]DD[/.\-]YYYY)$ALLOWED_DATE_FORMATSz%Y/%m/%d, %H:%M_DATETIME_UI_FORMAT)hourminute_DEFAULT_MIN_BOUND_TIME   ;   _DEFAULT_MAX_BOUND_TIMEc                   | dk(  r3t        j                         j                         j                  dd      S t	        | t
              r	 t        j                  |       S t	        | t               r!| j                         j                  dd      S t	        | t              r| S t        d      # t        $ rI 	 t        j                  |       j                         j                  dd      cY S # t        $ r Y nw xY wY w xY w)Nr+   r   secondmicrosecondzEThe type of value should be one of datetime, time, ISO string or None)	r   r+   r   replace
isinstancestrfromisoformat
ValueErrorr   values    i/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/streamlit/elements/widgets/time_widgets.py_convert_timelike_to_timerK   [   s    ~||~""$,,A1,EE%	%%e,, %"zz|##1!#<<%
O #  		**51TVWA1W5
  		s6   
B- -	C?73C-*C?-	C96C?8C99C?>C?c                   t        | t              r| j                         S t        | t              r| S | dv r"t        j                         j                         S t        | t              r	 t        j
                  |       S t        d      # t        $ rB 	 t        j
                  |       j                         cY S # t        $ r Y nw xY wY t        d      w xY w)N>   r/   zHDate value should either be an date/datetime or an ISO string or "today")rD   r   r   r+   rE   rF   rG   r   rH   s    rJ   _convert_datelike_to_daterM   y   s     %"zz|%	||~""$$%	%%e,,  R   	--e499;; 
R 	s6   *B
 
	C"B96C9	CCCCCc                    | yt        | t              rt        | t              sd}| }nd}t        d|       g}t	        |      dvrt        d      |D cg c]  }t        |       }}||fS c c}w )N)NFTFr0   >   r         z_DateInput value should either be an date/datetime or a list/tuple of 0 - 2 date/datetime values)rD   r   rE   r   lenr   rM   )rI   is_rangevalue_tuplevparsed_datess        rJ   _parse_date_valuerV      s    } %":eS+A5u=>
;y(#)
 	

 ;FFQ-a0FLF!! Gs   A,c                    t        | t        t        t        f      rt	        |       }|S | 5|rt        |d   d      }|S t        t        j                         d      }|S t        d      )Nr   yearsz6DateInput min should either be a date/datetime or NonerD   r   r   rE   rM   r)   r/   r   )	min_valuerU   parsed_min_dates      rJ   _parse_min_dater^      sx    
 )hc233I>  
	*<?#FO  +4::<sCO
  $D
 	
    c                    t        | t        t        t        f      rt	        |       }|S | 5|rt        |d   d      }|S t        t        j                         d      }|S t        d      )N
   rY   z6DateInput max should either be a date/datetime or Noner[   )	max_valuerU   parsed_max_dates      rJ   _parse_max_datere      sy    
 )hc233I>  
	*<+;2FO  +4::<rBO
  $D
 	
r_   c                *    | j                  ddd      S )z>Return a time without seconds, microseconds, or timezone info.r   N)rA   rB   tzinfo)rC   rH   s    rJ   _normalize_timerh      s    ==q=>>r_   c                d    | j                   | j                  d      } | j                  dd      S )zBReturn a datetime without seconds, microseconds, or timezone info.N)rg   r   r@   )rg   rC   rH   s    rJ   _normalize_datetime_valuerj      s/    ||T*==q=11r_   c                @    t        j                  | t        |            S )z3Combine a date and time into a normalized datetime.)r   combinerh   )component_datecomponent_times     rJ   _combine_date_timero      s    NON,KLLr_   c                N    	 t        j                  | |      S # t        $ r Y yw xY w)z6Try to parse a datetime string with a specific format.N)r   strptimerG   )rI   fmts     rJ   _try_parse_datetime_with_formatrs      s,      ,, s    	$$c                  t        |      }| dk(  rt        t        j                               S t	        | t              rt        |       S t	        | t
              rt	        | t              st        | |      S t	        | t              rt        ||       S t	        | t              r1| j                         }	 t        j                  |      }t        |      S t        d      # t        $ r Y nw xY wdD ]  }t        ||      }|t        |      c S  	 t        j                  |      }t        ||      S # t        $ r Y nw xY w	 t        j                  |      }t        ||      S # t        $ r Y t        d      w xY w)z=Convert supported datetime inputs into a normalized datetime.r+   )z%Y/%m/%d %H:%Mz%Y/%m/%d %H:%M:%Sz%Y-%m-%d %H:%Mz%Y-%m-%d %H:%M:%SzNThe type of value should be one of datetime, date, time, ISO string, or 'now'.)rh   rj   r   r+   rD   r   ro   r   rE   striprF   rG   rs   r   )	rI   fallback_datefallback_timestripped_value	parsed_dtrr   maybe_parsed_dtparsed_dateparsed_times	            rJ   !_convert_datetimelike_to_datetimer}      sw    $M2M~(88%"(//%z%'B!%77%!-77%	 ..~>I,Y774  X 3  		
 	BC >ncRO*0AA	B	,,^<K%k=AA 			,,^<K%m[AA 	
X 	s6   2C 	C)(C) D0 0	D<;D<  E! !	E76E7c                8    t        t        | d      t              S )NrX   rY   )ro   r)   r;   	base_dates    rJ   _default_min_datetimer   $  s    Yc*,C r_   c                8    t        t        | d      t              S )Nrb   rY   )ro   r)   r>   r   s    rJ   _default_max_datetimer   *  s    Yb)+B r_   c                >    t        |       j                  t              S N)rj   strftimer8   rH   s    rJ   _datetime_to_proto_stringr   0  s    $U+445HIIr_   T)frozenc                  V    e Zd ZU ded<   ded<   ded<   e	 	 	 	 	 	 	 	 d	d       Zd
dZy)_DateTimeInputValuesdatetime | NonerI   r   minmaxc                0   |d n#t        |t        j                         t              }||j                         nt        j                         }|t	        |      nt        ||t              }|t        |      nt        ||t              } | |||      S )N)rv   rw   rI   r   r   )r}   r   r/   r;   r   r   r>   )clsrI   r\   rc   parsed_valuebase_date_for_bounds
parsed_min
parsed_maxs           rJ   from_raw_valuesz$_DateTimeInputValues.from_raw_values:  s     } 2"jjl5 	 $0#;L 	   ""67225 	   ""67225 	 
 	
r_   c           	     f   | j                   | j                  kD  r&t        d| j                    d| j                   d      | j                  f| j                  | j                   k  s| j                  | j                  kD  r3t        d| j                   d| j                    d| j                   d      y y )NThe `min_value`, set to 3, shouldn't be larger than the `max_value`, set to .The default `value` of % must lie between the `min_value` of  and the `max_value` of , inclusively.r   r   r   rI   selfs    rJ   __post_init__z"_DateTimeInputValues.__post_init__i  s    88dhh'*488* 5004z< 
 ::!tzzDHH'<

TXX@U')$** 6hhZ7zQ  AV!r_   N)rI   r.   r\   r.   rc   r.   returnr   r   None__name__
__module____qualname____annotations__classmethodr   r   r2   r_   rJ   r   r   4  sP    	M	M,
,
 !,
 !	,

 
,
 ,
\r_   r   c                  `    e Zd ZU ded<   ded<   ded<   ded<   e	 	 	 	 	 	 	 	 dd       Zdd	Zy
)_DateInputValuesSequence[date] | NonerI   boolrR   r   r   r   c                    t        |      \  }}t        ||      }t        ||      }|dk(  rt        d|      d   }||k  r|g}||kD  r|g} | ||||      S )NrH   )r\   rU   )rc   rU   r/   z
list[date]r   )rI   rR   r   r   )rV   r^   re   r   )	r   rI   r\   rc   r   rR   r   r   rT   s	            rJ   r   z _DateInputValues.from_raw_values~  s     "3!?h$%

 %%


 G\<03A:~ *|:~ *|	
 	
r_   c           	     z   | j                   | j                  kD  r&t        d| j                    d| j                   d      | j                  rp| j                  d   }| j                  d   }|| j                   k  s|| j                  kD  r3t        d| j                   d| j                    d| j                   d	      y y )
Nr   r   r   r   ra   r   r   r   r   r   )r   start_value	end_values      rJ   r   z_DateInputValues.__post_init__  s    88dhh'*488* 5004z< 
 ::**Q-K

2Idhh&I,@+-djj\ :;;?88* E..2hhZ~G  -A	 r_   N)rI   r1   r\   r0   rc   r0   r   r   r   r   r2   r_   rJ   r   r   w  sT      N	I	I

 +
 +	

 

 
<r_   r   c                  <    e Zd ZU ded<   ded<   ded<   d	dZd
dZy)DateTimeInputSerder   rI   r   r   r   c                    |`t        |      dkD  rRt        t        j                  |d   t                    }|| j
                  k  s|| j                  kD  r| j                  S |S | j                  S )Nr   )rQ   rj   r   rq   r8   r   r   rI   )r   ui_valuedeserializeds      rJ   deserializezDateTimeInputSerde.deserialize  se    CMA$54!!(1+/BCL
 dhh&,*Azz!zzr_   c                "    |g S t        |      gS r   )r   r   rT   s     rJ   	serializezDateTimeInputSerde.serialize  s    9I)!,--r_   N)r   zlist[str] | Noner   r   )rT   r   r   	list[str]r   r   r   r   r   r   r2   r_   rJ   r   r     s    	M	M
.r_   r   c                  (    e Zd ZU ded<   ddZddZy)TimeInputSerdetime | NonerI   c                f    |$t        j                  |d      j                         S | j                  S N%H:%M)r   rq   r   rI   )r   r   s     rJ   r   zTimeInputSerde.deserialize  s8     # h0557	
 	
r_   c                t    |y t        |t              r|j                         }t        j                  |d      S r   )rD   r   r   r   r   s     rJ   r   zTimeInputSerde.serialize  s0    9a"A}}Q((r_   N)r   
str | Noner   r   )rT   zdatetime | time | Noner   r   r   r2   r_   rJ   r   r     s    
)r_   r   c                  (    e Zd ZU ded<   ddZddZy)DateInputSerder   rI   c                   |t        d |D              }n| j                  j                  }|t        |      dk(  r| j                  j                  rdS d S | j                  j                  s|d   S t	        dt        |            S )Nc              3  d   K   | ](  }t        j                  |d       j                          * yw)%Y/%m/%dN)r   rq   r   ).0rT   s     rJ   	<genexpr>z-DateInputSerde.deserialize.<locals>.<genexpr>  s+      !<=!!!Z0557!s   .0r   r2   r4   )tuplerI   rQ   rR   r   )r   r   return_values      rJ   r   zDateInputSerde.deserialize  s      !AI! L  ::++L3|#4#9,,26$6zz""?"&l(;<<r_   c                    |g S t        |t              rt        |      n|g}|D cg c]  }t        j                  |d       c}S c c}w )Nr   )rD   r   listr   r   )r   rT   to_serializes      rJ   r   zDateInputSerde.serialize  sA    9I",Q"9tAws6BCa,CCCs   AN)r   r   r   r4   )rT   r4   r   r   r   r2   r_   rJ   r   r     s    = Dr_   r   c                     e Zd Ze	 	 	 	 	 	 ddd ee      dd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd       Ze	 	 	 	 	 	 d dd ee      dd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!d       Z ed	      	 	 	 	 	 	 ddd ee      dd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"d
       Z	 	 	 	 	 	 ddd ee      ddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZe	 	 d$dddddd ee      dddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%d       Z	e	 	 	 d&dddddd ee      dddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'd       Z	 ed      	 	 	 d&dddddd ee      dddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d       Z		 	 	 d&dddddd ee      ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)dZ
e	 	 	 	 	 	 	 	 d*ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d       Ze	 	 	 	 	 	 	 d,ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-d       Ze	 	 	 	 	 	 	 d,ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d.d       Z ed      	 	 	 	 	 	 	 	 d*ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/d       Z	 	 	 	 	 	 	 	 d*dddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d0dZed1d       Zy)2TimeWidgetsMixinNFvisible)minutesstretch)disabledlabel_visibilitystepwidthc                    y r   r2   r   labelrI   keyhelp	on_changeargskwargsr   r   r   r   s               rJ   
time_inputzTimeWidgetsMixin.time_input        	r_   c                    y r   r2   r   s               rJ   r   zTimeWidgetsMixin.time_input
  r   r_   r   c               P    t               }| j                  |||||||||	|
||      S )a  Display a time input widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this time input is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown 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"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

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

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        value : "now", datetime.time, datetime.datetime, str, or None
            The value of this widget when it first renders. This can be one of
            the following:

            - ``"now"`` (default): The widget initializes with the current time.
            - A ``datetime.time`` or ``datetime.datetime`` object: The widget
              initializes with the given time, ignoring any date if included.
            - An ISO-formatted time (hh:mm[:ss.sss]) or datetime
              (YYYY-MM-DD hh:mm[:ss]) string: The widget initializes with the
              given time, ignoring any date if included.
            - ``None``: The widget initializes with no time and returns
              ``None`` until the user selects a time.

        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. No two widgets may have the same key.

        help : str or None
            A tooltip that gets displayed next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

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

        args : list or tuple
            An optional list or 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 that disables the time input if set to
            ``True``. The default is ``False``.

        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget aligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        step : int or timedelta
            The stepping interval in seconds. This defaults to ``900`` (15
            minutes). You can also pass a ``datetime.timedelta`` object. The
            value must be between 60 seconds and 23 hours.

        width : "stretch" or int
            The width of the time input widget. This can be one of the following:

            - ``"stretch"`` (default): The width of the widget matches the
              width of the parent container.
            - An integer specifying the width in pixels: The widget has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the widget matches the width
              of the parent container.

        Returns
        -------
        datetime.time or None
            The current value of the time input widget or ``None`` if no time has been
            selected.

        Example
        -------
        **Example 1: Basic usage**

        >>> import datetime
        >>> import streamlit as st
        >>>
        >>> t = st.time_input("Set an alarm for", datetime.time(8, 45))
        >>> st.write("Alarm is set for", t)

        .. output::
           https://doc-time-input.streamlit.app/
           height: 260px

        **Example 2: Empty initial value**

        To initialize an empty time input, use ``None`` as the value:

        >>> import datetime
        >>> import streamlit as st
        >>>
        >>> t = st.time_input("Set an alarm for", value=None)
        >>> st.write("Alarm is set for", t)

        .. output::
           https://doc-time-input-empty.streamlit.app/
           height: 260px

        )r   rI   r   r   r   r   r   r   r   r   r   ctx)r#   _time_input)r   r   rI   r   r   r   r   r   r   r   r   r   r   s                rJ   r   zTimeWidgetsMixin.time_input  sI    T !"-   
 	
r_   )r   r   r   r   r   c                  t        |      }t        | j                  |||dk7  r|nd        t        ||	       |d n
t	        |      }t        d|dh| j                  |t        |t        t        f      r|n|||
|	      }~t               j                  }|||v r||   d }t               }||_        ||_        |t        j                  |d      |_        t!        | j                        |_        t        |
t$        t&        f      st)        dt+        |
       d      t        |
t&              r|
j,                  }
|
d	k  s|
t'        d
      j,                  kD  rt)        d|
 d      |
|_        ||_        t3        |	      |j4                  _        |t9        |      |_        t=        |      }t?        |j                  ||||j@                  |jB                  |d      }|jD                  r+|jC                  |j6                        x}||_        d|_#        tI        |       tK        |      }| j                  jM                  d||       |j6                  S )Nr+   default_valuer   r   )user_keykey_as_main_identitydgr   rI   r   r   r   r   ,`step` can only be `int` or `timedelta` but  is provided.<   r<   hoursG`step` must be between 60 seconds and 23 hours but is currently set to 	 seconds.string_valueon_change_handlerr   r   deserializer
serializerr   
value_typeTr   layout_config)'r   r   r   r   rK   r   rD   r   r   r'   filtered_stateTimeInputProtoidr   r   defaultr   form_idintr	   r   typesecondsr   r   r   r   rI   r
   r   r   r(   r   r   value_changed	set_valuer   r   _enqueue)r   r   rI   r   r   r   r   r   r   r   r   r   r   r|   
element_idsession_statetime_input_protoserdewidget_stateserialized_valuer   s                        rJ   r   zTimeWidgetsMixin._time_input  sa     SkGG#(E>%t		
 	#5*:; $md1J51Q4 #)ww!+EHd3C!D+%

 )+::?sm3c8J8RK)+(!&"'+}}[''J$#2477#; $i 01'>tDzl-X  dI&<<D"9yr2:::'YZ^Y__hi  !%$,!2R3
))/ $*4L!{+&'**%	
 %%$)OOL4F4F$GG T)9 &)-&u$51'7}U!!!r_   z
YYYY/MM/DD)
r   r   r   r   r   formatr   r   r   r   c       
             y r   r2   r   r   rI   r\   rc   r   r   r   r   r   r  r   r   r   r   s                  rJ   datetime_inputzTimeWidgetsMixin.datetime_input  s    $ r_   c       
             y r   r2   r  s                  rJ   r  zTimeWidgetsMixin.datetime_input*  s    $ r_   r  c       
        V    t               }| j                  |||||||||	|
|||||      S )a  Display a date and time input widget.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this datetime input is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown 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"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

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

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
            The value of this widget when it first renders. This can be one of
            the following:

            - ``"now"`` (default): The widget initializes with the current date and time.
            - A ``datetime.datetime`` object: The widget initializes with the given
              datetime, stripping any timezone information.
            - A ``datetime.date`` object: The widget initializes with the given date
              at 00:00.
            - A ``datetime.time`` object: The widget initializes with today's date
              and the provided time.
            - An ISO-formatted datetime (YYYY-MM-DD hh:mm[:ss]) or date/time
              string: The widget initializes with the parsed value.
            - ``None``: The widget initializes with no value and returns ``None``
              until the user selects a datetime.

        min_value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
            The minimum selectable datetime. This can be any of the datetime
            types accepted by ``value``.

            If this is ``None`` (default), the minimum selectable datetime is
            ten years before the initial value. If no initial value is set, the
            minimum selectable datetime is ten years before today at 00:00.

        max_value : "now", datetime.datetime, datetime.date, datetime.time, str, or None
            The maximum selectable datetime. This can be any of the datetime
            types accepted by ``value``.

            If this is ``None`` (default), the maximum selectable datetime is
            ten years after the initial value. If no initial value is set, the
            maximum selectable datetime is ten years after today at 23:59.

        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. No two widgets may have the same key.

        help : str or None
            A tooltip that gets displayed next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

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

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

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

        format : str
            A format string controlling how the interface displays dates.
            Supports ``"YYYY/MM/DD"`` (default), ``"DD/MM/YYYY"``, or ``"MM/DD/YYYY"``.
            You may also use a period (.) or hyphen (-) as separators. This
            doesn't affect the time format.

        step : int or timedelta
            The stepping interval in seconds. This defaults to ``900`` (15
            minutes). You can also pass a ``datetime.timedelta`` object. The
            value must be between 60 seconds and 23 hours.

        disabled : bool
            An optional boolean that disables the widget if set to ``True``.
            The default is ``False``.

        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget aligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        width : "stretch" or int
            The width of the widget. This can be one of the following:

            - ``"stretch"`` (default): The width of the widget matches the width
              of the parent container.
            - An integer specifying the width in pixels: The widget has a fixed
              width. If the specified width is greater than the width of the
              parent container, the widget matches the container width.

        Returns
        -------
        datetime.datetime or None
            The current value of the datetime input widget (without timezone)
            or ``None`` if no value has been selected.

        Examples
        --------
        **Example 1: Basic usage**

        >>> import datetime
        >>> import streamlit as st
        >>>
        >>> event_time = st.datetime_input(
        ...     "Schedule your event",
        ...     datetime.datetime(2025, 11, 19, 16, 45),
        ... )
        >>> st.write("Event scheduled for", event_time)

        .. output::
           https://doc-datetime-input.streamlit.app/
           height: 500px

        **Example 2: Empty initial value**

        To initialize an empty datetime input, use ``None`` as the value:

        >>> import datetime
        >>> import streamlit as st
        >>>
        >>> event_time = st.datetime_input("Schedule your event", value=None)
        >>> st.write("Event scheduled for", event_time)

        .. output::
           https://doc-datetime-input-empty.streamlit.app/
           height: 500px

        )r   rI   r\   rc   r   r   r   r   r   r  r   r   r   r   r   )r#   _datetime_input)r   r   rI   r\   rc   r   r   r   r   r   r  r   r   r   r   r   s                   rJ   r  zTimeWidgetsMixin.datetime_input>  sR    P !"##- $ 
 	
r_   )r   r   r   r   r   r  r   r   r   r   r   c               >   t        |      }t        | j                  |||dk7  r|nd        t        ||       t        j                  |||      }|j                  }t        |j                        }t        |j                        }t        |t        t        t        f      r|d n
t        |      }n|}t        d|h d| j                  ||||||
||      }~t        t         j#                  |
            st%        d|
 d      t        |t&        t(        f      st%        d	t+        |       d
      t        |t(              rt'        |j-                               n|}|dk  s|t)        d      j.                  kD  rt%        d| d      t1               j2                  }|}|||v r||   d }t5               }||_        ||_        |t        |      g|j:                  d d  ||_        ||_	        t=        | j                        |_        ||_         ||_!        tE        |      |jF                  _        |
|_$        d|_%        |tM        |      |_'        tQ        ||j                  |j                        }tS        |j6                  |||	|jT                  |jV                  |d      }|jX                  r/|jW                  |j                        |j                  d d  d|_-        t]        |       t_        |      }| j                  ja                  d||       |j                  S )Nr+   r   rI   r\   rc   date_time_input>   r   r  rc   r\   )r   r   r   r   rI   r\   rc   r   r  r   r   The provided format (`z`) is not valid. DateTimeInput format should be one of `YYYY/MM/DD`, `DD/MM/YYYY`, or `MM/DD/YYYY` and can also use a period (.) or hyphen (-) as separators.r   r   r   r<   r   r   r   Fr   string_array_valuer   Tr   r   )1r   r   r   r   r   r   rI   r   r   r   rD   r   r   r   r   r   r7   matchr   r  r	   r  total_secondsr  r'   r   DateTimeInputProtor  r   r  r   r  r   r   r   r   r  rR   r
   r   r   r(   r   r   r  r  r   r   r	  )r   r   rI   r\   rc   r   r   r   r   r   r  r   r   r   r   r   datetime_valuesr   min_value_protomax_value_protovalue_for_idr
  step_secondsr  default_value_for_protodate_time_input_protor  r  r   s                                rJ   r  z TimeWidgetsMixin._datetime_input  sY   & SkGG#(E>%t		
 	#5*:;.>> ? 
 (--3O4G4GH3O4G4GHehd34 !( .}=  !L4 "Nww%%

  (..v67'( 1M M  $i 01'>tDzl-X  *4D))DC""$%$ 	 "yr/B/J/J J'YZfYggpq  *+::"/?sm3c8J8R&*# 2 4#- &+#".)*AB0!))!, %4!$3!(7(@%%1")1&7W8
..4 (.$).&)/!&")####

 '!$$'**+	
 %%-2__\=O=O-P!''*.2!+u$514M 	 	
 !!!r_   )r  r   r   r   c
                    y r   r2   r   r   rI   r\   rc   r   r   r   r   r   r  r   r   r   s                 rJ   
date_inputzTimeWidgetsMixin.date_input  s    " r_   c
                    y r   r2   r'  s                 rJ   r(  zTimeWidgetsMixin.date_input  s    " r_   c
                    y r   r2   r'  s                 rJ   r(  zTimeWidgetsMixin.date_input  s    & !$r_   r(  c
               T    t               }| j                  |||||||||	|||
||      S )aw  Display a date input widget.

        The date input widget can be configured to accept a single date or a
        date range. The first day of the week is determined from the user's
        locale in their browser.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this date input is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown 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"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

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

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        value : "today", datetime.date, datetime.datetime, str, list/tuple of these, or None
            The value of this widget when it first renders. This can be one of
            the following:

            - ``"today"`` (default): The widget initializes with the current date.
            - A ``datetime.date`` or ``datetime.datetime`` object: The widget
              initializes with the given date, ignoring any time if included.
            - An ISO-formatted date (YYYY-MM-DD) or datetime
              (YYYY-MM-DD hh:mm:ss) string: The widget initializes with the
              given date, ignoring any time if included.
            - A list or tuple with up to two of the above: The widget will
              initialize with the given date interval and return a tuple of the
              selected interval. You can pass an empty list to initialize the
              widget with an empty interval or a list with one value to
              initialize only the beginning date of the iterval.
            - ``None``: The widget initializes with no date and returns
              ``None`` until the user selects a date.

        min_value : "today", datetime.date, datetime.datetime, str, or None
            The minimum selectable date. This can be any of the date types
            accepted by ``value``, except list or tuple.

            If this is ``None`` (default), the minimum selectable date is ten
            years before the initial value. If the initial value is an
            interval, the minimum selectable date is ten years before the start
            date of the interval. If no initial value is set, the minimum
            selectable date is ten years before today.

        max_value : "today", datetime.date, datetime.datetime, str, or None
            The maximum selectable date. This can be any of the date types
            accepted by ``value``, except list or tuple.

            If this is ``None`` (default), the maximum selectable date is ten
            years after the initial value. If the initial value is an interval,
            the maximum selectable date is ten years after the end date of the
            interval. If no initial value is set, the maximum selectable date
            is ten years after today.

        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. No two widgets may have the same key.

        help : str or None
            A tooltip that gets displayed next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

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

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

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

        format : str
            A format string controlling how the interface should display dates.
            Supports ``"YYYY/MM/DD"`` (default), ``"DD/MM/YYYY"``, or ``"MM/DD/YYYY"``.
            You may also use a period (.) or hyphen (-) as separators.

        disabled : bool
            An optional boolean that disables the date input if set to
            ``True``. The default is ``False``.

        label_visibility : "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget aligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        width : "stretch" or int
            The width of the date input widget. This can be one of the following:

            - ``"stretch"`` (default): The width of the widget matches the
              width of the parent container.
            - An integer specifying the width in pixels: The widget has a
              fixed width. If the specified width is greater than the width of
              the parent container, the width of the widget matches the width
              of the parent container.

        Returns
        -------
        datetime.date or a tuple with 0-2 dates or None
            The current value of the date input widget or ``None`` if no date has been
            selected.

        Examples
        --------
        **Example 1: Basic usage**

        >>> import datetime
        >>> import streamlit as st
        >>>
        >>> d = st.date_input("When's your birthday", datetime.date(2019, 7, 6))
        >>> st.write("Your birthday is:", d)

        .. output::
           https://doc-date-input.streamlit.app/
           height: 380px

        **Example 2: Date range**

        >>> import datetime
        >>> import streamlit as st
        >>>
        >>> today = datetime.datetime.now()
        >>> next_year = today.year + 1
        >>> jan_1 = datetime.date(next_year, 1, 1)
        >>> dec_31 = datetime.date(next_year, 12, 31)
        >>>
        >>> d = st.date_input(
        ...     "Select your vacation for next year",
        ...     (jan_1, datetime.date(next_year, 1, 7)),
        ...     jan_1,
        ...     dec_31,
        ...     format="MM.DD.YYYY",
        ... )
        >>> d

        .. output::
           https://doc-date-input1.streamlit.app/
           height: 380px

        **Example 3: Empty initial value**

        To initialize an empty date input, use ``None`` as the value:

        >>> import datetime
        >>> import streamlit as st
        >>>
        >>> d = st.date_input("When's your birthday", value=None)
        >>> st.write("Your birthday is:", d)

        .. output::
           https://doc-date-input-empty.streamlit.app/
           height: 380px

        )r   rI   r\   rc   r   r   r   r   r   r   r   r  r   r   )r#   _date_input)r   r   rI   r\   rc   r   r   r   r   r   r  r   r   r   r   s                  rJ   r(  zTimeWidgetsMixin.date_input  sO    @ !"-   
 	
r_   )r  r   r   r   r   c
                  t        |      }t        | j                  |||dk7  r|nd        t        ||       dd} ||      } ||      }|dk(  rd }n.t	        |t
              r|D cg c]
  } ||       }}n ||      }t        d|h d| j                  ||||||
|      }t        t        j                  |
            st        d|
 d      t        j                  |||	      }|dk(  r7t               j                  }|!||v r||   }t        j                  |||	      }~~~t               }||_        |j"                  |_        ||_        t'        |      |j(                  _        |
|_        ||_        |j*                  g |j0                  d d  n;|j*                  D cg c]  }t3        j4                  |d
       c}|j0                  d d  t3        j4                  |j6                  d
      |_        t3        j4                  |j8                  d
      |_        t;        | j                        |_        |t?        |      |_         tC        |      }tE        |j                   |||	|jF                  |jH                  |d      }|jJ                  r/|jI                  |j*                        |j*                  d d  d|_&        tO        |       tQ        |      }| j                  jS                  d||       |j*                  S c c}w c c}w )Nr/   r   c                    | dk(  ry t        | t              r| S t        | t              r$t        j                  | j                         d      S t        | t              rt        j                  | d      S y )Nr/   r   )rD   rE   r   r   r   )rT   s    rJ   parse_date_deterministic_for_idzETimeWidgetsMixin._date_input.<locals>.parse_date_deterministic_for_id  sZ    G|!S!!X&}}QVVXz::!T"}}Q
33r_   r(  >   r  rc   r\   )
r   r   r   r   rI   r\   rc   r   r  r   r  z`) is not valid. DateInput format should be one of `YYYY/MM/DD`, `DD/MM/YYYY`, or `MM/DD/YYYY` and can also use a period (.) or hyphen (-) as separators.r  r   r  r   Tr   r   )rT   r0   r   r   )*r   r   r   r   rD   r   r   r   r7   r  r   r   r   r'   r   DateInputProtor  rR   r   r   r   rI   r  r   r  r   r   r   r   r   r  r
   r   r   r(   r   r   r  r  r   r   r	  )r   r   rI   r\   rc   r   r   r   r   r   r  r   r   r   r   r/  r]   rd   parsedrT   r
  parsed_valuesr  state_valuedate_input_protor  r  r   s                               rJ   r,  zTimeWidgetsMixin._date_input  s-   $ SkGG#(G#3%		
 	#5*:;	 :)D9)D GFx(BGHQ5a8HFH4U;F 5 "Fww%%!

$ (..v67'( 1M M  )88 9 
 G ./>>M3-#7+C0 0 @ @%'' !A ! 9i)+($1$:$:!$,!2R3
))/ #)!&& +-$$Q' 7D6I6I+12a,+$$Q'  $}}]->->
K#}}]->->
K#2477#; $*4L!}-&'**+	
 %%(-8J8J(K""1%)-&u$51'7}U!!!K IL+s   (K>#Lc                    t        d|       S )zGet our DeltaGenerator.r*   )r   r   s    rJ   r   zTimeWidgetsMixin.dg)  s     $d++r_   )r+   NNNNN)r   rE   rI   r,   r   
Key | Noner   r   r   WidgetCallback | Noner   WidgetArgs | Noner   WidgetKwargs | Noner   r   r   r   r   int | timedeltar   r   r   r   )NNNNNN)r   rE   rI   r   r   r6  r   r   r   r7  r   r8  r   r9  r   r   r   r   r   r:  r   r   r   r   )r   rE   rI   TimeValue | Noner   r6  r   r   r   r7  r   r8  r   r9  r   r   r   r   r   r:  r   r   r   r   )r   rE   rI   r;  r   r6  r   r   r   r7  r   r8  r   r9  r   r   r   r   r   r:  r   r   r   ScriptRunContext | Noner   r   )NN)r   rE   rI   r   r\   r.   rc   r.   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r:  r   r   r   r   r   r   r   r   )r+   NN)r   rE   rI   r-   r\   r.   rc   r.   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r:  r   r   r   r   r   r   r   r   )r   rE   rI   r.   r\   r.   rc   r.   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r:  r   r   r   r   r   r   r   r   ) r   rE   rI   r.   r\   r.   rc   r.   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r:  r   r   r   r   r   r   r   r<  r   r   )r/   NNNNNNN)r   rE   rI   z(date | datetime | str | Literal['today']r\   r0   rc   r0   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r   r   r   r   r   r   r   )NNNNNNN)r   rE   rI   r   r\   r0   rc   r0   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r   r   r   r   r   r   zdate | None)r   rE   rI   zxtuple[NullableScalarDateValue] | tuple[NullableScalarDateValue, NullableScalarDateValue] | list[NullableScalarDateValue]r\   r0   rc   r0   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r   r   r   r   r   r   r3   )r   rE   rI   r1   r\   r0   rc   r0   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r   r   r   r   r   r   r4   )r   rE   rI   r1   r\   r0   rc   r0   r   r6  r   r   r   r7  r   r8  r   r9  r  rE   r   r   r   r   r   r   r   r<  r   r4   )r   r*   )r   r   r   r   r	   r6   r   r!   r   r  r  r(  r,  propertyr   r2   r_   rJ   r   r     s
    !+/"&&* ,5 )2F G%.  	
  )   $  *  # 
 "  +/"&&* ,5 )2F G%.  	
  )   $  *  # 
 " L! #(+/"&&*W
 ,5 )2F G%.W
W
  W
 	W

 W
 )W
  W
 $W
 W
 *W
 W
 #W
 
W
 "W
x #(+/"&&*^" ,5 )2F G%.'+^"^"  ^" 	^"
 ^" )^"  ^" $^" ^" *^" ^" #^" %^" 
^"@ 
 $(#' +/"&&*" )2F G,5%.!  !	
 !   )   $    *  #!" 
# &  &+#'#' +/"&&*" )2F G,5%.! # !	
 !   )   $    *  #!" 
# & $%  %#'#'x
 +/"&&*" )2F G,5%.!x
x
 x
 !	x

 !x
 x
 x
 )x
  x
 $x
 x
 x
 x
 *x
  #!x
" 
#x
 &x
z  %#'#'I" +/"&&*" )2F G,5%.'+#I"I" I" !	I"
 !I" I" I" )I"  I" $I" I" I" I" *I"  #!I"" %#I"$ 
%I"V  ;B-1-1+/"&&* #,5%. 8 +	
 +   )   $   * #  
! $ 
 .2-1+/"&&* #,5%.  +	
 +   )   $   * #  
! $  .2-1+/"&&*$ #,5%.#$$($ +$ +$ $ $ )$  $ $$ $ $  *!$" ##$$ 
%$ $( L! #-1-1+/"&&*O
 #,5%.O
O
 O
 +	O

 +O
 O
 O
 )O
  O
 $O
 O
 O
 *O
 #O
  
!O
 "O
h #-1-1+/"&&*V" #,5%.'+!V"V" V" +	V"
 +V" V" V" )V"  V" $V" V" V" *V" #V"  %!V"" 
#V"p , ,r_   r   )rI   r,   r   r   )rI   r0   r   r   )rI   r1   r   ztuple[list[date] | None, bool])r\   r0   rU   r   r   r   )rc   r0   rU   r   r   r   )rI   r   r   r   )rI   r   r   r   )rm   r   rn   r   r   r   )rI   rE   rr   rE   r   r   )rI   r-   rv   r   rw   r   r   r   )r   r   r   r   )rI   r   r   rE   )a
__future__r   recollections.abcr   dataclassesr   r   r   r   r	   textwrapr
   typingr   r   r   r   r   r   r   !streamlit.elements.lib.form_utilsr   #streamlit.elements.lib.layout_utilsr   r   r   streamlit.elements.lib.policiesr   r   streamlit.elements.lib.utilsr   r   r   r   r   streamlit.errorsr   streamlit.proto.DateInput_pb2r   r0  !streamlit.proto.DateTimeInput_pb2r   r  streamlit.proto.TimeInput_pb2r    r   streamlit.runtime.metrics_utilr!   streamlit.runtime.scriptrunnerr"   r#   streamlit.runtime.stater$   r%   r&   r'   r(   streamlit.time_utilr)   streamlit.delta_generatorr*   rE   r,   r   r-   r.   r0   r1   r   r3   r4   r6   compiler7   r8   r;   r>   rK   rM   rV   r^   re   rh   rj   ro   rs   r}   r   r   r   r   r   r   r   r   r   r2   r_   rJ   <module>rR     s   # 	 $ ! 4 4    > 
  3 E Q E 9 O  -8 h,wu~=	9 =!)D4!7#!=!N Y N.5y 5 &*H_s%:WW=M%MPT%T  T /:Q1RR	9 R $)9uT{#:U4:=N#N y N"%::TA ) A ! e  (bjjI e  / U .!%1Q!7  7!%2b!9  9<"	6"0&' 
&&' 
&?
2M
66 6 	6
 6rJ $? ? ?D $5 5 5p . . .. ) ) )$ D D D6u, u,r_   