
    ,h             	      N   U d Z ddlm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mZmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ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*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0 ddlm1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddlm=Z= ddl>m?Z? ddl@Z@ddlAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZI ddl@mJZJmKZKmLZLmMZMmNZNmOZO ddlPmQZQ ddlRmSZSmTZTmUZU ddlVmWZWmXZXmYZY ddlZm[Z[m\Z\ ddl]m^Z^m_Z_m`Z`maZa ddlbmcZcmdZdmeZe ddlfmgZgmhZhmiZimjZjmkZk ddllmmZm ddlnmoZo dd lmpZp d!d"lqmrZrmsZsmtZtmuZumvZv d!d#lwmxZxmyZy d!d$lzm{Z{m|Z| d!d%l}m~Z~mZmZmZ d!d&lrmZmZmZmZmZmZmZmZmZmZmZmZ d!d'lmZ d!d(lmZmZmZ d!d)lmZ d!d*lmZmZ d!d+lmZmZ d!d,lmZ d!d-lmZmZ d!d.lmZmZ d!d/lmZ d!d0lmZmZ e1r dd1lmZmZ dd2lmZ dd3l,mZ d!d4lmZ d!d5lmZ ejd                  d6k\  Ze8eeef   Z e7d7e8      Ze8ee   ee   ee   f   Ze[Zd9ed:<   e3e2egeHj                  f   Zd9ed;<   d<Zd9ed=<   ejv                  egZd>ed?<   ej|                  eej                  j                  gZd>ed@<   ej                  eej                  j                  gZd>edA<   ej                  eej                  j                  gZd>edB<   ej                  egZd>edC<   e"e#e$e%e&e'gZd>edD<   ej                  ej                  j                  gZd>edE<   ej                   ej                  j                   ej                  ej                  j                  gZd>edF<   ej                  egZd>edG<   ej                  ej                  gZd>edH<   e	j                  e
j                  e
j                  e
j                  e
j                  e
j                  gZd>edI<   ej$                  ej                  ej                  j$                  ej                  j                  ej                  e@j                  ej                  ej                  gZej                  ej                  gZej                  ej                  gZd>edJ<   e8e/e-e0ef   Z eMe      ZehegejekdKZdLedM<   	 	 	 	 	 	 dudNZdvdOZ	 	 	 	 	 	 dwdPZ	 	 	 	 	 	 	 	 dxdQZ	 	 	 	 dydRZeee2   e`f   Z	 	 	 	 	 	 	 	 dzdSZd{dTZ G dU dVe      Z G dW dX      ZdY dZ d[ d\ d] d^ d_ d` daZdbedc<   	 	 	 	 	 	 	 	 d|ddZd}deZ	 	 	 	 	 	 	 	 d~dfZddgZddhZ G di djeL      Zddddddk	 	 	 	 	 	 	 	 	 	 	 	 	 ddlZddnZ	 	 	 	 ddoZ G dp dm      Z G dq dr      Z  G ds dt      Zy)z-Convert python types to pydantic-core schema.    )annotationsN)	GeneratorIterableIteratorMapping)contextmanager)copy)Decimal)Enum)Fraction)partial)	Parameter_ParameterKind	signature)IPv4AddressIPv4InterfaceIPv4NetworkIPv6AddressIPv6InterfaceIPv6Network)chain)
attrgetter)FunctionTypeGenericAlias
LambdaType
MethodType)
TYPE_CHECKINGAnyCallableFinal
ForwardRefLiteralTypeVarUnioncastoverload)UUID)warn)ZoneInfo)
CoreSchemaMultiHostUrlPydanticCustomError$PydanticSerializationUnexpectedValuePydanticUndefinedUrlcore_schemato_jsonable_python)	TypeAliasTypeAliasType	TypedDictget_args
get_originis_typeddict)typing_objects)AnnotationSourceget_literal_valuesis_union_origin   )AliasChoicesAliasGenerator	AliasPath)GetCoreSchemaHandlerGetJsonSchemaHandler)
ConfigDictJsonDictJsonEncoderJsonSchemaExtraCallable)PydanticSchemaGenerationErrorPydanticUndefinedAnnotationPydanticUserError)AfterValidatorBeforeValidatorFieldValidatorModesPlainValidatorWrapValidator)JsonSchemaValue)version_short)PydanticDeprecatedSince20   )_decorators_discriminated_union_known_annotated_metadata_repr_typing_extra)ConfigWrapperConfigWrapperStack)CoreMetadataupdate_core_metadata)get_refget_type_ref%is_list_like_schema_with_items_schemavalidate_core_schema)	DecoratorDecoratorInfosFieldSerializerDecoratorInfoFieldValidatorDecoratorInfoModelSerializerDecoratorInfoModelValidatorDecoratorInfoRootValidatorDecoratorInfoValidatorDecoratorInfoget_attribute_from_basesinspect_field_serializerinspect_model_serializerinspect_validator)extract_docstrings_from_cls)collect_dataclass_fieldsrebuild_model_fieldstakes_validated_data_argument)PydanticRecursiveRef)get_standard_typevars_mapreplace_types)import_cached_base_modelimport_cached_field_info)MockCoreSchema)NamespacesTuple
NsResolver)MissingDefinitionErrorgather_schemas_for_cleaning)CallbackGetCoreSchemaHandler)lenient_issubclasssmart_deepcopy)ComputedFieldInfo	FieldInfo	BaseModel)Discriminator)StandardDataclass)GetJsonSchemaFunction)      FieldDecoratorInfoType)boundr2   ModifyCoreSchemaWrapHandlerGetCoreSchemaFunctionz1Callable[[int, str, Any], Literal['skip'] | None]ParametersCallbackz
list[type]TUPLE_TYPES
LIST_TYPES	SET_TYPESFROZEN_SET_TYPES
DICT_TYPESIP_TYPESSEQUENCE_TYPESITERABLE_TYPES
TYPE_TYPESPATTERN_TYPES
PATH_TYPESDEQUE_TYPES)beforeafterplainwrapzbdict[FieldValidatorModes, type[BeforeValidator | AfterValidator | PlainValidator | WrapValidator]]_mode_to_validatorc                .    | j                   }d|v xs ||v S )zCheck if field name is in validator fields.

    Args:
        info: The field info.
        field: The field name to check.

    Returns:
        `True` if field name is in validator fields, `False` otherwise.
    *)fields)infofieldr   s      e/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py)check_validator_fields_against_field_namer      s      [[F&=+EVO+    c           	        t        |      }| D ]{  }d|j                  j                  v r|j                  j                  du r5|j                  j                  D ].  }||vst	        d|j
                   d|j                   dd       } y)	av  Check if the defined fields in decorators exist in `fields` param.

    It ignores the check for a decorator if the decorator has `*` as field or `check_fields=False`.

    Args:
        decorators: An iterable of decorators.
        fields: An iterable of fields name.

    Raises:
        PydanticUserError: If one of the field names does not exist in `fields` param.
    r   Fz*Decorators defined with incorrect fields: .zO (use check_fields=False if you're inheriting from the model and intended this)zdecorator-missing-fieldcodeN)setr   r   check_fieldsrH   cls_refcls_var_name)
decoratorsr   decr   s       r   check_decorator_fields_existr      s     [F #((//!88  E)XX__ 	EF"'@QsO_O_N`ef2 	r   c                Z    | D cg c]  }t        |j                  |      s| c}S c c}w N)r   r   )validator_functionsr   r   s      r   $filter_field_decorator_info_by_fieldr      s*     /mC2[\_\d\dfk2lCmmms   ((c                   |s| S | d   dk(  rt        | d   ||      | d<   | S | d   dk(  r.| j                  d      x}t        | d   |   ||      | d   |<   | S t        |       r6| j                  dt	        j
                               }t        |||      | d<   | S | d   dk(  r6| j                  dt	        j
                               }t        |||      | d<   | S t        d	| d          )
Ntypenullableschematuplevariadic_item_indexitems_schemadictvalues_schemazO`@validator(..., each_item=True)` cannot be applied to fields with a schema of )apply_each_item_validatorsgetapply_validatorsr]   r0   
any_schema	TypeError)r   each_item_validators
field_namer   inner_schemas        r   r   r      s.     
 f~#5fX6FH\^hix	7	"#)::.C#DDQ:J~&':;$;F>"#67 M 
/v	6zz.+2H2H2JK!1,@TV`!a~ M 
6	!zz/;3I3I3KL"2<AUWa"b
 M ]^dek^l]mn
 	
r   c                *   | j                   | j                  t        | j                        xs | j                  dk(  xs d t	        | j
                        d}|j                         D ci c]  \  }}|	|| }}}|xs d | j                  fS c c}}w )N )titledescription
deprecatedexamples)r   r   boolr   r1   r   itemsjson_schema_extra)r   json_schema_updateskvs       r   )_extract_json_schema_info_from_field_infor      s     ''4??+Lt"/DL&t}}5	 -@,E,E,GYDAq1=1a4YY'4)?)?@@ Zs   *
B5Bc                "   | s|S d|v r|S |gt        |d|j                  j                        dd D ]Y  }| j                  |      }|t	        j
                  dt                dt               t        j                  |d      |d<   |c S  |S )	a  Iterate over the json_encoders and add the first matching encoder to the schema.

    Args:
        json_encoders: A dictionary of types and their encoder functions.
        tp: The type to check for a matching encoder.
        schema: The schema to add the encoder to.
    serialization__mro__Nz=`json_encoders` is deprecated. See https://docs.pydantic.dev/z</concepts/serialization/#custom-serializers for alternativesjson	when_used)
getattr	__class__r   r   warningsr(   rO   rP   r0   $plain_serializer_function_ser_schema)json_encoderstpr   baseencoders        r   ,_add_custom_serialization_from_json_encodersr     s     &  Hgb)R\\-A-AB3BGH ##D)?KMOK\  ]Y  Z%	
 #."R"RSZfl"m Mr   c                    | | S |S )aB  Return the first argument if it is not None, otherwise return the second argument.

    Use case: serialization_alias (argument a) and alias (argument b) are both defined, and serialization_alias is ''.
    This function will return serialization_alias, which is the first argument, even though it is an empty string.
     )abs     r   _get_first_non_nullr   1  s     1$1$r   c                      e Zd ZdZy)InvalidSchemaErrorzThe core schema is invalid.N)__name__
__module____qualname____doc__r   r   r   r   r   :  s    %r   r   c                      e Zd ZdZdZ	 	 dL	 	 	 	 	 	 	 dMdZdN fdZedOd       ZedPd       Z	edQd       Z
dRd	ZdSd
ZdRdZdRdZdTdZdUdZdVdZdRdZdWdZdXdZdUdZdYdZ	 	 	 	 	 	 dZdZd[dZd\dZ	 	 	 	 d]dZd^dZd_dZd`dZd_dZedad       Z edbd       Z dcdddZ d_d Z!ded!Z"d]d"Z#d]d#Z$dfd$Z%d%d&	 	 	 	 	 	 	 	 	 dgd'Z&	 	 	 	 	 	 	 	 dhd(Z'	 	 	 	 	 	 	 	 did)Z(e)	 	 	 	 	 	 	 	 djd*       Z*e)	 	 	 	 	 	 dkd+       Z+e)	 	 	 	 	 	 	 	 dld,       Z,	 	 	 	 	 	 	 	 dmd-Z-dnd.Z.dod/Z/dpd0Z0dqd1Z1drd2Z2e3jh                  df	 	 	 	 	 	 	 	 	 	 	 dsd3Z5e3jh                  f	 	 	 	 	 	 	 	 	 	 	 dtd4Z6dud5Z7dvd6Z8dvd7Z9dnd8Z:dwd9Z;dxd:Z<dyd;Z=dzd<Z>dvd=Z?	 	 	 	 	 	 d{d>Z@d|d?ZA	 d}	 	 	 	 	 d~d@ZB	 d}	 	 	 	 	 ddAZCddBZD	 	 	 	 	 	 ddCZEddDZFdE f	 	 	 	 	 	 	 ddFZGddGZH	 	 	 	 	 	 ddHZI	 	 	 	 	 	 	 	 ddIZJ	 	 	 	 	 	 ddJZK	 	 	 	 	 	 ddKZL xZMS )GenerateSchemaz\Generate core schema for a Pydantic model, dataclass and types like `str`, `datetime`, ... .)_config_wrapper_stack_ns_resolver_typevars_mapfield_name_stackmodel_type_stackdefsNc                    t        |      | _        |xs
 t               | _        || _        t               | _        t               | _        t               | _
        y r   )rX   r   rv   r   r   _FieldNameStackr   _ModelTypeStackr   _Definitionsr   )selfconfig_wrapperns_resolvertypevars_maps       r   __init__zGenerateSchema.__init__J  sG     &8%G"'7:<) / 1 / 1 N	r   c                Z    t         |           t        j                  dt        d       y )NzeSubclassing `GenerateSchema` is not supported. The API is highly subject to change in minor versions.r<   )
