
    jj'              
         d dl mZ d dlZd dlZd dlmZ d dl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mZmZmZmZmZ ddlmZmZ dd	lmZ dd
lm Z  ddl!m"Z"m#Z#m$Z$ ejJ                  rd dlm&Z&m'Z' d dl(m)Z)  ejT                  d      Z+ ejT                  d      Z, G d de#      Z- G d de$      Z.ddZ/ G d dej`                        Z1 G d de"eeejd                  e+e,f         Z3y)    )annotationsN)MutableSequence)CanvasOverlayCompositeCanvas)remove_defaults   )RELATIVE_100AlignSizingVAlign
WHSettingsWrapModenormalize_alignnormalize_heightnormalize_valignnormalize_widthsimplify_alignsimplify_heightsimplify_valignsimplify_width) WidgetContainerListContentsMixinWidgetContainerMixin)calculate_top_bottom_filler)calculate_left_right_padding)WidgetWidgetErrorWidgetWarning)IteratorSequence)Literal	TopWidgetBottomWidgetc                      e Zd ZdZy)OverlayErrorzOverlay specific errors.N__name__
__module____qualname____doc__     ]/home/ubuntu/.cache/pipx/cdb5059130eadca/lib/python3.12/site-packages/urwid/widget/overlay.pyr$   r$   )   s    "r+   r$   c                      e Zd ZdZy)OverlayWarningzOverlay specific warnings.Nr%   r*   r+   r,   r.   r.   -   s    $r+   r.   c                    t        | t              sO| j                  j                   d| j                  j                   }t        j                  | dt        d       y y )N.z is not subclass of Widget   
stacklevel)
isinstancer   	__class__r'   r&   warningswarnDeprecationWarning)widgetobj_class_paths     r,   _check_widget_subclassr;   1   sY    ff%",,778&:J:J:S:S9TU89	
 &r+   c                      e Zd ZU ded<   ded<   ded<   ded<   ded<   d	ed
<   d	ed<   ded<   ded<   ded<   ded<   ded<   d	ed<   d	ed<   y)OverlayOptionsz$Align | Literal[WHSettings.RELATIVE]align
int | Nonealign_amountr   
width_typewidth_amount	min_widthintleftrightz%VAlign | Literal[WHSettings.RELATIVE]valign_typevalign_amountheight_typeheight_amount
min_heighttopbottomN)r&   r'   r(   __annotations__r*   r+   r,   r=   r=   ;   sR    //
IJ66	HKr+   r=   c                  D    e Zd ZdZdZ eej                  dej                  dddde
j                  dej                  dddd      Z	 	 	 	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d" fdZd#dZ	 	 d$	 	 	 	 	 d% fd	Zd&d'd
Zd( fdZd)dZed*d       Ze	 	 d+d       Zed,d       Ze	 	 d-d       Ze	 	 	 	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d.d       Z	 	 	 	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/dZd0dZ	 	 	 	 	 	 d1dZed2d       Zed3d       Zej>                  d4d       Zed5d       Z e j>                  d6d       Z 	 	 	 	 d7dZ!	 	 	 	 	 	 d8dZ"	 	 	 	 d9dZ#	 	 	 	 	 	 d:dZ$	 	 	 	 	 	 	 	 	 	 	 	 d;dZ%d&d<dZ&	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=d Z' xZ(S )>OverlayzOverlay contains two widgets and renders one on top of the other.

    Top widget can be Box, Flow or Fixed.
    Bottom widget should be Box.
    TNd   r   )r>   r@   rA   rB   rC   rE   rF   rG   rH   rI   rJ   rK   rL   rM   c                    t         |           || _        || _        | j	                  |||||||	|
