
    dhL;                    d   U d dl mZ d dlZd dl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mZmZ ddl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"m#Z# ddl$m%Z% ddl&m'Z' erd dl(m)Z)  G d de      Z* G d de e      Z+e,dk(  rd dl-Z-d dl.Z.d dl/m0Z0 d dl	m1Z1mZm2Z2 ddl3m4Z4 ddlmZ ddl5m+Z+ ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z=  e       Z e;ddd !      Z: e=d"d#d$      Z<e<j}                  d%d&d'       d( e7d)      d*e<d+d,d-d.d/e: e9d0      g	Z? e0e?      Z@g d1ZA e+e2      5 ZBi ZCd3eDd4<    eEd5      D ]V  ZFeAeF eGeA      z     ZHeAD ]?  ZIeIeHk(  r
 e.j                  d6        e-j                  d d7      dk  rej                   eMe@             d8 e-jZ                         d9z  dz   z  eCeHeIf<    eGeC       eGeA      dz
  kD  r(eCj                   eOeCj                               d            e=d:;      Z<e<j                  d<       e<j                  d=       e<j                  d>       eCj                         D ],  \  \  ZSZTZUe<j}                  eSeT e'eUd?eUd@k  rdAndBC             . eBj                   e4j                  e<             B Y 	 ddd       yy# 1 sw Y   yxY w)D    )annotationsN)EventRLockThread)TracebackType)	IOTYPE_CHECKINGAnyCallableListOptionalTextIOTypecast   )get_console)ConsoleConsoleRenderableGroupRenderableType
