§
    2�’jHN  ã                   ó   — d Z ddlZddlZddlZddlZddlmZmZ ddlmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZ ddlZddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZm Z m!Z!m"Z" ddl#m$Z$ ddl%m&Z&m'Z'  ej(        e)¦  «        Z*e G d„ d¦  «        ¦   «         Z+ ej,        ¦   «         Z-de+fd„Z.d„ Z/dd„Z0dd„Z1de!de!fd„Z2 G d„ de3¦  «        Z4 G d„ d¦  «        Z5	 ddl6m7Z7 e7j8        e5_9        e5j8        e7_8        n # e:$ r e* ;                    d¦  «         Y nw xY wee<e=e>e&ef         Z?ee?         Z@ee?         ZAeeAe@f         ZB G d„ de¦  «        ZCdS )u�  Server-Sent Events response for Starlette / FastAPI.

Intentional divergence from ``starlette.responses.StreamingResponse``
--------------------------------------------------------------------

``EventSourceResponse`` is modelled on Starlette's ``StreamingResponse`` and
re-syncs most of its behaviour (WebSocket denial, ``collapse_excgroups()``
around the task group, ``memoryview`` chunk handling). The following points
are deliberate divergences â€” DO NOT "fix" them without reading the rationale:

1. ASGI ``spec_version >= 2.4`` fast path is NOT adopted.
   Upstream short-circuits to ``await stream_response(send)`` and converts
   ``OSError`` into ``ClientDisconnect``, skipping ``listen_for_disconnect``.
   We keep ``_listen_for_disconnect`` running because it
     (a) invokes ``client_close_handler_callable`` on disconnect,
     (b) flips ``self.active = False`` so ``_ping`` and the cooperative
         shutdown grace loop exit promptly.
   Adopting the upstream fast path would regress both features.

2. ``_wrap_websocket_denial_send`` is inlined in this module rather than
   inherited from ``starlette.responses.Response``. The helper landed on
   Starlette ``main`` after our minimum pin (``starlette>=0.41.3``); inline
   until the floor moves past the release that contains it.

3. ``collapse_excgroups()`` is vendored in ``sse_starlette._utils`` rather
   than imported from ``starlette._utils`` (private module).
é    N)Ú	dataclassÚfield)ÚdatetimeÚtimezone)
ÚAnyÚAsyncIterableÚ	AwaitableÚCallableÚ	CoroutineÚIteratorÚMappingÚOptionalÚSetÚUnion)ÚBackgroundTask)Úiterate_in_threadpool)ÚMutableHeaders)ÚResponse)ÚReceiveÚScopeÚSendÚMessage)Úcollapse_excgroups)ÚServerSentEventÚensure_bytesc                   óZ   — e Zd ZU dZ ee¬¦  «        Zeej	                 e
d<   dZee
d<   dS )Ú_ShutdownStatezºPer-thread state for shutdown coordination.

    Issue #152 fix: Uses threading.local() instead of ContextVar to ensure
    one watcher per thread rather than one per async context.
    )Údefault_factoryÚeventsFÚwatcher_startedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úsetr   r   ÚanyioÚEventÚ__annotations__r    Úbool© ó    ú?C:\Projects\DSCons\.venv\Lib\site-packages\sse_starlette\sse.pyr   r   >   sR   € € € € € € ðð ð  %˜u°SÐ9Ñ9Ô9€FˆC�”ÔÐ9Ð9Ñ9Ø!€O�TÐ!Ð!Ñ!Ð!Ð!r+   r   Úreturnc                  ój   — t          t          dd¦  «        } | €t          ¦   «         } | t          _        | S )z4Get or create shutdown state for the current thread.Úshutdown_stateN)ÚgetattrÚ_thread_stater   r/   )Ústates    r,   Ú_get_shutdown_stater3   N   s1   € å•MÐ#3°TÑ:Ô:€EØ€}ÝÑ Ô ˆØ',�Ô$Ø€Lr+   c                  ó¸   — 	 t          j        t           j        ¦  «        } t          | d¦  «        r| j        }t          |d¦  «        r|S n# t
          $ r Y nw xY wdS )am  
    Try to get uvicorn Server instance via signal handler introspection.

    When uvicorn registers signal handlers, they're bound methods on the Server instance.
    We can retrieve the Server from the handler's __self__ attribute.

    Returns None if:
    - Not running under uvicorn
    - Signal handler isn't a bound method
    - Any introspection fails
    Ú__self__Úshould_exitN)ÚsignalÚ	getsignalÚSIGTERMÚhasattrr5   Ú	Exception)ÚhandlerÚservers     r,   Ú_get_uvicorn_serverr>   W   sp   € ðÝÔ"¥6¤>Ñ2Ô2ˆÝ�7˜JÑ'Ô'ð 	ØÔ%ˆFÝ�v˜}Ñ-Ô-ð Ø�øøÝð ð ð Øˆðøøøàˆ4s   ‚AA
 Á

