
    j/f                     T   d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	m
Z
mZ dej        fdedeeef         fdZ ed ej        d	d
                    Z G d de          Z G d de          Z G d d          Z G d d          Z e            ZdZdedefdZd Zd ZdS )a8  JSONPath implementation for Python.

This module provides a lightweight JSONPath implementation with support for:
- Standard JSONPath operators ($, @, ., .., *, [])
- Filter expressions with comparison, membership, and regex operators
- Sorter expressions for ordering results
- Field extractor expressions
- Value updates via JSONPath

Example:
    >>> from jsonpath import JSONPath, search
    >>> data = {"store": {"book": [{"price": 10}, {"price": 20}]}}
    >>> JSONPath("$..price").parse(data)
    [10, 20]
    >>> search("$.store.book[0].price", data)
    [10]
    N)OrderedDictdefaultdict)AnyCallableUnionnamelevelc                 B   t          j        |           }|j        r|S t          j        d|  dd          }t          j                    }|                    |           |                    |           |                    |           |                    |           |S )z,Get or create a logger used for local debug.z%(asctime)s-%(levelname)s-[z] %(message)sz[%Y-%m-%d %H:%M:%S])datefmt)logging	getLoggerhandlers	FormatterStreamHandlersetLevelsetFormatter
addHandler)r   r	   logger	formatterhandlers        [/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/jsonpath/jsonpath.pycreate_loggerr      s    t$$F  !"S"S"S"S]rsssI#%%GU###
OOE
gM    jsonpath
PYLOGLEVELINFOc                       e Zd ZdZdS )ExprSyntaxErrorzRaised when a JSONPath expression has invalid syntax.

    Examples of invalid syntax:
    - Using sorter on non-collection types
    - Using field-extractor on non-dict types
    N__name__
__module____qualname____doc__ r   r   r   r   2              r   r   c                       e Zd ZdZdS )JSONPathTypeErrorzRaised when type-related errors occur during JSONPath operations.

    Examples:
    - Comparing incompatible types during sorting (e.g., str vs int)
    - Sorting with missing keys that result in None comparisons
    Nr   r$   r   r   r'   r'   ;   r%   r   r'   c            	          e Zd ZdZdddZ e            ZdZdZ e	j
        d          Z e	j
        d          Z e	j
        d	          Z e	j
        d
          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z e	j
        d          Z eh ej        ej         ej!        ej"        ej#        ej$        ej%        ej&        ej'        ej(        ej)        ej*        ej+        ej,        ej-        ej.        ej/        ej0        ej1        ej2        ej3        ej4        ej5        ej6        ej7        ej8        ej9        ej:        ej;        ej<        ej=        ej>        ej?        ej@        ejA        ejB        ejC        d dD             z            ZD eh d          ZE eddh          ZFdeGfdZHdId"ZIdJd#ZJd$ ZKdKd&eGd'eGd(eGd)eGfd*ZLdKd&eGd+eGd(eGd)eGfd,ZMd- ZNd. ZOd/ ZPd0 ZQd1 ZRd2 ZSd3 ZTd4 ZUeVd5             ZWeVd6eGd)eGfd7            ZXeVd8eYfd9            ZZeVd:e[d6eGfd;            Z\eVd<d=d>e]d6eGfd?            Z^eVd@             Z_eVdA             Z`eVdB             ZaeVdC             Zbd:e[d6eGdDeGfdEZcd:e[fdFZdd>eeefeYf         dGeee]ege]ge]f         f         d)e]fdHZhd!S )LJSONPatha  JSONPath expression parser and evaluator.

    A JSONPath expression is used to navigate and extract data from JSON objects.
    This implementation supports extended syntax including filters, sorters, and
    field extractors.

    Attributes:
        RESULT_TYPE: Supported result types ('VALUE' or 'PATH').

    Example:
        >>> jp = JSONPath("$.store.book[?(@.price < 10)].title")
        >>> jp.parse({"store": {"book": [{"title": "A", "price": 5}]}})
        ['A']
    zA list of specific values.zAll path of specific values.)VALUEPATH;z;..;z\.\.z(?<!\.)\.(?!\.)z['](.*?)[']z#Q(\d+)z[`](.*?)[`]z#BQ(\d+)z[\[](.*?)[\]]z#B(\d+)z[\(](.*?)[\)]z#P(\d+)z^(-?\d*)?:(-?\d*)?(:-?\d*)?$z^([\w.']+)(, ?[\w.']+)+$zF@([.\[].*?)(?=<=|>=|==|!=|>|<| in| not| is|\s|\)|$)|len\(@([.\[].*?)\)zB(?:\.|^)(?P<dot>\w+)|\[['\"](?P<quote>.*?)['\"]\]|\[(?P<int>\d+)\]z=~\s*/(.*?)/z\.(\w+|'[^']*'|\"[^\"]*\")z\.(\.#B)z(?<!\w)@(?![.\[\w])c                 b    h | ],}t          t          |          t          t          |          -S r$   )hasattrastgetattr).0ns     r   	<setcomp>zJSONPath.<setcomp>   s2    
