Ë
    îÏjA§  ã                   ól  — d 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mZ dZdZdZd	Zd
ZdZdZ G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ dee«      Zd„ Z ej@                  ejB                  e¬«      Z"defd„Z#efd„Z$ G d„ de%«      Z& G d„ de&«      Z' G d„ de&«      Z( G d „ d!e&«      Z) G d"„ d#e&«      Z* G d$„ d%e&«      Z+ G d&„ d'e&«      Z, G d(„ d)e%«      Z- G d*„ d+e%«      Z.d,„ Z/d-„ Z0d.„ Z1 G d/„ d0e%«      Z2 G d1„ d2e%«      Z3d3„ Z4d4„ Z5d5„ Z6d6„ Z7d7„ Z8d8„ Z9d9„ Z:y):z Apply JSON-Patches (RFC 6902) é    N)ÚMappingÚMutableMappingÚMutableSequenceÚSequence)ÚSequenceMatcher)ÚMappingProxyType)ÚJsonPointerÚJsonPointerExceptioné   i�Ð u    Stefan KÃ¶gl <stefan@skoegl.net>z1.35z0https://github.com/stefankoegl/python-json-patchzBSD-3-Clausec                   ó   — e Zd ZdZy)ÚJsonPatchExceptionzBase Json Patch exceptionN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úF/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/jsonpatch.pyr   r   >   ó   „ Ú#r   r   c                   ó   — e Zd ZdZy)ÚInvalidJsonPatchz, Raised if an invalid JSON Patch is created Nr   r   r   r   r   r   B   s   „ Ú6r   r   c                   ó   — e Zd ZdZy)ÚJsonPatchConflicta
  Raised if patch could not be applied due to conflict situation such as:
    - attempt to add object key when it already exists;
    - attempt to operate with nonexistence object key;
    - attempt to insert value to array at position beyond its size;
    - etc.
    Nr   r   r   r   r   r   F   s   „ òr   r   c                   ó   — e Zd ZdZy)ÚJsonPatchTestFailedz A Test operation failed Nr   r   r   r   r   r   O   r   r   r   c                 ó°   — t        j                  t        «      }| D ]  \  }}||   j                  |«       Œ t	        d„ |j                  «       D «       «      S )z'Convert duplicate keys values to lists.c              3   óP   K  — | ]  \  }}|t        |«      d k(  r|d   n|f–— Œ  y­w)r   r   N©Úlen)Ú.0ÚkeyÚvaluess      r   Ú	<genexpr>zmultidict.<locals>.<genexpr>Z   s4   è ø€ ð ñ )‰KˆC�ð 
œ3˜v›;¨!Ò+ˆf�QŠi°Ô8Ù(ùs   ‚$&)ÚcollectionsÚdefaultdictÚlistÚappendÚdictÚitems)Úordered_pairsÚmdictr"   Úvalues       r   Ú	multidictr.   S   sX   € ô ×#Ñ#¤DÓ)€EÛ#‰
ˆˆUØˆc‰
×Ñ˜%Õ ð $ô ñ ð !Ÿ;™;œ=óó ð r   )Úobject_pairs_hookFc                 óœ   — t        |t        t        f«      rt        j	                  ||¬«      }nt        ||¬«      }|j                  | |«      S )a§  Apply list of patches to specified json document.

    :param doc: Document object.
    :type doc: dict

    :param patch: JSON patch as list of dicts or raw JSON-encoded string.
    :type patch: list or str

    :param in_place: While ``True`` patch will modify target document.
                     By default patch will be applied to document copy.
    :type in_place: bool

    :param pointer_cls: JSON pointer class to use.
    :type pointer_cls: Type[JsonPointer]

    :return: Patched document object.
    :rtype: dict

    >>> doc = {'foo': 'bar'}
    >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}]
    >>> other = apply_patch(doc, patch)
    >>> doc is not other
    True
    >>> other == {'foo': 'bar', 'baz': 'qux'}
    True
    >>> patch = [{'op': 'add', 'path': '/baz', 'value': 'qux'}]
    >>> apply_patch(doc, patch, in_place=True) == {'foo': 'bar', 'baz': 'qux'}
    True
    >>> doc == other
    True
    ©Úpointer_cls)Ú
isinstanceÚstrÚbytesÚ	JsonPatchÚfrom_stringÚapply)ÚdocÚpatchÚin_placer2   s       r   Úapply_patchr<   f   sE   € ôB �%œ#œu˜Ô&Ü×%Ñ% e¸Ð%ÓE‰ä˜%¨[Ô9ˆØ�;‰;�s˜HÓ%Ð%r   c                 ó2   — t         j                  | ||¬«      S )a›  Generates patch by comparing two document objects. Actually is
    a proxy to :meth:`JsonPatch.from_diff` method. The resulting patch
    transforms `src` into `dst`, so it has to be applied to `src` (or to a
    document equal to it).

    :param src: Data source document object.
    :type src: dict

    :param dst: Data target document object.
    :type dst: dict

    :param pointer_cls: JSON pointer class to use.
    :type pointer_cls: Type[JsonPointer]

    >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
    >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}
    >>> patch = make_patch(src, dst)
    >>> new = patch.apply(src)
    >>> new == dst
    True
    r1   )r6   Ú	from_diff)ÚsrcÚdstr2   s      r   Ú
make_patchrA   Ž   s   € ô. ×Ñ˜s C°[ÐÓAÐAr   c                   óˆ   — e Zd ZdZefd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
ed„ «       Zed	„ «       Zej                  d
„ «       Zd„ Zd„ Zy)ÚPatchOperationz'A single operation inside a JSON Patch.c                 ó\  — || _         |j                  d«      st        d«      ‚t        |d   | j                   «      r&|d   j                  | _        |d   | _        || _        y |d   | _        	 | j                  | j
                  «      | _        || _        y # t        $ r t        d«      ‚w xY w)NÚpathz#Operation must have a 'path' memberzInvalid 'path')	r2   Ú__contains__r   r3   rE   ÚlocationÚpointerÚ	TypeErrorÚ	operation)ÚselfrJ   r2   s      r   Ú__init__zPatchOperation.__init__«   s¯   € Ø&ˆÔà×%Ñ% fÔ-Ü"Ð#HÓIÐIä�i Ñ'¨×)9Ñ)9Ô:Ø% fÑ-×2Ñ2ˆDŒMØ$ VÑ,ˆDŒLð #ˆ�ð & fÑ-ˆDŒMð9Ø#×/Ñ/°·±Ó>�”ð #ˆ�øô ò 9Ü&Ð'7Ó8Ð8ð9ús   Á. B ÂB+c                 óÖ   — 	 | j                   d   }t        || j                  «      r|S 	 | j	                  |«      S # t        $ r t        d«      ‚w xY w# t
        $ r t        d«      ‚w xY w)zWBuilds the pointer of the 'from' member like __init__ builds the
        one of 'path'.Úfromz.The operation does not contain a 'from' memberzInvalid 'from')rJ   ÚKeyErrorr   r3   r2   rI   ©rK   Úfrom_ptrs     r   Ú_from_pointerzPatchOperation._from_pointer½   s„   € ð	BØ—~‘~ fÑ-ˆHô
 �h × 0Ñ 0Ô1ØˆOð	5Ø×#Ñ# HÓ-Ð-øô ò 	BÜ"Ø@óBð Bð	Bûô ò 	5Ü"Ð#3Ó4Ð4ð	5ús   ‚; ªA »AÁA(c                 ó   — t        d«      ‚)zGAbstract method that applies a patch operation to the specified object.z%should implement the patch operation.)ÚNotImplementedError)rK   Úobjs     r   r8   zPatchOperation.applyÎ   s   € ä!Ð"IÓJÐJr   c                 óh   — t        | j                  j                  d«      | j                  d   f«      S )NÚoprE   )ÚhashrJ   Úget©rK   s    r   Ú__hash__zPatchOperation.__hash__Ò   s,   € ô �T—^‘^×'Ñ'¨Ó-¨t¯~©~¸fÑ/EÐFÓGÐGr   c                 ód   — t        |t        «      syt        | j                  |j                  «      S ©NF)r3   rC   Ú_json_equalrJ   ©rK   Úothers     r   Ú__eq__zPatchOperation.__eq__×   s$   € Ü˜%¤Ô0Øä˜4Ÿ>™>¨5¯?©?Ó;Ð;r   c                 ó   — | |k(   S ©Nr   r_   s     r   Ú__ne__zPatchOperation.__ne__Ý   ó   € Ø˜5‘=Ð!Ð!r   c                 óR   — dj                  | j                  j                  d d «      S )NÚ/éÿÿÿÿ)ÚjoinrH   ÚpartsrZ   s    r   rE   zPatchOperation.pathà   s"   € à�x‰x˜Ÿ™×*Ñ*¨3¨BÐ/Ó0Ð0r   c                 ó$   — | j                  d«      S ©Nrh   )Úget_partrZ   s    r   r"   zPatchOperation.keyä   s   € à�}‰}˜RÓ Ð r   c                 ó(   — | j                  d|«       y rl   )Úset_part©rK   r-   s     r   r"   zPatchOperation.keyè   s   € à�‰�b˜%Õ r   c                 ó˜   — 	 t        | j                  j                  |   «      S # t        $ r | j                  j                  |   cY S w xY wrc   )ÚintrH   rj   Ú
