
    k7i_              
          S SK r S SKrS SKJ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  \(       a4  S SKJr  S SKJrJrJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJ r    " S S5      r! " S S5      r" " S S5      r#\ " S S5      5       r$\$" \#" 5       SSSSS9r%\$" \!" 5       SSSS9r&\$" \"" 5       SSS S!9r'S"S#S$S%S&\(S'   S(\)\$S)4   4S* jr*S"S#S$S%S&\(S'   S(\)\$S)4   4S+ jr+\ " S, S-5      5       r,\ " S. S/5      5       r-g)0    N)Iterable)
attrgetter)TYPE_CHECKINGLiteralOptionalUnionevolve)frozen)Box)ConsoleConsoleOptionsRenderableType)PaddingDimensionsPanel)	StyleTypeTable)	HelpEntry)Rendererc                   :    \ rS rSrSrSS\S-  4S jjrS	S jrSrg)
NameRenderer   zRenderer for parameter/command names with optional text wrapping.

Parameters
----------
max_width : int | None
    Maximum width for wrapping. If None, no wrapping is applied.
N	max_widthc                     Xl         g)zInitialize the renderer with formatting options.

Parameters
----------
max_width : int | None
    Maximum width for wrapping. If None, no wrapping is applied.
Nr   )selfr   s     M/home/james-whalen/.local/lib/python3.13/site-packages/cyclopts/help/specs.py__init__NameRenderer.__init__    s	     #    c                    UR                   (       a  SR                  UR                   5      OSnUR                  (       a  SR                  UR                  5      OSnU(       a  U(       a	  US-   U-   nOU=(       d    UnU R                  c  U$ [        R
                  " UU R                  SSSS9nSR                  U5      $ )zRender the names column with optional text wrapping.

Parameters
----------
entry : HelpEntry
    The table entry to render.

Returns
-------
~rich.console.RenderableType
    Combined names and shorts, optionally wrapped.
  z  F   )subsequent_indentbreak_on_hyphenstabsize
)namesjoinshortsr   textwrapwrap)r   entry	names_str
shorts_strtextwrappeds         r   __call__NameRenderer.__call__*   s     .3[[CHHU[[)b	/4||SXXell+
s?Z/D*
D>>!K--NN""
 yy!!r"   r   Nr0   r   returnr   )	__name__
__module____qualname____firstlineno____doc__intr    r5   __static_attributes__ r"   r   r   r      s    ##* # "r"   r   c                   4    \ rS rSrSrSS\4S jjrS	S jrSrg)
DescriptionRendererM   a  Renderer for descriptions with configurable metadata formatting.

Parameters
----------
newline_metadata : bool
    If True, display metadata (choices, env vars, defaults) on separate lines.
    If False (default), display metadata inline with the description.
newline_metadatac                     Xl         g)zInitialize the renderer with formatting options.

Parameters
----------
newline_metadata : bool
    If True, display metadata on separate lines instead of inline.
NrE   )r   rE   s     r   r    DescriptionRenderer.__init__W   s
     !1r"   c                    SSK Jn  SSKJn  UR                  nUc  U" U" 5       5      nOQ[        XC5      (       dA  [        UR                  S5      (       a	  U" U5      nOSSK Jn  U" U" [        U5      5      5      n/ nUR                  (       a7  SR                  UR                  5      nUR                  U" SU S3S5      5        UR                  (       a7  SR                  UR                  5      nUR                  U" S	U S3S5      5        UR                  b&  UR                  U" S
UR                   S3S5      5        UR                  (       a  UR                  U" SS5      5        U R                  (       an  U(       ag  SSKJn  SSK Jn  / n	UR"                  (       a  U	R                  UR"                  5        U H  n
U	R                  U
5        M     U	(       a  U" U	6 $ U" 5       $ U H  n
UR                  U
5        M     U$ )a?  Render parameter description with metadata annotations.

Enriches the base description with choices, environment variables,
default values, and required status.

Parameters
----------
entry : HelpEntry
    The table entry to render.

Returns
-------
~rich.console.RenderableType
    Description with appended metadata.
r   )Text)
InlineText__rich_console__z, z
[choices: ]dimz
[env var: z
[default: z
[required]zdim red)Group)	rich.textrJ   cyclopts.help.inline_textrK   description
isinstancehasattrstrchoicesr,   appendenv_vardefaultrequiredrE   rich.consolerO   primary_renderable)r   r0   rJ   rK   rR   metadata_itemschoices_strenv_vars_str	RichGrouprenderablesitems              r   r5   DescriptionRenderer.__call__a   s     	#8''$TV,KK44u((*<==(5 +(c+.>)?@ ==))EMM2K!!$*[M'CU"KL==99U]]3L!!$*\N!'De"LM==$!!$*U]]O1'Eu"MN>>!!$}i"@A   ^7& K --"";#A#AB '""4( ' /:9k*EtvE '""4( ' r"   rG   N)Fr8   )	r:   r;   r<   r=   r>   boolr    r5   r@   rA   r"   r   rC   rC   M   s    1 1Kr"   rC   c                   "    \ rS rSrSrSS jrSrg)AsteriskRenderer   z~Renderer for required parameter asterisk indicator.

A simple renderer that displays an asterisk (*) for required parameters.
c                 ,    UR                   (       a  S$ S$ )zRender an asterisk for required parameters.

Parameters
----------
entry : HelpEntry
    The table entry to render.

Returns
-------
~rich.console.RenderableType
    An asterisk if the entry is required, empty string otherwise.
*r%   rZ   )r   r0   s     r   r5   AsteriskRenderer.__call__   s     nns,",r"   rA   Nr8   )r:   r;   r<   r=   r>   r5   r@   rA   r"   r   rf   rf      s    
-r"   rf   c                   b   \ rS rSr% Sr\\S4   \S'    Sr\\S'    Sr	\\S'    Sr
\S	   \S
'    Sr\S	   \S'    Sr\S	   \S'    Sr\S   \S'    Sr\S   \S'    Sr\S   \S'    Sr\S-  \S'    Sr\S-  \S'    Sr\S-  \S'    Sr\S-  \S'    Sr\\S'    Sr\S-  \S'    S S jrS rSrg)!
ColumnSpec   a  Specification for a single column in a help table.