h
h
hqX_`cefXgXg
h73??
h
h
hr   )IndexNumStrBytesNameConstant>   len__objRegexPatternr9   r;   exprc                    t          t                    | _        g | _        d| _        g | _        d| _        d| _        |                     |          }d |	                    t          j                  D             | _        t          | j                  | _        t                              t          j                  r$t                              d| j                    dS dS )zInitialize JSONPath with an expression.

        Args:
            expr: JSONPath expression string (e.g., "$.store.book[*].price")
        r   r*   Nc                     g | ]}||S r$   r$   )r1   ss     r   
<listcomp>z%JSONPath.__init__.<locals>.<listcomp>   s    BBBqBBBBr   zsegments  : )r   listsubxsegmentslpathresultresult_type_custom_eval_func_parse_exprsplitr)   SEPr9   r   isEnabledForr   DEBUGdebugselfr<   s     r   __init__zJSONPath.__init__   s      %%	
"!%%%BBDJJx|$<$<BBB''
w}-- 	9LL77788888	9 	9r   r*   Nc                 P   t          |t          t          f          st          d          |t          j        vr;t          dt          t          j                                                             || _	        || _
        g | _        |                     |dd           | j        S )a  Parse JSON object using the JSONPath expression.

        Args:
            obj: JSON object (dict or list) to parse
            result_type: Type of result to return
                - 'VALUE': Return matched values (default)
                - 'PATH': Return JSONPath strings of matched locations
            eval_func: Custom eval function for filter expressions.
                If None (default), uses a safe expression evaluator that
                prevents code injection. Pass a custom function only if
                you trust the JSONPath expressions being evaluated.

        Returns:
            List of matched values or paths depending on result_type

        Raises:
            TypeError: If obj is not a dict or list
            ValueError: If result_type is invalid
        zobj must be a list or a dict.zresult_type must be one of r   $)
isinstancerA   dict	TypeErrorr)   RESULT_TYPE
ValueErrortuplekeysrF   rG   rE   _trace)rO   objrF   	eval_funcs       r   parsezJSONPath.parse   s    ( #d|,, 	=;<<<h222_5AUAZAZA\A\;];]__```&!* CC   {r   c                 .    |                      ||          S )zDAlias for parse(). Search JSON object using the JSONPath expression.)r]   )rO   r[   rF   s      r   searchzJSONPath.search   s    zz#{+++r   c                    t                               t          j                  rt                               d|            t
          j                            | j        |          }t
          j	                            | j
        |          }t
          j                            | j        |          }t
          j                            | j        |          }t
          j                            d|          }t
          j                            t
          j        |          }t
          j                            t
          j        |          }t
          j                            | j        |          }t
          j                            | j        |          }t
          j                            | j        |          }t
          j                            | j        |          }|dk    rd}n|                    d          r
|dd         }t                               t          j                  rt                               d|            |S )	zParse and normalize JSONPath expression into segments.

        Handles special patterns (quotes, brackets, parentheses) by temporarily
        replacing them with placeholders, then splits by dots and restores.
        zbefore expr : z\1rR    z$;   Nzafter expr  : )r   rK   r   rL   rM   r)   REP_GET_QUOTEsub