AÁAc               ƒ   óX  K  — t          ¦   «         } t          ¦   «         }	 	 t          j        rn=t          j        r|�|j        rdt          _        nt          j        d¦  «        ƒ d{V —† ŒJt          | j        ¦  «        D ]}| 	                    ¦   «          Œ	 d| _
        dS # d| _
        w xY w)ag  
    Poll for shutdown and broadcast to all events in this context.

    One watcher runs per thread (event loop). Checks two shutdown sources:
    1. AppStatus.should_exit - set when our monkey-patch works
    2. uvicorn Server.should_exit - via signal handler introspection (Issue #132 fix)

    When either becomes True, signals all registered events.
    TNg      à?F)r3   r>   Ú	AppStatusr6   Úenable_automatic_graceful_drainr&   ÚsleepÚlistr   r%   r    )r2   Úuvicorn_serverÚevents      r,   Ú_shutdown_watcherrF   n   sÛ   è è € õ  Ñ!Ô!€EÝ(Ñ*Ô*€Nð&ð	#åÔ$ð Øõ Ô9ðà"Ð.Ø"Ô.ð /ð )-•	Ô%ØÝ”+˜cÑ"Ô"Ð"Ð"Ð"Ð"Ð"Ð"Ð"ð	#õ ˜%œ,Ñ'Ô'ð 	ð 	ˆEØ�IŠI‰KŒKˆKˆKð	ð !&ˆÔÐÐø ˆÔÐ%Ð%Ð%Ð%s    A6B  Â 	B)c                  óÜ   — t          ¦   «         } | j        sVd| _        	 t          j        ¦   «         }|                     t          ¦   «         ¦  «         dS # t          $ r d| _        Y dS w xY wdS )zDEnsure the shutdown watcher is running for this thread (event loop).TFN)r3   r    ÚasyncioÚget_running_loopÚcreate_taskrF   ÚRuntimeError)r2   Úloops     r,   Ú$_ensure_watcher_started_on_this_looprM   ’   sŠ   € åÑ!Ô!€EØÔ ð *Ø $ˆÔð	*ÝÔ+Ñ-Ô-ˆDØ×ÒÕ.Ñ0Ô0Ñ1Ô1Ð1Ð1Ð1øÝð 	*ð 	*ð 	*à$)ˆEÔ!Ð!Ð!Ð!ð	*øøøð*ð *s   ž4A ÁA)Á(A)Úsendc                 ó&   ‡ — dt           ddfˆ fd„}|S )a;  Mirror of ``starlette.responses.Response._wrap_websocket_denial_send``.

    Divergence #2 (see module docstring): inlined because the helper landed
    on Starlette ``main`` (commit 9ee9519) after our minimum pin
    ``starlette>=0.41.3``. Drop this once the floor moves past the release
    that contains it.
    Úmessager-   Nc              “   ó\   •K  — | d         }|dv ri | ¥dd|z   i¥}  ‰| ¦  «        ƒ d {V —† d S )NÚtype>   úhttp.response.bodyúhttp.response.startz
