
    iGG              	       Z   % S r SSKrSSKrSSKrSSKrSSKrSSKrSSKJr  SSKJ	r	J
r
JrJr  SSKJr  SSKJrJrJrJrJrJrJr  SSKJr  SSKJr  \" S	5      rS
\\   S\
\\\\\   4      S\\   4S jr " S S\\   5      r S\S\S\	\/\!4   S\4S jr" " S S\\   5      r#S\4S jr$ " S S5      r%\%" 5       r&\" 5       r' " S S5      r(S\	\/\!4   S\4S jr)Sq*Sq+\,\-S'   Sq.\,\-S'   \R^                  r0S\,4S jr1S \\   S!\\   S\!4S" jr2S \\   S!\\   S\!4S# jr3S$\S\4S% jr4g)&zA module for miscellaneous useful bits and bobs that don't
obviously belong anywhere else. If you spot a better home for
anything that lives here, please move it.    N)	ArrayType)CallableIterableIteratorSequence)Lock)AnyClassVarGenericLiteralTypeVarUnionoverload)
SortedList)HypothesisWarningTlsreplacementsreturnc                     / nSnSnU H?  u  pVnUR                  XU 5        UR                  U5        UnU[        U5      Xe-
  -
  -  nMA     UR                  XS 5        [        U5      [        U 5      U-   :X  d   eU$ )zlSubstitute multiple replacement values into a list.

Replacements is a list of (start, end, value) triples.
r   N)extendlen)r   r   resultprevoffsetuvrs           h/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/hypothesis/internal/conjecture/junkdrawer.pyreplace_allr    )   s     FDFabaj!a#a&AE""	  
 MM"U)v;#b'F****M    c            	          \ rS rSr% Sr/ SQr\\\      \	S'   \
" \R                  " \5      5      r\\
\\4      \	S'   SrS'S\\   4S jjr\S	\S
S 4S j5       r\S\S\\   S
\\\   S4   4S j5       rS\S
\4S jrS
\4S jrS
\4S jr\S\S
\4S j5       r\S\S
S4S j5       rS\\-  S
S4S jrS\\-  S
S4S jrS\S\S
S4S jrS
\ \   4S jr!S\"S
\#4S  jr$S\"S
\#4S! jr%S	\S
S4S" jr&S\S	\S
S4S# jr'S$\\   S
S4S% jr(S(S& jr)Sr*g))IntList?   a  Class for storing a list of non-negative integers compactly.