stacklevel)super__init_subclass__r   r(   UserWarning)clsr   s    r   r   z GenerateSchema.__init_subclass__X  s#    !#s	
r   c                .    | j                   j                  S r   )r   tailr   s    r   _config_wrapperzGenerateSchema._config_wrapper`  s    ))...r   c                .    | j                   j                  S r   )r   types_namespacer  s    r   _types_namespacezGenerateSchema._types_namespaced  s      000r   c                .    | j                   j                  S r   )r  arbitrary_types_allowedr  s    r   _arbitrary_typeszGenerateSchema._arbitrary_typesh  s    ##;;;r   c                J    t        j                  | j                  |            S r   )r0   list_schemagenerate_schemar   
items_types     r   _list_schemazGenerateSchema._list_scheman  s    &&t';';J'GHHr   c                j    t        j                  | j                  |      | j                  |            S r   )r0   dict_schemar  )r   	keys_typevalues_types      r   _dict_schemazGenerateSchema._dict_schemaq  s,    &&t';';I'FH\H\]hHijjr   c                J    t        j                  | j                  |            S r   )r0   
set_schemar  r  s     r   _set_schemazGenerateSchema._set_schemat  s    %%d&:&::&FGGr   c                J    t        j                  | j                  |            S r   )r0   frozenset_schemar  r  s     r   _frozenset_schemaz GenerateSchema._frozenset_schemaw  s    ++D,@,@,LMMr   c           	       
 t        j                  j                               
t              j                  sd nt        j                  j                        }|dk(  rd }j                  |dj                         D ci c]  \  }}|	|| c}}d t        t              rdt        j                  d      }nft        t              rdt        j                  d      }n>t        t              rdt        j                  d      }nt        j                  d       }
rdfd}t!        j"                  dd       t$        j"                  j&                  u }t        j(                  
|rd nj"                  d	|gi
      }| j*                  j,                  r!t        j.                  t1        d      ||      }|S d
fd}	t        j2                  d	|	gi      S c c}}w )NzAn enumeration.)r   r   intstrfloatc                    | S r   r   xs    r   <lambda>z-GenerateSchema._enum_schema.<locals>.<lambda>  s    XY r   c                \     ||       }|j                  |      }|j                         |S r   )resolve_ref_schemaupdate)r   handlerjson_schemaoriginal_schema
js_updatess       r   get_json_schemaz4GenerateSchema._enum_schema.<locals>.get_json_schema  s0    %fo")"<"<["I&&z2""r   __func__pydantic_js_functions)sub_typemissingrefmetadatavalue)r   c                     |t        j                              }|j                  |      }|j                         |S )N)r/  r1  )r0   enum_schemar&  r'  )	_r(  r)  r*  casesenum_ref	enum_typer+  r/  s	       r   get_json_schema_no_casesz=GenerateSchema._enum_schema.<locals>.get_json_schema_no_cases  sD    %k&=&=iYago&pq")"<"<["I&&z2""r   r2  )r   r*   r(  rA   returnrN   )r(  rA   r<  rN   )list__members__valuesr\   r   inspectcleandocr   r   
issubclassr  r0   simple_ser_schemar  r   r   r   	_missing_r   r-  r5  r  use_enum_values no_info_after_validator_functionr   is_instance_schema)r   r9  r   r   r   value_ser_typer,  default_missingr5  r:  r7  r8  r+  r/  s    `        @@@@r   _enum_schemazGenerateSchema._enum_schemaz  s   	 5 5 < < >?	*"+"3"3d9I9I)J[J[9\,,K(11+N
'1'7'7'9Ktq!Q]adK
:>i%H4?4Q4QRW4XN	3'H(::5AN	5)H(::7CN )MMkZN# &i&9&9:tLPTP^P^PgPggO%11! /Y5H5H1O3DEK ##33)JJw'N # # 1114L3MN s Ls   

G0G0c                   ddl m}m} t        dt        dt
        dt        dt        dt        didfd	}t        j                  t        j                  |         t        j                  t        j                  t        j                               t        j                        
      t        j                   |dd      dfdgi      S )NrQ   )IP_VALIDATOR_LOOKUPIpTypeipv4ipv4networkipv4interfaceipv6ipv6networkipv6interfacec           	         t        | t        f      st        d dt        |        d|  d      |j                  dk(  r| S t        |       S Nz
Expected `z` but got `z` with value `'z-'` - serialized value may not be as expected.python
isinstancer  r-   r   mode)ipr   r   s     r   ser_ipz)GenerateSchema._ip_schema.<locals>.ser_ip  sW    b2s),: KRzLyz  yyH$	r7Nr   r)  python_schemaTalwaysinfo_argr   r.  c                    d   dS )Nstringr   formatr   )_1_2ip_type_json_schema_formatr   s     r   r$  z+GenerateSchema._ip_schema.<locals>.<lambda>  s    (VpqsVt9u r   
lax_schemastrict_schemar   r2  )rZ  r   r   core_schema.SerializationInfor<  zstr | IpType)_validatorsrL  rM  r   r   r   r   r   r   r0   lax_or_strict_schema no_info_plain_validator_functionjson_or_python_schemarF  
str_schemarG  r   )r   r   rL  rM  r[  rg  s    `   @r   
_ip_schemazGenerateSchema._ip_schema  s    < ???
"	 //"CCDWXZD[\%;;'HH[McMcMef)<<R@ &JJ6\`ltu'*u)v

 
	
r   c           	       	 t         j                  u r0t        t        hvr"t	        j
                        st        dd      t         j                  u rt        j                  n	t        u rt        j                  d      nt        j                  d      }t        u rt        j                         nt        j                         }d	fd}dfd}t        j                  t        j                  ||      t        j                              }t        j                  t        j                   |t        j                  ||      gd	d
       |t        j"                  |dd      dd gi      }|S )Nz;`os.PathLike` can only be used with `str`, `bytes` or `Any`zschema-for-unknown-typer   Tstrictc                2   	 t         u r.t        | t               r	 | j                         } n(t	        dd      t        | t
              st	        dd       |       S # t        $ r}t	        dd      |d }~ww xY w# t        $ r}t	        dd      |d }~ww xY w)N
bytes_typezInput must be valid byteszInput must be bytes	path_typezInput is not a valid path)bytesrX  decodeUnicodeDecodeErrorr,   r  r   )input_valueepath_constructorrw  s     r   path_validatorz3GenerateSchema._path_schema.<locals>.path_validator  s    [%!+u5h*5*<*<*>K 2,@UVV#K5-k;VWW'44  2 h"5lD_"`fggh  [)+7RSYZZ[s9   A; A 0A; 	A8&A33A88A; ;	BBBc           	         t        | t        f      st        d dt        |        d|  d      |j                  dk(  r| S t        |       S rU  rW  )pathr   r   s     r   ser_pathz-GenerateSchema._path_schema.<locals>.ser_path   sX    dRI.: KT
|?4&P}~  yyH$t9r   r\  rw  zInput is not a valid path for custom_error_typecustom_error_messager^  r_  r.  c                    i  ||       ddiS )Nrd  r  r   )sourcer(  s     r   r$  z-GenerateSchema._path_schema.<locals>.<lambda>  s    Hm7SY?Hm\dflHm r   rh  )r{  zstr | bytesr<  zos.PathLike[Any])r  r   r   rk  r<  zstr | os.PathLike[Any])osPathLiker  rx  r8   is_anyrH   pathlibPurePathr0   bytes_schemarp  ro  rF  rG  rm  union_schemar   )
r   r   rw  strict_inner_schemalax_inner_schemar~  r  instance_schemar   r}  s
    ``      @r   _path_schemazGenerateSchema._path_schema  sS   )C<"?H]H]^gHh#MTm  02R[[/@7++b6?56HK$$D1{OeOemqOr 	 ;Du:L;335S^SiSiSk	["	 &;;#DD^Uef%88<

 11"//#@@Qde #.'EbT%J *%JJ8^bnvw-0m/no
 r   c           	        ddl m} ddlm} | j	                  |      }t        j                  |d      }t        j                  |t        j                  t        j                  d            }t        j                  ||      }t        j                  |t        j                  ||g      t        j                  ||d	
            S )NrQ   serialize_sequence_via_list)deque_validatorFrs  Dequecls_reprr\  Tr   r`  ri  rj  r   )_serializersr  rl  r  r  r0   r  ro  rG  collectionsdequeno_info_wrap_validator_functionrm  chain_schema#wrap_serializer_function_ser_schema)r   r  r  r  item_type_schemar  check_instanceri  s           r   _deque_schemazGenerateSchema._deque_schema  s    =0//
; "--.>uM$::#%889J9JU\]

 !@@R]^
//!%22NJ3OP%II+4Dt
 	
r   c           	     T   ddl m}m}m} ||   }| j	                  |      }| j	                  |      }	t        j                  ||	d      }
|t        u r|
}|S t        j                  |
t        j                  |            }|t        j                  u r. ||      }t        t
        j                  t        ||            }nt        t
        j                  |      } ||
      }t        j                  ||g      }t        j                   ||t        j"                  d |
d      	      }|S )
NrQ   )MAPPING_ORIGIN_MAPdefaultdict_validator'get_defaultdict_default_default_factoryFrs  r\  )default_default_factoryc                     ||       S r   r   )r   hs     r   r$  z0GenerateSchema._mapping_schema.<locals>.<lambda>V  s
    1 r   r  r  )rl  r  r  r  r  r0   r  r   ro  rG  r  defaultdictr   r  rF  r  rm  r  )r   r   r  r  r  r  r  mapped_originkeys_schemar   r  r   r  r  coerce_instance_wrapri  rj  s                    r   _mapping_schemazGenerateSchema._mapping_schema6  s!   ss*2.**95,,[9!--k=QVWD  F6 3 )>>')<<]KN
 [,,,*QR]*^''.??1Kbc($
 (/{/[/[]j'k$-k:J'44nj5QRM 55%+)MM%kEF r   c           	        ddl m} t        j                  t        j                  |      t        j
                  t        j                  |      t        j                  t                    t        j                  d      dd gi      S )	z7Support for [`fractions.Fraction`][fractions.Fraction].rQ   )fraction_validatorr\  r^  r   r.  c                    dddS )Nrb  fractionrc  r   re  rf  s     r   r$  z1GenerateSchema._fraction_schema.<locals>.<lambda>j  s    \f?g r   rh  )	rl  r  r0   rm  rn  ro  rG  r   to_string_ser_schema)r   r  s     r   _fraction_schemazGenerateSchema._fraction_schema\  sp    3 //"CCDVW%;;'HHI[\)<<XF
 &::XN-0g/hi	
 		
r   c                    t        |t              s't        |dt               t	        j
                         S t	        j                  |      S )Na   is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.)rX  r   r(   r   r0   r   rG  )r   r   s     r   _arbitrary_type_schemaz%GenerateSchema._arbitrary_type_schemam  sL    "d#& Z Z  ))++--b11r   c                     t        d|d      )N,Unable to generate pydantic-core schema for a  . Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.)rF   r   objs     r   _unknown_type_schemaz#GenerateSchema._unknown_type_schemay  s#    +:3' Bf f
 	
r   c                    ||S 	 t        j                  ||| j                  j                        S # t         j                  $ r t        j
                  ||       |cY S w xY wr   )rS   apply_discriminatorr   _definitionsMissingDefinitionForUnionRefset_discriminator_in_metadata)r   r   discriminators      r   _apply_discriminator_to_unionz,GenerateSchema._apply_discriminator_to_union  sl      M	';;		&& 
 $@@ 	 >> M	s   *1 +AAc                R    | j                   j                  |      }t        |      }|S r   )r   finalize_schemar^   )r   r   s     r   clean_schemazGenerateSchema.clean_schema  s%    **62%f-r   c                    |j                  di       }|j                  dg       }||vr|j                  |       ||d<   y )Nr2  r.  )r   
setdefaultappend)r   metadata_schemajs_functionr2  r.  s        r   _add_js_functionzGenerateSchema._add_js_function  sK    "&&z26 ( 3 34KR P
 33!((5&.
#r   c                    | j                  ||      }|| j                  |      }t        |      }|*t        || j                        }|r| j                  ||       t        | j                  j                  ||      }|S )aX  Generate core schema.

        Args:
            obj: The object to generate core schema for.

        Returns:
            The generated core schema.

        Raises:
            PydanticUndefinedAnnotation:
                If it is not possible to evaluate forward reference.
            PydanticSchemaGenerationError:
                If it is not possible to generate pydantic-core schema.
            TypeError:
                - If `alias_generator` returns a disallowed type (must be str, AliasPath or AliasChoices).
                - If V1 style validator with `each_item=True` applied on a wrong field.
            PydanticUserError:
                - If `typing.TypedDict` is used instead of `typing_extensions.TypedDict` on Python < 3.12.
                - If `__modify_schema__` method is used instead of `__get_pydantic_json_schema__`.
        )	'_generate_schema_from_get_schema_method_generate_schema_inner!_extract_get_pydantic_json_schemaresolve_original_schemar   r  r   r  r   )r   r  r   metadata_js_functionr  s        r   r  zGenerateSchema.generate_schema  s    0 ==c3G>005F@E+5fdiiHO%%o7KL=d>R>R>`>`begmnr   c                   t               }| j                  j                  |      5 \  }}||cddd       S |j                  j	                  d      }|ot        |t              s_|d   dk(  r| j                  j                  |      }t        |      }|r$| j                  j                  |      cddd       S |cddd       S t        |j                  d      }| j                  j                  |      5  | j                  j                  |      5  | j                  j!                  |j"                        }|j$                  s||u rt'        |di       }	nXt)        |d      s%t+        |j"                  d	|j"                  d
      	 t-        || j                  | j.                  xs i       }	|j4                  }|j6                  }t9        t;        |j<                  j?                         |j@                  j?                         |jB                  j?                               h |	jE                         |jE                                |jF                  j?                         }d}d}|j	                  d      dk(  r|jH                  d   |u sJ |jH                  d   tJ        u sJ |jH                  dd D ]  }t'        |di       j	                  dd      }|#t        |tL              r6tO        jP                  tO        jR                  |dd      g| jT                   }tW        |      }|tX        vrt[        d      | j]                  |d      \  }}|tL        ur| j_                  |      }ta        jb                  |      s| j_                  |      }|| n t'        |di       j	                  d      }|jd                  r\| jg                  d|	d   |      }|d   }ti        ||d      }tk        jl                  |||t'        |dd      dt'        |dd      ||      }ntk        jn                  |	jq                         D ci c]  \  }}|| js                  |||       c}}|j?                         D cg c]  }| ju                  ||j@                          c}|||j"                        }tw        ||jx                  j?                         d      }ti        ||d      }tk        jl                  |||t'        |dd      dt'        |dd      ||      }| j{                  ||j|                  j?                               }ti        ||d       }| j                  j                  |      cddd       cddd       cddd       S # t0        $ r}
t+        j2                  |
      |
d}
~
ww xY wc c}}w c c}w # 1 sw Y   nxY wddd       n# 1 sw Y   nxY wddd       y# 1 sw Y   yxY w)!z%Generate schema for a Pydantic model.N__pydantic_core_schema__r   definitionsF)checkr   __pydantic_fields__zClass z is not defined)namemessage)r   r   extra_fields_behaviorallowr   r   __annotations____pydantic_extra__T)is_argumentis_classzEThe type annotation for `__pydantic_extra__` must be `dict[str, ...]`required__pydantic_generic_metadata__originrootr   inner__pydantic_custom_init____pydantic_post_init__)generic_origincustom_init
root_model	post_initconfigr1  )computed_fieldsextras_schemaextras_keys_schema
model_nameouter)?rr   r   get_schema_or_ref__dict__r   rX  rt   unpack_definitionsr[   "create_definition_reference_schemarW   model_configr   pushr   r  core_configr   __pydantic_fields_complete__r   hasattrrG   rm   r   	NameErrorfrom_name_error__pydantic_decorators__r  r   r   field_validatorsr?  field_serializers
validatorskeysmodel_validatorsr   objectr  rV   eval_type_backport_make_forward_refr  r6   r   rF    _get_args_resolving_forward_refsr  r8   r  __pydantic_root_model___common_field_schemaapply_model_validatorsr0   model_schemamodel_fields_schemar   _generate_md_field_schema_computed_field_schemar   root_validators_apply_model_serializersmodel_serializers)r   r  
BaseModel_	model_refmaybe_schemar   r1  r   r  r   r|  r   r  r  r  r  candidate_clsextras_annotationr   extra_keys_typeextra_items_typer  
root_fieldr   r  r   r   dfields_schemas                                r   _model_schemazGenerateSchema._model_schema  s   -/
YY((- G	L1J)\'#G	L G	L \\%%&@AF!*V^*L&>]2!YY99&AFfo99GGOG	L G	L "G	L G	L +3+;+;5IN++00@ wL$BSBSBXBXY\B] wL"22>>S\\>R33sj7H$S*?DF"3(=> :!$&,S\\,<O$L T!5(,(9(9)-););)Ar" !88
","<"<,"33::<"44;;="--446
 >fkkm=o&:&:&<= $.#>#>#E#E#G  $%)"??#:;wF;;q>S00;;r?f44),Sb)9 &,3MCTVX,Y,],]0$-) -8)*;SA4A4T4T$1$C$C(9uW[%&5" &*%:%:	5" 1 ",,=!>B!3&C$k'" !" AE@e@e 1)- Af A=O-=  /c9595I5I/5Z 2#1#8#89I#J040D0DEU0V1=AZ %5&8 :AFegi9j9n9now9x..!%!:!:66&>S]!^J#-h#7L#9,HXZa#bL#.#;#;$'5$+C1KT$R#'")#/G"N*%	$L =H<[<[Y_YeYeYghQUQRTUD::1aLLh &5%;%;%=) ! !77:;W;WX) '4+=#&<<	=M $4M:C]C]CdCdCfhl#mL#9,HXZa#bL#.#;#;$'5$+C1KT$R#(")#/G"N*%	$L 66|ZEaEaEhEhEjk/8H'RyyCCFKowL wL wL!G	L G	LV % T9II!LRSSTF i)wL wL wL wL wL!G	L G	L G	Ls   WA7W8W2W5V?A6V*&U8.D%V*B=V*B)V*;VV*.#V%CV*	V?%	W8	V	V	V	V**V3/V?6	W?W	WWc                X    | j                   j                         }|t        dd      |S )Nz(`typing.Self` is invalid in this contextzinvalid-self-typer   )r   r   rH   r  s     r   _resolve_self_typez!GenerateSchema._resolve_self_type[  s/    ##'');#$NUhii
r   c                   t               }t        |dd       }t        |dd       |j                  j                  u }||s| j                  j                  |      5 \  }}||cd d d        S 	 d d d        ||u rd}nd} ||t        | j                  | |            }	|	d   dk(  r| j                  j                  |	      }	t        |	      }
|
r| j                  j                  |	      S |	S |t        |dd       x}|d	d
lm} t        ||      rt        d|j                   dt                nt        dt"               t%        j&                   |       D cg c]  }t%        j(                  |       c}      S y y # 1 sw Y   xY wc c}w )N__get_pydantic_core_schema__r-  unpackzto-def)ref_moder   r  __get_validators__r   r~   zeMixing V1 models and V2 models (or constructs, like `TypeAdapter`) is not supported. Please upgrade `z` to V2.zc`__get_validators__` is deprecated and will be removed, use `__get_pydantic_core_schema__` instead.)rr   r   r!  r-  r   r  ry   r  r  r[   r  pydantic.v1r   rB  r(   r   r   rP   r0   r  "with_info_plain_validator_function)r   r  r  r  
get_schemais_base_model_get_schemar6  r  r#  r   r1  r  BaseModelV1r   s                 r   r  z6GenerateSchema._generate_schema_from_get_schema_methoda  s   -/
S"@$G
J
D1Z5\5\5e5ee 	!
 " - ,,S1 (5Fa+'( (+( f}##4T5P5PRVaijF f~.55f=&/CyyCCFKK M>RTX1Y#Y:"f<#{+{|  }I  }I  |J  JR  S
 y- ++hrht,ucd[-[-[\]-^,uvv #g-( (F -vs   E8F8Fc                ,   	 t        j                  |g| j                   }t        |t              rt	        |j                  d|       | j                  rt        || j                        }|S # t        $ r}t	        j
                  |      |d }~ww xY w)Nz%Unable to evaluate forward reference )rV   r  r  r  rG   r  rX  r!   __forward_arg__r   rq   )r   r  r|  s      r   _resolve_forward_refz#GenerateSchema._resolve_forward_ref  s    	H223O9N9NOC
 c:&-c.A.AEjknjoCpqqT%7%78C
  	H-==a@aG	Hs    A/ /	B8BBc                     y r   r   )r   r  r  s      r   r  z/GenerateSchema._get_args_resolving_forward_refs  s    fir   c                     y r   r   r  s     r   r  z/GenerateSchema._get_args_resolving_forward_refs  s    TWr   c                     t        |      }|r/t        |t              r	d |D        }t         fd|D              }|S |rt	        d| d      |S )Nc              3  j   K   | ]+  }t        |t              rt        j                  |      n| - y wr   )rX  r  rV   r  ).0r   s     r   	<genexpr>zBGenerateSchema._get_args_resolving_forward_refs.<locals>.<genexpr>  s+     f\]jC>P77:VWWfs   13c              3  d   K   | ]'  }t        |t              rj                  |      n| ) y wr   )rX  r!   r,  )r1  r   r   s     r   r2  zBGenerateSchema._get_args_resolving_forward_refs.<locals>.<genexpr>  s,     h^_Az9R2215XYYhs   -0z	Expected z+ to have generic parameters but it had none)r5   rX  r   r   r   )r   r  r  argss   `   r   r  z/GenerateSchema._get_args_resolving_forward_refs  s[    }#|,faefhcghhD  iu,WXYYr   c                >    | j                  |      }|st        S |d   S )Nr   )r  r   )r   r  r4  s      r   _get_first_arg_or_anyz$GenerateSchema._get_first_arg_or_any  s#    44S9JAwr   c                    | j                  |      }|st        t        fS t        |      dk  rt        |      }t	        d| d      |d   |d   fS )Nr<   z Expected two type arguments for z, got 1r   rQ   )r  r   lenr6   r   )r   r  r4  r  s       r   _get_first_two_args_or_anyz)GenerateSchema._get_first_two_args_or_any  s[    44S9:t9q=_F>vhgNOOAwQr   c                   t        j                  |      r| j                  |      }t        j                  t	        |            r| j                  |      S t        |t              r|S t        |t              rt        |      }t        |t              r | j                  | j                  |            S t               }t        ||      r6| j                  j                  |      5  | j!                  |      cd d d        S t        |t"              r t%        j&                  |j(                        S | j+                  |      S # 1 sw Y   JxY w)N)