_get_quoteREP_GET_BACKQUOTE_get_backquoteREP_GET_PAREN
_get_parenREP_GET_BRACKET_get_bracketREP_DOTDOT_BRACKETREP_DOUBLEDOTSEP_DOUBLEDOTREP_DOTrJ   REP_PUT_BRACKET_put_bracketREP_PUT_PAREN
_put_parenREP_PUT_BACKQUOTE_put_backquoteREP_PUT_QUOTE
_put_quote
startswithrN   s     r   rH   zJSONPath._parse_expr   s    w}-- 	2LL0$00111%))$/4@@)--d.A4HH%))$/4@@'++D,=tDD*..ud;;%))(*@$GG##HL$77'++D,=tDD%))$/4@@)--d.A4HH%))$/4@@3;;DD__T"" 	8Dw}-- 	2LL0$00111r   ra   pattern_typecontentwrapperreturnc                     t          | j        |                   }| j        |                             |           |r|                    | |           S | | S )a2  Save pattern content and return placeholder.

        Args:
            pattern_type: Pattern identifier (e.g., '#Q', '#BQ', '#B', '#P')
            content: Content to save
            wrapper: Optional wrapper format string (e.g., "'{}'", "`{}`")

        Returns:
            Placeholder string
        )r9   rB   appendformat)rO   ry   rz   r{   r2   s        r   _save_patternzJSONPath._save_pattern  si     	,'((	,&&w/// 	8>>\"61"6"6777####r   indexc                 t    | j         |         t          |                   }|r|                    |          S |S )aA  Restore pattern content from placeholder.

        Args:
            pattern_type: Pattern identifier (e.g., '#Q', '#BQ', '#B', '#P')
            index: Index as string
            wrapper: Optional wrapper format string (e.g., "'{}'", "`{}`")

        Returns:
            Original content with optional wrapper
        )rB   intr   )rO   ry   r   r{   rz   s        r   _restore_patternzJSONPath._restore_pattern  s:     )L)#e**5 	+>>'***r   c                 T    |                      d|                    d                    S )N#Q   r   grouprO   ms     r   re   zJSONPath._get_quote(  s"    !!$

333r   c                 V    |                      d|                    d          d          S )Nr   r   z'{}'r   r   r   s     r   rw   zJSONPath._put_quote+  s$    $$T1771::v>>>r   c                 V    |                      d|                    d          d          S )N#BQr   z`{}`r   r   s     r   rg   zJSONPath._get_backquote.  s$    !!%V<<<r   c                 T    |                      d|                    d                    S )Nr   r   r   r   s     r   ru   zJSONPath._put_backquote1  s"    $$UAGGAJJ777r   c                 Z    d|                      d|                    d                    z   S )N.#Br   r   r   s     r   rk   zJSONPath._get_bracket4  s'    T''aggajj9999r   c                 T    |                      d|                    d                    S )Nr   r   r   r   s     r   rq   zJSONPath._put_bracket7  "    $$T1771::666r   c                 `    d|                      d|                    d                    z   dz   S )N(#Pr   )r   r   s     r   ri   zJSONPath._get_paren:  s,    T''aggajj999C??r   c                 T    |                      d|                    d                    S )Nr   r   r   r   s     r   rs   zJSONPath._put_paren=  r   r   c                     |                      d          d u}|                      d          p|                      d          }d }t          j                            ||          }d|z   }|rd| d}|S )Nrb   r   c                 X    |                      d          }|d         dv rd| dS d| dS )Nr   r   )'"[]['']r   )r   gs     r   replzJSONPath._gen_obj.<locals>.replE  s;    