websocket.r*   )rP   Úmessage_typerN   s     €r,   Úwrappedz,_wrap_websocket_denial_send.<locals>.wrapped¨   s[   øè è € Ø˜v”ˆØÐHÐHÐHØF˜ÐF &¨,¸Ñ*EÐFÐFˆGØˆd�7‰mŒmÐÐÐÐÐÐÐÐÐr+   )r   )rN   rV   s   ` r,   Ú_wrap_websocket_denial_sendrW   Ÿ   s6   ø€ ð�wð ¨4ð ð ð ð ð ð ð €Nr+   c                   ó   — e Zd ZdS )ÚSendTimeoutErrorN)r!   r"   r#   r*   r+   r,   rY   rY   ±   s   € € € € € Ø€Dr+   rY   c                   óx   — e Zd ZU dZdZdZdZee         e	d<   e
d„ ¦   «         Ze
d„ ¦   «         Ze
d„ ¦   «         ZdS )	r@   z\Helper to capture a shutdown signal from Uvicorn so we can gracefully terminate SSE streams.FTNÚoriginal_handlerc                  ó   — dt           _        dS )aJ  
        Prevent automatic SSE stream termination on server shutdown.

        WARNING: When disabled, you MUST set AppStatus.should_exit = True
        at some point during shutdown, or streams will never close and the
        server will hang indefinitely (or until uvicorn's graceful shutdown
        timeout expires).
        FN©r@   rA   r*   r+   r,   Ú disable_automatic_graceful_drainz*AppStatus.disable_automatic_graceful_drain¼   s   € ð 5:�	Ô1Ð1Ð1r+   c                  ó   — dt           _        dS )a  
        Re-enable automatic SSE stream termination on server shutdown.

        This restores the default behavior where SIGTERM triggers immediate
        stream draining. Call this to undo a previous call to
        disable_automatic_graceful_drain().
        TNr]   r*   r+   r,   Ú$enable_automatic_graceful_drain_modez.AppStatus.enable_automatic_graceful_drain_modeÈ   s   € ð 59�	Ô1Ð1Ð1r+   c                  ót   — t           j        rdt           _        t           j        �t          j        | i |¤Ž d S d S )NT)r@   rA   r6   r[   )ÚargsÚkwargss     r,   Úhandle_exitzAppStatus.handle_exitÓ   sB   € åÔ4ð 	)Ø$(�IÔ!ÝÔ%Ð1ÝÔ&¨Ð7°Ð7Ð7Ð7Ð7Ð7ð 2Ð1r+   )r!   r"   r#   r$   r6   rA   r[   r   r
   r(   Ústaticmethodr^   r`   rd   r*   r+   r,   r@   r@   µ   sŒ   € € € € € € ØfÐfà€KØ&*Ð#Ø+/Ð�h˜xÔ(Ð/Ð/Ñ/àð	:ð 	:ñ „\ð	:ð ð9ð 9ñ „\ð9ð ð8ð 8ñ „\ð8ð 8ð 8r+   r@   )ÚServerzHUvicorn not installed. Graceful shutdown on server termination disabled.c                   ó$  — e Zd ZdZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 d'ded	ed
ee	e
e
f                  de
dee         dee         dee
         deeg ef                  deeg ed         f                  dee         deeeged         f                  deej                 deddfd„Zedeeef         fd„¦   «         Zej        deeef         ddfd„¦   «         Zd(deddfd„Zdeddfd„Zd eddfd!„Zed)d"„¦   «         Z d)d#„Z!deddfd$„Z"d%e#d ededdfd&„Z$dS )*ÚEventSourceResponseag  Streaming response implementing the SSE (Server-Sent Events) specification.

    Args:
        content: Async iterable or sync iterator yielding SSE event data.
        status_code: HTTP status code. Default: 200.
        headers: Additional HTTP headers.
        media_type: Response media type. Default: "text/event-stream".
        background: Background task to run after response completes.
        ping: Ping interval in seconds (0 to disable). Default: 15.
        sep: Line separator for SSE messages ("\r\n", "\r", or "\n").
        ping_message_factory: Callable returning custom ping ServerSentEvent.
        data_sender_callable: Async callable for push-based data sending.
        send_timeout: Timeout in seconds for individual send operations.
        client_close_handler_callable: Async callback on client disconnect.
        shutdown_event: Optional ``anyio.Event`` set by the library when server
            shutdown is detected. Generators can watch this event to send farewell
            messages and exit cooperatively instead of receiving CancelledError.
        shutdown_grace_period: Seconds to wait after setting ``shutdown_event``
            before force-cancelling the generator. Must be >= 0. Should be less
            than your ASGI server's graceful shutdown timeout. Default: 0
            (immediate cancel, identical to pre-v3.3.0 behavior).
    é   ú
