
    STh
6                        d dl Z d dlZd dl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 ddl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mZmZmZmZmZmZmZmZ dddZ 	 d Z!i Z" e!d       e!d      cZ#Z$e#d        Z%e#d-d       Z&e#d        Z'e#d        Z(e#d        Z)e$d        Z*e$d.d       Z+d Z,d Z-d Z.d/dZ/d Z0eZ1 e0d       d e0d       d e0d       d  e0d!       d" e0d        d# e0d$       d" e0d       d% e0d!       d e0d        d& e0d$       d  e0d       d' e0d       d# e0d       d' e0d!       d%d(Z2d) Z3d* Z4d+ Z5d, Z6y)0    N)	signature)chaincountislicerepeat)SimpleNamespace)
about_time   fix_signature   )terminal)	fix_cellsis_wide
join_cellsstrip_marksto_cells)	BLUE	BLUE_BOLDCYANDIMGREENORANGEORANGE_BOLDREDYELLOW_BOLDF)skip_compilerc                      d fd	S )Nc                      d	
 fd	fd} fd} fd} j                   j                  dt        |t        d      |dt        D ci c]  }|j
                   ||       c} xs i xs i c	_        S c c}w )	Nc           	          r	 | fi S t               5 } | fi }t        |j                  dd            }ddd       t        j                  dd            S # 1 sw Y   &xY w)a  Compile this spinner factory into an actual spinner runner.
            The previous parameters were the styling parameters, which defined a style.
            These are called operational parameters, which `alive_progress` binds dynamically
            as needed. Do not call this manually.

            Args:
                actual_length (int): the actual length to compile the frames renditions

            Returns:
                a spinner runner

            T NF)r	   spinner_compilergetspinner_runner_factory)	actual_length	t_compilegenspecextra_commandsnatural	op_paramsr   spinner_inner_factorys	       o/home/www/backend.miabetepe.com/venv/lib/python3.12/site-packages/alive_progress/animations/spinner_compiler.py#spinner_compiler_dispatcher_factoryzYspinner_controller.<locals>.inner_controller.<locals>.spinner_compiler_dispatcher_factory   s     ,]HiHH T+MGYG'Wn6H6Hr6RST *$	>;M;MeUW;XYYT Ts   'A##A,c                  4             j                   | i | y)z:Compile this spinner factory at its natural length, and...Ncheck)argskwargsr.   s     r-   compile_and_checkzGspinner_controller.<locals>.inner_controller.<locals>.compile_and_check'   s    7/177HH    c                  N     t              j                  di |   |       S )N)r
   )r   bind)paramsr)   inner_controllerr,   s    r-   set_operationalzEspinner_controller.<locals>.inner_controller.<locals>.set_operational+   s,    1I+,11>v>#$96>RRr5   c                 2      fd}t        | d      S )Nc                       t              j                  dg| i | t              t           }}|j	                  |d      | |ffz   ||<    |      S )Nr
   r!   )r   r7   dictEXTRA_COMMANDSr#   )	r2   r3   extracmd_typecommandr)   r9   r+   r,   s	       r-   inner_schedulez^spinner_controller.<locals>.inner_controller.<locals>.schedule_command.<locals>.inner_schedule0   sh    '	'"'';D;F;"&~"6w8Ox"'))Hb"9gtV=T<V"Vh'(=y%PPr5   r
   r   )rA   rB   r)   r9   r+   r,   s   ` r-   schedule_commandzFspinner_controller.<locals>.inner_controller.<locals>.schedule_command/   s     Q Q !!<<r5   r
   )r1   opNr!   )__dict__updater   r1   r>   __name__r*   )r,   r+   r)   r4   r:   rC   cr.   r9   r*   r   s   ```    @r-   r9   z,spinner_controller.<locals>.inner_controller   s    	Z 	Z*	I	S	= 	<+44;; 	
 15!<	
