
    3i                         S SK JrJr  S SKJr  S SKJrJr  S SKJ	r	  S\S\
S\\\   \\   4   4S jr  SS\S\
S
\\   S\\   S\\\   \\   4   4
S jjrg	)    )OptionalTuple)UserIdentity)DEFAULT_DATABASEDEFAULT_TENANT)ChromaAuthErroruser_identity4overwrite_singleton_tenant_database_access_from_authreturnc                     U(       d  gSnSnU R                   nU R                  nU(       a  US:w  a  UnU(       a.  [        U5      n[        U5      S:X  a  SU;  a  [	        U5      S   nX#4$ )a  
If settings.chroma_overwrite_singleton_tenant_database_access_from_auth
is False, this function always returns (None, None).

If settings.chroma_overwrite_singleton_tenant_database_access_from_auth
is True, follows the following logic:
- If the user only has access to a single tenant, this function will
    return that tenant as its first return value.
- If the user only has access to a single database, this function will
    return that database as its second return value. If the user has
    access to multiple tenants and/or databases, including "*", this
    function will return None for the corresponding value(s).
- If the user has access to multiple tenants and/or databases this
    function will return None for the corresponding value(s).
NNN*   r   )tenant	databasessetlenlist)r	   r
   r   databaseuser_tenantuser_databasesuser_databases_sets          V/home/james-whalen/.local/lib/python3.13/site-packages/chromadb/auth/utils/__init__.py(_singleton_tenant_database_if_applicabler      sw    & @FH&&K",,N{c) 0!"a'C7I,I./2H    Nuser_provided_tenantuser_provided_databasec                 F   [        U US9u  nnU(       a(  U[        :w  a  U(       a  XB:w  a  [        SU SU S35      eU(       a(  U[        :w  a  U(       a  XS:w  a  [        SU SU S35      eU(       a
  U[        :X  a	  U(       a  UnU(       a
  U[        :X  a	  U(       a  UnX#4$ )N)r	   r
   zTenant z does not match z5 from the server. Are you sure the tenant is correct?z	Database z7 from the server. Are you sure the database is correct?)r   r   r   r   )r	   r
   r   r   
new_tenantnew_databases         r   maybe_set_tenant_and_databaser!   *   s     	1#=q	 	 N2.(<'==Mj\  ZO  P  Q  	Q"&662	*@)AAQR^Q_  `W  X  Y  	Y !$8N$J
)"&<@P&P
!-77r   r   )typingr   r   chromadb.authr   chromadb.configr   r   chromadb.errorsr   boolstrr   r!    r   r   <module>r)      s    " & < +:> 8C=(3-'(J +/,0	,8,8:>,8 #3-,8 %SM	,8
 8C=(3-'(,8r   