+
    ÎiJ                    2   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
HtHtHt ^ RIHt ^ RIHtHt ^ RIHt ]'       d   ^ RI
Ht ^ R	IHt ^ R
IHt ^ RIHt ]P6                  ! ]4      t]P<                  ! R4      tRt R R lt! ! R R4      t"R# )z7
The httplib2 algorithms ported for use with requests.
)annotationsN)parsedate_tz)TYPE_CHECKING
CollectionMapping)CaseInsensitiveDict)	DictCacheSeparateBodyBaseCache)
Serializer)Literal)PreparedRequest)HTTPResponse)	BaseCachez9^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?c                    V ^8  d   QhRRRR/# )   uristrreturnztuple[str, str, str, str, str] )formats   "r/Users/ahmad/.openclaw/workspace/scripts/.venv/lib/python3.14/site-packages/pip/_vendor/cachecontrol/controller.py__annotate__r   '   s     C C3 C9 C    c                    \         P                  V 4      pVf   Q hVP                  4       pV^,          V^,          V^,          V^,          V^,          3# )z{Parses a URI using the regex given in Appendix B of RFC 3986.

(scheme, authority, path, query, fragment) = parse_uri(uri)
)URImatchgroups)r   r   r   s   &  r   	parse_urir   '   sM    
 IIcNE\\^F1Ivay&)VAYq	BBr   c                      ] tR t^2tRtRR R llt]R R l4       t]R R l4       tR	 R
 lt	R R lt
R R ltR R ltRR R lltRR R lltR R ltRtR# )CacheControllerz4An interface to see if request should cached or not.Nc               (    V ^8  d   QhRRRRRRRR/# )	r   cachezBaseCache | Nonecache_etagsbool
serializerzSerializer | Nonestatus_codesCollection[int] | Noner   )r   s   "r   r   CacheController.__annotate__5   s8     
P 
P
P 
P &	
P
 -
Pr   c                	    Vf   \        4       MTV n        W n        T;'       g    \        4       V n        T;'       g    RV n        R # )N)      i,  -  4  )r   r!   r"   r
   r$   cacheable_status_codes)selfr!   r"   r$   r%   s   &&&&&r   __init__CacheController.__init__5   s;     %*MY[u
&$44
&2&O&O6O#r   c                    V ^8  d   QhRRRR/# r   r   r   r   r   )r   s   "r   r   r'   B   s      3 3 r   c                6   \        V4      w  r#rEpV'       d	   V'       g   \        RV,          4      hVP                  4       pVP                  4       pV'       g   RpT;'       d    RP                  WE.4      ;'       g    TpVR,           V,           V,           pV# )z4Normalize the URL to create a safe key for the cachez(Only absolute URIs are allowed. uri = %s/?z://)r   	Exceptionlowerjoin)	clsr   scheme	authoritypathqueryfragmentrequest_uri
defrag_uris	   &&       r   _urlnormCacheController._urlnormA   s     6?s^2DYFLMMOO%	D 77$ 7??4e^i/+=
r   c                    V ^8  d   QhRRRR/# r2   r   )r   s   "r   r   r'   V   s     ! !C !C !r   c                	$    V P                  V4      # )N)rA   )r9   r   s   &&r   	cache_urlCacheController.cache_urlU   s    ||C  r   c                    V ^8  d   QhRRRR/# )r   headerszMapping[str, str]r   zdict[str, int | None]r   )r   s   "r   r   r'   Y   s     4 4+< 4AV 4r   c                	
   R \         R3R\         R3R\         R3RRRRRRR	RR
RRRRRRRR\         R3/pVP                  RVP                  RR4      4      p/ pVP                  R4       F  pVP                  4       '       g   K  VP                  R^4      pV^ ,          P                  4       p W',          w  rT'       d	   T	'       g   RYG&   T'       g   Km   T! T^,          P                  4       4      YG&   K  	  V#   \         d    \
        P                  RT4        K  i ; i  \         d&    T	'       d   \
        P                  RT4        K   K  \         d'    \
        P                  RTTP                  4        EK  i ; i)max-ageTz	max-staleF	min-freshno-cacheNno-storezno-transformzonly-if-cachedzmust-revalidatepublicprivatezproxy-revalidatezs-maxagezcache-controlzCache-Control ,=z,Ignoring unknown cache-control directive: %sz-Missing value for cache-control directive: %sz8Invalid value for cache-control directive %s, must be %s)NF)
