
    0j                          d Z ddlZddlZddlmZ ddlmZ ddlmZ  ej	        e
          Z ej        dej                  Zdee         dee         fd	Zdd
edee         fdZdS )z[
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
    N)Optional)CloudEnvironment)Tokenz^(https?://[^/]+)cloudreturnc                     | dS | j                                         }|sdS t                              |          }|t                              d|           dS |                    d          S )zQDerive the Graph API base URL from a cloud's graph_scope, or None if unavailable.Nzgraph_scope %r is not a URL; Graph calls will route to the public cloud. Set graph_scope to an 'https://<host>/.default' value to route to the correct Graph endpoint.   )graph_scopestrip_GRAPH_BASE_URL_REmatchloggerwarninggroup)r   scoper   s      h/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/microsoft_teams/apps/utils/graph.py_derive_graph_base_urlr      s{    }t##%%E t$$U++E}l	
 	
 	

 t;;q>>    tokenc                     	 ddl m}  || t          |                    S # t          $ r}t          d          |d}~ww xY w)a{  Lazy import and create a Graph client with the given token.

    Args:
        token: The token used to authenticate Graph requests.
        cloud: Optional cloud environment. When provided (and non-None), the Graph client
            routes HTTP calls to the cloud's Graph endpoint derived from ``graph_scope``.
            When ``None``, the public Graph endpoint is used.
    r   )get_graph_client)base_urlzYGraph functionality not available. Install with 'pip install microsoft-teams-apps[graph]'N)microsoft_teams.graphr   r   ImportError)r   r   r   excs       r   create_graph_clientr   &   so    ::::::0Fu0M0MNNNN   g
 
	s   " 
A<A)N)__doc__loggingretypingr   *microsoft_teams.api.auth.cloud_environmentr   (microsoft_teams.common.http.client_tokenr   	getLogger__name__r   compile
IGNORECASEr   strr   r    r   r   <module>r)      s    
  				       G G G G G G : : : : : :		8	$	$  RZ 4bmDD (+;"< #    $ u X6F-G      r   