We store them as the smallest size integer array we can get
away with. When we try to add an integer that is too large,
we upgrade the array to the smallest word size needed to store
the new value.)BHILQOARRAY_CODESNEXT_ARRAY_CODE)__underlyingvaluesc                 *   U R                    H  n U R                  X!5      n  O   [        SU< 35      e[	        U[
        5      (       a3  U H-  n[	        U[        5      (       a  US:  d  M   [        SU< 35      e   X0l        g ! [         a     M  f = f)NzCould not create storage for r   zCould not create IntList for )	r+   _array_or_listOverflowErrorAssertionError
isinstancelistint
ValueError_IntList__underlying)selfr.   code
underlyingr   s        r   __init__IntList.__init__L   s    $$D!00>
 % !#@
!KLLj$''!!S))QU$'DVJ%OPP   9C ! s   B
BBnr   c                 D    U " [         R                   " SS/5      U-  5      $ )Nr%   r   )array)clsr=   s     r   	of_lengthIntList.of_length[   s    5;;sQC(1,--r!   r9   contentszArrayType[int]c                 P    U S:X  a  [        U5      $ [        R                  " X5      $ )Nr*   )r4   r?   )r9   rC   s     r   r0   IntList._array_or_list_   s$     3;>!{{4**r!   valuec                 8    U R                   R                  U5      $ N)r7   count)r8   rF   s     r   rI   IntList.countg   s      &&u--r!   c                 6    S[        U R                  5      < S3$ )NzIntList())r4   r7   r8   s    r   __repr__IntList.__repr__j   s    $t0014A66r!   c                 ,    [        U R                  5      $ rH   )r   r7   rM   s    r   __len__IntList.__len__m   s    4$$%%r!   ic                     g rH    r8   rS   s     r   __getitem__IntList.__getitem__p   s    *-r!   zlist[int] | ArrayType[int]c                     g rH   rU   rV   s     r   rW   rX   s   s     (+r!   z int | list[int] | ArrayType[int]c                      U R                   U   $ rH   r7   rV   s     r   rW   rX   x   s      ##r!   Nc                     U R                   U	 g rH   r[   rV   s     r   __delitem__IntList.__delitem__{   s    a r!   r   c                 :    U R                   R                  X5        g rH   )r7   insertr8   rS   r   s      r   r`   IntList.insert~   s      &r!   c                 ,    [        U R                  5      $ rH   )iterr7   rM   s    r   __iter__IntList.__iter__   s    D%%&&r!   otherc                 t    XL a  g[        U[        5      (       d  [        $ U R                  UR                  :H  $ )NTr3   r#   NotImplementedr7   r8   rg   s     r   __eq__IntList.__eq__   s4    =%))!!  E$6$666r!   c                 t    XL a  g[        U[        5      (       d  [        $ U R                  UR                  :g  $ )NFri   rk   s     r   __ne__IntList.__ne__   s4    =%))!!  E$6$666r!   c                      U R                   R                  U5        g ! [         a7    [        U R                   5      nU R                   R                  S5        XU'    g f = fNr   )r7   appendr1   r   )r8   r=   rS   s      r   rs   IntList.append   sU    	$$Q' 	D%%&A$$Q'G	s    >AAc                 x      X R                   U'   g ! [         a    US:  d   eU R                  5          Of = fM:  rr   )r7   r1   _IntList__upgrade)r8   rS   r=   s      r   __setitem__IntList.__setitem__   sD    !'(!!!$  !1uu !	 s    "77r   c                 8    U H  nU R                  U5        M     g rH   )rs   )r8   r   r=   s      r   r   IntList.extend   s    AKKN r!   c                     [        U R                  [        R                  5      (       d   eU R                  U R                  R                     nU R                  XR                  5      U l        g rH   )r3   r7   r?   r,   typecoder0   )r8   r9   s     r   	__upgradeIntList.__upgrade   sT    $++U[[9999##D$5$5$>$>? //6G6GHr!   )rU   r   N)+__name__
__module____qualname____firstlineno____doc__r+   r
   r4   str__annotations__dict	itertoolspairwiser,   	__slots__r   r5   r;   classmethodrA   staticmethodr   r   r0   rI   rN   rQ   r   rW   slicer]   r`   r   re   objectboolrl   ro   rs   rw   r   rv   __static_attributes__rU   r!   r   r#   r#   ?   s    (FK$s)$E04Y5G5G5T0UOXd38n-U!ICx} C .# .) . . ++%c]+	tCy**	++ +.3 .3 .7# 7& & -S-S- -++	%+ +$S5[ $-O $!S5[ !T !' ' ' ''(3- '7F 7t 77F 7t 7  !S !S !T !# 4 Ir!   r#   lohifc                 n    U" U 5      nU S-   U:  a#  X-   S-  nU" U5      U:X  a  Un OUnU S-   U:  a  M#  U $ )zBinary searches in [lo , hi) to find
n such that f(n) == f(lo) but f(n + 1) != f(lo).
It is implicitly assumed and will not be checked
that f(hi) != f(lo).
      rU   )r   r   r   	referencemids        r   binary_searchr      sM     "I
q&2+w1nS6YBB q&2+ Ir!   c                       \ rS rSrSrS\\   4S jrS\4S jr	SS\S\4S jjr
S\S	\SS
4S jrS\S\4S jrS\S\SS
4S jrS\S\4S jrS\\   4S jrSrg
)LazySequenceCopy   a5  A "copy" of a sequence that works by inserting a mask in front
of the underlying sequence, so that you can mutate it without changing
the underlying sequence. Effectively behaves as if you could do list(x)
in O(1) time. The full list API is not supported yet but there's no reason
in principle it couldn't be.r.   c                 L    Xl         [        U5      U l        S U l        S U l        g rH   )_LazySequenceCopy__valuesr   _LazySequenceCopy__len_LazySequenceCopy__mask!_LazySequenceCopy__popped_indices)r8   r.   s     r   r;   LazySequenceCopy.__init__   s!    [
+/8<r!   r   c                 x    U R                   c  U R                  $ U R                  [        U R                   5      -
  $ rH   )r   r   r   rM   s    r   rQ   LazySequenceCopy.__len__   s2      (::zzC 5 5666r!   rS   c                 D   [        U 5      S:X  a  [        S5      eU R                  U5      nS nU R                  b  U R                  R	                  US 5      nUc  U R
                  U   nU R                  c  [        5       U l        U R                  R                  U5        U$ )Nr   zCannot pop from empty list)	r   
IndexError#_LazySequenceCopy__underlying_indexr   popr   r   r   addra   s      r   r   LazySequenceCopy.pop   s    t9>9::##A&;;"4(A9a A  ($.LD!!!!$r!   jNc                 *    X:X  a  gX   X   sX'   X'   g)zSwap the elements ls[i], ls[j].NrU   )r8   rS   r   s      r   swapLazySequenceCopy.swap   s    67DGr!   c                     U R                  U5      nU R                  U   nU R                  c  U$ U R                  R                  X5      $ rH   )r   r   r   get)r8   rS   defaults      r   rW   LazySequenceCopy.__getitem__   sB    ##A&--";;N;;??1..r!   r   c                 j    U R                  U5      nU R                  c  0 U l        X R                  U'   g rH   )r   r   ra   s      r   rw   LazySequenceCopy.__setitem__   s.    ##A&;;DKAr!   c                 D   [        U 5      nX* :  d  X:  a  [        SU SU S35      eUS:  a  X-  nSUs=::  a  U:  d   e   eU R                  bN  [        U R                  5      [        U R                  5      ::  d   eU R                   H  nX1:  a    U$ US-  nM     U$ )NzIndex z out of range [0, rL   r   r   )r   r   r   r   )r8   rS   r=   idxs       r   __underlying_index#LazySequenceCopy.__underlying_index   s    Ir6QVvaS(:1#Q?@@q5FAAzzzz  , t,,-T]]1CCCC,,7 Q - r!   c              #   N   #    [        [        U 5      5       H	  nX   v   M     g 7frH   )ranger   rV   s     r   re   LazySequenceCopy.__iter__  s     s4y!A'M "s   #%)__len__mask__popped_indices__values))r   r   r   r   r   r   r   r;   r5   rQ   r   r   rW   rw   r   r   re   r   rU   r!   r   r   r      s    $=x{ =7 7
S !  ,c ,c ,d ,/S /Q /S Q 4 C C 4(1+ r!   r   c                  x    [         R                  " S5      n SnU (       a  U R                  n US-  nU (       a  M  U$ )a6  Get stack size for caller's frame.

From https://stackoverflow.com/a/47956089/9297601 , this is a simple
but much faster alternative to `len(inspect.stack(0))`.  We use it
with get/set recursionlimit to make stack overflows non-flaky; see
https://github.com/HypothesisWorks/hypothesis/issues/2494 for details.
r   r   )sys	_getframef_back)framesizes     r   stack_depth_of_callerr     s:     MM!ED
	 % Kr!   c                   l    \ rS rSrS rSS.S\S\SS4S	 jjrS\S
\SS4S jrSS.S\S\SS4S jjr	Sr
g)StackframeLimiteri'  c                 >    SU l         [        5       U l        S U l        g rr   )_active_contextsset_known_limits_original_limitrM   s    r   r;   StackframeLimiter.__init__6  s     !'*u+/r!   Tcheck	new_limitr   r   Nc                   U(       aP  [         R                  " 5       =o0R                  ;  a,  [        R                  " SU R
                   SU S3[        SS9  g U R                  R                  U5        [         R                  " U5        g )NzXThe recursion limit will not be reset, since it was changed during test execution (from z to z).   )
stacklevel)	r   getrecursionlimitr   warningswarnr   r   r   setrecursionlimit)r8   r   r   current_limits       r   _setrecursionlimit$StackframeLimiter._setrecursionlimit;  sx    "%"7"7"99BTBTTMM//3/C/C.DDWY[!	 y)i(r!   r   c                    U R                   S:X  a:  U R                  b   eX l        U R                  R                  U R                  5        U =R                   S-  sl         U R	                  U5        g )Nr   r   )r   r   r   r   r   )r8   r   r   s      r   enter_contextStackframeLimiter.enter_contextK  sc      A% ''///#0 ""4#7#78"	*r!   c                   U R                   S:  d   eU =R                   S-  sl         U R                   S:X  a1  U R                  nUc   e U R                  X2S9  S U l        U1U l        g U R                  XS9  g ! S U l        U1U l        f = f)Nr   r   r   )r   r   r   r   )r8   r   r   original_limits       r   exit_contextStackframeLimiter.exit_contextV  s    $$q((("  A% "11N!---6'''D'+$ '5%5"##I#; (,$ '5%5"s   
A9 9B
)r   r   r   )r   r   r   r   r;   r5   r   r   r   r   r   rU   r!   r   r   r   '  sg    0
 CG )C )4 )4 ) 	+s 	+c 	+d 	+ =A <c <T <T < <r!   r   c                   (    \ rS rSrSrSS jrS rSrg)ensure_free_stackframesin  zbContext manager that ensures there are at least N free stackframes (for
a reasonable value of N).
Nc                    [        5       n[           [        R                  " 5       U l        US-   U l        US::  d-   SU R
                  U R                  -
  U R                  4-  5       e [        R                  U R
                  U R                  S9   S S S 5        g ! [         a     [        R                  U R                  SS9  e f = f! , (       d  f       g = f)Ni  i  zHypothesis would usually add %d to the stack depth of %d here, but we are already much deeper than expected.  Aborting now, to avoid extending the stack limit in an infinite loop...)r   Fr   )
r   _stackframe_limiter_lockr   r   	old_limitr   _stackframe_limiterr   	Exceptionr   )r8   	cur_depths     r   	__enter__!ensure_free_stackframes.__enter__s  s    )+	% 224DN '-DN $ I >>DNN2DNNCD$
#11NN$.. 2 # &%(  
 $00u0M) &%s   AC	*(B*CC		
Cc                     [            [        R                  U R                  5        S S S 5        g ! , (       d  f       g = frH   )r   r   r   r   )r8   argskwargss      r   __exit__ ensure_free_stackframes.__exit__  s#    %,,T^^< &%%s    0
>)r   r   r   )r   r   r   r   r   r   r   r   rU   r!   r   r   r   n  s    <=r!   r   c                     [        SS5       H  nU " U5      (       a  M  US-
  s  $    SnSnU " U5      (       a  UnUS-  nU " U5      (       a  M  US-   U:  a$  X#-   S-  nU " U5      (       a  UnOUnUS-   U:  a  M$  U$ )zFinds a (hopefully large) integer such that f(n) is True and f(n + 1) is
False.

f(0) is assumed to be True and will not be checked.
r      r   r   )r   )r   rS   r   r   r   s        r   find_integerr     s     1a[ttq5L  
B
 
B
B%%
a B%% q&2+w1nS66BB q&2+ Ir!   F	_gc_start_gc_cumulative_timec                     [         (       d  [        [        S5      (       aD  S[        S   S[        [
        [        4   SS 4S jn [        R                  R                  SU 5        O[        [        S5      (       am  S	[        SS 4S
 jn[        R                  R                  c  U[        R                  l        [        R                  R                  c  U[        R                  l        Sq [        $ )N	callbacksphase)startstopinfor   c                      [        5       nU S:X  a  Uqg U S:X  a  [        S:  a  [        U[        -
  -  qg g g ! [         a    Sq g f = f)Nr   r   r   )_perf_counterr   r   RecursionError)r   r   nows      r   gc_callback'gc_cumulative_time.<locals>.gc_callback  sW    '/C'$'	&Y]+sY>+ .;% 	 !"I	s   8  8 AAr   hooksstatsc                 L     [         U R                  -  q g ! [         a     g f = frH   )r   durationr   )r  s    r   hook gc_cumulative_time.<locals>.hook  s(    '5>>9'% s    
##T)_gc_initializedhasattrgcr   r   r   r5   r   r`   r	   r  on_gc_minoron_gc_collect_stepr   )r  r  s     r   gc_cumulative_timer    s     ?2{##/7;CH~* LL;/R!!C D  xx##+'+$xx**2.2+r!   l1l2c           
          [        U 5      [        U5      :  a  g[        S [        U S [        U5       USS9 5       5      $ )NFc              3   .   #    U  H  u  pX:H  v   M     g 7frH   rU   .0v1v2s      r   	<genexpr>startswith.<locals>.<genexpr>  s     K&JFBrx&J   strictr   allzipr  r  s     r   
startswithr!    s9    
2wRKc"Ys2w-E&JKKKr!   c           	          [        U 5      [        U5      :  a  g[        S [        U [        U5      * S  USS9 5       5      $ )NFc              3   .   #    U  H  u  pX:H  v   M     g 7frH   rU   r  s      r   r  endswith.<locals>.<genexpr>  s     L&KFBrx&Kr  r  r  r   s     r   endswithr%    s;    
2wRLc"c"gXZ."U&KLLLr!   r=   c                     U S-   S-	  $ )zThe number of bytes required to represent an n-bit number.
Equivalent to (n + 7) // 8, but slightly faster. This really is
called enough times that that matters.      rU   )r=   s    r   bits_to_bytesr)    s     Ea<r!   )5r   r?   r  r   r   timer   r   collections.abcr   r   r   r   	threadingr   typingr	   r
   r   r   r   r   r   sortedcontainersr   hypothesis.errorsr   r   tupler5   r4   r    r#   r   r   r   r   r   r   r   r   r   r
  r   floatr   r   perf_counterr   r  r!  r%  r)  rU   r!   r   <module>r3     s  -  	  
    B B    ( /CL5c8A;!678 
!W,mIhsm mI`c s xt'<  $Swqz Sls  @< @<F () 6 %= %=P#HcUD[) #c #L 	5  U  !!0E 0fL8A; LHQK LD LM! M(1+ M$ MS S r!   