Ë
    Z²jw±  ã                   ó®
  — U d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZ ddlZddlZddlmZmZ ddl m!Z!m"Z"m#Z# dd	l$m%Z% dd
l&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3  e*jh                  «       Z5dZ6dZ7erddl8m9Z9 dˆde:dz  ddfd„Z;dZ<dˆde=e:   de:dz  de:fd„Z>ed   e:z  Z?ee=e:   e@e:   geAdz  f   ZB ede:¬«      ZCde:dz  dejˆ                  dejŠ                  ddfd „ZF ejŽ                  d!«      ZH G d"„ d#e«      ZIg d$¢ZJe=eKe:e:f      eLd%<   dejŠ                  ddfd&„ZMd'ejœ                  deOfd(„ZPd'ejœ                  d)e=e:   ddfd*„ZQd)e=e:   deOfd+„ZRd)e=e:   d,eOd-eOddfd.„ZSd/e:dd0fd1„ZTd2ejª                  d3e:d4e=eKe:e:f      ddfd5„ZV	 dˆd6eBd7eg e=eKe:e:f      f   dz  deWeI   fd8„ZXdˆd9e?de=e:   dz  deWe   fd:„ZY G d;„ d<ej´                  «      Z[d‰d=e:de:dz  d>eWe   dz  dd<fd?„Z\ G d@„ dAe:e«      Z]ee: ej¼                  dB¬C«      f   Z_ee] ejÀ                  dDdEdF¬C«      f   Zaee:dz   ejÀ                  dG¬C«      f   ZbeeOdz   ejÀ                  dH¬C«      f   Zcee:dz   ejÀ                  dI¬C«      f   ZdeeA ejÀ                  dJ¬C«      f   Zeee:dz   ejÀ                  dK¬C«      f   Zfee=e:   dz   ejÀ                  dL¬C«      f   Zgee:dz   ejÀ                  dM¬C«      f   Zhee=e:   dz   ejÀ                  dNdOdP¬C«      f   Ziee=e:   dz   ejÀ                  dQdRdS¬C«      f   Zjee:dz   ejÀ                  dTdU¬C«      f   Zkee:dz   ejÀ                  dV¬C«      f   Zldeme:e:f   fdW„Zn	 	 d‰dXe=e:   dz  dYe:dz  deme:e:dz  f   fdZ„Zod[eme:e:dz  f   de=eme:e:f      dz  fd\„Zpee=e:   dz   ejÀ                  d]d^d_¬C«      f   Zqd`e=e:   dz  ddafdb„Zr G dc„ dde:e«      Zsees ejÀ                  de¬C«      f   Ztd/e2de2fdf„Zuee2 ejÀ                  dgeu¬h«      f   ZveeO ejÀ                  didjdk¬C«      f   Zwdle:de:fdm„Zxd/ede:fdn„Zye6fd/edoeAde:fdp„Zz	 dˆd4eeme:ef      dqe=e:   dreeme:ef   ge=e:   f   dseme:e:f   dz  ddf
dt„Z{	 	 	 	 dŠd4eeme:ef      duesdveOdwe:dqe=e:   dz  dreeme:ef   ge=e:   f   dz  dseme:e:f   dz  ddfdx„Z|dye}de}fdz„Z~d{edeme:ef   fd|„Zd}eeC   fd~„Z€ded€   ddfd�„Z�ded€   ddfd‚„Z‚de:de:dz  fdƒ„Zƒde:dz  fd„„Z„deAfd…„Z…de=e:   dz  fd†„Z†de=e:   dz  fd‡„Z‡y)‹z*Contains CLI utilities (styling, helpers).é    N)ÚCallableÚSequence)ÚEnum)ÚPath)ÚTYPE_CHECKINGÚ	AnnotatedÚAnyÚLiteralÚTypeVarÚUnionÚcast)ÚTyperCommandÚ
TyperGroup)ÚVolumeÚ__version__Ú	constants)ÚCLIError)Úget_sessionÚhf_raise_for_statusÚinstallation_methodÚloggingÚparse_hf_mountÚtabulate)Úload_dotenvé   )ÚStyledContext)ÚOutputFormatWithAutoÚouté#   é   ©ÚHfApiÚtokenÚreturnr"   c                 ó,   — ddl m}  || dt        ¬«      S )Nr   r!   zhuggingface-cli)r#   Úlibrary_nameÚlibrary_version)Úhuggingface_hub.hf_apir"   r   )r#   r"   s     ú]/var/www/html/ia-enhanced/venv/lib/python3.12/site-packages/huggingface_hub/cli/_cli_utils.pyÚ
get_hf_apir*   ?   s   € å,á�uÐ+<ÌkÔZÐZó    z9https://huggingface.co/docs/huggingface_hub/en/guides/cliÚexamplesÚdocs_anchorc                 óh   — |r
t         › |› �nt         }dj                  d„ | D «       «      }d|› d|› d�S )a  Generate an epilog with examples and a Learn More section.

    Args:
        examples: List of example commands (without the `$ ` prefix).
        docs_anchor: Optional anchor for the docs URL (e.g., "#hf-download").

    Returns:
        Formatted epilog string.
    ú
c              3   ó&   K  — | ]	  }d |› �–— Œ y­w)z  $ N© )Ú.0Úexs     r)   ú	<genexpr>z"generate_epilog.<locals>.<genexpr>V   s   è ø€ Ò<¨R˜t B 4œ[Ñ<ùs   ‚z	Examples
zk

Learn more
  Use `hf <command> --help` for more information about a command.
  Read the documentation at )ÚCLI_REFERENCE_URLÚjoin)r,   r-   Údocs_urlÚexamples_strs       r)   Úgenerate_epilogr9   K   sS   € ñ 7BÔ#Ð$ [ MÑ2ÔGX€HØ—9‘9Ñ<°8Ô<Ó<€Lðà€ð ð &˜Jð 'ðð r+   )ÚmainÚhelpÚExpandPropertyT)ÚboundÚepilogÚctxÚ	formatterc                 óx   — | r8|j                  «        | j                  d«      D ]  }|j                  |«       Œ yy)z%Write the epilog without indentation.r/   N)Úwrite_paragraphÚsplitÚ
write_text)r>   r?   r@   Úlines       r)   Ú_format_epilog_no_indentrF   f   s<   € áØ×!Ñ!Ô#Ø—L‘L Ó&ò 	'ˆDØ× Ñ  Õ&ñ	'ð r+   z\s*\|\s*c                   ó²  ‡ — e Zd ZdZeZdej                  ddfˆ fd„Zdej                  de	e
   defˆ fd„Zedej                  de	e
   ddfd	„«       Zdej                  d
e
dej                  dz  fˆ fd„Zdee
e	e
   f   fd„Zdej                  dej&                  ddfd„Zdej                  dej&                  ddfd„Zdej                  de	e
   fd„Zˆ xZS )ÚHFCliTyperGroupaÉ  
    Typer Group that:
    - lists commands alphabetically within sections.
    - separates commands by topic (main, help, etc.).
    - formats epilog without extra indentation.
    - supports aliases via pipe-separated names (e.g. ``name="list | ls"``).
    - consumes the global formatting flags (``--format``, ``--json``, ``-q`` / ``--quiet``, ``--no-truncate``)
      anywhere in the args of a leaf command and applies them to ``out``, so leaf
      commands don't need to declare these options themselves.
    - rewrites ``spaces/user/repo`` to ``user/repo --type space`` for commands that accept ``--type``.
    - enriches "No such option" / "No such command" errors with available options or commands.
    r?   r$   Nc                 óò  •— 	 t         ‰	| �  |«      S # t        j                  $ �rP}|j                  ��=|j                  j
                  ��&|j                  j
                  }t        |t        j                  «      rx|j                  |j                  «      D �cg c]@  }|j                  |j                  |«      x}� |j                  s||j                  d¬«      f‘ŒB nc c}w }}t        |d|«       ‚ |j                  |j                  «      D �cg c]G  }t        |t        j                  «      r+|j                  s|j                  |j                  «      x}r|‘ŒI nc c}w }}t        |d|«       ‚ d}~ww xY w)at  Enrich unknown-option errors with available options or subcommands.

        Catches `NoSuchOption` raised during subcommand `make_context()`
        (option parsing).  For leaf commands (e.g. `hf repos create --test`)
        we list the command's options; for groups (e.g. `hf cache --test`)
        we list subcommands since groups have no user-facing options.
        NéP   ©ÚlimitÚcommandsÚoptions)ÚsuperÚinvokeÚclickÚNoSuchOptionr?   ÚcommandÚ
