
    /j]                        S SK Jr  S SKrS SKJrJrJr  S SKJr  \R                  " S5      r
\R                  " S5      rSS jrSS jrSS	 jr        SS
 jrSS jrg)    )annotationsN)AnyMappingCallablequotez^(?:\.|%2[eE]){1,2}$z	\{(\w+)\}c                    [        U SS9$ )u   Percent-encode `value` for use in a URI path segment.

Considers characters not in `pchar` set from RFC 3986 §3.3 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
z!$&'()*+,;=:@safer   values    D/app/agent/.venv/lib/python3.13/site-packages/openai/_utils/_path.py_quote_path_segment_partr      s     _--    c                    [        U SS9$ )u   Percent-encode `value` for use in a URI query string.

Considers &, = and characters not in `query` set from RFC 3986 §3.4 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.4
z!$'()*+,;:@/?r
   r   r   s    r   _quote_query_partr      s     _--r   c                    [        U SS9$ )u   Percent-encode `value` for use in a URI fragment.

Considers characters not in `fragment` set from RFC 3986 §3.5 to be unsafe.
https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
z!$&'()*+,;=:@/?r
   r   r   s    r   _quote_fragment_partr   &   s     .//r   c                D   [         R                  U 5      n[        S[        U5      S5       Ha  nX4   nXQ;  a  [	        SU S35      eX   nUc  SX4'   M(  [        U[        5      (       a  U(       a  SOSX4'   ML  U" [        X   5      5      X4'   Mc     SR                  U5      $ )	zReplace {name} placeholders in `template`, quoting each value with `quoter`.

Placeholder names are looked up in `values`.

Raises:
    KeyError: If a placeholder is not found in `values`.
      za value for placeholder {z} was not providednulltruefalse )	_PLACEHOLDER_REsplitrangelenKeyError
isinstanceboolstrjoin)templatevaluesquoterpartsinamevals          r   _interpolater,   /   s     !!(+E1c%j!$x7v=PQRRl;EHT""!$v'EHc&,/0EH % 775>r   c                  SnSnU nSU;   a  UR                  SS5      u  pBSU;   a  UR                  SS5      u  pCUn[        XQ[        5      nUR                  S5       H1  n[        R	                  U5      (       d  M  [        SU< SU< S35      e   UnUb  US[        X1[        5      -   -  nUb  US[        X![        5      -   -  nU$ )	uS  Interpolate {name} placeholders in `template` from keyword arguments.

Args:
    template: The template string containing {name} placeholders.
    **kwargs: Keyword arguments to interpolate into the template.

Returns:
    The template with placeholders interpolated and percent-encoded.

    Safe characters for percent-encoding are dependent on the URI component.
    Placeholders in path and fragment portions are percent-encoded where the `segment`
    and `fragment` sets from RFC 3986 respectively are considered safe.
    Placeholders in the query portion are percent-encoded where the `query` set from
    RFC 3986 §3.3 is considered safe except for = and & characters.

Raises:
    KeyError: If a placeholder is not found in `kwargs`.
    ValueError: If resulting path contains /./ or /../ segments (including percent-encoded dot-segments).
N#r   ?/zConstructed path z contains dot-segment z which is not allowed)r   r,   r   _DOT_SEGMENT_REmatch
ValueErrorr   r   )	r%   kwargsfragment_templatequery_templaterestpath_templatepath_resultsegmentresults	            r   r8   r8   N   s    * %)!%ND
d{"&**S!"4
d{#zz#q1M }6NOK $$S)  ))0?UV]U``uvww * F!#^=NOOO$#%6@TUUUMr   )r   r#   returnr#   )r%   r#   r&   zMapping[str, Any]r'   zCallable[[str], str]r<   r#   )r%   r#   r4   r   r<   r#   )
__future__r   retypingr   r   r   urllib.parser   compiler1   r   r   r   r   r,   r8    r   r   <module>rC      sv    " 	 
  **45**\*	..0 ! 		>1r   