schema_ref)r8   is_selfr  is_annotatedr6   _annotated_schemarX  r   r  r!   r  r,  rr   rz   r   r  r  ro   r0   definition_reference_schematype_ref
match_type)r   r  r   s      r   r  z%GenerateSchema._generate_schema_inner  s
   !!#&))#.C&&z#7))#..c4 Jc3S/Cc:&''(A(A#(FGG,.	c9-&&++C0 /))#./ / c/0::cllSSs##/ /s   $E  E	c                V   |t         u rt        j                         S |t        u rt        j                         S |t
        u rt        j                         S |t        u rt        j                         S |t        u rt        j                         S |t        u rt        j                         S t        j                  |      s|t        u rt        j                          S |t"        j$                  u rt        j&                         S |t"        j"                  u rt        j(                         S |t"        j*                  u rt        j,                         S |t"        j.                  u rt        j0                         S |t2        u rt        j4                         S |t6        u rt        j8                         S |t:        u rt        j<                         S |t>        u r| jA                         S |tB        u rt        jD                         S ||tF        jH                  u rt        jJ                         S |tL        v r| jO                  |      S |tP        v r| jS                  |      S |tT        v r| jW                  tX              S |tZ        v r| j]                  tX              S |t^        v r| ja                  tX              S |tb        v r| je                  tX              S |tf        v r| ji                  |      S |tj        v r| jm                  tX        tX              S |tn        v r| jq                  |tX              S |tr        v r| ju                  tX              S |tv        v r| jy                  |tX        tX              S |tz        v r| jy                  |tX        t
              S t        j|                  |      r| j                  |      S |t        u r| j                         S tG        j                  |      rt        j                         S t        j                  t        |            r| j                  |      S t        |      r| j                  |d      S tG        j                  |      r| j                  |d      S t        j                  |      r| j                  |j                        S |t        v r| j                  |      S tG        j                  |      r| j                         S t        |t        j                        r| j                  |      S tG        j                  |      r<|t        u rt        j                          S | j                  | j                  |            S t        |t              r| j                  |      S t        j                  |      r!t        |t              r| j                  |      S |t        u r| j                         S t        j                  |      r| j                  |d      S t        |      }|| j                  ||      S | j                  r| j                  |      S | j                  |      S )a  Main mapping of types to schemas.

        The general structure is a series of if statements starting with the simple cases
        (non-generic primitive types) and then handling generics and other more complex cases.

        Each case either generates a schema directly, calls into a public user-overridable method
        (like `GenerateSchema.tuple_variable_schema`) or calls into a private method that handles some
        boilerplate before calling into the user-facing method (e.g. `GenerateSchema._tuple_schema`).

        The idea is that we'll evolve this into adding more and more user facing methods over time
        as they get requested and we figure out what the right API for them is.
        N)ir  r0   rp  rx  r  r  
int_schemar   float_schemar   bool_schemacomplexcomplex_schemar8   r  r  r   datetimedatedate_schemadatetime_schematimetime_schema	timedeltatimedelta_schemar
   decimal_schemar'   uuid_schemar/   
