
    AHj*
                    p    d dl mZ d dlmZmZmZmZ  ed      Zd	dZd	dZ	d
dZ
	 	 d	 	 	 	 	 	 	 	 	 ddZy)    )annotations)IterableLiteralSequenceTypeVarTc              #  ~   K   t        |       }	 t        |      }d|f |D ]  }d|f 
 y# t        $ r Y yw xY ww)z9Iterate and generate a tuple with a flag for first value.NTFiternextStopIteration)valuesiter_valuesvalues      E/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/_loop.py
loop_firstr      sV     v,K[! + Ul  s   =. =	:=:=c              #     K   t        |       }	 t        |      }|D ]
  }d|f |} d|f y# t        $ r Y yw xY ww)z8Iterate and generate a tuple with a flag for last value.NFTr
   )r   r   previous_valuer   s       r   	loop_lastr      s_     v,Kk*  ^## 
  s   ?0 ?	<?<?c              #     K   t        |       }	 t        |      }d}|D ]  }|d|f d}|} |d|f y# t        $ r Y yw xY ww)zBIterate and generate a tuple with a flag for first and last value.NTFr
   )r   r   r   firstr   s        r   loop_first_lastr   !   sm     v,Kk* E UN** ~
%%  s$   A6 A	AAAAc              #     K   |dv sJ d       t        |       }|r"t        |      D ]  }||z   |z  }|| |   f  y|dk(  r&t        |      D ]  }|dz   x}|k\  r y|| |   f  yt        |      D ]  }|dz
  x}dk  r y|| |   f  yw)a  Iterate over values in a sequence from a given starting index, potentially wrapping the index
    if it would go out of bounds.

    Note that the first value to be yielded is a step from `index`, and `index` will be yielded *last*.


    Args:
        values: A sequence of values.
        index: Starting index.
        direction: Direction to move index (+1 for forward, -1 for backward).
        bool: Should the index wrap when out of bounds?

    Yields:
        A tuple of index and value from the sequence.
    )   zdirection must be -1 or +1r   r   N)lenrange)r   index	directionwrapcount_s         r   loop_from_indexr#   0   s     ,  >">> KEu 	)AY&%/E&-((	) ?5\ -"QY&E50fUm,,-
 5\ -"QY&E!+fUm,,-s   BBN)r   Iterable[T]returnzIterable[tuple[bool, T]])r   r$   r%   zIterable[tuple[bool, bool, T]])r   T)
r   zSequence[T]r   intr   zLiteral[-1, +1]r    boolr%   zIterable[tuple[int, T]])
__future__r   typingr   r   r   r   r   r   r   r   r#        r   <module>r,      sa    " 7 7CL	
&$ "$	&-&-&- &- 	&-
 &-r+   