isinstanceÚGroupÚlist_commandsÚget_commandÚhiddenÚget_short_help_strÚ_enrich_usage_errorÚ
get_paramsÚOptionÚget_help_record)
Úselfr?   ÚeÚcmdÚnameÚsubÚitemsÚpÚrecordÚ	__class__s
            €r)   rP   zHFCliTyperGroup.invoke�   sN  ø€ ð	Ü‘7‘> #Ó&Ð&øÜ×!Ñ!ó 	Ø�u‰uÑ  Q§U¡U§]¡]Ñ%>Ø—e‘e—m‘m�Ü˜c¤5§;¡;Ô/ð %(×$5Ñ$5°a·e±eÓ$<öà Ø#&§?¡?°1·5±5¸$Ó#?Ð?˜CÐLÐUX×U_ÒU_ð ˜s×5Ñ5¸BÐ5Ó?Ò@ñùò �Eð ô
 (¨¨:°uÔ=ð ð	 "%§¡°·±Ó!6öàÜ% a¬¯©Ô6¸q¿xºxÐWX×WhÑWhÐij×inÑinÓWoÐMoÈVÐMoò ñùò �Eð ô
 (¨¨9°eÔ<Øûð'	ús/   ƒ ’E6¦A1E1ÂACÃ3E1ÄAEÅE1Å1E6Úargsc           	      ó†  •— |r|d   j                  d«      s|d   nd }|r| j                  ||«      nd }|�| j                  ||«       	 t        ‰| �  ||«      \  }}}|�&t)        |t
        j*                  «      st-        ||«       |||fS # t
        j                  $ �r!}|�€|��| j                  j                  «       D �	�
�cg c]-  \  }	}
|
j                  st        j                  |	«      D ]  }|‘Œ Œ/ nc c}}
}	w }}
}	}t        j                  ||«      }|r>dj                  d„ |D «       «      }|j                  j!                  d«      › d|› d�|_        | j#                  |«      D �cg c]6  }| j                  ||«      x}� |j                  s||j%                  d¬	«      f‘Œ8 nc c}w }}t'        |d
|«       ‚ d }~ww xY w)Nr   ú-ú, c              3   ó(   K  — | ]
  }d |› d �–— Œ y­w)ú'Nr1   ©r2   Úms     r)   r4   z2HFCliTyperGroup.resolve_command.<locals>.<genexpr>µ   s   è ø€ Ò+F¸¨a°¨s°!¬HÑ+Fùs   ‚ú.z. Did you mean ú?rJ   rK   rM   )Ú
startswithrW   Ú_rewrite_repo_type_prefixrO   Úresolve_commandrQ   Ú
UsageErrorrM   rc   rX   Ú_ALIAS_SPLITrC   ÚdifflibÚget_close_matchesr6   ÚmessageÚrstriprV   rY   rZ   rT   rU   Ú_consume_format_flags_for_leaf)r^   r?   rg   Úcmd_namer`   ra   Úresolved_cmdÚsub_argsr_   ÚkeyÚ
registeredÚaliasÚvisible_namesÚmatchesÚsuggestionsrb   rc   rf   s                    €r)   rs   zHFCliTyperGroup.resolve_command    sÞ  ø€ Ù"¨4°©7×+=Ñ+=¸cÔ+B�4˜’7ÈˆÙ19ˆd×Ñ˜s HÔ-¸tˆàˆ?Ø×*Ñ*¨3°Ô5ð	Ü+0©7Ñ+BÀ3ÈÓ+MÑ(ˆD�, ð4 Ð#¬J°|ÄUÇ[Á[Ô,QÜ*¨<¸ÔBà�\ 8Ð+Ð+øô9 ×Ñó 	à‰{˜xÑ3ð ,0¯=©=×+>Ñ+>Ó+@÷!ð !á'˜˜ZØ%×,Ò,Ü!-×!3Ñ!3°CÓ!8ò	!ð ò ð!Øñ!ùô !�ò !ô "×3Ñ3°H¸mÓL�ÙØ"&§)¡)Ñ+F¸gÔ+FÓ"F�KØ#$§9¡9×#3Ñ#3°CÓ#8Ð"9¸ÈÈÐUVÐ W�A”Ið !%× 2Ñ 2°3Ó 7öàØ#×/Ñ/°°TÓ:Ð:˜ÐGÐPS×PZÒPZð ˜3×1Ñ1¸Ð1Ó;Ò<ñùò �ð ô
 $ A z°5Ô9Øûð)	ús1   Á
B ÂG Â$F;Ã2C6
Ã5A5F;Å*;F&Æ%F;Æ;G r`   c                 ó¸  — t        d„ | j                  D «       «      }|syt        «       }d}| j                  D ]A  }t        |t        j
                  «      sŒ|j                  dv r|j                  |«       |dz  }ŒC |syt        «       }| j                  D ][  }t        |t        j                  «      sŒ|j                  rŒ+g |j                  ¢|j                  ¢­D ]  }|j                  |«       Œ Œ] d}g }	d}
|
t        |«      k  r^||
   }|dk(  rnS|j                  d«      rd|v s||vr|
dz  }
n%|
d	z  }
n||v r|	j                  |
«       |dz  }|
dz  }
|
t        |«      k  rŒ^|	syd}d}g }|	D ]˜  }||   j                  d
d	«      }t        |«      dk7  s|d   t         j"                  vrŒ<|d   }t         j"                  |   }|�!||k7  rt	        j$                  d|› d|› d�«      ‚|}|}|j                  ||d   › d
|d	   › �f«       Œš |syt        d„ |D «       «      rt	        j$                  d|› d�«      ‚|D ]
  \  }}|||<   Œ |j'                  d|g«       y)u„  Rewrite prefixed repo IDs (e.g. ``spaces/user/repo``) to ``user/repo --type space``.

        Only applies to commands that have a ``--type`` / ``--repo-type`` option and
        at least one repo-ID positional argument (any ``click.Argument`` whose name
        ends with ``_id``, e.g. ``repo_id``, ``from_id``, ``to_id``).  When the
        token that maps to such an argument matches ``{prefix}/org/repo`` (where
        *prefix* is one of ``spaces``, ``datasets``, or ``models``), the prefix is
        stripped and an implicit ``--type {type}`` is appended.  An error is raised
        if ``--type`` is also provided explicitly or if multiple prefixed arguments
        disagree on the repo type.

        Only repo-ID positional slots are inspected so that other positional
        arguments (filenames, local paths, patterns â€¦) are never misinterpreted as
        prefixed repo IDs.
        c              3   óp   K  — | ].  }t        |t        j                  «      xr d |j                  v –— Œ0 y­w)ú--typeN)rT   rQ   r\   Úopts)r2   Úparams     r)   r4   z<HFCliTyperGroup._rewrite_repo_type_prefix.<locals>.<genexpr>Ø   s-   è ø€ ÒqÐ]bœj¨´·±Ó=ÒXÀ(ÈeÏjÉjÐBXÓXÑqùs   ‚46Nr   )Úrepo_idÚfrom_idÚto_idr   ú--ri   ú=é   ú/é   z!Conflicting repo type prefixes: 'z/' and 'z/'.c              3   ó€   K  — | ]6  }|d k(  xs+ |j                  d«      xs |dk(  xs |j                  d«      –— Œ8 y­w)r†   z--type=ú--repo-typez--repo-type=N©rq   ©r2   Úargs     r)   r4   z<HFCliTyperGroup._rewrite_repo_type_prefix.<locals>.<genexpr>  sI   è ø€ ò 
