
    4gUe                        U d dl Z d dlZd dlZd dlmZmZmZ d dlmZ d dl	m
Z
mZ d dlmZmZmZmZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZ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-m.Z.m/Z/m0Z0m1Z1m2Z2 d d
l3m4Z4 erLd dl5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z< d dl=m>Z> d dl?m@Z@ d dl*mAZAmBZBmCZCmDZDmEZE ee%ee"e   e"eFef   e"eFeef   f      ZGdZHdZIeJeKeLeFeMeNeOe+eeeej                  eeeQj                  eSj                  hZTe!e#e      eUd<   eVeWeXeYeZeeehZ[e!e#e      eUd<   deFdefdZ\ddde%eF   deJdeFfdZ]dedeMfdZ^dee#d       d!eFddfd"Z_d#ed$e%e#e   e"e#e   d%f   df   deMfd&Z`d'ed$e%e#e   e"e#e   d%f   df   deMfd(ZadeMfd)Zbd*eFdeMfd+Zc e$d,      Zdd-eedef   d.eedef   deedef   fd/Zed-eeef   d0eddfd1Zfd2d3d4eKd5eKd6eKdeMfd7Zgd8ed9   d:eeFd;f   d<e#d=   dd>fd?Zhd@e%e#d    e#dA   f   de#d    fdBZidCeFdeFfdDZjdCeFdeFfdEZk e$dF      ZleFdGdHe%eel   e"eld%f   f   dIeelgeFf   deel   fdJZm G dK dLeF      Zn G dM dN      Zo G dO dPeo      Zp G dQ dReo      Zq G dS dT      ZrdUdVdWdXdYdZd[d\d]Zsd^d_deFfd`Zt e$da      Zud@eudeufdbZvdceFdeMfddZwh deZxdceFdeMfdfZy ez       Z{dgee   dhee   deMfdiZ|d@edjeFdefdkZ}dleeF   dmeFdeFfdnZ~doedmeFde"eFe"eFd%f   f   fdpZdqe#e   dmeFde"eFe"e"eFd%f   d%f   f   fdrZy)s    N)OrderedDictdefaultdictdeque)deepcopy)islicezip_longest)BuiltinFunctionTypeCodeTypeFunctionTypeGeneratorType
LambdaType
ModuleType)TYPE_CHECKINGAbstractSetAnyCallable
CollectionDict	GeneratorIterableIteratorListMappingNoReturnOptionalSetTupleTypeTypeVarUnion)	Annotated)ConfigError)NoneTypeWithArgsTypesall_literal_valuesdisplay_as_typeget_args
get_originis_literal_typeis_union)version_info)	Signature)Path)
BaseConfig)	Dataclass)
ModelField	BaseModel)AbstractSetIntStrDictIntStrAnyIntStrMappingIntStrAnyReprArgs)import_stringsequence_likevalidate_field_namelenient_isinstancelenient_issubclass
in_ipythonis_valid_identifierdeep_updateupdate_not_nonealmost_equal_floats	get_modelto_camelto_lower_camelis_valid_fieldsmart_deepcopyPyObjectStrRepresentation
GetterDict
ValueItemsr+   ClassAttribute	path_typeROOT_KEYget_unique_discriminator_alias"get_discriminator_alias_and_valuesDUNDER_ATTRIBUTES__root__IMMUTABLE_NON_COLLECTIONS_TYPESBUILTIN_COLLECTIONSdotted_pathreturnc                    ddl m} 	 | j                  d      j                  dd      \  }} ||      }	 t        ||      S # t        $ r}t        d|  d      |d}~ww xY w# t        $ r}t        d	| d
| d      |d}~ww xY w)z
    Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the
    last name in the path. Raise ImportError if the import fails.
    r   )import_module .   "z!" doesn't look like a module pathNzModule "z" does not define a "z" attribute)	importlibrW   striprsplit