||
       t        |       t        |       y)a  
        :param top_w: a flow, box or fixed widget to overlay "on top".
        :type top_w: Widget
        :param bottom_w: a box widget to appear "below" previous widget.
        :type bottom_w: Widget
        :param align: alignment, one of ``'left'``, ``'center'``, ``'right'`` or
            (``'relative'``, *percentage* 0=left 100=right)
        :type align: Literal["left", "center", "right"] | tuple[Literal["relative"], int]
        :param width: width type, one of:
            ``'pack'``
              if *top_w* is a fixed widget
            *given width*
              integer number of columns wide
            (``'relative'``, *percentage of total width*)
              make *top_w* width related to container width
        :type width: Literal["pack"] | int | tuple[Literal["relative"], int]
        :param valign: alignment mode, one of ``'top'``, ``'middle'``, ``'bottom'`` or
            (``'relative'``, *percentage* 0=top 100=bottom)
        :type valign: Literal["top", "middle", "bottom"] | tuple[Literal["relative"], int]
        :param height: one of:
            ``'pack'``
              if *top_w* is a flow or fixed widget
            *given height*
              integer number of rows high
            (``'relative'``, *percentage of total height*)
              make *top_w* height related to container height
        :type height: Literal["pack"] | int | tuple[Literal["relative"], int]
        :param min_width: the minimum number of columns for *top_w* when width is not fixed.
        :type min_width: int
        :param min_height: minimum number of rows for *top_w* when height is not fixed.
        :type min_height: int
        :param left: a fixed number of columns to add on the left.
        :type left: int
        :param right: a fixed number of columns to add on the right.
        :type right: int
        :param top: a fixed number of rows to add on the top.
        :type top: int
        :param bottom: a fixed number of rows to add on the bottom.
        :type bottom: int

        Overlay widgets behave similarly to :class:`Padding` and :class:`Filler`
        widgets when determining the size and position of *top_w*. *bottom_w* is
        always rendered the full size available "below" *top_w*.
        N)super__init__top_wbottom_wset_overlay_parametersr;   )selfrU   rV   r>   widthvalignheightrC   rK   rE   rF   rL   rM   r5   s                r,   rT   zOverlay.__init__f   sS    F 	
 ##E5&&)ZY]_dfikqru%x(r+   c           	        t         j                  h}| j                  j                         }| j                  t
        j                  k(  rt         j                  |v r*|j                  t         j                         t)        |      S t        j                  d| j                   dt         j                  j                          dt
        j                  j                          t        d       t)        |      S | j                  t
        j                  k(  r t         j                  |v r|j                  t         j                         | j                  r| j                  t
        j                   k(  s| j"                  r|j                  t         j                         t)        |      S t        j                  d| j                   dt         j                  j                          d| j                  j                          t        d       t)        |      S | j$                  r| j                  t
        j                   k(  s| j&                  rt         j                  |v r~|j                  t         j                         | j                  r| j                  t
        j                   k(  s| j"                  r|j                  t         j                         t)        |      S t        j                  d| j                   dt         j                  j                          d| j                  j                          t        d       t)        |      S )a"  Actual widget sizing.

        :returns: Sizing information depends on the top widget sizing and sizing parameters.
        :rtype: frozenset[Sizing]

        Rules:
        * BOX sizing is always supported provided by the bottom widget
        * FLOW sizing is supported if top widget has:
        * * PACK height type and FLOW supported by the TOP widget
        * * BOX supported by TOP widget AND height amount AND height type GIVEN of min_height
        * FIXED sizing is supported if top widget has:
        * * PACK width type and FIXED supported by the TOP widget
        * * width amount and GIVEN width or min_width AND:
        * * * FLOW supported by the TOP widget AND PACK height type
        * * * BOX supported by the TOP widget AND height_amount and GIVEN height or min height
        zTop widget z should support sizing z for width type r1   r2   z for height type )r   BOXrU   sizingrA   r   PACKFIXEDaddr6   r7   upperr.   rI   FLOWrB   GIVENrC   rJ   rK   	frozenset)rX   r^   
top_sizings      r,   r^   zOverlay.sizing   sq   " **ZZ&&(
??joo-||z)

6<<(H   E !$**-DV\\EWEWEYDZ [&&0oo&;&;&=%>@" 	D   7 0{{j(

6;;'$$$//Z=M=M*MQUQ_Q_JJv||,,   ) !$**-DV[[EVEVEXDY Z''+'7'7'='='?&@B" 	(    T%5%59I9I%IT__zzZ'

6;;'$$$//Z=M=M*MQUQ_Q_JJv||,    !$**-DVZZEUEUEWDX Y''+'7'7'='='?&@B" 	   r+   c                   |rt         |   ||      S | j                  xs d| j                  xs dz   }| j                  xs d| j
                  xs dz   }| j                  t        j                  k(  r)| j                  j                  d|      \  }}||z   ||z   fS | j                  st        d| j                   d| j                  j                          d| j                  d| j                  j                          d| j                  d| j                  d	| j                         | j                  t        j"                  k(  r| j                  }||z   }n| j                  t        j$                  k(  r7| j                  r+| j                  }t'        |d
