+
    Q(i                       a  R7 t\0 t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
Ht ^ RIHtHtHt ^ RIHtHt ^ RIHtHt ^ RIHtHtHtHtHtHtHt ]P8                  R88  d   ^ RIHt MRt^ RIHtH t H!t!H"t"H#t#H$t$ ^ R	I%H&t&H't' ^ R
I(H)t)H*t* ^ RI+H,t,H-t-H.t.H/t/H0t0 ]P8                  R88  d   ^ RIHt MRt]'       d   ^ RI1H2t2 ]! R4      t3]! R]R7      t4]! R]R7      t5]6]6]7,          ]8]8]7,          ]9]9]7,          ]:]:]7R3,          ];];]7]73,          /t<] ^ k ]
]8]P                  ]8]]8]Pz                  P|                  ]9]Pz                  P~                  ]9]Pz                  P                  ]8]Pz                  P                  ];]Pz                  P                  ];/tC] ^k ];]7]]]7,          R3,          3,          tDR R ltER R ltFR R ltGR R ltHR R ltIR R ltJR R  ltKR! R" ltLR# R$ ltM]N]E]O]F]P]G]Q]H]]I]]J]]K/tR] ^k R% R& ltSR9R' R( lltTR) R* ltUR+ R, ltVR- R. ltWR/ R0 ltXR1 R2 ltYR:R3 R4 lltZR;R5 R6 llt[R# )<    N)CallableIterableSequence)datedatetime	timedelta)EnumFlag)partialreduce)TYPE_CHECKINGAnyLiteralTypeVarUnionget_args
get_origin)TypeAliasType)ITERABLE_TYPESis_annotatedis_enum_flagis_nonetypeis_unionresolve)CoercionErrorValidationError)	FieldInfoget_field_infos)UNSETdefault_name_transformgrouper
is_builtinis_class_and_subclassTokenTE)boundF.NestedCliArgsc                0    V ^8  d   QhR\         R\        /#    sreturn)strbool)formats   "W/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/cyclopts/_convert.py__annotate__r4   G   s     . .S .T .    c                 f    V P                  4       p V R9   d   R# V R9   d   R# \        \        R7      h)noFT)target_type>   0fnr7   false>   1tyyestrue)lowerr   r1   r.   s   &r3   _boolrD   G   s2    		A**	
,	, --r5   c                0    V ^8  d   QhR\         R\        /# r,   )r0   int)r2   s   "r3   r4   r4   R   s      C C r5   c                 R   V P                  4       p V P                  R 4      '       d   \        V ^4      # V P                  R4      '       d   \        V ^4      # V P                  R4      '       d   \        V ^4      # RV 9   d   \        \        \	        V 4      4      4      # \        V 4      # )0x0o0b.)rB   
startswithrF   roundfloatrC   s   &r3   _intrO   R   s    		A||D1bz	
d		1ay	
d		1ay	 5q?##1vr5   c                0    V ^8  d   QhR\         R\        /# r,   )r0   bytes)r2   s   "r3   r4   r4   c   s     % %c %e %r5   c                     \        V R R7      # )utf8)encoding)rQ   rC   s   &r3   _bytesrU   c   s    V$$r5   c                0    V ^8  d   QhR\         R\        /# r,   )r0   	bytearray)r2   s   "r3   r4   r4   g   s        #  )  r5   c                 *    \        \        V 4      4      # N)rW   rU   rC   s   &r3   
_bytearrayrZ   g   s    VAYr5   c                0    V ^8  d   QhR\         R\        /# r,   )r0   r   )r2   s   "r3   r4   r4   k   s     ! !S !T !r5   c                .    \         P                  ! V 4      # )z4Parse a date string.

Returns
-------
datetime.date
)r   fromisoformatrC   s   &r3   _dater^   k   s     a  r5   c                0    V ^8  d   QhR\         R\        /# r,   )r0   r   )r2   s   "r3   r4   r4   u   s     F F F Fr5   c                     \         P                  ! V 4      #   \         d9    \         P                  ! T P                  4       P	                  RR^4      4      u # i ; i)z<Parse a datetime string.

Returns
-------
datetime.datetime
 r&   )r   r]   
