
    `E                         d dl Z d dlZd dlZd dlZddlmZ ej        d          dk     reefZ	eZnefZ	e
Z	 	 	 ddZ	 	 	 ddZd Zd	 Z	 	 	 	 	 ddZ	 	 	 	 ddZd Zd Zd Zd Zd Zd Zd Zd Zdad Zd ZdS )    N   )Parser   Tc	                 Z    |                                  }	t          |	||||||||	  	        S )a  Deserialize ``fp`` (a ``.read()``-supporting file-like object
    containing a JSON document) to a Python object.

    Supports almost the same arguments as ``json.load()`` except that:
        - the `cls` keyword is ignored.
        - an extra `allow_duplicate_keys` parameter supports checking for
          duplicate keys in a object; by default, this is True for
          compatibility with ``json.load()``, but if set to False and
          the object contains duplicate keys, a ValueError will be raised.
    )encodingclsobject_hookparse_float	parse_intparse_constantobject_pairs_hookallow_duplicate_keys)readloads)
fpr   r   r	   r
   r   r   r   r   ss
             )lib/python3.11/site-packages/json5/lib.pyloadr      s>     			AX3K(I .#4&:	< < < <    c	                    |
J d            t           j        d         dk     rt          d          }	nt          d          }	t          | |	          r|pd}|                     |          } | st          d          t          | d	          }
|
                                \  }}}|rt          |          d
 }|r|}nrfd}nd }|s|fd}|pt          }|pt          }|p|}t          |||||          S )a  Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a
    JSON5 document) to a Python object.

    Supports the same arguments as ``json.load()`` except that:
        - the `cls` keyword is ignored.
        - an extra `allow_duplicate_keys` parameter supports checking for
          duplicate keys in a object; by default, this is True for
          compatibility with ``json.load()``, but if set to False and
          the object contains duplicate keys, a ValueError will be raised.
    Nz!Custom decoders are not supportedr   r    r   zutf-8z!Empty strings are not legal JSON5z<string>c                 p    t          |                     dd                              dd                    S )NInfinityinfNaNnan)floatreplace)r   s    r   _fp_constant_parserz"loads.<locals>._fp_constant_parserT   s.    QYYz51199%GGHHHr   c                 4     t          |                     S Ndict)pairsr	   s    r   <lambda>zloads.<locals>.<lambda>Z   s    DKK 8 8 r   c                      t          |           S r!   r"   )r$   s    r   r%   zloads.<locals>.<lambda>\   s    U r   c                 $    t          |           S r!   )_reject_duplicate_keys)r$   _orig_dictifys    r   r%   zloads.<locals>.<lambda>`   s     6um L L r   )sysversion_infotype
