+
    xȇi}P                    P   ^ RI Ht ^ RIHtHt ^ RIt^ RIHtHtH	t	H
t
 ^ RIt^ RIHt ^ RIHt ^ RIt^ RIHtHt ]'       d   ^ RIHt ^ R	IHtHt R
 R lt]
RR R ll4       t]
RR R ll4       tRR R lltR R ltR R ltRR R lltR R lt]! R4      R R R ll4       t R# )!    )annotations)abcdefaultdictN)TYPE_CHECKINGAnyDefaultDictoverloadconvert_json_to_lines)
set_module)	DataFrameSeries)Iterable)IgnoreRaiseScalarc                    V ^8  d   QhRRRR/# )   sstrreturn )formats   "i/Users/max/.openclaw/workspace/postharvest/venv/lib/python3.14/site-packages/pandas/io/json/_normalize.py__annotate__r   %   s     
$ 
$ 
$ 
$    c                ^    V ^ ,          R8X  g   V R,          R8X  d   V # V ^R p \        V 4      # )zB
Helper function that converts JSON lists to line delimited JSON.
[]r
   )r   s   &r   convert_to_line_delimitsr    %   s4     Q43;1R5C<	!BA ##r   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   dsdictprefixr   seplevelint	max_level
int | Noner   dict[str, Any]r   )r   s   "r   r   r   3   sD       
 	
  r   c                    R # Nr   r"   r$   r%   r&   r(   s   &&&&&r   nested_to_recordr.   2   s     r   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   r"   z
list[dict]r$   r   r%   r&   r'   r(   r)   r   zlist[dict[str, Any]]r   )r   s   "r   r   r   =   sD       
 	
  r   c                    R # r,   r   r-   s   &&&&&r   r.   r.   <   s     r   c               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   r"   dict | list[dict]r$   r   r%   r&   r'   r(   r)   r   z%dict[str, Any] | list[dict[str, Any]]r   )r   s   "r   r   r   F   sL     N NNN 
N 	N
 N +Nr   c                P   Rp\        V \        4      '       d   V .p Rp. pV  F  p\        P                  ! V4      pVP	                  4        F  w  r\        V	\
        4      '       g   \        V	4      p	V^ 8X  d   T	pMW,           V	,           p\        V
\        4      '       d   Ve%   W48  d   V^ 8w  d   VP                  V	4      p
WV&   K}  VP                  V	4      p
VP                  \        WW#^,           V4      4       K  	  VP                  V4       K  	  V'       d
   V^ ,          # V# )a0  
A simplified json_normalize

Converts a nested dict into a flat dict ("record"), unlike json_normalize,
it does not attempt to extract a subset of the data.

Parameters
----------
ds : dict or list of dicts
prefix: the prefix, optional, default: ""
sep : str, default '.'
    Nested records will generate names separated by sep,
    e.g., for sep='.', { 'foo' : { 'bar' : 0 } } -> foo.bar
level: int, optional, default: 0
    The number of levels in the json string.

max_level: int, optional, default: None
    The max depth to normalize.

Returns
-------
d - dict or list of dicts, matching `ds`

Examples
--------
>>> nested_to_record(
...     dict(flat1=1, dict1=dict(c=1, d=2), nested=dict(e=dict(c=1, d=2), d=2))
... )
{'flat1': 1, 'dict1.c': 1, 'dict1.d': 2, 'nested.e.c': 1, 'nested.e.d': 2, 'nested.d': 2}
FT)

isinstancer#   copydeepcopyitemsr   popupdater.   append)r"   r$   r%   r&   r(   	singletonnew_dsdnew_dkvnewkeys   &&&&&       r   r.   r.   F   s   X I"dT	Fa GGIDAa%%Fz) a&&%%*<A:		!A$%&M		!ALL)!S!)YOP- . 	e3 6 ayMr   c          
     ,    V ^8  d   QhRRRRRRRRRR/# )	r   datar   
key_stringr   normalized_dictr*   	separatorr   r   )r   s   "r   r   r      s:     & &
&& $& 	&
 &r   c                    \        V \        4      '       dL   V P                  4        F5  w  rEV V V 2pV'       g   VP                  V4      p\	        VVVVR7       K7  	  V# WV&   V# )a  