Atz!!1xxx:::r   r:   zlen(r   )r   r)   REP_ATTR_PATHrd   )r   is_lenrz   r   rE   s        r   _gen_objzJSONPath._gen_obj@  s    4'''!***

	 	 	 (,,T7;;7" 	&%F%%%Fr   pathc                     t          |t                    r|  d| dS |                                s*|r/|                    dd                                          r|  d| S |  d| dS )zBuild JSON path string for a given key.

        Args:
            path: Current path string
            key: Key (string) or index (int)

        Returns:
            Formatted path string
        r   r   _ar   r   r   )rS   r   isidentifierreplaceisalnum)r   keys     r   _build_pathzJSONPath._build_pathQ  s     c3 	$##S#### 	## 	##++c3*?*?*G*G*I*I 	#??S??"!!#!!!!r   r   c                     | d         r| d         S | d         r| d         S | d         rt          | d                   S dS )zExtract key from regex match group dictionary.

        Args:
            group: Match group dictionary with 'dot', 'quote', or 'int' keys

        Returns:
            Key as string or int
        dotquoter   N)r   r   s    r   _extract_key_from_groupz JSONPath._extract_key_from_groupc  sS     < 	 <> 	">!< 	%uU|$$$tr   ic           	      P   t          |t                    r;t          |          D ])\  }} | ||t                              ||          g|R   *dS t          |t
                    r>|                                D ]+\  }} | ||t                              ||          g|R   *dS dS )aC  Traverse object children and apply function to each.

        Args:
            f: Function to apply to each child element
            obj: Object to traverse (list or dict)
            i: Current segment index
            path: Current JSONPath string
            *args: Additional arguments to pass to function f
        N)rS   rA   	enumerater)   r   rT   items)fr[   r   r   argsidxvks           r   	_traversezJSONPath._traverseu  s     c4   	>#C.. @ @Q!Q,,T377?$?????@ @T"" 	>		 > >1!Q,,T155======	> 	>> >r   Fconvert_number_strr[   c                   d|vr.t          | t                    r|| v r	| |         }nct          j        S | }|                    d          D ]?}t          |t                    r||v r	||         }$t          j        c S t          j        c S |rXt          |t
                    rC	 |                                rt          |          S t          |          S # t          $ r Y nw xY w|S )aZ  Get attribute value from object by dot-notation path.

        Args:
            obj: Source object (dict)
            path: Dot-separated path string (e.g., "author.name")
            convert_number_str: If True, convert numeric strings to int/float

        Returns:
            The value at the path, or _MISSING sentinel if not found
        r   )
rS   rT   r)   _MISSINGrI   strisdigitr   floatrW   )r[   r   r   rr   s        r   _getattrzJSONPath._getattr  s    d??#t$$ )I(( AZZ__ - -a&& -AvvaD'0000#,,,, 	*Q"4"4 	99;; "q66MQxx   s   ""C C 
C! C!c                 ^   d 	 |                     d          ddd         D ]c}|                                }|                    d          r|                     |ffd	d           H|                     |ffd		
           ddS # t          $ r}t          d|           |d}~ww xY w)z2Sort objects by multiple fields using stable sort.c                 l    t                               | d         |d          }|t           j        ur|nd S )Nr   Tr   )r)   r   r   )tr   r   s      r   key_funcz"JSONPath._sorter.<locals>.key_func  s7    !!!A$d!CCA!22211<r   ,N~c                 ,     | |dd                    S )Nr   r$   r   r   r   s     r   <lambda>z"JSONPath._sorter.<locals>.<lambda>  s    AabbE0B0B r   T)r   reversec                      | |          S Nr$   r   s     r   r   z"JSONPath._sorter.<locals>.<lambda>  s    XXa^^ r   )r   z2not possible to compare str and int when sorting: )rI   striprx   sortrU   r'   )r[   sortbyssortbyer   s       @r   _sorterzJSONPath._sorter  s   	= 	= 	=	e!--,,TTrT2 E E$$S)) EHH(.BBBBB $     
 HHV!C!C!C!C!CHDDDDE E  	e 	e 	e#$\YZ$\$\]]cdd	es   BB
 

B,B''B,c                    	 t          j        | d          }n%# t          $ r}t          d|           |d}~ww xY wt          j        |          D ]}t          |          }|t          j        vrt          d|j                   |t           j	        u r*|j
        t          j        vrt          d|j
                   |t           j        u r1|j                            d          rt          d|j                   |t           j        u rFt!          |j        t           j	                  r|j        j
        t          j        v st          d	          dS )
a  Validate that a filter expression only contains safe AST constructs.

        Raises ValueError if the expression contains potentially dangerous
        constructs like function calls (except len/RegexPattern), attribute
        access to dunder names, or disallowed node types.
        eval)modez"Invalid filter expression syntax: Nz!Disallowed expression construct: z&Disallowed name in filter expression: r   zDisallowed attribute access: zEOnly len() and RegexPattern() calls are allowed in filter expressions)r/   r]   SyntaxErrorrW   walktyper)   _ALLOWED_AST_NODESr    Nameid_ALLOWED_NAMES	Attributeattrrx   CallrS   func_ALLOWED_CALLS)r<   treer   node	node_types        r   _validate_filter_exprzJSONPath._validate_filter_expr  si   	N9T///DD 	N 	N 	NE!EEFFAM	N HTNN 
	n 
	nDT

I ;;; !YYEW!Y!YZZZCH$$8O)O)O !S$'!S!STTTCM))di.B.B3.G.G) !L!L!LMMMCH$$"49ch77 nDILHLc<c<c$%lmmm
	n 
	ns    
;6;c                 x    t                               |            t          | di i|t          t          d          S )uK  Safely evaluate a filter expression against an object.

        Validates the expression AST before evaluation and uses a restricted
        namespace with no access to Python builtins (defense-in-depth for
        the RCE fix — AST validation is the primary gate, restricted
        __builtins__ is the secondary gate).
        __builtins__)r:   r;   r9   )r)   r   r   r;   r9   )r<   r[   s     r   _safe_eval_filterzJSONPath._safe_eval_filter  s:     	&&t,,,D>2.#|dg0h0hiiir   c                 8   |                      d          }d }t          |          dk    r ||d                   nd}t          |          dk    r ||d                   nd}t          |          dk    r ||d                   nd}t          |||          S )zParse a slice expression string into a slice object.

        Args:
            s: Slice string like '1:3', '::2', '-1:', etc.

        Returns:
            A slice object
        :c                 P    |                                  } | rt          |           nd S r   )r   r   )r   s    r   to_intz%JSONPath._parse_slice.<locals>.to_int  s$    		A(3q666D(r   r   Nr   rb   )rI   r9   slice)r?   partsr   startstopsteps         r   _parse_slicezJSONPath._parse_slice  s     	) 	) 	) %(JJNNuQx   #&u::>>vveAht#&u::>>vveAhtUD$'''r   r   c                     d}	 | j          |                      |d|t          d          }n|                     ||          }n# t          $ r Y nw xY w|r|                     |||           dS dS )a"  Evaluate filter expression and continue trace if condition is true.

        Args:
            obj: Current object to evaluate against filter
            i: Next segment index to trace
            path: Current JSONPath string
            step: Python expression string to evaluate
        FN)r:   r;   )rG   r;   r   	ExceptionrZ   )rO   r[   r   r   r   r   s         r   _filterzJSONPath._filter  s     	%1**4Vb7c7cdd**455 	 	 	D	 	&KKQ%%%%%	& 	&s   =A 
AAc           	      r   || j         k    r| j        dk    r| j                            |           n%| j        dk    r| j                            |           t                              t          j                  r t                              d| d|            dS | j	        |         }|dk    r"| 
                    | j        ||dz   |           dS |dk    r9|                     ||dz   |           | 
                    | j        |||           dS t          |t                    r^|                                rJt          |          }|t!          |          k     r&|                     ||         |dz   | d	| d
           dS t!          |          dk    r"|d         dk    r|d         dk    r
