ó
    Ãu„jî"  ã                  óÆ   • S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	J
r
  SSK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  \(       a  SSKJr   " S S\SS9rg)zƒProvides the base code and implementations of toggle widgets.

In particular it provides `Checkbox`, `RadioButton` and `RadioSet`.
é    )Úannotations)ÚTYPE_CHECKINGÚClassVar)ÚRenderableType)ÚBindingÚBindingType)ÚContentÚContentText)ÚClick)ÚSize)ÚMessage)Úreactive)ÚStyle)ÚStatic)ÚSelfc                  óÊ  ^ • \ rS rSr% SrSr\" SSSSS9/rS\S	'    S
S1r	S\S'    Sr
SrS\S'    SrS\S'    SrS\S'    \" SSS9rS\S'    \" SSS9rS\S'       S-SSSSSSS.                   S.U 4S jjjjrS/S jr\S0S  j5       r\R*                  S1S! j5       r\S0S" j5       rS0S# jrS2S$ jrS3S% jrS4S& jrS5S' jrS6S( jr " S) S*\5      rS5S+ jrS,r U =r!$ )7ÚToggleButtoné   zìBase toggle button widget.

Warning:
    `ToggleButton` should be considered to be an internal class; it
    exists to serve as the common core of [Checkbox][textual.widgets.Checkbox] and
    [RadioButton][textual.widgets.RadioButton].
Fzenter,spaceÚtoggle_buttonÚToggle)ÚshowzClassVar[list[BindingType]]ÚBINDINGSútoggle--buttonútoggle--labelzClassVar[set[str]]ÚCOMPONENT_CLASSESa(  
    ToggleButton {
        width: auto;
        border: tall $border-blurred;
        padding: 0 1;
        background: $surface;
        text-wrap: nowrap;
        text-overflow: ellipsis;
        pointer: pointer;

        &:ansi {
            background: ansi_default;
            & > .toggle--button {
                background: $ansi-background;
                color: $ansi-foreground;
                text-style: dim;
            }
            &.-on > .toggle--button {
                color: $accent;
                background: $ansi-background;
                text-style: bold not dim;
            }
        }
        
        &.-textual-compact {
            border: none !important;
            padding: 0;
            &:focus {
                border: tall $border;
                background-tint: $foreground 5%;
                & > .toggle--label {
                    color: $block-cursor-foreground;
                    background: $block-cursor-background;
                    text-style: $block-cursor-text-style;
                }
            }
        }

        & > .toggle--button {
            color: $panel-darken-2;
            background: $panel;
        }

        &.-on > .toggle--button {
            color: $text-success;
            background: $panel;
        }

        &:focus {       
            border: tall $border;            
            background-tint: $foreground 5%;     
     
            & > .toggle--label {                         
                color: $block-cursor-foreground;
                background: $block-cursor-background;       
                text-style: $block-cursor-text-style;                
            }
        }
        &:blur:hover {
            & > .toggle--label {
                background: $block-hover-background;
            }
        }
    }
    u   â–�ÚstrÚBUTTON_LEFTÚXÚBUTTON_INNERu   â–ŒÚBUTTON_RIGHT)Úinitzreactive[bool]Úvaluez-textual-compact)Útoggle_classÚcompactN)ÚnameÚidÚclassesÚdisabledÚtooltipr$   c               óî   >• [         T
U ]  XEXgS9  X0l        U R                  U R                  5         X l        SSS5        U R                  U5      U l        Ub  X€l        X�l	        g! , (       d  f       N4= f)a¯  Initialise the toggle.