éÈ   Nútext/event-streamr   ÚcontentÚstatus_codeÚheadersÚ
media_typeÚ
backgroundÚpingÚsepÚping_message_factoryÚdata_sender_callable)NNNÚsend_timeoutÚclient_close_handler_callableÚshutdown_eventÚshutdown_grace_periodr-   c                 ó|  — |dvrt          d|› �¦  «        ‚|p| j        | _        t          |t          ¦  «        r|| _        nt          |¦  «        | _        || _        |€| j        n|| _        || _	        |	| _
        |
| _        t          ¦   «         }|�|                     |¦  «         |                     dd¦  «         d|d<   d|d<   |                      |¦  «         |€| j        n|| _        || _        || _        |d	k     rt          d
¦  «        ‚|| _        || _        d| _        t/          j        ¦   «         | _        d S )N)Nrj   úú
z'sep must be one of: \r\n, \r, \n, got: zCache-Controlzno-storez
keep-aliveÚ
ConnectionÚnozX-Accel-Bufferingr   z"shutdown_grace_period must be >= 0T)Ú
ValueErrorÚDEFAULT_SEPARATORrs   Ú
isinstancer   Úbody_iteratorr   rn   rp   rq   ru   rv   r   ÚupdateÚ
setdefaultÚinit_headersÚDEFAULT_PING_INTERVALÚping_intervalrt   rw   Ú_shutdown_eventÚ_shutdown_grace_periodÚactiver&   ÚLockÚ
_send_lock)Úselfrm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   Ú_headerss                  r,   Ú__init__zEventSourceResponse.__init__  se  € ð* Ð0Ð0Ð0ÝÐPÈ3ÐPÐPÑQÔQÐQØÐ0˜$Ô0ˆŒõ �g�}Ñ-Ô-ð 	@Ø!(ˆDÔÐå!6°wÑ!?Ô!?ˆDÔà&ˆÔØ-7Ð-?˜$œ/˜/ÀZˆŒØ$ˆŒØ$8ˆÔ!Ø(ˆÔõ "Ñ#Ô#ˆØÐØ�OŠO˜GÑ$Ô$Ð$ð 	×Ò˜O¨ZÑ8Ô8Ð8à!-ˆ�ÑØ(,ˆÐ$Ñ%Ø×Ò˜(Ñ#Ô#Ð#à;?¸<˜TÔ7Ð7ÈTˆÔØ$8ˆÔ!à-JˆÔ*ð ! 1Ò$Ð$ÝÐAÑBÔBÐBØ-ˆÔØ&;ˆÔ#àˆŒåœ*™,œ,ˆŒˆˆr+   c                 ó   — | j         S ©N)Ú_ping_interval©r�   s    r,   r‡   z!EventSourceResponse.ping_intervalO  s   € àÔ"Ð"r+   Úvaluec                 ó”   — t          |t          t          f¦  «        st          d¦  «        ‚|dk     rt	          d¦  «        ‚|| _        d S )Nzping interval must be intr   z$ping interval must be greater than 0)r�   ÚintÚfloatÚ	TypeErrorr   r’   )r�   r”   s     r,   r‡   z!EventSourceResponse.ping_intervalS  sM   € å˜%¥#¥u Ñ.Ô.ð 	9ÝÐ7Ñ8Ô8Ð8Ø�1Š9ˆ9ÝÐCÑDÔDÐDØ#ˆÔÐÐr+   FÚforcec                 ó    — t          d¦  «        ‚)Nz-Compression is not supported for SSE streams.)ÚNotImplementedError)r�   r™   s     r,   Úenable_compressionz&EventSourceResponse.enable_compression[  s   € Ý!Ð"QÑRÔRÐRr+   rN   c              ƒ   ón  K  —  |d| j         | j        dœ¦  «        ƒ d{V —† | j        2 3 d{V —†}t          || j        ¦  «        }t
                               d|¦  «         t          j        | j	        ¦  «        5 } |d|ddœ¦  «        ƒ d{V —† ddd¦  «         n# 1 swxY w Y   |r=|j
        r6t          | j        dd¦  «        }|� |¦   «         ƒ d{V —† t          ¦   «         ‚Œ½6 | j        4 ƒd{V —† d	| _         |dd
d	dœ¦  «        ƒ d{V —† ddd¦  «        ƒd{V —† dS # 1 ƒd{V —†swxY w Y   dS )zHSend out SSE data to the client as it becomes available in the iterator.rT   )rR   Ústatusro   Nz	chunk: %srS   T©rR   ÚbodyÚ	more_bodyÚacloseFr+   )rn   Úraw_headersr‚   r   rs   ÚloggerÚdebugr&   Úmove_on_afterrv   Úcancel_calledr0   rY   rŒ   rŠ   )r�   rN   ÚdataÚchunkÚcancel_scoper¢   s         r,   Ú_stream_responsez$EventSourceResponse._stream_response^  sÂ  è è € àˆdà-ØÔ*ØÔ+ðð ñ
ô 
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð Ô,ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)�$Ý   t¤xÑ0Ô0ˆEÝ�LŠL˜ eÑ,Ô,Ð,ÝÔ$ TÔ%6Ñ7Ô7ð ¸<Ø�dØ1¸5ÈtÐTÐTñô ð ð ð ð ð ð ð ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð
 ð ) Ô :ð )Ý  Ô!3°X¸tÑDÔD�ØÐ%Ø ˜&™(œ(�N�N�N�N�N�N�NÝ&Ñ(Ô(Ð(øð -ð ”?ð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	XØˆDŒKØ�$Ð 4¸cÐPUÐVÐVÑWÔWÐWÐWÐWÐWÐWÐWÐWð	Xð 	Xð 	Xñ 	Xô 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xøøøð 	Xð 	Xð 	Xð 	Xð 	Xð 	Xs)   ©C&Á9BÂB	Â"B	Ã4D$Ä$
D.Ä1D.Úreceivec              ƒ   óì   K  — | j         rj |¦   «         ƒ d{V —†}|d         dk    rEd| _         t                               d¦  «         | j        r|                      |¦  «        ƒ d{V —† dS | j         °hdS dS )uq  Watch for a disconnect message from the client.

        Divergence #1 (see module docstring): kept unconditionally instead of
        adopting Starlette's ASGI 2.4 ``OSError â†’ ClientDisconnect`` fast path,
        because this loop drives ``client_close_handler_callable`` and flips
        ``self.active = False`` for ``_ping`` and the shutdown grace loop.
        NrR   zhttp.disconnectFz+Got event: http.disconnect. Stop streaming.)rŠ   r¤   r¥   rw   )r�   r¬   rP   s      r,   Ú_listen_for_disconnectz*EventSourceResponse._listen_for_disconnectz  sª   è è € ð Œkð 	Ø#˜G™IœI�o�o�o�o�o�oˆGØ�vŒÐ"3Ò3Ð3Ø#�”Ý—’ÐJÑKÔKÐKØÔ5ð FØ×<Ò<¸WÑEÔEÐEÐEÐEÐEÐEÐEÐEØ�ð Œkð 	ð 	ð 	ð 	ð 	r+   c               ƒ   ó²  K  — t           j        rdS t          ¦   «          t          ¦   «         } t	          j        ¦   «         }| j                             |¦  «         	 t           j        r	 | j                             |¦  «         dS | 	                    ¦   «         ƒ d{V —† | j                             |¦  «         dS # | j                             |¦  «         w xY w)z0Wait for shutdown signal via the shared watcher.N)
r@   r6   rM   r3   r&   r'   r   ÚaddÚdiscardÚwait)r2   rE   s     r,   Ú_listen_for_exit_signalz+EventSourceResponse._listen_for_exit_signal‹  sÛ   è è € õ Ô ð 	ØˆFå,Ñ.Ô.Ð.å#Ñ%Ô%ˆÝ”‘”ˆØŒ×Ò˜ÑÔÐð	(åÔ$ð Øð ŒL× Ò  Ñ'Ô'Ð'Ð'Ð'ð —*’*‘,”,ÐÐÐÐÐÐÐàŒL× Ò  Ñ'Ô'Ð'Ð'Ð'øˆEŒL× Ò  Ñ'Ô'Ð'Ð'øøøs   ÁB: ÂB: Â:Cc              ƒ   óL  K  — |                       ¦   «         ƒ d{V —† | j        r| j                             ¦   «          | j        dk    r\t	          j        | j        ¦  «        5  | j        r!t	          j        d¦  «        ƒ d{V —† | j        °!ddd¦  «         dS # 1 swxY w Y   dS dS )a~  Wait for shutdown signal, then optionally give generator a grace period.

        Issue #167: When a shutdown_event is provided, the library sets it before
        returning, giving the generator a chance to send farewell events and exit
        cooperatively. The shutdown_grace_period controls how long to wait before
        force-cancelling via task group cancellation.
        Nr   gš™™™™™¹?)r³   rˆ   r%   r‰   r&   r¦   rŠ   rB   r“   s    r,   Ú"_listen_for_exit_signal_with_gracez6EventSourceResponse._listen_for_exit_signal_with_graceŸ  s  è è € ð ×*Ò*Ñ,Ô,Ð,Ð,Ð,Ð,Ð,Ð,Ð,ð Ôð 	'ØÔ ×$Ò$Ñ&Ô&Ð&ð Ô&¨Ò*Ð*ÝÔ$ TÔ%@ÑAÔAð +ð +Ø”kð +Ýœ+ cÑ*Ô*Ð*Ð*Ð*Ð*Ð*Ð*Ð*ð ”kð +ð+ð +ð +ñ +ô +ð +ð +ð +ð +ð +ð +ð +øøøð +ð +ð +ð +ð +ð +ð +Ð*s   Á!)BÂBÂBc              ƒ   ó  K  — | j         rõt          j        | j        ¦  «        ƒ d{V —† | j        r|                      ¦   «         n4t          dt          j        t          j	        ¦  «        › �| j
        ¬¦  «        }t          || j
        ¦  «        }t                               d|¦  «         | j        4 ƒd{V —† | j         r |d|ddœ¦  «        ƒ d{V —† ddd¦  «        ƒd{V —† n# 1 ƒd{V —†swxY w Y   | j         °ódS dS )zàPeriodically send ping messages to keep the connection alive on proxies.
        - frequenccy ca every 15 seconds.
        - Alternatively one can send periodically a comment line (one starting with a ':' character)
        Nzping - )Úcommentrs   zping: %srS   TrŸ   )rŠ   r&   rB   r’   rt   r   r   Únowr   Úutcrs   r   r¤   r¥   rŒ   )r�   rN   Ússe_pingÚ
ping_bytess       r,   Ú_pingzEventSourceResponse._ping³  sÔ  è è € ð
 Œkð 	Ý”+˜dÔ1Ñ2Ô2Ð2Ð2Ð2Ð2Ð2Ð2Ð2ð Ô,ð�×)Ò)Ñ+Ô+Ð+å$ØB¥h¤lµ8´<Ñ&@Ô&@ÐBÐBÈÌðñ ô ð õ & h°´Ñ9Ô9ˆJÝ�LŠL˜ ZÑ0Ô0Ð0à”ð ð ð ð ð ð ð ð Ø”;ð Ø˜$à$8Ø$.Ø)-ðð ñô ð ð ð ð ð ð ð ðð ð ñ ô ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð øøøð ð ð ð ð Œkð 	ð 	ð 	ð 	ð 	s   Â6C%Ã%