ValueError)rK   Úindexs     r   rm   zPatchOperation.get_partì   sE   € ð	-Ü�t—|‘|×)Ñ)¨%Ñ0Ó1Ð1øÜò 	-Ø—<‘<×%Ñ% eÑ,Ò,ð	-ús   ‚!$ ¤"A	ÁA	c                 ó°   — t        |«      | j                  j                  |<   | j                  j                  | _        | j                  | j
                  d<   y )NrE   )r4   rH   rj   rE   rG   rJ   )rK   rt   r-   s      r   ro   zPatchOperation.set_partò   s=   € Ü$'¨£Jˆ�‰×Ñ˜5Ñ!ØŸ™×)Ñ)ˆŒØ!%§¡ˆ�‰�vÒr   N)r   r   r   r   r	   rL   rR   r8   r[   ra   rd   ÚpropertyrE   r"   Úsetterrm   ro   r   r   r   rC   rC   ¨   sr   „ Ù1à.9ó #ò$5ò"KòHò
<ò"ð ñ1ó ð1ð ñ!ó ð!ð 	‡Z�Zñ!ó ð!ò-ó/r   rC   c                   ó   — e Zd ZdZd„ Zy)ÚRemoveOperationz/Removes an object property or an array element.c                 ó6  — | j                   j                  |«      \  }}|€t        d«      ‚t        |t        «      r*t        |t
        «      st        dj                  |«      «      ‚	 ||= |S # t        t        f$ r dj                  |«      }t        |«      ‚w xY w)Nzcan't remove the whole documentúinvalid array index '{0}'z(can't remove a non-existent object '{0}')
rH   Úto_lastr   r3   r   rr   r
   ÚformatrO   Ú
IndexError)rK   rU   ÚsubobjÚpartÚmsgs        r   r8   zRemoveOperation.applyû   s™   € Ø—|‘|×+Ñ+¨CÓ0‰ˆ�àˆ<Ü#Ð$EÓFÐFä�fœhÔ'´
¸4ÄÔ0EÜ&Ð'B×'IÑ'IÈ$Ó'OÓPÐPð	)Ø�t�ð
 ˆ
øô	 œ*Ð%ò 	)Ø<×CÑCÀDÓIˆCÜ# CÓ(Ð(ð	)ús   Á'A, Á,,BN©r   r   r   r   r8   r   r   r   ry   ry   ø   s
   „ Ù9ór   ry   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚAddOperationz,Adds an object property or an array element.c                 óœ   — 	 | j                   d   }| j                  |t	        j
                  |«      «      S # t        $ r t        d«      ‚w xY w)Nr-   ú/The operation does not contain a 'value' member)rJ   rO   r   Ú_addÚcopyÚdeepcopy)rK   rU   r-   s      r   r8   zAddOperation.apply  sW   € ð	CØ—N‘N 7Ñ+ˆEð �y‰y˜œdŸm™m¨EÓ2Ó3Ð3øô ò 	CÜ"ØAóCð Cð	Cús	   ‚6 ¶Ac                 ór  — | j                   j                  |«      \  }}|€|S t        |t        «      rJ|dk(  r|j	                  |«       |S |t        |«      kD  s|dk  rt        d«      ‚|j                  ||«       |S t        |t        «      r|||<   |S t        dj                  | j                  |«      «      ‚)NÚ-r   zcan't insert outside of listú2unable to fully resolve json pointer {0}, part {1})rH   r|   r3   r   r(   r    r   Úinsertr   r}   rG   )rK   rU   r-   r   r€   s        r   r‡   zAddOperation._add  s¾   € Ø—|‘|×+Ñ+¨CÓ0‰ˆ�àˆ<ØˆLä�fœoÔ.Ø�sŠ{Ø—‘˜eÔ$ð ˆ
ð œ˜F›Ò# t¨a¢xÜ'Ð(FÓGÐGð —‘˜d EÔ*ð ˆ
ô ˜¤Ô/Ø ˆF�4‰Lð ˆ
ô $Ð$X×$_Ñ$_Ð`d×`mÑ`mÐosÓ$tÓuÐur   N)r   r   r   r   r8   r‡   r   r   r   r„   r„     s   „ Ù6ò	4ór   r„   c                   ó   — e Zd ZdZd„ Zy)ÚReplaceOperationz?Replaces an object property or an array element by a new value.c                 óô  — 	 | j                   d   }t        j                  |«      }| j
                  j                  |«      \  }}|€|S t        |t        «      r.|dk(  rt        d«      ‚|t        |«      k\  s|dk  r`t        d«      ‚t        |t        «      r ||vrAdj                  |«      }t        |«      ‚t        dj                  | j                  |«      «      ‚|||<   |S # t        $ r t        d«      ‚w xY w)	Nr-   r†   r‹   z7'path' with '-' can't be applied to 'replace' operationr   zcan't replace outside of listz)can't replace a non-existent object '{0}'rŒ   )rJ   rO   r   rˆ   r‰   rH   r|   r3   r   r    r   r   r}   rG   )rK   rU   r-   r   r€   r�   s         r   r8   zReplaceOperation.apply6  s  € ð	CØ—N‘N 7Ñ+ˆEô —‘˜eÓ$ˆà—|‘|×+Ñ+¨CÓ0‰ˆ�àˆ<ØˆLä�fœoÔ.ð �sŠ{Ü&Ð'`ÓaÐaà”s˜6“{Ò" d¨Q¢hÜ'Ð(GÓHÐHä˜¤Ô/Ø˜6Ñ!ØA×HÑHÈÓN�Ü'¨Ó,Ð,ä#Ð$X×$_Ñ$_Ð`d×`mÑ`mÐosÓ$tÓuÐuàˆˆt‰Øˆ
øô; ò 	CÜ"ØAóCð Cð	Cús   ‚C" Ã"C7Nr‚   r   r   r   r�   r�   3  s
   „ ÙIó r   r�   c                   óf   — e Zd ZdZd„ Zed„ «       Zed„ «       Zej                  d„ «       Zd„ Z	d„ Z
y)	ÚMoveOperationz?Moves an object property or an array element to a new location.c                 ó  — | j                  «       }| j                  |k7  r&| j                  j                  |«      rt        d«      ‚t	        ||«      \  }}|€|S 	 ||   }| j                  |k(  r|S t        d| j                  d   dœ| j                  ¬«      j                  |«      }t        d| j                  dœ| j                  ¬«      j                  ||«      }|S # t
        t        f$ r}t        t        |«      «      ‚d }~ww xY w)Nz*Cannot move values into their own childrenÚremoverN   ©rW   rE   r1   Úadd)rR   rH   Úcontainsr   Ú_to_existing_lastrO   r~   r4   ry   rJ   r2   r8   r„   rG   r‡   ©rK   rU   rQ   r   r€   r-   Úexs          r   r8   zMoveOperation.apply\  s  € Ø×%Ñ%Ó'ˆð
 �<‰<˜8Ò#¨¯©×(=Ñ(=¸hÔ(GÜ#Ð$PÓQÐQä(¨°3Ó7‰ˆ�ð ˆ<ØˆJð	-Ø˜4‘LˆEð
 �<‰<˜8Ò#ØˆJäØØ—N‘N 6Ñ*ñ
ð ×'Ñ'ô)÷ */©¨s«ð 	ô ØØ—M‘Mñ
ð ×'Ñ'ô)÷ *.©¨c°5Ó)9ð 	ð
 ˆ