8FG1qzz+A..G	
 %.O^5Ir!	>6=+322	 Hs   B)NNr!   )r*   r   r9   s   ``@r-   spinner_controllerrJ      s    -3^ r5   c                       fd}|S )Nc                     t         | <   | S rE   )r>   )rA   is_compilers    r-   inner_commandz$extra_command.<locals>.inner_commandP   s    "-wr5   r!   )rM   rN   s   ` r-   extra_commandrO   O   s     r5   Tc                 P    t        fd| j                  D              | _        y)zReplace a portion of the frames by another with the same length.

    Args:
        old (str): the old string to be replaced
        new (str): the new string

    c              3   H   K   | ]  }t        fd |D                yw)c              3   f   K   | ](  }t        t        |      j                               * y wrE   )r   r   replace).0framenewolds     r-   	<genexpr>z$replace.<locals>.<genexpr>.<genexpr>e   s-      :?E"**345s   .1Ntuple)rT   cyclerV   rW   s     r-   rX   zreplace.<locals>.<genexpr>e   s+      
  CH  s   "N)rZ   data)r(   rW   rV   s    ``r-   rS   rS   [   s"      99 DIr5   c                     d fD        \  t        d fD              rd\  fdt        fdfd| j                  D        D              | _        y)a  Make the animation appear to pause at the edges or at the middle, or make it slower as
    a whole, or both.

    Use without arguments to get their defaults, which gives a small pause at the edges,
    very nice for bouncing text with `hide=False`. Please note that the defaults only apply
    if none of the params are set.

    In the future, I'd like to make this a `pace` command, which would receive a sequence
    of ints of any length, and apply it bouncing across the cycle. For example to smoothly
    decelerate it could be (6, 3, 2, 1), which would become (6, 3, 2, 1, 1, ..., 1, 2, 3, 6).

    Args:
        edges (Optional[int]): how many times the first and last frames of a cycle repeats
            default is 8.
        center (Optional[int]): how many times the middle frame of a cycle repeats
            default is 1.
        other (Optional[int]): how many times all the other frames of a cycle repeats
            default is 1.

    c              3   <   K   | ]  }t        d |xs d         ywr
   N)maxrT   xs     r-   rX   zpause.<locals>.<genexpr>   s     KqC16NK   c              3   &   K   | ]	  }|d k(    ywr_   r!   ra   s     r-   rX   zpause.<locals>.<genexpr>   s     
2a16
2s   )   r
   r
   c                 2    d| dz
  t        | dz        iS )Nr   r
   r   )round)lengthcenteredgess    r-   repeats_funczpause.<locals>.repeats_func   s)    uQJ&1*v
 	
r5   c           	   3      K   | ]8  \  }t        t        j                  fd t        |      D                     : yw)c              3   b   K   | ]&  \  }}t        |j                  |      xs        ( y wrE   )r   r#   )rT   irU   otherrepeatss      r-   rX   z"pause.<locals>.<genexpr>.<genexpr>   s.      03;1eugkk!n-.0s   ,/N)rZ   r   from_iterable	enumerate)rT   r[   rp   ro   s     @r-   rX   zpause.<locals>.<genexpr>   sC      Y5' E// 0?H?O0   Ys   >Ac              3   D   K   | ]  }| t        |            f  y wrE   len)rT   r[   rk   s     r-   rX   zpause.<locals>.<genexpr>   s     WEul3u:&>?Ws    N)allrZ   r\   )r(   rj   ri   ro   rk   s    ```@r-   pauserw   j   sk    , LUFE4JKE65

2E651
22&vu
  YWTYYWY YDIr5   c                     t        j                  d | j                  D              t        t	        fdd            | _        y)zReshape frame data into another grouping. It can be used to simplify content
    description, or for artistic effects.

    Args:
        num_frames (int): the number of consecutive frames to group

    c              3       K   | ]  }|  y wrE   r!   rT   r[   s     r-   rX   zreshape.<locals>.<genexpr>   s     !?E%!?s   c                  .    t        t                     S rE   )rZ   r   )flatten