C/Ã2C/Úscopec              ƒ   ó¨  ‡ ‡‡‡K  — |d         dk    rt          ‰¦  «        Št          ¦   «         5  t          j        ¦   «         4 ƒd{V —†Šdt          g t
          d         f         fˆfd„}‰                     |ˆ ˆfd„¦  «         ‰                     |ˆ ˆfd„¦  «         ‰                     |‰ j        ¦  «         ‰ j        r‰                     ‰ j        ¦  «         ‰                     |ˆˆ fd„¦  «         ddd¦  «        ƒd{V —† n# 1 ƒd{V —†swxY w Y   ddd¦  «         n# 1 swxY w Y   ‰ j	        �‰  	                    ¦   «         ƒ d{V —† dS dS )	a  Entrypoint for Starlette's ASGI contract. We spin up tasks:
        - _stream_response to push events
        - _ping to keep the connection alive
        - _listen_for_exit_signal to respond to server shutdown
        - _listen_for_disconnect to respond to client disconnect
        rR   Ú	websocketNÚcoroc              “   ó^   •K  —  | ¦   «         ƒ d {V —† ‰j                              ¦   «          d S r‘   )rª   Úcancel)rÀ   Ú
task_groups    €r,   Úcancel_on_finishz6EventSourceResponse.__call__.<locals>.cancel_on_finishá  s9   øè è € Ø˜$™&œ&�L�L�L�L�L�L�LØÔ+×2Ò2Ñ4Ô4Ð4Ð4Ð4r+   c                  ó.   •— ‰                       ‰¦  «        S r‘   )r«   ©r�   rN   s   €€r,   ú<lambda>z.EventSourceResponse.__call__.<locals>.<lambda>æ  s   ø€ ¨d×.CÒ.CÀDÑ.IÔ.I€ r+   c                  ó.   •— ‰                       ‰¦  «        S r‘   )r¼   rÆ   s   €€r,   rÇ   z.EventSourceResponse.__call__.<locals>.<lambda>è  s   ø€ ÀÇ
Â
È4Ñ@PÔ@P€ r+   c                  ó.   •— ‰                      ‰ ¦  «        S r‘   )r®   )r¬   r�   s   €€r,   rÇ   z.EventSourceResponse.__call__.<locals>.<lambda>ò  s   ø€ ¨d×.IÒ.IÈ'Ñ.RÔ.R€ r+   )
rW   r   r&   Úcreate_task_groupr
   r	   Ú