ValueErrorImportErrorgetattrAttributeError)rT   rW   module_path
class_nameemodules         g/var/www/python.lazyprojects.co.uk/rdoDiscordBot/venv/lib/python3.12/site-packages/pydantic/v1/utils.pyr8   r8   z   s    
 (V"-"3"3C"8"?"?Q"GZ ;'Fgvz**  VAk]*LMNTUUV  gH[M1FzlR]^_effgs.   $A A" 	A
AA"	B+A>>BP   )max_lenvri   c                V   t        j                  dt               t        | t              r*t        |       |dz
  kD  r| d|dz
   dz   j                         S 	 | j                         } t        |       |kD  r| d|dz
   dz   } | S # t        $ r | j                  j                  |       } Y Aw xY w)z`
    Truncate a value and add a unicode ellipsis (three dots) to the end if it was too long
    z:`truncate` is no-longer used by pydantic and is deprecated   N   u   …rZ   )	warningswarnDeprecationWarning
isinstancestrlen__repr__	TypeError	__class__)rj   ri   s     rg   truncaterw      s     MMNPbc!Sc!f!4/Wq["U*4466$JJL 1vm!u$H	  $KK  #$s   B $B('B(c           	      V    t        | t        t        t        t        t
        t        f      S N)rq   listtupleset	frozensetr   r   rj   s    rg   r9   r9      s    a$sI}eLMM    basesr2   
field_namec                 P    | D ]!  }t        ||d      st        d| d| d       y)zZ
    Ensure that the field's name does not shadow an existing attribute of the model.
    NzField name "zI" shadows a BaseModel attribute; use a different field name with "alias='z'".)ra   	NameError)r   r   bases      rg   r:   r:      s@     4T*zl +<<F<tM  r   oclass_or_tuple.c                 :    	 t        | |      S # t        $ r Y yw xY wNF)rq   ru   )r   r   s     rg   r;   r;      s&    !^,,     	clsc                     	 t        | t              xr t        | |      S # t        $ r t        | t              rY y w xY wr   )rq   type
issubclassru   r$   )r   r   s     rg   r<   r<      s?    #t$HC)HH c=)s     ==c                  :    	 t        d       y# t        $ r Y yw xY w)zU
    Check whether we're in an ipython environment, including jupyter notebooks.
    __IPYTHON__TF)evalr    r   rg   r=   r=      s(    ]   r   
identifierc                 R    | j                         xr t        j                  |        S )z
    Checks that a string is a valid identifier and not a Python keyword.
    :param identifier: The identifier to test.
    :return: True if the identifier is valid.
    )isidentifierkeyword	iskeyword)r   s    rg   r>   r>      s&     ""$JW->->z-J)JJr   KeyTypemappingupdating_mappingsc                     | j                         }|D ]Y  }|j                         D ]D  \  }}||v r6t        ||   t              r#t        |t              rt	        ||   |      ||<   @|||<   F [ |S ry   )copyitemsrq   dictr?   )r   r   updated_mappingupdating_mappingkrj   s         rg   r?   r?      sy    llnO-$**,DAqO#
?13Et(LQ[\]_cQd%01CQ%G"%&"	 - . r   updatec                 |    | j                  |j                         D ci c]  \  }}|	|| c}}       y c c}}w ry   )r   r   )r   r   r   rj   s       rg   r@   r@      s2    NNV\\^E^TQq}AqD^EFEs   
8
8
g:0yE>)deltavalue_1value_2r   c                $    t        | |z
        |k  S )z4
    Return True if two floats are almost equal
    )abs)r   r   r   s      rg   rA   rA      s     w !U**r   init).Nfieldsr0   configr.   r,   c                    ddl m}m}m} ddlm}  ||       j                  j                         }i }d}	d}
t        |dd      D ],  }|j                  |j                  u r|}	|||j                  <   . |	r|j                  }|j                         D ]w  \  }}|j                  }||v s||v rt        |      s|rt        |      r|}nd}
9|j                   sd|j"                  ini } |||j$                  fd	|j&                  i|||<   y |j(                  |j*                  u rd}
|	ry|
rwd
|j,                  fd|j                  fg}|D cg c]  }|j                  |j                  f c}|k(  rd}n|	j                  }||v r
|dz  }||v r
|	j/                  |      ||<    |t1        |j                               d      S c c}w )z:
    Generate signature for model based on its fields
    r   )	Parameterr,   	signature)ExtraNFrZ   Tdefault