z  | j                  z  dz         }nt        d| j                   d| j                  j                          d| j                  d| j                  j                          d| j                  d| j                  d	| j                         | j                  t        j                  k(  r"|| j                  j)                  |f|      |z   fS | j                  st        d| j                   d| j                  j                          d| j                  d| j                  j                          d| j                  d| j                  d	| j                         | j                  t        j"                  k(  r|| j                  |z   fS | j                  t        j$                  k(  r6| j                   r*|t'        | j                   d
z  | j                  z  dz         fS t        d| j                   d| j                  j                          d| j                  d| j                  j                          d| j                  d| j                  d	| j                         )Nr   r*   zRequested FIXED render for z with width_type=, width_amount=, height_type=, height_amount=
min_width=, min_height=rQ         ?)rS   packrE   rF   rL   rM   rA   r   r_   rU   rB   r$   rb   rI   rJ   rC   rK   rd   RELATIVErD   rows)	rX   sizefocus
extra_cols
extra_rowscolsrp   w_colsr5   s	           r,   rn   zOverlay.pack   s   
 7<e,,iin1q9
hhm!(8q9
??joo-U3JD$*$dZ&777  -djj\ :"oo3356 7  $ 1 14 5#//5578 9!!%!3!3 6T^^. /"oo02  ??j...&&FJ&D__
 3 33^^Fv|d&7&77#=>D-djj\ :"oo3356 7  $ 1 14 5#//5578 9!!%!3!3 6T^^. /"oo02  z.&E:ZGGG!!-djj\ :"oo3356 7  $ 1 14 5#//5578 9!!%!3!3 6T^^. /"oo02  z///++j888z222tT__s2T5G5GG#MNNN)$** 6////12 3 --0 1++1134 5!//2* +//,.
 	
r+   c                V   | j                   xs d| j                  xs dz   }| j                  t        j                  k(  r| j
                  |z   S | j                  t        j                  k(  r4| j                  r(t        | j                  dz  | j
                  z  dz         S | j                  t        j                  k(  r| j                   xs d| j                  xs dz   }| j                  t        j                  k(  r6| j                  r*| j                  j                  | j                  f|      |z   S | j                  t        j                  k(  rYt        t        |d   | j                  z  dz  dz         | j                  xs d      }| j                  j                  |f|      |z   S t!        d| j                   d|d| j                  j#                          d| j                  d| j                  j#                          d	| j
                  d
| j                  d| j                        )z#Widget rows amount for FLOW sizing.r   rQ   rm   zRequested rows for z with size zwidth_type=rh   ri   rj   rk   rl   )rL   rM   rI   r   rd   rJ   ro   rK   rD   r_   rA   rB   rU   rp   maxrC   r$   rb   )rX   rq   rr   extra_heightrY   s        r,   rp   zOverlay.rows7  s   A$++*:;z///%%44z222tt,t/A/AACGHHz. HHMdkk.>Q?L*"2"22t7H7Hzz(9(9';UClRR*"5"55CQ$*;*; ;c AC GH4>>K^]^`zzx7,FF!$**[$////12 3 --0 1++1134 5!//2* +//,.
 	
r+   c                f   i t         |          | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  d}t        |t        j                         S )NrU   rV   r>   rY   rZ   r[   rC   rK   rE   rF   rL   rM   )rS   _repr_attrsrU   rV   r>   rY   rZ   r[   rC   rK   rE   rF   rL   rM   r   rP   rT   )rX   attrsr5   s     r,   r|   zOverlay._repr_attrsQ  s    
g!#
ZZZZZZkkkk//IIZZ88kk
 ug&6&677r+   c              #    K   d| j                   f d| j                  f d| j                  f d| j                  f d| j                  f d| j
                  f d| j                  f d| j                  f d	| j                  f d
| j                  f d| j                  f d| j                  f y w)NrL   rM   r>   rY   rZ   r[   rC   rK   rE   rF   r{   rX   s    r,   __rich_repr__zOverlay.__rich_repr__c  s     TZZ%%tzz!!tzz!!####4>>))DOO++diitzz!!TXXo##s   CCc                B    t        | j                  | j                        S N)r   
align_typer@   r   s    r,   r>   zOverlay.alignq  s    doot/@/@AAr+   c                B    t        | j                  | j                        S r   )r   rA   rB   r   s    r,   rY   zOverlay.widthu  s     doot/@/@AAr+   c                B    t        | j                  | j                        S r   )r   rG   rH   r   s    r,   rZ   zOverlay.valign  s    t//1C1CDDr+   c                B    t        | j                  | j                        S r   )r   rI   rJ   r   s    r,   r[   zOverlay.height  s     t//1C1CDDr+   c                   | t         j                  t         j                  t         j                  hv rt        |       }n2| t        j
                  k(  rt        j
                  }nt        d|       |t        j                  t        j                  t        j                  hv rt        |      }n2|t        j
                  k(  rt        j
                  }nt        d|      t        ||t	        |      |||
