+
    i:2                        ^ RI Ht ^ RIt^ RIt^ RIt^ RIHtHtHtH	t	H
t
Ht ^RIHt ^RIHtHtHtHt ^RIHt ^RIHt R.t]P.                  ! R	4      t ! R
 R4      tR# )    )annotationsN)AnyCallableIterableIteratorLiteraloverload)ConcurrencyError)	OP_BINARYOP_CONTOP_TEXTFrame)Data)Deadline	Assemblerzutf-8c                  b   ] tR t^tRtRRR R 3R R lltR(R R lltR	 R
 lt]R R l4       t	]R R l4       t	]R(R R ll4       t	]R(R R ll4       t	]R)R R ll4       t	R)R R llt	]R R l4       t
]R R l4       t
]R(R R ll4       t
R(R R llt
R R  ltR! R" ltR# R$ ltR% R& ltR'tR# )*r   a  
Assemble messages from frames.

:class:`Assembler` expects only data frames. The stream of frames must
respect the protocol; if it doesn't, the behavior is undefined.

Args:
    pause: Called when the buffer of frames goes above the high water mark;
        should pause reading from the network.
    resume: Called when the buffer of frames goes below the low water mark;
        should resume reading from the network.

Nc                 	    R # N r       _/home/wkmabra/.openclaw/workspace/venv/lib/python3.14/site-packages/websockets/sync/messages.py<lambda>Assembler.<lambda>&   s    4r   c                 	    R # r   r   r   r   r   r   r   '   s    Dr   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	   highz
int | NonelowpausezCallable[[], Any]resumereturnNoner   )formats   "r   __annotate__Assembler.__annotate__"   s<     $ $$ $ !	$
 "$ 
$r   c                	f   \         P                  ! 4       V n        \        P                  ! 4       V n        Ve   Vf
   V^,          pVf   Ve
   V^,          pVe(   Ve$   V^ 8  d   \        R4      hW8  d   \        R4      hWuV n        V n        W0n	        W@n
        RV n        RV n        RV n        R # )Nz%low must be positive or equal to zeroz)high must be greater than or equal to lowF)	threadingLockmutexqueueSimpleQueueframes
ValueErrorr   r   r   r    pausedget_in_progressclosed)selfr   r   r   r    s   &&&&&r   __init__Assembler.__init__"   s     ^^%
 8=7H7H7J !)C<CO7DQw !HIIz !LMM"	48
  % r   c                    V ^8  d   QhRRRR/# )r   timeoutfloat | Noner!   r   r   )r#   s   "r   r$   r%   H   s      l e r   c                	   V P                   '       d    V P                  P                  R R7      pMG Ve%   V^ 8:  d   V P                  P                  R R7      pMV P                  P                  RVR7      p Vf   \        R4      hV#   \        P                   d    \        R4      Rhi ; i  \        P                   d    \        RTR R24      Rhi ; i)	Fblockstream of frames endedNT)r9   r5   ztimed out in z.1fs)r0   r,   getr*   EmptyEOFErrorTimeoutError)r1   r5   frames   && r   get_next_frameAssembler.get_next_frameH   s     ;;;Ce4M &7a< KKOO%O8E KKOO$OHE =344 ;; C78dBC ;; M"]73-q#ABLMs   B	 'B. B. 	"B+.'Cc                    V ^8  d   QhRRRR/# )r   r,   zIterable[Frame]r!   r"   r   )r#   s   "r   r$   r%   ^   s     ' '/ 'd 'r   c                	   V P                   ;_uu_ 4        . p  VP                  V P                  P                  RR7      4       K.    \        P
                   d     Mi ; iT F  pT P                  P                  T4       K   	  T F  pT P                  P                  T4       K   	  RRR4       R#   + '       g   i     R# ; i)TFr8   N)r)   appendr,   r<   r*   r=   put)r1   r,   queuedr@   s   &&  r   reset_queueAssembler.reset_queue^   s     ZZZFMM$++///">?;; &    &   ZZZs)   B4.AAB4AAB44C	c               $    V ^8  d   QhRRRRRR/# r   r5   r6   decodeLiteral[True]r!   strr   )r#   s   "r   r$   r%   u   s    KK<KK3Kr   c                	    R # r   r   r1   r5   rL   s   &&&r   r<   Assembler.gett   s    HKr   c               $    V ^8  d   QhRRRRRR/# r   r5   r6   rL   Literal[False]r!   bytesr   )r#   s   "r   r$   r%   x   s    NN<NNENr   c                	    R # r   r   rP   s   &&&r   r<   rQ   w   s    KNr   c               $    V ^8  d   QhRRRRRR/# rK   r   )r#   s   "r   r$   r%   {   s    UU<U=USUr   c               	    R # r   r   rP   s   &&$r   r<   rQ   z   s    RUr   c               $    V ^8  d   QhRRRRRR/# rS   r   )r#   s   "r   r$   r%   ~   s    XX<X>XeXr   c               	    R # r   r   rP   s   &&$r   r<   rQ   }       UXr   c               $    V ^8  d   QhRRRRRR/# r   r5   r6   rL   bool | Noner!   r   r   )r#   s   "r   r$   r%      s    XX<XXtXr   c                	    R # r   r   rP   s   &&&r   r<   rQ      r[   r   c               $    V ^8  d   QhRRRRRR/# r]   r   )r#   s   "r   r$   r%      s&     F F< F Ft Fr   c                   V P                   ;_uu_ 4        V P                  '       d   \        R4      hRV n        RRR4        \        V4      pV P	                  VP                  RR7      4      pV P                   ;_uu_ 4        V P                  4        RRR4       VP                  \        J g   VP                  \        J g   Q hVf   VP                  \        J pV.pVP                  '       gy    V P	                  VP                  RR7      4      pT P                   ;_uu_ 4        T P                  4        RRR4       TP                  \        J g   Q hTP                  T4       K   RV n        RP                  R V 4       4      pV'       d   VP!                  4       # V#   + '       g   i     ELr; i  + '       g   i     EL,; i  \         d    T P                  T4       h i ; i  + '       g   i     L; i  RT n        i ; i)a  