annotation__pydantic_self__data
extra_data_name)
parametersreturn_annotation)inspectr   r,   r   pydantic.v1.configr   r   valuesr   kindVAR_KEYWORDr   allow_population_by_field_namer   aliasr>   requiredr   KEYWORD_ONLYr   extraallowPOSITIONAL_OR_KEYWORDreplacerz   )r   r   r   r   r,   r   r   present_paramsmerged_paramsvar_kw
use_var_kwparamallow_namesr   field
param_namekwargsdefault_model_signaturepvar_kw_names                       rg   generate_model_signaturer      s    87(t_//668N*,MFJ40::***F$)ejj!	 1 ;;!'JJ]*jM.I(4#6z#B!+J!%J 8=~~i/2F(1I22)?D?O?O)SY)M*% "0" ||u{{"
* !)"A"ABY**+#
 '55nQVVQVVn59PP&K !++K V#3K V#%+^^^%Ek"]%9%9%; <PTUU 6s   	Gobjr/   c                 |    ddl m} 	 | j                  }t	        ||      st        d      |S # t        $ r | }Y &w xY w)Nr   r1   z7Unsupported type, must be either BaseModel or dataclass)pydantic.v1.mainr2   __pydantic_model__rb   r   ru   )r   r2   	model_clss      rg   rB   rB   -  sI    ***	 i+QRR  	s   - ;;stringc                 P    dj                  d | j                  d      D              S )N c              3   <   K   | ]  }|j                           y wry   )
capitalize).0words     rg   	<genexpr>zto_camel.<locals>.<genexpr>;  s     C1B4??$1Bs   r   )joinsplit)r   s    rg   rC   rC   :  s     77Cc1BCCCr   c                     t        |       dk\  r$t        |       }|d   j                         |dd  z   S | j                         S )NrZ   r   )rs   rC   lower)r   pascal_strings     rg   rD   rD   >  sD    
6{a (Q%%'-*;;;<<>r   T)name_factory
input_listr   c                    g }g }| D ]E  } ||      }||vr#|j                  |       |j                  |       2|||j                  |      <   G |S )z
    Make a list unique while maintaining order.
    We update the list if another one with the same name is set
    (e.g. root validator overridden in subclass)
    )appendindex)r   r   resultresult_namesrj   v_names         rg   unique_listr   H  s_     F La%'MM!12F<%%f-.  Mr   c                       e Zd ZdZdefdZy)rG   z
    String class where repr doesn't include quotes. Useful with Representation when you want to return a string
    representation of something that valid (or pseudo-valid) python.
    rU   c                     t        |       S ry   )rr   selfs    rg   rt   zPyObjectStr.__repr__e  s    4yr   N)__name__