intgetsplitstripKeyErrorloggerdebug
IndexError
ValueError__name__)
r.   rH   known_directives
cc_headersretvalcc_directiveparts	directivetyprequireds
   &&        r   parse_cache_control#CacheController.parse_cache_controlY   s    T{#u#tMm}m}d
  [['++or2RS
(*&,,S1L%%'' &&sA.Ea(I 0 ;
 h$(!s(+E!HNN,<(=F%# 2> -  KYW " N%  
 " LLU! s6   -
C;D#;!D D #F6FF"FFc                    V ^8  d   QhRRRR/# )r   requestr   r   zHTTPResponse | Noner   )r   s   "r   r   r'      s       <O r   c                   RVP                   9   d   R# VP                  pVf   Q hV P                  P                  V4      pVf   \        P                  R4       R# \        V P                  \        4      '       d   V P                  P                  V4      pMRpV P                  P                  WV4      pVf   \        P                  R4       V# )z?
Load a cached response, or return None if it's not available.
RangeNzNo cache entry availablez1Cache entry deserialization failed, entry ignored)rH   urlr!   rT   rX   rY   
isinstancer	   get_bodyr$   loadswarning)r.   rh   rE   
cache_data	body_fileresults   &&    r   _load_from_cache CacheController._load_from_cache   s     goo%KK	$$$ZZ^^I.
LL34djj"788

++I6II&&wIF>NNNOr   c                    V ^8  d   QhRRRR/# )r   rh   r   r   zHTTPResponse | Literal[False]r   )r   s   "r   r   r'      s     l lo l:W lr   c                   VP                   f   Q hV P                  VP                   4      p\        P                  RV4       V P	                  VP
                  4      pRV9   d   \        P                  R4       R# RV9   d&   VR,          ^ 8X  d   \        P                  R4       R# V P                  V4      pV'       g   R# \        VP                  4      \        9   d   Rp\        P                  V4       V# \        VP
                  4      pV'       d   RV9  dO   R	V9  d1   \        P                  R
4       V P                  P                  V4       \        P                  R4       R# \        P                  ! 4       p\        VR,          4      pVf   Q h\        P                   ! VR,          4      p	\#        ^ Wy,
          4      p
\        P                  RV
4       V P	                  V4      p^ pVP%                  R4      pVe   Tp\        P                  RV4       McRV9   d]   \        VR,          4      pVeG   \        P                   ! VR,          4      V	,
          p\#        ^ V4      p\        P                  RV4       VP%                  R4      pVe   Tp\        P                  RV4       VP%                  R4      pVe    V
V,          p
\        P                  RV
4       W8  d.   \        P                  R4       \        P                  RW4       V# R	V9  d1   \        P                  R4       V P                  P                  V4       R# )zM
Return a cached response if it exists in the cache, otherwise
return False.
zLooking up "%s" in the cacherL   z-Request header has "no-cache", cache bypassedFrJ   z1Request header has "max_age" as 0, cache bypassedzQReturning cached permanent redirect response (ignoring date and etag information)dateetagz(Purging cached response: no date or etagz!Ignoring cached response: no dateN   NzCurrent age based on date: %iz#Freshness lifetime from max-age: %iexpiresz#Freshness lifetime from expires: %iz+Freshness lifetime from request max-age: %irK   z'Adjusted current age from min-fresh: %iz2The response is "fresh", returning cached responsez%i > %iz4The cached response is "stale" with no etag, purging)rk   rE   rX   rY   re   rH   rs   rS   statusPERMANENT_REDIRECT_STATUSESr   r!   deletetimer   calendartimegmmaxrT   )r.   rh   rE   ccrespmsgrH   now
time_tuplerw   current_ageresp_ccfreshness_lifetimemax_ager{   expire_time	min_freshs   &&               r   cached_requestCacheController.cached_request   s   
 {{&&&NN7;;/	3Y?%%goo6 LLHI?r)}1LLLM $$W- t{{::7  LLK,?,M&/W$ GH

!!),LL<=iik!'&/2
%%%z"~.!SZ(4kB **73  ++i(!(LL>@RS '!"79#56G"&oogbk:TA%(K%8"BDVW &&#!(LL=?Q FF;'	 9$KLLBKP +LLMNLL$6DK  LLOPJJi( r   c                    V ^8  d   QhRRRR/# )r   rh   r   r   zdict[str, str]r   )r   s   "r   r   r'     s      ? ~ r   c                	    V P                  V4      p/ pV'       d<   \        VP                  4      pR V9   d   VR,          VR&   RV9   d   VR,          VR&   V# )rx   ETagzIf-None-Matchzlast-modifiedzLast-ModifiedzIf-Modified-Since)rs   r   rH   )r.   rh   r   new_headersrH   s   &&   r   conditional_headers#CacheController.conditional_headers  s\    $$W-0CDLL0QG /6vO,')3:?3K/0r   c               0    V ^8  d   QhRRRRRRRRR	R
RR/# )r   rE   r   rh   r   responser   bodybytes | Noneexpires_timez
int | Noner   Noner   )r   s   "r   r   r'   &  sF       ! 	
  ! 
r   c                l   \        V P                  \        4      '       d\   V P                  P                  VV P                  P                  W#R4      VR7       Ve   V P                  P                  W4       R# R# V P                  P                  VV P                  P                  W#V4      VR7       R# )z
Store the data in the cache.
r   )r{   N)rl   r!   r	   setr$   dumpsset_body)r.   rE   rh   r   r   r   s   &&&&&&r   
_cache_setCacheController._cache_set&  s     djj"788 JJNN%%g=$   

##I4   JJNN%%g>$  r   c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# )r   rh   r   response_or_refz2HTTPResponse | weakref.ReferenceType[HTTPResponse]r   r   r%   r&   r   r   r   )r   s   "r   r   r'   D  sD     Q Q Q LQ 	Q
 -Q 
Qr   c                   \        V\        P                  4      '       d   V! 4       pVf   R# MTpT;'       g    V P                  pVP                  V9  d$   \
        P                  RVP                  V4       R# \        VP                  4      pRV9   d7   \        VR,          4      pVf   Q h\        P                  ! VR,          4      p	M^ p	VeG   RV9   d@   VR,          P                  4       '       d#   \        VR,          4      \        V4      8w  d   R# V P                  VP                  4      p
V P                  V4      pVP                   f   Q hV P#                  VP                   4      p\
        P                  RV4       RpRV9   d   R	p\
        P                  R
4       RV
9   d   R	p\
        P                  R4       V'       dR   V P$                  P'                  V4      '       d1   \
        P                  R4       V P$                  P)                  V4       V'       d   R# RVP'                  RR4      9   d   \
        P                  R4       R# V P*                  '       d   RV9   d   ^ pVP'                  R4      '       d;   \        VR,          4      pVe%   \        P                  ! VR,          4      V	,
          p\-        VR4      p\
        P                  RV R24       \
        P                  R4       V P/                  WWSV4       R# \        VP                  4      \0        9   d+   \
        P                  R4       V P/                  WVR4       R# RV9   Ed   \        VR,          4      pVf   Q h\        P                  ! VR,          4      p	VP'                  R4      pVe6   V^ 8  d/   \
        P                  R4       TpV P/                  VVVVV4       R# RV9   d   VR,          '       dy   \        VR,          4      pVe&   \        P                  ! VR,          4      V	,
          pMRp\
        P                  RP3                  V4      4       V P/                  VVVVV4       R# R# R# R# )zK
Algorithm for caching requests.

This assumes a requests Response object.
NzStatus code %s not in %srw   ry   content-lengthz&Updating cache with response from "%s"FrM   TzResponse header has "no-store"zRequest header has "no-store"z0Purging existing cache entry to honor "no-store"*varyrP   zResponse header has "Vary: *"rx   r{   zetag object cached for z secondszCaching due to etagzCaching permanent redirectr   rJ   z'Caching b/c date exists and max-age > 0z4Caching b/c of expires header. expires in {} secondsi u )rl   weakrefReferenceTyper-   r|   rX   rY   r   rH   r   r   r   isdigitrS   lenre   rk   rE   r!   rT   r~   r"   r   r   r}   r   )r.   rh   r   r   r%   r   r-   response_headersr   rw   cc_reqr   rE   no_storer   r{   r   s   &&&&&            r   cache_responseCacheController.cache_responseD  s    ow'<'<==&(H 	   'H ".!L!L1L1L??"88LL*HOO=S 5H6
 %%%&6v&>?J)))??:b>2DD  $44 !12::<<$%5673t9D))'//:%%&67{{&&&NN7;;/	=yI HLL9:HLL89