RenderHook)Control)	FileProxy)JupyterMixin)
LiveRenderVerticalOverflowMethod)Screen)Text)Selfc                  4     e Zd ZdZd fdZddZddZ xZS )_RefreshThreadz3A thread that calls refresh() at regular intervals.c                `    || _         || _        t               | _        t        |   d       y )NT)daemon)liverefresh_per_secondr   donesuper__init__)selfr$   r%   	__class__s      W/var/www/html/vivango/api/ia/venv/lib/python3.12/site-packages/pip/_vendor/rich/live.pyr(   z_RefreshThread.__init__   s+    	"4G	%    c                8    | j                   j                          y N)r&   setr)   s    r+   stopz_RefreshThread.stop   s    		r,   c                f   | j                   j                  d| j                  z        s}| j                  j                  5  | j                   j                         s| j                  j                          d d d        | j                   j                  d| j                  z        s|y y # 1 sw Y   4xY w)Nr   )r&   waitr%   r$   _lockis_setrefreshr0   s    r+   runz_RefreshThread.run"   sz    ))..T%<%<!<= (yy'')II%%'( ))..T%<%<!<=( (s   5B''B0)r$   z'Live'r%   floatreturnNoner9   r:   )__name__
__module____qualname____doc__r(   r1   r7   __classcell__)r*   s   @r+   r!   r!      s    =&(r,   r!   c                      e Zd ZdZ	 ddddddddddd		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd	       Zdd
ZdddZddZ	ddZ
	 	 	 	 	 	 	 	 ddZddZddZedd       ZddddZddZ	 	 	 	 d dZy)!Livea  Renders an auto-updating live display of any given renderable.

    Args:
        renderable (RenderableType, optional): The renderable to live display. Defaults to displaying nothing.
        console (Console, optional): Optional Console instance. Defaults to an internal Console instance writing to stdout.
        screen (bool, optional): Enable alternate screen mode. Defaults to False.
        auto_refresh (bool, optional): Enable auto refresh. If disabled, you will need to call `refresh()` or `update()` with refresh flag. Defaults to True
        refresh_per_second (float, optional): Number of times per second to refresh the live display. Defaults to 4.
        transient (bool, optional): Clear the renderable on exit (has no effect when screen=True). Defaults to False.
        redirect_stdout (bool, optional): Enable redirection of stdout, so ``print`` may be used. Defaults to True.
        redirect_stderr (bool, optional): Enable redirection of stderr. Defaults to True.
        vertical_overflow (VerticalOverflowMethod, optional): How to handle renderable when it is too tall for the console. Defaults to "ellipsis".
        get_renderable (Callable[[], RenderableType], optional): Optional callable to get renderable. Defaults to None.
    NFT   ellipsis)	consolescreenauto_refreshr%   	transientredirect_stdoutredirect_stderrvertical_overflowget_renderablec       	           |dkD  sJ d       || _         ||n	t               | _        || _        d| _        || _        || _        d | _        d | _        t               | _
        d | _        || _        d| _        |rdn|| _        d | _        || _        |	| _        |
| _        t'        | j)                         |	      | _        d| _        y )Nr   zrefresh_per_second must be > 0FT)rK   )_renderabler   rE   _screen_alt_screen_redirect_stdout_redirect_stderr_restore_stdout_restore_stderrr   r4   
ipy_widgetrG   _startedrH   _refresh_threadr%   rK   _get_renderabler   rL   _live_render_nested)r)   
renderablerE   rF   rG   r%   rH   rI   rJ   rK   rL   s              r+   r(   zLive.__init__9   s     "A%G'GG%%")"5w;=  / /2626W
)-(#!'Y9="4!2-&!5F
 r,   c                    | j                   S )z'Check if live display has been started.)rV   r0   s    r+   
is_startedzLive.is_startedb   s     }}r,   c                ^    | j                   | j                         n| j                  }|xs dS )N )rX   rN   )r)   r[   s     r+   rL   zLive.get_renderableg   s9     ##/   "!! 	
 Rr,   c                   | j                   5  | j                  r
	 ddd       yd| _        | j                  j                  |       sd| _        	 ddd       y| j
                  r | j                  j                  d      | _        | j                  j                  d       | j                          | j                  j                  |        |r	 | j                          | j                  r5t        | | j                         | _        | j"                  j%                          ddd       y# t        $ r | j                           w xY w# 1 sw Y   yxY w)z|Start live rendering display.

        Args:
            refresh (bool, optional): Also refresh. Defaults to False.
        NTF)r4   rV   rE   set_liverZ   rO   set_alt_screenrP   show_cursor_enable_redirect_iopush_render_hookr6   	Exceptionr1   rG   r!   r%   rW   start)r)   r6   s     r+   rg   z
Live.starto   s    ZZ 	-}}	- 	- !DM<<((.#	- 	- ||#'<<#>#>t#D LL$$U+$$&LL))$/LLN   '5dD<S<S'T$$$**,5	- 	-" ! 
 IIK#	- 	-s0   E*EA4ED&AE&EEEc                   | j                   5  | j                  s
	 ddd       yd| _        | j                  j                          | j                  r;| j
                  s%| j                  j                  | j                         	 ddd       y| j                  r-| j                  !| j                  j                          d| _	        d| _        | j                  5  	 | j                  s&| j                  j                  s| j                          | j                          | j                  j!                          | j                  s0| j                  j"                  r| j                  j%                          | j                  j'                  d       | j                  r| j                  j)                  d       | j
                  r?| j                  s3| j                  j+                  | j,                  j/                                | j0                  '| j
                  r| j0                  j3                          	 ddd       ddd       y# | j                          | j                  j!                          | j                  s0| j                  j"                  r| j                  j%                          | j                  j'                  d       | j                  r| j                  j)                  d       | j
                  r?| j                  s3| j                  j+                  | j,                  j/                                | j0                  (| j
                  r| j0                  j3                          w w w xY w# 1 sw Y   ?xY w# 1 sw Y   yxY w)zStop live rendering display.NFvisibleT)r4   rV   rE   
clear_liverZ   rH   printr[   rG   rW   r1   rK   rP   
is_jupyterr6   _disable_redirect_iopop_render_hookis_terminallinerc   rb   controlrY   restore_cursorrU   closer0   s    r+   r1   z	Live.stop   s   ZZ 	0==	0 	0 "DMLL##%||~~LL&&t7	0 	0   T%9%9%E$$))+'+$%.D" 00++DLL4K4K--/LL002++0H0H))+LL,,T2''33E:~~d.>.>,,T->->-M-M-OP2t~~--/0	0 	0( --/LL002++0H0H))+LL,,T2''33E:~~d.>.>,,T->->-M-M-OP2t~~--/ 8F20 0	0 	0sJ   M<AM<AM<M/2ID&M/2M<D)M,,M//M9	4M<<Nc                B    | j                  | j                  d u       | S )Nr6   )rg   rN   r0   s    r+   	__enter__zLive.__enter__   s     

4++47
8r,   c                $    | j                          y r.   )r1   )r)   exc_typeexc_valexc_tbs       r+   __exit__zLive.__exit__   s     			r,   c                :   | j                   j                  s| j                   j                  r| j                  rjt	        t
        j                  t              sLt
        j                  | _        t        dt        | j                   t
        j                              t
        _        | j                  rlt	        t
        j                  t              sMt
        j                  | _        t        dt        | j                   t
        j                              t
        _        yyyy)z&Enable redirecting of stdout / stderr.r   N)rE   ro   rl   rQ   
isinstancesysstdoutr   rS   r   rR   stderrrT   r0   s    r+   rd   zLive._enable_redirect_io   s    <<##t||'>'>$$Z

I-N'*zz$!(IdllCJJ,OP
$$Z

I-N'*zz$!(IdllCJJ,OP
 .O$	 (?r,   c                    | j                   r&t        d| j                         t        _        d| _         | j                  r't        d| j                        t        _        d| _        yy)z'Disable redirecting of stdout / stderr.r   N)rS   r   r~   r   rT   r   r0   s    r+   rm   zLive._disable_redirect_io   sQ    h(<(<=CJ#'D h(<(<=CJ#'D   r,   c                    | j                   j                  }|r,| |d   u r%t        |D cg c]  }|j                          c} }n| j                         }| j                  rt        |      S |S c c}w )zwGet the renderable that is being displayed

        Returns:
            RenderableType: Displayed renderable.
        r   )rE   _live_stackr   rL   rP   r   )r)   
live_stackr$   r[   s       r+   r[   zLive.renderable   sk     \\--
$*Q-/: N4!4!4!6 NOJ,,.J%)%5%5vj!E:E !Os   A.ru   c                   t        |t              r| j                  j                  |      }| j                  5  || _        |r| j                          ddd       y# 1 sw Y   yxY w)zUpdate the renderable that is being displayed

        Args:
            renderable (RenderableType): New renderable to use.
            refresh (bool, optional): Refresh the display. Defaults to False.
        N)r}   strrE   
render_strr4   rN   r6   )r)   r[   r6   s      r+   updatezLive.update   sR     j#&00<JZZ 	)D	 	 	s   AA$c                   | j                   5  | j                  j                  | j                         | j                  rG| j
                  j                  r'| j
                  j                  d   j                          	 ddd       y| j
                  j                  r	 ddl	m
} ddlm} | j                   |       | _         || j                         | j                  5  | j                  j                  d       | j
                  j                  | j                  j                         ddd       n| j
                  j&                  rO| j
                  j(                  s9| j
                  5  | j
                  j                  t+                      ddd       nP| j,                  sD| j.                  s8| j
                  5  | j
                  j                  t+                      ddd       ddd       y# 1 sw Y   xY w# t         $ r ddl}|j%                  d       Y 5w xY w# 1 sw Y   BxY w# 1 sw Y   NxY w# 1 sw Y   yxY w)z&Update the display of the Live Render.r   N)display)OutputT)r3   z(install "ipywidgets" for Jupyter support)r4   rY   set_renderabler[   rZ   rE   r   r6   rl   IPython.displayr   
ipywidgetsr   rU   clear_outputrk   ImportErrorwarningswarnro   is_dumb_terminalr   rV   rH   )r)   r   r   r   s       r+   r6   zLive.refresh   s   ZZ 	2,,T__=||<<++LL,,Q/779	2 	2 ||&&I71 .*0(0 I44$4?**4+<+<+G+GHI I ))$,,2O2O\\ 2LL&&wy12 2 MM$..\\ 2LL&&wy12;	2 	2(I I # N#MM"LMN2 2
2 2;	2 	2s   A0H:H:G>)6H:AG2+AH:,$H"-H:=$H.!H:2G;	7H:>HH:HH:"H+	'H:.H7	3H::Ic                   | j                   | j                  _         | j                  j                  rb| j                  5  | j
                  rt        j                         n| j                  j                         }|g|| j                  }ddd       |S | j                  s| j                  sg || j                  }|S # 1 sw Y   |S xY w)z;Process renderables to restore cursor and display progress.N)rK   rY   rE   is_interactiver4   rP   r   homeposition_cursorrV   rH   )r)   renderablesresets      r+   process_renderableszLive.process_renderables  s     /3.D.D+<<&& G '' LLN**::< 
  %F{FD4E4EFG 	 dnn;K;):):;KG s   AB>>Cr.   )r[   zOptional[RenderableType]rE   zOptional[Console]rF   boolrG   r   r%   r8   rH   r   rI   r   rJ   r   rK   r   rL   z&Optional[Callable[[], RenderableType]]r9   r:   )r9   r   )r9   r   )F)r6   r   r9   r:   r;   )r9   r   )rx   zOptional[Type[BaseException]]ry   zOptional[BaseException]rz   zOptional[TracebackType]r9   r:   )r[   r   r6   r   r9   r:   )r   List[ConsoleRenderable]r9   r   )r<   r=   r>   r?   r(   propertyr]   rL   rg   r1   rv   r{   rd   rm   r[   r   r6   r    r,   r+   rB   rB   )   s=   " 04' &*!$% $ $4>AE',' #	'
 ' ' "' ' ' ' 2' ?' 
'R    -D 0D/ ) (	
 
Q( F F EJ  2D2	 r,   rB   __main__)cycle)Dictr   Tuple)Align)r   )rB   )Panel)Rule)Syntax)Tablea~  def loop_last(values: Iterable[T]) -> Iterable[Tuple[bool, T]]:
    """Iterate and generate a tuple with a flag for last value."""
    iter_values = iter(values)
    try:
        previous_value = next(iter_values)
    except StopIteration:
        return
    for value in iter_values:
        yield False, previous_value
        previous_value = value
    yield True, previous_valuepythonT)line_numbersfoobarbaz123zYou can make the terminal shorter and taller to see the live table hideText may be printed while the progress bars are rendering.z(In fact, [i]any[/i] renderable will workzSuch as [magenta]tables[/]...zPretty printed structures...examplezPretty printed)typetextz	Syntax...zGive it a try!)SGDMYREURUSDAUDJPYCNHHKDCADINRDKKGBPRUBNZDMXNIDRTWDTHBVND)rE   zDict[Tuple[str, str], float]exchange_rate_dictd   g?
      i@  zExchange Rates)titlezSource CurrencyzDestination CurrencyzExchange Ratez.4fg      ?redgreen)style)X
__future__r   r~   	threadingr   r   r   typesr   typingr   r	   r
   r   r   r   r   r   r   r_   r   rE   r   r   r   r   r   rq   r   
file_proxyr   jupyterr   live_renderr   r   rF   r   r   r   typing_extensionsr   r!   rB   r<   randomtime	itertoolsr   r   r   alignr   r$   panelr   ruler   syntaxr   tabler   add_rowprogress_renderablesexamples	exchanges
live_tabler   __annotations__rangeindexlenselect_exchangeexchangesleeprandintlognextpoplistkeys
add_columnitemssourcedestexchange_rater   centerr   r,   r+   <module>r      s   " 
 * *  W W W  R R  ! ! ;  &(V (&|< |~ z(( "iG
	" 	F  %&E	MM#sC 	E89'&$45 )*HI* 
g	 !7*;=8=3Z 	7E'I(>?O% 7.

3!6>>!R(1,KKX/BE"V]]_s*a/C"OX#>? )*S^a-??&**40B0G0G0I+J1+MN$45  !23  !78  15G5M5M5O 1NVTMMM,S1+83+>%G !!,%,,u"5677	7!7 !7O N!7 !7s   1E*J&&J/