__module____qualname____doc__rr   rt   r   r   rg   rG   rG   _  s    
# r   rG   c            	           e Zd ZU dZ e       Zeedf   ed<   ddZ	defdZ
dedefdZd	eegef   d
edeeddf   fdZdefdZdefdZddZy)rH   z
    Mixin to provide __str__, __repr__, and __pretty__ methods. See #884 for more details.

    __pretty__ is used by [devtools](https://python-devtools.helpmanual.io/) to provide human readable representations
    of objects.
    .	__slots__rU   c                 n      fd j                   D        }|D cg c]  \  }}|	||f c}}S c c}}w )a6  
        Returns the attributes to show in __str__, __repr__, and __pretty__ this is generally overridden.

        Can either return:
        * name - value pairs, e.g.: `[('foo_name', 'foo'), ('bar_name', ['b', 'a', 'r'])]`
        * or, just values, e.g.: `[(None, 'foo'), (None, ['b', 'a', 'r'])]`
        c              3   :   K   | ]  }|t        |      f  y wry   )ra   )r   sr   s     rg   r   z/Representation.__repr_args__.<locals>.<genexpr>{  s     ?1!WT1%&s   )r   )r   attrsarj   s   `   rg   __repr_args__zRepresentation.__repr_args__s  s8     @?#(:541aAMA5:::s   
11c                 .    | j                   j                  S )zA
        Name of the instance's class, used in __repr__.
        )rv   r   r   s    rg   __repr_name__zRepresentation.__repr_name__~  s     ~~&&&r   join_strc                 N    |j                  d | j                         D              S )Nc              3   J   K   | ]  \  }}|t        |      n| d|  y w)N=)repr)r   r   rj   s      rg   r   z.Representation.__repr_str__.<locals>.<genexpr>  s.     ePd1	T!W!AaU|CPds   !#)r   r   )r   r  s     rg   __repr_str__zRepresentation.__repr_str__  s!    }}ePTPbPbPdeeer   fmtr   Nc              +      K   | j                         dz    d | j                         D ]   \  }}||dz     ||       d d " d d yw)	z
        Used by devtools (https://python-devtools.helpmanual.io/) to provide a human readable representations of objects
        (rZ   Nr  ,r   ))r   r   )r   r  r   r   values        rg   
__pretty__zRepresentation.__pretty__  sh        "S((--/KD%Sj e*IG 0 	s   AAc                 $    | j                  d      S )NrX   )r  r   s    rg   __str__zRepresentation.__str__  s      %%r   c                 L    | j                          d| j                  d       dS )Nr	  , r  )r   r  r   s    rg   rt   zRepresentation.__repr__  s+    $$&'q):):4)@(ACCr   c              #   V   K   | j                         D ]  \  }}|| ||f  yw)zGet fields for Rich libraryN)r   )r   r   
field_reprs      rg   __rich_repr__zRepresentation.__rich_repr__  s4      $ 2 2 4D*|  J&&	 !5s   ')rU   r7   )rU   RichReprResult)r   r   r   r   r{   r   r   rr   __annotations__r   r   r  r   r   r   r  r  rt   r  r   r   rg   rH   rH   i  s     "'IuS#X(	;'s 'fS fS fhucz2 c iPSUY[_P_F` & &D# D'r   rH   c                       e Zd ZdZdZdefdZdedefdZdded	edefd
Z	de
e   fdZdee   fdZdee   fdZdeeeef      fdZdee   fdZdefdZdedefdZdedefdZddZdefdZy)rI   z
    Hack to make object's smell just enough like dicts for validate_model.

    We can't inherit from Mapping[str, Any] because it upsets cython so we have to implement all methods ourselves.
    _objr   c                     || _         y ry   r  )r   r   s     rg   __init__zGetterDict.__init__  s	    	r   keyrU   c                 j    	 t        | j                  |      S # t        $ r}t        |      |d }~ww xY wry   )ra   r  rb   KeyError)r   r  re   s      rg   __getitem__zGetterDict.__getitem__  s4    	'499c** 	'3-Q&	's    	2-2Nr   c                 0    t        | j                  ||      S ry   )ra   r  )r   r  r   s      rg   getzGetterDict.get  s    tyy#w//r   c                     t               S )zn
        We don't want to get any other attributes of obj if the model didn't explicitly ask for them
        )r|   r   s    rg   
extra_keyszGetterDict.extra_keys  s     ur   c                     t        |       S )z
        Keys of the pseudo dictionary, uses a list not set so order information can be maintained like python
        dictionaries.
        )rz   r   s    rg   keyszGetterDict.keys  s    
 Dzr   c                 2    | D cg c]  }| |   	 c}S c c}w ry   r   r   r   s     rg   r   zGetterDict.values  s    !%&AQ&&&s   c              #   D   K   | D ]  }|| j                  |      f  y wry   )r#  r)  s     rg   r   zGetterDict.items  s"     ATXXa[.  s    c              #   l   K   t        | j                        D ]  }|j                  d      r|  y w)Nr   )dirr  
startswith)r   r   s     rg   __iter__zGetterDict.__iter__  s)     		ND??3'
 #s   *44c                 &    t        d | D              S )Nc              3       K   | ]  }d   yw)rZ   Nr   )r   r   s     rg   r   z%GetterDict.__len__.<locals>.<genexpr>  s     #d1ds   )sumr   s    rg   __len__zGetterDict.__len__  s    #d###r   itemc                 &    || j                         v S ry   )r'  r   r3  s     rg   __contains__zGetterDict.__contains__  s    tyy{""r   otherc                 L    t        |       t        |j                               k(  S ry   )r   r   )r   r7  s     rg   __eq__zGetterDict.__eq__  s    DzT%++-000r   c                     d t        |       fgS ry   )r   r   s    rg   r   zGetterDict.__repr_args__  s    tDz"##r   c                 4    dt        | j                         dS )NzGetterDict[])r&   r  r   s    rg   r   zGetterDict.__repr_name__  s    _TYY78::r   ry   r  )r   r   r   r   r   r   r  rr   r!  r#  r   r%  r   r'  r   r   r   r   r.  intr2  boolr6  r9  r   r   r   r   rg   rI   rI     s     IC 's 's '0s 0S 0C 0CH d3i 'S	 '!xc3h0 !(3- 
