
    !<i                     t   U 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	m
Z
 d dlmZmZmZ d dlmZmZ d dlmZmZ d dlmZmZmZmZmZmZmZ ej        dk    rd dlmZ ndZd d	lmZmZm Z m!Z!m"Z" d d
l#m$Z$m%Z% d dl&m'Z'm(Z( d dl)m*Z*m+Z+m,Z,m-Z-m.Z. ej        dk    rd dlmZ ndZerd dl/m0Z0  ed          Z1 ede          Z2 ede          Z3e4e4e5         e6e6e5         e7e7e5         e8e8e5df         e9e9e5e5f         iZ:e9e;e;f         e<d<   e	e6ej
        e6e
e6ej=        j>        e7ej=        j?        e7ej=        j@        e6ej=        jA        e9ej=        jB        e9iZCe9e;e;f         e<d<   e	ej
        e
e4e6e7e8hZDe9e5ee
e5         df         f         ZEde5deFfdZGde5deHfdZIde5deJfdZKde5deLfdZMde5defdZNde5defdZOde5defdZPde;e2         d ed!e5f         d"ee5ge5f         de2fd#ZQd$e;e3         d%e	e5         e	d!         z  d"ee5ge5f         de3fd&ZReFeGeHeIeJeKeLeMeeNeeOeePiZSe9eef         e<d'<   de;e         d%d!d(ee;e5gef         dz  d"ee5ge5f         de8f
d)ZTded*e9d+e9d(edz  d"ee5ge5f         f
d,ZUd d!ded-ejV        de5fd.ZWde;e1         d*e9e5ef         de1fd/ZXde;e1         d e
d!         d+e9e5d0f         d1ede1f
d2ZYd ed!e
d!         f         d(eee5gef         dz  d"ee5ge5f         fd3ZZ	 	 d8ded%e
e5         e
d!         z  eEz  d(ee;e5gef         dz  d"ee5ge5f         dz  fd4Z[d9ded6eFde8eHeFf         fd7Z\dS ):    N)CallableIterableSequence)datedatetime	timedelta)EnumFlag)partialreduce)TYPE_CHECKINGAnyLiteralTypeVarUnionget_args
get_origin)      )TypeAliasType)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._implicit_iterable_type_mapping"_abstract_to_concrete_type_mappingNestedCliArgssreturnc                 l    |                                  } | dv rdS | dv rdS t          t                    )N>   0fnnofalseF>   1tyyestrueT)target_type)lowerr   boolr.   s    /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/cyclopts/_convert.py_boolr@   Q   sD    			A***u	
,	,	,t ----    c                    |                                  } |                     d          rt          | d          S |                     d          rt          | d          S |                     d          rt          | d          S d| v r)t          t          t	          |                               S t          |           S )N0x   0o   0b   .)r<   
startswithintroundfloatr>   s    r?   _intrN   \   s    			A||D 1bzz	
d		 
1ayy	
d		 1ayy	 5q??###1vvrA   c                 $    t          | d          S )Nutf8)encoding)bytesr>   s    r?   _bytesrS   m   s    V$$$$rA   c                 :    t          t          |                     S N)	bytearrayrS   r>   s    r?   
_bytearrayrW   q   s    VAYYrA   c                 *    t          j        |           S )zDParse a date string.

    Returns
    -------
    datetime.date
    )r   fromisoformatr>   s    r?   _daterZ   u   s     a   rA   c                     	 t          j        |           S # t          $ r> t          j        |                                                     ddd                    cY S w xY w)zLParse a datetime string.

    Returns
    -------
    datetime.datetime
     r'      )r   rY   