isinstancedecode
ValueErrorr   parser   int	_walk_ast)r   r   r   r	   r
   r   r   r   r   decodable_typeparserasterr_r   dictifyr)   s      `            @r   r   r   5   sO    ;;;;;;
Qbc!^$$ &wHHX ><===Az""F,,..KCa
 ooI I I  ,#	 ,8888++ MLLLL&K SI#:':NS';	>JJJr   c                     t                      }| D ].\  }}||v rt          d|          |                    |           / ||           S )Nz"Duplicate key "%s" found in object)setr/   add)r$   r8   keyskeyr7   s        r   r(   r(   i   sW    55D  Q$;;A3GGG75>>r   c                    | dk    rd S | dk    rdS | dk    rdS | \  }}|dk    rl|                     d          s|                     d          r |d	
          S d|v sd|v sd|v r |          S d|v sd|v r |          S  |          S |dk    r|S |dk    r?g }|D ]/\  }}	t          |	          }
|                    ||
f           0 |          S |dk    rfd|D             S t          d| z             )NNoneTrueTFalseFnumber0x0X   )base.eEr   r   stringobjectarrayc           	      6    g | ]}t          |          S  )r2   ).0elr8   r   r
   r   s     r   
<listcomp>z_walk_ast.<locals>.<listcomp>   s9        "g{I~NN   r   zunknown el: )
startswithr2   append	Exception)rP   r8   r
   r   r   tyvr$   r=   val_exprvals    ````      r   r2   r2   q   s   	V||t	V||t	W}}uEB	X~~<< 	 d!3!3 	 9QR((((AXXSAXX;q>>!1__

!>!$$$9Q<<	X~~	X~~ 	% 	%MCHg{I*, ,CLL#s$$$$wu~~	W}}         	
NR'
(
((r   Fc                 ~    |                     t          t          | ||||||||	|
|||                               dS )aQ  Serialize ``obj`` to a JSON5-formatted stream to ``fp`` (a ``.write()``-
    supporting file-like object).

    Supports the same arguments as ``json.dumps()``, except that:

    - The ``cls`` keyword is not supported.
    - The ``encoding`` keyword is ignored; Unicode strings are always written.
    - By default, object keys that are legal identifiers are not quoted;
      if you pass quote_keys=True, they will be.
    - By default, if lists and objects span multiple lines of output (i.e.,
      when ``indent`` >=0), the last item will have a trailing comma
      after it. If you pass ``trailing_commas=False, it will not.
    - If you use a number, a boolean, or None as a key value in a dict,
      it will be converted to the corresponding json string value, e.g.
      "1", "true", or "null". By default, dump() will match the `json`
      modules behavior and produce ill-formed JSON if you mix keys of
      different types that have the same converted value, e.g.:
      {1: "foo", "1": "bar"} produces '{"1": "foo", "1": "bar"}', an
      object with duplicated keys. If you pass allow_duplicate_keys=False,
      an exception will be raised instead.

    Calling ``dumps(obj, fp, quote_keys=True, trailing_commas=False,
                    allow_duplicate_keys=True)``
    should produce exactly the same output as ``json.dumps(obj, fp).``
    )objskipkeysensure_asciicheck_circular	allow_nanr   indent
separatorsdefault	sort_keys
quote_keystrailing_commasr   N)writestrdumps)rZ   r   r[   r\   r]   r^   r   r_   r`   ra   rb   rc   rd   r   kwargss                  r   dumpri      sk    @ HHS3&4	v*&)",o,@B B B C C D D D D Dr   c                     |                     dd          
J d            ||d}nd}|pt          }|rt                      }nd}d}d}t          | ||||||||	|
|||||          \  }}|S )a  Serialize ``obj`` to a JSON5-formatted ``str``.

    Supports the same arguments as ``json.dumps()``, except that:

    - The ``cls`` keyword is not supported.
    - The ``encoding`` keyword is ignored; Unicode strings are always returned.
    - By default, object keys that are legal identifiers are not quoted;
      if you pass quote_keys=True, they will be.
    - By default, if lists and objects span multiple lines of output (i.e.,
      when ``indent`` >=0), the last item will have a trailing comma
      after it. If you pass ``trailing_commas=False, it will not.
    - If you use a number, a boolean, or None as a key value in a dict,
      it will be converted to the corresponding json string value, e.g.
      "1", "true", or "null". By default, dump() will match the ``json``
      module's behavior and produce ill-formed JSON if you mix keys of
      different types that have the same converted value, e.g.:
      {1: "foo", "1": "bar"} produces '{"1": "foo", "1": "bar"}', an
      object with duplicated keys. If you pass ``allow_duplicate_keys=False``,
      an exception will be raised instead.


    Calling ``dumps(obj, quote_keys=True, trailing_commas=False,
                    allow_duplicate_keys=True)``
    should produce exactly the same output as ``json.dumps(obj).``
    r   Nz!Custom encoders are not supported)z, : ),rk   r   F)get_raise_type_errorr:   _dumps)rZ   r[   r\   r]   r^   r   r_   r`   ra   rb   rc   rd   r   rh   seenlevelis_keyr7   rV   s                      r   rg   rg      s    > ::eT""**,O***>'JJ&J**G uuEF#x~VZ)o/Cv' 'DAq Hr   c                 n   | du rd}n| du rd}n| d}nt          | t                    r8|r$t          |           r|	st          |           sd| fS dt	          | |          fS t          | t
                    rt          | |          }n't          | t                    rt          |           }nd }|r,|dd|z  fS |rdS t          dt          |           z            |d|fS |`d	}|
rd
}t          |          t          k    r+|dk    rdd|z  |z  z   }|dd|z  |dz
  z  z   z  }n#d}|dz  }nd||z  z   }|d||dz
  z  z   z  }nd	}d	}|\  }}||z  }|dz  }|7t          |           }||v rt          d          |                    |           t          | d          r1t          | d          r!t!          | |||||||||	|
|||||||          }nKt          | d          r0t          | d          r t#          | |||||||||	|
||||||          }n ||           }||                    |           d|fS )NTtrueFfalsenullz"%s")FNinvalid key %sr   rl   r   
 r   zCircular reference detected.r<   __getitem____iter__)r-   	str_types	_is_ident_is_reserved_word	_dump_strr   _dump_floatr1   rf   	TypeErrorreprr,   idr/   r;   hasattr
