
    MhH                       U d Z ddlmZ ddlmZmZmZ ddlmZm	Z	 ddl
mZmZmZmZmZ ddlmZ ddlmZmZmZmZ ddlmZmZmZ eeef         Ze	eef         Z ee          Z!ee          Z" e            Z#d	e$d
<   e G d de%                      Z&dVdZ'dVdZ(dWdZ)dXdZ*dYdZ+dYdZ,dZdZ- e.             e.             e.            fd[d#Z/ e.             e.             e.            fd[d$Z0 e.             e.             e.            fd[d%Z1 e.             e.             e.            fd[d&Z2 e.             e.             e.            fd[d'Z3 e.             e.             e.            fd[d(Z4 e.             e.             e.            fd[d)Z5 ed*e' e/h d+h d,h d-.          e* e3h d+h d,h d-.          /          Z6 ed0e' e0h d1h d2h d-.          e+ e4h d1h d2h d-.          /          Z7 ed3e( e1h d4h d2h d5.          e, e5h d4h d2h d5.          /          Z8 ed6e( e1h d7h d2h d5.          e, e5h d7h d2h d5.          /          Z9 ed8e) e2d9hh d2h d5.          e- e5h d:h d2h d5.          /          Z: ed;e) e2d<hh d5=          e- e5d>d?hd<hh d5.          /          Z; ed@ dAe6fdBe7fdCe8fdDe9fdEe:fdFe;ffD                       Z<dGe$dH<   efd\dNZ=e G dO dP                      Z>d]dTZ?dUS )^zI
Referencing implementations for JSON Schema specs (historic & current).
    )annotations)IterableSequenceSet)AnyUnion)AnchorRegistryResourceSpecification
exceptions)frozen)_UNSETResolvedResolver_Unset)URIr	   MappingSchemaRegistryEMPTY_REGISTRYc                      e Zd ZU dZded<   dS )UnknownDialectz
    A dialect identifier was found for a dialect unknown by this library.

    If it's a custom ("unofficial") dialect, be sure you've registered it.
    r   uriN)__name__
__module____qualname____doc____annotations__     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/referencing/jsonschema.pyr   r   $   s%           HHHHHr    r   contentsSchemareturn
URI | Nonec                Z    t          | t                    rd S |                     d          S )N$id)
isinstanceboolget)r"   s    r!   
_dollar_idr+   /   s+    (D!! <<r    c                    t          | t                    sd| v rd S |                     d          }||                    d          s|S d S d S )N$refr'   #)r(   r)   r*   
startswithr"   ids     r!   _legacy_dollar_idr2   5   sY    (D!! Vx%7%7	e		B	~bmmC00~	 ~~~r    ObjectSchemac                r    d| v rd S |                      d          }||                    d          s|S d S d S )Nr-   r1   r.   )r*   r/   r0   s     r!   
_legacy_idr5   =   sH    	d		B	~bmmC00~	 ~~~r    specificationSpecification[Schema]Iterable[AnchorType[Schema]]c              #  0  K   t          |t                    rd S |                    d          }|&t          ||                     |                    V  |                    d          }|(t          ||                     |                    V  d S d S )N$anchornameresourcez$dynamicAnchor)r(   r)   r*   r	   create_resourceDynamicAnchor)r6   r"   anchordynamic_anchors       r!   _anchorrB   E   s       (D!! \\)$$F"228<<
 
 
 	
 	
 	

 \\"233N!"228<<
 
 
 	
 	
 	
 	
 	
 "!r    Iterable[Anchor[Schema]]c                    t          |t                    rg S |                    d          }|g S t          ||                     |                    gS )Nr:   r;   )r(   r)   r*   r	   r>   )r6   r"   r@   s      r!   _anchor_2019rE   Z   sf     (D!! 	\\)$$F~	"228<<	
 	
 	
 r    c                    t          |t                    rg S |                    dd          }|                    d          sg S t	          |dd          |                     |                    gS )Nr'    r.      r;   )r(   r)   r*   r/   r	   r>   r6   r"   r1   s      r!   _legacy_anchor_in_dollar_idrJ   k   s     (D!! 		eR	 	 B== 	ABB"228<<	
 	
 	
 r    Specification[ObjectSchema]Iterable[Anchor[ObjectSchema]]c                    |                     dd          }|                    d          sg S t          |dd          |                     |                    gS )Nr1   rG   r.   rH   r;   )r*   r/   r	   r>   rI   s      r!   _legacy_anchor_in_idrN   |   sh     
