Ë
    :vžj‚  ã                  ó¨   — d Z ddlmZ ddlmZmZ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d	lmZ dd
lmZ  G d„ d«      Z G d„ d«      Zy)zAn extension handler.é    )Úannotations)ÚTYPE_CHECKINGÚAnyÚcast)ÚTemplateNotFound)ÚFileFindHandler)ÚLogger)ÚTemplate)ÚConfig)ÚExtensionApp)Ú	ServerAppc                  ó$   ‡ — e Zd ZdZdˆ fd„Zˆ xZS )ÚExtensionHandlerJinjaMixinz`Mixin class for ExtensionApp handlers that use jinja templating for
    template rendering.
    c                óÈ   •— 	 | j                   › d�}t        d| j                  |   j                  |«      «      }|S # t        $ r t        dt
        ‰| �  |«      «      cY S w xY w)z1Return the jinja template object for a given nameÚ_jinja2_envr
   )Únamer   ÚsettingsÚget_templater   Úsuper)Úselfr   ÚenvÚtemplateÚ	__class__s       €úq/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/jupyter_server/extension/handler.pyr   z'ExtensionHandlerJinjaMixin.get_template   sf   ø€ ð	@Ø—Y‘Y�K˜{Ð+ˆCÜ˜J¨¯©°cÑ(:×(GÑ(GÈÓ(MÓNˆHØˆOøÜò 	@Ü˜
¤E¡GÑ$8¸Ó$>Ó?Ò?ð	@ús   ƒ8< ¼"A!Á A!)r   ÚstrÚreturnr
   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__©r   s   @r   r   r      s   ø„ ñ÷@ñ @ó    r   c                  óÚ   ‡ — e Zd ZU dZded<   dˆ fd„Zedd„«       Zedd„«       Zedˆ fd„«       Z	edd„«       Z
edd	„«       Zedd
„«       Zdˆ fd„Zedd„«       Zedd„«       Zddd„Zˆ xZS )ÚExtensionHandlerMixina.  Base class for Jupyter server extension handlers.

    Subclasses can serve static files behind a namespaced
    endpoint: "<base_url>/static/<name>/"

    This allows multiple extensions to serve static files under
    their own namespace and avoid intercepting requests for
    other extensions.
    zdict[str, Any]r   c                óR   •— || _         	 t        ‰| �  |i |¤Ž y # t        $ r Y y w xY w©N)r   r   Ú
initializeÚ	TypeError)r   r   ÚargsÚkwargsr   s       €r   r(   z ExtensionHandlerMixin.initialize1   s3   ø€ ØˆŒ	ð	Ü‰GÑ Ð/¨Ó/øÜò 	Ùð	ús   Š š	&¥&c                óH   — t        d| j                  | j                     «      S )Nr   ©r   r   r   ©r   s    r   Úextensionappz"ExtensionHandlerMixin.extensionapp8   s   € ä�N D§M¡M°$·)±)Ñ$<Ó=Ð=r#   c                ó8   — d}t        d| j                  |   «      S )NÚ	serverappr   ©r   r   )r   Úkeys     r   r1   zExtensionHandlerMixin.serverapp<   s   € àˆÜ�K §¡¨sÑ!3Ó4Ð4r#   c                óä   •— t        | d«      st        dt        ‰| �  «      S 	 t        d| j                  j                  «      S # t
        $ r# t        d| j                  j                  «      cY S w xY w)Nr   r	   )Úhasattrr   r   Úlogr/   ÚAttributeErrorr1   )r   r   s    €r   r6   zExtensionHandlerMixin.logA   sb   ø€ ä�t˜VÔ$Ü˜¤%¡'¡+Ó.Ð.ð	6Ü˜ $×"3Ñ"3×"7Ñ"7Ó8Ð8øÜò 	6Ü˜ $§.¡.×"4Ñ"4Ó5Ò5ð	6ús   £A Á)A/Á.A/c                óN   — t        d| j                  | j                  › d�   «      S )Nr   Ú_configr-   r.   s    r   ÚconfigzExtensionHandlerMixin.configK   s#   € ä�H˜dŸm™m¨t¯y©y¨k¸Ð,AÑBÓCÐCr#   c                ó4   — t        d| j                  d   «      S )Nr   r:   r2   r.   s    r   Úserver_configz#ExtensionHandlerMixin.server_configO   s   € ä�H˜dŸm™m¨HÑ5Ó6Ð6r#   c                óN   — t        d| j                  j                  dd«      «      S )Nr   Úbase_urlÚ/)r   r   Úgetr.   s    r   r>   zExtensionHandlerMixin.base_urlS   s    € ä�E˜4Ÿ=™=×,Ñ,¨Z¸Ó=Ó>Ð>r#   c                óä   •— t        d| j                  |«      «      }|j                  | j                  «       |j                  | j
                  d   u rt        ‰| �  |d<    |j                  di |¤ŽS )zîOverride render template to handle static_paths

        If render_template is called with a template from the base environment
        (e.g. default error pages)
        make sure our extension-specific static_url is _not_ used.
        r
   Ú
jinja2_envÚ
static_url© )	r   r   ÚupdateÚtemplate_namespaceÚenvironmentr   r   rC   Úrender)r   r   Únsr   r   s       €r   Úrender_templatez%ExtensionHandlerMixin.render_templateW   sh   ø€ ô ˜
 D×$5Ñ$5°dÓ$;Ó<ˆØ
�	‰	�$×)Ñ)Ô*Ø×Ñ 4§=¡=°Ñ#>Ñ>ä$™wÑ1ˆBˆ|ÑØˆx�‰Ñ$ Ñ$Ð$r#   c                ó.   — | j                   j                  S r'   )r/   Ústatic_url_prefixr.   s    r   rL   z'ExtensionHandlerMixin.static_url_prefixe   s   € à× Ñ ×2Ñ2Ð2r#   c                óN   — t        d| j                  | j                  › d�   «      S )Nr   Ú_static_pathsr-   r.   s    r   Ústatic_pathz!ExtensionHandlerMixin.static_pathi   s#   € ä�E˜4Ÿ=™=¨D¯I©I¨;°mÐ)DÑEÓFÐFr#   c           	     óÞ  — | j                   › d�}	 | j                  |d«       | j                  j	                  dt
        «      j                  }|€t        | dd«      }d}|r0| j                  j                  d	z   | j                  j                  z   }| j                  | j                  d
œ}	|t        d ||	|fi |¤Ž«      z   S # t        $ r#}|| j                  v rd}t        |«      d‚|‚d}~ww xY w)aÃ  Returns a static URL for the given relative static file path.
        This method requires you set the ``{name}_static_path``
        setting in your extension (which specifies the root directory
        of your static files).
        This method returns a versioned url (by default appending
        ``?v=<signature>``), which allows the static files to be
        cached indefinitely.  This can be disabled by passing
        ``include_version=False`` (in the default implementation;
        other static file implementations are not required to support
        this, but they may support other options).
        By default this method returns URLs relative to the current
        host, but if ``include_host`` is true the URL returned will be
        absolute.  If this handler has an ``include_host`` attribute,
        that value will be used as the default for all `static_url`
        calls that do not pass ``include_host`` as a keyword argument.
        rN   rC   zlThis extension doesn't have any static paths listed. Check that the extension's `static_paths` trait is set.NÚstatic_handler_classÚinclude_hostFÚ z://)rO   rL   r   )r   Úrequire_settingÚ	Exceptionr   r@   r   Úmake_static_urlÚgetattrÚrequestÚprotocolÚhostrO   rL   r   )
r   ÚpathrR   r+   r3   ÚeÚmsgÚget_urlÚbaser   s
             r   rC   z ExtensionHandlerMixin.static_urlm   sý   € ð" —‘�˜=Ð)ˆð
	Ø× Ñ   lÔ3ð —-‘-×#Ñ#Ð$:¼OÓL×\Ñ\ˆàÐÜ" 4¨¸Ó?ˆLàˆÙØ—<‘<×(Ñ(¨5Ñ0°4·<±<×3DÑ3DÑDˆDð
  ×+Ñ+Ø!%×!7Ñ!7ñ
ˆð
 ”d˜5¡'¨(°DÑ"C¸FÑ"CÓDÑDÐDøô5 ò 	Ø�d—m‘mÑ#ð?ð ô   “n¨$Ð.à�ûð	ús   ‘C  Ã 	C,Ã	C'Ã'C,)r   r   r*   r   r+   r   r   ÚNone)r   r   )r   r   )r   r	   )r   r   )r   r   )r   r   r   r   r'   )r[   r   rR   zbool | Noner+   r   r   r   )r   r   r   r    Ú__annotations__r(   Úpropertyr/   r1   r6   r:   r<   r>   rJ   rL   rO   rC   r!   r"   s   @r   r%   r%   $   sÊ   ø… ñð Óõð ò>ó ð>ð ò5ó ð5ð ô6ó ð6ð òDó ðDð ò7ó ð7ð ò?ó ð?õ%ð ò3ó ð3ð òGó ðG÷.Eð .Er#   r%   N)r    Ú
__future__r   Útypingr   r   r   Újinja2.exceptionsr   Újupyter_server.base.handlersr   Úloggingr	   Újinja2r
   Útraitlets.configr   Ú$jupyter_server.extension.applicationr   Újupyter_server.serverappr   r   r%   rD   r#   r   Ú<module>rl      sC   ðÙ å "ç +Ñ +å .å 8áÝåÝ'åAÝ2÷@ñ @÷wEò wEr#   