ValueErrorstripreplacerC   s   &r3   	_datetimere   u   sR    F%%a(( F %%aggi&7&7S!&DEE	Fs    A AAc                0    V ^8  d   QhR\         R\        /# r,   )r0   r   )r2   s   "r3   r4   r4      s     "& "&# "&) "&r5   c                F   RpV P                  R4      '       d   RpV R,          p \        P                  ! RV 4      pV'       g   \        RV  24      h^ pV F  w  rEp\	        V4      pVR8X  d   W5,          pK"  VR8X  d   W5^<,          ,          pK:  VR	8X  d   W5R
,          ,          pKR  VR8X  d   W5R,          ,          pKj  VR8X  d   W5R,          ,          pK  VR8X  d   W5R,          ,          pK  VR8X  g   K  W5R,          ,          pK  	  V'       d   V) p\        VR7      # )zParse a timedelta string.F-T   NNz((\d+\.\d+|\d+)([smhdwMy]))z!Could not parse duration string: r.   mhi  diQ wi:	 Mi ' r?   i3)seconds)rL   refindallrb   rN   r   )r.   negativematchesrp   _valueunits   &      r3   
_timedeltarx      s    H||CbEjj7;G<QC@AAG!$e3;GS[rz!GS[t|#GS[u}$GS[v~%GS[w&GS[x''G# "& (W%%r5   c                    V ^8  d   QhR\         \        ,          R\        R\        3,          R\        \        .\        3,          R\        /# )r-   type_tokenr%   name_transformr/   )typer'   r   r0   r   )r2   s   "r3   r4   r4      sH      7# cUCZ( 	r5   c                   ^ RI Hp \        W4      pV'       d   VP                  MTpV! V4      pV P                  P                  4        F  w  rxV! V4      V8X  g   K  Vu # 	  \        V'       d	   VV R7      hRV R7      h)ziMatch a token's value to an enum's member.

Applies ``name_transform`` to both the value and the member.
r$   Nr{   r8   )cyclopts.argumentr%   
isinstancerv   __members__itemsr   )	rz   r{   r|   r%   is_tokenrv   value_transformednamemembers	   &&&      r3   get_enum_memberr      s~     (%'H#EKKE&u-))//1$#44M 2 e %) r5   c                    V ^8  d   QhR\         \        ,          R\        \        ,          \        R,          ,          R\        \        .\        3,          R\        /# )r-   	enum_typetokensr%   r|   r/   )r}   r)   r   r0   r   )r2   s   "r3   r4   r4      sM      AwSMHW-- cUCZ( 	r5   c                ^   a a \        \        P                  V V3R lV 4       S ! ^ 4      4      # )a  Convert tokens to a Flag enum value.

Parameters
----------
enum_type : type[F]
    The Flag enum type to convert to.
tokens : Iterable[str] | Iterable[Token]
    The tokens to convert. Can be member names or :class:`Token` objects.
name_transform : Callable[[str], str] | None
    Function to transform names for comparison.

Returns
-------
F
    The combined flag value.

Raises
------
CoercionError
    If a token is not a valid flag member.
c              3   >   <"   T F  p\        SVS4      x  K  	  R # 5irY   )r   ).0r{   r   r|   s   & r3   	<genexpr>$convert_enum_flag.<locals>.<genexpr>   s     OuE>	:	:s   )r   operatoror_)r   r   r|   s   f&fr3   convert_enum_flagr      s(    4 OO! r5   c          
          V ^8  d   QhR\         \        ,          RRR\        \         \        .\        3,          R,          R\        \        .\        3,          R\        /# )r-   rz   r   r%   	converterNr|   r/   )r}   r   r   r0   tuple)r2   s   "r3   r4   r4      s\     ( (9(( sS()D0( cUCZ(	(
 (r5   c          
        aaa \        \        WR 7      o\        ;QJ d    . R \        V 4       4       F  NK  	  5M! R \        V 4       4       4      p\	        V 4      w  op\        S^4      oV'       d   \        V4      S,          pV'       d   \        RS R\        V4       R2R7      h\        V4      ^8X  d   V^ ,          oM"\        V4      ^ 8X  d   \        oM\        R4      h\        ;QJ d#    . VVV3R l\        VS4       4       F  NK  	  5# ! VVV3R l\        VS4       4       4      # S\        V4      8w  d   \        RS R\        V4       R2R7      hV Uu. uF  p\	        V4      ^ ,          NK  	  pp\        V4      p	V U
Uu. uF'  p
\        V
4       Uu. uF  p\        V	4      NK  	  upNK)  	  pp
pV Uu. uF  p\        V4      ^8X  d
   V^ ,          MTNK   	  pp\        ;QJ d"    . V3R	 l\        WLR
R7       4       F  NK  	  5M! V3R	 l\        WLR
R7       4       4      pV# u upi u upi u upp
i u upi )r   r|   c              3   4   "   T F  qR Jg   K
  Vx  K  	  R# 5i.N r   xs   & r3   r   !_convert_tuple.<locals>.<genexpr>   s     C?asl?s   
z4Incorrect number of arguments: expected multiple of z	 but got rK   )msgz%A tuple must have 0 or 1 inner-types.c              3   V   <"   T F  pS! SS^8X  d
   V^ ,          MT4      x  K   	  R# 5i)rj   Nr   )r   chunkconvertinner_token_count
inner_types   & r3   r   r     s0      
; J,=,BaNN;s   &)z(Incorrect number of arguments: expected c              3   8   <"   T F  w  rS! W4      x  K  	  R # 5irY   r   )r   r   argr   s   &  r3   r   r     s     lDkGJ,,Dks   F)strict)r   _convertr   r   token_countmaxlenr   r0   rb   r!   iterrangenextzip)rz   r   r|   r   inner_typesconsume_all	remainderr   args_per_convertitsizeru   batchedelemoutr   r   r   s   &$$*           @@@r3   _convert_tupler      s	    h)SG%C8E?C%%C8E?CCK%0%7"{-q1K"33	JK\J]]fgjkqgrfsstu  {q $QJ"JDEEu 
 ):;
u 	
u 
 ):;
 
 	
 F+>?P>QQZ[^_e[fZgghi  8CC{!KN1--{C&\?OP?OteDk2kDHk2?OPCJK74c$i1n47$67KelCejDkleelCejDkllJ D2PKs$   !H2H< H74H<$I7H<c                8    V ^8  d   QhR\         R\        RRRR/# )r-   datarz   r{   zToken | Noner/   N)dictr}   )r2   s   "r3   r4   r4     s0     #
 #

#
#
 #
 
	#
r5   c                   \        V4      p\        4       pVP                  4        F1  w  rVVP                  V4       VP	                  VP
                  4       K3  	  \        V P                  4       4      V,
          pV'       d\   \        V4      ^ ,          pRP                  \        VP                  4       4      4      p	\        RV RVP                   RV	 2VVR7      hR# )au  Validate that JSON data doesn't contain extra keys not in the type's fields.

Parameters
----------
data : dict
    The JSON dictionary to validate.
type_ : type
    The target type (dataclass, etc.) to validate against.
token : Token | None
    Optional token for error context.

Raises
------
CoercionError
    If the data contains keys not present in the type's fields.
z, zUnknown field "z" in JSON for z. Valid fields: )r   r8   r{   N)r   setr   addupdatenameskeyssortedjoinr   __name__)
r   rz   r{   field_infosvalid_names
field_name
field_info
extra_keys	extra_keyvalid_fieldss
   &&&       r3   _validate_json_extra_keysr     s    * "%(KEK"-"3"3"5

#:++, #6 TYY[!K/J:&q)	yy(8(8(:!;<!)N5>>:JJZ[gZhi
 	
 r5   c                    V ^8  d   QhR\         R\        R\        R\        R,          R\        \        .\        3,          /# )r-   rz   r   r   r   Nr|   )r   r   r   r0   )r2   s   "r3   r4   r4   ?  sI     .# .#.#
.# .# $	.#
 cUCZ(.#r5   c                   ^ RI Hp \        W4       / pVP                  4        F  w  rxWq9   g   K  W,          p	V	e   \	        VP
                  \        4      '       gc   T! \        V	\        \        ,          4      '       d   \        P                  ! V	4      M
\        V	4      R7      p
\        VP
                  V
.W44      pMT	pWV&   K  	  V ! R/ VB # )a  Convert JSON dict to dataclass with proper type conversion for fields.

Parameters
----------
type_ : Type
    The dataclass type to create.
data : dict
    The JSON dictionary containing field values.
field_infos : dict
    Field information from the dataclass.
converter : Callable | None
    Optional converter function.
name_transform : Callable[[str], str]
    Function to transform field names.

Returns
-------
Instance of type_ with properly converted field values.
r$   rv   r   )cyclopts.tokenr%   r   r   r#   hintr0   r   r   listjsondumpsr   )rz   r   r   r   r|   r%   converted_datar   r   rv   r{   converted_values   &&&&&       r3   _convert_jsonr   ?  s    4 % d*N"-"3"3"5
$E )>zPS)T)TE4RV;9W9WDJJu$5]`af]gh")*//E7I"^"')8:& #6 ">""r5   c                T    V ^8  d   QhRRR\         R\        P                  R\        /# )r-   r{   r%   rz   errorr/   )r   r   JSONDecodeErrorr0   )r2   s   "r3   r4   r4   p  s<     5k 5k5k5k 5k 		5kr5   c           	        V P                   P                  4       p\        VR4      '       d   VP                  M&\        VR4      '       d   VP                  ^,
          M^ p\        ^ V^,
          4      p\        \        V4      V^,           4      pW5V pV^ 8  d
   RV,           pV\        V4      8  d
   VR,           pWE,
          pV^ 8  d
   V^,          pRp	\        P                  ! RV4      '       d   Rp	MI\        P                  ! RV4      '       d   Rp	M)\        P                  ! R	V4      '       d   R
p	M	RV9   d   Rp	RVP                   RV RRV,           RVP                   V	 2	# )aW  Create a helpful error message for JSON decode errors.

Parameters
----------
token : Token
    The token containing the invalid JSON.
type_ : Type
    The target type we were trying to convert to.
error : json.JSONDecodeError
    The JSON decode error that occurred.

Returns
-------
str
    A formatted error message with context and hints.
poscolnoz... z\bTrue\bz8
    Hint: Use lowercase 'true' instead of Python's Truez	\bFalse\bz:
    Hint: Use lowercase 'false' instead of Python's Falsez\bNone\bz.
    Hint: Use 'null' instead of Python's None'z9
    Hint: JSON requires double quotes, not single quoteszInvalid JSON for z:
    z
    ra   z^ )rv   rc   hasattrr   r   r   minr   rq   searchr   r   )
r{   rz   r   	value_str	error_possnippet_startsnippet_endsnippet
marker_posr   s
   &&&       r3   !_create_json_decode_error_messager   p  sJ   * !!#I %UE22		7SXZaKbKbahiI 9r>*Mc)ni"n5Kk2G q'/S^#E/ *Jqa
 D	yyi((J	<	+	+L	;		*	*@			Ku~~.ggYfS:EUDVVXY^YbYbXcdhcijjr5   c                t    V ^8  d   QhR\         \        ,          R\        \        \        3,          R\        /# )r-   rz   r   r/   )r}   r&   r   r0   r   )r2   s   "r3   r4   r4     s-     *6 *6a *6S#X *61 *6r5   c                  a \        V 4      pV'       g	   V ! R/ VB # . p/ pVP                  4        FU  w  rVVP                  V4      pV'       d4   VP                  \        P
                  8X  d   VP                  WV34       KQ  WdV&   KW  	  \        VP                  4       4      oVP                  V3R lR7       V ! R V 4       / VB # )a  Instantiate a type with proper handling of parameter kinds.

Respects POSITIONAL_ONLY, KEYWORD_ONLY, and POSITIONAL_OR_KEYWORD parameter kinds
when constructing the object.

This function is necessary because `inspect.signature().bind(**data)` has the same
limitation we're solving: it cannot accept positional-only parameters as keyword
arguments. For example, `def __init__(self, a, /, b)` requires `a` to be passed
positionally, but when we have a dict `{"a": 1, "b": 2}`, we need to transform
this into the call `type_(1, b=2)`.

Parameters
----------
type_ : type[T]
    The type to instantiate.
data : dict[str, Any]
    Dictionary mapping field names to values.

Returns
-------
T
    Instance of type_ constructed from data.
c                 4   < SP                  V ^ ,          4      # )r   )index)r   field_names_orders   &r3   <lambda>'instantiate_from_dict.<locals>.<lambda>  s     1 7 7! =r5   )keyc              3   *   "   T F	  w  rVx  K  	  R # 5irY   r   )r   ru   vs   &  r3   r   (instantiate_from_dict.<locals>.<genexpr>  s     *1s   r   )
r   r   getkindr   POSITIONAL_ONLYappendr   r   sort)	rz   r   r   pos_argskwargsr   rv   r   r   s	   &&      @r3   instantiate_from_dictr     s    0 "%(K}t}HF!ZZ\
 __Z0
*//Y-F-FFOOZ/0!&: * [--/0MM=M>**5f55r5   c          
          V ^8  d   QhR\         \        ,          R\        R,          R\        \        R3,          R\
        R\        /# )r-   rz   r{   r%   r   r   r   r/   )r}   r&   r   r   r0   r   )r2   s   "r3   r4   r4     sM     =. =.7=.G=. c;&'=. 	=.
 =.r5   c                   ^ p/ pT pVP                  4        F  w  rxVP                  p\        V\        4      '       d   W,          P                  p	V^,          pRp
MH\        V4      w  rV^8X  d   V! WaV,          4      p	V^,          pMV! WaWDV,            4      p	WK,          pTp
WV&   V
'       d    MV\        V4      8X  g   K   M	  V\        V4      8X  g   Q h\        W4      # )a  Convert tokens to a structured type with proper positional/keyword argument handling.

Respects the parameter kind of each field:
- POSITIONAL_ONLY: passed as positional argument
- KEYWORD_ONLY or POSITIONAL_OR_KEYWORD: passed as keyword argument

This correctly handles types with keyword-only fields (e.g., dataclasses with kw_only=True).

Parameters
----------
type_ : type[T]
    The target structured type to instantiate.
token : Sequence[Token]
    The tokens to convert.
field_infos : dict[str, FieldInfo]
    Field information for the structured type.
convert : Callable
    Conversion function for nested types.

Returns
-------
T
    Instance of type_ constructed from the tokens.
F)r   r   r#   r0   rv   r   r   r   )rz   r{   r   r   ir   r   r   r   rv   should_breaktokens_per_elementr   s   &&&&         r3   _convert_structured_typer    s    < 	
ADD"-"3"3"5
 !s++HNNEFA L.9$.?+!Q&Ah/QA4F0F&GH'&L Z E
?1 #64 E
?? --r5   c                    V ^8  d   QhR\         R\        R,          3,          R\        \        \        .\        3,          R,          R\        \        .\        3,          /# )r-   r{   r%   r   Nr|   )r   r   r   r   r0   )r2   s   "r3   r4   r4     sY     J J(7++,J c
C(4/	J
 cUCZ(Jr5   c                 aaaa ^ RI Ho ^ RIHp Rp\	        V 4      '       dV   ^ RIHp VP                  V 4      w  p oSP                  '       d   RpV3R lpTpSP                  '       d   SP                  pMRo\        \        W#R7      o\        \        W#R7      p\        V 4      pV\        9   d   \        V,          p\        V 4      oV \        J d!   S! \        \        \        3,          V4      p	EMnV \         9   d   S! \         V ,          V4      p	EMMV \        9   d-   \        V ,          p
\         P#                  W4      pS! W4      p	EM\$        e,   \'        V \$        4      '       d   S! V P(                  V4      p	EM\+        V4      '       dO   S F   p\-        V4      '       d   K   S! W4      p	 EM	  \'        V\0        4      '       d   \2        h\5        WR7      hV\6        J du   Rp\        V 4       F!  p S! \9        V4      V4      pY8X  g   K  Tp	 EMJ	  V'       d	   Wn        Vh\5        \'        V\0        4      '       d   V^ ,          V R7      hTV R7      hV\<        J d-   \'        VS4      '       d   V! WVR	7      p	EMV! V .VO5R
V/ p	EMV\>        9   d   \A        S^ ,          4      w  pp\'        V\0        4      '       g   \2        hS^ ,          pV^8  dN   \B        ;QJ d    V3R lV 4       F  '       g   K   RM	  RM! V3R lV 4       4      '       d   V\        Jd   TpM&V^8  d   \E        \G        V4      .V,          RR/ pMTpV! VV3R lV 4       4      p	EM\I        V \J        4      '       d)   \M        T \'        V\0        4      '       d   TMV.V4      p	EM\I        V \N        4      '       dC   \'        V\0        4      '       d   \2        hVf   \Q        WV4      p	EMzV! WPR                  4      p	EMf\U        V 4      p\W        V 4      '       g	   V'       g   \'        VS4      '       g   Q h VPX                  \Z        Jd   VPX                  p	EMVf'   \\        P#                  W 4      ! VPR                  4      p	MV'       d
   V! W4      p	MV! WPR                  4      p	M\'        VS4      '       d   VPR                  Pa                  4       Pc                  R4      '       dW   V \        JdM    \d        Pf                  ! VPR                  4      p\'        V\        4      '       g   \h        h\k        V VVW#4      p	M&\'        V\0        4      '       g   V.p\q        WVS4      p	S'       d    SPr                   F  pV! W	4       K  	  V	# V	#   \.         d     EK  i ; i  \4         d   pTp Rp?EK  Rp?ii ; i  \4         d1   pTP:                  f   T Tn        TP^                  f   TTn/        h Rp?i\2         d    \5        YR7      Rhi ; i  \d        Pl                   d    p\o        YT4      p\5        TYR7      ThRp?i\h         d+    \'        T\0        4      '       g   T.p\q        YTS4      p	 ELi ; i  \t        \2        \h        3 d9   p\w        TPx                  '       d   TPx                  ^ ,          MRT	R7      ThRp?ii ; i)zInner recursive conversion function for public ``convert``.

Parameters
----------
converter: Callable
name_transform: Callable
r$   )	ParameterFTc                    < SP                   '       g   Q hSP                   p\        V\        4      '       d   \        W4      p\        P
                  ! V4      '       d
   V! V34      # V! W34      # rY   )r   r   r0   getattrinspectismethod)t_rv   resolved_convertercparams   && r3   converter_with_token&_convert.<locals>.converter_with_token.  sl    ''''' &,%5%5"0#66)0)H& ##$677-uh77 .b(;;r5   Nr   r   )r   r   c              3      <"   T FB  p\        VS4      ;'       d*    VP                  P                  4       P                  R 4      x  KD  	  R# 5i){N)r   rv   rc   rL   )r   r>   r%   s   & r3   r   _convert.<locals>.<genexpr>  s;     \V[QRJq%(LLQWW]]_-G-G-LLV[s
   A2Ar   c              3   D   <"   T F  pS! S^ ,          V4      x  K  	  R# 5i)r   Nr   )r   er   r   s   & r3   r   r    s     Bc'+a.!44cs    r  )r   r{   r8   r   )exception_messagerv   )=r   r%   cyclopts.parameterr  r   from_annotationr   r|   r   r   r   r   "_abstract_to_concrete_type_mappingr   r   r0   _implicit_iterable_type_mappingr   r   r   	__value__r   r   	Exceptionr   rb   r   r   r}   r8   r   r   r   anyr   r   r#   r
   r   r	   r   rv   r   r"   implicit_valuer   _convertersr{   rc   rL   r   loads	TypeErrorr   r   r   r  	validatorAssertionErrorr   args)rz   r{   r   r|   r  converter_needs_tokenr  convert_tupleorigin_typer   concrete_typedefault_paramr>   last_coercion_errorchoiceresr  countru   r   genr   r   r   r!  r%   r   r  r   s   &&$$                     @@@@r3   r   r     s    (,!E0!11%8v$(!<" -I   #22Nh)SGNi_MU#K 888E5/K}d38ne,	1	15e<eD	4	4 ;5A7;;MYm+		"z%'G'Geoou-	+		A1~~a'  %**  e??		"uoFd6lE2 } & #27/))#j6Q6Q%(joppW\jopp		eU##	BCCCCC		& {1~.q%** !^
AI\V[\\V[\\\#% CQYU}u,;U;CCBcBB	ud	+	+
5(0K0KuRWQXZhi	ud	+	+eX&&!%?CE;;/C%e, eKeU++++N''u4..C&%//%7DC*#E1C#E;;7C %''EKK,=,=,?,J,J3,O,OTYadTdW::ekk2D%dD11''t[)\C "%22"GE.u['R
	c#--	%% .
 J3Jw   ! &'#D ! ==($)AM77?#AG N#%CMN ++ X;E!LC'CuPVWW  W%eX66!&25gVC	W& 
I6 	c!AFF1IRWZ[abb	cs   *V:V6 V: )V: V: 
V: V: 2A
X ,Y9 VVV7)V22V7:X+W00X=XY6$X>>Y6'Y65Y69[3[[c          
         V ^8  d   QhR\         R\        \        ,          \        R,          ,          \        ,          R\        \
        \        .\         3,          R,          R\        \        .\        3,          R,          /# )r-   rz   r   r%   r   Nr|   )r   r   r0   r*   r   r}   )r2   s   "r3   r4   r4     sl     x6 x6x6SMHW--=x6 sS()D0x6 cUCZ(4/	x6r5   c                `  a ^ RI Ho V'       g   \        h\        V\        4      '       gP   \        V^ ,          \
        4      '       d3   \        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      pVf   \        p\        \        W#R7      p\        \        W#R7      p\        V 4      p V \        J d   \
        p \        P                  W 4      p V \        9   d#   \        V ,          p\        P                  Wf4      p \!        V 4      pV\        9   d   \        V,          pT;'       g    T pV\        J d   V! V .VO5!  # V\"        9   d	   V! W4      # V\        J dz   \        V\        4      '       g   \        h \%        V 4      ^,          p	VP)                  4        U