àð �8‰OÒr˜sŸ~™~¨iÓ8Òr¸CÀ=Ñ<PÒrÐTW×TbÑTbÐcqÓTrÓrñ
ùs   ‚<>z!Ambiguous repo type: got prefix 'z8/' in repo ID and explicit --type. Use one or the other.r†   )ÚanyÚparamsÚsetrT   rQ   ÚArgumentra   Úaddr\   Úis_flagr‡   Úsecondary_optsÚlenrq   ÚappendrC   r   ÚREPO_TYPES_MAPPINGrt   Úextend)r`   rg   Úhas_type_optionÚrepo_id_positionsÚarg_idxrˆ   Úvalue_optionsÚoptÚpositional_countÚrepo_id_arg_indicesÚir•   Úinferred_typeÚfirst_prefixÚrewritesÚ	arg_indexÚpartsÚprefixÚmapped_typeÚ	new_values                       r)   rr   z)HFCliTyperGroup._rewrite_repo_type_prefixÇ   s¼  € ô" ÑqÐfi×fpÑfpÔqÓqˆÙØô '*£eÐØˆØ—Z‘Zò 	ˆEÜ˜%¤§¡Õ0Ø—:‘:Ð!@Ñ@Ø%×)Ñ)¨'Ô2Ø˜1‘‘ð		ñ !Øô #&£%ˆØ—Z‘Zò 	+ˆEÜ˜%¤§¡Õ.°u·}³}Ø?˜UŸZ™ZÐ?¨%×*>Ñ*>Ñ?ò +�CØ!×%Ñ% cÕ*ñ+ð	+ð ÐØ)+ÐØˆØ”#�d“)ŠmØ�q‘'ˆCØ�dŠ{ØØ�~‰~˜cÔ"Ø˜#‘: ¨MÑ!9Ø˜‘F‘Aà˜‘F‘Aà#Ð'8Ñ8Ø'×.Ñ.¨qÔ1Ø  AÑ%Ð Ø�Q‘�ð ”#�d“)‹mñ #Øð %)ˆØ#'ˆØ*,ˆà,ò 
	CˆIØ˜‘O×)Ñ)¨#¨qÓ1ˆEÜ�5‹z˜QŠ %¨¡(´)×2NÑ2NÑ"NØØ˜1‘XˆFÜ#×6Ñ6°vÑ>ˆKØÐ(¨[¸MÒ-IÜ×&Ñ&Ð)JÈ<È.ÐX`ÐagÐ`hÐhkÐ'lÓmÐmØ'ˆMØ!ˆLØ�O‰O˜Y¨5°©8¨*°A°e¸A±h°ZÐ(@ÐAÕBð
	Cñ Øô ñ 
àô
ô 
ô ×"Ñ"Ø3°L°>ÐAyÐzóð ð
 %-ò 	(Ñ ˆI�yØ'ˆD�ŠOð	(à�‰�X˜}Ð-Õ.r+   r{   c                 ó¬   •— t         ‰| �  ||«      }|�|S | j                  j                  «       D ]"  \  }}t        j                  |«      }||v sŒ |c S  y ©N)rO   rW   rM   rc   ru   rC   )r^   r?   r{   r`   Úregistered_nameÚregistered_cmdÚaliasesrf   s          €r)   rW   zHFCliTyperGroup.get_command(  sd   ø€ ä‰gÑ! # xÓ0ˆØˆ?ØˆJð 04¯}©}×/BÑ/BÓ/Dò 	&Ñ+ˆO˜^Ü"×(Ñ(¨Ó9ˆGØ˜7Ò"Ø%Ò%ð	&ð r+   c                 óp   — i }| j                   D ]$  }t        j                  |«      }|d   }|dd ||<   Œ& |S )zBBuild a mapping from primary command name to its aliases (if any).r   r   N)rM   ru   rC   )r^   Úresultr³   r­   Úprimarys        r)   Ú
_alias_mapzHFCliTyperGroup._alias_map5  sI   € à')ˆØ#Ÿ}™}ò 	(ˆOÜ ×&Ñ& Ó7ˆEØ˜A‘hˆGØ# A B˜iˆF�7ŠOð	(ð ˆr+   r@   c                 óÖ  — i }| j                  «       }| j                  |«      D ]š  }| j                  ||«      }|�|j                  rŒ$|j	                  |j
                  ¬«      }|j                  |g «      }|r|› ddj                  |«      › d�}t        |dd«      }	|j                  |	g «      j                  ||f«       Œœ |j                  d«      5  |j                  |d   «       d d d «       t        |j                  «       «      D ]G  }	|	dk(  rŒ	|j                  |	j                  «       › d�«      5  |j                  ||	   «       d d d «       ŒI y # 1 sw Y   ŒmxY w# 1 sw Y   Œ`xY w)	NrK   z	 [alias: rj   ú]Útopicr:   zMain commandsz	 commands)r¹   rV   rW   rX   rY   ÚwidthÚgetr6   ÚgetattrÚ
setdefaultrž   ÚsectionÚwrite_dlÚsortedÚkeysÚ
capitalize)
r^   r?   r@   ÚtopicsÚ	alias_mapra   r`   Ú	help_textrµ   r¼   s
             r)   Úformat_commandszHFCliTyperGroup.format_commands>  si  € Ø"$ˆØ—O‘OÓ%ˆ	à×&Ñ& sÓ+ò 		CˆDØ×"Ñ" 3¨Ó-ˆCØˆ{˜cŸjšjØØ×.Ñ.°Y·_±_Ð.ÓEˆIØ—m‘m D¨"Ó-ˆGÙØ(˜k¨°4·9±9¸WÓ3EÐ2FÀaÐH�	Ü˜C ¨&Ó1ˆEØ×Ñ˜e RÓ(×/Ñ/°°yÐ0AÕBð		Cð ×Ñ˜Ó/ñ 	/Ø×Ñ˜v f™~Ô.÷	/ä˜FŸK™K›MÓ*ò 	2ˆEØ˜ŠØØ×"Ñ" e×&6Ñ&6Ó&8Ð%9¸Ð#CÓDñ 2Ø×"Ñ" 6¨%¡=Ô1÷2ð 2ñ	2÷	/ð 	/ú÷
2ð 2ús   ÃEÄ3EÅEÅE(	c                 ó<  — g }| j                  |«      D ]G  }| j                  ||«      }|�|j                  rŒ$t        |dg «      }|sŒ4|j	                  |d   «       ŒI |rt        |«      }t        |||«       y | j                  rt        | j                  ||«       y y )Nr,   r   )rV   rW   rX   r¿   rž   r9   rF   r>   )r^   r?   r@   Úall_examplesra   r`   Úcmd_examplesr>   s           r)   Úformat_epilogzHFCliTyperGroup.format_epilogU  s�   € ð #%ˆØ×&Ñ& sÓ+ò 	5ˆDØ×"Ñ" 3¨Ó-ˆCØˆ{˜cŸjšjØÜ" 3¨
°BÓ7ˆLÚØ×#Ñ# L°¡OÕ4ð	5ñ Ü$ \Ó2ˆFÜ$ V¨S°)Õ<Ø�[Š[Ü$ T§[¡[°#°yÕAð r+   c                 ó�   — g }| j                   D ]+  }t        j                  |«      d   }|j                  |«       Œ- t	        |«      S )Nr   )rM   ru   rC   rž   rÃ   )r^   r?   Úprimary_namesra   r¸   s        r)   rV   zHFCliTyperGroup.list_commandsg  sJ   € à#%ˆØ—M‘Mò 	*ˆDÜ"×(Ñ(¨Ó.¨qÑ1ˆGØ× Ñ  Õ)ð	*ô �mÓ$Ð$r+   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úcontext_classrQ   ÚContextrP   ÚlistÚstrÚtuplers   ÚstaticmethodÚCommandrr   rW   Údictr¹   ÚHelpFormatterrÉ   rÍ   rV   Ú__classcell__©rf   s   @r)   rH   rH   q   s*  ø„ ñð "€Mð˜%Ÿ-™-ð ¨Dõ ð>%, 5§=¡=ð %,¸¸S¹	ð %,Àeõ %,ðN ð^/ u§}¡}ð ^/¸DÀ¹Ið ^/È$ò ^/ó ð^/ð@˜uŸ}™}ð ¸ð ÀÇÁÐPTÑ@Tõ ð˜D  d¨3¡i Ñ0ó ð2 5§=¡=ð 2¸U×=PÑ=Pð 2ÐUYó 2ð.B §¡ð B¸5×;NÑ;Nð BÐSWó Bð$% §¡ð %°4¸±9÷ %r+   rH   ))z&--format [auto|human|agent|json|quiet]zWOutput format. Defaults to 'auto' which picks 'agent' or 'human' based on the terminal.)ú--jsonz+JSON output. Equivalent to '--format json'.)z-q, --quietz?Quiet output (one ID per line). Equivalent to '--format quiet'.)ú--no-truncatezQDo not truncate scalar values in human tables (list/dict columns stay shortened).Ú _FORMATTING_OPTIONS_HELP_RECORDSc                 óz   — | j                  d«      5  | j                  t        «       d d d «       y # 1 sw Y   y xY w)NzFormatting options)rÁ   rÂ   rá   )r@   s    r)   Ú"_format_formatting_options_sectionrã   {  s5   € Ø	×	Ñ	Ð/Ó	0ñ =Ø×ÑÔ;Ô<÷=÷ =ñ =ús   ’1±:r`   c                 ó¶   — | j                   D ]J  }t        |t        j                  «      sŒg |j                  ¢|j
                  ¢­}d|v sd|v s	d|v sd|v sŒJ y y)a  Return True if the command defines its own --format, --json or --quiet / -q.

    Used to skip the global formatting flag pre-processor and the duplicated "Formatting options" help section for
    legacy commands like 'hf jobs ps' that have their own format/quiet options.
    ú--formatrß   ú--quietú-qTF)r—   rT   rQ   r\   r‡   rœ   )r`   rˆ   r‡   s      r)   Ú_has_local_formatting_optionrè   €  sf   € ð —‘ò ˆÜ˜%¤§¡Ô.ØØ3�—‘Ð3˜e×2Ñ2Ñ3ˆØ˜Ñ ¨TÑ!1°YÀ$Ñ5FÈ$ÐRVÊ,Ùðð r+   rg   c                 óæ  ‡— | j                   j                  d«      ryt        |«      }t        j                  |«       d}d}d}| j
                  D ]O  }t        |t        j                  «      sŒg |j                  ¢|j                  ¢­}d|v rd}d|v sd|v rd}d|v sŒNd}ŒQ |rt        || | ¬	«       yt        j                  }dŠd
t        ddfˆfd„}	d}
|
t        |«      k  rø||
   }|dk(  rní|dk(  rJ |	d«       |
dz   t        |«      k\  rt        j                   d«      ‚t#        ||
dz      «      }dŠ||
|
dz   …= Œh|j%                  d«      r* |	d«       t#        |t        d«      d «      }dŠ||
|
dz   …= Œ£|dk(  r# |	d«       t        j&                  }dŠ||
|
dz   …= ŒË|dv r# |	|«       t        j(                  }|Š||
|
dz   …= Œò|
dz  }
|
t        |«      k  rŒøt        j*                  |«       y)uJ  Apply global formatting flags from 'args' to a leaf command.

    Two modes, depending on the command:

    * **Pass-through commands** (ignore_unknown_options=True, e.g. 'hf extensions exec'):
      args are forwarded verbatim to an external binary; we don't touch them.

    * **Legacy commands with a local --format option** (e.g. 'hf jobs ps' whose '--format' accepts Go templates):
      the global flags are rewritten in-place to the legacy form ('--json' â†’ '--format json', '--quiet'/'-q' â†’ '--format quiet'
      when the cmd has no own '--quiet') so click can parse them locally. This preserves backwards compatibility with the previous shorthand behavior.

    * **Modern commands** (no local format/quiet/json options): the flags '--format <value>' / '--json' / '--quiet' / '-q' are stripped from 'args' and applied to the singleton 'out'.

    '--no-truncate' is stripped for all non-pass-through commands; when present, human table cells are not truncated.

    Raises click.UsageError if multiple conflicting flags are supplied (e.g. '--json' together with '--format table').
    Úignore_unknown_optionsNFrå   Træ   rç   rß   )Úrewrite_jsonÚrewrite_quietÚnew_flagr$   c                 óB   •— ‰�t        j                  d‰› d| › d�«      ‚y )Nrl   z' and 'z' are mutually exclusive.)rQ   rt   )rí   Úchosen_flags    €r)   Ú_check_conflictz7_consume_format_flags_for_leaf.<locals>._check_conflict½  s1   ø€ ð Ð"Ü×"Ñ" Q { m°7¸8¸*ÐD]Ð#^Ó_Ð_ð #r+   r   rŒ   r   z#Option '--format' requires a value.rŽ   ú	--format=)rç   ræ   )Úcontext_settingsr¾   Ú_consume_no_truncate_flagsr   Úset_no_truncater—   rT   rQ   r\   r‡   rœ   Ú_rewrite_legacy_shorthandsr   Úautor×   r�   rt   Ú_parse_format_valuerq   ÚjsonÚquietÚset_mode)r`   rg   Úno_truncateÚhas_local_formatÚhas_local_quietÚhas_local_jsonrˆ   r‡   Úchosen_moderð   r¨   r•   rï   s               @r)   rz   rz   �  s>  ø€ ð$ ×Ñ×ÑÐ 8Ô9Øä,¨TÓ2€KÜ×Ñ˜Ô$àÐØ€OØ€NØ—‘ò 	"ˆÜ˜%¤§¡Ô.ØØ3�—‘Ð3˜e×2Ñ2Ñ3ˆØ˜ÑØ#ÐØ˜Ñ ¨¡Ø"ˆOØ�tÒØ!‰Nð	"ñ Ü" 4¸.Ð6HÐ\kÐXkÕlØô )=×(AÑ(A€KØ"€Kð`¤#ð `¨$õ `ð 	
€AØ
Œc�$‹iŠ-Ø�1‰gˆØ�$Š;ØØ�*ÒÙ˜JÔ'Ø�1‰uœ˜D›	Ò!Ü×&Ñ&Ð'LÓMÐMÜ-¨d°1°q±5©kÓ:ˆKØ$ˆKØ�Q˜˜Q™�Y�ØØ�>‰>˜+Ô&Ù˜JÔ'Ü-¨c´#°kÓ2BÐ2DÐ.EÓFˆKØ$ˆKØ�Q˜˜Q™�Y�ØØ�(Š?Ù˜HÔ%Ü.×3Ñ3ˆKØ"ˆKØ�Q˜˜Q™�Y�ØØÐ#Ñ#Ù˜CÔ Ü.×4Ñ4ˆKØˆKØ�Q˜˜Q™�Y�ØØ	ˆQ‰ˆð= Œc�$‹i‹-ô@ ‡L�L�Õr+   c                 óØ   — d}d}|t        | «      k  rW| |   }|dk(  r	 |S |dk(  rd}| ||dz   …= Œ+|j                  d«      rt        j                  d«      ‚|dz  }|t        | «      k  rŒW|S )	zSStrip all global --no-truncate flags from args and return whether any was provided.Fr   rŒ   rà   Tr   z--no-truncate=z-Option '--no-truncate' does not take a value.)r�   rq   rQ   rt   )rg   rû   r¨   r•   s       r)   ró   ró   è  s�   € à€KØ	€AØ
Œc�$‹iŠ-Ø�1‰gˆØ�$Š;Øð Ðð �/Ò!ØˆKØ�Q˜˜Q™�Y�ØØ�>‰>Ð*Ô+Ü×"Ñ"Ð#RÓSÐSØ	ˆQ‰ˆð Œc�$‹i‹-ð Ðr+   rë   rì   c                ó0  — t        d„ | D «       «      }|r8d| v r4|rt        j                  d«      ‚| j                  d«      }ddg| ||dz    d}|rHd| v rdnd	| v rd	nd
}|�7|rt        j                  d|› d�«      ‚| j                  |«      }ddg| ||dz    y
y
y
)a  Rewrite --json / -q / --quiet to --format ... for legacy commands.

    Used for commands like 'hf jobs ps' that still own their '--format' option.
    The rewrite lets users keep using the global shorthand while click parses
    '--format <value>' locally.
    c              3   óL   K  — | ]  }|d k(  xs |j                  d«      –— Œ y­w)rå   rñ   Nr“   r”   s     r)   r4   z-_rewrite_legacy_shorthands.<locals>.<genexpr>  s'   è ø€ Ò^ÐRU˜S JÑ.ÒM°#·.±.ÀÓ2MÓMÑ^ùs   ‚"$rß   z/'--json' and '--format' are mutually exclusive.rå   rø   r   Trç   ræ   Nrl   z(' and '--format' are mutually exclusive.rù   )r–   rQ   rt   Úindex)rg   rë   rì   Úhas_format_in_argsÚidxÚflags         r)   rõ   rõ   ú  sÈ   € ô Ñ^ÐY]Ô^Ó^Ðá˜ DÑ(ÙÜ×"Ñ"Ð#TÓUÐUØ�j‰j˜Ó"ˆØ)¨6Ð2ˆˆS�3˜‘7ÐØ!ÐáØ˜t‘|‰t°yÀDÑ7H©)ÈdˆØÐÙ!Ü×&Ñ&¨¨4¨&Ð0XÐ'YÓZÐZØ—*‘*˜TÓ"ˆCØ#-¨wÐ"7ˆD��s˜Q‘wÑð	 ð r+   Úvaluer   c                 ó¦   — 	 t        | «      S # t        $ r: dj                  d„ t         D «       «      }t        j                  d| › d|› d�«      d ‚w xY w)Nrj   c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr²   ©r  rm   s     r)   r4   z&_parse_format_value.<locals>.<genexpr>  s   è ø€ Ò@ a˜!Ÿ'�'Ñ@ùs   ‚zInvalid value for '--format': 'z'. Valid values: ro   )r   Ú
ValueErrorr6   rQ   rt   )r  Úvalids     r)   r÷   r÷     sa   € ðmÜ# EÓ*Ð*øÜò mØ—	‘	Ñ@Ô+?Ô@Ó@ˆÜ×ÑÐ!@ÀÀÐGXÐY^ÐX_Ð_`ÐaÓbÐhlÐlðmús
   ‚
 �AAÚerrorÚlabelrc   c                 ó  — |r| j                   �d|› d�| j                  v ry| j                   j                  }d|› d|› d�g}|D ]  \  }}|j                  d|d›d	|› �«       Œ |j                  d
