Ë
    A²Xj4  ã                  ó8  — U d dl mZ d dlZd dlmZmZmZmZmZm	Z	 d dl
mZ ddlmZ erddlmZmZ g d¢Zeegd	f   Zd
ed<   	 eege	d   f   Zd
ed<   	  G d„ d«      Zeeegd	f   Zd
ed<   eeege	d   f   Zd
ed<   eeeef   Zd
ed<   dd„Zdd„Zdd„Zdd„Zy)é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚUnionÚCallableÚIterableÚ	Awaitable)Ú	TypeAliasé   )Ú
APIRequest)ÚAPIResponseÚAsyncAPIResponse)Ú
MiddlewareÚCallNextÚAsyncCallNextÚMiddlewareCallableÚAsyncMiddlewareCallableÚMiddlewareInputúAPIResponse[Any]r
   r   úAsyncAPIResponse[Any]r   c                  ó    — e Zd ZdZdd„Zdd„Zy)r   zìBase class for client-level middleware.

    Subclass and override `handle` (used by the sync client) and/or `handle_async`
    (used by the async client). The default implementations delegate straight to
    the rest of the chain.
    c                ó   —  ||«      S ©N© ©ÚselfÚrequestÚ	call_nexts      ú[/var/www/html/content_generation/venv/lib/python3.12/site-packages/anthropic/_middleware.pyÚhandlezMiddleware.handle6   s   € Ù˜Ó!Ð!ó    c              ƒ  ó.   K  —  ||«      ƒ d {  –—† S 7 Œ­wr   r   r   s      r   Úhandle_asynczMiddleware.handle_async9   s   è ø€ Ù˜wÓ'×'Ð'Ð'ús   ‚Ž�N)r   r   r   r   Úreturnr   )r   r   r   r   r$   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r    r#   r   r!   r   r   r   .   s   „ ñó"ô(r!   r   r   r   r   c                ó    — t        | t        «      rt        | «      j                  S t	        | dd «      }t        |t
        «      r|S t        | «      S )Nr%   )Ú
isinstancer   Útyper%   ÚgetattrÚstrÚrepr)Ú
middlewareÚnames     r   Ú_middleware_namer1   B   sD   € Ü�*œjÔ)Ü�JÓ×(Ñ(Ð(Ü�:˜z¨4Ó0€DÜ˜d¤CÔ(ˆ4Ð>¬d°:Ó.>Ð>r!   c                ó~   — t        j                  | «      ryt        | dd«      }|duxr t        j                  |«      S )z·Whether calling the given object returns a coroutine.

    Unlike `inspect.iscoroutinefunction(obj)` this also handles class instances
    that define an async `__call__` method.
    TÚ__call__N)ÚinspectÚiscoroutinefunctionr,   )ÚobjÚcalls     r   Ú_is_async_callabler8   I   s>   € ô ×"Ñ" 3Ô'ØÜ�3˜
 DÓ)€DØ�tÐÒA¤× ;Ñ ;¸DÓ AÐAr!   c                óº  — | D ]Ö  }t        |t        «      r~t        |«      j                  t        j                  u rt	        dt        |«      › d�«      ‚t        j                  t        |«      j                  «      sŒyt	        dt        |«      › d�«      ‚t        |«      st	        dt        |«      › d�«      ‚t        |«      sŒÀt	        dt        |«      › d�«      ‚ y )Númiddleware zW does not implement `handle()`; the synchronous client requires sync-capable middlewarezj defines `handle()` as an async function; the synchronous client requires `handle()` to be a sync functionú is not callablezP is an async function; the synchronous client requires sync middleware functions)
r*   r   r+   r    Ú	TypeErrorr1   r4   r5   Úcallabler8   ©r/   Úentrys     r   Úvalidate_sync_middlewarer@   U   sê   € ÛˆÜ�eœZÔ(Ü�E‹{×!Ñ!¤Z×%6Ñ%6Ñ6ÜØ!Ô"2°5Ó"9Ð!:ð ;Nð Nóð ô ×*Ñ*¬4°«;×+=Ñ+=Õ>ÜØ!Ô"2°5Ó"9Ð!:ð ;Wð Wóð ô ˜%”Ü˜kÔ*:¸5Ó*AÐ)BÐBRÐSÓTÐTÜ Õ&ÜØÔ.¨uÓ5Ð6ð 7Lð Lóð ñ r!   c                óº  — | D ]Ö  }t        |t        «      r~t        |«      j                  t        j                  u rt	        dt        |«      › d�«      ‚t        j                  t        |«      j                  «      rŒyt	        dt        |«      › d�«      ‚t        |«      st	        dt        |«      › d�«      ‚t        |«      rŒÀt	        dt        |«      › d�«      ‚ y )Nr:   z_ does not implement `handle_async()`; the asynchronous client requires async-capable middlewarezw defines `handle_async()` as a sync function; the asynchronous client requires `handle_async()` to be an async functionr;   zV is not an async function; the asynchronous client requires async middleware functions)
r*   r   r+   r#   r<   r1   r4   r5   r=   r8   r>   s     r   Úvalidate_async_middlewarerB   k   sê   € ÛˆÜ�eœZÔ(Ü�E‹{×'Ñ'¬:×+BÑ+BÑBÜØ!Ô"2°5Ó"9Ð!:ð ;Pð Póð ô ×.Ñ.¬t°E«{×/GÑ/GÕHÜØ!Ô"2°5Ó"9Ð!:ð ;`ð `óð ô ˜%”Ü˜kÔ*:¸5Ó*AÐ)BÐBRÐSÓTÐTÜ# EÕ*ÜØÔ.¨uÓ5Ð6ð 7Nð Nóð ñ r!   )r/   Úobjectr$   r-   )r6   rC   r$   Úbool)r/   zIterable[MiddlewareInput]r$   ÚNone)Ú
__future__r   r4   Útypingr   r   r   r   r   r	   Útyping_extensionsr
   Ú_requestr   Ú	_responser   r   Ú__all__r   Ú__annotations__r   r   r   r   r   r1   r8   r@   rB   r   r!   r   Ú<module>rM      sÙ   ðÞ "ã ß K× KÝ 'å  áß8ò€ð  
˜|Ð-?Ð?Ñ@€ˆ)Ó @ð	ð $ Z L°)Ð<SÑ2TÐ$TÑU€ˆyÓ Uð	÷(ñ (ð !)¨*°hÐ)?ÐASÐ)SÑ TÐ �IÓ TØ%-¨z¸=Ð.IÈ9ÐUlÑKmÐ.mÑ%nÐ ˜Ó nØ" :Ð/AÐCZÐ#ZÑ[€�Ó [ó?ó	Bóô,r!   