Uu/ uF  w  rV
\+        WW#R7      bK  	  pp
p\,        P                  W4      ! R/ VB # \        V\        4      '       d   \        RV : R24      h\/        V4      '       d   \1        WV4      # \3        V4      ^8X  d   V! W^ ,          4      # \5        V 4      w  rV^8X  d   V Uu. uF
  q! W4      NK  	  up# \3        V4      V8X  d	   V! W4      # \7        R4      h  \&         d    \
        p	 ELi ; iu upp
i u upi )aT  Coerce variables into a specified type.

Internally used to coercing string CLI tokens into python builtin types.
Externally, may be useful in a custom converter.
See Cyclopt's automatic coercion rules :doc:`/rules`.

If ``type_`` **is not** iterable, then each element of ``tokens`` will be converted independently.
If there is more than one element, then the return type will be a ``Tuple[type_, ...]``.
If there is a single element, then the return type will be ``type_``.

If ``type_`` **is** iterable, then all elements of ``tokens`` will be collated.

Parameters
----------
type_: Type
    A type hint/annotation to coerce ``*args`` into.
tokens: Union[Sequence[str], NestedCliArgs]
    String tokens to coerce.
    Generally, either a list of strings, or a dictionary of list of strings (recursive).
    Each leaf in the dictionary tree should be a list of strings.