dB		B== 	ABB"228<<	
 	
 	
 r    in_valueSet[str]in_subvaluesin_subarrayc                     d fd}|S )z
    Create a callable returning JSON Schema specification-style subschemas.

    Relies on specifying the set of keywords containing subschemas in their
    values, in a subobject's values, or in a subarray.
    r"   r#   r$   Iterable[ObjectSchema]c              3     K   t          | t                    rd S D ]}|| v r
| |         V  D ]}|| v r| |         E d {V  D ]&}|| v r | |                                         E d {V  'd S N)r(   r)   values)r"   eachrR   rQ   rO   s     r!   subresources_ofz)_subresources_of.<locals>.subresources_of   s      h%% 	F 	% 	%Dxtn$$$ 	* 	*Dx#D>)))))))  	3 	3Dx#D>00222222222	3 	3r    r"   r#   r$   rT   r   rO   rQ   rR   rY   s   ``` r!   _subresources_ofr\      s5    3 3 3 3 3 3 3 3 r    c                     d fd}|S )O
    Specifically handle older drafts where there are some funky keywords.
    r"   r#   r$   rT   c              3  X  K   t          | t                    rd S D ]}|| v r
| |         V  D ]}|| v r| |         E d {V  D ]&}|| v r | |                                         E d {V  '|                     d          }|%t          |t                    r
|E d {V  d S |V  d S d S Nitems)r(   r)   rW   r*   r   )r"   rX   ra   rR   rQ   rO   s      r!   rY   z:_subresources_of_with_crazy_items.<locals>.subresources_of   s     h%% 	F 	% 	%Dxtn$$$ 	* 	*Dx#D>)))))))  	3 	3Dx#D>00222222222W%%%**           	 r    rZ   r   r[   s   ``` r!   !_subresources_of_with_crazy_itemsrb      s5           ( r    c                     d fd}|S )r^   r"   r#   r$   rT   c              3  ,  K   t          | t                    rd S D ]}|| v r
| |         V  D ]}|| v r| |         E d {V  D ]&}|| v r | |                                         E d {V  '|                     d          }|"t          |t                    r	|E d {V  n|V  |                     d          }|Tt          |                                          }t          |d           }t          |t                    r|V  |E d {V  d S d S d S )Nra   dependencies)r(   r)   rW   r*   r   iternextr   	r"   rX   ra   re   rW   valuerR   rQ   rO   s	         r!   rY   zG_subresources_of_with_crazy_items_dependencies.<locals>.subresources_of   s     h%% 	F 	% 	%Dxtn$$$ 	* 	*Dx#D>)))))))  	3 	3Dx#D>00222222222W%%%**          ||N33#,--//00F&&E%)) "!!!!!!!!!! $#" "r    rZ   r   r[   s   ``` r!   ._subresources_of_with_crazy_items_dependenciesrj      s5    " " " " " " " "6 r    c                     d fd}|S )zT
    Specifically handle even older drafts where there are some funky keywords.
    r"   r3   r$   rT   c              3  \  K   D ]}|| v r
| |         V  D ]}|| v r| |         E d {V  D ]&}|| v r | |                                          E d {V  '|                     d          }|"t          |t                    r	|E d {V  n|V  |                     d          }|Rt	          |                                           }t          |d           }t          |t                    r|V  |E d {V  dD ]0}|                     |          }t          |t                    r|V  1d S )Nra   re   )additionalItemsadditionalProperties)rW   r*   r(   r   rf   rg   r   rh   s	         r!   rY   zJ_subresources_of_with_crazy_aP_items_dependencies.<locals>.subresources_of   s      	% 	%Dxtn$$$ 	* 	*Dx#D>)))))))  	3 	3Dx#D>00222222222W%%%**          ||N33#,--//00F&&E%)) "!!!!!!!!= 	 	DLL&&E%)) 	 	r    )r"   r3   r$   rT   r   r[   s   ``` r!   1_subresources_of_with_crazy_aP_items_dependenciesro      s5           < r    c                "     ||z  d	 fd}|S )
NsegmentsSequence[int | str]resolver_Resolver[Any]subresourceResource[Any]r$   c                    t          |           }|D ]}|vr|vst          |d           |c S |                    |          S rV   )rf   rg   in_subresourcerq   rs   ru   	_segmentssegmentin_childrO   s        r!   maybe_in_subresourcez3_maybe_in_subresource.<locals>.maybe_in_subresource  sb    
 NN	  	  	 Gh&&x''4	4+@+@+H&&{333r    rq   rr   rs   rt   ru   rv   r$   rt   r   rO   rQ   rR   r}   r|   s   `   @r!   _maybe_in_subresourcer     s;    
 k)H4 4 4 4 4 4 4  r    c                "     ||z  d	 fd}|S )
Nrq   rr   rs   rt   ru   rv   r$   c                    t          |           }|D ]U}|dk    r1t          |j        t                    r|                    |          c S |vr|vst          |d           |c S V|                    |          S r`   rf   r(   r"   r   rx   rg   ry   s        r!   r}   z?_maybe_in_subresource_crazy_items.<locals>.maybe_in_subresource6  s    
 NN	  		  		 G'!!j$' '!  ..{;;;;;h&&x''4	4+@+@+H&&{333r    r~   r   r   s   `   @r!   !_maybe_in_subresource_crazy_itemsr   /  ;    
 k)H4 4 4 4 4 4 4$  r    c                "     ||z  d	 fd}|S )