num_framess   r-   <lambda>zreshape.<locals>.<lambda>   s    5)D#E r5   r!   N)r   rq   r\   rZ   iter)r(   r}   r|   s    `@r-   reshaper      s3     !!!?TYY!??GdErJKDIr5   c           	      l    t        t        | j                  | j                  ddd               | _        y)z%Make the animation bounce its cycles.r   N)rZ   r   r\   r(   s    r-   bouncer      s*     eDIItyyAb'9:;DIr5   c                 R    t        d t        | j                   D              | _        y)zTranspose the frame content matrix, exchanging columns for rows. It can be used
    to simplify content description, or for artistic effects.c              3   2   K   | ]  }t        |        y wrE   rY   rz   s     r-   rX   ztranspose.<locals>.<genexpr>   s     @ueEl@   N)rZ   zipr\   r   s    r-   	transposer      s     @TYY@@DIr5   c                 x    d }d|_         | j                  j                  |t        | j                               y)zEConfigure the runner to play the compiled cycles in sequential order.c              3   &   K   	 | E d {    7 wrE   r!   r\   s    r-   
cycle_datazsequential.<locals>.cycle_data   s     OO s   
sequentialstrategycyclesN)namerF   rG   ru   r\   )r(   r   s     r-   r   r      s/     #JOMM*S^Dr5   c                     d }d|_         | j                  j                  |t        d|xs d      xs | j                         y)zConfigure the runner to play the compiled cycles in random order.

    Args:
        cycles (Optional[int]): number of cycles to play randomized

    c              3   <   K   	 t        j                  |        wrE   )randomchoicer   s    r-   r   zrandomize.<locals>.cycle_data   s     --%% rc   