|||t	        |      ||	||      S )an  
        Return a new options tuple for use in this Overlay's .contents mapping.

        This is the common container API to create options for replacing the
        top widget of this Overlay.  It is provided for completeness
        but is not necessarily the easiest way to change the overlay parameters.
        See also :meth:`.set_overlay_parameters`
        zUnknown alignment type z Unknown vertical alignment type )r
   LEFTCENTERRIGHTr   ro   
ValueErrorr   TOPMIDDLEBOTTOMr=   )r   r@   rA   rB   rG   rH   rI   rJ   rC   rK   rE   rF   rL   rM   r>   rZ   s                   r,   optionszOverlay.options  s    2 %**ellEKK@@*%E:...''E6znEFF6::v}}fmmDDK(FJ///((F?OPPz"{#
 	
r+   c                &   t        |t              r?|d   dk(  r|d   }t        j                  }n,|d   dk(  r|d   }t        j                  }n|}nt        |      }t        |t              r'|d   dk(  r|d   }t
        }n|d   dk(  r|d   }t
        }t        |t              r?|d   dk(  r|d   }	t        j                  }nP|d   dk(  r|d   }
t        j                  }n2|}n/t        |t        t        f      st        d|      t        |      }t        |t              r'|d   dk(  r|d   }
t
        }n|d   dk(  r|d   }	t
        }|t        j                  }|t        j                  }t        |t              \  }}t        |t              \  }}t        |t              \  }}t!        |t              \  }}|t        j"                  t        j                  hv rd}| j$                  | j'                  |||||||||||||	|
      f| j(                  d<   y)	z
        Adjust the overlay size and position parameters.

        See :class:`__init__() <Overlay>` for a description of the parameters.
        r   z