|› d�«       t	        | t
        j                  «      rJ| j                  r>|j                  ddj                  t        | j                  «      «      › d�«       g | _        | xj                  dj                  |«      z  c_        y)zHAppend a list of available options or commands to a usage error message.Nz
Available z forz

Available z for 'z':z  Ú30sú z
Run 'z --help' for full details.z
Did you mean: rj   rp   r/   )
r?   rx   Úcommand_pathrž   rT   rQ   rR   Úpossibilitiesr6   rÃ   )r  r  rc   Úcmd_pathÚlinesra   rÈ   s          r)   rZ   rZ     sñ   € á�E—I‘IÐ%¨:°e°W¸DÐ)AÀUÇ]Á]Ñ)RØØ�y‰y×%Ñ%€HØ˜e˜W F¨8¨*°BÐ7Ð8€EØ ò 2‰ˆˆiØ�‰�r˜$˜s˜ 1 Y KÐ0Õ1ð2à	‡L�L�7˜8˜*Ð$>Ð?Ô@Ü�%œ×+Ñ+Ô,°×1DÒ1DØ�‰Ð'¨¯	©	´&¸×9LÑ9LÓ2MÓ(NÐ'OÈqÐQÔRØ ˆÔØ	‡M‚M�T—Y‘Y˜uÓ%Ñ%†Mr+   Úfallback_handlerÚextra_commands_providerc                 ó.   ‡ ‡—  G ˆˆ fd„dt         «      }|S )zRReturn a Typer group class that runs a fallback handler before command resolution.c                   óŒ   •‡ — e Zd Zdej                  dee   defˆ ˆfd„Zdej                  dej                  ddfˆ ˆfd„Z
ˆ xZS )ú8fallback_typer_group_factory.<locals>.FallbackTyperGroupr?   rg   r$   c                 ó’   •—  ‰|t        | j                  j                  «       «      «      }|�t        |«      ‚t        ‰| �  ||«      S r²   )r˜   rM   rÄ   Ú
SystemExitrO   rs   )r^   r?   rg   Úfallback_exit_coderf   r  s       €€r)   rs   zHfallback_typer_group_factory.<locals>.FallbackTyperGroup.resolve_command1  sF   ø€ Ù!1°$¼¸D¿M¹M×<NÑ<NÓ<PÓ8QÓ!RÐØ!Ð-Ü Ð!3Ó4Ð4Ü‘7Ñ*¨3°Ó5Ð5r+   r@   Nc                 ó®   •— t         ‰| �  ||«       ‰�6 ‰«       }|r,|j                  d«      5  |j                  |«       d d d «       y y y # 1 sw Y   y xY w)NzExtension commands)rO   rÉ   rÁ   rÂ   )r^   r?   r@   Úentriesrf   r  s       €€r)   rÉ   zHfallback_typer_group_factory.<locals>.FallbackTyperGroup.format_commands7  sd   ø€ Ü‰GÑ# C¨Ô3Ø&Ð2Ù1Ó3�ÙØ"×*Ñ*Ð+?Ó@ñ 4Ø!×*Ñ*¨7Ô3÷4ð 4ð ð 3÷4ð 4ús   ®AÁA)rÐ   rÑ   rÒ   rQ   rÕ   rÖ   r×   rØ   rs   rÜ   rÉ   rÝ   )rf   r  r  s   @€€r)   ÚFallbackTyperGroupr  0  sO   ù„ ð	6 u§}¡}ð 	6¸DÀ¹Ið 	6È%ö 	6ð	4 u§}¡}ð 	4À×ATÑATð 	4ÐY]÷ 	4ò 	4r+   r   )rH   )r  r  r   s   `` r)   Úfallback_typer_group_factoryr!  *  s   ù€ ÷4œ_ô 4ð Ðr+   r¼   c                 ó¦  — dt         j                  dt         j                  dt         j                  dd fd„}dt        dt         j                  dt         j                  dd fd„}dt         j                  dt         j                  dt
        t           dt
        t           fd„}t        d	| j                  «       › �t        ft        | |xs g |||d
