
    \j                    p    d dl mZ d dlZd dlmZmZ d	dZd
dZ ej                  d      Z	 G d d      Z
y)    )annotationsN)ListOptionalAttributeRefc                d    ||dk(  rt         j                  |       S t         j                  |       S N )r   from_literal	from_pathattr_ref_strcontext_kinds     K/root/env/lib/python3.12/site-packages/ldclient/impl/model/attribute_ref.py"req_attr_ref_with_opt_context_kindr      s1    |r1((66!!,//    c                *    | | dk(  ry t        | |      S r   )r   r   s     r   "opt_attr_ref_with_opt_context_kindr      s    |r1-lLIIr   z(~[^01]|~$)c                      e Zd Zg dZdZ	 	 	 	 	 	 	 	 ddZedd       Zedd       Zedd       Z	edd       Z
ddZedd	       Zedd
       Zedd       Zedd       Zedd       Zy)r   _raw_single_component_components_errorz#attribute reference cannot be emptyc                <    || _         || _        || _        || _        y Nr   )selfrawsingle_component
componentserrors        r   __init__zAttributeRef.__init__   s"     	!1%r   c                    | j                   d u S r   r   r   s    r   validzAttributeRef.valid%   s    {{d""r   c                    | j                   S r   r#   r$   s    r   r    zAttributeRef.error)   s    {{r   c                    | j                   S r   )r   r$   s    r   pathzAttributeRef.path-   s    yyr   c                `    | j                   y| j                  t        | j                        S y)Nr      )r   r   lenr$   s    r   depthzAttributeRef.depth1   s/    ;;"'t''((r   c                    | j                   y | j                  .|dk  s|t        | j                        k\  rd S | j                  |   S |dk(  r| j                  S d S )Nr   )r   r   r+   r   )r   indexs     r   __getitem__zAttributeRef.__getitem__9   sa    ;;"' 19T5E5E1F(F4cDL\L\]bLcc).!t%%==r   c                   | dk(  s| dk(  r#t         j                  t         j                        S | d   dk7  rt        | | d d       S | dd  j                  d      }t	        |      D ]T  \  }}|dk(  rt         j                  d      c S t         j                  |      }|t         j                  d      c S |||<   V t        | d |d       S )Nr	   /r   r*   z@attribute reference contained a double slash or a trailing slashzUattribute reference contained an escape character (~) that was not followed by 0 or 1)r   _from_error
_ERR_EMPTYsplit	enumerate	_unescape)r(   r   ic	unescapeds        r   r   zAttributeRef.from_path@   s    2:++L,C,CDD7c>dD$77!"X^^C(
j) 	&DAqBw#//0rss$..q1I #//  1H  I  I%JqM	& D$
D99r   c                    | dk(  r#t         j                  t         j                        S t        t         j                  |       | d d       S r   )r   r2   r3   _escape)names    r   r
   zAttributeRef.from_literalP   s<    2:++L,C,CDDL006dDIIr   c                    t        dd d |       S r   )r   )r    s    r   r2   zAttributeRef._from_errorV   s    BdE22r   c                r    t         j                  |       ry | j                  dd      j                  dd      S )N~1r1   ~0~)_INVALID_ATTR_ESCAPE_REGEXsearchreplacess    r   r6   zAttributeRef._unescapeZ   s1    %,,Q/yys#++D#66r   c                F    | j                  dd      j                  dd      S )NrA   r@   r1   r?   )rD   rE   s    r   r;   zAttributeRef._escape`   s     yyd#++C66r   N)r   strr   Optional[str]r   zOptional[List[str]]r    rI   )returnbool)rJ   rI   )rJ   rH   )rJ   int)r(   rH   rJ   r   )r<   rH   rJ   r   )r    rH   rJ   r   )rF   rH   rJ   rI   )rF   rH   rJ   rH   )__name__
__module____qualname__	__slots__r3   r!   propertyr%   r    r(   r,   r/   staticmethodr   r
   r2   r6   r;    r   r   r   r      s    FI6J

 (
 (	

 
 # #      > : : J J
 3 3 7 7
 7 7r   )r   rH   r   rI   rJ   r   )r   rI   r   rI   rJ   zOptional[AttributeRef])
__future__r   retypingr   r   r   r   compilerB   r   rS   r   r   <module>rX      s8    " 	 !0
J (RZZ6 N7 N7r   