_dump_dict_dump_arrayremove)rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   r   rp   rq   rr   r   end_str
indent_stritem_sepkv_sepis                        r   ro   ro      s    d{{			C	#	# 
 	y~~ 	j 	%c**	9YsL1111	C		 I&&	C		 HH 6=!## 	;(4994555}Qw 	G<<3zz!C&L5$88
4#,%!)"<<<!
4.Jtf	222GG
!Hf
H	QJEsGG99;<<<HHQKKK sF ] ; ; sHl%y&!7I!?+T5W> > 
m	$	$ j)A)A X|&	6"GY"O,dE *g7 7 GCLLA!8Or   c                 >   | sdS |r"t          |                                           }n|                                 }d|z   }d}t                      }|D ]}t          ||||||||||	|
|||d          \  }}|rz|s8||v rt	          dt          |          z            |                    |           |r||z  }|||z   t          | |         |||||||||	|
|||d          d         z   z  }|dz  }|st          d	t          |          z            ||d
z   z  }|S )Nz{}{r   T)rr   zduplicate key %sFr   rw   })sortedr<   r:   ro   r/   r   r;   r   )rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   r   rp   rq   r   r   r   r   r<   r   num_items_addednew_keysr=   	valid_keykey_strs                            r   r   r   F  s     u chhjj!!xxzzzAOuuH : :#C<$-vz7$-$.$8$(%> > >	7  	:' *h&&$%7$s))%CDDDLL))) X6!F3s8X|+99f+5w	+5+?+/u%F %F %F
 GH%I I IA q OO 	:,tCyy8999	: 4AHr   c                    	
 | sdS d|z   |                     	
fd| D                       z   |z   dz   S )Nz[][c                 V    g | ]%}t          |	
d           d         &S )Fr   )ro   )rO   rP   r   r^   r]   ra   r\   r_   rq   rc   rp   r`   r[   rb   rd   s     r   rQ   z_dump_array.<locals>.<listcomp>z  sh     H H H >@	 ""hn"+VZ"+Z"6"&u	6 6 78	9 H H Hr   ])join)rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   r   rp   rq   r   r   r   s    `````````````   r   r   r   s  s      u:MM H H H H H H H H H H H H H H H H DG	H H H I II   r   c                 8   |rAt          j        |           rdS | t          d          k    rdS | t          d          k    rdS nIt          j        |           s&| t          d          k    s| t          d          k    rt          d          t	          |           S )Nr   r   r   z-infz	-Infinityz0Out of range float values are not JSON compliant)mathisnanr   r/   rf   )rZ   r^   s     r   r   r     s     	3:c?? 	5%,,:%--;  	C 3C5<<//3%--3G3G 2 3 3 	3s88Or   c                    dg}| D ]}|dk    r|                     d           |dk    r|                     d           ;|dk    r|                     d           W|dk    r|                     d           s|d	k    r|                     d
           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           |dk    r|                     d           9|s|                     |           Rt          |          }|dk    r|dk     r|                     |           |dk     r|                     dd|z  z              |dz
  }d|dz	  z   }d|dz  z   }|                     d ||fz             d!                    |          dz   S )"N"\z\\z\"u    z\u2028u    z\u2029rx   z\nz\rz\bz\f	z\tz\v z\0       i   z\uz%04xi   
   i   i  z\u%04x\u%04xr   )rS   ordr   )rZ   r\   retchorX   highlows           r   r   r     s(   %C #; #;::JJv3YYJJu9__JJy!!!!9__JJy!!!!4ZZJJu4ZZJJu4ZZJJu4ZZJJu4ZZJJu4ZZJJu4ZZJJu 	;JJrNNNNBABww1s77

2U

56A:-....'k+e,

+tSk9::::88C==3r   c                     t          |           } | rt          | d                   s| d         dvrdS | dd          D ]}t          |          s|dvr dS dS )Nr   )$r7   Fr   T)rf   _is_id_start_is_id_continue)kr   s     r   r}   r}     sy    AA L1&& 1Q4|+C+Cue  r"" 	r'='=554r   c                 .    t          j        |           dv S )N)LuLlLiLtLmLoNlunicodedatacategoryr   s    r   r   r     s    ## (2 2 2r   c                 .    t          j        |           dv S )N)r   r   r   r   r   r   r   NdMnMcPcr   r   s    r   r   r     s"    ## (J J Jr   c                     t           /t          j        dd                    g d          z   dz             a t                               |           d uS )N(|)$breakcasecatchclassconstcontinuedebuggerra   deletedoelseenumexportextendsru   finallyforfunctionifimportin
instanceofnewrv   returnsuperswitchthisthrowrt   trytypeofvarvoidwhilewithz)$)_reserved_word_rerecompiler   match)r   s    r   r~   r~     sj      JsSXX %7
 %7
 %7
 %. %. %(J K%( % %L ""1%%T11r   c                 @    t          dt          |           z            )Nz%s is not JSON5 serializable)r   r   )rZ   s    r   rn   rn     s    
2T#YY>
?
??r   )NNNNNNNT)FTTTNNNNFFTT)r   r   r*   r   r4   r   r+   rf   unicoder|   r1   longr   r   r(   r2   ri   rg   ro   r   r   r   r   r}   r   r   r   r~   rn   rN   r   r   <module>r      s    				 



           AgI
CCID EI@D"< < < <, EIAE#1K 1K 1K 1Kh  ) ) )@ EI;?!&+/"	%D %D %D %DP BF<@"'GK5 5 5 5pR R Rj* * *Z    & & &R  2 2 2
J J J
  +2 +2 +2\@ @ @ @ @r   