ValueErrorstripreplacer>   s    r?   	_datetimera      sk    F%a((( F F F %aggii&7&7S!&D&DEEEEE	Fs    AAAc                    d}|                      d          rd}| dd         } t          j        d|           }|st          d|            d}|D ]z\  }}}t	          |          }|d	k    r||z  }!|d
k    r	||dz  z  }0|dk    r	||dz  z  }?|dk    r	||dz  z  }N|dk    r	||dz  z  }]|dk    r	||dz  z  }l|dk    r||dz  z  }{|r| }t          |          S )zParse a timedelta string.F-Tr]   Nz((\d+\.\d+|\d+)([smhdwMy]))z!Could not parse duration string: r   r.   m<   hi  diQ wi:	 Mi ' r8   i3)seconds)rJ   refindallr^   rM   r   )r.   negativematchesrj   _valueunits          r?   
_timedeltarr      sO   H||C abbEj7;;G B@Q@@AAAG! ( (5$e3;;uGGS[[urz!GGS[[ut|#GGS[[uu}$GGS[[uv~%GGS[[uw&GGS[[ux''G (W%%%%rA   type_tokenr&   name_transformc                     ddl m} t          ||          }|r|j        n|} ||          }| j                                        D ]\  }} ||          |k    r|c S t          |r|nd|           )zqMatch a token's value to an enum's member.

    Applies ``name_transform`` to both the value and the member.
    r   r%   Nrt   r;   )cyclopts.argumentr&   
isinstancerp   __members__itemsr   )	rs   rt   ru   r&   is_tokenrp   value_transformednamemembers	            r?   get_enum_memberr      s     ('''''%''H#.EKKE&u--)//11  f>$#444MMM 5
)eeT   rA   	enum_typetokensc                 h     t          t          j         fd|D               d                    S )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   :   K   | ]}t          |          V  d S rU   )r   ).0rt   r   ru   s     r?   	<genexpr>z$convert_enum_flag.<locals>.<genexpr>   s/      OOuE>	:	:OOOOOOrA   r   )r   operatoror_)r   r   ru   s   ` `r?   convert_enum_flagr      sB    4 OOOOOOOO	!  rA   _converters	converterc                P  
 t          t          ||          
t          d t          |           D                       }t	          |           \  }t          d          |rt          |          z  }|r$t          d dt          |           d          t          |          dk    r	|d         n*t          |          dk    rt          nt          d	          t          
fd
t          |          D                       S t          |          k    r$t          d dt          |           d          d |D             }t          |          fd|D             }d |D             }t          
fdt          ||d          D                       }	|	S )Nr   ru   c              3   "   K   | ]
}|d u|V  dS ).N r   xs     r?   r   z!_convert_tuple.<locals>.<genexpr>   s&      CCaasllllllCCrA   r]   z4Incorrect number of arguments: expected multiple of z	 but got rI   )msgr   z%A tuple must have 0 or 1 inner-types.c              3   L   K   | ]} d k    r|d         n|          V  dS )r]   r   Nr   )r   chunkconvertinner_token_count
inner_types     r?   r   z!_convert_tuple.<locals>.<genexpr>  sV       
 
 GJ,=,B,BaNN
 
 
 
 
 
rA   z(Incorrect number of arguments: expected c                 8    g | ]}t          |          d          S )r   token_countr   s     r?   
<listcomp>z"_convert_tuple.<locals>.<listcomp>  s#    CCC!KNN1-CCCrA   c                 F    g | ]}fd t          |          D             S )c                 .    g | ]}t                    S r   )next)r   ro   its     r?   r   z-_convert_tuple.<locals>.<listcomp>.<listcomp>  s    222DHH222rA   )range)r   sizer   s     r?   r   z"_convert_tuple.<locals>.<listcomp>  s4    PPPt2222eDkk222PPPrA   c                 H    g | ]}t          |          d k    r|d         n| S )r]   r   )len)r   elems     r?   r   z"_convert_tuple.<locals>.<listcomp>  s.    KKK4c$ii1nn477$KKKrA   c              3   6   K   | ]\  }} ||          V  d S rU   r   )r   r   argr   s      r?   r   z!_convert_tuple.<locals>.<genexpr>  s3      llSGGJ,,llllllrA   F)strict)r   _converttupler   r   maxr   r   strr^   r"   iterzip)rs   r   ru   r   inner_typesconsume_all	remainderargs_per_convertbatchedoutr   r   r   r   s             @@@@r?   _convert_tupler      s$    h)NSSSGCC8E??CCCCCK%0%7%7"{-q11 mKK"33	 	uK\uugjkqgrgruuu    {q  $QJJ""JJDEEE 
 
 
 
 
 
 ):;;
 
 
 
 
 	
 F++i?Pii[^_e[f[fiii    DC{CCC&\\PPPP?OPPPKK7KKKllllCU\ejDkDkDklllllJrA   datafield_infosc                 z   ddl m} i }|                                D ]\  }}||v r||         }	|	}t          |j        t
                    sc |t          |	t          t          z            rt          j
        |	          nt          |	                    }
t          |j        |
g||          }n|	}|||<    | di |S )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   r%   Nrp   r   )cyclopts.tokenr&   r{   r$   hintr   ry   dictlistjsondumpsr   )rs   r   r   r   ru   r&   converted_data
field_name
field_inforp   rt   converted_values               r?   _convert_jsonr   #  s    4 %$$$$$N"-"3"3"5"5 9 9
J$E )>zPS)T)T E4RV;9W9W$gDJu$5$5$5]`af]g]ghhh")*/E7I~"^"^"')8N:& 5"">"""rA   errorc           	      T   | j                                         }t          |d          r|j        nt          |d          r
|j        dz
  nd}t          d|dz
            }t          t          |          |dz             }|||         }|dk    rd|z   }|t          |          k     r|dz   }||z
  }|dk    r|dz  }d}	t          j	        d	|          rd
}	n6t          j	        d|          rd}	nt          j	        d|          rd}	nd|v rd}	d|j
         d| dd|z   d|j         |	 	S )a  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colnor]   r      z...r    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
    r\   z^ )rp   r_   hasattrr   r   r   minr   rk   search__name__r   )
rt   rs   r   	value_str	error_possnippet_startsnippet_endsnippet
marker_posr   s
             r?   !_create_json_decode_error_messager   Q  s~   * !!##I %UE22i		7SXZaKbKb8iahiI 9r>**Mc)nni"n55Kk12G q'/S^^##E/ ]*Jqa
 D	yi(( LJ	<	+	+ LL	;		*	* L@				Kju~jjgjjS:EUjjY^YbjdhjjjrA   c                    t          |           }|s | di |S g }i }|                                D ]N\  }}|                    |          }|r-|j        t          j        k    r|                    ||f           I|||<   Ot          |                                          |	                    fd            | d |D             i |S )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                 :                         | d                   S )Nr   )index)r   field_names_orders    r?   <lambda>z'instantiate_from_dict.<locals>.<lambda>  s     1 7 7! = = rA   )keyc              3       K   | ]	\  }}|V  
d S rU   r   )r   ro   vs      r?   r   z(instantiate_from_dict.<locals>.<genexpr>  s&      **A1******rA   r   )
r   r{   getkindr   POSITIONAL_ONLYappendr   keyssort)	rs   r   r   pos_argskwargsr   rp   r   r   s	           @r?   instantiate_from_dictr     s    0 "%((K u}}t}}HF!ZZ\\ ' '
E __Z00
 	'*/Y-FFFOOZ/0000!&F: [--//00MM====M>>>5*****5f555rA   r   r   c                    d}i }| }|                                 D ]\  }}|j        }t          |t                    r||         j        }	|dz  }d}
nNt          |          \  }}|dk    r ||||                   }	|dz  }n ||||||z                      }	||z  }|}
|	||<   |
r n|t          |          k    r n|t          |          k    sJ t          | |          S )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.
    r   r]   F)r{   r   r$   r   rp   r   r   r   )rs   rt   r   r   ir   r   r   r   rp   should_breaktokens_per_elementr   s                r?   _convert_structured_typer     s/   < 	
ADD"-"3"3"5"5  
J !s++ 	'!HNEFA LL.9$.?.?+!Q&&eAh//QeA4F0F,F&GHH''&L Z  	EE

??E  E

???? ---rA   c                   ddl m ddlm} d}t	          |           r=ddlm} |                    |           \  } j        r	d}fd}|}j        rj        }ndt          t          ||          t          t          ||          }t          |           }|t          v rt          |         }t          |           | t          u r% t          t          t          f         |          }	n"| t           v r t           |          |          }	n | t          v r6t          |          }
t                               |
|
          } ||          }	nt$          (t'          | t$                    r | j        |          }	nt+          |          rbD ]0}t-          |          r	  ||          }	 n=# t.          $ r Y -w xY wt'          |t0                    rt2          t5          || 	          n!|t6          u rd}t          |           D ]@}	  t9          |          |          }n# t4          $ r}|}Y d}~.d}~ww xY w||k    r|}	 n:A|r	| |_        |t5          t'          |t0                    r|d         n|| 	          n|t<          u r.t'          |          r || ||
          }	nb || g|R d|i}	nT|t>          v rtA          d                   \  }}t'          |t0                    st2          d         }|dk    r'tC          fd|D                       r|t          ur|}n&|dk    rtE          tG          |          g|z  ddi}n|} |fd|D                       }	ntI          | tJ                    r+tM          | t'          |t0                    r|n|g|          }	nbtI          | tN                    rDt'          |t0                    rt2          |tQ          | ||          }	n || |j)                  }	n	tU          |           }tW          |           s|st'          |          sJ 	 |j,        tZ          ur|j,        }	nK|)t]                              | |           |j)                  }	n |r || |          }	n || |j)                  }	ns# t4          $ r"}|j        | |_        |j/        ||_/         d}~wt2          $ r t5          || 	          dw xY wt'          |          r|j)        0                                1                    d          r| t          ur	 te          j3        |j)                  }t'          |t                    sth          tk          | ||||          }	n# td          j6        $ r)}to          || |          }t5          |||           |d}~wth          $ r- t'          |t0                    s|g}tq          | ||          }	Y n.w xY wt'          |t0                    s|g}tq          | ||          }	r]	 j9        D ]} || |	           nE# tt          t2          th          f$ r+}tw          |j<        r|j<        d         nd|	          |d}~ww xY w|	S )zInner recursive conversion function for public ``convert``.

    Parameters
    ----------
    converter: Callable
    name_transform: Callable
    r   r%   )	ParameterFTc                     j         sJ j         }t          |t                    rt          | |          }t	          j        |          r ||f          S  || |f          S rU   )r   ry   r   getattrinspectismethod)t_rp   resolved_convertercparams      r?   converter_with_tokenz&_convert.<locals>.converter_with_token  s    '''' &,%5"0#66 I)05G)H)H& #$677 <--uh777 .-b5(;;;rA   Nr   rw   )r   r   r]   c              3      K   | ]@}t          |          o+|j                                                            d           V  AdS ){N)ry   rp   r_   rJ   )r   r7   r&   s     r?   r   z_convert.<locals>.<genexpr>n  sK      \\QRJq%((LQW]]__-G-G-L-L\\\\\\rA   r   c              3   <   K   | ]} d          |          V  dS )r   Nr   )r   er   r   s     r?   r   z_convert.<locals>.<genexpr>w  s3      BB''+a.!44BBBBBBrA   r   )r   rt   r;   r   )exception_messagerp   )=rx   r&   cyclopts.parameterr   r   from_annotationr   ru   r   r   r   r   r,   r   r   r   r+   r   r   ry   	__value__r   r   	Exceptionr   r^   r   r   typer;   r   ITERABLE_TYPESr   anyr   r   r$   r
   r   r	   r   rp   r   r#   implicit_valuer    r   rt   r_   rJ   r   loads	TypeErrorr   JSONDecodeErrorr   r   	validatorAssertionErrorr   args)rs   rt   r   ru   r   converter_needs_tokenr   convert_tupleorigin_typer   concrete_typedefault_paramr7   last_coercion_errorchoiceresr   countro   r   genr   r   r   r  r&   r   r   r   s                            @@@@r?   r   r     s	    (''''',,,,,,!E 000000!11%88v 	-$(!< < < < <" -I  	3#2Nh)NSSSGNiP^___MU##K 8888E5//K}}gd38ne,,	1	1	1g5e<eDD	4	4	4 ;5A7;;M=YYgmU++		"z%'G'G	"geou--	+		 uS 	@ 	@A1~~ ga''    %** !  e????  
		"uoo 	q 	qFgd6llE22    &'# f}}  # q27#/))#j6Q6Q*\%((W\jopppp  
		eU## 	D-u	BBBCC-CCCCCCCC		&	& {1~..q%** 	 !^
AII\\\\V[\\\\\ #%% CCQYYU}u,;U;;CCCkBBBBBcBBBBB	ud	+	+ ;S
5(0K0K'XuuRWQXZhii	ud	+	+ 8SeX&& 	!%??CC)E5;//CC%e,, e +	SK +	SeU+++++N'u44.CC&%//%77DDCC* 8#)E511CC#)E5;77C    =($)AM7?#AG N N N#%UCCCMN
 %'' SEK,=,=,?,?,J,J3,O,O STYadTdTdW:ek22D%dD11 (''t[)^\\CC+ X X X;E5!LLC'Cu%PPPVWW  W W W%eX66 (!&25%gVVCCC	W "%22 $"GE.ue['RR 	c
	c#- & &		%%%%%&
I6 	c 	c 	c!4OAF1IIRWZ[[[abb	c Jsz   %F33
G ?G H))
H?3H::H?=A!R   
S'*S S'0AU9 9W&$V,,7W&%W&X- -Y/&Y**Y/c                 T    ddl m |st          t          |t                    s6t          |d         t
                    rt          fd|D                       }t          t          t                    t          t                    }t                       t          u rt
           t                                            t          v r(t                    }t                              ||           t!                     }|t          v rt          |         }|p }|t          u r	 | g|R  S |t"          v r  |          S |t          u rt          |t                    st          	 t%                     d         n# t&          $ r
 t
          Y nw xY wfd|                                D             }t+                              ||          di |S t          |t                    rt          d d	          t-          |          rt/          ||          S t1          |          dk    r  |d                   S t3                     \  }	}
|	dk    r fd
|D             S t1          |          |	k    r  |          S t5          d          )a  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   r%   c              3   J   K   | ]} t          |                     V  dS )r   N)r   )r   r   r&   s     r?   r   zconvert.<locals>.<genexpr>  s6      ;;quu3q66***;;;;;;rA   Nr   r]   c           	      >    i | ]\  }}|t          |           S )r   )r   )r   kr   r   ru   
value_types      r?   
<dictcomp>zconvert.<locals>.<dictcomp>(  s?     
 
 
^b^_abAwz1	.YYY
 
 
rA   z*Dictionary of tokens provided for unknown rI   c                 (    g | ]} |          S r   r   )r   itemconvert_privrs   s     r?   r   zconvert.<locals>.<listcomp>7  s%    AAA$LL--AAArA   zUnreachable?r   )rx   r&   r^   ry   r   r   r   r!   r   r   r   r   r   r+   r   r,   r   r   r   
IndexErrorr{   r   r   r   r   r   NotImplementedError)rs   r   r   ru   r
  r  r  maybe_origin_typedict_convertedr   ro   r&   r  r  s   ` ``       @@@r?   r   r     s   t (''''' fd## <
6!9c(B(B <;;;;F;;;;;/8yXXXLNiP^___MENNE||+//u==E 222:5A/33M=QQU##K8888E#,ue}U,V,,,,	n	,	,|E6***	d	"	"&$'' 		!%+JJ 	 	 	JJJ	
 
 
 
 
 
flfrfrftft
 
 
 02CDDVV~VVV	FD	!	! 6PePPPQQQ	'	(	( 6 !!2FNKKKv;;!<vay111 +E 2 2A""AAAAA&AAAA[[...<v...%n555s   9F F#"F#Fskip_converter_paramsc                 t   ddl m}  || |          \  }}|D ]=}|j        4|j        dk    r dS || urt          |d          \  }}nd}|j        |fc S >|} t	          |           }|t
          v rt
          |         }| t
          v r7t
          |          }	t                              |	|	          } t	          |           }|p| t          u r0t          |           }
|
rt          d	 |
D                       d
|
v fS dS |p| t          u rdS | t          v s)|t          v r"t          t          |                     dk    rdS t          |           rdS |t          v rFt          t          |                     r*t          t          |           d                   d         dfS t          )t!          | t                    rt          | j                  S t%          |           rct          |           }t          |d                   }|dd         D ]2}t          |          }||k    rt'          d|d          d|           3|S t)          |           rdS t+          |           }d\  }}|                                D ]<}|j        |j        u rd}n|j        st          |j                  \  }}||z  }||z  }=|sdS ||fS )a  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.
    r   )get_parameters)r   N)r]   TTFc              3   H   K   | ]}|d ut          |          d         V  dS ).r   Nr   r   s     r?   r   ztoken_count.<locals>.<genexpr>w  s1      GGQ!3,,{1~~a(,,,,GGrA   .)r   Fr]   z=Cannot Union types that consume different numbers of tokens: r\   )r]   F)r   r"  n_tokensr   r   r,   r+   r   r   r   sumr=   r   r   r   r   ry   r   r   r^   r#   r   valuesr   VAR_POSITIONALrequiredr   )rs   r   r"  resolved_type
parametersparamro   consume_all_from_typer  r  r  sub_argstoken_count_target	sub_type_thisr   r  r   rp   
elem_countelem_consume_alls                        r?   r   r   >  sf   * 211111 .uLa b b bM: = =>%~##ww
 !-- 0;=`d/e/e/e,A,, -2)~'<<<<< &" EU##K8888E 222:5A/33M=QQ ''u&& 	GG$GGGGGPTTT7

