
    ̺i                        S SK Jr  S SKrS SKJrJrJrJr  S SKJ	r	  S SK
r
SSKJr  \S   r1 Skr    SS	 jr    SS
 jrg)    )annotationsN)AnyLiteralOptionalcast)assert_never   )is_list)objectarraystringintegernumberbooleannull>
   uridateipv4ipv6timeuuidemaildurationhostname	date-timec                F    U R                  S5      S:X  a  SU ;  a  SU S'   U $ )a9  Transforms a JSON schema of type string to ensure it conforms to the API's expectations.

Specifically, it ensures that if the schema is of type "string" and does not already
specify a "format", it sets the format to "text".

Args:
    schema: The original JSON schema.

Returns:
    The transformed JSON schema.
typer   formattext)get)schemas    ^/var/www/piano.thomer.com/venv/lib/python3.13/site-packages/anthropic/lib/_parse/_transform.pyget_transformed_stringr#   #   s+     zz&X%(&*@!xM    c           	        [         R                  " U 5      (       a/  [        U [        R                  5      (       a  U R                  5       n 0 n0 U En U R                  SS5      nUb  X!S'   U$ U R                  SS5      nUb,  0 nXAS'   UR                  5        H  u  pV[        U5      XE'   M     U R                  SS5      nU R                  SS5      nU R                  SS5      n	U R                  SS5      n
[        U5      (       a*  U Vs/ s H  n[        [        SU5      5      PM     snUS'   O[        U	5      (       a*  U	 Vs/ s H  n[        [        SU5      5      PM     snUS'   OL[        U
5      (       a*  U
 Vs/ s H  n[        [        SU5      5      PM     snUS'   OUc  [        S	5      eXqS'   U R                  S
S5      nUb  XS
'   U R                  SS5      nUb  XS'   US:X  at  U R                  S0 5      R                  5        VVs0 s H  u  pU[        U5      _M     snnUS'   U R                  SS5        SUS'   U R                  SS5      nUb  UUS'   OUS:X  a6  U R                  SS5      nU(       a  U[        ;   a  UUS'   OU(       a  UU S'   OUS:X  aS  U R                  SS5      nUb  [        U5      US'   U R                  SS5      nUb  US:X  d  US:X  a  UUS'   O0Ub  UU S'   O'US:X  d  US:X  d  US:X  d	  US:X  d  Uc  O[        U5        U (       aK  UR                  S
5      nUb  US-   OSS-   SR                  S  U R                  5        5       5      -   S!-   US
'   U$ s  snf s  snf s  snf s  snnf )"a  
    Transforms a JSON schema to ensure it conforms to the API's expectations.

    Args:
        json_schema (Dict[str, Any]): The original JSON schema.

    Returns:
        The transformed JSON schema.

    Examples:
        >>> transform_schema(
        ...     {
        ...         "type": "integer",
        ...         "minimum": 1,
        ...         "maximum": 10,
        ...         "description": "A number",
        ...     }
        ... )
        {'type': 'integer', 'description': 'A number

{minimum: 1, maximum: 10}'}
    z$refNz$defsr   anyOfoneOfallOfdict[str, Any]z>Schema must have a 'type', 'anyOf', 'oneOf', or 'allOf' field.descriptiontitler   
propertiesadditionalPropertiesFrequiredr   r   r   itemsminItemsr      r   r   r   r   z

 {z, c              3  4   #    U  H  u  pU S U 3v   M     g7f)z: N ).0keyvalues      r"   	<genexpr>#transform_schema.<locals>.<genexpr>   s     P<Ojc3%r%)<Os   })inspectisclass
issubclasspydantic	BaseModelmodel_json_schemapopr/   transform_schemar
   r   
ValueErrorSupportedStringFormatsr   r    join)json_schemastrict_schemarefdefsstrict_defsnamer!   type_any_ofone_ofall_ofvariantr*   r+   r7   prop_schemar.   r   r/   	min_itemss                       r"   rC   rC   6   s   . {##
;@R@R(S(S!335$&M![/K
//&$
'C
 #f??7D)D&(!,g JJLLD 0 8K ) '2oofd&CE__Wd+F__Wd+F__Wd+Fvci!jciX_"248H'3R"Sci!jg	ci!jciX_"248H'3R"Sci!jg	ci!jciX_"248H'3R"Sci!jg=]^^ %f//-6K'2m$OOGT*E!&gGRWcegGhGnGnGp'
Gp3C3C!+..Gp'
l# 	.505,-??:t4(0M*%	(	40f 66&,M(#$*K!	'	.%5e%<M'"OOJ5	 Y!^yA~(1M*%"&/K
#	)	u	1Uh5F%SY/]b]jU #''6%0%<[6!"iiPK<M<M<OPPQ  	m$ C "k!j!j '
s   	M1M6=M;N )r!   r)   returnr)   )rG   z)type[pydantic.BaseModel] | dict[str, Any]rT   r)   )
__future__r   r<   typingr   r   r   r   typing_extensionsr   r?   _utilsr
   SupportedTypesrE   r#   rC   r5   r$   r"   <module>rZ      s^    "  / / *   &q:qqr$   