Used by :class:`~cyclopts.help.formatters.default.DefaultFormatter` to define
how individual columns are rendered in help tables. Each column can have its
own renderer, styling, and layout properties.

See Also
--------
~cyclopts.help.formatters.default.DefaultFormatter : The formatter that uses these specs.
~cyclopts.help.specs.TableSpec : Specification for the entire table.
~cyclopts.help.specs.PanelSpec : Specification for the outer panel.
r   rendererr%   headerfooterNr   header_stylefooter_stylestyleleft)rY   ru   centerrightfulljustifytop)rz   middlebottomverticalellipsis)foldcropr~   ignoreoverflowwidth	min_widthr   ratioFno_wrap	highlightc                     [        U R                  [        5      (       a  [        U R                  5      " U5      nO.[	        U R                  5      (       a  U R                  U5      nOSnUc  S$ U$ )zRender the cell content based on the renderer type.

If renderer is a string, retrieves that attribute from the entry.
If renderer is callable, calls it with the entry.
Nr%   )rS   ro   rU   r   callable)r   r0   values      r   _render_cellColumnSpec._render_cellL  sY     dmmS))t}}-e4Edmm$$MM%(EE]r--r"   c                     [        U 40 UD6$ r7   r	   r   kwargss     r   copyColumnSpec.copyZ      d%f%%r"   rA   r8   )r:   r;   r<   r=   r>   r   rU   __annotations__rp   rq   rr   r   rs   rt   ry   r   r}   r   r   r?   r   r   r   r   rd   r   r   r   r@   rA   r"   r   rm   rm      sM    CO$$* FC
 FC
 +/L(;'.
 +/L(;'.
 $(E8K '
 FLGWABK
 49Hg/08
 ?IHg:;H
 E3:
 !IsTz 
 !IsTz 
 E3:
 GT
 "Itd{!
.&r"   rm   r%   ru      zred bold)ro   rp   ry   r   rt   Optioncyan)ro   rp   ry   rt   Descriptionr   )ro   rp   ry   r   consoler   optionsr   entriesr   r9   .c                     [         R                  " U R                  S-  5      n[        [	        US9SSSUS9nU[
        4$ )al  Get default column specifications for command display.

Parameters
----------
console : ~rich.console.Console
    Rich console for width calculations.
options : ~rich.console.ConsoleOptions
    Console rendering options.
entries : list[HelpEntry]
    Command entries to display.

Returns
-------
tuple[ColumnSpec, ...]
    Column specifications for command table.
ffffff?r   Commandru   r   ro   rp   ry   rt   r   )mathceilr   rm   r   DescriptionColumn)r   r   r   r   command_columns        r   get_default_command_columnsr   q  sK    & 		'--$./I	2N 	 r"   c                     [         R                  " U R                  S-  5      n[        [	        US9SSSUS9n[        S U 5       5      (       a  [        U[        4$ U[        4$ )ar  Get default column specifications for parameter display.

Parameters
----------
console : ~rich.console.Console
    Rich console for width calculations.
options : ~rich.console.ConsoleOptions
    Console rendering options.
entries : list[HelpEntry]
    Parameter entries to display.

Returns
-------
tuple[ColumnSpec, ...]
    Column specifications for parameter table.
r   r   r   ru   r   r   c              3   8   #    U  H  oR                   v   M     g 7fr7   rj   ).0xs     r   	<genexpr>0get_default_parameter_columns.<locals>.<genexpr>  s     
'w!::ws   )r   r   r   rm   r   anyAsteriskColumnr   )r   r   r   r   name_columns        r   get_default_parameter_columnsr     sq    & 		'--$./I	2K 
'w
'''
 	
 
 	
r"   c                      \ rS rSr% SrSr\S-  \S'    Sr\S-  \S'    Sr	\
S   \S'    Sr\
S   \S'    Sr\
S   \S	'    Sr\
S   \S
'    Sr\
S   \S'    Sr\\S'    Sr\\S'    Sr\\S'    Sr\\S'    Sr\\S'    Sr\\S'    SrS\S'    Sr\\S'    Sr\S-  \S'    Sr\S-  \S'    Sr\S-  \S'    S\\S4   S\S   S S!4S" jrS# r S$r!g)%	TableSpeci  a   Specification for table layout and styling.

Used by :class:`~cyclopts.help.formatters.default.DefaultFormatter` to control
the appearance of tables that display commands and parameters. This spec defines
table-wide properties like borders, headers, and padding.

See Also
--------
~cyclopts.help.formatters.default.DefaultFormatter : The formatter that uses these specs.
~cyclopts.help.specs.ColumnSpec : Specification for individual columns.
~cyclopts.help.specs.PanelSpec : Specification for the outer panel.
Ntitlecaptionr   rt   border_stylerr   rs   r   boxFshow_headershow_footer
show_linesT	show_edgeexpandpad_edge)r      r   r   r   paddingcollapse_paddingr   r   safe_boxcolumns.r   r   r9   r   c                 n   U R                   nU(       a  [        S U 5       5      (       a  Sn0 SU R                  _SU R                  _SU R                  _SU R
                  _SU R                  _SU R                  _S	U R                  _S
U_SU R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                  _SU R                   _SU R"                  _SU R$                  0EnUR'                  U5        SSKJn  U" S0 UD6nU H  nUR,                  UR.                  UR                  UR                  UR                  UR0                  UR2                  UR4                  UR                   UR"                  UR6                  UR8                  UR:                  S.n	UR<                  b  UR<                  U	S'   UR>                  " S0 U	D6  M     U H2  n
U Vs/ s H  oRA                  U
5      PM     nnURB                  " U6   M4     U$ s  snf )aM  Construct and populate a rich.Table.

Parameters
----------
columns : tuple[ColumnSpec, ...]
    Column specifications defining the table structure.
entries : Iterable[HelpEntry]
    Table entries to populate the table with.
**overrides
    Per-render overrides for table settings.

Returns
-------
Table
    A populated Rich Table.
c              3   B   #    U  H  oR                   (       + v   M     g 7fr7   )rp   )r   cols     r   r   "TableSpec.build.<locals>.<genexpr>Q  s     A#::~~s   Fr   r   rt   r   rr   rs   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )rp   rq   rr   rs   rt   ry   r}   r   r   r   r   r   r   r   rA   )"r   allr   r   rt   r   rr   rs   r   r   r   r   r   r   r   r   r   r   r   update
rich.tabler   rp   rq   ry   r}   r   r   r   r   r   
add_columnr   add_row)r   r   r   	overridesr   optsr   tablecolumncol_optser   cellss                r   buildTableSpec.build8  sR   0 &&3AAAAK
TZZ
t||
 TZZ
 D--	

 D--
 D--
 488
 ;
 4++
 $//
 
 dkk
 
 t||
  5 5
  TZZ!
" #
$ %
( 	I$ F -- -- & 3 3 & 3 3!>>"OO"OO#--#--!>>H +(.(8(8%(x(% * A4;<GS%%a(GE<MM5!   =s   H2c                     [        U 40 UD6$ r7   r	   r   s     r   r   TableSpec.copy  r   r"   rA   )"r:   r;   r<   r=   r>   r   rU   r   r   rt   r   r   rr   rs   r   r   rd   r   r   r   r   r   r   r   r   r?   r   r   tuplerm   r   r   r   r@   rA   r"   r   r   r     s    E3:
 GS4Z
 $(E8K '
 +/L(;'.
 +/L(;'.
 +/L(;'.
  C%
 K
 K
 J
 It
 FD
 Hd
 $0G /
 #d"
 E3:
 !IsTz 
 !HdTk 
Pz3'P +&P
 
Pd&r"   r   c                   6   \ rS rSr% SrSr\S   \S'    Sr\S   \S'    Sr	\
S   \S	'    S
r\
S   \S'    Sr\S   \S'    Sr\S   \S'    Sr\S   \S'    SrS\S'    Sr\\S'    Sr\S-  \S'    Sr\S-  \S'    Sr\S-  \S'    Sr\\S'    SS jrS rSrg) 	PanelSpeci  a  Specification for panel (outer box) styling.

Used by :class:`~cyclopts.help.formatters.default.DefaultFormatter` to control
the appearance of the outer panel that wraps help sections. This spec defines
the panel's border, title, subtitle, and overall styling.

See Also
--------
~cyclopts.help.formatters.default.DefaultFormatter : The formatter that uses these specs.
~cyclopts.help.specs.TableSpec : Specification for the inner table.
~cyclopts.help.specs.ColumnSpec : Specification for individual columns.
Nr   r   subtitleru   )ru   rv   rw   title_alignrv   subtitle_alignnoner   rt   r   r   r   )r   r   r   r   Tr   r   heightr   Fr   c                    U R                   nUc  SSKJn  UnU R                  U R                  U R
                  U R                  UU R                  U R                  U R                  U R                  U R                  U R                  S.nU R                  b  U R                  US'   U R                  b  U R                  US'   UR                  U5        SSKJn  U" U40 UD6$ )zKCreate a Panel around `renderable`. Use kwargs to override spec per render.r   )ROUNDED)r   r   rt   r   r   r   r   r   r   r   r   r   r   r   )r   rich.boxr   r   r   rt   r   r   r   r   r   r   r   r   r   r   
rich.panelr   )r   
renderabler   r   r   r   r   s          r   r   PanelSpec.build  s     hh;(C  ++"11ZZ --||kkZZkk
 ::! JJDM==$#}}DI$Z(4((r"   c                     [        U 40 UD6$ r7   r	   r   s     r   r   PanelSpec.copy  r   r"   rA   )r   r   r9   r   )r:   r;   r<   r=   r>   r   r   r   r   r   r   r   rt   r   r   r   r   rd   r   r?   r   r   r   r   r   r@   rA   r"   r   r   r     s#    )-E8$%,
 ,0Hh'(/
 7=K23<
 :BNG56A
 $*E8K )
 +1L(;'0
  C% $*G )
 FD
 E3:
 FC$J
 !HdTk 
 It
)B&r"   r   ).r   r.   collections.abcr   operatorr   typingr   r   r   r   attrsr
   cyclopts.utilsr   r   r   r[   r   r   r   rich.paddingr   r   r   
rich.styler   r   r   cyclopts.helpr   cyclopts.help.protocolsr   r   rC   rf   rm   r   
NameColumnr   listr   r   r   r   r   rA   r"   r   <module>r      sl     $  : :  !DD. $ '03" 3"l_ _D- -, U& U& U&r 

 ^
	
 (;(=m]cntu !1<@<M
:s?D&
&
!1&
<@<M&

:s?&
R N& N& N&b @& @& @&r"   