øô% œ*Ð%ò 	-Ü#¤C¨£GÓ,Ð,ûð	-ús   ÁC ÃDÃ+C?Ã?Dc                 óz   — | j                  | j                  d   «      }dj                  |j                  d d «      S )NrN   rg   rh   )r2   rJ   ri   rj   rP   s     r   Ú	from_pathzMoveOperation.from_path�  s5   € à×#Ñ# D§N¡N°6Ñ$:Ó;ˆØ�x‰x˜Ÿ™ s¨Ð+Ó,Ð,r   c                 ó$   — | j                  d«      S rl   )Úget_from_partrZ   s    r   Úfrom_keyzMoveOperation.from_key†  s   € à×!Ñ! "Ó%Ð%r   c                 ó(   — | j                  d|«       y rl   )Úset_from_partrp   s     r   rŸ   zMoveOperation.from_keyŠ  s   € à×Ñ˜2˜uÕ%r   c                 ó¬   — | j                  | j                  d   «      }	 t        |j                  |   «      S # t        $ r |j                  |   cY S w xY w©NrN   )r2   rJ   rr   rj   rs   )rK   rt   rQ   s      r   rž   zMoveOperation.get_from_partŽ  sR   € Ø×#Ñ# D§N¡N°6Ñ$:Ó;ˆð	)Ü�x—~‘~ eÑ,Ó-Ð-øÜò 	)Ø—>‘> %Ñ(Ò(ð	)ús    8 ¸AÁAc                 ó¢   — | j                  | j                  d   «      }t        |«      |j                  |<   |j                  | j                  d<   y r£   )r2   rJ   r4   rj   rE   )rK   rt   r-   rQ   s       r   r¡   zMoveOperation.set_from_part•  s?   € Ø×#Ñ# D§N¡N°6Ñ$:Ó;ˆÜ # E£
ˆ�‰�uÑØ!)§¡ˆ�‰�vÒr   N)r   r   r   r   r8   rv   rœ   rŸ   rw   rž   r¡   r   r   r   r’   r’   Y  sU   „ ÙIò#ðJ ñ-ó ð-ð ñ&ó ð&ð ‡_�_ñ&ó ð&ò)ó/r   r’   c                   ó   — e Zd ZdZd„ Zy)ÚTestOperationz!Test value by specified location.c           
      óš  — 	 | j                   j                  |«      \  }}|€|}n| j                   j                  ||«      }	 | j                  d   }t        ||«      s1d}t	        |j                  |t        |«      |t        |«      «      «      ‚|S # t        $ r}t	        t        |«      «      ‚d }~ww xY w# t        $ r t        d«      ‚w xY w)Nr-   r†   z0{0} ({1}) is not equal to tested value {2} ({3}))rH   r|   Úwalkr
   r   r4   rJ   rO   r   r^   r}   Útype)rK   rU   r   r€   Úvalrš   r-   r�   s           r   r8   zTestOperation.applyž  sÜ   € ð	/ØŸ<™<×/Ñ/°Ó4‰LˆF�DØˆ|Ø‘à—l‘l×'Ñ'¨°Ó5�ð	CØ—N‘N 7Ñ+ˆEô
 ˜3 Ô&ØDˆCÜ% c§j¡j°´d¸3³iØ16¼¸U»ó'Eó Fð Fð ˆ
øô $ò 	/Ü%¤c¨"£gÓ.Ð.ûð	/ûô
 ò 	CÜ"ØAóCð Cð	Cús#   ‚?B ÁB5 Â	B2ÂB-Â-B2Â5C
Nr‚   r   r   r   r¦   r¦   ›  s
   „ Ù+ór   r¦   c                   ó   — e Zd ZdZd„ Zy)ÚCopyOperationzA Copies an object property or an array element to a new location c                 ó<  — | j                  «       }t        ||«      \  }}	 t        j                  |€|n||   «      }t        d| j                  dœ| j                  ¬«      j                  ||«      }|S # t        t
        f$ r}t        t        |«      «      ‚d }~ww xY w)Nr–   r•   r1   )rR   r˜   rˆ   r‰   rO   r~   r   r4   r„   rG   r2   r‡   r™   s          r   r8   zCopyOperation.apply¹  s¡   € Ø×%Ñ%Ó'ˆä(¨°3Ó7‰ˆ�ð	-Ü—M‘M¨D¨L¡&¸fÀT¹lÓKˆEô
 ØØ—M‘Mñ
ð ×'Ñ'ô)÷ *.©¨c°5Ó)9ð 	ð
 ˆ
øô œ*Ð%ò 	-Ü#¤C¨£GÓ,Ð,ûð	-ús   ¡A3 Á3BÂBÂBNr‚   r   r   r   r¬   r¬   ¶  s
   „ ÙKór   r¬   c            	       óè   — e Zd ZdZ eej                  «      Z ee«      Z	 e
eeeeeedœ«      Zefd„Zd„ Zd„ ZeZd„ Zd„ Zd„ Zd	„ Zed
efd„«       Zedd
efd„«       Zdd„Zed„ «       Z dd„Z!d„ Z"y
)r6   ad  A JSON Patch is a list of Patch Operations.

    >>> patch = JsonPatch([
    ...     {'op': 'add', 'path': '/foo', 'value': 'bar'},
    ...     {'op': 'add', 'path': '/baz', 'value': [1, 2, 3]},
    ...     {'op': 'remove', 'path': '/baz/1'},
    ...     {'op': 'test', 'path': '/baz', 'value': [1, 3]},
    ...     {'op': 'replace', 'path': '/baz/0', 'value': 42},
    ...     {'op': 'remove', 'path': '/baz/1'},
    ... ])
    >>> doc = {}
    >>> result = patch.apply(doc)
    >>> expected = {'foo': 'bar', 'baz': [42]}
    >>> result == expected
    True

    JsonPatch object is iterable, so you can easily access each patch
    statement in a loop:

    >>> lpatch = list(patch)
    >>> expected = {'op': 'add', 'path': '/foo', 'value': 'bar'}
    >>> lpatch[0] == expected
    True
    >>> lpatch == patch.patch
    True

    Also JsonPatch could be converted directly to :class:`bool` if it contains
    any operation statements:

    >>> bool(patch)
    True
    >>> bool(JsonPatch([]))
    False

    This behavior is very handy with :func:`make_patch` to write more readable
    code:

    >>> old = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
    >>> new = {'baz': 'qux', 'numbers': [1, 4, 7]}
    >>> patch = make_patch(old, new)
    >>> if patch:
    ...     # document have changed, do something useful
    ...     patch.apply(old)    #doctest: +ELLIPSIS
    {...}
    )r”   r–   ÚreplaceÚmoveÚtestrˆ   c                 ó¦   — || _         || _        | j                   D ]4  }t        |t        t        f«      rt        d«      ‚| j                  |«       Œ6 y )NzMDocument is expected to be sequence of operations, got a sequence of strings.)r:   r2   r3   r4   r5   r   Ú_get_operation)rK   r:   r2   rW   s       r   rL   zJsonPatch.__init__  sV   € ØˆŒ