Main recursive function
Designed for the most basic use case of pd.json_normalize(data)
intended as a performance improvement, see #15621

Parameters
----------
data : Any
    Type dependent on types contained within nested Json
key_string : str
    New key (with separator(s) in) for data
normalized_dict : dict
    The new normalized/flattened Json dict
separator : str, default '.'
    Nested records will generate names separated by sep,
    e.g., for sep='.', { 'foo' : { 'bar' : 0 } } -> foo.bar
rC   rD   rE   rF   )r4   r#   r7   removeprefix_normalize_json)rC   rD   rE   rF   keyvaluenew_keys   &&&&   r   rJ   rJ      st    . $**,JC#YKu5G!..y9" /#	 '  '+
#r   c               $    V ^8  d   QhRRRRRR/# )r   rC   r*   rF   r   r   r   )r   s   "r   r   r      s!     ) ). )S )^ )r   c           
     .   V P                  4        UUu/ uF  w  r#\        V\        4      '       d   K  W#bK!  	  ppp\        V P                  4        UUu/ uF  w  r#\        V\        4      '       g   K  W#bK!  	  uppR/ VR7      p/ VCVC# u uppi u uppi )aK  
Order the top level keys and then recursively go to depth

Parameters
----------
data : dict or list of dicts
separator : str, default '.'
    Nested records will generate names separated by sep,
    e.g., for sep='.', { 'foo' : { 'bar' : 0 } } -> foo.bar

Returns
-------
dict or list of dicts, matching `normalized_json_object`
 rH   )r7   r4   r#   rJ   )rC   rF   r?   r@   	top_dict_nested_dict_s   &&    r   _normalize_json_orderedrS      s     #'**,J,$!jD6I,IJ"#zz|C|tqz!T/Bdad|C	L )i(<(( KCs   BBB
3B
c               $    V ^8  d   QhRRRRRR/# )r   r"   r2   r%   r   r   zdict | list[dict] | Anyr   )r   s   "r   r   r      s&     2" 2"2"	2" 2"r   c                    / p\        V \        4      '       d   \        WR7      pV# \        V \        4      '       d   V  Uu. uF  p\	        W1R7      NK  	  ppV# V# u upi )a1  
An optimized basic json_normalize

Converts a nested dict into a flat dict ("record"), unlike
json_normalize and nested_to_record it doesn't do anything clever.
But for the most basic use cases it enhances performance.
E.g. pd.json_normalize(data)

Parameters
----------
ds : dict or list of dicts
sep : str, default '.'
    Nested records will generate names separated by sep,
    e.g., for sep='.', { 'foo' : { 'bar' : 0 } } -> foo.bar

Returns
-------
frame : DataFrame
d - dict or list of dicts, matching `normalized_json_object`

Examples
--------
>>> _simple_json_normalize(
...     {
...         "flat1": 1,
...         "dict1": {"c": 1, "d": 2},
...         "nested": {"e": {"c": 1, "d": 2}, "d": 2},
...     }
... )
{'flat1': 1, 'dict1.c': 1, 'dict1.d': 2, 'nested.e.c': 1, 'nested.e.d': 2, 'nested.d': 2}

)rC   rF   r%   )r4   r#   rS   list_simple_json_normalize)r"   r%   normalized_json_objectrownormalized_json_lists   &&   r   rX   rX      si    V  "d!8b!P "! 
B		PRSPR 6s DPRS##!!  Ts   Ac                    V ^8  d   QhRRRR/# )r   meta"str | list[str | list[str]] | Noner   Noner   )r   s   "r   r   r     s      ;  r   c                   V f   R# \        V \        4      '       d   R# V  F  p\        V\        4      '       dG   V F>  p\        V\        4      '       d   K  \        R\	        V4      P
                   RV: 24      h	  K_  \        V\        4      '       d   Kw  \        R\	        V4      P
                   RV: 24      h	  R# )a  
Validate that meta parameter contains only strings or lists of strings.
Parameters
----------
meta : str or list of str or list of list of str or None
    The meta parameter to validate.
Raises
------
TypeError
    If meta contains elements that are not strings or lists of strings.
