
    *b              	       N   d dl Z d dlZd dl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mZmZmZ  ed          Z ed          ZdefdZd	ee         d
ee         fdZde j        d
eeef         fdZdee         d
e
eeef                  fdZded
efdZeeddZdeeef         d
efdZdeeef         d
e
eeef                  fdZdeeef         d
eeef         fdZdee         deegef         d
eeee         f         fdZ  G d de!          Z"d Z#d dZ$dS )!    N)OrderedDictCounterdefaultdict)	FrameTypeTracebackType)IteratorListTupleIterableCallableUnionTypeVarMappingTR
max_lengthc                     t          |           |k    rC|t          |          z
  dz  }|t          |          z
  |z
  }| d |         |z   | | d          z   } | S )N   )len)seqr   middlerightlefts        0lib/python3.11/site-packages/stack_data/utils.pytruncater      sc    
3xx*c&kk)a/CKK'%/%4%j6!CL0J    itreturnc                 D    t          t          j        |                     S N)listr   fromkeys)r   s    r   unique_in_orderr#      s    $R(()))r   nodec                     	 | j         j        d         | j        j        d         dz   fS # t          $ r# | j        t          | d| j                  dz   fcY S w xY w)z
    Returns a pair of numbers representing a half open range
    (i.e. suitable as arguments to the `range()` builtin)
    of line numbers of the given AST nodes.
    r      
end_lineno)first_tokenstart
last_tokenendAttributeErrorlinenogetattr)r$   s    r   
line_ranger/      s}    	
"1%O"Q&
 	
  
 
 
KD,44q8
 	
 	
 	

s   &) *AAlstc              #     K   t          |           t          j        | fd          D ]\  }|rjt                    dgt	                    z  fd}t                    D ]2 |fd           |fd            |fd           3nt          j        d          t                    E d {V  d S )	Nc                     |          dk    S )N    )xcountss    r   <lambda>z"highlight_unique.<locals>.<lambda>0   s    Q r   keyFc                 L    	  |             }n# t           $ r Y d S w xY wd|<   |S )NT)
ValueError)fihighlighteds     r   highlight_indexz)highlight_unique.<locals>.highlight_index5   sE     AA!      44 !%As   
 
c                  .                                    S r    indexgroupitems   r   r7   z"highlight_unique.<locals>.<lambda>>   s    D0A0A r   c                  6                          dz             S Nr&   rA   )firstrD   rE   s   r   r7   z"highlight_unique.<locals>.<lambda>@   s    EKKeai,H,H r   c                  F    d d d d                                        z
  S )NrA   rC   s   r   r7   z"highlight_unique.<locals>.<lambda>A   s$    U44R4[->->t-D-D(D r   T)r   	itertoolsgroupbyr!   r   setrepeatzip)r0   	is_commonr?   r6   rH   rD   r>   rE   s      @@@@@r   highlight_uniquerQ   -   sD     S\\F%-c7N7N7N7NOOO + +	5 	1KKE 'CJJ.K     E

 F F'(A(A(A(A(ABB$#O$H$H$H$H$H$HIII D D D D DEEEE	F $*400Kuk**********++ +r   r5   c                     | S r    r4   )r5   s    r   identityrS   H   s    Hr   )mapperr9   c             #   f  K   t          t          ||                     }t          j        t	          | t          |                    d           D ]^\  }}t	          | \  }}|rt          ||          E d {V  *t	          | \  }	}
 |t          |          t          |	                    V  _d S )Nc                     | d         d         S rG   r4   )ts    r   r7   z#collapse_repeated.<locals>.<lambda>P   s    !A$q' r   r8   )r!   maprK   rL   rO   rQ   )r0   	collapserrT   r9   keyedis_highlightedrD   original_grouphighlighted_groupkeyed_group_s              r   collapse_repeatedr`   L   s      S#E!*!2%e,,--!!" " " 	E 	E -0K)) 	E6>2222222222 "34NK)D00${2C2CDDDDDD	E 	Er   frame_or_tbc                     t          t          | t          j        t          j        f                     t          | t          j        f          S r    )assert_