Ø&ˆÔð —*”*ˆBô ˜"œs¤E˜lÔ+Ü&ð (Pó Qð Qð ×Ñ Õ#ñ r   c                 ó"   — | j                  «       S )zstr(self) -> self.to_string())Ú	to_stringrZ   s    r   Ú__str__zJsonPatch.__str__  s   € à�~‰~ÓÐr   c                 ó,   — t        | j                  «      S rc   )Úboolr:   rZ   s    r   Ú__bool__zJsonPatch.__bool__!  ó   € Ü�D—J‘JÓÐr   c                 ó,   — t        | j                  «      S rc   )Úiterr:   rZ   s    r   Ú__iter__zJsonPatch.__iter__&  rº   r   c                 ó>   — t        t        | j                  «      «      S rc   )rX   ÚtupleÚ_opsrZ   s    r   r[   zJsonPatch.__hash__)  s   € Ü”E˜$Ÿ)™)Ó$Ó%Ð%r   c                 óV   — t        |t        «      sy| j                  |j                  k(  S r]   )r3   r6   rÀ   r_   s     r   ra   zJsonPatch.__eq__,  s"   € Ü˜%¤Ô+ØØ�y‰y˜EŸJ™JÑ&Ð&r   c                 ó   — | |k(   S rc   r   r_   s     r   rd   zJsonPatch.__ne__1  re   r   Nc                 óF   — |xs | j                   } ||«      } | ||¬«      S )a¨  Creates JsonPatch instance from string source.

        :param patch_str: JSON patch as raw string.
        :type patch_str: str

        :param loads: A function of one argument that loads a serialized
                      JSON string.
        :type loads: Callable

        :param pointer_cls: JSON pointer class to use.
        :type pointer_cls: Type[JsonPointer]

        :return: :class:`JsonPatch` instance.
        r1   )Újson_loader)ÚclsÚ	patch_strÚloadsr2   rÄ   r:   s         r   r7   zJsonPatch.from_string4  s)   € ð  Ò.˜sŸ™ˆÙ˜IÓ&ˆÙ�5 kÔ2Ð2r   Tc                 ó®   — |xs | j                   }t        ||||¬«      }|j                  dd||«       t        |j	                  «       «      } | ||¬«      S )a½  Creates JsonPatch instance based on comparison of two document
        objects. Json patch would be created for `src` argument against `dst`
        one. The resulting patch transforms `src` into `dst`, so it has to be
        applied to `src` (or to a document equal to it).

        :param src: Data source document object.
        :type src: dict

        :param dst: Data target document object.
        :type dst: dict

        :param dumps: A function of one argument that produces a serialized
                      JSON string.
        :type dumps: Callable

        :param pointer_cls: JSON pointer class to use.
        :type pointer_cls: Type[JsonPointer]

        :return: :class:`JsonPatch` instance.

        >>> src = {'foo': 'bar', 'numbers': [1, 3, 4, 8]}
        >>> dst = {'baz': 'qux', 'numbers': [1, 4, 7]}
        >>> patch = JsonPatch.from_diff(src, dst)
        >>> new = patch.apply(src)
        >>> new == dst
        True
        r1   r   N)Újson_dumperÚDiffBuilderÚ_compare_valuesr'   Úexecute)	rÅ   r?   r@   ÚoptimizationÚdumpsr2   rÉ   ÚbuilderÚopss	            r   r>   zJsonPatch.from_diffH  sU   € ð@ Ò.˜sŸ™ˆÜ˜c 3¨ÀÔMˆØ×Ñ  D¨#¨sÔ3Ü�7—?‘?Ó$Ó%ˆÙ�3 KÔ0Ð0r   c                 óF   — |xs | j                   } || j                  «      S )z!Returns patch set as JSON string.)rÉ   r:   )rK   rÎ   rÉ   s      r   rµ   zJsonPatch.to_stringn  s!   € àÒ/˜t×/Ñ/ˆÙ˜4Ÿ:™:Ó&Ð&r   c                 óT   — t        t        | j                  | j                  «      «      S rc   )r¿   Úmapr³   r:   rZ   s    r   rÀ   zJsonPatch._opss  s   € ä”S˜×,Ñ,¨d¯j©jÓ9Ó:Ð:r   c                 óx   — |st        j                  |«      }| j                  D ]  }|j                  |«      }Œ |S )a5  Applies the patch to a given object.

        :param obj: Document object.
        :type obj: dict

        :param in_place: Tweaks the way how patch would be applied - directly to
                         specified `obj` or to its copy.
        :type in_place: bool

        :return: Modified `obj`.
        )rˆ   r‰   rÀ   r8   )rK   rU   r;   rJ   s       r   r8   zJsonPatch.applyw  s8   € ñ Ü—-‘- Ó$ˆCàŸœˆIØ—/‘/ #Ó&‰Cð #ð ˆ
r   c                 ó8  — t        |t        «      st        d«      ‚d|vrt        d«      ‚|d   }t        |t        t        f«      st        d«      ‚|| j
                  vrt        dj                  |«      «      ‚| j
                  |   } ||| j                  ¬«      S )NzOperation must be an objectrW   z&Operation does not contain 'op' memberzOperation's op must be a stringzUnknown operation {0!r}r1   )r3   r   r   r4   r5   Ú
operationsr}   r2   )rK   rJ   rW   rÅ   s       r   r³   zJsonPatch._get_operationŒ  s“   € Ü˜)¤WÔ-Ü"Ð#@ÓAÐAà�yÑ Ü"Ð#KÓLÐLà�t‰_ˆä˜"œs¤E˜lÔ+Ü"Ð#DÓEÐEà�T—_‘_Ñ$Ü"Ð#<×#CÑ#CÀBÓ#GÓHÐHà�o‰o˜bÑ!ˆÙ�9¨$×*:Ñ*:Ô;Ð;r   rc   )F)#r   r   r   r   ÚstaticmethodÚjsonrÎ   rÉ   Ú
_jsonloadsrÄ   r   ry   r„   r�   r’   r¦   r¬   rÖ   r	   rL   r¶   r¹   Ú__nonzero__r½   r[   ra   rd   Úclassmethodr7   r>   rµ   rv   rÀ   r8   r³   r   r   r   r6   r6   Ë  sË   „ ñ,ñZ ˜tŸz™zÓ*€KÙ˜zÓ*€Ká!Ø!ØØ#ØØØñ#ó €Jð +6ó $ò0 ò ð €Kò ò&ò'ò
"ð Ø*.¸Kò 3ó ð3ð& à(,°DØ#ò#1ó ð#1óJ'ð
 ñ;ó ð;óó*<r   r6   c                   ó¤   — e Zd Zej                  efd„Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)rÊ   c                 ó~   — || _         || _        i i g| _        g x| _        }|| _        || _        i | _        ||d g|d d  y rc   )rÎ   r2   Úindex_storageÚ_DiffBuilder__rootÚsrc_docÚdst_docÚarrays)rK   rà   rá   rÎ   r2   Úroots         r   rL   zDiffBuilder.__init__¡  sN   € ØˆŒ
Ø&ˆÔØ  "˜XˆÔØÐˆŒ�dØˆŒØˆŒàˆŒØ˜˜tÐ$ˆ‰Q‰r   c                 ó‚   — 	 | j                  t        |«      «      S # t        t        t        f$ r t        |«      cY S w xY w)z A key of value, which is equal for values that are equal in JSON,
        so that e.g. [1] is not moved where [true] is added )rÎ   Ú_sorted_membersrI   rs   ÚRecursionErrorÚidrp   s     r   Ú	_move_keyzDiffBuilder._move_key¬  s=   € ð	à—:‘:œo¨eÓ4Ó5Ð5øÜœ:¤~Ð6ò 	ô �e“9Òð	ús   ‚ œ>½>c                 ó‚   — | j                   |   }|j                  | j                  |«      g «      j                  |«       y rc   )rÞ   Ú