start_soonrµ   ru   rq   )r�   r½   r¬   rN   rÄ   rÃ   s   ` `` @r,   Ú__call__zEventSourceResponse.__call__Î  sv  øøøøè è € ð �Œ=˜KÒ'Ð'Ý.¨tÑ4Ô4ˆDõ
  Ñ!Ô!ð 	ð 	ÝÔ.Ñ0Ô0ð ð ð ð ð ð ð °Jð5µ¸"½iÈ¼oÐ:MÔ1Nð 5ð 5ð 5ð 5ð 5ð 5ð ×%Ò%Ø$Ð&IÐ&IÐ&IÐ&IÐ&Iñô ð ð ×%Ò%Ð&6Ð8PÐ8PÐ8PÐ8PÐ8PÑQÔQÐQØ×%Ò%Ø$ dÔ&Mñô ð ð Ô,ð EØ×)Ò)¨$Ô*CÑDÔDÐDð ×%Ò%Ø$Ð&RÐ&RÐ&RÐ&RÐ&Rñô ð ð%ð ð ñ ô ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð øøøð ð ð ð ð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð. Œ?Ð&Ø—/’/Ñ#Ô#Ð#Ð#Ð#Ð#Ð#Ð#Ð#Ð#Ð#ð 'Ð&s6   °D$Á
B+DÃ5D$Ä
D	ÄD$ÄD	ÄD$Ä$D(Ä+D()rk   Nrl   NNNNNNNNr   )F©r-   N)%r!   r"   r#   r$   r†   r€   ÚContentStreamr–   r   r   Ústrr   r
   r   r   r—   r   r	   r&   r'   r�   Úpropertyr   r‡   Úsetterr)   rœ   r   r«   r   r®   re   r³   rµ   r¼   r   rÌ   r*   r+   r,   rh   rh   ë   sÛ  € € € € € ðð ð. ÐØÐð
 Ø/3Ø-Ø/3Ø"Ø!ØHLð Ø(,ð Ø04Ø'(ð%G'ð G'àðG'ð ðG'ð ˜' # s (Ô+Ô,ð	G'ð
 ðG'ð ˜^Ô,ðG'ð �sŒmðG'ð �cŒ]ðG'ð ' x°°OÐ0CÔ'DÔEðG'ð 'Ø�R˜Ð#3Ô4Ð4Ô5ô
ðG'ð ˜u”oðG'ð (0Ø�g�Y 	¨$¤Ð/Ô0ô(
ðG'ð" ! ¤Ô-ð#G'ð$  %ð%G'ð& 
ð'G'ð G'ð G'ð G'ðR ð#˜u S¨% ZÔ0ð #ð #ð #ñ „Xð#ð Ôð$ 5¨¨e¨Ô#4ð $¸ð $ð $ð $ñ Ôð$ðSð S¨ð S¸ð Sð Sð Sð SðX¨4ð X°Dð Xð Xð Xð Xð8°Gð Àð ð ð ð ð" ð(ð (ð (ñ „\ð(ð&+ð +ð +ð +ð( ð ¨ð ð ð ð ð6($ Eð ($°Gð ($À4ð ($ÈDð ($ð ($ð ($ð ($ð ($ð ($r+   rh   rÍ   )Dr$   rH   Úloggingr7   Ú	threadingÚdataclassesr   r   r   r   Útypingr   r   r	   r
   r   r   r   r   r   r   r&   Ústarlette.backgroundr   Ústarlette.concurrencyr   Ústarlette.datastructuresr   Ústarlette.responsesr   Ústarlette.typesr   r   r   r   Ússe_starlette._utilsr   Ússe_starlette.eventr   r   Ú	getLoggerr!   r¤   r   Úlocalr1   r3   r>   rF   rM   rW   ÚTimeoutErrorrY   r@   Úuvicorn.mainrf   rd   r[   ÚImportErrorr¥   rÏ   ÚbytesÚdictÚContentÚSyncContentStreamÚAsyncContentStreamrÎ   rh   r*   r+   r,   ú<module>rç      sŒ  ððð ð8 €€€Ø €€€Ø €€€Ø Ð Ð Ð Ø (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð €€€Ø /Ð /Ð /Ð /Ð /Ð /Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø (Ð (Ð (Ð (Ð (Ð (Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9à 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø =Ð =Ð =Ð =Ð =Ð =Ð =Ð =ð 
ˆÔ	˜8Ñ	$Ô	$€ð ð"ð "ð "ð "ð "ñ "ô "ñ „ð"ð  �	”Ñ!Ô!€ð˜^ð ð ð ð ðð ð ð.!&ð !&ð !&ð !&ðH
*ð 
*ð 
*ð 
*ð dð ¨tð ð ð ð ð$	ð 	ð 	ð 	ð 	�|ñ 	ô 	ð 	ð#8ð #8ð #8ð #8ð #8ñ #8ô #8ð #8ðLØ#Ð#Ð#Ð#Ð#Ð#à!'Ô!3€IÔØ"Ô.€FÔÐøØð ð ð Ø
‡L‚LØRñô ð ð ð ðøøøð
 ��U˜D /°3Ð6Ô
7€Ø˜WÔ%Ð Ø" 7Ô+Ð ØÐ(Ð*;Ð;Ô<€ðK$ð K$ð K$ð K$ð K$˜(ñ K$ô K$ð K$ð K$ð K$s   ÃC9 Ã9DÄD