Args:
    label: The label for the toggle.
    value: The initial value of the toggle.
    button_first: Should the button come before the label, or after?
    name: The name of the toggle.
    id: The ID of the toggle in the DOM.
    classes: The CSS classes of the toggle.
    disabled: Whether the button is disabled or not.
    tooltip: RenderableType | None = None,
    compact: Show a compact button.
)r%   r&   r'   r(   N)
ÚsuperÚ__init__Ú_button_firstÚpreventÚChangedr"   Ú_make_labelÚ_labelr)   r$   )ÚselfÚlabelr"   Úbutton_firstr%   r&   r'   r(   r)   r$   Ú	__class__s             €Ú¬C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\textual/widgets/_toggle_button.pyr,   ÚToggleButton.__init__ˆ   sb   ø€ ô4 	‰Ñ˜d°7ÐÑNØ)Ôà�\‰\˜$Ÿ,™,Õ'ØŒJ÷ (à×&Ñ& uÓ-ˆŒØÑØ"ŒLØ�÷ (Õ'ús   ±A&Á&
A4c                ób   • [         R                  " U5      R                  R                  5       nU$ )zŽMake label content.

Args:
    label: The source value for the label.

Returns:
    A `Content` rendering of the label for use in the button.
)r	   Ú	from_textÚ
first_lineÚrstrip©r2   r3   s     r6   r0   ÚToggleButton._make_label¬   s(   € ô ×!Ò! %Ó(×3Ñ3×:Ñ:Ó<ˆØˆó    c                ó   • U R                   $ )z%The label associated with the button.)r1   ©r2   s    r6   r3   ÚToggleButton.label¸   s   € ð �{‰{Ðr>   c                óN   • U R                  U5      U l        U R                  SS9  g )NT)Úlayout)r0   r1   Úrefreshr<   s     r6   r3   rA   ½   s"   € à×&Ñ& uÓ-ˆŒØ�‰˜DˆÒ!r>   c                óÞ   • U R                  S5      n[        UR                  U R                  S   S9n[        R
                  " U R                  U4U R                  U4U R                  U45      $ )z)The button, reflecting the current value.r   é   )Ú
foregroundÚ
background)	Úget_visual_styler   rH   Úbackground_colorsr	   Úassembler   r   r    )r2   Úbutton_styleÚ
side_styles      r6   Ú_buttonÚToggleButton._buttonÂ   sw   € ð
 ×,Ñ,Ð-=Ó>ˆô
 Ø#×.Ñ.Ø×-Ñ-¨aÑ0ñ
ˆ
ô
 ×ÒØ×Ñ˜zÐ*Ø×Ñ Ð-Ø×Ñ 
Ð+ó
ð 	
r>   c                ó  • U R                   nU R                  S5      nU R                  R                  SS5      R	                  U5      nU R
                  (       a  [        R                  " X5      nU$ [        R                  " X15      nU$ )zVRender the content of the widget.

Returns:
    The content to render for the widget.
r   rF   )rN   rI   r1   ÚpadÚstylize_beforer-   r	   rK   )r2   ÚbuttonÚlabel_styler3   Úcontents        r6   ÚrenderÚToggleButton.render×   ss   € ð —‘ˆØ×+Ñ+¨OÓ<ˆØ—‘—‘  1Ó%×4Ñ4°[ÓAˆà××Ü×&Ò& vÓ5ˆGð ˆô ×&Ò& uÓ5ˆGØˆr>   c                óÈ   • U R                   R                  U R                  S5      U R                  (       a  SOS-   U R                  R                  U R                  S5      -   $ )Nr   é   )rN   Úget_optimal_widthÚstylesr1   )r2   Ú	containerÚviewports      r6   Úget_content_widthÚToggleButton.get_content_widthç   sL   € à�L‰L×*Ñ*¨4¯;©;¸Ó:Ø—K—K‰q Qñ(à�k‰k×+Ñ+¨D¯K©K¸Ó;ñ<ð	
r>   c                ó   • g)NrF   © )r2   r\   r]   Úwidths       r6   Úget_content_heightÚToggleButton.get_content_heightî   s   € Ør>   c                ó2   • U R                   (       + U l         U $ )zKToggle the value of the widget.

Returns:
    The `ToggleButton` instance.
)r"   r@   s    r6   ÚtoggleÚToggleButton.toggleñ   s   € ð Ÿ™”^ˆŒ
Øˆr>   c                ó$   • U R                  5         g)znToggle the value of the widget when called as an action.