$ $# # #1C 1D 1$;s ;r   rI   c            
           e Zd ZdZdZdeded   ddfdZd	edefd
Z	d	edefdZ
dddeed      fdZdddeddfdZeddedededefd       Zeded   ddfd       Zededefd       Zededefd       ZddZy)rJ   zY
    Class for more convenient calculation of excluded or included fields on values.
    )_items_typer  r   )r3   r6   rU   Nc                     | j                  |      }t        |t        t        f      r| j	                  |t        |            }|| _        y ry   )_coerce_itemsrq   rz   r{   _normalize_indexesrs   r@  )r   r  r   s      rg   r  zValueItems.__init__  s=    ""5)edE]+++E3u:>E*/r   r3  c                 V    | j                  | j                  j                  |            S )z`
        Check if item is fully excluded.

        :param item: key or index of a value
        )is_truer@  r#  r5  s     rg   is_excludedzValueItems.is_excluded  s      ||DKKOOD122r   c                     || j                   v S )zh
        Check if value is contained in self._items

        :param item: key or index of value
        r@  r5  s     rg   is_includedzValueItems.is_included  s     t{{""r   re   r5   c                 b    | j                   j                  |      }| j                  |      s|S dS )z
        :param e: key or index of element on value
        :return: raw values for element if self._items is dict and contain needed element
        N)r@  r#  rF  )r   re   r3  s      rg   for_elementzValueItems.for_element  s,     {{q!<<-t747r   r6   v_lengthr4   c                    i }d}|j                         D ]  \  }}t        |t              s<t        |t              s,| j	                  |      st        d| d|j                         |dk(  r| j                  |      }it        |t              st        d      |dk  r||z   n|}| j                  ||j                  |            ||<    |s|S | j	                  |      r$t        |      D ]  }|j                  |d        |S t        |      D ];  }|j                  |i       }| j	                  |      r'| j                  ||      ||<   = |S )af  
        :param items: dict or set of indexes which will be normalized
        :param v_length: length of sequence indexes of which will be

        >>> self._normalize_indexes({0: True, -2: True, -1: True}, 4)
        {0: True, 2: True, 3: True}
        >>> self._normalize_indexes({'__all__': True}, 4)
        {0: True, 1: True, 2: True, 3: True}
        Nz,Unexpected type of exclude value for index "z" __all__zExcluding fields from a sequence of sub-models or dicts must be performed index-wise: expected integer keys or keyword "__all__"r   .)r   rq   r   r   rF  ru   rv   _coerce_valuer=  merger#  range
setdefault)	r   r   rM  normalized_items	all_itemsirj   normalized_inormalized_items	            rg   rD  zValueItems._normalize_indexes  sU    -/	KKMDAqq'*jK.HDLLYZO"NqcQSTUT_T_S` abbI~ ..q1	a%A  ,-q58a<aL-1ZZ;K;O;OP\;]-^\* " ##<<	"8_ ++As3 %##xA.99!R@O<<0&*jjO&L # !  r   r   override	intersectc                    | j                  |      }| j                  |      }||S | j                  |      s||S | j                  |      r|r|S |S |r,|D cg c]	  }||v s| c}|D cg c]	  }||v s| c}z   }n!t        |      |D cg c]	  }||vs| c}z   }i }|D ]<  }| j                  |j	                  |      |j	                  |      |      }|8|||<   > |S c c}w c c}w c c}w )ae  
        Merge a ``base`` item with an ``override`` item.

        Both ``base`` and ``override`` are converted to dictionaries if possible.
        Sets are converted to dictionaries with the sets entries as keys and
        Ellipsis as values.

        Each key-value pair existing in ``base`` is merged with ``override``,
        while the rest of the key-value pairs are updated recursively with this function.

        Merging takes place based on the "union" of keys if ``intersect`` is
        set to ``False`` (default) and on the intersection of keys if
        ``intersect`` is set to ``True``.
        )rZ  )rP  rF  rz   rQ  r#  )r   r   rY  rZ  r   