Read the next message.

:meth:`get` returns a single :class:`str` or :class:`bytes`.

If the message is fragmented, :meth:`get` waits until the last frame is
received, then it reassembles the message and returns it. To receive
messages frame by frame, use :meth:`get_iter` instead.

Args:
    timeout: If a timeout is provided and elapses before a complete
        message is received, :meth:`get` raises :exc:`TimeoutError`.
    decode: :obj:`False` disables UTF-8 decoding of text frames and
        returns :class:`bytes`. :obj:`True` forces UTF-8 decoding of
        binary frames and returns :class:`str`.

Raises:
    EOFError: If the stream of frames has ended.
    UnicodeDecodeError: If a text frame contains invalid UTF-8.
    ConcurrencyError: If two coroutines run :meth:`get` or
        :meth:`get_iter` concurrently.
    TimeoutError: If a timeout is provided and elapses before a
        complete message is received.

&get() or get_iter() is already runningTNF)raise_if_elapsedr   c              3  8   "   T F  qP                   x  K  	  R # 5ir   )data).0r@   s   & r   	<genexpr> Assembler.get.<locals>.<genexpr>   s     7u

s   )r)   r/   r
   r   rA   r5   maybe_resumeopcoder   r   finr?   rH   r   rE   joinrL   )r1   r5   rL   deadliner@   r,   re   s   &&&    r   r<   rQ      s   4 ZZZ###&'OPP#'D  	)(H ''(8(8%(8(PQE!!# <<7*elli.GGG~0WF iii // ((%(@E ZZZ%%'  ||w...e$    $)D  xx777;;= KY ZZ  $  $$V,	
  Z $)D sa   %F#A G? F7AG? 2!G G? 'G,81G? #F4	7G		G? G))G? ,G<	7G? ?	Hc                    V ^8  d   QhRRRR/# )r   rL   rM   r!   zIterator[str]r   )r#   s   "r   r$   r%      s    CC}CCr   c                	    R # r   r   r1   rL   s   &&r   get_iterAssembler.get_iter   s    @Cr   c                    V ^8  d   QhRRRR/# )r   rL   rT   r!   zIterator[bytes]r   )r#   s   "r   r$   r%      s    FF~F/Fr   c                	    R # r   r   rp   s   &&r   rq   rr      s    CFr   c                    V ^8  d   QhRRRR/# r   rL   r^   r!   zIterator[Data]r   )r#   s   "r   r$   r%      s    II{InIr   c                	    R # r   r   rp   s   &&r   rq   rr      s    FIr   c                    V ^8  d   QhRRRR/# rv   r   )r#   s   "r   r$   r%      s     >% >%{ >%n >%r   c              #    "   V P                   ;_uu_ 4        V P                  '       d   \        R4      hRV n        RRR4       V P                  4       pV P                   ;_uu_ 4        V P	                  4        RRR4       VP
                  \        J g   VP
                  \        J g   Q hVf   VP
                  \        J pV'       d4   \        4       pVP                  VP                  VP                  4      x  M\        VP                  4      x  VP                  '       g   V P                  4       pV P                   ;_uu_ 4        V P	                  4        RRR4       VP
                  \        J g   Q hV'       d+   XP                  VP                  VP                  4      x  K  \        VP                  4      x  K  RV n        R#   + '       g   i     EL; i  + '       g   i     ELp; i  + '       g   i     L; i5i)a!  