setdefaultrè   r(   )rK   r-   rt   ÚstÚstorages        r   Ústore_indexzDiffBuilder.store_index·  s6   € Ø×$Ñ$ RÑ(ˆØ×Ñ˜4Ÿ>™>¨%Ó0°"Ó5×<Ñ<¸UÕCr   c                 ó‚   — | j                   |   j                  | j                  |«      «      }|r|j                  «       S y rc   )rÞ   rY   rè   Úpop)rK   r-   rë   Ústoreds       r   Ú
take_indexzDiffBuilder.take_index»  s:   € Ø×#Ñ# BÑ'×+Ñ+¨D¯N©N¸5Ó,AÓBˆÙØ—:‘:“<Ðð r   c                 óH   — | j                   }|d   }|||gx|d<   |d<   |d   S )Nr   r   ©rß   )rK   rW   rã   Úlasts       r   r�   zDiffBuilder.insertÀ  s6   € Ø�{‰{ˆØ�A‰wˆØ! 4¨Ð,Ð,ˆˆQ‰�$�q‘'Ø�A‰wˆr   c                 ó.   — |\  }}}||d<   ||d<   g |d d  y )Nr   r   r   )rK   rt   Ú	link_prevÚ	link_nextÚ_s        r   r”   zDiffBuilder.removeÆ  s)   € Ø"'Ñˆ	�9˜aØ ˆ	�!‰Ø ˆ	�!‰Øˆ‰a‰r   c              #   óZ   K  — | j                   }|d   }||ur|d   –— |d   }||urŒy y ­w)Nr   é   ró   )rK   rã   Úcurrs      r   r½   zDiffBuilder.__iter__Ì  s<   è ø€ Ø�{‰{ˆØ�A‰wˆØ˜$ÑØ�q‘'ŠMØ˜‘7ˆDð ˜$Ôùs   ‚&+©+c              #   ó€  K  — t        | j                  «       «      }d}|t        |«      k  r‘|dz   t        |«      k  rE||   ||dz      }}|d   |d   k(  r-|d   dk(  r%|d   dk(  rdt        |d   «      |d   d	œ–— |d
z  }Œd||   }dD ]  }||v sŒt        ||   «      ||<   Œ |–— |dz  }|t        |«      k  rŒ�y y ­w)Nr   r   rE   rW   r”   r–   r¯   r-   ©rW   rE   r-   rú   )rN   rE   )r'   Ú_replayr    Ú_to_pointer)rK   rÖ   ÚiÚop_firstÚ	op_secondrJ   Úmembers          r   rÌ   zDiffBuilder.executeÓ  sô   è ø€ Ü˜$Ÿ,™,›.Ó)ˆ
ØˆØ”#�j“/Ò!Ø�1‰u”s˜:“Ò&Ø&0°¡m°ZÀÀAÁÑ5F˜)�Ø˜FÑ# y°Ñ'8Ò8Ø  ™¨(Ò2Ø! $™¨5Ò0à'Ü +¨I°fÑ,=Ó >Ø!*¨7Ñ!3ñò ð
 ˜‘F�AØà" 1™ˆIÛ*�Ø˜YÒ&Ü(3°I¸fÑ4EÓ(F�I˜fÒ%ð +ð ŠOØ�‰FˆAð' ”#�j“/Õ!ùs   ‚BB>Â*B>Â<B>c              #   ó˜  K  — | j                   j                  «       D ]  }|j                  «        Œ | D ]’  }t        |«      }d|v r,| j	                  |d   «      |d<   | j                  |d   d«       | j	                  |d   «      |d<   |d   dk(  r| j                  |d   d«       n|d   dv r| j                  |d   d«       |–— Œ” y­w)	z‚ Applies the operations to the arrays of the source document, and
        returns them with the array indices at which they apply rN   FrE   rW   r”   )r–   r°   TN)râ   r#   Úresetr)   Ú_partsÚ_set_present)rK   r*   rW   rJ   s       r   rþ   zDiffBuilder._replayë  sË   è ø€ ð —[‘[×'Ñ'Ö)ˆEØ�K‰K�Mð *ó ˆBÜ˜R›ˆIà˜‰|Ø$(§K¡K°°6±
Ó$;�	˜&Ñ!Ø×!Ñ! " V¡*¨eÔ4à $§¡¨B¨v©JÓ 7ˆI�fÑØ�$‰x˜8Ò#Ø×!Ñ! " V¡*¨eÕ4Ø�D‘˜_Ñ,Ø×!Ñ! " V¡*¨dÔ3à‹Oñ ùs   ‚CC
c                 ór   — | j                   j                  |«      }|€t        «       x}| j                   |<   |S )z* The _ArrayItems of the array at location )râ   rY   Ú_ArrayItems)rK   rG   r*   s      r   Ú_array_itemszDiffBuilder._array_items   s3   € à—‘—‘ Ó)ˆØˆ=Ü,7«MÐ9ˆE�D—K‘K Ñ)Øˆr   c                 ó„   — d}|D ]8  }t        |t        «      r | j                  |«      j                  |«      }||fz  }Œ: |S )z/ The location of parts in the current document r   )r3   rr   r
  Úat)rK   rj   rG   r€   s       r   Ú	_locationzDiffBuilder._location  sI   € àˆÛˆDÜ˜$¤Ô$Ø×(Ñ(¨Ó2×5Ñ5°dÓ;�Ø˜˜Ñ‰Hð ð ˆr   c                 óœ   — | j                  |«      }t        |t        «      r | j                  |«      j	                  |«      }t        ||«      S )zb The location of an item inserted at key of the container at path
        of the current document )r  r3   rr   r
  r�   Ú
_path_join)rK   rE   r"   rG   s       r   Ú_new_locationzDiffBuilder._new_location  sD   € ð —>‘> $Ó'ˆÜ�cœ3ÔØ×#Ñ# HÓ-×4Ñ4°SÓ9ˆCÜ˜( CÓ(Ð(r   c                 ó&   — t        d„ |D «       «      S )z¡ The parts of location in the current document. If location is an
        array item that is not in the array, its index is where it would be
        if it was. c              3   ó`   K  — | ]&  }t        |t        «      r|j                  «       n|–— Œ( y ­wrc   )r3   Ú
_ArrayItemrt   ©r!   r€   s     r   r$   z%DiffBuilder._parts.<locals>.<genexpr>  s,   è ø€ ð +Ù!)˜ô &0°´jÔ%A�T—Z‘Z”\ÀtÓKÙ!)ùs   ‚,.)r¿   )rK   rG   s     r   r  zDiffBuilder._parts  s   € ô ñ +Ù!)ó+ó +ð 	+r   c                 óª   — |r|d   nd}t        |t        «      r:|r|j                  j                  |«       y|j                  j	                  |«       yy)z` Adds the array item at location to the current document, or
        removes it, if not present rh   N)r3   r  Úarrayr–   r”   )rK   rG   ÚpresentÚitems       r   r  zDiffBuilder._set_present  sE   € ñ  (ˆx˜Š|¨TˆÜ�dœJÔ'ÙØ—
‘
—‘˜tÕ$à—
‘
×!Ñ! $Õ'ð	 (r   c                 ó¬  — t        ||«      }| j                  |t        «      }|�t|d   d   }| j                  |«      }t	        ||«      sO| j                  |«       ||k7  r&| j                  d|| j                  ||«      dœ«       y | j                  |d«       y | j                  d| j                  ||«      |dœ«      }| j                  ||t        «       y )Nrú   rE   r°   ©rW   rN   rE   Tr–   rý   )r  rñ   Ú
_ST_REMOVEr  Ú
_is_insider”   r�   r  r  rí   Ú_ST_ADD)	rK   rE   r"   r  Útargetrt   ÚremovedÚsourceÚ	new_indexs	            r   Ú_item_addedzDiffBuilder._item_added)  sÛ   € Ü˜D #Ó&ˆØ—‘ ¤jÓ1ˆØÐØ˜A‘h˜vÑ&ˆGà—[‘[ Ó)ˆFä˜f fÔ-Ø—‘˜EÔ"Ø˜VÒ#Ø—K‘K v°wØ)-×);Ñ);¸DÀ#Ó)Fñ!Hô Ið
 ð ×%Ñ% g¨tÔ4Øà—K‘K uØ)-×);Ñ);¸DÀ#Ó)FØ*.ñ!0ó 1ˆ	ð 	×Ñ˜˜y¬'Õ2r   c                 óÐ  — t        ||«      }| j                  |«      }| j                  |t        «      }|�t|d   d   }| j	                  |«      }| j                  |«       t        ||«      |k7  r(| j                  |d«       | j                  d||dœ«       y | j                  |d«       y | j                  |d«       | j                  d|dœ«      }	| j                  ||	t        «       y )Nrú   rE   Fr°   r  r”   r•   )r  r  rñ   r  r  r”   Ú_without_itemr  r�   rí   r  )