y11LLKLJJi( "&&vr22LL89 *: :L##I..&'7	'BC&#+??72;#?$#FL|Z8LLL2<.IJLL./OOIM !%@@LL56OOI#>
 ''%&6v&>?J)))??:b>2DffY'G"w{FG&  ..#I..*+;I+FGG*'/wr{'Cd'J'+LLNUU(
 OO! $ / /' (r   c               $    V ^8  d   QhRRRRRR/# )r   rh   r   r   r   r   r   )r   s   "r   r   r'     s$     ( (&(2>(	(r   c                   VP                   f   Q hV P                  VP                   4      pV P                  V4      pV'       g   V# R.pVP                  P	                  VP                  P                  4        UUu/ uF  w  rgVP                  4       V9  g   K  WgbK   	  upp4       ^Vn        V P                  W1V4       V# u uppi )zOn a 304 we will get a new set of headers that we want to
update our cached value with, assuming we have one.

This should only ever be called when we've sent an ETag and
gotten a 304 as the response.
r   )	rk   rE   rs   rH   updateitemsr7   r|   r   )r.   rh   r   rE   cached_responseexcluded_headerskvs   &&&     r   update_cached_response&CacheController.update_cached_response  s     {{&&&NN7;;/	//8O --&& %,,2244DA779$44 4	
 "% 		O<s   <C
C
)r!   r"   r-   r$   )NTNN)NN)r\   
__module____qualname____firstlineno____doc__r/   classmethodrA   rE   re   rs   r   r   r   r   r   __static_attributes__r   r   r   r   r   2   s`    >
P  & ! !4l4l\<Qf( (r   r   )r+   r,   )#r   
__future__r   r   loggingrer   r   email.utilsr   typingr   r   r   pip._vendor.requests.structuresr   pip._vendor.cachecontrol.cacher   r	   "pip._vendor.cachecontrol.serializer
   r   pip._vendor.requestsr   pip._vendor.urllib3r   r   	getLoggerr\   rX   compiler   r}   r   r   r   r   r   <module>r      sv   
 #   	   $ 5 5 ? K 9408			8	$jjMN( CM Mr   