a
    ên§aã  ã                   @  sJ   d Z ddlmZ ddlZe e¡ZdZdddœdd„Zdddœd	d
„Z	dS )z6 Internal utility functions used by ``bokeh.client``

é    )ÚannotationsN)Úserver_url_for_websocket_urlÚwebsocket_url_for_server_urlÚstr)ÚurlÚreturnc                 C  sb   |   d¡rd| dd…  }n(|   d¡r8d| dd…  }ntd|  ƒ‚| d	¡sVtd
ƒ‚|dd… S )ag   Convert an ``ws(s)`` URL for a Bokeh server into the appropriate
    ``http(s)`` URL for the websocket endpoint.

    Args:
        url (str):
            An ``ws(s)`` URL ending in ``/ws``

    Returns:
        str:
            The corresponding ``http(s)`` URL.

    Raises:
        ValueError:
            If the input URL is not of the proper form.

    zws:Zhttpé   Nzwss:Zhttpsé   zURL has non-websocket protocol ú/wsz!websocket URL does not end in /wséþÿÿÿ©Ú
startswithÚ
ValueErrorÚendswith©r   Zreprotocoled© r   ú0lib/python3.9/site-packages/bokeh/client/util.pyr   (   s    


r   c                 C  sb   |   d¡rd| dd…  }n(|   d¡r8d| dd…  }ntd|  ƒ‚| d	¡rV|d S |d
 S dS )a]   Convert an ``http(s)`` URL for a Bokeh server websocket endpoint into
    the appropriate ``ws(s)`` URL

    Args:
        url (str):
            An ``http(s)`` URL

    Returns:
        str:
            The corresponding ``ws(s)`` URL ending in ``/ws``

    Raises:
        ValueError:
            If the input URL is not of the proper form.

    zhttp:Zwsé   Nzhttps:Zwssé   zURL has unknown protocol ú/r
   r   r   r   r   r   r   C   s    


r   )
Ú__doc__Z
__future__r   ZloggingZ	getLoggerÚ__name__ÚlogÚ__all__r   r   r   r   r   r   Ú<module>   s   