fixed leftr   zfixed rightz	fixed topzfixed bottomzinvalid valign: N)r4   tupler
   r   r   r	   r   r   r   strr$   r   r_   r   r   r   r   rd   rU   r   contents)rX   r>   rY   rZ   r[   rC   rK   rE   rF   rL   rM   normalized_alignnormalized_valignr   r@   rA   rB   rG   rH   rI   rJ   s                        r,   rW   zOverlay.set_overlay_parameters  s    8 eU#Qx<'Qx#(:: q]*a#(;; #( $U|eU#Qx<'Qx$q]*a$fe$ayK'Qi$*JJ!n,$*MM!$*!FVSM2!1&<== !'vfe$ayN*%k)Qi%=OOE>__F#23C\#R 
L#25,#G 
L%56G%V"]%5fl%K"]:++Z__==J JJLL
ar+   c                6    | j                   j                         S )zReturn selectable from top_w.)rU   
selectabler   s    r,   r   zOverlay.selectable1  s    zz$$&&r+   c           	         | j                  |d      }| j                  j                   | j                  |g| j	                  |d       |      S )zPass keypress to top_w.T)rn   rU   keypress
top_w_sizecalculate_padding_filler)rX   rq   key	real_sizes       r,   r   zOverlay.keypress5  sO     IIdD)	zz""DOOIW(E(EiQU(VW
 	
r+   c                    | j                   S )z
        Read-only property returning the child widget in focus for
        container widgets.  This default implementation
        always returns ``None``, indicating that this widget has no children.
        )rU   r   s    r,   rr   zOverlay.focusA  s     zzr+   c                     y)zF
        Return the top widget position (currently always 1).
        r   r*   r   s    r,   focus_positionzOverlay.focus_positionJ  s    
 r+   c                *    |dk7  rt        d|       y)z
        Set the widget in focus.  Currently only position 0 is accepted.

        position -- index of child widget to be made focus
        r   zEOverlay widget focus_position currently must always be set to 1, not N)
IndexError)rX   positions     r,   r   zOverlay.focus_positionQ  s%     q=demdnopp r+   c           	           G  fddt         t        t        j                  t        t
        f   t        f            } |       S )a-  
        a list-like object similar to::

            [(bottom_w, bottom_options)),
             (top_w, top_options)]

        This object may be used to read or update top and bottom widgets and
        top widgets's options, but no widgets may be added or removed.

        `top_options` takes the form
        `(align_type, align_amount, width_type, width_amount, min_width, left,
        right, valign_type, valign_amount, height_type, height_amount,
        min_height, top, bottom)`

        bottom_options is always
        `('left', None, 'relative', 100, None, 0, 0,
        'top', None, 'relative', 100, None, 0, 0)`
        which means that bottom widget always covers the full area of the Overlay.
        writing a different value for `bottom_options` raises an
        :exc:`OverlayError`.
        c                  v    e Zd ZddZW  j                  ZW  j                  Zd	dZd
dZ	d fdZ
ddZddZy))Overlay.contents.<locals>.OverlayContentsc                     yN   r*   )
inner_selfs    r,   __len__z1Overlay.contents.<locals>.OverlayContents.__len__}  s    r+   c                    t        d      Nz'OverlayContents is fixed-sized sequence	TypeErrorrX   indexs     r,   __delitem__z5Overlay.contents.<locals>.OverlayContents.__delitem__       IJJr+   c                    t        d      r   r   )rX   r   values      r,   insertz0Overlay.contents.<locals>.OverlayContents.insert  r   r+   c                d    t        d| j                  j                   d| d   | d   g d       S )N<(r   r   z)> for )reprr5   r&   )r   rX   s    r,   __repr__z2Overlay.contents.<locals>.OverlayContents.__repr__  sB    a
 4 4 = =>aAPZ[\P]@^?__fgkflmnnr+   c              3  &   K   | D ]  }d |f 
 y wr   r*   )r   vals     r,   r   z7Overlay.contents.<locals>.OverlayContents.__rich_repr__  s     % $C)O$s   c              3  :   K   t        d      D ]	  }| |     y wr   )range)r   idxs     r,   __iter__z2Overlay.contents.<locals>.OverlayContents.__iter__  s#      8 *C$S/)*s   N)returnrD   )r   int | slicer   typing.NoReturn)r   r   r   z