Nz9All elements in nested meta paths must be strings. Found z: zBAll elements in 'meta' must be strings or lists of strings. Found )r4   r   rW   	TypeErrortype__name__)r]   itemsubitems   &  r   _validate_metarf     s     |$dD!!!'3//#!!%g!7!7 87+G    D#&&d,,-Rx9  r   pandasc               <    V ^8  d   QhRRRRRRRRR	RR
RRRRRRR/	# )r   rC   zdict | list[dict] | Seriesrecord_pathzstr | list | Noner]   r^   meta_prefixz
str | Nonerecord_prefixerrorsr   r%   r   r(   r)   r   r   r   )r   s   "r   r   r   .  sm     Z Z
$Z"Z -Z 	Z
 Z Z 
Z Z Zr   c                  aaaaaaaaaaaa \        V4       RR V3R llloR V3R llo\        V \        4      '       d   V P                  pMRp\        V \        4      '       d   V '       g   \        4       # \        V \        4      '       d   V .p M\        V \        P                  4      '       de   \        V \        4      '       gO   \	        V 4      p V  F<  p	\        V	\        4      '       d   K  R\        V	4      P                   2p
\        V
4      h	  M\        hVf)   Vf%   Vf!   Sf   Sf   \        \        V SR7      VR	7      # Vfq   \        ;QJ d    R
 V  4       F  '       g   K   RM	  RM! R
 V  4       4      '       d   \!        V SSR7      p \        WR	7      pSe   VP#                  V3R lR7      pV# \        V\        4      '       g   V.pVf   . pM\        V\        4      '       g   V.pV Uu. uF  p\        V\        4      '       d   TMV.NK   	  upo. o. o\%        \        4      oS Uu. uF  pSP'                  V4      NK  	  upoRR VVVVVVVVVV3
R llloS! W/ ^ R7       \        S4      pSe   VP#                  V3R lR7      pSP)                  4        F  w  rVe	   W>,           pW9   d   \+        RV R24      h\,        P.                  ! V\0        R7      pVP2                  ^8  dA   \,        P4                  ! \7        V4      3\0        R7      p\9        V4       F  w  ppVVV&   K  	  VP;                  S4      W&   K  	  Ve   VP;                  S4      Vn        V# u upi u upi )a  
Normalize semi-structured JSON data into a flat table.

This method is designed to transform semi-structured JSON data, such as nested
dictionaries or lists, into a flat table. This is particularly useful when
handling JSON-like data structures that contain deeply nested fields.

Parameters
----------
data : dict, list of dicts, or Series of dicts
    Unserialized JSON objects.
record_path : str or list of str, default None
    Path in each object to list of records. If not passed, data will be
    assumed to be an array of records.
meta : list of paths (str or list of str), default None
    Fields to use as metadata for each record in resulting table.
meta_prefix : str, default None
    String to prefix records with dotted path, e.g. foo.bar.field if
    meta is ['foo', 'bar'].
record_prefix : str, default None
    String to prefix records with dotted path, e.g. foo.bar.field if
    path to records is ['foo', 'bar'].
errors : {'raise', 'ignore'}, default 'raise'
    Configures error handling.

    * 'ignore' : will ignore KeyError if keys listed in meta are not
      always present.
    * 'raise' : will raise KeyError if keys listed in meta are not
      always present.
sep : str, default '.'
    Nested records will generate names separated by sep.
    e.g., for sep='.', {'foo': {'bar': 0}} -> foo.bar.
max_level : int, default None
    Max number of levels(depth of dict) to normalize.
    if None, normalizes all levels.

Returns
-------
DataFrame
    The normalized data, represented as a pandas DataFrame.

See Also
--------
DataFrame : Two-dimensional, size-mutable, potentially heterogeneous tabular data.
Series : One-dimensional ndarray with axis labels (including time series).

Examples
--------
>>> data = [
...     {"id": 1, "name": {"first": "Coleen", "last": "Volk"}},
...     {"name": {"given": "Mark", "family": "Regner"}},
...     {"id": 2, "name": "Faye Raker"},
... ]
>>> pd.json_normalize(data)
    id name.first name.last name.given name.family        name
0  1.0     Coleen      Volk        NaN         NaN         NaN
1  NaN        NaN       NaN       Mark      Regner         NaN
2  2.0        NaN       NaN        NaN         NaN  Faye Raker

