
    hje                        d dl mZ d dlZ ej        e          Zd dlmZmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ erdd
lmZ ddlmZ ddlmZ dZ G d dee                   ZdS )    )annotationsN)TYPE_CHECKINGAny   )
Serializerinvoke_with_curdoc)	PatchJson   )Message)Setter)Document)DocumentPatchedEvent)	patch_docc                  8    e Zd ZdZdZedd            ZdddZd	S )r   a?   Define the ``PATCH-DOC`` message for sending Document patch events
    between remote documents.

    The ``content`` fragment of for this message is has the form:

    .. code-block:: python

        {
            'events'     : <protocol document events>
            'references' : <model references>
        }

    z	PATCH-DOCeventslist[DocumentPatchedEvent]metadatar   returnc                  	 |                                  }|st          d          d |D             }t          |          dk    rt          d          |\  }t          |j        j                  	t          	                    |                    }|j                            	fd            | |||          }	j	        D ]}|
                    |           |S )z Create a ``PATCH-DOC`` message

        Args:
            events (list) :
                A list of patch events to apply to a document

        Any additional keyword arguments will be put into the message
        ``metadata`` fragment as-is.

        z-PATCH-DOC message requires at least one eventc                    h | ]	}|j         
S  )document).0events     Alib/python3.11/site-packages/bokeh/protocol/messages/patch_doc.py	<setcomp>z#patch_doc.create.<locals>.<setcomp>T   s    3335333       zCPATCH-DOC message configured with events for more than one document)
references)r   c                0                         |            S N)has_ref)model
serializers    r   <lambda>z"patch_doc.create.<locals>.<lambda>[   s    *2D2DU2K2K.K r   )create_header
ValueErrorlenr   modelssynced_referencesr
   encodeflush_syncedbuffers
add_buffer)
clsr   r   headerdocsdoc
patch_jsonmsgbufferr%   s
            @r   createzpatch_doc.createC   s     ""$$ 	NLMMM33F333t99>>bccc3:+GHHH
j&7&7&?&?@@@

 K K K KLLLc&(J// ( 	# 	#FNN6""""
r   Nr3   r   setterSetter | NoneNonec                6     t           fd           dS )z


        c                 <                          j                  S )N)r8   )apply_json_patchpayload)r3   selfr8   s   r   r&   z-patch_doc.apply_to_document.<locals>.<lambda>h   s    (<(<T\RX(<(Y(Y r   Nr   )r?   r3   r8   s   ```r   apply_to_documentzpatch_doc.apply_to_documentd   s-     	3 Y Y Y Y Y YZZZZZr   )r   r   r   r   r   r   r"   )r3   r   r8   r9   r   r:   )__name__
__module____qualname____doc__msgtypeclassmethodr7   r@   r   r   r   r   r   2   sd          G   [@[ [ [ [ [ [ [r   r   )
__future__r   logging	getLoggerrA   logtypingr   r   core.serializationr   document.callbacksr	   document.jsonr
   messager   core.has_propsr   document.documentr   document.eventsr   __all__r   r   r   r   <module>rT      s    # " " " " " g!! & % % % % % % % - , , , , , 4 4 4 4 4 4 & & & & & &       8((((((------7777776[ 6[ 6[ 6[ 6[	" 6[ 6[ 6[ 6[ 6[r   