|dd         n|}t          |t"                    r:||v r6|                     ||         |dz   |                     ||                     dS t          |t                    rt&          j                            |          rat          t-          |                    }||                     |                   }|D ]%\  }	}
|                     |
|dz   | d	|	 d
           &dS t          |t"                    rt&          j                            |          rf|                    d          D ]N}|                                }||v r4|                     ||         |dz   |                     ||                     OdS |r4|d         dv r)|                    d          r|                    d          r|dd         }t&          j                            | j        |          }t&          j                             d|          }d|v r t&          j!                            d|          }t          |t"                    r| "                    ||dz   ||           | 
                    | j"        ||dz   ||           dS |                    d          r"t          |t                    rqt          t-          |                    }| #                    ||dd                    |D ]3\  }	}
|                     |
|dz   |                     ||	                     4nt          |t"                    rvt          |$                                          }| #                    ||dd                    |D ]3\  }}
|                     |
|dz   |                     ||                     4ntK          d          dS |r|d         dk    r|                    d          rt          |t"                    rzi }|dd                             d          D ]?}|                                }| &                    ||          }
|
t&          j'        ur|
||<   @|                     ||dz   |           ntK          d          dS dS dS dS )a  Recursively traverse object following JSONPath segments.

        This is the core evaluation method that processes each segment of the
        parsed JSONPath expression and navigates through the object accordingly.

        Args:
            obj: Current object being traversed
            i: Index of current segment in self.segments
            path: JSONPath string representing current location
        r*   r+   zpath: z
 | value: N*r   z..r   r   rb   r   r   r   r   z?/r   z?(r:   z=~z@ RegexPattern(r'\1')z/(z"sorter must acting on list or dictr   z#field-extractor must acting on dict)(rD   rF   rE   r~   r   rK   r   rL   rM   rC   r   rZ   rS   rA   r   r   r9   rT   r   r)   REP_SLICE_CONTENT	fullmatchr   r   REP_SELECT_CONTENTrI   r   endswithrx   REP_FILTER_CONTENTrd   r   REP_BARE_ATREP_REGEX_PATTERNr   r   r   r   r   r   )rO   r[   r   r   r   ikeystep_keyindexedvalsr   r   r   obj_s                r   rZ   zJSONPath._trace  sN    
??7**""3''''!V++""4(((""7=11 =;d;;c;;<<<F}Q 3;;NN4;QUD999F 4<<KKQUD)))NN4;Q555F c4   	T\\^^ 	t99Dc#hhCIq1u.?.?.?.?.?@@@F #&d))q..T!W^^RTW4"::^bc4   	X__KKHq1ud.>.>tX.N.NOOOF c4   	X%?%I%I$%O%O 	9S>>**G4,,T223D 8 8QAq1u&6&6&6&6&67777F c4   	X%@%J%J4%P%P 	ZZ__ J JGGII88KKAAt/?/?a/H/HIIIF   	DGtOOc(:(:Ot$$ AbDz266t}dKK  +//>>4<<#599:RTXYYDc4(( 9LLa!eT4888t|S!a%tDDDt$$ c4(( Py~~..CLLd1R4j111"% K KQAq1ud.>.>tS.I.IJJJJKT** Psyy{{++CLLd1R4j111 # I I1Aq1ud.>.>tQ.G.GHHHHI **NOOO  	DGsNNt}}S'9'9N#t$$ 	Mad))#.. $ $A		Ac1--A 111"#QD!a%....%&KLLLF	 	NNNNr   value_or_funcc                    |                      |d          }t          |          }t          |          dk    r|d         dk    r|r ||          n|S |D ]}t          t          j                            |                    }|s1|}|dd         D ]1}|                     |                                          }	||	         }2|                     |d                                                   }	|r |||	                   n|||	<   |S )aI  Update values in JSON object using JSONPath expression.

        Args:
            obj: JSON object (dict or list) to update
            value_or_func: Static value or callable that transforms the current value

        Returns:
            Updated object (modified in-place for nested paths, returns new value for root)
        r+   )rF   r   r   rR   Nr   )	r]   callabler9   rA   r)   REP_PATH_SEGMENTfinditerr   	groupdict)
rO   r[   r  pathsis_funcr   matchestargetmatchr   s
             r   updatezJSONPath.update  s(    

3F
33=)) u::??uQx3)0C==%%%mC 	S 	SD84==dCCDDG F " % %225??3D3DEE ..wr{/D/D/F/FGGC8?R--s444]F3KK
r   )r*   N)r*   )ra   )ir    r!   r"   r#   rV   objectr   rJ   rn   recompilerm   ro   rc   rv   rf   rt   rj   rp   rh   rr   r  r  r  r  r  r   rl   r  	frozensetr/   
ExpressionBoolOpAndOrBinOpAddSubMultDivFloorDivModMatMultUnaryOpNotUAddUSubCompareEqNotEqLtLtEGtGtEIsIsNotInNotInConstantr   	SubscriptSliceListTupleDictr   r   Loadr   r   r   r   rP   r]   r_   rH   r   r   re   rw   rg   ru   rk   rq   ri   rs   staticmethodr   r   rT   r   r   r   r   r   r   r   r   r   r   rZ   r   rA   r   r  r$   r   r   r)   r)   D   s          .. K
 vxxH CMBJw''Mbj+,,G BJ~..MBJz**M"
>22"
;// bj!122O bj,,OBJ/00MBJz**M #
#BCC#$?@@#$mnn!rz"ghh"
?33BJ<==M#K00"*344K #0	
N0	
 J0	
 G	0	

 F0	
 I0	
 G0	
 G0	
 H0	
 G0	
 L0	
 G0	
 K0	
  K!0	
" G#0	
$ H%0	
& H'0	
* K+0	
, F-0	
. I/0	
0 F10	
2 G30	
4 F50	
6 G70	
8 F90	
: I;0	
< F=0	
> I?0	
B LC0	
D HE0	
H MI0	
J IK0	
N HO0	
P IQ0	
R HS0	
V MW0	
Z H[0	
^ H_0	
d i
h$T
h
h
he2	i4 4j Y???@@NY~677N9S 9 9 9 9(       D, , , ,  >$ $# $ $c $SV $ $ $ $" S  s TW     4 4 4? ? ?= = =8 8 8: : :7 7 7@ @ @7 7 7   \  "# "s " " " \"" t    \" >S > > > > \>" <A $ $ $c $ $ $ $ \$L e e \e( n n \n0 
j 
j \
j ( ( \((&c & &C & & & &(qS q q q qf %d
+  E#xQTPUWZPZG[B[<\  ad            r   r)   c                       e Zd ZdZd Zd ZdS )r;   a<  Regex pattern wrapper for use with the =~ operator in filter expressions.

    This class enables regex matching syntax like: @.name =~ /pattern/
    The @ operator is overloaded to perform the regex search.

    Example:
        >>> pattern = RegexPattern(r"^test")
        >>> "testing" @ pattern
        True
    c                 F    || _         t          j        |          | _        dS )z'Initialize with a regex pattern string.N)patternr  r  	_compiled)rO   rB  s     r   rP   zRegexPattern.__init__  s    G,,r   c                 ~    t          |t                    r't          | j                            |                    S dS )z@Right matmul operator (@) - checks if other matches the pattern.F)rS   r   boolrC  r_   )rO   others     r   __rmatmul__zRegexPattern.__rmatmul__  s7    eS!! 	6--e44555ur   N)r    r!   r"   r#   rP   rG  r$   r   r   r;   r;     s<        	 	- - -
    r   r;      r<   r|   c                    | t           v rt                               |            nOt          t                     t          k    rt                               d           t          |           t           | <   t           |          S )zGet or create a cached JSONPath instance.

    Args:
        expr: JSONPath expression string

    Returns:
        Cached or newly created JSONPath instance
    F)last)_jsonpath_cachemove_to_endr9   _CACHE_MAX_SIZEpopitemr)   r<   s    r   _get_cached_jsonpathrP    sm     ##D)))) ?22###/// (4  r   c                      t          |           S )a  Compile a JSONPath expression for reuse.

    Returns a cached JSONPath instance when available, avoiding redundant parsing.

    Args:
        expr: JSONPath expression string

    Returns:
        JSONPath object that can be used to parse multiple JSON objects

    Example:
        >>> jp = compile("$.store.book[*].price")
        >>> jp.parse(data1)
        >>> jp.parse(data2)
    )rP  rO  s    r   r  r    s       %%%r   c                 F    t          |                               |          S )zSearch JSON data using JSONPath expression with caching.

    Args:
        expr: JSONPath expression string
        data: JSON data (dict or list)

    Returns:
        List of matched values
    )rP  r]   )r<   datas     r   r_   r_     s       %%++D111r   )r#   r/   r   osr  collectionsr   r   typingr   r   r   r   r   r   r   getenvr   r   r   r'   r)   r;   rK  rM  rP  r  r_   r$   r   r   <module>rX     s   $ 


  				 				 0 0 0 0 0 0 0 0 ' ' ' ' ' ' ' ' ' ' #W\   5c?    ( 
z929\6#B#B	C	C    i       	   b	 b	 b	 b	 b	 b	 b	 b	J       2 +--!s !x ! ! ! !(& & &&
2 
2 
2 
2 
2r   