Ë
    ©2Úi²-  ã                  ó„  — U d Z ddlmZ ddlZddlZddlZddlmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZmZmZmZmZ ddlmZmZ dd	lmZmZ d
dlmZmZ ej<                  rdZde d<   dZ!de d<   ddl"m#Z# e$e%e&e'e(e)e*ejV                  eeeejX                  eee-j\                  e/j\                  hZ0de d<   e1e2e3e4e5ee	e
hZ6de d<   d)d„Z7d*d„Z8d+d„Z9d,d„Z:d-d„Z; ed«      Z<d.d„Z=d/d„Z> ed«      Z?e'dœ	 	 	 	 	 d0d „Z@ G d!„ d"ej‚                  «      ZBej<                  rd1d#„ZCn
 G d$„ d%«      ZC ed&«      ZDd2d'„ZE eF«       ZGd3d(„ZHy)4z�Bucket of reusable internal utilities.

This should be reduced as much as possible with functions only used in one place, moved to that place.
é    )ÚannotationsN)ÚOrderedDictÚdefaultdictÚdeque)Údeepcopy)Úzip_longest)ÚBuiltinFunctionTypeÚCodeTypeÚFunctionTypeÚGeneratorTypeÚ
LambdaTypeÚ
ModuleType)ÚAnyÚTypeVar)Ú	TypeAliasÚ	TypeGuardé   )Ú_reprÚ_typing_extraz3typing.Mapping[int, Any] | typing.Mapping[str, Any]r   ÚMappingIntStrAnyz1typing.AbstractSet[int] | typing.AbstractSet[str]ÚAbstractSetIntStré   ©Ú	BaseModelzset[type[Any]]ÚIMMUTABLE_NON_COLLECTIONS_TYPESÚBUILTIN_COLLECTIONSc           	     óV   — t        | t        t        t        t        t
        t        f«      S ©N)Ú
isinstanceÚlistÚtupleÚsetÚ	frozensetr   r   ©Úvs    úP/var/www/html/acx/venv/lib/python3.12/site-packages/pydantic/_internal/_utils.pyÚsequence_liker'   >   s   € Ü�aœ$¤¤s¬I´}ÄeÐLÓMÐMó    c                ó:   — 	 t        | |«      S # t        $ r Y yw xY w©NF)r   Ú	TypeError)ÚoÚclass_or_tuples     r&   Úlenient_isinstancer.   B   s&   € ðÜ˜!˜^Ó,Ð,øÜò Ùðús   ‚ Ž	™c                ó”   — 	 t        | t        «      xr t        | |«      S # t        $ r t        | t        j
                  «      rY y‚ w xY wr*   )r   ÚtypeÚ
issubclassr+   r   ÚWithArgsTypes)Úclsr-   s     r&   Úlenient_issubclassr4   I   sE   € ðÜ˜#œtÓ$ÒH¬°C¸Ó)HÐHøÜò Ü�cœ=×6Ñ6Ô7ÙØðús   ‚   #AÁAc                ó2   — ddl m} t        | |«      xr | |uS )zŒReturns true if cls is a _proper_ subclass of BaseModel, and provides proper type-checking,
    unlike raw calls to lenient_issubclass.
    r   r   )Úmainr   r4   )r3   r   s     r&   Úis_model_classr7   R   s   € õ !ä˜c 9Ó-ÒF°#¸YÐ2FÐFr(   c                ó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)Ú
identifiers    r&   Úis_valid_identifierr=   [   s&   € ð
 ×"Ñ"Ó$ÒJ¬W×->Ñ->¸zÓ-JÐ)JÐJr(   ÚKeyTypec                óâ   — | j                  «       }|D ]Y  }|j                  «       D ]D  \  }}||v r6t        ||   t        «      r#t        |t        «      rt	        ||   |«      ||<   Œ@|||<   ŒF Œ[ |S r   )ÚcopyÚitemsr   ÚdictÚdeep_update)ÚmappingÚupdating_mappingsÚupdated_mappingÚupdating_mappingÚkr%   s         r&   rC   rC   f   sƒ   € Ø—l‘l“n€OØ-ò 'ÐØ$×*Ñ*Ó,ò 	'‰DˆAˆqØ�OÑ#¬