randomizedr   r   N)r   rF   rG   r`   r   )r(   r   r   s      r-   	randomizer      s;    & #JOMM*SFKa5H5WDKKXr5   c                 2    |D ]  \  }}} || g|i |  y rE   r!   )r(   r)   rA   r2   r3   s        r-   apply_extra_commandsr      s*    !/ 'v&t&v&'r5   c                    t        t        d | D              |      }t        ||       t        d |j                  D              }|j                  j                  t        |j                        t        |j                  d   d         |t        |             t        d |j                  D              t        d |j                  D              k(  sJ t        |d      xs d	       |S )
a  Optimized spinner compiler, which compiles ahead of time all frames of all cycles
    of a spinner.

    Args:
        gen (Generator): the generator expressions that defines the cycles and their frames
        natural (int): the natural length of the spinner
        extra_commands (tuple[tuple[cmd, list[Any], dict[Any]]]): requested extra commands

    Returns:
        the spec of a compiled animation

    c              3   @   K   | ]  }t        d  |D                yw)c              3   2   K   | ]  }t        |        y wrE   )r   )rT   rU   s     r-   rX   z-spinner_compiler.<locals>.<genexpr>.<genexpr>   s     =e5)=r   NrY   rz   s     r-   rX   z#spinner_compiler.<locals>.<genexpr>   s     O%5=u==O   )r\   r*   c              3   2   K   | ]  }t        |        y wrE   rt   rz   s     r-   rX   z#spinner_compiler.<locals>.<genexpr>   s     5%3u:5r   r   )r   rh   framestotal_framesc              3   @   K   | ]  }|D ]  }t        |         y wrE   rt   rT   r[   rU   s      r-   rX   z#spinner_compiler.<locals>.<genexpr>         EuuEeE
E
Er   c              3   @   K   | ]  }|D ]  }t        |         y wrE   rt   r   s      r-   rX   z#spinner_compiler.<locals>.<genexpr>   r   r   Tz.Different cell lengths detected in frame data.)r   rZ   r   r\   rF   rG   ru   sumr`   minrender_data)r'   r*   r)   r(   r   s        r-   r"   r"      s     O3OOY`bD~. 549955FMMDIIs499Q<?7K &S[  B E		EEE		EEF TD$S#ST F Kr5   c                 (    fd} fd}|j                   j                   j                   t        |t        d              j                   j                  ||       t	                t         |        j                   j                        |S )aH  Optimized spinner runner, which receives the spec of an animation, and controls
    the flow of cycles and frames already compiled to a certain screen length and with
    wide chars fixed, thus avoiding any overhead in runtime within complex spinners,
    while allowing their factories to be garbage collected.

    Args:
        spec (SimpleNamespace): the spec of an animation
        t_compile (about_time.Handler): the compile time information
        extra_commands (tuple[tuple[cmd, list[Any], dict[Any]]]): requested extra commands

    Returns:
        a spinner runner

    c               3   8   K   t               E d{    y7 w)zWow, you are really deep! This is the runner of a compiled spinner.
        Every time you call this function, a different generator will kick in,
        which yields the frames of the current animation cycle. Enjoy!N)next)	cycle_gens   r-   spinner_runnerz.spinner_runner_factory.<locals>.spinner_runner   s     
 	?""s   c                  "    t        g| i |S rE   r0   )r2   r3   r(   s     r-   runner_checkz,spinner_runner_factory.<locals>.runner_check   s    T+D+F++r5   r
   r0   )r&   runner)rF   rG   r   r1   r   r   r   r\   )r(   r&   r)   r   r   r   s   `    @r-   r$   r$      sx     #, ""4==lTY[\8]"^MM9^Dt~.dii(Ir5   c                    t        dt        d|xs d            }|dv rt        | |dv        t        |        | j                  j
                  }t        dt        |              t        dt        |    d       |dv rt        |        y	y	)
aG  Check the specs, contents, codepoints, and even the animation of this compiled spinner.
    
    Args:
        verbosity (int): change the verbosity level
                             0 for specs only (default)
                               /                 \
                              /           3 to include animation
                             /                      \
            1 to unfold frame data   --------   4 to unfold frame data
                            |                        |
            2 to reveal codepoints   --------   5 to reveal codepoints

    r      )r
   r      r   )r   r   z
Spinner frames compiled in: z(call ))   r   r   N)
r`   r   r   	spec_datar&   duration_humanprintr   HELP_MSGanimate)r(   	verbositydurations      r-   r1   r1     s     As1in1-.IL D)v-.dO~~,,H	*5?*;
<=	F8I&'q
)*I r5   c                 l    t        dt        j                   d       t        |        t        d       S )N.(r   )r   r1   rH   r   )ps    r-   __checkr   '  s1    Qu~~&a()*9Q<.cDDr5   z to unfold frame data, or r   z to include animationz to reveal codepoints, or r   z to include animation, or z to fold up frame datar   z to hide codepointsz to omit animationz to omit animation, or )r   r
   r   r   r   r   c                       fdt        dt        d              t         d      d d       d       t         d      d d	       d       t        dj                  fd
