Ë
    ðLqjð;  ã                  ót  — 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
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mZmZmZmZmZ ddlmZm Z m!Z!m"Z"m#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. ej^                  rdZ0de1d<   dZ2de1d<   ddl3m4Z4 e5e6e7e8e9e:e;e,jx                  eeee	jz                  eee>j~                  e@j~                  hZAde1d<   eBeCeDeEeFeeehZGde1d<   d9d„ZHd:d„ZId;d„ZJd<d„ZKd=d„ZLd>d „ZM e"d!«      ZNd?d"„ZOd@d#„ZP e"d$«      ZQe8d%œ	 	 	 	 	 dAd&„ZR G d'„ d(e+j¦                  «      ZTej^                  rdBd)„ZUn
 G d*„ d+«      ZU e"d,«      ZVdCd-„ZW eX«       ZYdDd.„ZZ ej¶                  d/¬0«       G d1„ d2«      «       Z\ e"d3d4¬5«      Z] e"d6«      Z^ G d7„ d8e!e]e^f   «      Z_y)Ez�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)ÚMapping)Údeepcopy)Úcached_property)Ú	Parameter)Úzip_longest)ÚBuiltinFunctionTypeÚCodeTypeÚFunctionTypeÚGeneratorTypeÚ
LambdaTypeÚ
ModuleType)ÚAnyÚCallableÚGenericÚTypeVarÚoverload)Ú	TypeAliasÚ	TypeGuardÚ
deprecated)ÚPydanticDeprecatedSince211é   )Ú_reprÚ_typing_extra)Úimport_cached_base_modelz3typing.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                óZ   — | j                   t        j                  t        j                  fv S )aZ  Return whether the parameter accepts a positional argument.

    ```python {test="skip" lint="skip"}
    def func(a, /, b, *, c):
        pass

    params = inspect.signature(func).parameters
    can_be_positional(params['a'])
    #> True
    can_be_positional(params['b'])
    #> True
    can_be_positional(params['c'])
    #> False
    ```
    )Úkindr
   ÚPOSITIONAL_ONLYÚPOSITIONAL_OR_KEYWORD)Úparams    úe/var/www/html/ai-menu-system/python-ai/venv/lib/python3.12/site-packages/pydantic/_internal/_utils.pyÚcan_be_positionalr+   H   s$   € ð  �:‰:œ)×3Ñ3´Y×5TÑ5TÐUÐUÐUó    c           	     óV   — t        | t        t        t        t        t
        t        f«      S ©N)Ú
isinstanceÚlistÚtupleÚsetÚ	frozensetr   r   ©Úvs    r*   Úsequence_liker6   [   s   € Ü�aœ$¤¤s¬I´}ÄeÐLÓMÐMr,   c                ó:   — 	 t        | |«      S # t        $ r Y yw xY w©NF)r/   Ú	TypeError)ÚoÚclass_or_tuples     r*   Úlenient_isinstancer<   _   s&   € ðÜ˜!˜^Ó,Ð,øÜò Ùðús   ‚ Ž	™c                ó”   — 	 t        | t        «      xr t        | |«      S # t        $ r t        | t        j
                  «      rY y‚ w xY wr8   )r/   ÚtypeÚ
issubclassr9   r   ÚWithArgsTypes)Úclsr;   s     r*   Úlenient_issubclassrB   f   sE   € ðÜ˜#œtÓ$ÒH¬°C¸Ó)HÐHøÜò Ü�cœ=×6Ñ6Ô7ÙØðús   ‚   #AÁAc                ó:   — t        «       }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   rB   )rA   r"   s     r*   Úis_model_classrD   o   s#   € ô )Ó*€Iä˜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_identifierrJ   x   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Úkr5   s         r*   rP   rP   ƒ   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.   )ÚupdaterN   )rQ   rW   rU   r5   s       r*   Úupdate_not_nonerX   Ž   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_listrZ   ÚresultÚresult_namesr5   Úv_names         r*   Úunique_listrb   •   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/   r0   r1   Ú_normalize_indexesÚlenre   )ÚselfÚvaluerN   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_truere   Úget©rk   Ú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
        ©re   rq   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)re   rp   ro   )rk   Úerr   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   .)rN   r/   Útypingr   ÚAbstractSetro   r9   Ú	__class__Ú_coerce_valueÚintÚmergerp   ÚrangeÚ
