§
    ˜Štj�  ã                   óÜ   — d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	 dede
deee         ee         f         fd„Z	 	 ddede
d
ee         dee         deee         ee         f         f
d„Zd	S )é    )ÚOptionalÚTuple)ÚUserIdentity)ÚDEFAULT_DATABASEÚDEFAULT_TENANT)ÚChromaAuthErrorÚuser_identityÚ4overwrite_singleton_tenant_database_access_from_authÚreturnc                 óÄ   — |sdS d}d}| j         }| j        }|r|dk    r|}|r;t          |¦  «        }t          |¦  «        dk    rd|vrt	          |¦  «        d         }||fS )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          úZ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/chromadb/auth/utils/__init__.pyÚ(_singleton_tenant_database_if_applicabler      s–   € ð& @ð ØˆzØ€FØ€HØÔ&€KØ"Ô,€NØð �{ cÒ)Ð)ØˆØð 3Ý  Ñ0Ô0ÐÝÐ!Ñ"Ô" aÒ'Ð'¨CÐ7IÐ,IÐ,IÝÐ.Ñ/Ô/°Ô2ˆHØ�8ÐÐó    NÚuser_provided_tenantÚuser_provided_databasec                 ó"  — t          | |¬¦  «        \  }}|r)|t          k    r|r||k    rt          d|› d|› d�¦  «        ‚|r)|t          k    r|r||k    rt          d|› d|› d�¦  «        ‚|r|t          k    r|r|}|r|t          k    r|r|}||fS )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!   *   sJ  € õ 	1Ø#Ø=qð	ñ 	ô 	ñØØð 	ðQà ¥NÒ2Ð2Øð 3àÐ.Ò.Ð.åð  PÐ(<ð  Pð  PÈjð  Pð  Pð  Pñ  Qô  Qð  	QàðYà"Õ&6Ò6Ð6Øð 7àÐ2Ò2Ð2åð  XÐ*@ð  Xð  XÐR^ð  Xð  Xð  Xñ  Yô  Yð  	Yð !ð*Ø$8½NÒ$JÐ$JØ
ð %Kà)Ðà"ð.Ø&<Õ@PÒ&PÐ&PØ
ð 'Qà!-ÐàÐ!7Ð7Ð7r   r   )Útypingr   r   Úchromadb.authr   Úchromadb.configr   r   Úchromadb.errorsr   ÚboolÚstrr   r!   © r   r   ú<module>r)      s  ðØ "Ð "Ð "Ð "Ð "Ð "Ð "Ð "à &Ð &Ð &Ð &Ð &Ð &Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø +Ð +Ð +Ð +Ð +Ð +ðØðà:>ðð ˆ8�CŒ=˜( 3œ-Ð'Ô(ðð ð ð ðJ +/Ø,0ð	,8ð ,8Øð,8à:>ð,8ð # 3œ-ð,8ð % SœMð	,8ð
 ˆ8�CŒ=˜( 3œ-Ð'Ô(ð,8ð ,8ð ,8ð ,8ð ,8ð ,8r   