>>> data = [
...     {
...         "id": 1,
...         "name": "Cole Volk",
...         "fitness": {"height": 130, "weight": 60},
...     },
...     {"name": "Mark Reg", "fitness": {"height": 130, "weight": 60}},
...     {
...         "id": 2,
...         "name": "Faye Raker",
...         "fitness": {"height": 130, "weight": 60},
...     },
... ]
>>> pd.json_normalize(data, max_level=0)
    id        name                        fitness
0  1.0   Cole Volk  {'height': 130, 'weight': 60}
1  NaN    Mark Reg  {'height': 130, 'weight': 60}
2  2.0  Faye Raker  {'height': 130, 'weight': 60}

Normalizes nested data up to level 1.

>>> data = [
...     {
...         "id": 1,
...         "name": "Cole Volk",
...         "fitness": {"height": 130, "weight": 60},
...     },
...     {"name": "Mark Reg", "fitness": {"height": 130, "weight": 60}},
...     {
...         "id": 2,
...         "name": "Faye Raker",
...         "fitness": {"height": 130, "weight": 60},
...     },
... ]
>>> pd.json_normalize(data, max_level=1)
    id        name  fitness.height  fitness.weight
0  1.0   Cole Volk             130              60
1  NaN    Mark Reg             130              60
2  2.0  Faye Raker             130              60

>>> data = [
...     {
...         "id": 1,
...         "name": "Cole Volk",
...         "fitness": {"height": 130, "weight": 60},
...     },
...     {"name": "Mark Reg", "fitness": {"height": 130, "weight": 60}},
...     {
...         "id": 2,
...         "name": "Faye Raker",
...         "fitness": {"height": 130, "weight": 60},
...     },
... ]
>>> series = pd.Series(data, index=pd.Index(["a", "b", "c"]))
>>> pd.json_normalize(series)
    id        name  fitness.height  fitness.weight
a  1.0   Cole Volk             130              60
b  NaN    Mark Reg             130              60
c  2.0  Faye Raker             130              60

>>> data = [
...     {
...         "state": "Florida",
...         "shortname": "FL",
...         "info": {"governor": "Rick Scott"},
...         "counties": [
...             {"name": "Dade", "population": 12345},
...             {"name": "Broward", "population": 40000},
...             {"name": "Palm Beach", "population": 60000},
...         ],
...     },
...     {
...         "state": "Ohio",
...         "shortname": "OH",
...         "info": {"governor": "John Kasich"},
...         "counties": [
...             {"name": "Summit", "population": 1234},
...             {"name": "Cuyahoga", "population": 1337},
...         ],
...     },
... ]
>>> result = pd.json_normalize(
...     data, "counties", ["state", "shortname", ["info", "governor"]]
... )
>>> result
         name  population    state shortname info.governor
0        Dade       12345   Florida    FL    Rick Scott
1     Broward       40000   Florida    FL    Rick Scott
2  Palm Beach       60000   Florida    FL    Rick Scott
3      Summit        1234   Ohio       OH    John Kasich
4    Cuyahoga        1337   Ohio       OH    John Kasich

>>> data = {"A": [1, 2]}
>>> pd.json_normalize(data, "A", record_prefix="Prefix.")
    Prefix.0
0          1
1          2

Returns normalized data with columns prefixed with the given string.
Fc               (    V ^8  d   QhRRRRRRRR/# )	r   jsr*   spec
list | strextract_recordboolr   zScalar | Iterabler   )r   s   "r   r   $json_normalize.<locals>.__annotate__  s,      ",>B	r   c                D  < T p \        V\        4      '       d#   V F  pVf   \        V4      hW4,          pK  	  V# W1,          p V#   \         dM   pT'       d   \        RT R24      ThSR8X  d   \        P                  u Rp?# \        RT RT R24      ThRp?ii ; i)zInternal function to pull fieldNzKey zS not found. If specifying a record_path, all elements of data should have the path.ignorez) not found. To replace missing values of z% with np.nan, pass in errors='ignore')r4   rW   KeyErrornpnan)ro   rp   rr   resultfielderl   s   &&&   r   _pull_field#json_normalize.<locals>._pull_field  s     	$%%!E~&uo-#]F "(      	1# 1 2  !vv1#Fqc J6 7 	s-   A  A A B.BBBBc               $    V ^8  d   QhRRRRRR/# )r   ro   r*   rp   rq   r   rW   r   )r   s   "r   r   rt     s!      . 
 t r   c                   < S! WRR7      p\        V\        4      '       gF   \        P                  ! V4      '       d   . pV# \	        R\        V4      P                   RV: 24      hV# )z