setdefault)	rk   rN   Úv_lengthÚnormalized_itemsÚ	all_itemsÚir5   Únormalized_iÚnormalized_items	            r*   ri   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)r   ro   r0   r�   rp   )rA   ÚbaseÚoverrider‹   rU   Ú
merge_keysÚmergedÚmerged_items           r*   r�   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.r~   z???z!Unexpected type of exclude value )r/   r|   r   r}   rO   ÚfromkeysÚgetattrr9   )rN   Ú
class_names     r*   rh   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.   )ro   rh   )rA   rl   s     r*   r   zValueItems._coerce_value#  s(   € àˆ=˜CŸK™K¨Ô.ØˆLØ× Ñ  Ó'Ð'r,   c                ó   — | du xs | du S )NT.© r4   s    r*   ro   zValueItems.is_true)  s   € à�DˆyÒ$˜A ˜HÐ$r,   c                ó    — d | j                   fgS r.   ru   ©rk   s    r*   Ú__repr_args__zValueItems.__repr_args__-  s   € Ø�t—{‘{Ð#Ð$Ð$r,   N)rl   r   rN   ú$AbstractSetIntStr | MappingIntStrAnyÚreturnÚNone)rr   r   rœ   Úbool)rx   z	int | strrœ   z+AbstractSetIntStr | MappingIntStrAny | None)rN   r   r„   r€   rœ   zdict[int | str, Any])F)rŒ   r   r�   r   r‹   rž   rœ   r   )rN   r›   rœ   r   )rl   r   rœ   r   ©r5   r   rœ   rž   )rœ   z_repr.ReprArgs)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__rm   rs   rv   ry   ri   Úclassmethodr�   Ústaticmethodrh   r   ro   rš   r—   r,   r*   rd   rd   «   sz   „ ÙYà#€Ió.ó3ó#ó8ó# ðJ ó#ó ð#ðJ òó ðð ò(ó ð(ð
 ò%ó ð%ô%r,   rd   c                 ó   — y r.   r—   ©ÚnameÚ	get_values     r*   ÚLazyClassAttributer«   3  s   � r,   c                  ó2   — e Zd ZdZdd„Zedd„«       Zdd„Zy)	r«   z­A descriptor exposing an attribute only accessible on a class (hidden from instances).

        The attribute is lazily computed and cached during the first access.
        c                ó    — || _         || _        y r.   r¨   )rk   r©   rª   s      r*   rm   zLazyClassAttribute.__init__=  s   € ØˆDŒIØ&ˆD�Nr,   c                ó"   — | j                  «       S r.   )rª   r™   s    r*   rl   zLazyClassAttribute.valueA  s   € à—>‘>Ó#Ð#r,   c                óh   — |€| j                   S t        | j                  ›d|j                  ›d�«      ‚)Nz attribute of z is class-only)rl   ÚAttributeErrorr©   r    )rk   ÚinstanceÚowners      r*   Ú__get__zLazyClassAttribute.__get__E  s4   € ØÐØ—z‘zÐ!Ü  D§I¡I =°¸u¿~¹~Ð>PÐP^Ð!_Ó`Ð`r,   N)r©   Ústrrª   zCallable[[], Any]rœ   r�   )rœ   r   )r±   r   r²   z	type[Any]rœ   r�   )r    r¡   r¢   r£   rm   r	   rl   r³   r—   r,   r*   r«   r«   7  s&   „ ñ	ó
	'ð 
ò	$ó 
ð	$ô	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.
    )	r~   r#   r$   r1   rM   r9   Ú
ValueErrorÚRuntimeErrorr   )ÚobjÚobj_types     r*   Úsmart_deepcopyr»   N  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   Ú	_SENTINEL)ÚleftÚrightÚ	left_itemÚ
right_items       r*   Úall_identicalrÃ   d  s1   € ô "-¨T°5ÄIÔ!Nò Ñˆ	�:Ø˜JÒ&Ùðð r,   T)Úfrozenc                  óJ   — e Zd ZU dZdZded<   dd„Zej                  rd	d„Z	yy)
ÚSafeGetItemProxyz¦Wrapper redirecting `__getitem__` to `get` with a sentinel value as default

    This makes is safe to use in `operator.itemgetter` when some keys may be missing
    )ÚwrappedzMapping[str, Any]rÇ   c               óB   — | j                   j                  |t        «      S r.   )rÇ   rp   r¾   ©rk   Úkeys     r*   Ú__getitem__zSafeGetItemProxy.__getitem__€  s   € Ø�|‰|×Ñ ¤YÓ/Ð/r,   c               ó8   — | j                   j                  |«      S r.   )rÇ   Ú__contains__rÉ   s     r*   rÍ   zSafeGetItemProxy.__contains__‰  s   € Ø—<‘<×,Ñ,¨SÓ1Ð1r,   N)rÊ   r´   rœ   r   )rÊ   r´   rœ   rž   )