°?À1Ñ3EÄtÔ(LÔQ[Ð\]Ô_cÔQdÜ%0°ÀÑ1CÀQÓ%G� Ò"à%&� Ò"ñ		'ð'ð Ðr(   c                ó|   — | j                  |j                  «       D ��ci c]  \  }}|€Œ	||“Œ c}}«       y c c}}w r   )ÚupdaterA   )rD   rJ   rH   r%   s       r&   Úupdate_not_nonerK   q   s.   € Ø‡N�N V§\¡\£^×E™T˜Q °q±}�A�q‘DÓEÕFùÓEs   Ÿ
8
ª8
ÚT)Úname_factoryc               ó¢   — 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. model validator overridden in subclass).
    )ÚappendÚindex)Ú
input_listrM   ÚresultÚresult_namesr%   Úv_names         r&   Úunique_listrU   x   sd   € ð €FØ €LØò 3ˆÙ˜a“ˆØ˜Ñ%Ø×Ñ Ô'Ø�M‰M˜!Õà12ˆF�<×%Ñ% fÓ-Ò.ð3ð €Mr(   c                  óŽ   — e Zd ZdZdZdd„Zdd„Zdd„Zdd„Zdd„Z	e
ddd„«       Zedd	„«       Ze
dd
„«       Zedd„«       Zdd„Zy)Ú
ValueItemszOClass for more convenient calculation of excluded or included fields on values.)Ú_itemsÚ_typec                ó–   — | j                  |«      }t        |t        t        f«      r| j	                  |t        |«      «      }|| _        y r   )Ú_coerce_itemsr   r    r!   Ú_normalize_indexesÚlenrX   )ÚselfÚvaluerA   s      r&   Ú__init__zValueItems.__init__“   s=   € Ø×"Ñ" 5Ó)ˆä�eœd¤E˜]Ô+Ø×+Ñ+¨E´3°u³:Ó>ˆEà(-ˆ�r(   c                óV   — | j                  | j                  j                  |«      «      S )zWCheck if item is fully excluded.

        :param item: key or index of a value
        )Úis_truerX   Úget©r^   Úitems     r&   Úis_excludedzValueItems.is_excluded›   s    € ð
 �|‰|˜DŸK™KŸO™O¨DÓ1Ó2Ð2r(   c                ó   — || j                   v S )z`Check if value is contained in self._items.

        :param item: key or index of value
        ©rX   rd   s     r&   Úis_includedzValueItems.is_included¢   s   € ð
 �t—{‘{Ð"Ð"r(   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)rX   rc   rb   )r^   Úere   s      r&   Úfor_elementzValueItems.for_element©   s,   € ð �{‰{�‰˜qÓ!ˆØŸ<™<¨Ô-ˆtÐ7°4Ð7r(   c                óÆ  — i }d}|j                  «       D ]Ç  \  }}t        |t        j                  «      sFt        |t        j                  «      s,| j                  |«      st        d|› d|j                  › �«      ‚|dk(  r| j                  |«      }Œ}t        |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 )a]  :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__z€Excluding fields from a sequence of sub-models or dicts must be performed index-wise: expected integer keys or keyword "__all__"r   .)rA   r   ÚtypingÚMappingÚAbstractSetrb   r+   Ú	__class__Ú_coerce_valueÚintÚmergerc   ÚrangeÚ
setdefault)	r^   rA   Úv_lengthÚnormalized_itemsÚ	all_itemsÚir%   Únormalized_iÚnormalized_items	            r&   r\   zValueItems._normalize_indexes°   sv  € ð 24ÐØˆ	Ø—K‘K“Mò 	_‰DˆAˆqÜ˜q¤&§.¡.Ô1´ZÀÄ6×CUÑCUÔ5VÐZ^×ZfÑZfÐghÔZiÜÐ"NÈqÈcÐQSÐTU×T_ÑT_ÐS`Ð aÓbÐbØ�IŠ~Ø ×.Ñ.¨qÓ1�	ØÜ˜a¤Ô%ÜðAóð ð ,-¨qª5˜8 aš<°aˆLØ-1¯Z©Z¸Ð;K×;OÑ;OÐP\Ó;]Ó-^Ð˜\Ò*ð	_ñ Ø#Ð#Ø�<‰<˜	Ô"Ü˜8“_ò 4�Ø ×+Ñ+¨A¨sÕ3ð4à#Ð#Ü�x“ò 	MˆAØ.×9Ñ9¸!¸RÓ@ˆOØ—<‘< Õ0Ø&*§j¡j°¸OÓ&LÐ  Ò#ð	Mð  Ðr(   c                óì  — | 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 )aH  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`.
        )Ú	intersect)rs   rb   r    ru   rc   )r3   ÚbaseÚoverrider   rH   Ú