Internal function to pull field for records, and similar to
_pull_field, but require to return list. And will raise error
if has non iterable value.
T)rr   z(Path must contain list or null, but got z at )r4   rW   pdisnullra   rb   rc   )ro   rp   rz   r}   s   && r   _pull_records%json_normalize.<locals>._pull_records  sr     Rd; &$''yy   	  #F|445T$C  r   Nz.All items in data must be of type dict, found rV   )indexc              3     "   T F2  qP                  4        Uu. uF  p\        V\        4      NK  	  upx  K4  	  R # u upi 5ir,   )valuesr4   r#   ).0yxs   &  r   	<genexpr>!json_normalize.<locals>.<genexpr>/  s-     G$QXXZ8Z
1d#Z8$8s   A<ATr%   r(   c                   < S V  2# r,   r   r   rk   s   &r   <lambda> json_normalize.<locals>.<lambda>:  s    qc5Jr   )columnsc                    V ^8  d   QhRRRR/# )r   r&   r'   r   r_   r   )r   s   "r   r   rt   M  s     % % %T %r   c           
       <
 \        V \        4      '       d   V .p \        V4      ^8  ds   V  Fj  p\        S
SRR7       F/  w  rVV^,           \        V4      8X  g   K  S! WER,          4      W&&   K1  	  S! WA^ ,          ,          VR,          W#^,           R7       Kl  	  R# V  F  pS! WA^ ,          4      pV Uu. uF)  p\        V\        4      '       d   \	        VSSR7      MTNK+  	  ppSP                  \        V4      4       \        S
SRR7       FH  w  rVV^,           \        V4      8  d
   W&,          p	MS! WEVR 4      p	SV,          P                  V	4       KJ  	  SP                  V4       K  	  R# u upi )   T)strict:r   NNr&   r   Nr   )r4   r#   lenzipr.   r:   extend)rC   path	seen_metar&   objvalrK   recsrmeta_val_metar}   r   _recursive_extractlengthsr(   	meta_keys	meta_valsrecordsr%   s   &&&&      r   r   *json_normalize.<locals>._recursive_extractM  sS   dD!!6Dt9q= #E9T BHCqyCH,)4Sb')B	 !C #3Aw<b9TUIV  $Sq'2
 "	 " "!T** %QC9E "	   s4y) #E9T BHCqy3s8+#,>#.sK#@cN))(3 !C t$# s   5/E1r   c                   < S V  2# r,   r   r   s   &r   r   r   p  s    M?1#1Fr   zConflicting metadata name z, need distinguishing prefix )dtype)F)r   )rf   r4   r   r   rW   r   r#   r   r   r   rb   rc   ra   NotImplementedErrorrX   anyr.   renamer   joinr7   
ValueErrorrx   arrayobjectndimemptyr   	enumeraterepeat)rC   ri   r]   rj   rk   rl   r%   r(   r   rd   msgrz   mr   r?   r@   r   ir   r}   r   r   r   r   r   r   s   &&&&ffff          @@@@@@@@r   json_normalizer   -  s    T 4 : ( $

$d{	D$		v	D#,,	'	'
40E0E DzDdD))!$Z0013   n$  "! 	L!/#>eLL3G$G333G$GGG $DcYGD4-$]]+J]KFT**"m|d##v8<=1*Q%%QA3.=E GG(.I*/0%3#%0I% % %< t"A6wF 'FG !"A;,QC/LM 
 !6*;;?XXs1viv6F#A,3q	 ' MM'*	% "& ||G,MI > 1s   :$M/8M4)....)rP   .r   N)r   )NNNNraiser   N)!
__future__r   collectionsr   r   r5   typingr   r   r   r	   numpyrx   pandas._libs.writersr   pandas.util._decoratorsr   rg   r   r   r   collections.abcr   pandas._typingr   r   r    r.   rJ   rS   rX   rf   r   r   r   r   <module>r      s    #    6 . 
 (
$ 
 
 
 
Nb&R)22"j> HZ Zr   