Nrq   rr   rs   rt   ru   rv   r$   c                    t          |           }|D ]S}|dv r1t          |j        t                    r|                    |          c S |vr|vst          |d           |c S T|                    |          S )N>   ra   re   r   ry   s        r!   r}   zL_maybe_in_subresource_crazy_items_dependencies.<locals>.maybe_in_subresourceR  s    
 NN	  		  		 G333
$9 93  ..{;;;;;h&&x''4	4+@+@+H&&{333r    r~   r   r   s   `   @r!   ._maybe_in_subresource_crazy_items_dependenciesr   K  r   r    zdraft2020-12>   ifnotelsethenra   containscontentSchemapropertyNamesunevaluatedItemsrn   unevaluatedProperties>   allOfanyOfoneOfprefixItems>   $defs
propertiesdefinitionsdependentSchemaspatternProperties)rO   rR   rQ   )r<   id_ofrY   
anchors_inr}   zdraft2019-09>   r   r   r   r   r   r   r   rm   r   rn   r   >   r   r   r   zdraft-07>   r   r   r   r   r   r   rm   rn   >   r   r   r   zdraft-06>   r   r   r   rm   rn   zdraft-04r   >   r   rm   rn   zdraft-03extends)rR   rQ   rm   rn   c                >    i | ]\  }}|t          j        |          S r   )r   opaque).0
dialect_idr6   s      r!   
<dictcomp>r   /  s8     
 
 
%J 	HOM22
 
 
r    z,https://json-schema.org/draft/2020-12/schemaz,https://json-schema.org/draft/2019-09/schemaz&http://json-schema.org/draft-07/schemaz&http://json-schema.org/draft-06/schemaz&http://json-schema.org/draft-04/schemaz&http://json-schema.org/draft-03/schemazRegistry[Specification[Schema]]_SPECIFICATIONSr   r   defaultSpecification[Any] | _UnsetSpecification[Any]c                    t                               |                     d                    }||j        S |t          u rt          |           |S )z
    Retrieve the `Specification` with the given dialect identifier.

    Raises:

        `UnknownDialect`

            if the given ``dialect_id`` isn't known

    r.   )r   r*   rstripr"   r   r   )r   r   r=   s      r!   specification_withr   =  sR     "":#4#4S#9#9::H  &Z(((Nr    c                  0    e Zd ZU dZded<   ded<   dd
ZdS )r?   z4
    Dynamic anchors, introduced in draft 2020.
    strr<   SchemaResourcer=   rs   _Resolver[Schema]r$   _Resolved[Schema]c                <   | j         }|                                D ]X\  }}	 |                    || j                  j        }n# t
          j        $ r Y 8w xY wt          |t                    r|j         }Yt          |j
        |                    |                    S )z2
        Resolve this anchor dynamically.
        )r"   rs   )r=   dynamic_scoper@   r<   ri   r   NoSuchAnchorr(   r?   	_Resolvedr"   rx   )selfrs   lastr   registryr@   s         r!   resolvezDynamicAnchor.resolve\  s     }%3355 	' 	'MC!di88>*   &-00 '],,T22
 
 
 	
s    AAANrs   r   r$   r   )r   r   r   r   r   r   r   r    r!   r?   r?   S  sK           III
 
 
 
 
 
r    r?   rs   r   r   c                f   |                      d          }t          |j        t                    r|j                            d          rg|                                 D ]R\  }}|                      |          }t          |j        t                    r|j                            d          s n|}S|S )u   
    Recursive references (via recursive anchors), present only in draft 2019.

    As per the 2019 specification (§ 8.2.4.2.1), only the ``#`` recursive
    reference is supported (and is therefore assumed to be the relevant
    reference).
    r.   z$recursiveAnchor)lookupr(   r"   r   r*   r   )rs   resolvedr   _next_resolveds        r!   lookup_recursive_refr   n  s     s##H(#W-- 
%(2C2G2G3 3 
% ,,.. 	% 	%FC$OOC00M&   #+//0BCC $HHOr    N)r"   r#   r$   r%   )r"   r3   r$   r%   )r6   r7   r"   r#   r$   r8   )r6   r7   r"   r#   r$   rC   )r6   rK   r"   r3   r$   rL   )rO   rP   rQ   rP   rR   rP   )r   r   r   r   r$   r   r   )@r   
__future__r   collections.abcr   r   r   typingr   r   referencingr	   r
   r   r   r   referencing._attrsr   referencing._corer   r   r   r   	_Resolverr   referencing.typingr   
AnchorTyper   r   r3   r)   r#   r   r   r   r   	Exceptionr   r+   r2   r5   rB   rE   rJ   rN   	frozensetr\   rb   rj   ro   r   r   r   DRAFT202012DRAFT201909DRAFT7DRAFT6DRAFT4DRAFT3r   r   r?   r   r   r    r!   <module>r      s     # " " " " " 3 3 3 3 3 3 3 3 3 3         M M M M M M M M M M M M M M % % % % % %            B A A A A A A A A A sCx  
t\!	" &! &! "* + + + +     Y            
 
 
 
*   "   "     #&Y[[%IKK    : #&Y[[%IKK    B #&Y[[%IKK$ $ $ $ $P #&Y[[%IKK' ' ' ' 'V #&Y[[%IKK         0 #&Y[[%IKK         : #&Y[[%IKK         : m	
$$
 
 
 ?>>
 
 
  . ..
 
 
 ?>>
 
 
  72 2 2h m	
55
 
 
 0//
 
 
  . ::
 
 
 0//
 
 
  72 2 2h 
	
BB	
 	
 	
 0//GGG   +GG	
 	
 	
 0//GGG  % 
  
  
D 
	
BB
 
 
 0//GGG
 
 
 +GG
 
 
 0//GGG
 
 

 
 
8 
	
EE///GGG  
 $GGCCC///GGG  
 
 
  
	
EEKGGG   $GG#%;<KGGG  
 
 
  4<8
 
 <[I;[I5v>5v>5v>5v>*

 
 
4 4    " ,2    , 
 
 
 
 
 
 
 
4     r    