url_schemar   r  r+   multi_host_url_schemarV   NoneTypenone_schemar   rq  r   _tuple_schemar   r  r   r   r  r   r  r   _sequence_schemar   _iterable_schemar   r  r   r  r   r  MAPPING_TYPESr  COUNTER_TYPESis_typealiastype_type_alias_type_schemar   _type_schemais_callablecallable_schema
is_literalr6   _literal_schemar7   _typed_dict_schemais_namedtuple_namedtuple_schema
is_newtyper  __supertype__r   _pattern_schemais_hashable_hashable_schemarX  typingr#   _unsubstituted_typevar_schemais_finalvarr    r6  VALIDATE_CALL_SUPPORTED_TYPES_call_schemar@  isclassrB  r   rJ  r)   _zoneinfo_schemadataclassesis_dataclass_dataclass_schema_match_generic_typer  r  r  )r   r  r  s      r   rA  zGenerateSchema.match_type  s    #:))++E\++--CZ))++E\++--D[**,,G^--//""3'3&=))++HMM!**,,H%%%..00HMM!**,,H&&&//11G^--//D[**,,CZ))++H_((**L 4466[C=#9#99**,,H_??3''K%%c**J$$S))I##C(($$))#..N"((--N"((--J$$S#..J$$S#..K%%c**M!''S#66M!''S#66,,S1//44D[$$&&&&s+..00&&z#7'',,#**355((-**355&&s+''(9(9::M!'',,&&s+((**V^^,55c::&&s+e|"--//''**3/  :;$$S))__S!jd&;$$S))H_((** ##C())#t44C++C88  ..s33((--r   c                   t        j                  |      r| j                  ||      S t        j                  |      r| j                  ||      S | j                  ||      }||S t        j                  |      r| j                  |      S t        |      r| j                  |      S |t        v r| j                  |      S |t        v r | j                  | j!                  |            S |t"        v r | j%                  | j!                  |            S |t&        v r | j)                  | j!                  |            S |t*        v r | j,                  | j/                  |       S |t0        v r!| j3                  || j!                  |            S |t4        v r | j7                  | j!                  |            S |t8        v r" | j:                  |g| j/                  |       S |t<        v r&| j;                  || j!                  |      t>              S tA        |      r| jC                  ||      S |tD        v r| jG                  |      S |tH        v r | jK                  | j!                  |            S |tL        v r| jO                  |      S |tP        v r| jS                  |      S | jT                  r| jW                  |      S | jY                  |      S r   )-rq  rr  rs  rV   rc  rd  r  r8   r[  r\  r;   _union_schemar   rV  r   r  r6  r   r  r   r  r   r  r9  r   r  r   r  rY  r  rZ  r  r7   rb  r   _subclass_schemar   rW  r   rX  r   rg  r  r  r  )r   r  r  r   s       r   rt  z"GenerateSchema._match_generic_typed  s   
 ##F+))#v66&&v.**377==fcJM**62//44V$%%c**{"%%c**z!$$T%?%?%DEEy ##D$>$>s$CDD''))$*D*DS*IJJz!$4$$d&E&Ec&JKKz!$$VT-G-G-LMM{"%%d&@&@&EFF}$'4''V1P1PQT1UVV}$''0J0J30OQTUU&!**377z!((--~%(()C)CC)HII~%((--}$'',,  ..v66((--r   Tr  c          	         | j                  |||      }t        j                  |d   |j                         sdn||d   |d   |d   |d         S )zAPrepare a TypedDictField to represent a model or typeddict field.r   Fserialization_excludevalidation_aliasserialization_aliasr2  )r  ry  rz  r{  r2  )r
  r0   typed_dict_fieldis_required)r   r  
field_infor   r  common_fields         r   _generate_td_field_schemaz(GenerateSchema._generate_td_field_schema  sf     00z:N++"","8"8":U"./F"G)*<= ,-B C!*-
 	
r   c           	         | j                  |||      }t        j                  |d   |d   |d   |d   |d   |d         S )z0Prepare a ModelField to represent a model field.r   ry  rz  r{  frozenr2  ry  rz  r{  r  r2  )r
  r0   model_fieldr   r  r~  r   r  s        r   r  z(GenerateSchema._generate_md_field_schema  s^     00z:N&&""./F"G)*<= ,-B C)!*-
 	
r   c                    | j                  |||      }t        j                  ||d   |j                  |j                  xs d|j
                  rdnd|d   |d   |d   |d   |d   	
      S )
zJPrepare a DataclassField to represent the parameter/field, of a dataclass.r   NFry  rz  r{  r  r2  )init	init_onlykw_onlyry  rz  r{  r  r2  )r
  r0   dataclass_fieldr  init_varr  r  s        r   _generate_dc_field_schemaz(GenerateSchema._generate_dc_field_schema  s     00z:N**" ))1T&..DE"./F"G)*<= ,-B C)!*-
 	
r   c                   |j                   4|j                   dk  s%|j                  |j                  |j                  d\  }}}t	        | t
              r| j                  |      \  }}}nCt	        | t              r3 | |      }t	        |t              st        d|  d|j                         |j                   |j                   dk  rd|_         |j                   dk(  r)t        ||      |_        t        ||      |_        ||_        |j                  ||_        |j                  t        ||      |_        |j                  t        ||      |_        yyy)a  Apply an alias_generator to aliases on a FieldInfo instance if appropriate.

        Args:
            alias_generator: A callable that takes a string and returns a string, or an AliasGenerator instance.
            field_info: The FieldInfo instance to which the alias_generator is (maybe) applied.
            field_name: The name of the field from which to generate the alias.
        NrQ   NNNalias_generator  must return str, not )alias_priorityaliasrz  r{  rX  r>   generate_aliasesr   r  r   r   r   )alias_generatorr~  r   r  rz  r{  s         r   $_apply_alias_generator_to_field_infoz3GenerateSchema._apply_alias_generator_to_field_info  sm    %%-((A-'**2--5;K8E#%8/>:?N?_?_`j?k<')<OX6'
3!%-#&66GG]^c^m^m]n$opp
 ((0J4M4MQR4R,-
) ((A-1DEXZ_1`
..ABRTY.Z
+#(
  '#(
 --51DEXZ_1`
.**2.ABRTY.Z
+ 39 6r   c                   |j                   |j                   dk  s|j                  d\  }}}t        | t              r| j	                  |      \  }}}nCt        | t
              r3 | |      }t        |t              st        d|  d|j                         |j                   |j                   dk  rd|_         |j                   dk(  rt        ||      |_        yyy)a  Apply an alias_generator to alias on a ComputedFieldInfo instance if appropriate.

        Args:
            alias_generator: A callable that takes a string and returns a string, or an AliasGenerator instance.
            computed_field_info: The ComputedFieldInfo instance to which the alias_generator is (maybe) applied.
            computed_field_name: The name of the computed field from which to generate the alias.
        NrQ   r  r  r  )
r  r  rX  r>   r  r   r  r   r   r   )r  computed_field_infocomputed_field_namer  rz  r{  s         r   -_apply_alias_generator_to_computed_field_infoz<GenerateSchema._apply_alias_generator_to_computed_field_info  s    $  ..6"11Q6"((0;K8E#%8/>:?N?_?_`s?t<')<OX6'(;<!%-#&66GG]^c^m^m]n$opp
 #119=P=_=_cd=d56#2
 #11Q6,?@SUZ,[#) 7) 1r   c                    |j                   xs | j                   }|y|j                  < |||      }t        |t              st	        d| d|j
                         ||_        yy)ae  Apply a field_title_generator on a FieldInfo or ComputedFieldInfo instance if appropriate
        Args:
            config_wrapper: The config of the model
            field_info: The FieldInfo or ComputedField instance to which the title_generator is (maybe) applied.
            field_name: The name of the field from which to generate the title.
        Nzfield_title_generator r  )field_title_generatorr   rX  r  r   r   )r   r~  r   r  r   s        r   *_apply_field_title_generator_to_field_infoz9GenerateSchema._apply_field_title_generator_to_field_info-  sw     !+ @ @ hNDhDh (#)*jAEeS)"89N8OOefkfufuev wxx$J $r   c                p    j                   j                  }}d fd}g }t        |j                  j	                         |      D ]=  }|j                  t        |j                  j                     j                  |             ?  j                  j                  |      5  j                   j                  |||z   |      }	n j                  |||z         }	d d d        t        |j                  j	                         |      }
t        |
      rd_        |
D cg c]  }|j                  j"                  du s| }}|
D cg c]	  }||vs| }
}t%        	||      }	t'        |	|
|      }	j)                         st+        |	      }	 j-                  |	t        |j.                  j	                         |            }	 j1                   j2                  |       t5              \  }}i }t7        |||        j2                  j8                  }| j;                  ||       t=        j>                  t@        tB        f      rj>                  jE                         }nj>                  }tG        |	jH                  rdnd |jJ                  jL                  |      S # 1 sw Y   xY wc c}w c c}w )Nc                @    j                  | j                        } | S r   )r  r  )r   r~  r   s    r   set_discriminatorz>GenerateSchema._common_field_schema.<locals>.set_discriminatorH  s     77
@X@XYFMr   )transform_inner_schemaTpydantic_js_updatespydantic_js_extrar  r   r*   r<  r*   )'
annotationr2  r   r   r?  r  r   r   rY  _from_decoratorr   r  r  _apply_annotationsr  $_validators_require_validate_defaultvalidate_default	each_itemr   r   r}  wrap_default_apply_field_serializersr  r  r  r   rZ   r  r  rX  rz  r=   r?   convert_to_aliases_common_fieldexcluder{  r  )r   r  r~  r   source_typer   r  validators_from_decorators	decoratorr   this_field_validatorsr   r   r  r  core_metadatar  rz  s   ` `               r   r
  z#GenerateSchema._common_field_schemaC  s    $.#8#8*:M:M[	
 &("=j>Y>Y>`>`>bdhi 	rI&--.@ATAT.U.e.efo.pq	r ""''- 		''300/I!Ibs 1  00"<<		 !EZEZEZEaEaEcei j/0EF*.J'+@]aAFFDTDTX\D\]],A cqQNbEb c c+F4H$O!&*?F
 %%'!*f5F..89U9U9\9\9^`de
 	778L8LjZ^_1Z[e1f..(*/BVg	
 ..>>&55ozSWXj11L)3LM)::MMO)::*4*<*<$$- * > >$$"
 	
e		 		$  ^ cs$   #:J!J.=J.	J3J3!J+c                   | j                  |d      }g }d}|D ]9  }||t        j                  u rd}|j                  | j	                  |             ; t        |      dk(  r|d   }ntg }|D ]X  }t        t        |j                  di             j                  d      }	|	|j                  ||	f       H|j                  |       Z t        j                  |      }|rt        j                  |      }|S )zGenerate schema for a Union.Tr  FrQ   r   r2  pydantic_internal_union_tag_key)r  rV   rT  r  r  r8  r%   rY   r   r0   r  nullable_schema)
r   
union_typer4  choicesr   argschoices_with_tagschoicetags
             r   rv  zGenerateSchema._union_schema  s    44Z$4O$& 	:C{c]%;%;;t33C89		: w<1
AKM! 5<J)CDHHIjk?%,,fc];%,,V45 (():;A++A.Ar   c                J   | j                   j                  |      5 \  }}||cd d d        S t        |      xs |}t        |      }| j                  j                  |      5  	 t        j                  |j                  g| j                   }t        ||      }| j                  |      }|d   dk7  sJ ||d<   d d d        | j                   j                        cd d d        S # t        $ r}t        j                  |      |d }~ww xY w# 1 sw Y   TxY w# 1 sw Y   y xY w)Nr   r  r1  )r   r  r6   rp   r   r  rV   	eval_type	__value__r  r  rG   r  rq   r  r  )	r   r  r1  r  r  r   r  r|  r   s	            r   r\  z&GenerateSchema._type_alias_type_schema  s*   YY((- 	H1D#|'#	H 	H %/sO$:sF4S9L""''/ $P!.!8!89I9I!bDLaLa!bJ +:|D
--j9f~66 #u$ 99??G!	H 	H ! P5EEaHaOP$ $	H 	HsL   D5D"D$*C&,D:"D&	D
/DD

DD	DD"c                    t        t        |dd            }|s
J d|        t        j                  |      }| j                  j
                  r)t        d |D              rt        j                  d |      }|S )zGenerate schema for a Literal.Feager)
type_checkunpack_type_aliasesz(literal "expected" cannot be empty, obj=c              3  <   K   | ]  }t        |t                y wr   )rX  r   )r1  r   s     r   r2  z1GenerateSchema._literal_schema.<locals>.<genexpr>  s     7^PQ
1d8K7^s   c                >    t        | t              r| j                  S | S r   )rX  r   r3  )r   s    r   r$  z0GenerateSchema._literal_schema.<locals>.<lambda>  s    Z4%8!'' a r   )r=  r:   r0   literal_schemar  rE  anyrF  )r   literal_typeexpectedr   s       r   ra  zGenerateSchema._literal_schema  ss    *<E_fghRCL>RR++H5//C7^U]7^4^ AA?F r   c                   t               }| j                  j                  |      5  | j                  j	                  |      5 \  }}||cddd       cddd       S t        |      }||}t        s%t        |      j                  dk(  rt        dd      	 t        |d      }| j                  j                  |      5  | j                  j                  |j                        }|j                   }	i }
t#        j$                  |      }| j                  j&                  rt)        |d	      }nd}	 t+        j,                  || j.                  
      }g }|j7                         D ]  \  }} |j8                  |t:        j<                        }t?        |j@                  |      |_         ||	v xs d|jB                  v xr d|jB                  v}d|jB                  v r|jE                  |       ||jF                  ||v r