r    r¡   r¢   r£   r¤   Ú__annotations__rË   r|   ÚTYPE_CHECKINGrÍ   r—   r,   r*   rÆ   rÆ   s  s.   … ñð €IàÓó0ð ×Òô	2ð r,   rÆ   Ú_ModelTr"   )ÚboundÚ_RTc                  ó^   — e Zd ZdZd	d„Zed
d„«       Ze edd¬«      dd„«       «       Zdd„Zy)Údeprecated_instance_propertya›  A decorator exposing the decorated class method as a property, with a warning on instance access.

    This decorator takes a class method defined on the `BaseModel` class and transforms it into
    an attribute. The attribute can be accessed on both the class and instances of the class. If accessed
    via an instance, a deprecation warning is emitted stating that instance access will be removed in V3.
    c               ó   — || _         y r.   )Úfget)rk   rÖ   s     r*   rm   z%deprecated_instance_property.__init__™  s	   € àˆ�	r,   c                 ó   — y r.   r—   ©rk   r±   Úobjtypes      r*   r³   z$deprecated_instance_property.__get__�  s   € ØFIr,   z›Accessing this attribute on the instance is deprecated, and will be removed in Pydantic V3. Instead, you should access this attribute from the model class.N)Úcategoryc                 ó   — y r.   r—   rØ   s      r*   r³   z$deprecated_instance_property.__get__Ÿ  s	   € ð JMr,   c                ó  — |�it         j                  dk\  r| j                  j                  n| j                  j                  j                  }t        j                  d|›d�t        d¬«        | j                  j                  ||«      «       S )N)é   é
   zAccessing the zi attribute on the instance is deprecated. Instead, you should access this attribute from the model class.r!   )rÚ   Ú
stacklevel)	ÚsysÚversion_inforÖ   r    Ú__func__ÚwarningsÚwarnr   r³   )rk   r±   rÙ   Ú	attr_names       r*   r³   z$deprecated_instance_property.__get__¦  sy   € ØÐÜ.1×.>Ñ.>À'Ò.I˜Ÿ	™	×*Ò*ÈtÏyÉy×OaÑOa×OjÑOjˆIÜ�M‰MØ   ð .Rð Rä3Øõ	ð 4ˆt�y‰y× Ñ  ¨7Ó3Ó5Ð5r,   )rÖ   zCallable[[type[_ModelT]], _RT]rœ   r�   )r±   r�   rÙ   útype[_ModelT]rœ   rÒ   )r±   rÐ   rÙ   ræ   rœ   rÒ   )r±   z_ModelT | NonerÙ   ræ   rœ   rÒ   )r    r¡   r¢   r£   rm   r   r³   r   r—   r,   r*   rÔ   rÔ   ‘  sK   „ ñóð ÚIó ØIØÙð	Jàôò
 Móó ð Mô	6r,   rÔ   )r)   r
   rœ   rž   rŸ   )r:   r   r;   z(type[Any] | tuple[type[Any], ...] | Nonerœ   rž   )rA   r   r;   r   rœ   rž   )rA   r   rœ   zTypeGuard[type[BaseModel]])rI   r´   rœ   rž   )rQ   údict[KeyType, Any]rR   rç   rœ   rç   )rQ   zdict[Any, Any]rW   r   rœ   r�   )r^   zlist[T] | tuple[T, ...]rZ   ztyping.Callable[[T], str]rœ   zlist[T])r©   r´   rª   zCallable[[], T]rœ   rY   )r¹   rµ   rœ   rµ   )r¿   útyping.Iterable[Any]rÀ   rè   rœ   rž   )`r£   Ú
__future__r   Ú_annotationsÚdataclassesrG   rà   r|   rã   ÚweakrefÚcollectionsr   r   r   Úcollections.abcr   rM   r   Ú	functoolsr	   Úinspectr
   Ú	itertoolsr   Útypesr   r   r   r   r   r   r   r   r   r   r   Útyping_extensionsr   r   r   Úpydanticr   Ú r   r   Ú_import_utilsr   rÏ   r   rÎ   r    Úmainr"   r€   ÚfloatÚcomplexr´   rž   Úbytesr>   ÚNoneTypeÚrefÚNotImplementedr~   ÚEllipsisr#   r0   r2   r1   r3   rO   r$   r+   r6   r<   rB   rD   rJ   rK   rP   rX   rY   rb   ÚRepresentationrd   r«   rµ   r»   Úobjectr¾   rÃ   Ú	dataclassrÆ   rÐ   rÒ   rÔ   r—   r,   r*   ú<module>r     sþ  ðòõ
 3ã Û Û 
Û Û Û ß 7Ñ 7Ý #Ý Ý %Ý Ý !ß d× dß <Õ <ç >Ñ >å /ç "Ý 3à	×ÒØ"WÐ�iÓWØ#VÐ�yÓVÝ ð
 Ø	ØØØØ	ØØ×ÑØØØØ‡K�KØð Ø×ÑØ×Ñð'3Ð  ó ð0 	ØØ	ØØØØØ	ð	'Ð �^ó 	óVó&NóóóGóKñ �)Ó
€óóGñ ˆCƒL€ð /2ñØ'ðð ,ðð ó	ô,C%�×%Ñ%ô C%ðL 
×ÒäK÷añ añ( ˆeƒn€óñ& ‹H€	óð €×Ñ˜dÔ#÷2ð 2ó $ð2ñ2 �) ;Ô
/€Ùˆeƒn€ô6 7¨7°C¨<Ñ#8õ 6r,   