typing.Anyr   r   )r   r   r   z4Iterator[tuple[str | None, typing.Any] | typing.Any])r   z'Iterator[tuple[Widget, OverlayOptions]])r&   r'   r(   r   _contents__getitem____getitem___contents__setitem____setitem__r   r   r   r   r   r   s   r,   OverlayContentsr   t  s<     33K33KKKo$*r+   r   )r   r   typingUnionr!   r"   r=   )rX   r   s   ` r,   r   zOverlay.contents[  sB    2	*LLL!89"$	*@   r+   c                ~    t        |      dk7  rt        d      |d   | j                  d<   |d   | j                  d<   y )Nr   z,Contents length for overlay should be only 2r   r   )lenr   r   )rX   new_contentss     r,   r   zOverlay.contents  s?    |!KLL'?a'?ar+   c                   |dk(  r| j                   | j                  fS |dk(  r| j                  t        | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                   | j"                        fS t%        d|      )Nr   r   !Overlay.contents has no position )rV   _DEFAULT_BOTTOM_OPTIONSrU   r=   r   r@   rA   rB   rC   rE   rF   rG   rH   rI   rJ   rK   rL   rM   r   r   s     r,   r   zOverlay._contents__getitem__  s     A:MM4#?#?@@A:

OO%%OO%%NNIIJJ$$&&$$&&OOHHKK & <UIFGGr+   c                   	 |\  }}|dk(  r/|| j
                  k7  rt        d| j
                        || _        n|dk(  r	 |\  }}}}	}
}}}}}}}}}t        t        ||      t              \  }}t        t        ||	      t              \  }}	t        t        ||      t              \  }}t        t        ||      t              \  }}|| _        || _        || _        |	| _        || _        || _        || _        || _        || _        || _        || _        || _        |
| _        || _        nt;        d|      | j=                          y # t         t        f$ r-}t        d|      j                  |j                        |d }~ww xY w# t         t        f$ r-}t        d|      j                  |j                        |d }~ww xY w)Nzadded content invalid: r   zbottom_options must be set to r   ztop_options is invalid: r   )r   r   r$   with_traceback__traceback__r   rV   r   r   r   r   r   r   r   r   r   r@   rA   rB   rG   rH   rI   rJ   rE   rF   rL   rM   rC   rK   r   _invalidate)rX   r   r   value_wvalue_optionsexcr   r@   rA   rB   rC   rE   rF   rG   rH   rI   rJ   rK   rL   rM   s                       r,   r   zOverlay._contents__setitem__  s    
	o%*"G] A: < <<"%CDD`D`Cc#dee#DMaZ  "  !! (7~jR^7_am'n$J'6~jR^7_am'n$J)9/+Wd:egs)t&K)9/+Wd:egs)t&K(DO ,D(DO ,D*D!.D*D!.DDIDJDH DK&DN(DO@	JKKc I& 	o!8	BCRRSVSdSdeknn	o0 	* "%=m=N#OP__%%s/   E F F(E??FG(F>>Gc                   t        | j                  d      sy| j                  |d      }|\  }}| j                  |d      \  }}}}| j                  j	                  ||z
  |z
  ||z
  |z
  f      \  }	}
|
|k\  r|dz
  }
|	|z   |
|z   fS )z(Return cursor coords from top_w, if any.get_cursor_coordsNTr   )hasattrrU   rn   r   r   )rX   rq   r   maxcolmaxrowrE   rF   rL   rM   xys              r,   r   zOverlay.get_cursor_coords  s    
 tzz#67IIdD)	$#'#@#@D#Q eS&zz++Vd]U-BFSLSYDY,Z[1;
A4xS  r+   c           
        |\  }}d}| j                   t        j                  k(  ry| j                  j	                  d|      \  }}|st        d      t        || j                  | j                  t        j                  |d| j                  | j                        \  }}n[t        || j                  | j                  | j                   | j                  | j                  | j                  | j                        \  }}|r_t        || j                   | j"                  t        j$                  |d| j&                  | j(                        \  }	}