||   |_#        | jI                  | j                  ||       | jK                  ||||      |
|<    |r_djM                  d |D              }tO        |      dk\  }tQ        jR                  d|rdnd d| d|j                  d|rdnd d	tT               tW        jX                  |
||jZ                  j]                         D cg c]  }| j_                  ||j`                          c}||      }| jc                  ||jd                  j]                               }tg        ||jh                  j]                         d      }| j                  jk                  |      cddd       cddd       cddd       S # t        $ r d}Y w xY w# t0        $ r}t3        j4                  |      |d}~ww xY wc c}w # 1 sw Y   nxY w	 ddd       n# 1 sw Y   nxY wddd       y# 1 sw Y   yxY w)a,  Generate a core schema for a `TypedDict` class.

        To be able to build a `DecoratorInfos` instance for the `TypedDict` class (which will include
        validators, serializers, etc.), we need to have access to the original bases of the class
        (see https://docs.python.org/3/library/types.html#types.get_original_bases).
        However, the `__orig_bases__` attribute was only added in 3.12 (https://github.com/python/cpython/pull/103698).

        For this reason, we require Python 3.12 (or using the `typing_extensions` backport).
        Nrj  zXPlease use `typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.12.ztyped-dict-versionr   __pydantic_config__r  T)use_inspectr   _sourcer  not_required	read_onlyr  , c              3  2   K   | ]  }t        |        y wr   repr)r1  fs     r   r2  z4GenerateSchema._typed_dict_schema.<locals>.<genexpr>  s     +MDG+M   r<   Itemr  r    z on TypedDict class areiszk using the `ReadOnly` qualifier. Pydantic will not protect items from any mutation on dictionary instances.)r  r  r1  r  all)6rs   r   r  r   r  rp   _SUPPORTS_TYPEDDICTr   r   rH   rg   AttributeErrorr   r  r  r   __required_keys__r`   builduse_attribute_docstringsrk   rV   get_cls_type_hintsr   r  rG   r  r   from_annotationr9   
TYPED_DICTrq   r  _qualifiersr  r   r  r  joinr8  r   r(   r   r0   typed_dict_schemar  r?  r  r  r  r  r  r  r  )r   typed_dict_clsr  r}   typed_dict_refr  r   r  r  required_keysr   r   field_docstringsr   r|  readonly_fieldsr   r  r~  r  fields_reprpluralr  	td_schemar   s                            r   rb  z!GenerateSchema._typed_dict_schema  s5    -.	 !!&&~6\	LII''7\	L< '#\	L \	L \	L 5^DL!!'&4+?+J+Jh+V'n- 
 -E^Uj,k ++008 AL"22>>^E\E\>]0>0P0P@B+11.A
''@@'B>_c'd$'+$P"/"B"B>_c_p_p"qK .0.9.?.?.A *J
!:!:!::O_OjOj!kJ,9*:O:OQ],^J) #m3[zZE[E[7[ G(
0F0FF  #j&<&<<'..z: )4&22:&*::1A*1M
.CCDDXDXZdfpq)-)G)G"J
X *H *F:&#* #"&))+M_+M"MK 1Q6FMMfs"5Q{mCWXfXoXoWrrs$*55 6EE $	 (99& ",!;!;!B!B!D% 33Az7S7ST% '&		 66y*B^B^BeBeBgh/
8S8S8Z8Z8\^cdyyCCFKCAL AL7\	L \	L \	L0 " & ! P5EEaHaOPN%oAL AL AL7\	L \	L \	L \	L \	L \	Ls   O$O		O$:OM;#O>A0N9/!NE9N9	#N4,A3N9	O(	O$;N
O	N

O	N1	N,	,N1	1N99O>O	O$O	O$$O-c                   | j                   j                  |      5  | j                  j                  |      5 \  }}||cddd       cddd       S t	        |      }||}	 t        j                  || j                        }|s|j                  D ci c]	  }|t         }}|r-|j                         D 	
ci c]  \  }	}
|	t        |
|       }}	}
t        j                   |j                         D 	
cg c]P  \  }	}
| j#                  |	|
t$        j&                  |j(                  j+                  |	t,        j.                              R c}
}	ddi      }t        j0                  |||      }| j                  j3                  |      cddd       cddd       S # t        $ r}t        j                  |      |d}~ww xY wc c}w c c}
}	w c c}
}	w # 1 sw Y   nxY wddd       y# 1 sw Y   yxY w)z!Generate schema for a NamedTuple.Nr  )r  default'pydantic_js_prefer_positional_argumentsTr;  )r1  )r   r  r   r  rp   rV   r  r   r  rG   r  _fieldsr   r   rq   r0   arguments_schema_generate_parameter_schemar9   NAMED_TUPLE_field_defaultsr   r   emptycall_schemar  )r   namedtuple_clsr  namedtuple_refr  r   r   r|  r   r   r  r  r   s                r   rd  z!GenerateSchema._namedtuple_schema1  s    !!&&~6(	HII''7(	H< '#(	H (	H (	H 5^DL!!'L+>>~[_[l[lm ?M?U?U.V!q#v.V.V 3>2C2C2E.
J j, GG 
  +;; 3>2C2C2E /
J 33""/;; . > > B B:y _	 4  DTJ  !,,-=~SabF99??GQ(	H (	H (	H  L1AA!D!KL /W9(	H (	H (	H (	H (	Hsv   G'G	G'G"!FGG!G8G
%G4AG	>G	G'	F>#F99F>>GG	G''G0c                   t               }|t        j                  u r |j                  ||      }n |j                  |||      }|j
                  J d       | j                  j                  |      5  | j                  |j
                  |g      }ddd       |j                         st        |      }t        j                  |      }	|||	d<   |j                  |j                  |	d<   |	S | j                  j                  }
t!        |
t"              r"|
j                  |
j                  |      |	d<   |	S t%        |
      r |
|      |	d<   |	S # 1 sw Y   xY w)zGenerate the definition of a field in a namedtuple or a parameter in a function signature.

        This definition is meant to be used for the `'arguments'` core schema, which will be replaced
        in V3 by the `'arguments-v3`'.
        r  Nz<field.annotation should not be None when generating a schemarY  r  )rs   r   r  r  from_annotated_attributer  r   r  r  r}  r  r0   arguments_parameterr  r  r  rX  r>   callable)r   r  r  r  r  rY  r}   r   r   parameter_schemar  s              r   r  z)GenerateSchema._generate_parameter_schema]  sd    -.	ioo%-I--j&IE6I66z7TZ[E+k-kk""''- 	H,,U-=-=wGF	H   "!%0F&::4H'+V$;;"(-W%   #22BBO/>:?T?T?`,;,A,A$,G )   /*,;D,A )#	H 	Hs   5EEc                   t               }|t        j                  u r |j                  ||      }n |j                  |||      }| j
                  j                  |      5  | j                  |j                  |g      }ddd       |j                         st        |      }t        j                  ||      }	|j                  |j                  |	d<   |	S | j                  j                  }
t!        |
t"              r"|
j                  |
j                  |      |	d<   |	S t%        |
      r |
|      |	d<   |	S # 1 sw Y   xY w)zGenerate the definition of a parameter in a function signature.

        This definition is meant to be used for the `'arguments-v3'` core schema, which will replace
        the `'arguments`' schema in V3.
        r  N)r  r   rY  r  )rs   r   r  r  r  r   r  r  r  r}  r  r0   arguments_v3_parameterr  r  r  rX  r>   r  )r   r  r  r  rY  r  r}   r   r   r  r  s              r   _generate_parameter_v3_schemaz,GenerateSchema._generate_parameter_v3_schema  sG   ( -.	ioo%-I--j&IE6I66z7TZ[E""''- 	H,,U-=-=wGF	H   "!%0F&==

 ;;"(-W%   #22BBO/>:?T?T?`,;,A,A$,G )   /*,;D,A ))	H 	Hs   "D99Ec                ^   t        |      | j                  |      }r|rt        fd|D              }|sG|t        v r*t	        j
                  t	        j                         gd      S t	        j
                  g       S |d   t        u rCt        |      dk(  r*t	        j
                  | j                  |d         gd      S t        d      t        |      dk(  r|d   dk(  rt	        j
                  g       S t	        j
                  |D cg c]  }| j                  |       c}      S c c}w )	zIGenerate schema for a Tuple, e.g. `tuple[int, str]` or `tuple[int, ...]`.c              3  6   K   | ]  }t        |        y wr   )rq   )r1  paramr   s     r   r2  z/GenerateSchema._tuple_schema.<locals>.<genexpr>  s     R%==Rs   r   )r   r   r<   z&Variable tuples can only have one typerQ   r   )rp   r  r   r   r0   tuple_schemar   Ellipsisr8  r  
ValueError)r   
tuple_typeparamsr  r   s       @r   rV  zGenerateSchema._tuple_schema  s    1<66zBFR6RRF [("//1G1G1I0J`abb #//33BZ8#6{a"//1E1EfQi1P0Qghii !!IJJ[A&)r/ ++B//++V\,]UT-A-A%-H,]^^,]s   D*c                `    t        j                  t        j                  t              dd      S )Nis_typezInput should be a typer  )r0   custom_error_schemarG  r   r  s    r   r]  zGenerateSchema._type_schema  s)    ..**40'!9
 	
r   c                n    ddl m} dd gi}t        j                  |t        j                         |      S )z/Generate schema for a zone_info.ZoneInfo objectrQ   )validate_str_is_valid_iana_tzr.  c                    dddS )Nrb  zoneinforc  r   r  s     r   r$  z1GenerateSchema._zoneinfo_schema.<locals>.<lambda>  s    hZd=e r   r   r2  )rl  r  r0   rn  r  )r   r  r2  s      r   rp  zGenerateSchema._zoneinfo_schema  s8    >+.e-fg;;)%::<
 	
r   c           	         | j                  |d      }t        j                  |D cg c]  }| j                  t        |          c}      S c c}w )z*Generate schema for `type[Union[X, ...]]`.Tr  )r  r0   r  r  r   )r   r  r4  s      r   _union_is_subclass_schemaz(GenerateSchema._union_is_subclass_schema  sF    44Z$4O''VZ([d)=)=d4j)I([\\([s   Ac           
        | j                  |      }t        j                  |      xs |}t        j                  |      r| j                         S t        j                  |      r"| j                  t        |j                           S t        j                  |      r|j                  rXt        t        |j                              r| j                  |j                        S t        j                   |j                        S |j"                  rCt        j$                  |j"                  D cg c]  }| j                  t        |          c}      S | j                         S t        t        |            r| j                  |      S t        j&                  |      r| j)                  |      }t        j*                  |      r0t-        d|dt/        j0                  t        |             dd      t3        j4                  |      s3|#t        j                   t        j6                        S t9        d|      t        j                   |      S c c}w )z-Generate schema for a type, e.g. `type[int]`.z`Subscripting `type[]` with an already parametrized type is not supported. Instead of using type[z], use type[z].Nr   zExpected a class, got )r6  rV   annotated_typer8   r  r]  r[  r  r   r  
is_typevar	__bound__r;   r6   r  r0   is_subclass_schema__constraints__r  r<  r  is_generic_aliasrH   rU   display_as_typer@  ro  rT  r   )r   type_
type_paramcs       r   rw  zGenerateSchema._subclass_schema  s   //6
 #11*=K
  ,$$&&,,Z8''Z-A-A(BCC&&z2##":j.B.B#CD99*:N:NOO"55j6J6JKK++"//XbXrXr0sST1E1Ed1g1N0stt((**Z
3411*==%%j1!44Z@
--j9'--7N,uG\G\]ghr]sGtFuuwy 
 ??:. %&99-:P:PQQ"8 GHH11*==) 1ts   )Ic                   ddl m} | j                  |      }t        j                  |      }t        |      }t        j                  t        j                  d      }t        j                  |      s1ddlm} t        j                  |t        j                  ||      g      }t        j                  ||d      }t        j                   |||      S )	z5Generate schema for a Sequence, e.g. `Sequence[int]`.rQ   r  Sequencer  )sequence_validatorTr  )r)  r]  r   )r  r  r  r0   r  r{   rG  rj  r$  r8   r  rl  r%  r  r  r  ro  )	r   r  r  r  r  r)  r]  r%  r   s	            r   rW  zGenerateSchema._sequence_schema  s    =//
;!--.>?$[1#66vQ[\$$Z07'44 K KL^`k lmM $GG'0@4
 00#=P]
 	
r   c                l    | j                  |      }t        j                  | j                  |            S )z$Generate a schema for an `Iterable`.)r6  r0   generator_schemar  )r   r   	item_types      r   rX  zGenerateSchema._iterable_schema(  s.    ..u5	++D,@,@,KLLr   c                   ddl m} dd gi}t        j                  t	        d      dt        j
                               }|t        j                  u s|t        j                  u r"t        j                  |j                  ||      S | j                  |d	
      d   }|t        u r"t        j                  |j                  ||      S |t        u r"t        j                  |j                  ||      S t!        d|d      )NrQ   )rl  r.  c                    dddS )Nrb  regexrc  r   r  s     r   r$  z0GenerateSchema._pattern_schema.<locals>.<lambda>1  s    hZa=b r   patternr   )r   return_schemar  Tr  r   r  r   )r   rl  r0   r   r   rp  rj  Patternrern  pattern_either_validatorr  r  pattern_str_validatorrx  pattern_bytes_validatorrF   )r   pattern_typerl  r2  serr  s         r   rg  zGenerateSchema._pattern_schema.  s   !+.b-cd>>y!V;CYCYC[
 6>>)\RZZ-G??44CRZ  55 6 
  C<??11x  e^??333QY  02^_k^nno0pqqr   c           
     V   t        j                  t        j                  t        j                  t        j                         t        j
                  t        j                  j                        g      t        j
                  t        j                  j                              dd      S )Nr\  rh  zInput should be hashable)r   r  r  )	r0   r  ro  r  r   rG  r  abcHashabler  s    r   ri  zGenerateSchema._hashable_schemaJ  sy    ..44'44 ++-{/M/MkooNfNf/gh *<<[__=U=UV	 ,!;	
 		