rK   rE   r"   r  r   rG   rt   Úadded_locationÚaddedr!  s
             r   Ú_item_removedzDiffBuilder._item_removed@  sâ   € Ü˜D #Ó&ˆØ—>‘> &Ó)ˆØ—‘ ¤gÓ.ˆØÐØ" 1™X fÑ-ˆNØ—K‘K Ó/ˆEð �K‰K˜ÔÜ˜V UÓ+¨uÒ4Ø×!Ñ! (¨EÔ2Ø—‘ 6°8Ø%3ñ5ô 6ð
 ð ×!Ñ! .°%Ô8Øà×Ñ˜( EÔ*Ø—K‘K x¸Ñ BÓCˆ	Ø×Ñ˜˜y¬*Õ5r   c           	      ó`   — | j                  d| j                  t        ||«      «      |dœ«       y )Nr¯   rý   )r�   r  r  )rK   rE   r"   r  s       r   Ú_item_replacedzDiffBuilder._item_replacedX  s,   € Ø�‰ØØ—N‘N¤:¨d°CÓ#8Ó9Øñ
õ 	r   c                 ó†  — |D �cg c]	  }||vsŒ|‘Œ }}|D �cg c]	  }||vsŒ|‘Œ }}|D �cg c]	  }||v sŒ|‘Œ }}|D ]!  }| j                  |t        |«      ||   «       Œ# |D ]!  }| j                  |t        |«      ||   «       Œ# |D ]%  }| j                  |t        |«      ||   ||   «       Œ' y c c}w c c}w c c}w rc   )r'  r4   r"  rË   )rK   rE   r?   r@   r"   Ú
added_keysÚremoved_keysÚintersections           r   Ú_compare_dictszDiffBuilder._compare_dicts_  sÑ   € Ù%(Ó;¡S˜c¨C°sªN’c Sˆ
Ð;Ù'*Ó=¡s ¨c¸ªnš sˆÐ=Ù'*Ó9¡s ¨c°Sªjš sˆÐ9ãˆCØ×Ñ˜t¤S¨£X¨s°3©xÕ8ð  ó ˆCØ×Ñ˜T¤3 s£8¨S°©XÕ6ð ó  ˆCØ× Ñ  ¤s¨3£x°°S±¸3¸s¹8ÕDñ  ùò <ùÚ=ùÚ9s   …	B4�B4™	B9£B9­	B>·B>c                 ó6  ‡‡‡‡‡‡— 	 ‰D �cg c]  }| j                  t        |«      «      ‘Œ c}Š‰D �cg c]  }| j                  t        |«      «      ‘Œ c}Št        t        ‰«      t        ‰«      «      }d}||k  r!‰|   ‰|   k(  r|dz  }||k  r‰|   ‰|   k(  rŒd}|||z
  k  r0‰d|z
     ‰d|z
     k(  r|dz  }|||z
  k  r‰d|z
     ‰d|z
     k(  rŒt        ‰«      |z
  t        ‰«      |z
  }}ˆˆˆˆfd„Š||||f}	 ‰|	Ž }
||z
  ||z
  z  t        k  }|sHt        j                  ‰|| «      Št        ˆfd„‰|| D «       «      }|t        t        |
dz  «      kD  r|	gS t        d‰|| ‰|| | ¬«      }|j                  «       D �����cg c]  \  }}}}}|d	k7  r||z   ||z   ||z   ||z   f‘Œ! }}}}}}t        ˆfd
„|D «       «      |
kD  r|	gS |S c c}w c c}w # t        t        t        f$ r dt        ‰«      dt        ‰«      fgcY S w xY wc c}}}}}w )a$   Returns (i1, i2, j1, j2) for each run of items src[i1:i2] that is
        replaced by dst[j1:j2], between runs of items that both lists have.

        Without matching up the items they both have, inserting an item in
        front of arrays or objects would change all of them that follow. r   r   rh   c                 ó˜   •— t        || z
  ||z
  z
  «      t        ˆˆˆˆfd„t        t        | |«      t        ||«      «      D «       «      z   S )Nc              3   ó^   •K  — | ]$  \  }}‰|   ‰|   k7  rt        ‰|   ‰|   «      –— Œ& y ­wrc   ©Ú_positional_cost)r!   r   Újr@   Údst_keysr?   Úsrc_keyss      €€€€r   r$   z<DiffBuilder._differing_runs.<locals>.cost.<locals>.<genexpr>‰  s<   øè ø€ ð 4/á=‘D�A�qØ˜A‘; (¨1¡+Ò-ô !  Q¡¨¨Q©×0Ù=ùs   ƒ*-)ÚabsÚsumÚzipÚrange)Úi1Úi2Új1Új2r@   r5  r?   r6  s       €€€€r   Úcostz)DiffBuilder._differing_runs.<locals>.costˆ  sI   ø€ Ü˜˜R™ B¨¡GÑ,Ó-´ö 4/ä¤ b¨"£¬u°R¸«}Ô=ó4/ó 1/ñ /ð /r   c              3   ó(   •K  — | ]	  }‰|   –— Œ y ­wrc   r   )r!   r"   Úcountss     €r   r$   z.DiffBuilder._differing_runs.<locals>.<genexpr>œ  s   øè ø€ ÐMÑ5L¨c˜f S�kÑ5Lùó   ƒrú   N)ÚautojunkÚequalc              3   ó(   •K  — | ]	  } ‰|Ž –— Œ y ­wrc   r   )r!   Úrunr?  s     €r   r$   z.DiffBuilder._differing_runs.<locals>.<genexpr>ª  s   øè ø€ Ð*¡T˜c‰t�SŒz¡TùrB  )rÎ   rå   rI   rs   ræ   r    ÚminÚ_EXACT_MATCH_LIMITr%   ÚCounterr8  Úmaxr   Úget_opcodes)rK   r?   r@   r  ÚshorterÚstartÚ
common_endÚsrc_endÚdst_endÚby_positionÚposition_costÚexactÚcomparisonsÚmatcherÚtagr;  r<  r=  r>  Úrunsr?  rA  r5  r6  s    ``                 @@@@r   Ú_differing_runszDiffBuilder._differing_runsm  s}  ý€ ð	0ñ GJÓJÁc¸d˜Ÿ
™
¤?°4Ó#8Õ9ÀcÑJˆHÙFIÓJÁc¸d˜Ÿ
™
¤?°4Ó#8Õ9ÀcÑJˆHô ”c˜#“h¤ C£Ó)ˆØˆØ�gŠo (¨5¡/°X¸e±_Ò"DØ�Q‰JˆEð �gŠo (¨5¡/°X¸e±_Ó"Dàˆ
Ø˜7 U™?Ò*Ø˜˜j™Ñ)¨X°b¸:±oÑ-FÒFØ˜!‰OˆJð ˜7 U™?Ò*Ø˜˜j™Ñ)¨X°b¸:±oÑ-FÓFä˜s›8 jÑ0´#°c³(¸ZÑ2G�ˆ÷	/ð ˜g u¨gÐ6ˆÙ˜kÐ*ˆð
 ˜5‘ W¨u¡_Ñ5Ô9KÑKˆÙô !×(Ñ(¨°%¸Ð)@ÓAˆFÜÓM°X¸eÀGÑ5LÓMÓMˆKØœSÔ!3°]ÀaÑ5GÓHÒHØ#�}Ð$ä! $¨°°wÐ(?Ø"*¨5°Ð"9ÈÀIôOˆð ,3×+>Ñ+>Ô+@÷#Ù+@Ñ'�C˜˜R  RØ˜'’>ð ˜‘˜U R™Z¨°©°U¸R±ZÒ@Ø+@ð 	ô #ô Ó*¡TÓ*Ó*¨]Ò:Ø�=Ð àˆùòo KùÚJøÜœ:¤~Ð6ò 	0àœ˜C› !¤S¨£XÐ.Ð/Ò/ð	0üöT#s2   ˆG Œ!G­G ´!GÁG Æ$HÇ
G Ç-HÈHc                 óÒ  — | j                  ||«      D �]Q  \  }}}}t        ||z
  ||z
  «      }t        |||z   «      D ]Ø  }	|||	z   |z
     ||	   }}
t        |
t        «      r.t        |t        «      r| j                  t        ||	«      |
|«       ŒQt        |
t        «      r.t        |t        «      r| j                  t        ||	«      |
|«       Œ�| j                  |
«      | j                  |«      k(  rŒ³| j                  ||	|
«       | j                  ||	|«       ŒÚ |||z   | D ]  }
| j                  |||z   |
«       Œ t        ||z   |«      D ]  }	| j                  ||	||	   «       Œ �ŒT y rc   )rX  rG  r:  r3   r   r.  r  r   Ú_compare_listsrÎ   r'  r"  )rK   rE   r?   r@   r;  r<  r=  r>  Úpairedr"   ÚoldÚnews               r   rZ  zDiffBuilder._compare_lists¯  s]  € ð #×2Ñ2°3¸×<‰NˆB��B˜Ü˜˜b™ " r¡'Ó*ˆFÜ˜R  f¡Ö-�Ø˜r C™x¨"™}Ñ-¨s°3©x�S�Ü˜c¤>Ô2Ü" 3¬Ô7Ø×'Ñ'¬
°4¸Ó(=¸sÀCÕHä ¤_Ô5Ü" 3¬Ô8Ø×'Ñ'¬
°4¸Ó(=¸sÀCÕHð
 —Z‘Z “_¨¯
©
°3«Ò7Øð ×&Ñ& t¨S°#Ô6Ø×$Ñ$ T¨3°Õ4ð% .ð( ˜2 ™; rÓ*�Ø×"Ñ" 4¨¨f©°cÕ:ð +ô ˜R &™[¨"Ö-�Ø× Ñ   s¨C°©HÕ5ò .ñ3 =r   c                 ój  — t        |t        «      r.t        |t        «      r| j                  t        ||«      ||«       y t        |t        «      r.t        |t        «      r| j                  t        ||«      ||«       y | j                  |«      | j                  |«      k(  ry | j                  |||«       y rc   )r3   r   r.  r  r   rZ  rÎ   r)  )rK   rE   r"   r?   r@   s        r   rË   zDiffBuilder._compare_valuesÎ  s�   € Ü�cœ>Ô*Ü˜3¤Ô/Ø×Ñ¤
¨4°Ó 5°s¸CÕ@ä˜œ_Ô-Ü˜3¤Ô0Ø×Ñ¤
¨4°Ó 5°s¸CÕ@ð �Z‰Z˜‹_ §
¡
¨3£Ò/Øð ×Ñ  c¨3Õ/r   N)r   r   r   rØ   rÎ   r	   rL   rè   rí   rñ   r�   r”   r½   rÌ   rþ   r
  r  r  r  r  r"  r'  r)  r.  rX  rZ  rË   r   r   r   rÊ   rÊ   Ÿ  sx   „ à/3¯z©zÀ{ó 	%ò	òDò ò
òòòò0ò*òò)ò+ò(ò3ò.6ò0òEò@òD6ó>0r   rÊ   c                 ób  ‡ ‡— ‰ ‰k(  ryt        ‰ t        «      r:t        ‰t        «      r*t        ˆˆ fd„‰ D «       «      t        ˆ fd„‰D «       «      z   S t        ‰ t        «      rMt        ‰t        «      r=t	        t        ‰ «      t        ‰«      z
  «      t        d„ t        ‰ ‰«      D «       «      z   S y)zh Estimates how many operations change old into new, if the items of
    arrays are compared by position r   c              3   óN   •K  — | ]  }|‰v rt        ‰|   ‰|   «      nd –— Œ y­w)r   Nr2  )r!   r"   r]  r\  s     €€r   r$   z#_positional_cost.<locals>.<genexpr>ë  s4   øè ø€ ð #Ù!�sð <?À#¹:Ô# C¨¡H¨c°#©hÔ7È1ÓLÙ!ùó   ƒ"%c              3   ó&   •K  — | ]  }|‰v–— Œ
 y ­wrc   r   )r!   r"   r\  s     €r   r$   z#_positional_cost.<locals>.<genexpr>ì  s   øè ø€ Ð(GÁ3¸C¨°C¬Á3ùs   ƒc              3   ó,   K  — | ]  }t        |Ž –— Œ y ­wrc   r2  ©r!   r*   s     r   r$   z#_positional_cost.<locals>.<genexpr>î  s   è ø€ ð .AÙ2?¨Ô˜eÔ$±-ùó   ‚r   )r3   r   r8  r   r7  r    r9  )r\  r]  s   ``r   r3  r3  å  s¥   ù€ ð ˆc‚zØÜ�#”~Ô&¬:°c¼>Ô+JÜô #Ù!ó#ó #Ü%(Ó(GÁ3Ó(GÓ%GñHð 	Hä�#”Ô'¬J°s¼OÔ,LÜ”3�s“8œc #›hÑ&Ó'¬#ñ .AÜ25°c¸3´-ó.Aó +Añ Að 	Aàr   c                 óè  ‡ ‡— t        ‰ t        «      st        ‰t        «      r)t        ‰ t        «      xr t        ‰t        «      xr ‰ ‰k(  S t        ‰ t        «      r>t        ‰t        «      r.t        ‰ «      t        ‰«      k(  xr t	        ˆ ˆfd„‰ D «       «      S t        ‰ t
        «      rEt        ‰t
        «      r5t        ‰ «      t        ‰«      k(  xr t	        d„ t        ‰ ‰«      D «       «      S ‰ ‰k(  S )z¿ Compares values the way RFC 6902, 4.6 does: numbers by value, but
    literals like true only with themselves, which Python considers equal to
    1, and arrays and objects member by member c              3   óN   •K  — | ]  }|‰v xr t        ‰|   ‰|   «      –— Œ y ­wrc   ©r^   )r!   r"   ÚfirstÚseconds     €€r   r$   z_json_equal.<locals>.<genexpr>ü  s4   øè ø€ ð 1á�ð �6ˆMÒBœk¨%°©*°f¸S±kÓBÓBÙùra  c              3   ó,   K  — | ]  }t        |Ž –— Œ y ­wrc   rh  rd  s     r   r$   z_json_equal.<locals>.<genexpr>  s   è ø€ ð 1AÙ-? EŒK˜ÔÑ-?ùre  )r3   r¸   r   r    Úallr   r9  )ri  rj  s   ``r   r^   r^   ó  sÝ   ù€ ô �%œÔ¤*¨V´TÔ":Ü˜%¤Ó&ò ¬:°f¼dÓ+Cò Ø�V‰Oð	ä�%œÔ(Ü�vœ~Ô.Ü�5‹zœS ›[Ñ(ò ¬Sô 1áó1ó .ð 	ô �%œÔ)Ü�vœÔ/Ü�5‹zœS ›[Ñ(ò A¬Sñ 1AÜ-0°¸Ô-?ó1Aó .Að 	Aà�F‰?Ðr   c                 ó  — | �t        | t        t        t        f«      r| S t        | t        «      r&t        | «      D �ci c]  }|t        | |   «      “Œ c}S t        | t        «      r| D �cg c]  }t        |«      ‘Œ c}S | S c c}w c c}w )zW Copies the arrays and objects in value, with the members of objects
    sorted by key )r3   r4   rr   Úfloatr   Úsortedrå   r   )r-   r"   r  s      r   rå   rå     s�   € ð €}œ
 5¬3´´UÐ*;Ô<ØˆÜ�%œÔ(Ü<BÀ5¼MÓJ¹M°S�”_ U¨3¡ZÓ0Ñ0¸MÑJÐJÜ�%œÔ)Ù27Ó8±%¨$” Õ%°%Ñ8Ð8Ø€Lùò Kùâ8s   ½BÁ*Bc                   ó    — e Zd ZdZdZd„ Zd„ Zy)r  z5 An item that an array has at some point of the diff ©r  ÚlabelÚinitialc                 ó.   — || _         || _        || _        y rc   rq  )rK   r  rr  rs  s       r   rL   z_ArrayItem.__init__  s   € ØˆŒ
ØˆŒ
àˆ�r   c                 ój   — t        j                  | j                  j                  | j                  «      S )z_ The index of the item in the array, or the index it would have if
        it was in the array )ÚbisectÚbisect_leftr  Úpresent_labelsrr  rZ   s    r   rt   z_ArrayItem.index%  s%   € ô ×!Ñ! $§*¡*×";Ñ";¸T¿Z¹ZÓHÐHr   N)r   r   r   r   Ú	__slots__rL   rt   r   r   r   r  r    s   „ Ù?à-€IòóIr   r  c                   óB   — e Zd ZdZdZdZd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zy)r	  aÖ   All items that an array has at some point of the diff, and the items
    that it has at the moment, both ordered by their labels.

    The array has its items in this order at every point of the diff, also
    when a move later replaces the 'add' or 'remove' of an item. So an item
    inserted at an index is put directly after the item before it in the
    array: inserting at the index of a removed item inserts before it, if a
    move replaces its 'remove' later. i   l        c                 ó<   — g | _         g | _        g | _        g | _        y rc   )r*   Úlabelsr  rx  rZ   s    r   rL   z_ArrayItems.__init__:  s   € ØˆŒ
ØˆŒØˆŒØ ˆÕr   c                 óÈ  — t        | j                  «      |k  r¼| j                  r| j                  d   | j                  z   nd}t	        | |d«      }| j
                  j                  |«       | j                  j                  |«       | j                  j                  |«       | j                  j                  |«       t        | j                  «      |k  rŒ¼| j                  |   S )z  The item at index of the array rh   r   T)r    r  r|  Úgapr  r*   r(   rx  )rK   rt   rr  r  s       r   r  z_ArrayItems.at@  s¯   € ô �$—,‘,Ó 5Ò(Ø26·+²+�D—K‘K ‘O d§h¡hÒ.À1ˆEÜ˜d E¨4Ó0ˆDØ�J‰J×Ñ˜dÔ#Ø�K‰K×Ñ˜uÔ%Ø�L‰L×Ñ Ô%Ø×Ñ×&Ñ& uÔ-ô �$—,‘,Ó 5Ó(ð �|‰|˜EÑ"Ð"r   c                 óò  — d}|r<t        j                  | j                  | j                  |dz
  «      j                  «      }|dk(  s|t        | j                  «      k(  rN| j                  sd}n´|dk(  r| j                  d   | j                  z
  }n’| j                  d   | j                  z   }nu| j                  |   | j                  |dz
     z
  dk  r| j                  «        | j                  |dz
     | j                  |   }}|t        | j                  ||z
  dz  «      z   }t        | |d«      }| j                  j                  ||«       | j                  j                  ||«       | j                  |«       |S )z: Inserts a new item at index of the array, and returns it r   r   rh   rú   F)rv  Úbisect_rightr|  r  rr  r    r~  Ú_relabelrG  Ústepr  r*   r�   r–   )rK   rt   Úpositionrr  ÚlowÚhighr  s          r   r�   z_ArrayItems.insertN  s@  € àˆÙÜ×*Ñ*¨4¯;©;Ø+/¯7©7°5¸1±9Ó+=×+CÑ+CóEˆHð �qŠ=˜H¬¨D¯K©KÓ(8Ò8Ø—;’;Ø‘Ø˜Q’ØŸ™ A™¨¯©Ñ1‘àŸ™ B™¨$¯(©(Ñ2‘ð �{‰{˜8Ñ$ t§{¡{°8¸a±<Ñ'@Ñ@À1ÒDØ—‘”ØŸ™ H¨q¡LÑ1°4·;±;¸xÑ3H�ˆCØœ#˜dŸi™i¨$°©*¸Ñ):Ó;Ñ;ˆEä˜$  uÓ-ˆØ�
‰
×Ñ˜( DÔ)Ø�‰×Ñ˜8 UÔ+Ø�‰�ŒØˆr   c                 óD  — t        t        | j                  «      «      D �cg c]  }|| j                  z  ‘Œ c}| _        t        | j                  | j                  «      D ]  \  }}||_        Œ | j                  D �cg c]  }|j                  ‘Œ c}| _        y c c}w c c}w rc   )	r:  r    r*   r~  r|  r9  rr  r  rx  )rK   r   r  rr  s       r   r�  z_ArrayItems._relabeli  s~   € Ü-2´3°t·z±z³?Ô-CÓDÑ-C¨�q˜4Ÿ8™8“|Ð-CÑDˆŒÜ˜tŸz™z¨4¯;©;Ö7‰KˆD�%ØˆD�Jð 8à6:·l²lÓC±l¨d˜tŸz›z°lÑCˆÕùò Eùò Ds   ¡BÁ<Bc                 óÜ   — t        j                  | j                  |j                  «      }| j                  j                  ||«       | j                  j                  ||j                  «       y)z Adds item to the array N)rv  rw  rx  rr  r  r�   ©rK   r  rƒ  s      r   r–   z_ArrayItems.addo  sL   € ä×%Ñ% d×&9Ñ&9¸4¿:¹:ÓFˆØ�‰×Ñ˜H dÔ+Ø×Ñ×"Ñ" 8¨T¯Z©ZÕ8r   c                 óŒ   — t        j                  | j                  |j                  «      }| j                  |= | j                  |= y)z Removes item from the array N)rv  rw  rx  rr  r  rˆ  s      r   r”   z_ArrayItems.removeu  s8   € ä×%Ñ% d×&9Ñ&9¸4¿:¹:ÓFˆØ�L‰L˜Ð"Ø×Ñ Ñ)r   c                 óÂ   — | j                   D �cg c]  }|j                  sŒ|‘Œ c}| _        | j                  D �cg c]  }|j                  ‘Œ c}| _        yc c}w c c}w )z< Changes the array back to its items in the source document N)r*   rs  r  rr  rx  )rK   r  s     r   r  z_ArrayItems.reset{  sJ   € à)-¯ªÓD© °t·|³|š¨ÑDˆŒØ6:·l²lÓC±l¨d˜tŸz›z°lÑCˆÕùò EùÚCs   �A¡A»AN)r   r   r   r   r‚  r~  rL   r  r�   r�  r–   r”   r  r   r   r   r	  r	  +  s8   „ ñ*ð €Dà
€Cò!ò#òò6Dò9ò*óDr   r	  c                 ó   — |€| S | |fz   S rc   r   )rE   r"   s     r   r  r  �  s   € Ø
€{Øˆà�3�&‰=Ðr   c                 ó2   — dj                  d„ | D «       «      S )NÚ c              3   óx   K  — | ]2  }d t        |«      j                  dd«      j                  d d«      z   –— Œ4 y­w)rg   Ú~z~0z~1N)r4   r¯   r  s     r   r$   z_to_pointer.<locals>.<genexpr>‰  s;   è ø€ ð %Ù#�tð œ˜T›×*Ñ*¨3°Ó5×=Ñ=¸cÀ4ÓHÕHÙ#ùs   ‚8:)ri   )rE   s    r   rÿ   rÿ   ˆ  s    € Ø�7‰7ñ %Ù#ó%ó %ð %r   c                 ó$   — | |d t        | «       k(  S rc   r   )Ú	sub_partsrj   s     r   Ú
_is_prefixr’  �  s   € Ø˜˜oœs 9›~Ð.Ñ.Ð.r   c                 óL   — t        | «      t        |«      kD  xr t        || «      S rc   )r    r’  )rj   Ú	containers     r   r  r  ‘  s!   € Üˆu‹:œ˜I›Ñ&ÒG¬:°iÀÓ+GÐGr   c                 ó2   — | d | | |   |z   fz   | |dz   d  z   S )Nr   r   )rj   ÚdepthÚoffsets      r   Ú_shiftr˜  •  s/   € Ø��%ˆ=˜E %™L¨6Ñ1Ð3Ñ3°e¸EÀA¹I¸JÐ6GÑGÐGr   c                 ó–   — t        |«      dz
  }t        |d   t        «      r't        | |dd «      r| |   |d   kD  rt	        | |d«      S | S )zY Changes parts, which assumes that there is an item at location, to
    the item missing r   rh   N)r    r3   rr   r  r˜  )rj   rG   r–  s      r   r$  r$  ™  sS   € ô �‹M˜AÑ€EÜ�(˜2‘,¤Ô$¬°E¸8ÀCÀR¸=Ô)IØ�e‘˜x¨™|Ò+Ü�e˜U BÓ'Ð'à€Lr   c                 ó�   — | j                  |«      \  }}|dk(  r*t        |t        «      rt        dj	                  |«      «      ‚||fS )z£Resolve pointer like JsonPointer.to_last, for a location that has to
    exist.

    The '-' of an array refers to the nonexistent element after its last one.
    r‹   r{   )r|   r3   r   r
   r}   )rH   r9   r   r€   s       r   r˜   r˜   ¤  sG   € ð —?‘? 3Ó'�L€FˆDàˆs‚{”z &¬(Ô3Ü"Ð#>×#EÑ#EÀdÓ#KÓLÐLà�4ˆ<Ðr   );r   rv  r%   rˆ   Ú	functoolsrØ   Úcollections.abcr   r   r   r   Údifflibr   Útypesr   Újsonpointerr	   r
   r  r  rH  Ú
__author__Ú__version__Ú__website__Ú__license__Ú	Exceptionr   r   r   ÚAssertionErrorr   r.   ÚpartialrÇ   rÙ   r<   rA   ÚobjectrC   ry   r„   r�   r’   r¦   r¬   r6   rÊ   r3  r^   rå   r  r	  r  rÿ   r’  r  r˜  r$  r˜   r   r   r   Ú<module>r¨     sŠ  ðñB &ã Û Û Û Û ß NÓ NÝ #Ý "ç 9ð €Ø€
ð Ð ð 0€
Ø€Ø@€Ø€ô$˜ô $ô7Ð)ô 7ôÐ*ô ô$Ð,¨nô $òð  ˆY×Ñ˜tŸz™z¸YÔG€
ð &+¸ó %&ðP &1ó Bô4M/�Vô M/ô`�nô ô*#�>ô #ôL#�~ô #ôL?/�Nô ?/ôD�Nô ô6�Nô ô*Q<�ô Q<ôhC0�&ô C0òL
òò&
ô(I�ô Iô"SD�&ô SDòlò%ò
/òHòHòór   