
    h,                        S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	J
r
  SSKJrJr  SSKJr          SS jrSS	 jrg
)    )annotations)AnyDictOptional)check_default_instances_context)InvalidDefaultInstanceErrorUnsupportedStructTypeMessage   )_fields
_singleton)_confstructc                   [         R                  U 5      nUR                  5        HL  u  pEUR                  [        R
                  ;   a  M%  U[         R                  UR                  5      :X  d  MJ  Us  $    UR                  5        HU  u  pEUR                  [        R
                  ;   a  M%  XR                  :H  n[        U[        5      (       d  MJ  U(       d  MS  Us  $    UR                  5        H  u  pG[        XpSS9(       d  M  Us  $    g)zGiven a subcommand mapping and a default, return which subcommand the default
corresponds to.

TOOD: this function is based on heuristics. While it should be robust to
most real-world scenarios, there's room for improvement for generic types.
TrootN)	object__hash__itemsdefaultr   MISSING_AND_MISSING_NONPROP
isinstancebool_recursive_struct_match)r   subcommand_config_from_namesubcommand_type_from_namedefault_hashsubcommand_nameconfequalsubcommand_types           S/home/james-whalen/.local/lib/python3.13/site-packages/tyro/_subcommand_matching.pymatch_subcommandr!      s     ??7+L!<!B!B!D<<:AAA6??4<<88""	 "E "=!B!B!D<<:AAA<<'eT""uu"" "E -F,K,K,M( #?$GG"" -N"     c                (    [        5          [        R                  " XUS9nSSS5        [	        W[
        5      (       a  gUS    H)  n[        UR                  UR                  SS9(       a  M)    g   g! , (       d  f       NW= f! [         a     gf = f)zUReturns `True` if the given type and default instance are compatible
with each other.)support_single_arg_typesNFTr
   r   )	r   r    field_list_from_type_or_callabler   r   r	   r   typer   )r   r   r   
field_listfields        r    r   r   @   s    ,. AA4J / *:;;A&uzz5==uMM  # /. '  s-   
B A3B 3
B=B B 
BBN)r   r   r   z(Dict[str, _confstruct._SubcommandConfig]r   zDict[str, type]returnzOptional[str])r   r   r   r   r   r   r)   r   )
__future__r   typingr   r   r   tyro.constructors._registryr   tyro.constructors._struct_specr   r	    r   r   r   r   r!   r    r"   r    <module>r0      sM    " & & G
 " ..!I.  /. 	.br"   