dD                     y )Nc                 z    t        | j                  d      d          d t        j                  |              S )Nr   r   z: )r   splitoperator
attrgetter)fieldr(   s    r-   infozspec_data.<locals>.info9  s=    ekk#.q12326Ph6I6I%6PQU6V5WXXr5   
Specsrh   r   r*   r   r   zstrategy.namec              3   .   K   | ]  } |        y wrE   r!   )rT   r   r   s     r-   rX   zspec_data.<locals>.<genexpr>?  s     HEDKHs   )r   r   )r   SECTIONjoin)r(   r   s   `@r-   r   r   8  sq    Y 
Bww 
!"	$x.Ad9o.a01	$x.Ad?34A67	$))H-GH
HIr5   c                 v    dj                  d | D              }dt        t        d | D                     d| dS )N|c              3      K   | ]7  } t        |      rt        nt        d j                  d |D                     9 yw) c              3   d   K   | ](  }t        t        |            j                  d d       * yw)0x N)hexordrS   )rT   rI   s     r-   rX   z.format_codepoints.<locals>.<genexpr>.<genexpr>D  s%     :1SV$$T2.:s   .0N)r   r   r   r   )rT   gs     r-   rX   z$format_codepoints.<locals>.<genexpr>C  s;      L@A 5
f:::< Ls   =?z -> c              3   2   K   | ]  }t        |        y wrE   rt   )rT   fragments     r-   rX   z$format_codepoints.<locals>.<genexpr>E  s     >H#h->r   z:[])r   r   r   )rU   codess     r-   format_codepointsr   B  sF    HH LEJL LE#c>>>?@5'KKr5   c                    t        dt        d       d       t        d      }ddt        t	        t        | j                                    z    dt        t	        | j                               c|rt        nd t        | j                  d      D ]R  \  }}t        d	 |      }t        d
| ddj                  fdt        t        d      ||      D              z          T y )Nr   z
Frame datar   endr
   ><c                      y)Nr   r!   )_s    r-   r~   zrender_data.<locals>.<lambda>L  s    r5   c                 *    t        t        |             S rE   )rZ   r   )r   s    r-   r~   zrender_data.<locals>.<lambda>N  s    eK,A&B r5   z
cycle c           	   3      K   | ]?  \  }}}t        |      d dj                  |       dt        |       z    |      z    A yw)z |r   z| N)r   r   )rT   lirU   wi
codepointslfwfs       r-   rX   zrender_data.<locals>.<genexpr>O  sP      +
E2 BKBrwwu~.bR>>EARR+
s   AA)r   r   r   ru   strr`   r   r   r   rr   r\   mapr   r   )	r(   show_codepointswhole_indexrn   r[   r   r   r   r   s	         @@@r-   r   r   H  s    	Bw|$%
&B/(KSS-.//01Qs3t?P?P;Q7R6S3TFB&5"<Jdii+ 5BEJ2 +
!$U1Xv{!C+
 "
 
 	r5   c                 d   t        dt        d              d | j                  t        | j                        | j
                  fD        \  }}}ddlm}  |t        d| j                  dz                |t        d| j
                  dz               }}t        j                         }|j                          	 	 t        |      }t        | j                         d      D ]  \  }	}
t        |      }t        dt        ||       dt        |	|       d	t!        |
       d
t        ||       d	       t        t#        d      d       |j%                          t'        j(                  d       |j+                           # t,        $ r Y nw xY w	 |j/                          y # |j/                          w xY w)Nr   	Animationc              3   J   K   | ]  }d t        t        |               yw)r   N)ru   r   ra   s     r-   rX   zanimate.<locals>.<genexpr>W  s     `Ac#a&k]#`s   !#r   )r[   r
   :z -->z<-- r   z(press CTRL+C to stop)r   r   g?)r   r   r   r`   r   r   	itertoolsr[   ranger   get_termhide_cursorr   rr   r   r   r   r   clear_end_linetimesleepcursor_up_1KeyboardInterruptshow_cursor)r(   cfr   tfr[   r   r   termrI   rn   fns               r-   r   r   U  sr   	Bw{#$
%&`dkk3t{{;KTM^M^-_`JBB5DKK!O45uU1dFWFWZ[F[=\7]FFDVA!$++-3 #1L42;-qaT*Q-TRSUW[MYZ[\c23<##%

6"  "#   s%   8CE< <	FF FF F/)NNNrE   )r   )7r   r   r   inspectr   r   r   r   r   r   typesr   r	   utilsr   r   utils.cellsr   r   r   r   r   utils.colorsr   r   r   r   r   r   r   r   r   rJ   rO   r>   compiler_commandrunner_commandrS   rw   r   r   r   r   r   r   r"   r$   r1   r   r   r   r   r   r   r   r!   r5   r-   <module>r     s       2 2 ! !    O O c c c 27 0f	 #0#6e8L   .   "Y "YJ 	L 	L < <
 A A E E Y Y '
: F6E 
!*/
|;PQ
!*/
| <aj\/1
!*/
|;NO
!*/
|;MN
!*/
| <aj\/1
!*,WQZL8KL	JL
r5   