Stream the next message.

Iterating the return value of :meth:`get_iter` yields a :class:`str` or
:class:`bytes` for each frame in the message.

The iterator must be fully consumed before calling :meth:`get_iter` or
:meth:`get` again. Else, :exc:`ConcurrencyError` is raised.

This method only makes sense for fragmented messages. If messages aren't
fragmented, use :meth:`get` instead.

Args:
    decode: :obj:`False` disables UTF-8 decoding of text frames and
        returns :class:`bytes`. :obj:`True` forces UTF-8 decoding of
        binary frames and returns :class:`str`.

Raises:
    EOFError: If the stream of frames has ended.
    UnicodeDecodeError: If a text frame contains invalid UTF-8.
    ConcurrencyError: If two coroutines run :meth:`get` or
        :meth:`get_iter` concurrently.

rb   TNF)r)   r/   r
   rA   ri   rj   r   r   UTF8DecoderrL   re   rk   rU   r   )r1   rL   r@   decoders   &&  r   rq   rr      sY    2 ZZZ###&'OPP#'D   ##%ZZZ ||w&%,,)*CCC>\\W,F!mG..UYY77 

## )))'')E!!# <<7***nnUZZ;; EJJ''$K ZZ ZZ s`   H%G,H(G 9AH	AH%$H	G4%H AHG		H G1	+	H4H	?Hc                    V ^8  d   QhRRRR/# )r   r@   r   r!   r"   r   )r#   s   "r   r$   r%     s       4 r   c                    V P                   ;_uu_ 4        V P                  '       d   \        R4      hV P                  P	                  V4       V P                  4        RRR4       R#   + '       g   i     R# ; i)z_
Add ``frame`` to the next message.

Raises:
    EOFError: If the stream of frames has ended.

r:   N)r)   r0   r>   r,   rF   maybe_pause)r1   r@   s   &&r   rF   Assembler.put  sJ     ZZZ{{{788KKOOE" ZZZs   A	A((A9	c                   V ^8  d   QhRR/# r   r!   r"   r   )r#   s   "r   r$   r%   -  s      T r   c                   V P                   f   R# V P                  P                  4       '       g   Q hV P                  P	                  4       V P                   8  d.   V P
                  '       g   RV n        V P                  4        R# R# R# )z7Pause the writer if queue is above the high water mark.NT)r   r)   lockedr,   qsizer.   r   r1   s   &r   r~   Assembler.maybe_pause-  se     99zz  """" ;;*4;;;DKJJL 4?*r   c                   V ^8  d   QhRR/# r   r   )r#   s   "r   r$   r%   :  s      d r   c                   V P                   f   R# V P                  P                  4       '       g   Q hV P                  P	                  4       V P                   8:  d.   V P
                  '       d   RV n        V P                  4        R# R# R# )z7Resume the writer if queue is below the low water mark.NF)r   r)   r   r,   r   r.   r    r   s   &r   ri   Assembler.maybe_resume:  se     88zz  """" ;;$((*t{{{DKKKM 0;*r   c                   V ^8  d   QhRR/# r   r   )r#   s   "r   r$   r%   G  s      t r   c                \   V P                   ;_uu_ 4        V P                  '       d    RRR4       R# RV n        V P                  '       d   V P                  P	                  R4       V P
                  '       d   RV n        V P                  4        RRR4       R#   + '       g   i     R# ; i)z
End the stream of frames.

Calling :meth:`close` concurrently with :meth:`get`, :meth:`get_iter`,
or :meth:`put` is safe. They will raise :exc:`EOFError`.

NTF)r)   r0   r/   r,   rF   r.   r    r   s   &r   closeAssembler.closeG  sj     ZZZ{{{ Z DK###%{{{# ZZZs   BB,B9BB+	)	r0   r,   r/   r   r   r)   r   r.   r    r   )NN)__name__
__module____qualname____firstlineno____doc__r2   rA   rH   r	   r<   rq   rF   r~   ri   r   __static_attributes__r   r   r   r   r      s       #/$0$L,', K KN NU UX XX XFP C CF FI I>%@2 r   )
__future__r   codecsr*   r'   typingr   r   r   r   r   r	   
exceptionsr
   r,   r   r   r   r   r   utilsr   __all__getincrementaldecoderrz   r   r   r   r   <module>r      sK    "    G G ) 7 7   -**73I Ir   