
    Cj1                        S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  S SK
JrJrJr  \(       a  S SKJr   " S S\5      rg	)
    )annotations)zip_longest)TYPE_CHECKING)NULL_OFFSETRegionSize)ArrangeResultLayoutWidgetPlacement)Widgetc                  ~   ^  \ rS rSrSrSrS	U 4S jjr S
         SS jjrSS jr          SS jr	Sr
U =r$ )StreamLayout   a  A cut down version of the vertical layout.

The stream layout is faster, but has a few limitations compared to the vertical layout.

- All widgets are the full width (as if their widget is `1fr`).
- All widgets have an effective height of `auto`.
- `max-height` is supported, but only if it is a units value, all other extrema rules are ignored.
- No absolute positioning.
- No overlay: screen.
- Layers are ignored.
- Non TCSS styles are ignored.

The primary use of `layout: stream` is for a long list of widgets in a scrolling container, such as
what you might expect from a LLM chat-bot. The speed improvement will only be significant with a lot of
child widgets, so stick to vertical layouts unless you see any slowdown.

streamc                >   > S U l         SU l        [        TU ]  5         g )Nr   )_cached_placements_cached_widthsuper__init__)self	__class__s    h/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/layouts/stream.pyr   StreamLayout.__init__"   s    @D    c                Z   UR                  U 5        U(       d  / $ UR                  R                  nUR                  U R                  :w  a  S U l        U R
                  =(       d    / nUR                  R                  R                  U/ 5      n[        n[        n	/ n
UR                  nUS   R                  nSnUR                  R                  n[        n[        U=(       a    U5      n[!        X&5       GH  u  nnU(       ap  Ubm  UUR"                  L a^  UU;   a  SnOUU
R%                  U5        UR&                  R(                  nUR                  R*                  nUR                  R(                  nM~  Uc    GOUR                  R*                  nUR                  nUR,                  R.                  u  nnUu  nnnnUUU:  a  UOU-  nUnUR1                  X5UU-
  5      U-   nUR2                  =nb0  UR4                  (       a  U[7        UR8                  5      =n:  a  UOUnUR:                  =nb0  UR4                  (       a  U[7        UR8                  5      =n:  a  UOUnU
R%                  U	" U" UXUU-   -
  U5      UUUSSSS5      5        UU-  nGM     UR                  U l        Xl        U
$ )Nr   F)
pre_layoutappviewport_sizewidthr   r   screen_layout_widgetsgetr   r   stylesmargintopr   boolr   widgetappendregionbottom_base_stylesguttertotalsget_content_height
max_heightis_cellsintvalue
min_height) r   parentchildrensizegreedyviewportprevious_resultslayout_widgets_Region_WidgetPlacement
placementsr   first_child_stylesyprevious_marginnull_offsetpre_populater'   	placementr#   r$   gutter_widthgutter_heightr%   rightr*   leftheightr/   max_height_valuer3   min_height_values                                    r   arrangeStreamLayout.arrange'   s    	$I::++::+++&*D#228b66::62F*,.


%a[//,3377!,?@!,X!HFI	 5&IDTDT:T^+#(L%%i0!((//A#]]77F&,mm&:&:O~]]//F]]F*0--*>*>'L-'-$Co-?BA$O))$%,:NO   %///
<ATAT S9I9I5J!J!1K ) 
 %///
<ATAT S9I9I5J!J!1K ) 
  D!dUl%;VD	 KA_ "Ib "ZZ",r   c                .    UR                   R                  $ )zGet the optimal content width by arranging children.

Args:
    widget: The container widget.
    container: The container size.
    viewport: The viewport size.

Returns:
    Width of the content.
)scrollable_content_regionr   )r   r'   	containerr8   s       r   get_content_widthStreamLayout.get_content_widthu   s     //555r   c                    UR                   (       a3  UR                  [        US5      5      nUR                  R                  nU$ SnU$ )zGet the content height.

Args:
    widget: The container widget.
    container: The container size.
    viewport: The viewport.
    width: The content width.

Returns:
    Content height (in lines).
r   )_nodesrK   r   total_regionrH   )r   r'   rO   r8   r   arrangementrH   s          r   r.   StreamLayout.get_content_height   sC     == ..eQ8K --44F  Fr   )r   r   )returnNone)T)
r4   r   r5   zlist[Widget]r6   r   r7   r&   rW   r	   )r'   r   rO   r   r8   r   rW   r1   )
r'   r   rO   r   r8   r   r   r1   rW   r1   )__name__
__module____qualname____firstlineno____doc__namer   rK   rP   r.   __static_attributes____classcell__)r   s   @r   r   r      s    $ D RVLL(4L<@LJNL	L\6)-9=FI	 r   r   N)
__future__r   	itertoolsr   typingr   textual.geometryr   r   r   textual.layoutr	   r
   r   textual.widgetr   r    r   r   <module>rh      s.    " !   6 6 A A%H6 Hr   