r   c                H	     j                   j                  |      5   j                  j                  |      5 \  }}||cddd       cddd       S |j                  j                  d      }|t        |t              sq|d   dk(  r j                  j                  |      }t        |      }|r- j                  j                  |      cddd       cddd       S |cddd       cddd       S t        |      }||}t        |dd      }ddlm}	  j                  j                  |      5   j                   j                  |      5   |	|      rk|j"                  j%                         D 
ci c]  \  }
}|
t'        |       }}
}|rK|j)                         D ]  } |j*                  |g j,                    ! nt/        || j0                        } j0                  j2                  d	k(  r7|j%                         D ]$  \  }}|j4                  d
u st7        d| dd       |j                  j                  d      xs t9        j:                  |      t=         fd|j%                         D        d       }t?        |d      }t?        |d      }tA        jB                  |jD                  |jF                  j)                         D cg c]  } jI                  |jJ                          c}|      }tM        |jN                  j)                         d      }jP                  j)                         }tS        ||d      } j0                  jU                  |jD                        }tA        jV                  |||||t        jX                  |      D cg c]  }|jZ                   c}|| j                   j\                  j^                  	      } ja                  |jb                  j)                               }tS        ||d      } j                  j                  |      cddd       cddd       cddd       cddd       S c c}}
w c c}w c c}w # 1 sw Y   nxY wddd       n# 1 sw Y   nxY wddd       n# 1 sw Y   nxY wddd       y# 1 sw Y   yxY w)z Generate schema for a dataclass.Nr  r   r  r  r<   )is_pydantic_dataclass)r   r   r  FzField zd has `init=False` and dataclass has config setting `extra="allow"`. This combination is not allowed.z dataclass-init-false-extra-allowr   r  c              3  J   K   | ]  \  }}j                  ||        y wr   )r  )r1  r   r   r   r   s      r   r2  z3GenerateSchema._dataclass_schema.<locals>.<genexpr>  s$     a$!QT33Aq*Eas    #c                (    | j                  d      duS )Nr  F)r   )r   s    r   r$  z2GenerateSchema._dataclass_schema.<locals>.<lambda>  s    !%%	"2%"? r   )key__post_init__	__slots__)r  collect_init_onlyr  r  )r  r  r1  r   slotsr  r  r  )2r   r  r   r  r  r   rX  rt   r  r[   r  rp   r   rq  r9  r   r   r  r   r	   r?  apply_typevars_mapr  rl   r  extrar  rH   r`   r  sortedr  r0   dataclass_args_schemar   r  r  r  r   r  r  r  r  dataclass_schemar   r  r  r  r  r  )r   	dataclassr  dataclass_refr  r   r1  r   r  r9  f_namer~  r   r   r   r4  has_post_init	has_slotsr  args_schemar   r  r  	dc_schemar   s   `                       @r   rs  z GenerateSchema._dataclass_schemaV  s   
 !!&&y1d	LII''	2d	L7 '#d	L d	L d	L ''++,FGF!*V^*L&>]2!YY99&AFfo99GGO!d	L d	L d	L$ "%d	L d	L d	L( 5Y?L!"	
 Y(=tDF;""''	2 ELD4N4N4S4STZ4[ EL(3
 R[QnQnQtQtQvw;M6:fd:&66wFw#%+]]_ [E4E44\ZDDYDYZ[ 6!%1'+';';F ''--8-3\\^ )
E ::."3"( 5C !D%G#  '//334MNqR`RfRfgpRq
 aRXR^R^R`a? !(	? C#I{;	)??&& ",!;!;!B!B!D% 33Az7S7ST% '4  0Z=W=W=^=^=`bfg#-#>#>#E#E#G 5lDTV]^"22>>YEWEW>X'88 #)+%4?4F4Fy4QR5EJJR#&  55::AA	 66y*B^B^BeBeBgh/8H'RyyCCFKKEL EL EL?d	L d	L d	LJ xD%( SyEL EL EL EL EL?d	L d	L d	L d	L d	L d	Ls   RR	RA7R	RR	R2=R/Q.&Q	1Q	BQ	B9Q	#Q1B&Q	Q*A:Q	$	Q.-	R6	R	Q	Q"Q.%	R.Q73R:	RR	RR!c                L   | j                  |      }d}| j                  }|j                  rbt        |      }|j                  }||j
                  ur=| j                  \  }}t        j                  |||dh      }	| j                  |	d         }t        j                  |||      S )zsGenerate schema for a Callable.

        TODO support functional validators once we support them in Config
        Nr<  )globalnslocalnsinclude_keys)r-  )_arguments_schemar  validate_returnr   return_annotationr  r  rV   get_function_type_hintsr  r0   r  )
r   functionr  r-  r   sigreturn_hintrN  rO  
type_hintss
             r   rn  zGenerateSchema._call_schema  s    
  11(;7;--))H%C//K#))+$($9$9!'*BBxPXz
 !% 4 4Z5I J&&'
 	
r   c                   t         j                  dt         j                  dt         j                  di}t	        |      }| j
                  \  }}t        j                  |||      }g }d}	d}
d}t        |j                  j                               D ]9  \  }\  }}|j                  |j                  u rt        j                  t        t              }n||   }| ||||      }|dk(  rX|j!                  |j"                        }|?| j%                  ||t&        j(                  |j*                  |      }|j-                  |       |j"                  t         j.                  k(  r| j1                  |      }	|j"                  t         j2                  k(  sJ |j"                         t        j4                  |      }|t7        |      xs |}t9        |      st;        d|d	      |j                  j                         D ch c]%  \  }}|j"                  t         j                  k7  s$|' }}}|j=                  |j>                        }|rOt;        d
|j@                  dtC        |      dk\  rdnd ddjE                  d tG        |      D               d	      d}| jI                  |t7        |            }
'd}| j1                  |      }
< tK        jL                  ||	||
| jN                  jP                        S c c}}w )z Generate schema for a Signature.positional_onlypositional_or_keywordkeyword_onlyrN  rO  Nskip7Expected a `TypedDict` class inside `Unpack[...]`, got unpack-typed-dictr   Typed dictionary  overlaps with parameterr<   r  r   r  r  c              3  2   K   | ]  }t        |        y wr   r  r1  ps     r   r2  z3GenerateSchema._arguments_schema.<locals>.<genexpr>       (UQa(Ur  overlapping-unpack-typed-dictzunpacked-typed-dictuniform)var_args_schemavar_kwargs_modevar_kwargs_schemavalidate_by_name))r   POSITIONAL_ONLYPOSITIONAL_OR_KEYWORDKEYWORD_ONLYr   r  rV   rT  	enumerate
parametersr   r  r  rj  r%   r   r   kindr  r9   FUNCTIONr  r  VAR_POSITIONALr  VAR_KEYWORDunpack_typer6   r7   rH   intersectionr  r   r8  r  rC  rb  r0   r  r  rl  )r   rU  parameters_callbackmode_lookuprV  rN  rO  rX  arguments_listri  rk  rj  ir  re  r  resultparameter_mode
arg_schemarv  r  non_pos_only_param_namesoverlapping_paramss                          r   rQ  z GenerateSchema._arguments_schema  s   
 %%'8++-D""Nr
 ! 11'"::8h`gh
?A9=;?<@%cnn&:&:&<= .	ILAya||syy(#[[c2
'-
".,QjAV#(__QVV4N)!<<*&6&?&?N
 %%j19333"&"6"6z"Bvv!6!66>>+77
C*'4CF'//UVaUde!4 
 -0NN,@,@,B0!(qaffPYPiPiFi0, 0 *B)N)NvOeOe)f&)///BBZ&)*<&=&BsK1#yy(U&AS:T(UUVX "A	  '<O(,(?(?ZXcMd(e%&/O(,(<(<Z(H%].	I` ++++/!11BB
 	
%0s   ?%K;%K;c                v   t         j                  dt         j                  dt         j                  dt         j                  di}t        |      }| j                  \  }}t        j                  |||      }g }t        |j                  j                               D ]  \  }	\  }
}| ||	|
|j                        }|dk(  r&|j                  t         j                  u rt        j                  t         t               }n||
   }|j#                  |j$                        }|,|j$                  t         j&                  k(  sJ |j$                         t        j(                  |      }|t+        |      xs |}t-        |      st/        d|d	      |j                  j                         D 
ch c]%  \  }
}|j$                  t         j                  k7  s$|
' }}
}|j1                  |j2                        }|rOt/        d
|j4                  dt7        |      dk\  rdnd ddj9                  d t;        |      D               d	      d}|}nd}|j=                  | j?                  
|t@        jB                  |jD                                tG        jH                  || jJ                  jL                        S c c}}
w )NrZ  r[  var_argsr\  r]  r^  r_  r`  r   ra  rb  r<   r  r   r  r  c              3  2   K   | ]  }t        |        y wr   r  rd  s     r   r2  z6GenerateSchema._arguments_v3_schema.<locals>.<genexpr>U  rf  r  rg  var_kwargs_unpacked_typed_dictvar_kwargs_uniform)r  )rl  )'r   rm  rn  rt  ro  r   r  rV   rT  rp  rq  r   r  r  rj  r%   r   r   rr  ru  rv  r6   r7   rH   rw  r  r   r8  r  rC  r  r  r9   rs  r  r0   arguments_v3_schemar  rl  )r   rU  rx  ry  rV  rN  rO  rX  parameters_listr{  r  re  r|  r  r}  rv  r  r  r  s                      r   _arguments_v3_schemaz#GenerateSchema._arguments_v3_schema$  s    %%'8++-D$$j""N	
 	 ! 11'"::8h`gh
BD%cnn&:&:&<= +	LAya".,QallCV#||y.#[[c2
'-
(__QVV4N%vv!6!66>>+77
C*'4CF'//UVaUde!4 
 -0NN,@,@,B0!(qaffPYPiPiFi0, 0 *B)N)NvOeOe)f&)///BBZ&)*<&=&BsK1#yy(U&AS:T(UUVX "A	  &FN!,J%9N""22*&6&?&?YZYbYb 3 O+	Z ..!11BB
 	
-0s   *%J5J5c                   	 |j                         }|r| j                  |j                        S |j                  x}r"| j                  t        j                  |         S |j                  x}r@| j                  |      }t        j                  d t        j                               |d<   |S t        j                         S # t        $ r Y w xY w)Nc                     ||       S r   r   )r#  r  s     r   r$  z>GenerateSchema._unsubstituted_typevar_schema.<locals>.<lambda>x  s
    QqT r   )r   r   )has_defaultr  __default__r  r  rv  rj  r$   r  r0   r  r   )r   typevarr  constraintsr   r   s         r   rk  z,GenerateSchema._unsubstituted_typevar_schemah  s    	A!--/K
 ++G,?,?@@!111;1%%fll;&?@@%%%5%))%0F&1&U&U!"--/'F?# M%%''%  		s   C 	CCc                   |j                   j                  t        ur|j                   j                  }n6	 t        j                  |j
                  | j                  j                        }|t        u rt        dd      t        || j                        }t        j                  |j                   |      |_         | j!                  |      }| j#                  |t%        |j'                         |j(                              }| j*                  j,                  }|(| j/                  ||j                   |j(                         | j1                  | j*                  |j                   |j(                         t3        |j                         \  }}i }	t5        |	ddi|r|ni |	       t7        j8                  |j(                  ||j                   j:                  |	
      S # t        $ r}t        j                  |      |d }~ww xY w)NrO  zComputed field is missing return type annotation or specifying `return_type` to the `@computed_field` decorator (e.g. `@computed_field(return_type=int | str)`)zmodel-field-missing-annotationr   )return_type)r  r  r  readOnlyTr  )r-  r  r2  )r   r  r.   rR   get_callable_return_typefuncr  localsr  rG   r  rH   rq   r   rq  replacer  r  r   r?  r   r  r  r  r  r   rZ   r0   computed_fieldr  )
