+
    Vjw                        ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHt  ! R R]4      tR# )    )annotations)Any)Mapping)UploadedFile)BaseRenderer)CheckboxInputMediaWidget)MultiValueDict)conditional_escape)
SafeString	mark_safe)gettext_lazyc                      ] tR t^tRt]! R4      tRt ! R R4      tRR R llt	R	 R
 lt
]R 4       tRR R lltR R ltR R ltR R ltRtR# )ClearableWidgetWrappera  
Wraps another widget adding a clear checkbox, making it possible to
reset the field to some empty value even if the original input doesn't
have means to.

Useful for ``TextInput`` and ``Textarea`` based widgets used in combination
with nullable text fields.

Use it in ``Field.formfield`` or ``ModelAdmin.formfield_for_dbfield``:

    field.widget = ClearableWidgetWrapper(field.widget)

``None`` is assumed to be a proper choice for the empty value, but you may
pass another one to the constructor.
Nonez=<span class="clearable-input">{0} <span>{2}</span> {3}</span>c                      ] tR t^&tRtRtR# )ClearableWidgetWrapper.Media N)z'modeltranslation/js/clearable_inputs.js)__name__
__module____qualname____firstlineno__js__static_attributes__r       M/var/www/idalgo/venv/lib/python3.14/site-packages/modeltranslation/widgets.pyr	   r   &   s    9r   r	   Nc               $    V ^8  d   QhRRRRRR/# )   widgetr
   empty_valuez
Any | Nonereturnr   r   )formats   "r   __annotate__#ClearableWidgetWrapper.__annotate__)   s!     ' 'v 'J '$ 'r   c                D    Wn         \        RR/R7      V n        W n        R# )zi
Remebers the widget we are wrapping and precreates a checkbox input.
Allows overriding the empty value.
tabindexz-1)attrsN)r    r   checkboxr!   )selfr    r!   s   &&&r   __init__ClearableWidgetWrapper.__init__)   s     
 %Z,>?&r   c                    V ^8  d   QhRRRR/# )r   namestrr"   r   r   )r#   s   "r   r$   r%   2   s        r   c                H    VR8w  d   \        V P                  V4      # \        h)zO
If we don't have a property or a method, chances are the wrapped
widget does.
r    )getattrr    AttributeErrorr*   r.   s   &&r   __getattr__"ClearableWidgetWrapper.__getattr__2   s#    
 84;;--r   c                    V P                   P                  V P                  P                  ,           \        V P                  4      ,           # )z
Combines media of both components and adds a small script that unchecks
the clear box, when a value in any wrapped input is modified.
)r    mediar)   r	   )r*   s   &r   r7   ClearableWidgetWrapper.media;   s1     {{  4==#6#66tzz9JJJr   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   r.   r/   valuer   r(   zdict[str, Any] | NonerendererzBaseRenderer | Noner"   r   r   )r#   s   "r   r$   r%   C   s<     
 

 
 %	

 &
 

r   c           
        V P                   P                  WW44      pV P                  V4      pV P                  V4      pV P                  pV P
                  P                  WbV P                  8H  RV/VR7      p	\        V P                  P                  \        V4      \        V4      \        V4      \        V	4      4      4      # )zb
Appends a checkbox for clearing the value (that is, setting the field
with the ``empty_value``).
id)r(   r;   )r    renderclear_checkbox_nameclear_checkbox_idclear_checkbox_labelr)   r!   r   templater#   r   )
r*   r.   r:   r(   r;   wrappedcheckbox_namecheckbox_idcheckbox_labelr)   s
   &&&&&     r   r>   ClearableWidgetWrapper.renderC   s     ++$$T%B006,,];22==''D$4$44T;<OZb ( 
 MM  "7+";/">2"8,	
 	
r   c               (    V ^8  d   QhRRRRRRRR/# )	r   datazMapping[str, Any]filesz!MultiValueDict[str, UploadedFile]r.   r/   r"   r   r   )r#   s   "r   r$   r%   ^   s2     
B 
B%
B.O
BWZ
B	
Br   c                    V P                   P                  WV P                  V4      4      pV'       d   V P                  # V P                  P                  WV4      # )zn
If the clear checkbox is checked returns the configured empty value,
completely ignoring the original input.
)r)   value_from_datadictr?   r!   r    )r*   rI   rJ   r.   clears   &&&& r   rL   *ClearableWidgetWrapper.value_from_datadict^   sL     11$t?W?WX\?]^###{{..tDAAr   c                    V ^8  d   QhRRRR/# r   r.   r/   r"   r   )r#   s   "r   r$   r%   j   s        r   c                    VR,           # )zF
Given the name of the input, returns the name of the clear checkbox.
z-clearr   r3   s   &&r   r?   *ClearableWidgetWrapper.clear_checkbox_namej   s     hr   c                    V ^8  d   QhRRRR/# rP   r   )r#   s   "r   r$   r%   p   s      c c r   c                    VR,           # )zI
Given the name of the clear checkbox input, returns the HTML id for it.
_idr   r3   s   &&r   r@   (ClearableWidgetWrapper.clear_checkbox_idp   s     e|r   )r)   r!   r    )N)NN)r   r   r   r   __doc___rA   rB   r	   r+   r4   propertyr7   r>   rL   r?   r@   r   r   r   r   r   r      s\      V9NH
: :' K K
6
B r   r   N)
__future__r   typingr   collections.abcr   django.core.files.uploadedfiler   django.forms.renderersr   django.forms.widgetsr   r	   r
   django.utils.datastructuresr   django.utils.htmlr   django.utils.safestringr   r   django.utils.translationr   rX   r   r   r   r   <module>rd      s4    "  # 7 / = = 6 0 9 6eV er   