isinstancetypesr   r   ra   s    r   is_framerg   Z   s9    J{U_e6I$JKKLLLkEO#5666r   c              #   Z   K   | r&| V  t          |           r| j        } n| j        } | $d S d S r    )rg   f_backtb_nextrf   s    r   
iter_stackrk   _   sZ      
 .K   	.%,KK%-K  . . . . .r   c                 N    t          |           r	| | j        fS | j        | j        fS r    )rg   f_linenotb_frame	tb_linenorf   s    r   frame_and_linenorp   h   s1     ;K000#[%:::r   iterablekey_funcc                     t          t                    }| D ]&}| ||                                       |           '|S )a  
    Create a dictionary from an iterable such that the keys are the result of evaluating a key function on elements
    of the iterable and the values are lists of elements all of which correspond to the key.

    >>> def si(d): return sorted(d.items())
    >>> si(group_by_key_func("a bb ccc d ee fff".split(), len))
    [(1, ['a', 'd']), (2, ['bb', 'ee']), (3, ['ccc', 'fff'])]
    >>> si(group_by_key_func([-1, 0, 1, 3, 6, 8, 9, 2], lambda x: x % 2))
    [(0, [0, 6, 8, 2]), (1, [-1, 1, 3, 9])]
    )r   r!   append)rq   rr   resultrE   s       r   group_by_key_funcrv   o   sI     F , ,xx~~%%d++++Mr   c                   "    e Zd ZdZd Zd ZeZdS )cached_propertyz
    A property that is only computed once per instance and then replaces itself
    with an ordinary attribute. Deleting the attribute resets the property.

    Based on https://github.com/pydanny/cached-property/blob/master/cached_property.py
    c                 ,    |j         | _         || _        d S r    )__doc__func)selfr{   s     r   __init__zcached_property.__init__   s    |			r   c                 `    || S |                      |          x}|j        | j         j        <   |S r    )r{   __dict____name__)r|   obj_clsvalues       r   cached_property_wrapperz'cached_property.cached_property_wrapper   s1    ;K3799S>>ATY/0r   N)r   
__module____qualname__rz   r}   r   __get__r4   r   r   rx   rx      s=              &GGGr   rx   c           	          dd l }ddlm}  G fddt           |d                              } |d          }|                    |||                                           S )Nr   )get_lexer_by_namec                   "     e Zd Z fdZ xZS )'_pygmented_with_ranges.<locals>.MyLexerc              3      K   dt                                          |          D ]?\  }}t          fdD                       r|j        }t	          |          z  ||fV  @d S )Nr   c              3   >   K   | ]\  }}|cxk    o|k     nc V  d S r    r4   ).0r)   r+   lengths      r   	<genexpr>zE_pygmented_with_ranges.<locals>.MyLexer.get_tokens.<locals>.<genexpr>   sC      FFu,,,,,,,,FFFFFFr   )super
get_tokensanyExecutingNoder   )r|   textttyper   r   	__class__rangess       @r   r   z2_pygmented_with_ranges.<locals>.MyLexer.get_tokens   s      F % 2 24 8 8 # #uFFFFvFFFFF 0!/E#e**$Ul""""	# #r   )r   r   r   r   __classcell__)r   r   s   @r   MyLexerr      s>        	# 	# 	# 	# 	# 	# 	# 	# 	# 	#r   r   python3F)stripnl)pygmentspygments.lexersr   type	highlight
splitlines)	formattercoder   r   r   r   lexers     `    r   _pygmented_with_rangesr      s    OOO111111# # # # # # #$((3344 # # # GE"""EdE955@@BBBr    c                 V    | s&t          |t                    rt          |          }|d S r    )rd   strAssertionError)	conditionerrors     r   rc   rc      s8     eS!! 	*"5))E r   )r   )%astrK   re   collectionsr   r   r   r   r   typingr   r	   r
   r   r   r   r   r   r   r   intr   r#   ASTr/   boolrQ   rS   r`   rg   rk   rp   rv   objectrx   r   rc   r4   r   r   <module>r      s   



      9 9 9 9 9 9 9 9 9 9 * * * * * * * *                   
 GCLLGCLLc    * *Q * * * *
SW 
sCx 
 
 
 
$+$q' +huQW~&> + + + +6 a     19h E E E E E7%	= 89 7d 7 7 7 7
.E)]":; .yZgOgIh@i . . . .;%	=(@"A ;eIWZNF[ ; ; ; ; xQ7G GTUW[\]W^T^L_    $& & & & &f & & &,C C C"     r   