r   r  r  r  r|  return_type_schemar  r  r  r  s
             r   r  z%GenerateSchema._computed_field_schema  s   
 66%66&&,,KL *BB166SWShShSoSop ++#f5  $K1C1CD $$QVVE!11+>!::01B1I1I1KQ^^\

 ..>>&>> /QVVabaoao ?  	778L8LaffVWVdVde1Z[\[a[a1b..(*!+T jM`6Ifh j/	

 ))NN*<AFFLL[h
 	
E  L1AA!D!KLs   5G 	G<!G77G<c                    t               }| j                  |d      ^}}| j                  ||      }|D ]  }t        ||      st	        ||      } |S )zdGenerate schema for an Annotated type, e.g. `Annotated[int, Field(...)]` or `Annotated[int, Gt(0)]`.Tr  )rs   r  r  rX  r  )r   r  r}   r  r   r   r  s          r   r>  z GenerateSchema._annotated_schema  sm    ,.	$($I$I %J %
!k ((kB & 	:J*i0%j&9	: r   c                    | S r   r   r"  s    r   r$  zGenerateSchema.<lambda>  s    q r   c                >    t        t        j                  |            }g }d fd}t        |       }|D ]  }| j	                  |||      }  |      }|r|j                  di       }	t        |	|       t         j                  j                  |      S )a  Apply arguments from `Annotated` or from `FieldInfo` to a schema.

        This gets called by `GenerateSchema._annotated_schema` but differs from it in that it does
        not expect `source_type` to be an `Annotated` object, it expects it to be  the first argument of that
        (in other words, `GenerateSchema._annotated_schema` just unpacks `Annotated`, this process it).
        c                    j                  |       }|j                  |       }t        |       }|*t        |j                        }|j                  ||        |      S r   )r  r  r  r  r   r  )r  r   r  r  r   r  r  s       r   inner_handlerz8GenerateSchema._apply_annotations.<locals>.inner_handler  sm    AA#{SF~44S9#DS#I #/"9&$))"L".))/;OP)&11r   r2  ) pydantic_js_annotation_functionsr  r   r<  r*   )
r=  rT   expand_grouped_metadatary   _get_wrapped_inner_schemar  rZ   r   r  r   )
r   r  r   r  r  r  get_inner_schemar  r   r  s
   `` `      r   r  z!GenerateSchema._apply_annotations  s     4LL[YZHJ(	2 8tL% 	J!#== *.N 	 "+.+"--j"=M Qqr;D<P<P<^<^`kmsttr   c                "   t               }t        ||      rM|j                  D ]  }| j                  ||      } |j                  | j                  ||j                        }|S |d   dk(  r?|j                  dt        j                               }| j                  ||      }|r||d<   |S |}|j                  d      }|F|j                         }|dt        |       z   }| j                  j                  |      x}	|	S ||d<   no|d   dk(  rg|d   }| j                  j                  |      x}
E|
j                         }|dt        |       z   }| j                  j                  |      x}	|	S ||d<   t        j                  ||      }||S |S )Nr   r   r   r1  r6  definition-refr;  )rs   rX  r2  _apply_single_annotationr  r  r   r0   r   r	   r  r   get_schema_from_refrT   apply_known_metadata)r   r   r2  r}   field_metadatar  r*  r1  new_refexistingreferenced_schemamaybe_updated_schemas               r   r  z'GenerateSchema._apply_single_annotation  s   ,.	h	*"*"3"3 O66v~NO %%1;;FHDZDZ[M&>Z'JJx)?)?)ABE11%BE#(x M jj?[[]FaX/00G II99'BBO#F5MF^//&C%)YY%B%B3%GG!T*//1!DN#3 44 $		 = =g FFHS#O 'u8MMhX^_+''r   c                    t               }t        ||      rQ|j                  D ]  }| j                  ||      } t	        |      \  }}|j                  di       }t        |||       |S )Nr2  r  )rs   rX  r2  $_apply_single_annotation_json_schemar   r  rZ   )r   r   r2  r}   r  r  r  r  s           r   r  z3GenerateSchema._apply_single_annotation_json_schema	  s~     -.	h	*"*"3"3 [BB6>Z[ 6__g5h2!2"--j"=M 3FZk r   c                R     t        dd       d fd}t        |       S )Nr!  c                    
 |       }n, |       }j                  |      }j                  |      }t              }|j                  |       |S r   )r  r  r  r  )r  r   r  r  annotation_get_schemar  r  r   s      r   new_handlerz=GenerateSchema._get_wrapped_inner_schema.<locals>.new_handler/	  si    $0.v7GH)&166vzJBB6:V#DZ#P #/0778LMMr   )r  r   r<  core_schema.CoreSchema)r   ry   )r   r  r  r  r  r  s   ```` @r   r  z(GenerateSchema._get_wrapped_inner_schema'	  s0     ?FjRprv>w	 	 ,K>>r   c                   |rt        |      }|d   dk(  r|d   }| j                  ||      |d<   |S d|v r| j                  j                  |      }|d   }t	        |j
                  |j                  j                        \  }}|j                  j                  t        ur|j                  j                  }n6	 t        j                  |j
                  | j                  j                        }|t        u rd}	n| j#                  |      }	|j                  j                  dk(  r=t%        j&                  |j
                  |||	|j                  j(                  	      |d
<   |S |j                  j                  dk(  sJ t%        j*                  |j
                  |||	|j                  j(                  	      |d
<   |S # t        $ r}t        j                   |      |d}~ww xY w)z$Apply field serializers to a schema.r   r  r   r1  r   r  Nr   )is_field_serializerr`  r-  r   r   r   )r	   r  r   r  rh   r  r   rY  r  r.   rR   r  r  r  r  rG   r  r  r0   r  r   r   )
r   r   serializersr   
serializerr  r`  r  r|  r-  s
             r   r  z'GenerateSchema._apply_field_serializers>	  s    &\Ff~.%h/#'#@#@{#[x &EEfM %RJ,DZ__V`VeVeVjVj,k)**2CC(oo99P #."F"F"1F1F1M1M#K // $ $ 4 4[ A##v-*5*Y*YOO(;%"/(oo77+'   "++w66*5*Z*ZOO(;%"/(oo77+' 3 ! P5EEaHaOPs   85F7 7	G GGc                    |j                  dd      }|rJt        |      d   }t        |j                  |j                  j
                        }|j                  j                  t        ur|j                  j                  }n6	 t        j                  |j                  | j                  j                        }|t        u rd}n| j                  |      }|j                  j
                  dk(  r8t!        j"                  |j                  |||j                  j$                        }	n7t!        j&                  |j                  |||j                  j$                        }	|	|d<   |r||d<   |S # t        $ r}t        j                  |      |d}~ww xY w)z$Apply model serializers to a schema.r1  Nr   r  r   )r`  r-  r   r   )popr=  ri   r  r   rY  r  r.   rR   r  r  r  r  rG   r  r  r0   r  r   r   )
r   r   r  r1  r  r`  r  r|  r-  
ser_schemas
             r   r  z'GenerateSchema._apply_model_serializersv	  s[    !**UD1k*2.J/
AUAUVH**2CC(oo99P #."F"F"1F1F1M1M#K // $ $ 4 4[ A##v-4?4c4cOO%"/(oo77	5
 )MMOO%"/(oo77	
 '1F?#F5M5 ! P5EEaHaOPs   5E) )	F2FF)NN)r   rW   r   zNsResolver | Noner   zMapping[TypeVar, Any] | Noner<  Noner<  r  )r<  rW   )r<  ru   )r<  r   )r  r   r<  r*   )r  r   r  r   r<  r*   )r9  z
type[Enum]r<  r*   )r   r   r<  r*   )r   r   rw  r   r<  r*   )r   r   r  r   r  r   r<  r*   )r<  r*   r  )r   r*   r  zstr | Discriminator | Noner<  r*   r  )r  r*   r  zCallable[..., Any]r<  r  )r  r   r<  r  )r  ztype[BaseModel]r<  r  )r  r   r<  r   )r  r   r  r   r<  zcore_schema.CoreSchema | None)r  r   r  zLiteral[True]r<  ztuple[Any, ...])r  r   r<  tuple[Any, ...] | None)F)r  r   r  r   r<  r  )r  r   r<  ztuple[Any, Any])r  r   r  r   r<  r*   )
r  r  r~  r}   r   r`   r  r   r<  zcore_schema.TypedDictField)r  r  r~  r}   r   r`   r<  zcore_schema.ModelField)r  r  r~  r}   r   r`   r<  zcore_schema.DataclassField)r  %Callable[[str], str] | AliasGeneratorr~  r}   r   r  r<  r  )r  r  r  r|   r  r  )r   rW   r~  FieldInfo | ComputedFieldInfor   r  r<  r  )r  r  r~  r}   r   r`   r<  _CommonField)r  r   r<  r  )r  r3   r<  r*   )r  r   r<  r*   )r  r   r  r   r<  r  )r  r   r  r   r<  r  )r  r  r  z	type[Any]r  r9   r  r   rY  zJLiteral['positional_only', 'positional_or_keyword', 'keyword_only'] | Noner<  zcore_schema.ArgumentsParameter)r  r  r  r   r  r9   rY  zLiteral['positional_only', 'positional_or_keyword', 'keyword_only', 'var_args', 'var_kwargs_uniform', 'var_kwargs_unpacked_typed_dict']r  r   r<  z core_schema.ArgumentsV3Parameter)r  r   r<  r  )r<  r  )r   r   r<  r  )r  r   r<  r  )r   r   r<  zcore_schema.GeneratorSchema)r3  r   r<  r  )rF  ztype[StandardDataclass]r  ztype[StandardDataclass] | Noner<  r  )rU  ValidateCallSupportedTypesr<  zcore_schema.CallSchemar   )rU  r  rx  ParametersCallback | Noner<  zcore_schema.ArgumentsSchema)rU  r  rx  r  r<  zcore_schema.ArgumentsV3Schema)r  ztyping.TypeVarr<  r  )r  zDecorator[ComputedFieldInfo]r  z2dict[str, Decorator[FieldSerializerDecoratorInfo]]r<  zcore_schema.ComputedField)r  r   r<  r  )r  r   r   z	list[Any]r  z"Callable[[CoreSchema], CoreSchema]r<  r*   )r   r  r2  r   r<  r  )r  r@   r  r   r  zlist[GetJsonSchemaFunction]r<  ry   )r   r  r  z-list[Decorator[FieldSerializerDecoratorInfo]]r<  r  )r   r  r  z1Iterable[Decorator[ModelSerializerDecoratorInfo]]r<  r  )Nr   r   r   r   r>  r   r   propertyr  r  r  r  r  r  r  rJ  rq  r  r  r  r  r  r  r  r  r  r  r  r  r  r,  r&   r  r6  r9  r  rA  rt  r  r  r  staticmethodr  r  r  r
  rv  r\  ra  rb  rd  r   r  r  r  rV  r]  rp  r  rw  rW  rX  rg  ri  rs  rn  rQ  r  rk  r  r>  r  r  r  r  r  r  __classcell__)r   s   @r   r   r   >  s   fI *.59	#%# '# 3	#
 
#
 / / 1 1 < <
IkHNFP
B8t
2$L
"
2	
 1K	&
	/%% 
 %NKLZ9wv, i iW W	 $8t.l1.r 

 
 #	
 
 
$
&

 
 #	

 
 
"

 
 #	

 
$
* /[>/[LU/[cf/[	/[ /[b (\>(\.(\ !(\ (\T %%%3P%^a%	% %*G
G
%.G
<JG
	G
R6H&hLT*Hb ![_% %  %  !	% 
 %  Y%  
(% h !/ /  /  !	/ 

/  /  
*/ b_<
	
]
%>N
.Mr8

hL0hL:XhL	hLT
4 fjI
2I
IbI
	$I
X fjB
2B
IbB
	&B
H(.1
'1
 N1
 
#	1
f& FQ	*u*u *u !C	*u
 
*uX(T,8;	 ?.? ? +F	?
 
&?.6&6 C6 
 	6p-,-;l-	-r   r   c                .    t        j                  | |      S r   )r0   !no_info_before_validator_functionr  r   r6  s      r   r$  r$  	  s    0]0]^_ag0h r   c                .    t        j                  | |      S r   )r0   rF  r  s      r   r$  r$  	  s    {/[/[\]_e/f r   c                ,    t        j                  |       S r   )r0   rn  )r  re  rf  s      r   r$  r$  	  s    K,X,XYZ,[ r   c                .    t        j                  | |      S r   )r0   r  r  s      r   r$  r$  	  s    k.Y.YZ[]c.d r   c                2    t        j                  | ||      S N)r   )r0   #with_info_before_validator_functionr  r   r   s      r   r$  r$  	  s    ;;j;j	6j< r   c                2    t        j                  | ||      S r  )r0   "with_info_after_validator_functionr  s      r   r$  r$  	  s    +:h:h	6j; r   c                0    t        j                  | |      S r  )r0   r&  )r  r6  r   s      r   r$  r$  	  s    [5c5c	j6 r   c                2    t        j                  | ||      S r  )r0   !with_info_wrap_validator_functionr  s      r   r$  r$  	  s    9f9f	6j: r   ))r   no-info)r   r  )r   r  )r   r  )r   	with-info)r   r  )r   r  )r   r  zMapping[tuple[FieldValidatorModes, Literal['no-info', 'with-info']], Callable[[Callable[..., Any], core_schema.CoreSchema, str | None], core_schema.CoreSchema]]_VALIDATOR_F_MATCHc                    |D ]b  }t        |j                  |j                  j                        }|rdnd}t	        |j                  j                  |f   |j                  | |      } d | S )a  Apply validators to a schema.

    Args:
        schema: The schema to apply validators on.
        validators: An iterable of validators.
        field_name: The name of the field if validators are being applied to a model field.

    Returns:
        The updated schema.
    r  r  )rj   r  r   rY  r  )r   r  r   	validatorr`  val_types         r   r   r   	  sg    "   i	$Y^^Y^^5H5HI"*;	#Y^^%8%8($CDY^^U[]gh	i
 Mr   c                B    | D ]  }|j                   j                  s y y)a?  In v1, if any of the validators for a field had `always=True`, the default value would be validated.

    This serves as an auxiliary function for re-implementing that logic, by looping over a provided
    collection of (v1-style) ValidatorDecoratorInfo's and checking if any of them have `always=True`.

    We should be able to drop this function and the associated logic calling it once we drop support
    for v1-style validator decorators. (Or we can extend it and keep it if we add something equivalent
    to the v1-validator `always` kwarg to `field_validator`.)
    TF)r   r^  )r  r  s     r   r  r  	  s(       	>>   r   c                \   | j                  dd      }|D ]  }|dk(  r|j                  j                  dk7  r#|dk(  r|j                  j                  dk(  rBt        |j                  |j                  j                        }|j                  j                  dk(  rF|r"t        j                  |j                  |       } t        j                  |j                  |       } |j                  j                  dk(  rH|r#t        j                  |j                  |       } 	t        j                  |j                  |       } ,|j                  j                  dk(  sJ |r#t        j                  |j                  |       } lt        j                  |j                  |       }  |r|| d<   | S )	a  Apply model validators to a schema.

    If mode == 'inner', only "before" validators are applied
    If mode == 'outer', validators other than "before" are applied
    If mode == 'all', all validators are applied

    Args:
        schema: The schema to apply validators on.
        validators: An iterable of validators.
        mode: The validator mode.

    Returns:
        The updated schema.
    r1  Nr  r   r  r   )rU  r   r   )r  r   rY  rj   r  r0   r  r  r  r  r  rF  )r   r  rY  r1  r  r`  s         r   r  r  	  s`   & jj-C n	7?y~~22h>7?y~~22h>$Y^^Y^^5H5HI>>&($FFPYP^P^gmn$DDinnekl^^  H,$HHR[R`R`iop$FFPYP^P^gmn>>&&'11$GGQZQ_Q_hno$EEy~~flm+n, uMr   c                   | j                   r@t        j                  || j                   t        | j                         | j                        S | j
                  t        ur,t        j                  || j
                  | j                        S |S )a  Wrap schema with default schema if default value or `default_factory` are available.

    Args:
        field_info: The field info object.
        schema: The schema to apply default on.

    Returns:
        Updated schema by default value or `default_factory`.
    )default_factorydefault_factory_takes_datar  )r  r  )r  r0   with_default_schemarn   r  r  r.   )r~  r   s     r   r  r  
  s     !!..&66'DZE_E_'`'88	
 	
 
		#4	4..J..A\A\
 	
 r   c                (   t        | dd      }t        | d      r]t               }|duxr% |j                  j                  |t        |dd      fv}|s&t        | dd      }t        d|rd| dnd	 d
d      t        |       x}t        |      S |y|S )z`Extract `__get_pydantic_json_schema__` from a type, handling the deprecated `__modify_schema__`.__get_pydantic_json_schema__N__modify_schema__r-  r   zjThe `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` insteadz in class ``r   r   zcustom-json-schemar   )r   r  rr   r  r-  rH   r6   r  )r   js_modify_functionr   has_custom_v2_modify_js_funccls_namer  s         r   r  r  0
  s     %CTJr&',.	 d* W66??&0BJPT(UVW 	% ,r:t4H#=Zb{8*TU=Vhj<kkln)  R. - 188!r   c                  J    e Zd ZU ded<   ded<   ded<   ded<   ded	<   d