merge_keysmergedmerged_items           rg   rQ  zValueItems.merge2  s     $$X.  &K;;tO;;x $42(2 %);TQ(]!T;(>`(QVW[_V_q(>``Jd(&L(Qatmq(&LLJ"$A))DHHQKaI)VK&'q	 
  <>`&Ls$   	C'#C'-	C,7C,	C1C1c                     t        | t              r	 | S t        | t              rt        j	                  | d      } | S t        | dd      }t        | d|        | S )N.rv   z???z!Unexpected type of exclude value )rq   r   r   r   fromkeysra   assert_never)r   rd   s     rg   rC  zValueItems._coerce_itemsY  se    eW%  {+MM%-E  !U;J3J<@ r   c                 N    || j                  |      r|S | j                  |      S ry   )rF  rC  )r   r  s     rg   rP  zValueItems._coerce_valueg  s(    =CKK.L  ''r   rj   c                     | du xs | du S )NT.r   r~   s    rg   rF  zValueItems.is_truem  s    Dy$AH$r   c                      d | j                   fgS ry   rI  r   s    rg   r   zValueItems.__repr_args__q  s    t{{#$$r   )Fr  )r   r   r   r   r   r   r    r  r>  rG  rJ  r   rL  r=  rD  classmethodrQ  staticmethodrC  rP  rF  r   r   r   rg   rJ   rJ     s2    $I0c 0%0W*X 0]a 03 3 3# # #8X 8(59`3a*b 8% (: % c % o % N $ $ $ $ $ $L U#JK Pb   (# (# ( (
 %3 %4 % %%r   rJ   c                   B    e Zd ZdZdZdededdfdZded	ee   ddfd
Z	y)rK   z1
    Hide class attribute from its instances
    r   r  r   r  rU   Nc                      || _         || _        y ry   rh  )r   r   r  s      rg   r  zClassAttribute.__init__  s    	
r   instanceownerc                 h    || j                   S t        | j                  d|j                  d      )Nz attribute of z is class-only)r  rb   r   r   )r   rj  rk  s      rg   __get__zClassAttribute.__get__  s3    ::		}N5>>:LN[\\r   )
r   r   r   r   r   rr   r   r  r   rm  r   r   rg   rK   rK   u  sJ    I
S   ] ]DI ]$ ]r   rK   	directoryfilezmount pointsymlinkzblock devicezchar deviceFIFOsocket)is_diris_fileis_mount
is_symlinkis_block_deviceis_char_deviceis_fifo	is_socketr   r-   c                     | j                         sJ d       t        j                         D ]  \  }} t        | |             s|c S  y)z0
    Find out what sort of thing a path is.
    zpath does not existunknown)exists
path_typesr   ra   )r   methodr   s      rg   rL   rL     sH     88:,,,:"((*71fK + r   Objc                     | j                   }|t        v r| S 	 | s"|t        v r|t        u r| S | j	                         S t        |       S # t
        t        t        f$ r Y t        |       S w xY w)z
    Return type as is for immutable built-in types
    Use obj.copy() for built-in empty collections
    Use copy.deepcopy() for non-empty collections and unknown objects
    )	rv   rR   rS   r{   r   ru   r_   RuntimeErrorr   )r   obj_types     rg   rF   rF     st     }}H22
x#66"e+3;;
 C=	 z<0 C=	s   A A A('A(r   c                 8    | j                  d      syt        | k(  S )Nr   T)r-  rM   r   s    rg   rE   rE     s    ??3tr   >   r   r   r   __classcell____orig_bases____orig_class__r  c                 .    t        |        xr | t        vS ry   )rE   rP   r   s    rg   is_valid_private_namer    s    d##E4E(EEr   leftrightc                 D    t        | |t              D ]  \  }}||us y y)a  
    Check that the items of `left` are the same objects as those in `right`.

    >>> a, b = object(), object()
    >>> all_identical([a, b, a], [a, b, a])
    True
    >>> all_identical([a, b, [a]], [a, b, [a]])  # new list object, while "equal" is not "identical"
    False
    )	fillvalueFT)r   _EMPTY)r  r  	left_item
right_items       rg   all_identicalr    s-     "-T5F!K	:J& "L r   msgc                     t        |      )z
    Helper to make sure that we have covered all possible types.

    This is mostly useful for ``mypy``, docs:
    https://mypy.readthedocs.io/en/latest/literal_types.html#exhaustive-checks
    )ru   )r   r  s     rg   ra  ra    s     C.r   all_aliasesdiscriminator_keyc           
          t        |       }t        |      dkD  r*t        d|ddj                  t	        |              d      |j                         S )zNValidate that all aliases are the same and if that's the case return the aliasrZ   zAliases for discriminator z must be the same (got r  r  )r|   rs   r"   r   sortedpop)r  r  unique_aliasess      rg   rN   rN     sa    %N
