
    t iDc              <       *   % S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  S SKJ
r
  S SKJr  S SKJr  S SKJr  S SKJr  S SKrS S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SK J!r!  S SK J"r"  S SK#J$r$  S SK#J%r%  S SK&J'r'  S SK&J(r(  S SK)J*r*  S SK)J+r+  S SK,J-r-  S SK.J/r/  S SK0J1r1  \Rd                  " \35      r4Sr5Sr6\7\8S'   S r9\7\8S!'   S r:\7\8S"'   S#\74S$ jr;S%\<S#S4S& jr=\1" \+5      S'\>S#\74S( j5       r?\1" \'5      S'\>S#\74S) j5       r@\1" \5      S'\S#\74S* j5       rASS+\\<   S#S4S, jjrB\R                  " S-S.S/S0S0S1S2/S3.S49rD\DR                  S0S.S59                SS6\R                  S7\	\G\R                  " S8S95      4   S:\	\\<   \R                  " S;S<S0S=94   S>\	\\<   \R                  " S?S@SAS0S=94   SB\	\\<   \R                  " SCS0S=94   SD\	\\G   \R                  " SES0S=94   SF\	\\G   \R                  " SGSHS0S=94   SI\	\\<   \R                  " SJS0S=94   SK\	\\<   \R                  " SLS0S=94   SM\	\\<   \R                  " SNSOS0S=94   SP\	\\<   \R                  " SQS0S=94   SR\	\\G   \R                  " SSSTS0S=94   SU\	\\G   \R                  " SVSWS0S=94   SX\	\\<   \R                  " SYSZS0S=94   S[\	\\G   \R                  " S\S]S0S=94   S^\	\\G   \R                  " S_S`SaS0S=94   Sb\	\\\<      \R                  " S0ScSd94   S#S4$Se jj5       rJSSf\\\G\<4      S#S4Sg jjrK\DR                  Sh5         SSi\	\G\R                  " 5       4   Sf\	\\G   \R                  " Sj5      4   S+\	\\<   \R                  " 5       4   S#S4Sk jj5       rM\DR                  SlSm9SS+\	\\<   \R                  " 5       4   S#S4Sn jj5       rN\DR                  SoSm9SS+\	\\<   \R                  " 5       4   S#S4Sp jj5       rO\DR                  SqSm9SS+\	\\<   \R                  " 5       4   S#S4Sr jj5       rP\R                  " SsS.StS0S0S1S2/S3.S49rQ\QR                  SuSm9SSv j5       rR\QR                  SwSm9   SSx\	\\<   \R                  " SySz94   S{\	\\G   \R                  " S|S}Sz94   S~\	\G\R                  " SSz94   S#S4S jj5       rS SSs\"S\\G   S\GS#S4S jjrT                         SS6\R                  S\	\\<   \R                  " SSz94   S:\	\\<   \R                  " SSz94   S\	\G\R                  " SSz94   S\	\\<   \R                  " S\-" 5        3Sz94   S\	\\<   \R                  " S0S=94   S\	\\<   \R                  " S0S=94   S\	\\<   \R                  " S0S=94   Sf\	\\G   \R                  " Sj5      4   S\	\\G   \R                  " S5      4   S\	\\<   \R                  " SSz94   S\	\\<   \R                  " S0S=94   S\	\\<   \R                  " S0S=94   S\	\\<   \R                  " S0S=94   S\	\\<   \R                  " S0S=94   S\	\\<   \R                  " S0S=94   S\	\\<   \R                  " S0S=94   S\	\\G   \R                  " S5      4   S\	\\G   \R                  " SS0S=94   S\	\\<   \R                  " SSz94   S\	\\<   \R                  " 5       4   S\	\\<   \R                  " 5       4   S\	\\G   \R                  " S5      4   S\	\\G   \R                  " S5      4   S\	\\G   \R                  " SSz94   S\	\\G   \R                  " SSSSz94   S#S46S jjrU\QR                  SS0S\-" 5        3S9" \U5      rV\QR                  SS0S\-" 5        3S9" \U5      rW\QR                  SXS0S9 SSx\	\<\R                  " SSz94   S\	\\G   \R                  " SSSSz94   S#S4S jj5       rXg)    N)dedent)	Annotated)Any)Dict)List)Optional)Union)	HTTPError)JSONDecodeError)Confirm)Syntax)Table)__version__)login)logout)