ed<   y)r  r  r   4str | list[str | int] | list[list[str | int]] | Nonerz  
str | Noner{  bool | Nonery  r  zdict[str, Any]r2  N)r   r   r   r  r   r   r   r  r  P
  s&    ""JJ##&&r   r  )rz  r{  ry  r  r2  c                   | |||||dS )Nr   rz  r{  ry  r  r2  r   r  s         r   r  r  Y
  s      ,2!6 r   r   c                X    | d   dk(  r|j                  | d         S | d   dk(  r| d   S | S )Nr   r  r;  r  r   )r  r   r  s     r   r  r  l
  sA    f~))..vl/CDD	=	(hr   c                \    d| v ry| j                  d      }|syt        |      dk(  rd|v ryy)a  Determine the inlining behavior of the `'definition-ref'` schema.

    - If no `'serialization'` schema and no metadata is attached, the schema can safely be inlined.
    - If it has metadata but only related to the deferred discriminator application, it can be inlined
      provided that such metadata is kept.
    - Otherwise, the schema should not be inlined. Doing so would remove the `'serialization'` schema or metadata.
    r   keepr2  inlinerQ   %pydantic_internal_union_discriminatorpreserve_metadata)r   r8  )def_refr2  s     r   _inlining_behaviorr  u
  s=     '!{{:&H
8}EQ"r   c                  l    e Zd ZU dZded<   	 ded<   	 ddZedd       ZddZdd	Z	dd
Z
ddZddZy)r   z*Keeps track of references and definitions.zset[str]_recursively_seenz!dict[str, core_schema.CoreSchema]r  c                0    t               | _        i | _        y r   )r   r  r  r  s    r   r   z_Definitions.__init__
  s    !$r   c             #  H  K   t        |      }|| j                  v s|| j                  v r|t        j                  |      f y| j                  j                  |       	 |df | j                  j                  |       y# | j                  j                  |       w xY ww)a  Get a definition for `tp` if one exists.

        If a definition exists, a tuple of `(ref_string, CoreSchema)` is returned.
        If no definition exists yet, a tuple of `(ref_string, None)` is returned.

        Note that the returned `CoreSchema` will always be a `DefinitionReferenceSchema`,
        not the actual definition itself.

        This should be called for any type that can be identified by reference.
        This includes any recursive types.

        At present the following types can be named/recursive:

        - Pydantic model
        - Pydantic and stdlib dataclasses
        - Typed dictionaries
        - Named tuples
        - `TypeAliasType` instances
        - Enums
        N)r\   r  r  r0   r?  adddiscard)r   r   r1  s      r   r  z_Definitions.get_schema_or_ref
  s     , 2$(((C43D3D,D??DEE""&&s+4Dk!&&..s3&&..s3s   AB" B &B"BB"c                8    | j                   j                  |      S )z,Resolve the schema from the given reference.)r  r   )r   r1  s     r   r  z _Definitions.get_schema_from_ref
  s      $$S))r   c                T    |d   }|| j                   |<   t        j                  |      S )zStore the schema as a definition and return a `'definition-reference'` schema pointing to it.

        The schema must have a reference attached to it.
        r1  )r  r0   r?  )r   r   r1  s      r   r  z/_Definitions.create_definition_reference_schema
  s.    
 Um!'#66s;;r   c                D    |d   D ]  }|| j                   |d   <    |d   S )zZStore the definitions of the `'definitions'` core schema and return the inner core schema.r  r1  r   )r  )r   r   
def_schemas      r   r  z_Definitions.unpack_definitions
  s6     / 	>J3=Dj/0	>hr   c                   | j                   }	 t        ||      }i }|d   j	                         D ]  \  }}|t        |      x}dk7  r|dk(  r2|j                          |j                  | j                  ||             O|dk(  sU|j                  d      }	|j                          |j                  | j                  ||             |	|d<   | j                  ||      ||<    |d   D ]`  }
|
d   j                  d	d      }|t        j                  |
j                         ||      }|
j                          |
j                  |       b |r't        j                  |g |j                         
      }|S # t        $ r}t        |d}~ww xY w)zFinalize the core schema.

        This traverses the core schema and referenced definitions, replaces `'definition-ref'` schemas
        by the referenced definition if possible, and applies deferred discriminators.
        )r  Ncollected_referencesr  r  r  r2  deferred_discriminator_schemasr  r  )r  rx   rw   r   r   r  clearr'  _resolve_definitionr  rS   r  r	   r0   definitions_schemar?  )r   r   r  gather_resultr|  remaining_defsr1  inlinable_def_refinlining_behaviormetacsr  applieds                r   r  z_Definitions.finalize_schema
  s    ''	,7'M 13 '44J&K&Q&Q&S 	Q"C" ,GYZkGl2l2Cqw1w$0
 &++-%,,T-E-Ec;-WX&*== -00<D%++-%,,T-E-Ec;-WX48%j1
 '+&>&>sK&Ps#+	Q.   @A 
	B(*:(:(:;bdh(iM$ *>>rwwy-YghGHHJIIg
	  336OiQ_QfQfQhOijFY & 	,$!+	,s   E7 7	F FFc                    ||   }|d   dk7  r|S t               }|d   dk(  rTt        |      dk(  rF|d   }||v rt        | dd      |j                  |       ||   }|d   dk(  rt        |      dk(  rFi |d|iS )	Nr   r  r  r;  z) contains a circular reference to itself.zcircular-reference-schemar   r1  )r   r  rH   r  )r   r1  r  
definitionvisitedr;  s         r   r  z _Definitions._resolve_definition  s     %
f!11  E $449KJ9W[c9c#L1JW$'eDELg  KK
#$Z0J  $449KJ9W[c9c **)eS))r   Nr  )r   r   r<  zCGenerator[tuple[str, core_schema.DefinitionReferenceSchema | None]])r1  r  r<  CoreSchema | None)r   r*   r<  %core_schema.DefinitionReferenceSchema)r   zcore_schema.DefinitionsSchemar<  r*   r  )r1  r  r  zdict[str, CoreSchema]r<  r*   )r   r   r   r   r  r   r   r  r  r  r  r  r  r   r   r   r   r   
  sQ    4 43 4 4@*< 8t*r   c                  2    e Zd ZdZddZedd       ZddZy)	r   _stackc                    g | _         y r   r  r  s    r   r   z_FieldNameStack.__init__&  s	    !#r   c              #  ~   K   | j                   j                  |       d  | j                   j                          y wr   r  r  r  )r   r   s     r   r  z_FieldNameStack.push)  s)     :&   ;=c                :    | j                   r| j                   d   S y Nr   r  r  s    r   r   z_FieldNameStack.get/      ;;;;r?"r   Nr  )r   r  r<  Iterator[None])r<  r  r   r   r   r>  r   r   r  r   r   r   r   r   r   #  s%    I$  
r   r   c                  2    e Zd ZdZddZedd       ZddZy)	r   r  c                    g | _         y r   r  r  s    r   r   z_ModelTypeStack.__init__9  s	    "$r   c              #  ~   K   | j                   j                  |       d  | j                   j                          y wr   r  )r   type_objs     r   r  z_ModelTypeStack.push<  s)     8$r  c                :    | j                   r| j                   d   S y r  r  r  s    r   r   z_ModelTypeStack.getB  r  r   Nr  )r"  r   r<  r  )r<  ztype | Noner  r   r   r   r   r   6  s%    I%  
r   r   )r   FieldDecoratorInfor   r  r<  r   )r   zIterable[AnyFieldDecorator]r   zIterable[str]r<  r  )r   z+Iterable[Decorator[FieldDecoratorInfoType]]r   r  r<  z'list[Decorator[FieldDecoratorInfoType]])r   r  r   z'list[Decorator[ValidatorDecoratorInfo]]r   r  r<  r  )r   r  r<  zAtuple[JsonDict | None, JsonDict | JsonSchemaExtraCallable | None])r   zJsonEncoders | Noner   r   r   r*   r<  r*   )r   r   r   r   r<  r   )r   r  r  zIterable[Decorator[RootValidatorDecoratorInfo]] | Iterable[Decorator[ValidatorDecoratorInfo]] | Iterable[Decorator[FieldValidatorDecoratorInfo]]r   r  r<  r  )r  z+Iterable[Decorator[ValidatorDecoratorInfo]]r<  r   )r   r  r  z0Iterable[Decorator[ModelValidatorDecoratorInfo]]rY  z Literal['inner', 'outer', 'all']r<  r  )r~  r}   r   r  r<  r  )r   r   r<  zGetJsonSchemaFunction | None)r   r  rz  r  r{  r  ry  r  r  r  r2  r   r<  r  )r   r*   r  r   r<  r  )r  r  r<  z.Literal['inline', 'keep', 'preserve_metadata'](  r   
__future__r   _annotationscollections.abcr  rq  rH  r@  r  r  r/  sysrj  r   r   r   r   r   
contextlibr   r	   decimalr
   enumr   	fractionsr   	functoolsr   r   r   r   	ipaddressr   r   r   r   r   r   	itertoolsr   operatorr   typesr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   uuidr'   r(   r  r)   typing_extensionspydantic_corer*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   typing_inspectionr8   typing_inspection.introspectionr9   r:   r;   aliasesr=   r>   r?   annotated_handlersr@   rA   r  rB   rC   rD   rE   errorsrF   rG   rH   functional_validatorsrI   rJ   rK   rL   rM   r)  rN   versionrO   rP   r   rR   rS   rT   rU   rV   _configrW   rX   _core_metadatarY   rZ   _core_utilsr[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   _docs_extractionrk   r  rl   rm   rn   _forward_refro   	_genericsrp   rq   _import_utilsrr   rs   _mock_val_serrt   _namespace_utilsru   rv   _schema_gatherrw   rx   _schema_generation_sharedry   _utilsrz   r{   r   r|   r}   mainr   r   _dataclassesr   r   version_infor  r$  r   AnyFieldDecoratorr   r  r   r   Tupler   r   Listr=  r6  MutableSequencer   Setr   
MutableSetr   	FrozenSet	frozensetr   Dictr   r   r   r$  r   r   Typer   r   r.  r   r  Pathr  	PosixPathPurePosixPathPureWindowsPathr   MutableMappingOrderedDictDefaultDictr  rY  CounterrZ  r  r  r   r  rm  r   r   r   r   r   r   JsonEncodersr   r   	Exceptionr   r   r  r   r  r  r  r  r  r  r  r  r   r   r   r   r   r   <module>r_     s   3 2     	  	 
   B B %      8 8 f f   D D      	 	 	 f e , a a = = K O O b b w w ) # 0 ` ` 6 >     : b b . ? M ) 9 O C 65 %/@&&'1 13NPllm  !9AST $%)**+-  *> Y =#+S2M,NP[PfPf,f#g y g S I S!<</Z / ++t[__-L-LM
J MS+//*D*DE	: E & 0 0)[__=P=PQ * Q ++t,
J ,#]Km]hi* i$oo{/G/GH
 H$oo{/G/GIYIY[f[j[j[t[tu
 u ++t,
J ,#^^RZZ8z 8KKLL
J  NN
OOOO""!!
	 $$fnn5&,,fll;Z ; #  !))C D  .Zgh   i
,
,, 
,"6nDnMPn,n"""A" " 	"J
A
'
AF
A DI{*+&,/9CD%& &e! e!XC if[d   2"7
  2 ,",@, +, 	,^2@9  NR&*)-" K $	
 '   &23(W* W*t & r   