||	z
  |
z
  |k  r||	z
  |z
  }
n| j*                  t        j                  k(  rt| j                  j-                  |f|      }t        || j                   | j"                  t        j$                  |d| j&                  | j(                        \  }	}
||kD  ra||z
  }
n[t        || j                   | j"                  | j*                  | j.                  | j0                  | j&                  | j(                        \  }	}
|||	|
fS )z1Return (padding left, right, filler top, bottom).Nr*   )rr   zfixed widget must have a height)rA   r   r_   rU   rn   r$   r   r   r@   r   CLIPrE   rF   rB   rC   r   rG   rH   rd   rL   rM   rI   rp   rJ   rK   )rX   rq   rr   r   r   r[   rY   rE   rF   rL   rM   s              r,   r   z Overlay.calculate_padding_filler  s     ??joo- JJOOBeO<ME6"#DEE6!!		

	KD% 7!!!!		

	KD% 5  ""  	KC |f$v-#.0ZZ__fYe_<F5  ""  	KC &5  ""  ""	KC UC''r+   c                    | j                   t        j                  k(  ry|\  }}| j                   t        j                  k7  r&| j                  t        j                  k(  r	||z
  |z
  fS ||z
  |z
  ||z
  |z
  fS )z!Return the size to pass to top_w.r*   )rA   r   r_   rI   )rX   rq   rE   rF   rL   rM   r   r   s           r,   r   zOverlay.top_w_sizeO  sp     ??joo-??joo-$2B2Bjoo2UTME)++%v|f'<==r+   c           	     0   | j                  ||      }| j                  ||      \  }}}}| j                  j                  |      }|j	                         r|j                         st        |      S | j                  j                  | j                  |||||      |      }	t        |	      }	|dk  s|dk  r&|	j                  t        d|      t        d|             |dk  s|dk  r&|	j                  t        d|      t        d|             t        |	|||      S )z#Render top_w overlayed on bottom_w.r   )rn   r   rV   renderru   rp   r   rU   r   pad_trim_left_rightminpad_trim_top_bottomr   )
rX   rq   rr   r   rE   rF   rL   rM   bottom_ctop_cs
             r,   r   zOverlay.rendera  s    IIdE*	#'#@#@E#R eS&==''	2}}hmmo"8,,

!!$//)T5#v"VX]^&!8uqy%%c!TlC5MB7fqj%%c!Sk3q&>BUHdC88r+   c           	     4   t        | j                  d      sy| j                  ||      }| j                  ||      \  }}	}
}|\  }}||k  s|||	z
  k\  s||
k  s|||z
  k\  ry| j                  j	                  | j                  |||	|
|      ||||z
  ||
z
  |      S )z0Pass event to top_w, ignore if outside of top_w.mouse_eventF)r   rU   rn   r   r   r   )rX   rq   eventbuttoncolrowrr   r   rE   rF   rL   rM   r   r   s                 r,   r   zOverlay.mouse_events  s     tzz=1IIdE*	#'#@#@E#R eS&":.#)sfvo?Uzz%%OOItUC@$J#I
 	