merge_keysÚmergedÚmerged_items           r&   ru   zValueItems.mergeÕ   s	  € ð ×$Ñ$ XÓ.ˆØ× Ñ  Ó&ˆØÐØˆKØ�;‰;�tÔ  ØˆOØ�;‰;�xÔ Ù$�4Ð2¨(Ð2ñ Ø%)Ö; ¨Q°(ª]š!Ò;È(Ö>`ÀQÐVWÐ[_ÒV_ºqÒ>`Ñ`‰Jä˜d›°(Ö&L¨Q¸aÀtºm¢qÒ&LÑLˆJà')ˆØò 	(ˆAØŸ)™) D§H¡H¨Q£K°·±¸a³ÈI˜)ÓVˆKØÑ&Ø'��q’	ð	(ð
 ˆùò <ùÒ>`ùâ&Ls$   Á	C'Á#C'Á-	C,Á7C,Â	C1ÂC1c                óÖ   — t        | t        j                  «      r	 | S t        | t        j                  «      rt        j                  | d«      } | S t        | dd«      }t        d|› �«      ‚)N.rr   z???z!Unexpected type of exclude value )r   ro   rp   rq   rB   ÚfromkeysÚgetattrr+   )rA   Ú
class_names     r&   r[   zValueItems._coerce_itemsû   sf   € ä�eœVŸ^™^Ô,Øð ˆô ˜œv×1Ñ1Ô2Ü—M‘M %¨Ó-ˆEð ˆô ! ¨°UÓ;ˆJÜÐ?À
¸|ÐLÓMÐMr(   c                óN   — |�| j                  |«      r|S | j                  |«      S r   )rb   r[   )r3   r_   s     r&   rs   zValueItems._coerce_value  s(   € àˆ=˜CŸK™K¨Ô.ØˆLØ× Ñ  Ó'Ð'r(   c                ó   — | du xs | du S )NT.© r$   s    r&   rb   zValueItems.is_true  s   € à�DˆyÒ$˜A ˜HÐ$r(   c                ó    — d | j                   fgS r   rh   )r^   s    r&   Ú__repr_args__zValueItems.__repr_args__  s   € Ø�t—{‘{Ð#Ð$Ð$r(   N)r_   r   rA   ú$AbstractSetIntStr | MappingIntStrAnyÚreturnÚNone)re   r   r�   Úbool)rk   z	int | strr�   z+AbstractSetIntStr | MappingIntStrAny | None)rA   r   rx   rt   r�   zdict[int | str, Any])F)r€   r   r�   r   r   r‘   r�   r   )rA   rŽ   r�   r   )r_   r   r�   r   ©r%   r   r�   r‘   )r�   z_repr.ReprArgs)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r`   rf   ri   rl   r\   Úclassmethodru   Ústaticmethodr[   rs   rb   r�   r‹   r(   r&   rW   rW   Ž   sz   „ ÙYà#€Ió.ó3ó#ó8ó# ðJ ó#ó ð#ðJ òó ðð ò(ó ð(ð
 ò%ó ð%ô%r(   rW   c                 ó   — y r   r‹   ©Únamer_   s     r&   ÚClassAttributer�     s   € Ør(   c                  ó$   — e Zd ZdZdZdd„Zdd„Zy)r�   z(Hide class attribute from its instances.r›   c                ó    — || _         || _        y r   r›   )r^   rœ   r_   s      r&   r`   zClassAttribute.__init__   s   € ØˆDŒIØˆD�Jr(   c                óh   — |€| j                   S t        | j                  ›d|j                  ›d�«      ‚)Nz attribute of z is class-only)r_   ÚAttributeErrorrœ   r“   )r^   ÚinstanceÚowners      r&   Ú__get__zClassAttribute.__get__$  s4   € ØÐØ—z‘zÐ!Ü  D§I¡I =°¸u¿~¹~Ð>PÐP^Ð!_Ó`Ð`r(   N)rœ   Ústrr_   r   r�   r�   )r¢   r   r£   z	type[Any]r�   r�   )r“   r”   r•   r–   r—   r`   r¤   r‹   r(   r&   r�   r�     s   „ Ù6à#ˆ	ó	ô	ar(   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.
    )	rr   r   r   r!   r@   r+   Ú
ValueErrorÚRuntimeErrorr   )ÚobjÚobj_types     r&   Úsmart_deepcopyr¬   -  st   € ð
 �}‰}€HØÔ2Ñ2Øˆ
ðÙ�xÔ#6Ñ6à"¤eÑ+�3Ð;°·±³Ð;ô
 �C‹=Ðøô	 ”z¤<Ð0ò àä�C‹=Ðð	ús   ˜A ¬A ÁA(Á'A(c                ó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)ÚleftÚrightÚ	left_itemÚ
right_items       r&   Úall_identicalr´   C  s1   € ô "-¨T°5ÄFÔ!Kò Ñˆ	�:Ø˜JÒ&Ùðð r(   r’   )r,   r   r-   z(type[Any] | tuple[type[Any], ...] | Noner�   r‘   )r3   r   r-   r   r�   r‘   )r3   r   r�   zTypeGuard[type[BaseModel]])r<   r¥   r�   r‘   )rD   údict[KeyType, Any]rE   rµ   r�   rµ   )rD   zdict[Any, Any]rJ   r   r�   r�   )rQ   zlist[T] | tuple[T, ...]rM   ztyping.Callable[[T], str]r�   zlist[T])rœ   r¥   r_   rL   r�   rL   )rª   r¦   r�   r¦   )r°   útyping.Iterable[Any]r±   r¶   r�   r‘   )Ir–   Ú
__future__r   Ú_annotationsr:   ro   ÚweakrefÚcollectionsr   r   r   r@   r   Ú	itertoolsr   Útypesr	   r
   r   r   r   r   r   r   Útyping_extensionsr   r   Ú r   r   ÚTYPE_CHECKINGr   Ú__annotations__r   r6   r   rt   ÚfloatÚcomplexr¥   r‘   Úbytesr0   ÚNoneTypeÚrefÚNotImplementedrr   ÚEllipsisr   r    r"   r!   r#   rB   r   r'   r.   r4   r7   r=   r>   rC   rK   rL   rU   ÚRepresentationrW   r�   r¦   r¬   Úobjectr¯   r´   r‹   r(   r&   ú<module>rÊ      sŠ  ðòõ 3ã Û Û ß 7Ñ 7Ý Ý !ß d× dß ç 2ç "à	×ÒØ"WÐ�iÓWØ#VÐ�yÓVÝ ð
 Ø	ØØØØ	ØØ×ÑØØØØ‡K�KØð Ø×ÑØ×Ñð'3Ð  ó ð0 	ØØ	ØØØØØ	ð	'Ð �^ó 	óNóóóGóKñ �)Ó
€óóGñ ˆCƒL€ð /2ñØ'ðð ,ðð ó	ô,C%�×%Ñ%ô C%ðL 
×Òô÷
añ añ ˆeƒn€óñ& 
‹€ôr(   