4	'	'x	.	 	 [N%B%Bs8TY??G[G[_`G`G`w	e		 $"w		&	&3x+?+?	&8E??1-..q1477		"z%'G'G	"5?+++	% "E??(!55!!"" 	 	Iy))D))) mT\]^T_mmbkmm   * "!	E		 "x &e,,%{ '')) 	, 	,EzU111"^ +6uz+B+B(J(ZE++KK  	8k!!rA   )NN)F)]collections.abccollectionsr   r   r   rk   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   cyclopts.exceptionsr   r   cyclopts.field_infor   r   cyclopts.utilsr    r!   r"   r#   r$   rx   r&   r'   r(   r*   	frozensetr   r   setr   r   r+   r   __annotations__abcSet
MutableSetMutableSequenceMappingMutableMappingr,   r   r-   r=   r@   rK   rN   rR   rS   rV   rW   rZ   ra   rr   r   r   r   r   r   r  r   r   r   r   r   r   r   rA   r?   <module>rH     s           				 



  8 8 8 8 8 8 8 8 8 8 . . . . . . . . . .         % % % % % % % %                  w$$$$$$$M [ [ [ [ [ [ [ [ [ [ [ [ [ [ > > > > > > > > : : : : : : : : d d d d d d d d d d d d d dw$$$$$$$M ('''''' GCLLGCtGCt
 y~$s)S	5c?$sCx.5 dDj!1    d
OTdOOO#TOTO"D	8 "Dt$4 	 	 	 
O	 S% >??@.S .T . . . .C C    "%c %e % % % % #  )        !S !T ! ! ! !F F F F F F "&# "&) "& "& "& "&J7# cUCZ( 	   .AwSMHW-- cUCZ( 	   F 	%	6z%iz$T#x-    (9(( sS()D0( cUCZ(	(
 ( ( ( (V+#+#
+# +# $	+#
 cUCZ(+# +# +# +#\5k5k5k 5k 		5k 5k 5k 5kp*6a *6S#X *61 *6 *6 *6 *6Z=.7=.G=. c;&'=. 	=.
 =. =. =. =.@J(7++,J c
C(4/	J
 cUCZ(J J J J` 4826	x6 x6x6SMHW--=x6 sS()D0x6 cUCZ(4/	x6 x6 x6 x6vd" d"s d"4 d"E#t)DT d" d" d" d" d" d"rA   