œ«      S )Nr^   r?   r@   r$   c                 ó2   — t        | j                  ||«       y r²   )rF   r>   ©r^   r?   r@   s      r)   rÍ   z#HFCliCommand.<locals>.format_epilogC  s   € Ü  §¡¨c°9Õ=r+   c                 ó˜   — t        j                  | ||«       t        | «      ry | j                  j	                  d«      ry t        |«       y )Nrê   )r   Úformat_optionsrè   rò   r¾   rã   r$  s      r)   r&  z$HFCliCommand.<locals>.format_optionsF  sA   € Ü×#Ñ# D¨#¨yÔ9ô (¨Ô-ØØ× Ñ ×$Ñ$Ð%=Ô>ØÜ*¨9Õ5r+   rg   c                 ó  — |sg|j                   s[t        d„ | j                  D «       «      r?t        j                  |j                  «       |j                  ¬«       |j                  «        t        j                  | ||«      S )Nc              3   ól   K  — | ],  }t        |t        j                  «      xr |j                  –— Œ. y ­wr²   )rT   rQ   r™   Úrequired)r2   rd   s     r)   r4   z3HFCliCommand.<locals>.parse_args.<locals>.<genexpr>T  s'   è ø€ ÒUÀA”:˜a¤§¡Ó0Ò?°Q·Z±ZÓ?ÑUùs   ‚24)Úcolor)
Úresilient_parsingr–   r—   rQ   ÚechoÚget_helpr*  Úexitr   Ú
parse_args)r^   r?   rg   s      r)   r/  z HFCliCommand.<locals>.parse_argsP  sW   € ñ ˜C×1Ò1ÜÑUÈÏÉÔUÔUÜ—
‘
˜3Ÿ<™<›>°·±Õ;Ø—‘”
Ü×&Ñ& t¨S°$Ó7Ð7r+   r   )rÔ   r¼   r,   rÍ   r&  r/  )
rQ   rÚ   rÕ   rÜ   r   rÖ   r×   ÚtyperÅ   r   )r¼   r,   rÍ   r&  r/  s        r)   ÚHFCliCommandr1  B  sÕ   € ð>œEŸM™Mð >´·±ð >Ì%×J]ÑJ]ð >Ðbfó >ð6œ\ð 6´·±ð 6Ì%×J]ÑJ]ð 6Ðbfó 6ð8œŸ™ð 8¬U¯]©]ð 8Ä$ÄsÁ)ð 8ÔPTÔUXÑPYó 8ô Ø
�u×'Ñ'Ó)Ð*Ð+Ü	ˆä*ØØ š BØ*Ø,Ø$ñ	
óð r+   c            "       óÖ   ‡ — e Zd ZdZ	 ddddddddddddddœdedz  d	ed
ee   dz  deeef   dz  dedz  dedz  dedz  dede	de	de	de	dedz  de
e
def   ge
def   f   fˆ fd„Zˆ xZS )ÚHFCliAppz&Custom Typer app for Hugging Face CLI.Nr:   z	[OPTIONS]TF)r¼   r,   rò   r;   r>   Ú
short_helpÚoptions_metavarÚadd_help_optionÚno_args_is_helprX   Ú
deprecatedÚrich_help_panelra   r¼   r,   rò   r;   r>   r4  r5  r6  r7  rX   r8  r9  r$   .c                ó¦   •‡ ‡‡‡‡‡‡‡‡‡	‡
‡‡‡— ‰€‰rt        ‰«      Šdt        dt        f   dt        dt        f   fˆˆ	ˆˆˆˆˆˆˆˆ
ˆˆˆ ˆˆfd„}|S )NÚfunc.r$   c                 ó`   •— t        t        ‰�  ‰	t        ‰‰«      ‰‰‰‰‰‰‰
‰‰‰¬«      | «      S )N)Úclsrò   r;   r>   r4  r5  r6  r7  rX   r8  r9  )rO   r3  rS   r1  )r;  rf   r6  rò   r8  r>   r,   r;   rX   ra   r7  r5  r9  r^   r4  r¼   s    €€€€€€€€€€€€€€€r)   Ú_innerz HFCliApp.command.<locals>._inner  sQ   ø€ Üœ 4Ñ0ØÜ  ¨Ó1Ø!1ØØØ%Ø /Ø /Ø /ØØ%Ø /ð 1ó ð óð r+   )r9   r   r	   )r^   ra   r¼   r,   rò   r;   r>   r4  r5  r6  r7  rX   r8  r9  r>  rf   s   `````````````` €r)   rS   zHFCliApp.commandj  sM   ÿþ€ ð$ ˆ>™hÜ$ XÓ.ˆFð	œ #¤s (Ñ+ð 	´¸¼c¸Ñ0B÷ 	÷ 	ó 	ð  ˆr+   r²   )rÐ   rÑ   rÒ   rÓ   r×   ÚTOPIC_TrÖ   rÛ   r	   Úboolr   rS   rÝ   rÞ   s   @r)   r3  r3  g  s  ø„ Ù0ð  ð%ð  Ø%)Ø26ØØ!Ø!%Ø*Ø $Ø %ØØ Ø&*ò%à�D‰jð%ð ð	%ð
 �s‘)˜dÑ"ð%ð ˜s C˜x™.¨4Ñ/ð%ð �D‰jð%ð �d‘
ð%ð ˜$‘Jð%ð ð%ð ð%ð ð%ð ð%ð ð%ð ˜t™ð%ð  
�8˜C ˜HÑ%Ð&¨°°c°Ñ(:Ð:Ñ	;÷!%ñ %r+   r3  r;   r=  c                 óF   — |€t         }t        | |dd|dddddddgdœ¬«
      S )	a+  Create a Typer app with consistent settings.

    Args:
        help: Help text for the app.
        epilog: Optional epilog text (use `generate_epilog` to create one).
        cls: Optional Click group class to use (defaults to `HFCliTyperGroup`).

    Returns:
        A configured Typer app.
    NTFéx   z-hz--help)Úmax_content_widthÚhelp_option_names)
r;   r>   Úadd_completionr7  r=  Úrich_markup_moder9  Úpretty_exceptions_enableÚsuggest_commandsrò   )rH   r3  )r;   r>   r=  s      r)   Útyper_factoryrI  ’  sJ   € ð €{ÜˆÜØØØØØàØØ!&ð ð "%Ø"&¨Ð!1ñ
ôð r+   c                   ó   — e Zd ZdZdZdZy)ÚRepoTypeÚmodelÚdatasetÚspaceN)rÐ   rÑ   rÒ   rL  rM  rN  r1   r+   r)   rK  rK  µ  s   „ Ø€EØ€GØ�Er+   rK  zNThe ID of the repo (e.g. `username/repo-name` or `spaces/username/repo-name`).)r;   r†   r’   z2The type of repository (model, dataset, or space).zJA User Access Token generated from https://huggingface.co/settings/tokens.zfWhether to create a private repo if repo doesn't exist on the Hub. Ignored if the repo already exists.zDGit revision id which can be a branch name, a tag, or a commit hash.zLimit the number of results.z!Filter by author or organization.zHFilter by tags (e.g. 'text-classification'). Can be used multiple times.zSearch query.z-ez--envz/Set environment variables. E.g. --env ENV=valuez-sz	--secretszvSet secret environment variables. E.g. --secrets SECRET=value or `--secrets HF_TOKEN` to pass your Hugging Face token.z
--env-filez(Read in a file of environment variables.z/Read in a file of secret environment variables.c                  ój   — ddl m}  t        j                  j	                  «       } | «       x}�||d<   |S )zQReturn a copy of ``os.environ`` with the user's HF token injected (if available).r   )Ú	get_tokenÚHF_TOKEN)Úhuggingface_hubrP  ÚosÚenvironÚcopy)rP  Úextended_environr#   s      r)   Ú_get_extended_environrW    s4   € å)ä—z‘z—‘Ó(ÐÙ“ÐˆÐ)Ø',Ð˜Ñ$ØÐr+   ÚenvÚenv_filec                 óÖ   — t        «       }i }|r3|j                  t        t        |«      j	                  «       |¬«      «       | xs g D ]  }|j                  t        ||¬«      «       Œ  |S )zìParse ``-e``/``--env``/``-s``/``--secrets`` and ``--env-file``/``--secrets-file`` CLI args into a dict.

    Uses an extended environment that includes the user's HF token so that
    bare ``--secrets HF_TOKEN`` resolves correctly.
    )rT  )rW  Úupdater   r   Ú	read_text)rX  rY  rV  Úenv_mapÚ	env_values        r)   Úparse_env_mapr_  (  sd   € ô -Ó.ÐØ%'€GÙØ�‰”{¤4¨£>×#;Ñ#;Ó#=ÐGWÔXÔYØ’Y˜Bò Iˆ	Ø�‰”{ 9Ð6FÔGÕHðIà€Nr+   r]  c                 óh   — | sy| j                  «       D ��cg c]  \  }}||xs ddœ‘Œ c}}S c c}}w )z_Convert an env/secrets dict to the ``[{"key": ..., "value": ...}]`` format used by the Hub API.NÚ )r~   r  )rc   )r]  ÚkÚvs      r)   Úenv_map_to_key_value_listrd  :  s/   € áØØ5<·]±]³_×E©T¨Q°�A ¢ RÓ(ÓEÐEùÓEs   —.z-vz--volumeaV  Mount one or more volumes. Format: hf://[TYPE/]SOURCE:/MOUNT_PATH[:ro]. TYPE is one of: models, datasets, spaces, buckets. TYPE defaults to models if omitted. models, datasets and spaces are always mounted read-only. buckets are read+write by default. E.g. -v hf://org/m:/data or -v hf://datasets/org/ds:/data or -v hf://buckets/org/b:/mnt:roÚvolumeszlist[Volume] | Nonec                 óL  — | syg }| D ]™  }t        |«      }|j                  t        |j                  j                  |j                  j
                  |j                  |j                  |j                  j                  xs d|j                  j                  xs d¬«      «       Œ› |S )a_  Parse volume specs from CLI arguments.

    Format: hf://[TYPE/]SOURCE[/PATH]:/MOUNT_PATH[:ro|:rw]
    Where TYPE is one of: models, datasets, spaces, buckets (defaults to models if omitted).
    SOURCE is the repo/bucket identifier (e.g. 'username/my-model').
    PATH is an optional subfolder inside the repo/bucket.
    MOUNT_PATH starts with '/'.
    Optional ':ro' or ':rw' suffix for read-only or read-write.

    Examples:
        hf://my-org/my-model:/data                (model, implicit type)
        hf://models/my-org/my-model:/data         (model, explicit type)
        hf://datasets/my-org/my-dataset:/data:ro
        hf://buckets/my-org/my-bucket:/mnt
        hf://spaces/my-org/my-space:/app
        hf://datasets/org/ds/train:/data          (with path inside repo)
        hf://buckets/org/b/sub/dir:/mnt           (with path inside bucket)
    N)r0  ÚsourceÚ
mount_pathÚ	read_onlyÚpathÚrevision)
r   rž   r   rg  r0  Úidrh  ri  Úpath_in_repork  )re  r·   Úraw_specÚmounts       r)   Úparse_volumesrp  O  s�   € ñ& Øà€FØò 
ˆÜ˜xÓ(ˆØ�‰ÜØ—\‘\×&Ñ&Ø—|‘|—‘Ø ×+Ñ+ØŸ/™/Ø—\‘\×.Ñ.Ò6°$ØŸ™×.Ñ.Ò6°$ôõ		
ð
ð €Mr+   c                   ó   — e Zd ZdZdZdZy)ÚOutputFormatz$Output format for CLI list commands.Útablerø   N)rÐ   rÑ   rÒ   rÓ   rs  rø   r1   r+   r)   rr  rr  u  s   „ Ù.à€EØ�Dr+   rr  zOutput format (table or json).c                 ó0   — t        j                  | «       | S )aL  Callback for the legacy FormatWithAutoOpt option type.

    Most commands now rely on the global --format / --json / -q flags consumed by _consume_format_flags_for_leaf instead
    of declaring FormatWithAutoOpt themselves.  This callback is kept for the rare cases where a command still wires
    FormatWithAutoOpt explicitly.
    )r   rú   r
  s    r)   Ú_set_output_moderu  „  s   € ô ‡L�L�ÔØ€Lr+   zOutput format.)r;   Úcallbackrç   ræ   zPrint only IDs (one per line).ra   c                 óP   — t        j                  dd| «      }|j                  «       S )z\Convert a camelCase or PascalCase string to SCREAMING_SNAKE_CASE to be used as table header.z([a-z])([A-Z])z\1_\2)Úrerb   Úupper)ra   Úss     r)   Ú
_to_headerr{  š  s!   € ä
�‰Ð  (¨DÓ1€AØ�7‰7‹9Ðr+   c                 ó´  — | syt        | t        «      r| rdS dS t        | t        j                  «      r| j                  d«      S t        | t        «      rt        j                  d| «      r| dd S t        | t        «      rdj                  d„ | D «       «      S t        | t        «      r'd	| v rt	        | d	   «      S t        j                  | «      S t	        | «      S )
z/Convert a value to string for terminal display.ra  u   âœ”z%Y-%m-%dz^\d{4}-\d{2}-\d{2}TNé
   rj   c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr²   )Ú_format_value)r2   rc  s     r)   r4   z _format_value.<locals>.<genexpr>«  s   è ø€ Ò9¨aœ q×)Ñ9ùs   ‚ra   )rT   r@  ÚdatetimeÚstrftimer×   rx  ÚmatchrÖ   r6   rÛ   rø   Údumpsr
  s    r)   r  r     sº   € áØÜ�%œÔÙˆuÐ% 2Ð%Ü�%œ×*Ñ*Ô+Ø�~‰~˜jÓ)Ð)Ü�%œÔ¤"§(¡(Ð+AÀ5Ô"IØ�S�bˆzÐÜ�%œÔØ�y‰yÑ9°5Ô9Ó9Ð9Ü	�Eœ4Ô	 Ø�U‰?Ü�u˜V‘}Ó%Ð%ä�z‰z˜%Ó Ð Üˆu‹:Ðr+   Úmax_lenc                 óN   — t        | «      }t        |«      |kD  r|d|dz
   dz   }|S )z/Format a value + truncate it for table display.Nr�   z...)r  r�   )r  r„  Úcells      r)   Ú_format_cellr‡  ´  s2   € ä˜Ó€DÜ
ˆ4ƒy�7ÒØ�M�g ‘kÐ" UÑ*ˆØ€Kr+   ÚheadersÚrow_fnÚ
alignmentsc           	      ó|  — | st        d«       yt        t        t        t        t        t
        f         | D �cg c]
  } ||«      ‘Œ c}«      }|D �cg c]  }t        |«      ‘Œ }}|xs i j                  «       D ��	ci c]  \  }}	t        |«      |	“Œ }
}}	t        t        |||
¬«      «       yc c}w c c}w c c}	}w )ai  Print items as a formatted table.

    Args:
        items: Sequence of dictionaries representing the items to display.
        headers: List of column headers.
        row_fn: Function that takes an item dict and returns a list of string values for each column.
        alignments: Optional mapping of header name to "left" or "right". Defaults to "left".
    zNo results found.N)rˆ  rŠ  )	Úprintr   rÖ   r   r×   Úintr{  rc   r   )rc   rˆ  r‰  rŠ  ÚitemÚrowsÚhÚscreaming_headersrb  rc  Úscreaming_alignmentss              r)   Úprint_as_tabler“  ¼  s¦   € ñ ÜÐ!Ô"ØÜ””Tœ%¤¤S ™/Ñ*Ñ+ÀuÖ-M¸t©f°T­lÒ-MÓN€DØ07Ö8¨1œ A�Ð8ÐÐ8à:DÒ:JÈ×9QÑ9QÓ9S×T±°°AœJ q›M¨1Ñ,ÐTÐÑTÜ	Œ(�4Ð!2Ð?SÔ
TÕUùò	 .NùÚ8ùãTs   ¸B.
ÁB3Á=B8Úformatrù   Úid_keyc                 óÆ  ‡‡	— |r| D ]  }t        ||   «       Œ y|t        j                  k(  r/t        t        j                  t	        | «      dt
        ¬«      «       y‰€G| rt	        | d   j                  «       «      n|g}|D �	‡	cg c]  Š	t        ˆ	fd„| D «       «      sŒ‰	‘Œ c}	Š|€&dt        t
        t        f   dt        t
           fˆfd„}t        | ‰||¬	«       yc c}	w )
aP  Print list command output in the specified format.

    Args:
        items: Sequence of dictionaries representing the items to display.
        format: Output format.
        quiet: If True, print only IDs (one per line).
        id_key: Key to use for extracting IDs in quiet mode.
        headers: Optional list of column names for headers. If not provided, auto-detected from keys.
        row_fn: Optional function to extract row values. If not provided, uses _format_cell on each column.
        alignments: Optional mapping of header name to "left" or "right". Defaults to "left".
    NrŽ   )ÚindentÚdefaultr   c              3   óR   •K  — | ]  }t        |j                  ‰«      «      –— Œ  y ­wr²   ©r‡  r¾   )r2   rŽ  Úcols     €r)   r4   z$print_list_output.<locals>.<genexpr>ó  s   øè ø€ Ò4cÐUY´\À$Ç(Á(È3Ã-×5PÑ4cùs   ƒ$'rŽ  r$   c                 ó^   •— ‰D �cg c]  }t        | j                  |«      «      ‘Œ c}S c c}w r²   rš  )rŽ  r›  rˆ  s     €r)   r‰  z!print_list_output.<locals>.row_fn÷  s$   ø€ Ø;BÖC°C”L §¡¨#£Õ/ÒCÐCùÒCs   †!*)rˆ  r‰  rŠ  )rŒ  rr  rø   rƒ  rÖ   r×   rÄ   r–   rÛ   r	   r“  )
rc   r”  rù   r•  rˆ  r‰  rŠ  rŽ  Úall_columnsr›  s
       `    `r)   Úprint_list_outputrž  Ô  sÊ   ù€ ñ( Øò 	 ˆDÜ�$�v‘,Õð	 àà”×"Ñ"Ò"ÜŒd�j‰jœ˜e›¨Q¼Ô<Ô=Øà€Ù/4”d˜5 ™8Ÿ=™=›?Ô+¸6¸(ˆØ"-×d˜3´Ó4cÐ]bÔ4cÕ1c’3Òdˆà€~ð	Dœœc¤3˜h™ð 	D¬D´©Iõ 	Dô �5 '°&ÀZÖPùò es   ÂCÂCrc  c                 óB  — t        | t        j                  «      r| j                  «       S t        | t        «      r0| j	                  «       D ��ci c]  \  }}|€Œ	|t        |«      “Œ c}}S t        | t        «      r| D �cg c]  }t        |«      ‘Œ c}S | S c c}}w c c}w )z4Recursively serialize a value to be JSON-compatible.)rT   r€  Ú	isoformatrÛ   rc   Ú_serialize_valuerÖ   )rc  r~   ÚvalrŽ  s       r)   r¡  r¡  ý  s�   € ä�!”X×&Ñ&Ô'Ø�{‰{‹}ÐÜ	�A”tÔ	Ø;<¿7¹7»9×X©x¨s°CÈÉ�Ô% cÓ*Ñ*ÓXÐXÜ	�A”tÔ	Ø34Ö5¨4Ô  Õ&Ò5Ð5Ø€Hùó Yùâ5s   Á
BÁBÁ?BÚinfoc                 ó”   — t        j                  | «      j                  «       D ��ci c]  \  }}|€Œ	|t        |«      “Œ c}}S c c}}w )z9Convert repo info dataclasses to json-serializable dicts.)ÚdataclassesÚasdictrc   r¡  )r£  rb  rc  s      r)   Úapi_object_to_dictr§    s?   € ä/:×/AÑ/AÀ$Ó/G×/MÑ/MÓ/O×a¡t q¨!ÐSTÑS`ˆAÔ Ó"Ñ"ÓaÐaùÓas
   §