converter: Optional[Callable[[Type, str], Any]]
    An optional function to convert tokens to the inner-most types.
    The converter should have signature:

    .. code-block:: python

        def converter(type_: type, value: str) -> Any:
            "Perform conversion of string token."

    This allows to use the :func:`convert` function to handle the the difficult task
    of traversing lists/tuples/unions/etc, while leaving the final conversion logic to
    the caller.
name_transform: Optional[Callable[[str], str]]
    Currently only used for ``Enum`` type hints.
    A function that transforms enum names and CLI values into a normalized format.

    The function should have signature:

    .. code-block:: python

        def name_transform(s: str) -> str:
            "Perform name transform."

    where the returned value is the name to be used on the CLI.

    If ``None``, defaults to ``cyclopts.default_name_transform``.

Returns
-------
Any
    Coerced version of input ``*args``.
r$   c              3   H   <"   T F  pS! \        V4      R 7      x  K  	  R# 5i)r   N)r0   )r   r   r%   s   & r3   r   convert.<locals>.<genexpr>"  s     ;Fqu3q6**Fs   "r   z*Dictionary of tokens provided for unknown rK   zUnreachable?r   )r   r%   rb   r   r   r0   r   r    r   r   r   r   r   r  r   r  r   r   r   
IndexErrorr   r   r  r   r   r   r   NotImplementedError)rz   r   r   r|   convert_privr%  r'  r&  maybe_origin_type
value_typekr   dict_convertedr  ru   itemr%   s   &&&&            @r3   r   r     s^   t (fd##
6!9c(B(B;F;;F;;/8yXLNi_MENE|+//=E 22:5A/33MQU#K888E#,,ueU,V,,	n	,E**	d	"&$''	!%+J gmfrfrft
ft^b^_Awz	YYft 	 
 0DV~VV	FD	!	!EeYaPQQ	'	(	( !!2NKKv;!ay11 +E 2":@A&$L-&AA[....%n55+  	J	
 Bs   J &J%J+J"!J"c                ^    V ^8  d   QhR\         R\        R\        \        \        3,          /# )r-   rz   skip_converter_paramsr/   )r   r1   r   rF   )r2   s   "r3   r4   r4   ]  s/     d" d"s d"4 d"E#t)DT d"r5   c                   ^ RI Hp V! WR7      w  r4V FM  pVP                  f   K  VP                  R
8X  d   Ru # W0Jd   \        VRR7      w  rgMRpVP                  V3u # 	  Tp \	        V 4      pV\
        9   d   \
        V,          pV \
        9   d.   \
        V ,          p	\        P                  W4      p \	        V 4      pT;'       g    T \        J d-   \        V 4      p
V
'       d   \        R V
 4       4      RV
9   3# R# T;'       g    T \        J d   R# V \        9   g%   V\        9   d   \        \        V 4      4      ^ 8X  d   R# \        V 4      '       d   R# V\        9   d?   \        \        V 4      4      '       d%   \        \        V 4      ^ ,          4      ^ ,          R3# \        e,   \!        V \        4      '       d   \        V P"                  4      # \%        V 4      '       dY   \        V 4      p\        V^ ,          4      pVR,           F,  p\        V4      pW8w  g   K  \'        RV^ ,           R	V 24      h	  V# \)        V 4      '       d   R# \+        V 4      p^ RppVP-                  4        F^  pVP.                  VP0                  J d   RpMVP2                  '       g   K4  \        VP4                  4      w  ppVV,          pVV,          pK`  	  V'       g   R# VV3# )aC  The number of tokens after a keyword the parameter should consume.

Parameters
----------
type_: Type
    A type hint/annotation to infer token_count from if not explicitly specified.
skip_converter_params: bool
    If True, don't extract converter parameters from __cyclopts__.
    Used to prevent infinite recursion when determining consume_all behavior.

Returns
-------
int
    Number of tokens to consume.
bool
    If this is ``True`` and positional, consume all remaining tokens.
    The returned number of tokens constitutes a single element of the iterable-to-be-parsed.
)get_parameters)r;  TFc              3   T   "   T F  qR Jg   K
  \        V4      ^ ,          x  K   	  R# 5ir   )r   r   s   & r3   r   token_count.<locals>.<genexpr>  s#     G$Q3,({1~a(($s   ((.ri   z=Cannot Union types that consume different numbers of tokens: ra   )rj   T)r   F)rj   F)r  r=  n_tokensr   r   r  r  r   r   r   sumr1   r   r   r   r   r   r  r   rb   r"   r   valuesr   VAR_POSITIONALrequiredr   )rz   r;  r=  resolved_type
parametersparamru   consume_all_from_typer&  r'  r#  sub_argstoken_count_target	sub_type_thisr   r,  r   rv   
elem_countelem_consume_alls   &&                   r3   r   r   ]  s   * 2 .u bM>>%~~#
 !- 0;=`d/e,A, -2)~~'<<<! $ EU#K888E 22:5A/33MQ 'u&G$GGPTTTN


4	'	.	 [N%Bs8TY?G[_`G`	e				&3x+?+?8E?1-.q1477		"z%'G'G5??++	%E?(!5!"Iy)D) ST\]^T_S``abkalm  & "!	E		 &e,{ '')EzzU111"^^^+6uzz+B(J(ZE++K * Ok!!r5   c                    V ^8  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   ^\         9   d   \        \        \        3,          ;R&   ^\         9   d   \        \        \        3,          ;R&   # )r-   r  r  r  )__conditional_annotations__r   r}   r   r   )r2   s   "r3   r4   r4      sk      \ dDj!1 ] p	 	Dt$4 	q D T#x-  E r5   )      rY   )NN)F)]rQ  collections.abccollectionsr	  r   r   rq   systypingr   r   r   r   r   r   enumr	   r
   	functoolsr   r   r   r   r   r   r   r   r   version_infor   cyclopts.annotationsr   r   r   r   r   r   cyclopts.exceptionsr   r   cyclopts.field_infor   r   cyclopts.utilsr   r    r!   r"   r#   r   r%   r&   r'   r)   	frozensetr0   r   r   r   r   r  abcSet
MutableSetMutableSequenceMappingMutableMappingr  r*   rD   rO   rU   rZ   r^   re   rx   r   r   r1   rF   rQ   rW   r  r   r   r   r   r   r  r   r   r   r4   )rQ  s   @r3   <module>rf     s        	 
  8 8 . .  %   w$M k k > : d dw$M' CLCtCt
 y~$s)S	5c?$sCx.5   d
OOTdOOOOOO##TOOTOO""D	8 " 	 S% >??@."% !F "&J.F 	%	6z%iz$ (V#
L.#b5kp*6Z=.@JZx6vd" d"r5   