This would normally be used for a keyboard binding.
N©rf   r@   s    r6   Úaction_toggle_buttonÚ!ToggleButton.action_toggle_buttonú   s   € ð
 	�‰�r>   c              ƒ  ó,   #   • U R                  5         g7f)z;Toggle the value of the widget when clicked with the mouse.Nri   )r2   Ú_s     r6   Ú	_on_clickÚToggleButton._on_click  s   é € à�‰�ùs   ‚c                  ó0   ^ • \ rS rSrSrSU 4S jjrSrU =r$ )ÚToggleButton.Changedi  z3Posted when the value of the toggle button changes.c                ó<   >• [         TU ]  5         Xl         X l        g)z„Initialise the message.

Args:
    toggle_button: The toggle button sending the message.
    value: The value of the toggle button.
N)r+   r,   Ú_toggle_buttonr"   )r2   r   r"   r5   s      €r6   r,   ÚToggleButton.Changed.__init__  s!   ø€ ô ‰GÑÔØ"/ÔØDØŒJØBr>   )rs   r"   )r   r   r"   ÚboolÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r,   Ú__static_attributes__Ú__classcell__©r5   s   @r6   r/   rq     s   ø† ÙA÷	Cõ 	Cr>   r/   c                ó�   • U R                  U R                  S5        U R                  U R                  X R                  5      5        g)zàReact to the value being changed.

When triggered, the CSS class `-on` is applied to the widget if
`value` has become `True`, or it is removed if it has become
`False`. Subsequently a related `Changed` event will be posted.
z-onN)Ú	set_classr"   Úpost_messager/   r@   s    r6   Úwatch_valueÚToggleButton.watch_value  s1   € ð 	�‰�t—z‘z 5Ô)Ø×Ñ˜$Ÿ,™, t¯Z©ZÓ8Õ9r>   )r-   r1   r$   r)   r"   )Ú FT)r3   r
   r"   ru   r4   ru   r%   ú
str | Noner&   r†   r'   r†   r(   ru   r)   zRenderableType | Noner$   ru   rv   rw   )r3   r
   rv   r	   )rv   r	   )r3   r
   rv   rw   )r\   r   r]   r   rv   Úint)r\   r   r]   r   rb   r‡   rv   r‡   )rv   r   )rv   rw   )rm   r   rv   rw   )"rx   ry   rz   r{   r|   ÚALLOW_SELECTr   r   Ú__annotations__r   ÚDEFAULT_CSSr   r   r    r   r"   r$   r,   r0   Úpropertyr3   ÚsetterrN   rV   r^   rc   rf   rj   rn   r   r/   rƒ   r}   r~   r   s   @r6   r   r      sµ  ø‡ ñð €Lá�˜°¸uÑEð-€HÐ)ó ðð 	Øð-ÐÐ)ó ðð@€KðD €K�ÓØDà€L�#ÓØ:à€L�#ÓØEá$ U°Ñ7€Eˆ>Ó7ØBá& uÐ;MÑN€Gˆ^ÓNØ!ð  ØØ!ð	"ð  ØØ"ØØ)-Øñ"àð"ð ð"ð ð	"ð ð"ð ð"ð ð"ð ð"ð 'ð"ð ð"ð 
÷"ñ "ôH
ð óó ðð ‡\�\ó"ó ð"ð ó
ó ð
ô(ô 
ôôôôôC�'ô C÷ :ò :r>   r   T)Ú	can_focusN)r|   Ú
__future__r   Útypingr   r   Úrich.consoler   Útextual.bindingr   r   Útextual.contentr	   r
   Útextual.eventsr   Útextual.geometryr   Útextual.messager   Útextual.reactiver   Útextual.styler   Útextual.widgets._staticr   Útyping_extensionsr   r   ra   r>   r6   Ú<module>rš      sC   ðñõ
 #ç *å 'ç 0ß 0Ý  Ý !Ý #Ý %Ý Ý *æÝ&ôD:�6 Tó D:r>   