BaseClient)AnacondaAuthSite)AnacondaAuthSitesConfig)fetch_org_features)get_orgs_with_env_logger)TokenExpiredError)UnknownSiteName)	TokenInfo)TokenNotFoundError)anaconda_config_path)console)register_error_handleru   [bold green]✔︎[/bold green]   PROGRAM_ERROR   ARGUMENT_ERRORSUCCESSreturnc                  l   [         R                  R                  5       (       a  [        R                  " SSS/S9n U (       a  [        5         g[        R                  " [        S5      5        [        R                  " [        [        S5      SS S	95        [        R                  " S
[        5        35        g)Nz Continue with interactive login?yn)choicesa  
                To configure your credentials you can run
                  [green]anaconda login --at anaconda.com[/green]

                or set your API key using the [green]ANACONDA_AUTH_API_KEY[/green] env var

                or set
                zl                        [plugin.auth]
                        api_key = "<api-key>"
                        toml)background_colorzin r   )sysstdoutisattyr   askr   r   printr   r   r   )do_logins    1lib/python3.13/site-packages/anaconda_auth/cli.py_continue_with_loginr2   /   s    
zz;;ACQT:VGMM  	 MM %)	 MMC 4 6789    error_classifierc                 8    [         R                  " SU  S35        g )N[bold][red]z9[/red][/bold]: Login is required to complete this action.)r   r/   )r4   s    r1   _login_required_messager7   P   s    MM
&''`ar3   ec                 T    [        U R                  R                  5        [        5       $ N)r7   	__class____name__r2   r8   s    r1   login_requiredr>   V   s    AKK001!!r3   c                 r    [         R                  " SU R                  R                   S35        [	        5       $ )Nr6   z+[/red][/bold]: Your login token has expired)r   r/   r;   r<   r2   r=   s    r1   token_expiredr@   \   s1    MM
akk**++VW  !!r3   c                     U R                   R                  5       R                  S0 5      R                  SS5      nUS:X  aO  SU R                  R
                  ;   a   [        R                  " S5        [        5       $ [        S5        [        5       $ [        R                  " SU R                  R                   S	U  35        g
! [         a    Sn Nf = f)Nerrorcode auth_requiredAuthorizationz^[bold][red]InvalidAuthentication:[/red][/bold] Your provided API Key or login token is invalidAuthenticationMissingErrorr6   z:[/red][/bold] r   )responsejsongetr   requestheadersr   r/   r7   r2   r;   r<   )r8   
error_codes     r1   
http_errorrN   e   s    ZZ__&**7B7;;FBG
 _$aii///MMp
 $%% $$@A#%%AKK$8$8#9LM  
s   :C CCatc                 :    U (       a  U [         R                  S'   g g )NANACONDA_DEFAULT_SITE)osenvironrO   s    r1   _override_default_siterU   y   s    	.0

*+ 
r3   authFz#Manage your Anaconda authenticationTz--helpz-h)allow_extra_argsignore_unknown_optionshelp_option_names)nameadd_completionhelpcontext_settings)invoke_without_commandno_args_is_helpctxversionz-Vz	--versionrZ   z-nz--name)hiddenorganizationz-oz--orgz--organizationstrengthz
--strengthstrongz--strongweakz-wz--weakurlz--urlmax_agez	--max-agescopesz-sz--scopesoutz--outlist_scopesz-xz--list-scopeslist_tokensz-lz--listremovez-rz--removecreatez-cz--createinfoz-iz--infoz--current-info
extra_argsrD   )rb   metavarc                    U(       a5  [         R                  " S[         S3SS9  [        R                  " [
        S9eU=(       d    / nU(       a  US   nOS n[        U R                  S0 5      nUR                  U5      =n(       a  UR                  USS  US	U S
9  g [        S UUUUUUUU	U
UUUUU4 5       5      nU(       d  U(       aQ   SSKJ	n  [         R                  " S5        [        R                  " S[         5        U" ["        R$                  SS  S	S9  g [         R                  " U R'                  5       5        g ! [        [        4 a     g f = f)Nzanaconda-auth, version [cyan]z[/cyan]
bold green)stylerC   r   commandsr   F)	prog_namestandalone_modeparentc              3   *   #    U  H	  nUS Lv   M     g 7fr:    ).0values     r1   	<genexpr>main.<locals>.<genexpr>  s       
E 	T
s   )mainz[yellow]DeprecationWarning[/yellow]: Please use [cyan]anaconda org auth[/cyan] instead for explicit management of anaconda.org auth tokens
zZPlease use `anaconda org auth` instead for explicit management of anaconda.org auth tokens)allow_plugin_main)r   r/   r   typerExitr"   getattrcommandrJ   r   anybinstar_client.scripts.cliImportErrorModuleNotFoundErrorwarningswarnDeprecationWarningr+   argvget_help)r`   ra   rZ   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   subcommand_namesubcommands_dictcmdhas_legacy_optionsbinstar_mains                         r1   r   r      sh   p +K=@	
 jjg&& !rJ$Q- s{{J; ""?33s3qrNouUX 	 	
 	  
 ( _	G 	 [	
 	h	

 	SXXab\U; MM#,,.! 01 		s   E   EE
ssl_verifyc                 $   [         R                  " S5      nU(       d  gSSKJn  SSKJn  SSKJn  SSKJn  [        U S9nUc  g[        U5      nU(       d  gU" U5      (       d{  [        R                  " S	S
S9nU(       d  g[        R                  " S5        U" U5      u  pU	(       d  [        R                  " SU
 35        g[        R                  " [         S35        U" U5      (       a  gU" U5      (       d  [        R                  " S5        gg)zPost-login pipeline: fetch org features, check for environments,
install env-manager and register org if needed.

Skipped entirely when conda is not available on PATH.
condaNr   )install_env_manager)is_client_registered)is_env_manager_installed)register_orgr   zeAnaconda Environment Manager is required by your organization. It is recommended to install. Proceed?Tdefaultz"Installing anaconda-env-manager...zD[bold red]Error:[/bold red] Failed to install anaconda-env-manager.
z- anaconda-env-manager installed successfully.z
[bold yellow]Warning:[/bold yellow] Failed to register client token.
You can retry registration manually by running:
  [green]conda env-log register[/green])shutilwhich&anaconda_auth._conda.env_logger_configr   r   r   r   r   r   r   r.   r   r/   
CHECK_MARK)r   
conda_pathr   r   r   r   org_featuresenv_orgsinstallsuccessrB   s              r1   _post_login_setupr   H  s     g&JJKOC%<L'5H#J//++s
 :;,Z8MMWX]W^_ $QRS J'' 
##6	
 $r3   r   forcez--ssl-verify/--no-ssl-verifyc                 6   [        U5         [        R                  " 5       nUR                  nUR                  (       a;  [
        R                  " SU 35        [        SUS9  [        R                  " [        S9e U =(       d    [        R                  " SU S3SS9n U (       d  [        R                  " [        S9e [        XS9   [        US	9  g! [         a     N f = f! [         a-    [         R#                  S
SS9  [
        R                  " S5         gf = f)Loginz'Your API key has expired, logging into T)r   r   ru   z&You are already logged into Anaconda (z'). Would you like to force a new login?Fr   r   zPost-login setup failed)exc_infoz
[bold yellow]Warning:[/bold yellow] Post-login setup could not be completed.
You can configure environment management manually by running:
  [green]conda env-log register[/green]N)rU   r   loaddomainexpiredr   r/   r   r   r   r"   r   r.   r   r   	Exceptionloggerdebug)r   r   rO   
token_infor   s        r1   
auth_loginr   ~  s     2+^^%
""MMCF8LM4**'**   
4VH<cd
 **'**  
-
Z0    
.>6	

s$   A-C 	C! 
CC!4DDwhoamirZ   c                    [        U 5        [        5       nUR                  S5      nUR                  5         [        R
                  " SUR                  R                   S35        [        R                  " UR                  5       SSS9  g)z6Display information about the currently signed-in userz/api/accountzYour info (z):r    T)dataindent	sort_keysN)
rU   r   rJ   raise_for_statusr   r/   configr   
print_jsonrI   )rO   clientrH   s      r1   	auth_infor     se     2\Fzz.)HMMK 4 45R89HMMOAFr3   zapi-keyc                     [        U 5        [        R                  " 5       nUR                  (       d  [	        UR
                  5        g[        5       e)z"Display API Key for signed-in userN)rU   r   r   r   r/   api_keyr   )rO   r   s     r1   auth_keyr     s;     2!Jj  !!!r3   r   c                 .    [        U 5        [        5         g)LogoutN)rU   r   rT   s    r1   auth_logoutr     s     2
Hr3   sitesz'Manage your Anaconda site configurationlistc                  4   [        5       n [        SSSSS9nU R                  R                  5        H8  u  p#X R                  :X  a  [
        OSnUR                  X#R                  U5        M:     [        R                  " U5        [        R                  " S5        g)	z)List configured sites by name and domain.z	Site namezDomain namezDefault siters   )header_stylerD   z_[dim italic]To view full site details use[/] [dim bold]anaconda sites show \[name or domain][/]N)
r   r   r   itemsdefault_siter   add_rowr   r   r/   )sites_configtablerZ   site
is_defaults        r1   
sites_listr     sx     +,L+}n<XE"((..0
#'+D+D#DZ"
dKK4 1 MM%MMjr3   showr   zaChoose configured site name or domain name. If unspecified will show the configured default site.)r\   allz--allzShow all site configurationsshow_hiddenzShow hidden fieldsc                    1 SknU(       a  SOUnU(       ak  [        5       nUR                  R                  R                  5        Vs0 s H  nUR                  UR                  US9_M     nn[        R                  " US9  g[         R                  " U S9nUR                  US9nSUR                  0UEn[        R                  " US9  gs  snf )z[Show the site configuration for the default site or look up by the provided name or domain.>   r   keyring	client_idkeyring_pathredirect_urihash_hostnamelogin_error_pathlogin_success_pathopenid_config_pathenv_manager_channelenv_manager_packageenv_manager_versionauth_domain_overrideoidc_request_headerspreferred_token_storageN)exclude)r   )r   r   )	r   r   rootvaluesr   
model_dumpr   r   	load_site)	r   r   r   rb   r   r   r   	all_sitesr   s	            r1   
sites_showr     s    F$ "dvG
')  ++**113
3 KK**7*;;3 	 
 		*(22=   1,t,%
s   $C
yespreserve_existing_keysc                     USL a  U R                  US9  g USL a  U R                  SUS9  g U R                  SUS9  [        R                  " S5      (       a  U R                  US9  g g )NTr   F)dry_runr   zConfirm:)write_configr   r.   )r   r   r   s      r1   _confirm_writer     sr    
 d{2HI	4@VW4@VW;;z""6LM #r3   r   z0Domain name for site, defaults to 'anaconda.com'z1Name for site, defaults to domain if not suppliedr   zSet this site as defaultr   z4API key for site. CAUTION: this will get written to r   r   r   use_truststorez$--use-truststore/--no-use-truststoreextra_headersz4Extra headers in JSON format to use for all requestsr   r   r   r   r   r   use_unified_repo_api_keyz8--use-unified-repo-api-key/--no-use-unified-repo-api-keyr   z$--hash-host-name/--no-hash-host-nameproxy_serversz#JSON string of proxy server mappingclient_certclient_cert_keyuse_device_flowz&--use-device-flow/--no-use-device-flowdisable_conda_auto_configz:--disable-conda-auto-config/--no-disable-conda-auto-configremove_anaconda_comz/Remove the site named 'anaconda.com' if presentz--yes/--dry-runz-yzGConfirm changes and write, use --dry-run to print diff but do not writec                 	   0 nUc  U	c  OaU(       d  Uc  U	(       a  SUS'   OJUSL a5  U	(       a.  [         R                  " S5        [        R                  " [        S9eUSL a  SUS'   OSUS'   Ub  UUS'   Ub  UUS'   Ub)  S	[        5        S
3n[         R                  " U5        UUS'   U
b   [        R                  " U
5      nUUS'   Ub   [        R                  " U5      nUUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub@  S[        5        S
3n[         R                  " U5         [        R                  " U5      nUUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub   [        R                  " U5      nUUS'   Ub  UUS '   Ub  UUS!'   Ub  UUS"'   [        5       n U R                  R                  S#:X  Ga  Uc.  [         R                  " S$5        [        R                  " [        S9eUc  UnUU R                  ;   a2  [         R                  " S%U S&35        [        R                  " [        S9eU(       a1  S'U R                  R                  ;   a  U R                  R                  S'	 [        S,0 UD6n!U R!                  U!U!R"                  S(9  U(       d  [%        U R                  5      S):X  a  U!R"                  U l        OU R                  R                  S*:X  a  Uc1  Uc.  [         R                  " S+5        [        R                  " [        S9eU R                  R)                  U=(       d    U5      n"U R                  R                  U"   n!0 U!R+                  5       EUESU!R"                  0En#[        R,                  " U#5      n!U R!                  U!U!R"                  S(9  U(       a  U!R"                  U l        [/        U U5        g ! [        R                   a3    [         R                  " SU
 S35        [        R                  " [        S9ef = f! [        R                   a3    [         R                  " SU S35        [        R                  " [        S9ef = f! [        R                   a/    [         R                  " S5        [        R                  " [        S9ef = f! [        R                   a/    [         R                  " S5        [        R                  " [        S9ef = f)-N
truststorer   Fz4Cannot set both --use-truststore and --no-ssl-verifyru   Tr   r   zC[bold yellow]WARNING:[/bold yellow] Your API Key will be stored in z and may not be securer   r   zextra-headers=z could not be parsed as JSONr   zproxy-servers=r   r   r   r   r   r   r   zL[bold yellow]WARNING:[/bold yellow] Your Keyring contents will be stored in r   z0The keyring argument could not be parsed as JSONr   r   r   r   z=The oidc-request-headers argument could not be parsed as JSONr   r   r   addz5You must supply at least --domain to a add a new sitezA site with name z6 already exists, use the modify subcommand to alter itzanaconda.comr   r   modifyzCYou must supply at least one of --domain or --name to modify a siter{   )r   r/   r   r   r!   r   rI   loadsr   r   r   rZ   r   r   r   r   r   r   lenr   _find_atr   model_validater   )$r`   r   rZ   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   kwargsmsgparsed_extra_headersparsed_proxy_serversparsed_keyringparsed_headersr   r   keydumps$                                       r1   _sites_add_or_modifyr
     s   J  Fn4

*+|	u	LMjjn--	u	$|#|v!x..B.D-EE[] 	 	c#y 	2#'::m#< &:F?#  	2#'::m#< &:F?#  +}"$3 !"$3 !+-E)* ,.G*+*,C()')=%&77K7M6NNdf 	 	c	2!ZZ0N .F9 '{!-~%'9#$'	2!ZZ(<=N-;F)* %'9#$#%5!" "/#%E
{{5 >MMQR**.11<D5;;MM#D6)_` **-00>U[[5E5E#E  0!+F+		&v{{	+c%++&!+!'E			X	%>dlMMU **.11kk""4>62!!#&E&##%EEE!006		&v{{	+!'E5#I ## 	2MMN=/9UVW**.11	2 ## 	2MMN=/9UVW**.11	24 ## 	2MMLM**.11	2 ## 	2MMO **.11		2s4   +O 
P' Q1 <R7 AP$'AQ.1AR47AS:r   zAdd new site configuration to )rZ   r_   r\   r   zModify site configuration in )rZ   r_   z#Site name or domain name to remove.zFConfirm changes and write, use --dry-run to print diff but do no writec                    [        5       n[        UR                  5      S:X  a  U /[        UR                  5      :X  d9  U /UR                  R	                  5        Vs/ s H  o3R
                  PM     sn:X  a1  [        R                  " U  S35        [        R                  " [        S9e UR                  U    nUR                  U 5        UR                  UR                  :X  a#  [!        [#        UR                  5      5      Ul        [%        X!SS9  gs  snf ! [         a@  n[        R                  " UR                  S   5        [        R                  " [        S9eSnAff = f)z,Remove site configuration by name or domain.r   z2 is the only configured site and cannot be removedru   r   NFr   )r   r   r   r   r   r   r   r/   r   r   r   r   argsrm   r   r   nextiterr   )r   r   r   sr   r8   s         r1   sites_remover    s    $%E 	EKKAVtEKK((F););)=>)=Axx)=>>PQRjjm,,-T"
 
LLV[[(!$u{{"345e< ?  -affQi jjm,,-s   D)D 
E  ;EE r:   )FNNNNNNNNNNNNNNN)FNN)r#   N)NFF)T)NNFNNNNNNNNNNNNNNNNNNNNTN)YrI   loggingrR   r   r+   r   textwrapr   typingr   r   r   r   r   r	   r   requests.exceptionsr
   r   rich.promptr   rich.syntaxr   
rich.tabler   anaconda_authr   anaconda_auth.actionsr   r   anaconda_auth.clientr   anaconda_auth.configr   r   anaconda_auth.env_loggerr   r   anaconda_auth.exceptionsr   r   anaconda_auth.tokenr   r   anaconda_cli_base.configr   anaconda_cli_base.consoler   anaconda_cli_base.exceptionsr   	getLoggerr<   r   r   r   int__annotations__r!   r"   r2   strr7   r   r>   r@   rN   rU   TyperappcallbackContextboolOptionArgumentr   r   r   r   r   r   r   	sites_appr   r   r   r
  	sites_addsites_modifyr  r{   r3   r1   <module>r0     s     	  
          ) /    % ' ( + 1 8 7 = 6 4 ) 2 9 - ?			8	$.
s   c Bc d  *+"i "C " ,"
 )*"Y "3 " +" 	")   #&1x} 1 1
 kk		. "&&-		    AF 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	ew"	w"tU\\$<<=w" 	
	w" 		
	w"( 	
	)w"6 	
	7w"D 	
	Ew"T 
	
	
Uw"b 	
	cw"p 	
	qw"@ 
	
	
Aw"N 	
	Ow"^ 	
	_w"n 	
	ow"~ 	
	w"N 		
	Ow"` cU^^4DDaw"f 
gw"	w"t3
(5s+;"< 3
 3
l W-2 	37#
T5<<>)*#
%CDD#

 	(3-/0#
 
#
 #
L (G)HSM5<<>9: Gd G G )"8C=%,,.89 "T " " (IhsmU\\^;<    KK		2 "&&-			      	 	LQ-&
t	
	-& 
W3QRR
-& 43G!HHI-& 
-&  -&f $(N"N	$N !N 
	N( 	 	NS 	SWPTCG 	 	 	EIHLNRPTNRLP 	 	 	<@@D 	 	 	 	GF	FLM	OF MN	PF tU\\/IJJKF GH\H^G_`	
	F" 'x}ell$6O'OP#F$ $HSM5<<t3L$LM%F& x}ell$&??@'F( %CDD)F. %KLL/F4 PQ	S5F< #D(AAB=F> HSM5<<t+DDE?F@ "(3-T1J"JKAFB $HSM5<<t3L$LMCFD "(3-T1J"JKEFF  u||4/H HIGFH (OP	RIFP ;DI	KQFX u||)NOOYF^ 8C=%,,.89_F` x}elln<=aFb %MNNcFh  )QR	T iFp #KL	NqFx 
Z	
	
yFH 
IFR 	)*>*@)A	B   		   	()=)?(@	A !  	 $7 	 =
C-RSS
T =	Y	
	
 = 
 = 8 =r3   