r+   )NNr   r   r   r   )rU   r!   rV   r"   r>   ~Literal['left', 'center', 'right'] | Align | tuple[Literal['relative', 'fixed left', 'fixed right', WHSettings.RELATIVE], int]rY   dLiteral['pack', WHSettings.PACK] | int | tuple[Literal['relative', WHSettings.RELATIVE], int] | NonerZ   Literal['top', 'middle', 'bottom'] | VAlign | tuple[Literal['relative', 'fixed top', 'fixed bottom', WHSettings.RELATIVE], int]r[   r   rC   r?   rK   r?   rE   rD   rF   rD   rL   rD   rM   rD   r   None)r   zfrozenset[Sizing])r*   F)rq   (tuple[()] | tuple[int] | tuple[int, int]rr   boolr   tuple[int, int])F)rq   z
tuple[int]rr   r   r   rD   )r   zdict[str, typing.Any]r   )r   z0Align | tuple[Literal[WHSettings.RELATIVE], int])r   zLiteral[WHSettings.CLIP, WHSettings.PACK] | int | tuple[Literal[WHSettings.RELATIVE], int] | tuple[Literal[WHSettings.WEIGHT], int | float])r   z1VAlign | tuple[Literal[WHSettings.RELATIVE], int])r   zint | Literal[WHSettings.FLOW, WHSettings.PACK] | tuple[Literal[WHSettings.RELATIVE], int] | tuple[Literal[WHSettings.WEIGHT], int | float])r   zKLiteral['left', 'center', 'right', 'relative', WHSettings.RELATIVE] | Alignr@   r?   rA   z9Literal['clip', 'pack', 'relative', 'given'] | WHSettingsrB   r?   rG   zLLiteral['top', 'middle', 'bottom', 'relative', WHSettings.RELATIVE] | VAlignrH   r?   rI   z9Literal['flow', 'pack', 'relative', 'given'] | WHSettingsrJ   r?   rC   r?   rK   r?   rE   rD   rF   rD   rL   rD   rM   rD   r   r=   )r>   r   rY   r   rZ   r   r[   r   rC   r?   rK   r?   rE   rD   rF   rD   rL   rD   rM   rD   r   r   )r   r   )rq   r   r   r   r   z
str | None)r   r!   )r   z
Literal[1])r   rD   r   r   )r   z@MutableSequence[tuple[TopWidget | BottomWidget, OverlayOptions]])r   z&Sequence[tuple[width, OverlayOptions]]r   r   )r   Literal[0, 1]r   /tuple[TopWidget | BottomWidget, OverlayOptions])r   r   r   r   r   r   )rq   r   r   ztuple[int, int] | None)rq   r   rr   r   r   ztuple[int, int, int, int])rq   r   rE   rD   rF   rD   rL   rD   rM   rD   r   r   )rq   r   rr   r   r   r   )rq   r   r   r   r   rD   r   rD   r   rD   rr   r   r   zbool | None))r&   r'   r(   r)   _selectabler=   r
   r   r   ro   r   r   r   rT   r^   rn   rp   r|   r   propertyr>   rY   rZ   r[   staticmethodr   rW   r   r   rr   r   setterr   r   r   r   r   r   r   r   __classcell__)r5   s   @r,   rP   rP   L   s    K,jj&&JJ''B !%!%+K)K) K)
`K) tK)`K) uK)  !K)" #K)$ %K)& 'K)( )K)* +K), 
-K)Z9!z :<G
6G
 G
 
	G
R
48$$ B B B	9B B E E E	9E E  !%!%5
_5
 5
 N5
 !	5

 b5
 "5
 O5
 "5
 5
 5
 5
 5
 5
 5
 
5
 5
J !%!%'h
`h
 th
`h
 uh
 h
 h
  !h
" #h
$ %h
& 'h
( 
)h
T'

6

 

 
	

     q q 8! 8!t __+ +HH 
9H:88 ?8 
	8t!6! 
 !J(J( J( 
#	J(X>> > 	>
 > > 
2>$9$
6
 
 	

 
 
 
 

r+   rP   )r9   r   r   r   )4
__future__r   r   r6   collections.abcr   urwid.canvasr   r   urwid.split_reprr   	constantsr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   	containerr   r   fillerr   paddingr   r9   r   r   r   TYPE_CHECKINGr   r   typing_extensionsr    TypeVarr!   r"   r$   r.   r;   
NamedTupler=   GenericrP   r*   r+   r,   <module>r     s    "   + 7 ,     N / 1 6 6	2) FNN;'	v~~n-#; #%] %
V&& "B
f*,Lfnn]fht]tNu B
r+   