A²AÚvalid_propertiesc                 óF   ‡ — dt         dz  dt        t           dz  fˆ fd„}|S )zJCreate a callback to parse and validate comma-separated expand properties.r  Nr$   c           	      ó  •— | €y | j                  d«      D �cg c]  }|j                  «       ‘Œ }}|D ]0  }|‰vsŒt        j                  d|› ddj	                  ‰«      › �«      ‚ |D �cg c]  }t        t        |«      ‘Œ c}S c c}w c c}w )Nú,zInvalid expand property: 'z'. Valid values are: rj   )rC   ÚstripÚtyperÚBadParameterr6   r   r<   )r  rd   Ú
propertiesÚpropr¨  s       €r)   Ú_parse_expand_propertiesz?make_expand_properties_parser.<locals>._parse_expand_properties  sš   ø€ Øˆ=ØØ).¯©°SÓ)9Ö: A�a—g‘g•iÐ:ˆ
Ð:Øò 	ˆDØÐ+Ò+Ü×(Ñ(Ø0°°Ð6KÈDÏIÉIÐVfÓLgÐKhÐióð ð	ð
 9CÖC°””_ dÕ+ÒCÐCùò ;ùò Ds   ˜BÁ*B	)r×   rÖ   r<   )r¨  r±  s   ` r)   Úmake_expand_properties_parserr²    s/   ø€ ð	D¬¨d©
ð 	D´t¼OÑ7LÈtÑ7Sõ 	Dð $Ð#r+   Úlibrary)rR  Útransformersc                 óh   — 	 t        | «       y# t        $ r t        j                  dd¬«       Y yw xY w)a�  
    Check whether a newer version of a library is available on PyPI.

    If a newer version is found, print a hint pointing at `hf update`.

    If current version is a pre-release (e.g. `1.0.0.rc1`), or a dev version (e.g. `1.0.0.dev1`), no check is performed.
    If `HF_HUB_DISABLE_UPDATE_CHECK` is set, the check is skipped entirely.

    This function is called at the entry point of the CLI. It only performs the check once every 24 hours, and any error
    during the check is caught and logged, to avoid breaking the CLI.

    Args:
        library: The library to check for updates. Currently supports "huggingface_hub" and "transformers".
    z$Error while checking for CLI update.T©Úexc_infoN)Ú_check_cli_updateÚ	ExceptionÚloggerÚdebug)r³  s    r)   Úcheck_cli_updater¼  !  s2   € ðLÜ˜'Õ"øÜò Lä�‰Ð;ÀdˆÖKðLús   ‚ Ž 1°1c                 óP  ‡— t         j                  ry t        j                  j	                  | «      Št        ˆfd„dD «       «      ry t        j                  j                  t         j                  «      rHt        j                  j                  t         j                  «      }t        j                  «       |z
  dk  ry t        t         j                  «      j                  j                  dd¬«       t        t         j                  «      j                  «        | dk(  rt!        «       dk(  rt#        «       }nt%        | «      }|�‰|k(  ry | dk(  rt'        «       }n
t)        «       }d| › d	|› d
‰› d�}|�#| dk(  r|dz  }n	 |ddj+                  |«      › �z  }t-        j.                  |«       y )Nc              3   ó&   •K  — | ]  }|‰v –— Œ
 y ­wr²   r1   )r2   ÚtagÚcurrent_versions     €r)   r4   z$_check_cli_update.<locals>.<genexpr>>  s   øè ø€ Ò
; cˆ3�/Ô!Ñ
;ùs   ƒ)ÚrcÚdevi€Q T)ÚparentsÚexist_okrR  ÚbrewzA new version of z (z&) is available! You are using version ro   z
To update, run: hf updatez
To update, run: r  )r   ÚHF_HUB_DISABLE_UPDATE_CHECKÚ	importlibÚmetadataÚversionr–   rS  rj  ÚexistsÚCHECK_FOR_UPDATE_DONE_PATHÚgetmtimeÚtimer   ÚparentÚmkdirÚtouchr   Ú_fetch_latest_brew_versionÚ_fetch_latest_pypi_versionÚ#_get_huggingface_hub_update_commandÚ _get_transformers_update_commandr6   r   Úhint)r³  ÚmtimeÚlatest_versionÚupdate_commandrx   rÀ  s        @r)   r¸  r¸  7  sp  ø€ Ü×,Ò,Øä×(Ñ(×0Ñ0°Ó9€Oô Ó
;¨]Ô
;Ô;Øô 
‡w�w‡~�~”i×:Ñ:Ô;Ü—‘× Ñ ¤×!EÑ!EÓFˆÜ�I‰I‹K˜%Ñ 9Ò,Øô 	Œ×	-Ñ	-Ó.×5Ñ5×;Ñ;ÀDÐSWÐ;ÔXÜŒ×	-Ñ	-Ó.×4Ñ4Ô6ð Ð#Ò#Ô(;Ó(=ÀÒ(GÜ3Ó5‰ä3°GÓ<ˆØÐ °NÒ!BØàÐ#Ò#Ü<Ó>‰ä9Ó;ˆà! ' ¨"¨^Ð,<Ð<bÐcrÐbsÐstÐu€GØÐ!ØÛ"ØÐ8Ñ8‘ØØÐ/°·±¸Ó0HÐ/IÐJÑJ�Ü‡H�HˆWÕr+   c                 óÐ   — 	 t        «       j                  d| › d�d¬«      }t        |«       |j                  «       d   d   S # t        $ r t
        j                  dd¬	«       Y y
w xY w)zSFetch the latest version of a library from PyPI. Returns None if the request fails.zhttps://pypi.org/pypi/z/jsonrŽ   ©Útimeoutr£  rÉ  z.Error while fetching latest version from PyPI.Tr¶  N©r   r¾   r   rø   r¹  rº  r»  )r³  Úresponses     r)   rÒ  rÒ  b  sk   € ðÜ“=×$Ñ$Ð'=¸g¸YÀeÐ%LÐVWÐ$ÓXˆÜ˜HÔ%Ø�}‰}‹˜vÑ& yÑ1Ð1øÜò Ü�‰ÐEÐPTˆÔUÙðús   ‚?A Á A%Á$A%c                  óÈ   — 	 t        «       j                  dd¬«      } t        | «       | j                  «       d   d   S # t        $ r t
        j                  dd¬«       Y y	w xY w)
zkFetch the latest version of the `hf` formula from the Homebrew registry. Returns None if the request fails.z,https://formulae.brew.sh/api/formula/hf.jsonrŽ   rÚ  ÚversionsÚstablez2Error while fetching latest version from Homebrew.Tr¶  NrÜ  )rÝ  s    r)   rÑ  rÑ  m  sb   € ðÜ“=×$Ñ$Ð%SÐ]^Ð$Ó_ˆÜ˜HÔ%Ø�}‰}‹˜zÑ*¨8Ñ4Ð4øÜò Ü�‰ÐIÐTXˆÔYÙðús   ‚;> ¾ A!Á A!c                  óZ   — t        «       } | €t        d«      ‚t        j                  | «      S )zÛRun the install-method-appropriate update command for the `hf` CLI.

    Raises CLIError if the installation method can't be determined.
    Returns the subprocess exit code on success/failure of the update itself.
    zeCannot determine how to update huggingface_hub (unknown installation method). Please update manually.)rÓ  r   Ú
subprocessÚcall)r`   s    r)   Ú
run_updaterä  x  s2   € ô .Ó
/€CØ
€{ÜØsó
ð 	
ô �?‰?˜3ÓÐr+   c                  ó®   — t        «       xdk(  r g d¢S xdk(  rt        j                  dk(  r g d¢S xdk(  r g d¢S dk(  rt        j                  ddd	d
dgS 	 y)zlReturn the command to update huggingface_hub as an argv list, or None if the installation method is unknown.rÅ  )rÅ  ÚupgradeÚhfÚhf_installerÚnt)Ú
powershellú
-NoProfileú-Commandz-iwr -useb https://hf.co/cli/install.ps1 | iex)Úbashú-cz0curl -LsSf https://hf.co/cli/install.sh | bash -Úpipú-mÚinstallú-UrR  N©r   rS  ra   ÚsysÚ
executabler1   r+   r)   rÓ  rÓ  †  sP   € ä
Ó
ÝÚ,Ð,ÜœrŸw™w¨$šˆ^ÚlÐlÝÚUÐUÛÜ—N‘N D¨%°¸DÐBSÐTÐTØØr+   c                  óš   — t        «       xdk(  rt        j                  dk(  r g d¢S xdk(  r g d¢S dk(  rt        j                  ddddd	gS 	 y
)ziReturn the command to update transformers as an argv list, or None if the installation method is unknown.rè  ré  )rê  rë  rì  z?iwr -useb https://hf.co/cli/install.ps1 | iex -WithTransformers)rí  rî  zHcurl -LsSf https://hf.co/cli/install.sh | bash -s -- --with-transformersrï  rð  rñ  rò  r´  Nró  r1   r+   r)   rÔ  rÔ  •  sL   € ä
Ó
ÜœrŸw™w¨$šˆ^òð õ ÚmÐmÛÜ—N‘N D¨%°¸DÀ.ÐQÐQØØr+   r²   )NN)rl  NNN)ˆrÓ   r¥  r€  rv   Úimportlib.metadatarÇ  rø   rS  rx  râ  rô  rÍ  Úcollections.abcr   r   Úenumr   Úpathlibr   Útypingr   r   r	   r
   r   r   r   rQ   r­  Ú
typer.corer   r   rR  r   r   r   Úhuggingface_hub.errorsr   Úhuggingface_hub.utilsr   r   r   r   r   r   Úhuggingface_hub.utils._dotenvr   Ú_help_formatterr   Ú_outputr   r   Ú
get_loggerrº  Ú_MAX_CELL_LENGTHÚREPO_LIST_DEFAULT_LIMITr(   r"   r×   r*   r5   rÖ   r9   r?  r˜   r�  ÚFallbackHandlerTr<   rÕ   rÜ   rF   Úcompileru   rH   rá   rØ   Ú__annotations__rã   rÚ   r@  rè   rz   ró   rõ   r÷   rt   rZ   r0  r!  r1  ÚTyperr3  rI  rK  r™   Ú	RepoIdArgr\   ÚRepoTypeOptÚTokenOptÚ
PrivateOptÚRevisionOptÚLimitOptÚ	AuthorOptÚ	FilterOptÚ	SearchOptÚEnvOptÚ
SecretsOptÚ
EnvFileOptÚSecretsFileOptrÛ   rW  r_  rd  Ú
VolumesOptrp  rr  Ú	FormatOptru  ÚFormatWithAutoOptÚQuietOptr{  r  r‡  r“  rž  Úobjectr¡  r§  r²  r¼  r¸  rÒ  rÑ  rä  rÓ  rÔ  r1   r+   r)   ú<module>r     sø  ðò 1ã Û Û Û Û Û 	Û 	Û Û 
Û ß .Ý Ý ß O× OÑ Oã Û ß /ç :Ñ :Ý +÷÷ õ 6å *ß .ð 
ˆ×	Ñ	Ó	€ð Ð ð Ð áÝ,ñ[�c˜D‘jð [¨Gó [ð PÐ ñ˜d 3™ið °c¸D±jð ÈCó ð, �.Ñ
! CÑ
'€Ø˜T #™Y¨¨C©Ð1°3¸±:Ð=Ñ>Ð ÙÐ+°3Ô7€ð' S¨4¡Zð '°e·m±mð 'ÐPU×PcÑPcð 'Ðhló 'ð ˆr�z‰z˜+Ó&€ô|%�jô |%ò~;Ð   $ u¨S°#¨X¡Ñ"7ó ð=°%×2EÑ2Eð =È$ó =ð
 e§m¡mð ¸ó ðV¨¯©ð V¸TÀ#¹Yð VÈ4ó Vðr T¨#¡Yð °4ó ð$8 T¨#¡Yð 8Àð 8ÐVZð 8Ð_có 8ð2m˜sð mÐ'=ó mð&˜u×/Ñ/ð &¸ð &ÀDÈÈsÐTWÈxÉÑDYð &Ð^bó &ð" KOñØ&ðà% b¨$¨u°S¸#°X©Ñ*?Ð&?Ñ@À4ÑGðð 
ˆ/Ñóñ0"˜ð "¨4°©9°tÑ+;ð "ÀtÈLÑGYó "ôJ(ˆu�{‰{ô (ñV ˜ð   S¨4¡Zð  ¸TÀ*Ñ=MÐPTÑ=Tð  Ð`jó  ôFˆs�Dô ð ØØ€E‡N�NØ]ôðñ€	ð ØØ€E‡L�LØØØAôðñ€ð Øˆ$�JØ€E‡L�LØYôðñ€ð Øˆ4�KØ€E‡L�LØuôðñ€
ð Øˆ$�JØ€E‡L�LØSôðñ€ð ØØ€E‡L�LÐ4Ô5ð7ñ€ð
 Øˆ$�JØ€E‡L�LÐ9Ô:ð<ñ€	ð
 Øˆ�I�ÑØ€E‡L�LÐ`Ôaðcñ€	ð
 Øˆ$�JØ€E‡L�L�oÔ&ð(ñ€	ð 
Øˆ�I�ÑØ€E‡L�LØØØ>ôðñ
€ð Øˆ�I�ÑØ€E‡L�LØØðHô	ðñ
€
ð Øˆ$�JØ€E‡L�LØØ7ôðñ€
ð Øˆ$�JØ€E‡L�LØ>ôðñ€ð˜t C¨ H™~ó ð !ØñØ	ˆc‰�TÑ	ðà�D‰jðð 
ˆ#ˆs�T‰zˆ/Ñóð$F t¨C°°t±¨OÑ'<ð FÀÀdÈ3ÐPSÈ8ÁnÑAUÐX\ÑA\ó Fð Øˆ�I�ÑØ€E‡L�LØØðeôð	ñ€
ð#˜4 ™9 tÑ+ð #Ð0Eó #ôL�3˜ô ð ØØ€E‡L�LØ-ôðñ€	ðÐ0ð Ð5Ió ð ØØ€E‡L�LÐ&Ð1AÔBðDñÐ ð
 ØØ€E‡L�L��yÐ'GÔHðJñ€ð�Sð ˜Só ð˜ð  ó ð( -=ñ ˜ð  cð Àó ð )-ñ	VØ�D˜˜c˜‘NÑ#ðVà�#‰YðVð �d˜3 ˜8‘nÐ% t¨C¡yÐ0Ñ1ðVð �S˜#�X‘ Ñ%ð	Vð
 
óVð8 Ø $Ø;?Ø(,ñ&QØ�D˜˜c˜‘NÑ#ð&Qàð&Qð ð&Qð ð	&Qð
 �#‰Y˜Ñð&Qð �d˜3 ˜8‘nÐ% t¨C¡yÐ0Ñ1°DÑ8ð&Qð �S˜#�X‘ Ñ%ð&Qð 
ó&QðR˜ð  6ó ðb˜Sð b T¨#¨s¨(¡^ó bð
$°H¸_Ñ4Mó $ð(L˜gÐ&GÑHð LÈTó Lð,(˜wÐ'HÑIð (Èdó (ðV¨ð °°d±
ó ð C¨$¡Jó ð �Có  ð¨T°#©Y¸Ñ-=ó ð¨$¨s©)°dÑ*:ô r+   