Ë
    :vžj„  ã                  ó´   — U d Z ddl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 dd	lmZ erdd
lmZ dZ G d„ deej&                  «      Zg Zded<   y)z.Serve files directly from the ContentsManager.é    )ÚannotationsN)Údecodebytes)ÚTYPE_CHECKING)Úensure_async)Úweb)Ú
authorized)ÚJupyterHandler)Ú	AwaitableÚcontentsc                  ó�   ‡ — e Zd ZdZeZeˆ fd„«       Zej                  e
dd„«       «       Zej                  e
dd„«       «       Zˆ xZS )ÚFilesHandlerzÝserve files via ContentsManager

    Normally used when ContentsManager is not a FileContentsManager.

    FileContentsManager subclasses use AuthenticatedFilesHandler by default,
    a subclass of StaticFileHandler.
    c                ó   •— t         ‰| �  dz   S )zThe content security policy.z; sandbox allow-scripts)ÚsuperÚcontent_security_policy)ÚselfÚ	__class__s    €ún/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/jupyter_server/files/handlers.pyr   z$FilesHandler.content_security_policy"   s   ø€ ô
 ‰wÑ.Ð1JÑJÐJó    c                ón   — | j                  |d¬«       | j                  «        | j                  |d¬«      S )zThe head response.F)Úinclude_body)ÚgetÚcheck_xsrf_cookie)r   Úpaths     r   ÚheadzFilesHandler.head)   s3   € ð 	�‰� EˆÔ*Ø×ÑÔ Ø�x‰x˜¨5ˆxÓ1Ð1r   c              ƒ  óR  K  — | j                  «        | j                  }|j                  sRt        |j	                  |«      «      ƒ d{  –—† r0| j
                  j                  d«       t        j                  d«      ‚|j                  d«      }d|v r|j                  dd«      \  }}n|}t        |j                  |d|¬«      «      ƒ d{  –—† }| j                  dd«      r| j                  |«       |j                  «       j                  d	«      r| j!                  d
d«       nžt#        j$                  |«      \  }}|dk(  r| j!                  d
d«       |dk(  r| j!                  d
d«       nW|�| j!                  d
d«       nB|�| j!                  d
|«       n-|d   dk(  r| j!                  d
d«       n| j!                  d
d«       |r\|d   dk(  r/|d   j'                  d«      }	| j)                  t+        |	«      «       n| j)                  |d   «       | j-                  «        yy7 �ŒÙ7 �ŒZ­w)zGet a file by path.Nz,Refusing to serve hidden file, via 404 Errori”  Ú/é   Úfile)ÚtypeÚcontentÚdownloadz.ipynbzContent-Typezapplication/x-ipynb+jsonz
text/plainztext/plain; charset=UTF-8Úgzipzapplication/gzipzapplication/octet-streamÚformatÚbase64r    Úascii)r   Úcontents_managerÚallow_hiddenr   Ú	is_hiddenÚlogÚinfor   Ú	HTTPErrorÚstripÚrsplitr   Úget_argumentÚset_attachment_headerÚlowerÚendswithÚ
set_headerÚ	mimetypesÚ
guess_typeÚencodeÚwriter   Úflush)
r   r   r   ÚcmÚ_ÚnameÚmodelÚcur_mimeÚencodingÚ	b64_bytess
             r   r   zFilesHandler.get1   sà  è ø€ ð
 	×ÑÔ Ø×"Ñ"ˆà�Š¬°b·l±lÀ4Ó6HÓ)I×#IÐ#IØ�H‰H�M‰MÐHÔIÜ—-‘- Ó$Ð$à�z‰z˜#‹ˆØ�$‰;Ø—k‘k # qÓ)‰GˆA‰tàˆDä" 2§6¡6¨$°VÀ\ 6Ó#RÓS×Sˆà×Ñ˜Z¨Ô.Ø×&Ñ& tÔ,ð �:‰:‹<× Ñ  Ô*Ø�O‰O˜NÐ,FÕGä!*×!5Ñ!5°dÓ!;ÑˆH�hØ˜<Ò'Ø—‘ Ð0KÔLà˜6Ò!Ø—‘ Ð0BÕCØÐ%Ø—‘ Ð0JÕKØÐ%Ø—‘ °Õ9Ø�x‘ HÒ,Ø—‘ Ð0JÕKà—‘ Ð0KÔLáØ�X‰ (Ò*Ø! )Ñ,×3Ñ3°GÓ<�	Ø—
‘
œ; yÓ1Õ2à—
‘
˜5 Ñ+Ô,Ø�J‰J�Lð ðE $Jùð Tûs&   ‚AH'ÁH!Á	BH'Ã
H$ÃEH'È$H')r   ÚstrÚreturnzAwaitable[None] | None)T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚAUTH_RESOURCEÚauth_resourceÚpropertyr   r   Úauthenticatedr   r   r   Ú__classcell__)r   s   @r   r   r      sg   ø„ ñð "€MàóKó ðKð 	×ÑØò2ó ó ð2ð 	×ÑØò.ó ó ô.r   r   zlist[JupyterHandler]Údefault_handlers)rD   Ú
__future__r   r3   r$   r   Útypingr   Újupyter_core.utilsr   Útornador   Újupyter_server.auth.decoratorr   Újupyter_server.base.handlersr	   Úcollections.abcr
   rE   ÚStaticFileHandlerr   rJ   Ú__annotations__© r   r   Ú<module>rU      sR   ðÚ 4õ #ã Ý Ý  å +Ý å 4Ý 7áÝ)à€ôJ�> 3×#8Ñ#8ô JðZ *,Ð Ð&Ô +r   