Ë
    :vžjÈ  ã                  ój   — d Z ddlmZ ddlmZ ddlmZmZ d
d„Z	d
d„Z
 G d„ d	ej                  «      Zy)z(WidgetTrait type for widget composition.é    )ÚannotationsNé   )Ú_WIDGET_REF_PREFIXÚ_try_get_model_idc                ó:   — | €yt        | «      }|€| S t        › |› �S )z/Serialize a WidgetTrait value to its wire form.N)r   r   )ÚvalueÚ_objÚmodel_ids      úb/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/anywidget/_traits.pyÚ_widget_to_jsonr   
   s/   € à€}ØÜ  Ó'€HØÐØˆÜ Ð! ( Ð,Ð,ó    c                ó   — | S )z?Pass-through for incoming state. JS sends the ref string as-is.© )r   r	   s     r   Ú_widget_from_jsonr      s   € à€Lr   c                  ó8   ‡ — e Zd ZdZdZdZdZdˆ fd„Zdd„Zˆ xZ	S )	ÚWidgetTraituð  A trait that accepts anywidget-compatible objects.

    Validates that the value implements the anywidget protocol (has a
    ``MimeBundleDescriptor`` or ``ReprMimeBundle`` as ``_repr_mimebundle_``,
    or has a ``model_id`` attribute like ipywidgets). When synced, the value
    is serialized to the wire as ``"anywidget:<model_id>"``.

    .. note::
       Validation has no side effect for ``ipywidgets``-based widgets (their
       comms open in ``__init__``). For protocol-based widgets â€” those using
       ``MimeBundleDescriptor`` â€” validation opens the child's comm at
       assignment time instead of at display time. The difference is only
       observable if the parent is never displayed; otherwise the comm would
       open anyway.

    Examples
    --------
    >>> import anywidget
    >>> import traitlets
    >>>
    >>> class Dashboard(anywidget.AnyWidget):
    ...     _esm = "export default { render({ host }) {} }"
    ...     control = anywidget.WidgetTrait().tag(sync=True)
    Nz&an anywidget-compatible object or NoneTc                ó¢   •— t         ‰| �  «        | j                  j                  dt        «       | j                  j                  dt
        «       y )NÚto_jsonÚ	from_json)ÚsuperÚ__init__ÚmetadataÚ
setdefaultr   r   )ÚselfÚ	__class__s    €r   r   zWidgetTrait.__init__7   s7   ø€ Ü‰ÑÔØ�‰× Ñ  ¬OÔ<Ø�‰× Ñ  Ô.?Õ@r   c                óJ   — |€|S t        |«      �|S | j                  ||«       y )N)r   Úerror)r   Úobjr   s      r   ÚvalidatezWidgetTrait.validate<   s-   € Øˆ=ØˆLÜ˜UÓ#Ð/ØˆLØ�
‰
�3˜ÔØr   )ÚreturnÚNone)r   Úobjectr   r"   r    r"   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údefault_valueÚ	info_textÚ
allow_noner   r   Ú__classcell__)r   s   @r   r   r      s$   ø„ ñð2 €MØ8€IØ€JõA÷
r   r   )r   r"   r	   r"   r    r"   )r&   Ú
__future__r   Útraitlets.traitletsÚ	traitletsÚtÚ_descriptorr   r   r   r   Ú	TraitTyper   r   r   r   Ú<module>r1      s+   ðÙ .å "å ç >ó-óô
)�!—+‘+õ )r   