>Q():(==TUYU^U^_efq_rUsTttuv
 	
 r   tpc                 4   t        | dd      }t        |       t        u rt        |       d   } t	        | d      r| j
                  } t        t        |             r#t        | |      \  }}|t        d |D              fS |rd| j                  t           j                  }t        ||      \  }}t        t        |            dkD  rt        d|dt        |             ||d   fS 	 | j                  |   j                  }t)        |      st        d|d| j$                  d      | j                  |   j*                  t-        |      fS # t         $ r}t#        d	| j$                  d
      |d}~wt&        $ r!}t        d| j$                  d|      |d}~ww xY w)z
    Get alias and all valid values in the `Literal` type of the discriminator field
    `tp` can be a `BaseModel` class or directly an `Annotated` `Union` of many.
    __custom_root_type__Fr   r   c              3   .   K   | ]  }|D ]  }|   y wry   r   )r   r   rj   s      rg   r   z5get_discriminator_alias_and_values.<locals>.<genexpr>  s     GJ&1AAJs   rZ   zField z& is not the same for all submodels of zType z* is not a valid `BaseModel` or `dataclass`NzModel z% needs a discriminator field for key z
 of model z needs to be a `Literal`)ra   r(   r!   r'   hasattrr   r*   _get_union_alias_and_all_valuesr{   
__fields__rM   type_rs   r|   r"   r&   rb   ru   r   r   r)   r   r%   )r  r  is_root_modelr   
all_values
union_typet_discriminator_typere   s           rg   rO   rO     s   
 B 6>M"~"b\!_r'(""
2;B@QRzeGJGGGG	]]8,22
;JHYZzs:!#*--STcdfTgSjk  jm##	y#%==1B#C#I#I  34'8&;:bkk_Tlmnn}}./557IJ^7___  	feBKK?2\]^dee 	yr{{o5Z[lZopqwxx	ys$   #E 	FE**F6FFr  c                     t        |       D cg c]  }t        ||       }}t        | \  }}t        ||      |fS c c}w ry   )r'   rO   ziprN   )r  r  tzipped_aliases_valuesr  r  s         rg   r  r    sV     `hhr_st_sZ[?CTU_st!#89K)+7HI:UU us   <)r   rn   weakrefcollectionsr   r   r   r   r   	itertoolsr   r   typesr	   r
   r   r   r   r   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    typing_extensionsr!   pydantic.v1.errorsr"   pydantic.v1.typingr#   r$   r%   r&   r'   r(   r)   r*   pydantic.v1.versionr+   r   r,   pathlibr-   r   r.   pydantic.v1.dataclassesr/   pydantic.v1.fieldsr0   r   r2   r3   r4   r5   r6   r7   rr   r  rO  rM   r=  floatcomplexr>  bytesr   refNotImplementedrv   EllipsisrR   r  rz   r|   r{   r}   r   rS   r8   rw   r9   r:   r;   r<   r=   r>   r   r?   r@   rA   r   rB   rC   rD   r   r   rG   rH   rI   rJ   rK   r~  rL   r  rF   rE   rP   r  objectr  r  ra  rN   rO   r  r   r   rg   <module>r     sa      7 7  ) d d    * ( *	 	 	 -!-1-*ggeCsU38_eCQTVYMFZ$Z[\N:  		KK '3 T#Y 0 				' Sc^ 	gs gs g& /1 c
  S "NS NT N	tD$56 	C 	D 	# uT#Yd3iQTn@UW[5[/\ ae C tCy%S	SVBWY]7]1^ cg 	D 	KC KD K )
gsl+ gslAS X\]dfi]iXj GT#s(^ Gs Gt G KO + + +% +SW +>V
9
>V'+C,='>>VHL\HZ>V>VB
5k*D,==> 
4CT 
DS DS D3 3  CL (+d1guQV},- A38$ 
!W	.# 9' 9'x;; ;;|O% O%d] ]* %#	
	 	C 	 en  *   F F F 
 hsm   h S X  
3  TW  \_  &`3 &`3 &`5QTV[\_ad\dVeQeKf &`RVS	V.1V
3eCHos*++,Vr   