§
    }Štj¾³  ã                   ó„  — U d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZ ddlmZ ddlmZ ddlmZ ddlmZmZ ddlmZ ddlZdd	lmZ d
dlmZ d
dlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z& ddlm'Z' ddl(m)Z) ddl*m+Z+  e'j,        e-¦  «        Z. ed¬¦  «         G d„ d¦  «        ¦   «         Z/ ej0        d¦  «        Z1 ej0        d¦  «        Z2dee3e3f         de/dz  fd„Z4dee3e3f         de5dz  fd„Z6dZ7dZ8dZ9 ej0        dej:        ¬¦  «        Z; ej0        d ej:        ¬¦  «        Z< ej0        d!¦  «        Z= ej0        d"¦  «        Z> ej0        d#¦  «        Z?h d$£Z@d%e3deAe3dz  e3dz  f         fd&„ZBd%e3de3dz  fd'„ZCd%e3de3dz  fd(„ZDd)ejE        ddfd*„ZFd)ejE        ddfd+„ZGd,ejH        ddfd-„ZIdejJ        fd.„ZKdejL        fd/„ZMe
g ejJ        f         ZNe
g ejL        f         ZO ejP        ¦   «         ZQeKaReNeSd0<   eMaTeOeSd1<   daUejJ        dz  eSd2<   d3eNddfd4„ZVd5eOddfd6„ZWdejJ        fd7„ZXdejL        fd8„ZYdfd9„ZZ ej[        eZ¦  «          e\ed:¦  «        r ej]        eZ¬;¦  «         ej^        ej_        ej`        fZaeAebec         d<f         eSd=<   d>ZdeAe5d<f         eSd?<   d@ddAeaeddBdCœdDe+d%e3dEe5dFeedGeedHebec         eAebec         d<f         z  dIe5eAe5d<f         z  dJefdeejH        ddf         fdK„Zgd@ddAeaeddLœdDe+d%e3dEe5dFeedGeedHebec         eAebec         d<f         z  dIe5eAe5d<f         z  dejH        fdM„Zhed@ddAeaeddLœdDe+d%e3dEe5dFeedGeedHebec         eAebec         d<f         z  dIe5eAe5d<f         z  deejH        ddf         fdN„¦   «         ZidBdOœdDe+d%e3dPefdejH        fdQ„Zjd%e3dRe3dz  de3fdS„Zkdgd,ejH        dTe3dz  ddfdU„Zl em¦   «         Znd,ejH        ddfdV„Zo edWe"¬X¦  «        ZpdYebep         dZe3d,ejH        d[edepf
d\„Zqd]Zrd^„ erD ¦   «         Zsd_e3de3fd`„Ztd)ejE        de3fda„Zu ej0        dbejv        ¦  «        Zwdce3dz  dde5de3dz  fde„ZxdS )hz>Contains utilities to handle HTTP requests in huggingface_hub.é    N)ÚCallableÚ	GeneratorÚMapping)Úcontextmanager)Ú	dataclass)Úquote)ÚAnyÚTypeVar)Úurlparse)ÚOfflineModeIsEnabledé   )Ú	constants)	ÚBadRequestErrorÚBucketNotFoundErrorÚDisabledRepoErrorÚGatedRepoErrorÚHfHubHTTPErrorÚJobNotFoundErrorÚRemoteEntryNotFoundErrorÚRepositoryNotFoundErrorÚRevisionNotFoundErroré   )Úlogging)ÚSliceFileObj)ÚHTTP_METHOD_TT)Úfrozenc                   óZ   — e Zd ZU dZeed<   eed<   eed<   dZedz  ed<   dZedz  ed<   dS )ÚRateLimitInfoaÿ  
    Parsed rate limit information from HTTP response headers.

    Attributes:
        resource_type (`str`): The type of resource being rate limited.
        remaining (`int`): The number of requests remaining in the current window.
        reset_in_seconds (`int`): The number of seconds until the rate limit resets.
        limit (`int`, *optional*): The maximum number of requests allowed in the current window.
        window_seconds (`int`, *optional*): The number of seconds in the current window.

    Úresource_typeÚ	remainingÚreset_in_secondsNÚlimitÚwindow_seconds)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__Úintr"   r#   © ó    úY/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/huggingface_hub/utils/_http.pyr   r   7   sg   € € € € € € ð
ð 
ð ÐÐÑØ€N€N�NØÐÐÑØ€Eˆ3�‰:ÐÐÑØ!%€N�C˜$‘JÐ%Ð%Ñ%Ð%Ð%r,   r   zL\"(?P<resource_type>\w+)\"\s*;\s*r\s*=\s*(?P<r>\d+)\s*;\s*t\s*=\s*(?P<t>\d+)z'q\s*=\s*(?P<q>\d+).*?w\s*=\s*(?P<w>\d+)ÚheadersÚreturnc                 ó`  — d}d}| D ]3}|                      ¦   «         }|dk    r	| |         }Œ%|dk    r| |         }Œ4|sdS t                               |¦  «        }|sdS |                     d¦  «        }t	          |                     d¦  «        ¦  «        }t	          |                     d¦  «        ¦  «        }d}	d}
|r`t
                               |¦  «        }|rDt	          |                     d¦  «        ¦  «        }	t	          |                     d¦  «        ¦  «        }
t          ||||	|
¬	¦  «        S )
a*  Parse rate limit information from HTTP response headers.

    Follows IETF draft: https://www.ietf.org/archive/id/draft-ietf-httpapi-ratelimit-headers-09.html
    Only a subset is implemented.

    Example:
    ```python
    >>> from huggingface_hub.utils import parse_ratelimit_headers
    >>> headers = {
    ...     "ratelimit": '"api";r=0;t=55',
    ...     "ratelimit-policy": '"fixed window";"api";q=500;w=300',
    ... }
    >>> info = parse_ratelimit_headers(headers)
    >>> info.remaining
    0
    >>> info.reset_in_seconds
    55
    ```
    NÚ	ratelimitzratelimit-policyr   ÚrÚtÚqÚw)r   r    r!   r"   r#   )ÚlowerÚ_RATELIMIT_REGEXÚsearchÚgroupr*   Ú_RATELIMIT_POLICY_REGEXr   )r.   r1   ÚpolicyÚkeyÚ	lower_keyÚmatchr   r    r!   r"   r#   Úpolicy_matchs               r-   Úparse_ratelimit_headersr@   S   sP  € ð* !€IØ€FØð "ð "ˆØ—I’I‘K”Kˆ	Ø˜Ò#Ð#Ø œˆIˆIØÐ,Ò,Ð,Ø˜S”\ˆFøàð Øˆtå×#Ò# IÑ.Ô.€EØð Øˆtà—K’K Ñ0Ô0€MÝ�E—K’K Ñ$Ô$Ñ%Ô%€IÝ˜5Ÿ;š; sÑ+Ô+Ñ,Ô,Ðà€EØ!%€Nàð :Ý.×5Ò5°fÑ=Ô=ˆØð 	:Ý˜×*Ò*¨3Ñ/Ô/Ñ0Ô0ˆEÝ  ×!3Ò!3°CÑ!8Ô!8Ñ9Ô9ˆNåØ#ØØ)ØØ%ðñ ô ð r,   c                 óÖ   — d}| D ]$}|                      ¦   «         dk    r
| |         } nŒ%|€dS |                     ¦   «         }|sdS |                     ¦   «         rt          |¦  «        S dS )a[  Parse the standard `Retry-After` HTTP header into a number of seconds to wait.

    The `Retry-After` header can be either a non-negative number of seconds (delay-seconds)
    or an HTTP-date after which to retry. We handle only the delay-seconds case.

    See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Retry-After.
    Nzretry-after)r6   ÚstripÚisdigitr*   )r.   Úvaluer<   s      r-   Ú_parse_retry_afterrE   Ž   s…   € ð €EØð ð ˆØ�9Š9‰;Œ;˜-Ò'Ð'Ø˜C”LˆEØˆEð (ð €}ØˆtØ�KŠK‰MŒM€EØð Øˆtà‡}‚}�„ð Ý�5‰zŒzÐØˆ4r,   zx-request-idzX-Amzn-Trace-Idzx-amz-cf-ida  
        # staging or production endpoint
        ^https://[^/]+
        (
            # on /api/repo_type/repo_id
            /api/(models|datasets|spaces)/(.+)
            |
            # or /repo_id/resolve/revision/...
            /(.+)/resolve/(.+)
        )
    )Úflagszz
        # staging or production endpoint
        ^https?://[^/]+
        # on /api/buckets/...
        /api/buckets/
    z:^https?://[^/]+/api/(?:scheduled-jobs|jobs)/[^/]+/([^/?]+)zA^https?://[^/]+/api/(models|datasets|spaces)/([^/]+)(?:/([^/]+))?z)^https?://[^/]+/api/buckets/([^/]+/[^/]+)>	   ÚrawÚblobÚrefsÚtreeÚcommitÚresolveÚrevisionÚsettingsÚdiscussionsÚurlc                 ó(  — t                                | ¦  «        }|sdS t          j                             |                     d¦  «        ¦  «        }|                     d¦  «        |                     d¦  «        }}|r|t          vr|› d|› �}n|}||fS )a,  Extract (repo_type, repo_id) from an API URL.

    Returns canonical repo_type values: "model", "dataset", "space" (or None).

    Examples:
        >>> _parse_repo_info_from_url("https://huggingface.co/api/models/user/repo")
        ("model", "user/repo")
        >>> _parse_repo_info_from_url("https://huggingface.co/api/datasets/user/repo/resolve/main/data.csv")
        ("dataset", "user/repo")
        >>> _parse_repo_info_from_url("https://huggingface.co/api/models/bert-base-cased/resolve/main/config.json")
        ("model", "bert-base-cased")
    ©NNr   r   é   ú/)Ú_REPO_ID_FROM_URL_REGEXr8   r   ÚREPO_TYPES_MAPPINGÚgetr9   Ú_REPO_URL_SUBPATHS)rP   r>   Ú	repo_typeÚfirstÚsecondÚrepo_ids         r-   Ú_parse_repo_info_from_urlr]   Õ   s™   € õ $×*Ò*¨3Ñ/Ô/€EØð ØˆzÝÔ,×0Ò0°·²¸Q±´Ñ@Ô@€IØ—K’K ‘N”N E§K¢K°¡N¤Nˆ6€EØð �&Õ 2Ð2Ð2ØÐ%Ð%˜VÐ%Ð%ˆˆàˆØ�gÐÐr,   c                 óh   — t                                | ¦  «        }|r|                     d¦  «        ndS )z9Extract bucket_id (namespace/name) from a bucket API URL.r   N)Ú_BUCKET_ID_FROM_URL_REGEXr8   r9   ©rP   r>   s     r-   Ú_parse_bucket_id_from_urlra   î   s.   € å%×,Ò,¨SÑ1Ô1€EØ"Ð,ˆ5�;Š;�q‰>Œ>ˆ>¨Ð,r,   c                 óh   — t                                | ¦  «        }|r|                     d¦  «        ndS )z>Extract the job_id from a (scheduled) job API URL, if present.r   N)Ú_JOB_ID_FROM_URL_REGEXr8   r9   r`   s     r-   Ú_parse_job_id_from_urlrd   ô   s.   € å"×)Ò)¨#Ñ.Ô.€EØ"Ð,ˆ5�;Š;�q‰>Œ>ˆ>¨Ð,r,   Úrequestc           	      ó:  — t          j        ¦   «         rt          d| j        › d�¦  «        ‚t          | j        vrL| j                             t          ¦  «        pt          t          j
        ¦   «         ¦  «        | j        t          <   | j                             t          ¦  «        }t                               d|| j        | j        | j                             d¦  «        du¦  «         t           j        r(t                               dt          | ¦  «        ¦  «         |S )zõ
    Event hook that will be used to make HTTP requests to the Hugging Face Hub.

    What it does:
    - Block requests if offline mode is enabled
    - Add a request ID to the request headers
    - Log the request if debug mode is enabled
    zCannot reach za: offline mode is enabled. To disable it, please unset the `HF_HUB_OFFLINE` environment variable.z%Request %s: %s %s (authenticated: %s)ÚauthorizationNzSend: %s)r   Úis_offline_moder   rP   ÚX_AMZN_TRACE_IDr.   rW   ÚX_REQUEST_IDr(   ÚuuidÚuuid4ÚloggerÚdebugÚmethodÚHF_DEBUGÚ_curlify)re   Ú
request_ids     r-   Úhf_request_event_hookrs   ú   s
  € õ Ô Ñ"Ô"ð 
Ý"ð K˜GœKð  Kð  Kð  Kñ
ô 
ð 	
õ
 ˜gœoÐ-Ð-Ø+2¬?×+>Ò+>½|Ñ+LÔ+LÐ+aÕPSÕTXÔT^ÑT`ÔT`ÑPaÔPaˆŒ�Ñ(Ø”×$Ò$¥_Ñ5Ô5€Jõ ‡L‚LØ/ØØŒØŒØŒ×Ò˜OÑ,Ô,°DÐ8ñô ð õ Ôð 4Ý�Š�Z¥¨'Ñ!2Ô!2Ñ3Ô3Ð3àÐr,   c              ƒ   ó$   K  — t          | ¦  «        S )z3
    Async version of `hf_request_event_hook`.
    )rs   )re   s    r-   Úasync_hf_request_event_hookru     s   è è € õ ! Ñ)Ô)Ð)r,   Úresponsec              ƒ   óØ   K  — | j         dk    rXd| j        v rQ	 t          | j        d         ¦  «        }n# t          $ r Y d S w xY w|dk     r |                      ¦   «         ƒ d {V —† d S d S d S d S )Né�  zContent-lengthi@B )Ústatus_coder.   r*   Ú
ValueErrorÚaread)rv   Úlengths     r-   Úasync_hf_response_event_hookr}   "  s°   è è € ØÔ˜sÒ"Ð"ð ˜xÔ/Ð/Ð/ðÝ˜XÔ-Ð.>Ô?Ñ@Ô@��øÝð ð ð Ø��ðøøøð ˜	Ò!Ð!Ø—n’nÑ&Ô&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ð&ð #Ð"ð 0Ð/ð "Ð!s   ˜3 ³
AÁ Ac                  ó@   — t          j        dt          gidd¬¦  «        S )zQ
    Factory function to create a `httpx.Client` with the default transport.
    re   TN©Úevent_hooksÚfollow_redirectsÚtimeout)ÚhttpxÚClientrs   r+   r,   r-   Údefault_client_factoryr…   0  s/   € õ Œ<ØÕ!6Ð 7Ð8ØØðñ ô ð r,   c                  óN   — t          j        t          gt          gdœdd¬¦  «        S )zV
    Factory function to create a `httpx.AsyncClient` with the default transport.
    )re   rv   TNr   )rƒ   ÚAsyncClientru   r}   r+   r,   r-   Údefault_async_client_factoryrˆ   ;  s6   € õ ÔÝ!<Ð =ÕLhÐKiÐjÐjØØðñ ô ð r,   Ú_GLOBAL_CLIENT_FACTORYÚ_GLOBAL_ASYNC_CLIENT_FACTORYÚ_GLOBAL_CLIENTÚclient_factoryc                 óf   — t           5  t          ¦   «          | addd¦  «         dS # 1 swxY w Y   dS )a  
    Set the HTTP client factory to be used by `huggingface_hub`.

    The client factory is a method that returns a `httpx.Client` object. On the first call to [`get_session`] the client factory
    will be used to create a new `httpx.Client` object that will be shared between all calls made by `huggingface_hub`.

    This can be useful if you are running your scripts in a specific environment requiring custom configuration (e.g. custom proxy or certifications).

    Use [`get_session`] to get a correctly configured `httpx.Client`.
    N)Ú_CLIENT_LOCKÚclose_sessionr‰   )rŒ   s    r-   Úset_client_factoryr�   O  s}   € õ 
ð 0ð 0Ý‰ŒˆØ!/Ðð0ð 0ð 0ñ 0ô 0ð 0ð 0ð 0ð 0ð 0ð 0ð 0øøøð 0ð 0ð 0ð 0ð 0ð 0s   ˆ&¦*­*Úasync_client_factoryc                 ó
   — | a dS )až  
    Set the HTTP async client factory to be used by `huggingface_hub`.

    The async client factory is a method that returns a `httpx.AsyncClient` object.
    This can be useful if you are running your scripts in a specific environment requiring custom configuration (e.g. custom proxy or certifications).
    Use [`get_async_client`] to get a correctly configured `httpx.AsyncClient`.

    > [!WARNING]
    > Contrary to the `httpx.Client` that is shared between all calls made by `huggingface_hub`, the `httpx.AsyncClient` is not shared.
    > It is recommended to use an async context manager to ensure the client is properly closed when the context is exited.
    N©rŠ   )r‘   s    r-   Úset_async_client_factoryr”   `  s   € ð $8Ð Ð Ð r,   c                  óx   — t           €-t          5  t          ¦   «         a ddd¦  «         n# 1 swxY w Y   t           S )a  
    Get a `httpx.Client` object, using the transport factory from the user.

    This client is shared between all calls made by `huggingface_hub`. Therefore you should not close it manually.

    Use [`set_client_factory`] to customize the `httpx.Client`.
    N)r‹   rŽ   r‰   r+   r,   r-   Úget_sessionr–   p  sv   € õ ÐÝð 	6ð 	6Ý3Ñ5Ô5ˆNð	6ð 	6ð 	6ñ 	6ô 	6ð 	6ð 	6ð 	6ð 	6ð 	6ð 	6øøøð 	6ð 	6ð 	6ð 	6åÐs   �*ª.±.c                  ó   — t          ¦   «         S )a»  
    Return a `httpx.AsyncClient` object, using the transport factory from the user.

    Use [`set_async_client_factory`] to customize the `httpx.AsyncClient`.

    > [!WARNING]
    > Contrary to the `httpx.Client` that is shared between all calls made by `huggingface_hub`, the `httpx.AsyncClient` is not shared.
    > It is recommended to use an async context manager to ensure the client is properly closed when the context is exited.
    r“   r+   r,   r-   Úget_async_sessionr˜     s   € õ (Ñ)Ô)Ð)r,   c                  ó´   — t           } da | �L	 |                      ¦   «          dS # t          $ r(}t                               d|› �¦  «         Y d}~dS d}~ww xY wdS )zÚ
    Close the global `httpx.Client` used by `huggingface_hub`.

    If a Client is closed, it will be recreated on the next call to [`get_session`].

    Can be useful if e.g. an SSL certificate has been updated.
    NzError closing client: )r‹   ÚcloseÚ	Exceptionrm   Úwarning)ÚclientÚes     r-   r�   r�   Œ  s‚   € õ €Fð €Nð Ðð	9Ø�LŠL‰NŒNˆNˆNˆNøÝð 	9ð 	9ð 	9Ý�NŠNÐ7°AÐ7Ð7Ñ8Ô8Ð8Ð8Ð8Ð8Ð8Ð8Ð8øøøøð	9øøøð Ðs   �# £
A­AÁAÚregister_at_fork)Úafter_in_child.Ú_DEFAULT_RETRY_ON_EXCEPTIONS)i˜  é­  iô  iö  i÷  iø  Ú_DEFAULT_RETRY_ON_STATUS_CODESé   é   F)Úmax_retriesÚbase_wait_timeÚmax_wait_timeÚretry_on_exceptionsÚretry_on_status_codesÚstreamro   r¦   r§   r¨   r©   rª   r«   c          	   +   ó`  ‡ ‡‡‡‡‡K  — t          |t          ¦  «        r|f}t          ‰t          ¦  «        r‰fŠdŠ|}	dŠd}
d|v rAt          |d         t          j        t
          f¦  «        r|d                              ¦   «         }
t          ¦   «         }	 ‰dz  ŠdŠ	 |
�|d                              |
¦  «         dt          j
        dt          fˆˆ ˆˆˆˆfd„}|rG |j        d‰ ‰d	œ|¤Ž5 } ||¦  «        s|V — 	 ddd¦  «         dS 	 ddd¦  «         n# 1 swxY w Y   n! |j        d‰ ‰d	œ|¤Ž} ||¦  «        s|V — dS ne# |$ r]}t                               d
|› d‰ › d‰› �¦  «         t          |t          j        ¦  «        rt#          ¦   «          ‰‰k    r|‚Y d}~nd}~ww xY w‰�7t%          ‰¦  «        dz   }t                               d|› d‰› d‰› d�¦  «         n&|	}t                               d|› d‰› d‰› d�¦  «         t'          j        |¦  «         t+          ||	dz  ¦  «        }	�Œ›)zfInternal implementation of HTTP backoff logic shared between `http_backoff` and `http_stream_backoff`.r   NÚdataTr   rv   r/   c                 ó  •— | j         ‰vrdS t                               d| j         › d‰› d‰› �¦  «         ‰‰k    rt          | ¦  «         dS | j         dk    rt	          | j        ¦  «        x}�|j        Šnt          | j        ¦  «        x}�|ŠdS )zNHandle response and return True if should retry, False if should return/yield.FzHTTP Error z thrown while requesting ú r¢   NT)ry   rm   rœ   Úhf_raise_for_statusr@   r.   r!   rE   )	rv   Úratelimit_infoÚretry_afterr¦   ro   Únb_triesÚratelimit_resetrª   rP   s	      €€€€€€r-   Ú_should_retryz)_http_backoff_base.<locals>._should_retryØ  s»   ø€ ð Ô'Ð/DÐDÐDØ ˜5õ —’Ðj¨XÔ-AÐjÐjÐ\bÐjÐjÐehÐjÐjÑkÔkÐkØ˜kÒ)Ð)Ý'¨Ñ1Ô1Ð1ð !˜5ð Ô(¨CÒ/Ð/Ý+BÀ8ÔCSÑ+TÔ+TÐT˜Ðaà&4Ô&E�O�OÝ%7¸Ô8HÑ%IÔ%IÐI�kÐVØ&1�Oà�tr,   ©ro   rP   ú'z' thrown while requesting r¯   zRate limited. Waiting zs before retry [Retry rT   z].zRetrying in z	s [Retry r   r+   )Ú
isinstanceÚtyper*   ÚioÚIOBaser   Útellr–   Úseekrƒ   ÚResponseÚboolr«   re   rm   rœ   ÚConnectErrorr�   ÚfloatÚtimeÚsleepÚmin)ro   rP   r¦   r§   r¨   r©   rª   r«   ÚkwargsÚ
sleep_timeÚio_obj_initial_posr�   rµ   rv   ÚerrÚactual_sleepr³   r´   s   ```   `         @@r-   Ú_http_backoff_baserÊ   ¯  s_  øøøøøøè è € õ Ð%¥tÑ,Ô,ð 5Ø2Ð4ÐåÐ'­Ñ-Ô-ð 9Ø!6Ð 8Ðà€HØ€JØ"&€Oð
 ÐØ�ÐÐ�J v¨f¤~½¼	Å<Ð7PÑQÔQÐØ# Fœ^×0Ò0Ñ2Ô2Ðå‰]Œ]€FðB8Ø�A‰ˆØˆð3	ð "Ð-Ø�v”×#Ò#Ð$6Ñ7Ô7Ð7ð­¬ð ½4ð ð ð ð ð ð ð ð ð ð ð ð4 ð 	Ø"�V”]ÐD¨&°cÐDÐD¸VÐDÐDð ÈØ(˜=¨Ñ2Ô2ð Ø&˜˜˜Øðð ð ñ ô ð ð ð ððð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð øð
 *˜6œ>ÐK°¸SÐKÐKÀFÐKÐK�Ø$�} XÑ.Ô.ð Ø"�N�N�NØ�Føøà"ð 	ð 	ð 	Ý�NŠNÐL˜sÐLÐL¸fÐLÐLÀsÐLÐLÑMÔMÐMå˜#�uÔ1Ñ2Ô2ð  Ý‘”�à˜+Ò%Ð%Ø�	ð &Ð%Ð%Ð%Ð%øøøøð	øøøð Ð&Ý  Ñ1Ô1°AÑ5ˆLÝ�NŠNÐr°LÐrÐrÐX`ÐrÐrÐcnÐrÐrÐrÑsÔsÐsÐsà%ˆLÝ�NŠNÐ[¨,Ð[Ð[ÀÐ[Ð[ÈKÐ[Ð[Ð[Ñ\Ô\Ð\åŒ
�<Ñ Ô Ð õ ˜¨
°Q©Ñ7Ô7ˆ
ñEB8sD   ÂAE Ã*DÃ;E Ä	E ÄDÄE ÄDÄ#E ÅF%ÅAF Æ F%)r¦   r§   r¨   r©   rª   c                óF   — t          t          d| ||||||ddœ|¤Ž¦  «        S )a_  Wrapper around httpx to retry calls on an endpoint, with exponential backoff.

    Endpoint call is retried on exceptions (ex: connection timeout, proxy error,...)
    and/or on specific status codes (ex: service unavailable). If the call failed more
    than `max_retries`, the exception is thrown or `raise_for_status` is called on the
    response object.

    Re-implement mechanisms from the `backoff` library to avoid adding an external
    dependencies to `hugging_face_hub`. See https://github.com/litl/backoff.

    Args:
        method (`Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"]`):
            HTTP method to perform.
        url (`str`):
            The URL of the resource to fetch.
        max_retries (`int`, *optional*, defaults to `5`):
            Maximum number of retries, defaults to 5. Set to `0` to disable retries.
        base_wait_time (`float`, *optional*, defaults to `1`):
            Duration (in seconds) to wait before retrying the first time.
            Wait time between retries then grows exponentially, capped by
            `max_wait_time`.
        max_wait_time (`float`, *optional*, defaults to `8`):
            Maximum duration (in seconds) to wait before retrying.
        retry_on_exceptions (`type[Exception]` or `tuple[type[Exception]]`, *optional*):
            Define which exceptions must be caught to retry the request. Can be a single type or a tuple of types.
            By default, retry on `httpx.TimeoutException`, `httpx.NetworkError` and `httpx.RemoteProtocolError`.
        retry_on_status_codes (`int` or `tuple[int]`, *optional*, defaults to `(429, 500, 502, 503, 504)`):
            Define on which status codes the request must be retried. By default, retries
            on rate limit (429) and server errors (5xx).
        **kwargs (`dict`, *optional*):
            kwargs to pass to `httpx.request`.

    Example:
    ```
    >>> from huggingface_hub.utils import http_backoff

    # Same usage as "httpx.request".
    >>> response = http_backoff("GET", "https://www.google.com")
    >>> response.raise_for_status()

    # If you expect a Gateway Timeout from time to time
    >>> http_backoff("PUT", upload_url, data=data, retry_on_status_codes=504)
    >>> response.raise_for_status()
    ```

    > [!WARNING]
    > When using `requests` it is possible to stream data by passing an iterator to the
    > `data` argument. On http backoff this is a problem as the iterator is not reset
    > after a failed call. This issue is mitigated for file objects or any IO streams
    > by saving the initial position of the cursor (with `data.tell()`) and resetting the
    > cursor between each call (with `data.seek()`). For arbitrary iterators, http backoff
    > will fail. If this is a hard constraint for you, please let us know by opening an
    > issue on [Github](https://github.com/huggingface/huggingface_hub).
    F©ro   rP   r¦   r§   r¨   r©   rª   r«   r+   )ÚnextrÊ   ©ro   rP   r¦   r§   r¨   r©   rª   rÅ   s           r-   Úhttp_backoffrÏ     sP   € õB Ýð 
	
ØØØ#Ø)Ø'Ø 3Ø"7Øð
	
ð 
	
ð ð
	
ð 
	
ñô ð r,   c             +   ó@   K  — t          d| ||||||ddœ|¤ŽE d{V —† dS )a¶  Wrapper around httpx to retry calls on an endpoint, with exponential backoff.

    Endpoint call is retried on exceptions (ex: connection timeout, proxy error,...)
    and/or on specific status codes (ex: service unavailable). If the call failed more
    than `max_retries`, the exception is thrown or `raise_for_status` is called on the
    response object.

    Re-implement mechanisms from the `backoff` library to avoid adding an external
    dependencies to `hugging_face_hub`. See https://github.com/litl/backoff.

    Args:
        method (`Literal["GET", "OPTIONS", "HEAD", "POST", "PUT", "PATCH", "DELETE"]`):
            HTTP method to perform.
        url (`str`):
            The URL of the resource to fetch.
        max_retries (`int`, *optional*, defaults to `5`):
            Maximum number of retries, defaults to 5. Set to `0` to disable retries.
        base_wait_time (`float`, *optional*, defaults to `1`):
            Duration (in seconds) to wait before retrying the first time.
            Wait time between retries then grows exponentially, capped by
            `max_wait_time`.
        max_wait_time (`float`, *optional*, defaults to `8`):
            Maximum duration (in seconds) to wait before retrying.
        retry_on_exceptions (`type[Exception]` or `tuple[type[Exception]]`, *optional*):
            Define which exceptions must be caught to retry the request. Can be a single type or a tuple of types.
            By default, retry on `httpx.TimeoutException`, `httpx.NetworkError` and `httpx.RemoteProtocolError`.
        retry_on_status_codes (`int` or `tuple[int]`, *optional*, defaults to `(429, 500, 502, 503, 504)`):
            Define on which status codes the request must be retried. By default, retries
            on rate limit (429) and server errors (5xx).
        **kwargs (`dict`, *optional*):
            kwargs to pass to `httpx.request`.

    Example:
    ```
    >>> from huggingface_hub.utils import http_stream_backoff

    # Same usage as "httpx.stream".
    >>> with http_stream_backoff("GET", "https://www.google.com") as response:
    ...     for chunk in response.iter_bytes():
    ...         print(chunk)

    # If you expect a Gateway Timeout from time to time
    >>> with http_stream_backoff("PUT", upload_url, data=data, retry_on_status_codes=504) as response:
    ...     response.raise_for_status()
    ```

    > [!WARNING]
    > When using `httpx` it is possible to stream data by passing an iterator to the
    > `data` argument. On http backoff this is a problem as the iterator is not reset
    > after a failed call. This issue is mitigated for file objects or any IO streams
    > by saving the initial position of the cursor (with `data.tell()`) and resetting the
    > cursor between each call (with `data.seek()`). For arbitrary iterators, http backoff
    > will fail. If this is a hard constraint for you, please let us know by opening an
    > issue on [Github](https://github.com/huggingface/huggingface_hub).
    TrÌ   Nr+   )rÊ   rÎ   s           r-   Úhttp_stream_backoffrÑ   c  so   è è € õF "ð 
ØØØØ%Ø#Ø/Ø3Øð
ð 
ð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
r,   )Úretry_on_errorsrÒ   c                óN  — |ri ndddœ}	 t          d| |dœ|¤ddi¤|¤Ž}t          |¦  «         d|j        cxk    rdk    rcn n`t          |j        d	         ¦  «        }|j        d
k    r;t          |¦  «                             |j        ¬¦  «                             ¦   «         }Œš	 |S )aF  Perform an HTTP request with backoff and follow relative redirects only.

    Used to fetch HEAD /resolve on repo or bucket files.

    This is useful to follow a redirection to a renamed repository without following redirection to a CDN.

    A backoff mechanism retries the HTTP call on errors (429, 5xx, timeout, network errors).

    Args:
        method (`str`):
            HTTP method, such as 'GET' or 'HEAD'.
        url (`str`):
            The URL of the resource to fetch.
        retry_on_errors (`bool`, *optional*, defaults to `False`):
            Whether to retry on errors. If False, no retry is performed (fast fallback to local cache).
            If True, uses default retry behavior (429, 5xx, timeout, network errors).
        **httpx_kwargs (`dict`, *optional*):
            Params to pass to `httpx.request`.
    r+   )r©   rª   Tr¶   r�   Fi,  i�  ÚLocationÚ )Úpath)	rÏ   r°   ry   r   r.   ÚnetlocÚ_replacerÖ   Úgeturl)ro   rP   rÒ   Úhttpx_kwargsÚno_retry_kwargsrv   Úparsed_targets          r-   Ú-_httpx_follow_relative_redirects_with_backoffrÝ   ³  sü   € ð0 Ð[ˆˆ¸2ÐXZÐ#[Ð#[ð ðÝð 
ØØð
ð 
ð ð
ð 
ð #ð	
ð 
ð
 ð
ð 
ˆõ 	˜HÑ%Ô%Ð%ð �(Ô&Ð-Ð-Ò-Ð-¨#Ò-Ð-Ð-Ð-Ð-Ý$ XÔ%5°jÔ%AÑBÔBˆMØÔ# rÒ)Ð)å˜s‘m”m×,Ò,°-Ô2DÐ,ÑEÔE×LÒLÑNÔN�Øð 	à€Or,   Úendpointc                 ó   — |r|                      d¦  «        nt          j        }|t          j        t          j        fvr@|                      t          j        |¦  «        } |                      t          j        |¦  «        } | S )z¤Replace the default endpoint in a URL by a custom one.

    This is useful when using a proxy and the Hugging Face Hub returns a URL with the default endpoint.
    rT   )Úrstripr   ÚENDPOINTÚ_HF_DEFAULT_ENDPOINTÚ_HF_DEFAULT_STAGING_ENDPOINTÚreplace)rP   rÞ   s     r-   Úfix_hf_endpoint_in_urlrå   æ  si   € ð
 (0ÐGˆx�Š˜sÑ#Ô#Ð#µYÔ5G€Hà�	Ô6½	Ô8^Ð_Ð_Ð_Ø�kŠk�)Ô8¸(ÑCÔCˆØ�kŠk�)Ô@À(ÑKÔKˆØ€Jr,   Úendpoint_namec           	      ó,	  — 	 t          | ¦  «         n,# t          $ r t                               dd¬¦  «         Y nw xY w	 |                      ¦   «          dS # t
          j        $ �r.}| j        dz  dk    rY d}~dS | j         	                    d¦  «        }| j         	                    d¦  «        }| j
        �%| j
        j        �t          | j
        j        ¦  «        nd}|rt          |¦  «        nd	\  }}|d
k    r3| j        › d�dz   d| j        › d�z   }t          t          || ||¬¦  «        |‚|dk    r3| j        › d�dz   d| j        › d�z   }t          t           || ||¬¦  «        |‚|dk    r3| j        › d�dz   d| j        › d�z   }t          t"          || ||¬¦  «        |‚|dk    r6| j        › d�dz   d| j        › d�z   dz   dz   }t          t$          || ¦  «        |‚|dk    ra|�_t&                               |¦  «        �E| j        › d�dz   d| j        › d�z   dz   dz   }t          t*          || t-          |¦  «        ¬¦  «        |‚| j        dk    rH|�Ft/          |¦  «        x}	�5| j        › d�dz   d| j        › d�z   dz   }t          t0          || |	¬¦  «        |‚|dk    s-| j        d k    r[|d!k    rU|�St2                               |¦  «        �9| j        › d�dz   d"| j        › d�z   d#z   d$z   }t          t4          || ||¬¦  «        |‚| j        d%k    r!|�d&|› d'�nd(}t          t6          || ¦  «        |‚| j        d)k    r4d| j        › d*|› d�d+| j        › d�z   d,z   }t          t8          || ¦  «        |‚| j        d-k    r’t;          | j        ¦  «        }
|
�Zd.|
j        › d/�}|d0|
j        › d1�z  }|
j         �&|
j!        �|d2|
j"        › d3|
j         › d4|
j!        › d5�z  }n|dz  }|d6| j        › d�z  }nd7| j        › d�}t          t8          || ¦  «        |‚| j        d8k    rY| j
        j         	                    d9¦  «        }|› d:|› d;| j         	                    d<¦  «        › d�}t          t8          || ¦  «        |‚t          t8          t          |¦  «        | ¦  «        |‚d}~ww xY w)=aÔ  
    Internal version of `response.raise_for_status()` that will refine a potential HTTPError.
    Raised exception will be an instance of [`~errors.HfHubHTTPError`].

    This helper is meant to be the unique method to raise_for_status when making a call to the Hugging Face Hub.

    Args:
        response (`Response`):
            Response from the server.
        endpoint_name (`str`, *optional*):
            Name of the endpoint that has been called. If provided, the error message will be more complete.

    > [!WARNING]
    > Raises when the request has failed:
    >
    >     - [`~utils.RepositoryNotFoundError`]
    >         If the repository to download from cannot be found. This may be because it
    >         doesn't exist, because `repo_type` is not set correctly, or because the repo
    >         is `private` and you do not have access.
    >     - [`~utils.GatedRepoError`]
    >         If the repository exists but is gated and the user is not on the authorized
    >         list.
    >     - [`~utils.RevisionNotFoundError`]
    >         If the repository exists but the revision couldn't be found.
    >     - [`~utils.EntryNotFoundError`]
    >         If the repository exists but the entry (e.g. the requested file) couldn't be
    >         find.
    >     - [`~utils.BadRequestError`]
    >         If request failed with a HTTP 400 BadRequest error.
    >     - [`~utils.HfHubHTTPError`]
    >         If request failed for a reason not listed above.
    zFailed to parse warning headersT)Úexc_infoéd   rS   NzX-Error-CodeúX-Error-MessagerR   ÚRevisionNotFoundz Client Error.ú

zRevision Not Found for url: ú.)rY   r\   ÚEntryNotFoundzEntry Not Found for url: Ú	GatedRepoz!Cannot access gated repo for url z$Access to this resource is disabled.z!Cannot access repository for url ú
ÚRepoNotFoundzBucket Not Found for url: zG
Please make sure you specified the correct bucket id (namespace/name).zg
If the bucket is private, make sure you are authenticated and your token has the required permissions.)Ú	bucket_idi”  zJob Not Found for url: zA
Please make sure you specified the correct job ID and namespace.)Újob_idi‘  z+Invalid credentials in Authorization headerzRepository Not Found for url: zÈ
Please make sure you specified the correct `repo_id` and `repo_type`.
If you are trying to access a private or gated repo, make sure you are authenticated and your token has the required permissions.zQ
For more details, see https://huggingface.co/docs/huggingface_hub/authenticationrx   z

Bad request for z
 endpoint:z

Bad request:i“  z Forbidden: z
Cannot access content at: z2
Make sure your token has the correct permissions.r¢   z0

429 Too Many Requests: you have reached your 'z' rate limit.z
Retry after z secondsú (rT   z requests remaining in current z
s window).z
Url: z!

429 Too Many Requests for url: i   ÚRangez. Requested range: z. Content-Range: zContent-Range)#Ú_warn_on_warning_headersr›   rm   rn   Úraise_for_statusrƒ   ÚHTTPStatusErrorry   r.   rW   re   rP   r(   r]   Ú_formatr   r   r   r   ÚBUCKET_API_REGEXr8   r   ra   rd   r   ÚREPO_API_REGEXr   r   r   r@   r   r!   r"   r#   r    )rv   ræ   rž   Ú
error_codeÚerror_messageÚrequest_urlrY   r\   Úmessageró   r±   Úrange_headers               r-   r°   r°   ó  s   € ðBGÝ  Ñ*Ô*Ð*Ð*øÝð Gð Gð Gå�ŠÐ6ÀˆÑFÔFÐFÐFÐFðGøøøðB?Ø×!Ò!Ñ#Ô#Ð#Ð#Ð#øÝÔ ð @?ñ @?ð @?ØÔ 3Ñ&¨!Ò+Ð+ØˆFˆFˆFˆFˆFàÔ%×)Ò)¨.Ñ9Ô9ˆ
Ø Ô(×,Ò,Ð->Ñ?Ô?ˆð *2Ô)9Ð)EÈ(ÔJZÔJ^ÐJj�C�Ô Ô$Ñ%Ô%Ð%Ðptð 	ð HSÐdÕ6°{ÑCÔCÐCÐXdÑˆ	�7àÐ+Ò+Ð+Ø!Ô-Ð=Ð=Ð=ÀÑFÐIwÐhpÔhtÐIwÐIwÐIwÑwˆGÝÕ/°¸(ÈiÐahÐiÑiÔiÐopÐpà˜?Ò*Ð*Ø!Ô-Ð=Ð=Ð=ÀÑFÐItÐemÔeqÐItÐItÐItÑtˆGÝÕ2°G¸XÐQZÐdkÐlÑlÔlÐrsÐsà˜;Ò&Ð&àÔ'Ð7Ð7Ð7¸&Ñ@ÐCvÐgoÔgsÐCvÐCvÐCvÑvð õ �.¨'°8ÀyÐZaÐbÑbÔbÐhiÐiàÐDÒDÐDàÔ'Ð7Ð7Ð7ØñàE°h´lÐEÐEÐEñFð ñð 9ñ	9ð õ Õ+¨W°hÑ?Ô?ÀQÐFð ˜.Ò(Ð(ØÐ'Ý ×'Ò'¨Ñ4Ô4Ð@ð Ô'Ð7Ð7Ð7Øñà>¨x¬|Ð>Ð>Ð>ñ?ð ]ñ]ð }ñ	}ð õ Ý# W¨hÕB[Ð\gÑBhÔBhðñ ô àðð
 Ô  CÒ'Ð'ØÐ'Ý1°+Ñ>Ô>Ð>�ÐKð Ô'Ð7Ð7Ð7Øñà;¨H¬LÐ;Ð;Ð;ñ<ð WñWð õ Õ*¨G°XÀfÐMÑMÔMÐSTÐTà˜>Ò)Ð)ØÔ  CÒ'Ð'ØÐ!NÒNÐNØÐ'Ý×%Ò% kÑ2Ô2Ð>ð Ô'Ð7Ð7Ð7ØñàB°8´<ÐBÐBÐBñCð`ñ`ð gñgð õ Õ1°7¸HÐPYÐcjÐkÑkÔkÐqrÐràÔ! SÒ(Ð(àDQÐD]Ð@ }Ð@Ð@Ð@Ð@Ðcuð õ �/¨7°HÑ=Ô=À1ÐDàÔ! SÒ(Ð(àI�xÔ+ÐIÐI¸ÐIÐIÐIØ@°´Ð@Ð@Ð@ñAàGñHð õ
 �.¨'°8Ñ<Ô<À!ÐCàÔ! SÒ(Ð(Ý4°XÔ5EÑFÔFˆNØÐ)àtÈÔIeÐtÐtÐtð ð ÐU¨NÔ,KÐUÐUÐUÑU�Ø!Ô'Ð3¸Ô8UÐ8aØðQ˜^Ô5ð Qð Q¸Ô8Lð Qð QØ'5Ô'DðQð Qð Qñ�G�Gð
 ˜s‘N�GØÐ4 X¤\Ð4Ð4Ð4Ñ4��àOÀÄÐOÐOÐO�Ý�.¨'°8Ñ<Ô<À!ÐCàÔ! SÒ(Ð(Ø#Ô+Ô3×7Ò7¸Ñ@Ô@ˆLØÐvÐv¨|ÐvÐvÈhÔN^×NbÒNbÐcrÑNsÔNsÐvÐvÐvˆGÝ�.¨'°8Ñ<Ô<À!ÐCõ •n¥c¨!¡f¤f¨hÑ7Ô7¸QÐ>øøøøðA@?øøøs*   ‚ ’&;º;¿A ÁRÁ%RÁ9PRÒRc                 óT  — | j                              d¦  «        }|D ]Š}d|v r|                     dd¦  «        nd|f\  }}|                     ¦   «         }|t          vrJ|                     ¦   «         }|r4t                               |¦  «         t                               |¦  «         Œ‹dS )a�  
    Emit warnings if warning headers are present in the HTTP response.

    Expected header format: 'X-HF-Warning: topic; message'

    Only the first warning for each topic will be shown. Topic is optional and can be empty. Note that several warning
    headers can be present in a single response.

    Args:
        response (`httpx.Response`):
            The HTTP response to check for warning headers.
    zX-HF-Warningú;r   rÕ   N)r.   Úget_listÚsplitrB   Ú_WARNED_TOPICSÚaddrm   rœ   )rv   Úserver_warningsÚserver_warningÚtopicrÿ   s        r-   rö   rö   ¢  s¶   € ð Ô&×/Ò/°Ñ?Ô?€OØ)ð (ð (ˆØ9<ÀÐ9NÐ9N˜×-Ò-¨c°1Ñ5Ô5Ð5ÐUWÐYgÐTh‰ˆˆwØ—’‘”ˆØ�Ð&Ð&Ø—m’m‘o”oˆGØð (Ý×"Ò" 5Ñ)Ô)Ð)Ý—’˜wÑ'Ô'Ð'øð(ð (r,   Ú_HfHubHTTPErrorT)ÚboundÚ
error_typeÚcustom_messageÚattrsc                 óæ  — g }|j                              d¦  «        }|�|                     |¦  «         	 	 |                     ¦   «         }nQ# t          j        $ r? 	 |                     ¦   «          |                     ¦   «         }n# t          $ r i }Y nw xY wY nw xY w|                     d¦  «        }|                     d¦  «        }|�^t          |t          ¦  «        r| 
                    |¦  «         nJ|�|                     |› d|› �¦  «         n-|                     |¦  «         n|�|                     |¦  «         |                     d¦  «        }	|	�$|	D ]!}d|v r|                     |d         ¦  «         Œ"ng# t          j        $ rU |j                              dd¦  «        }
|j        r0d	|
                     ¦   «         vr|                     |j        ¦  «         Y nw xY wd
„ |D ¦   «         }t          t                               |¦  «        ¦  «        }d                     |¦  «        }|}|r=|                     ¦   «         |                     ¦   «         vrd|v r	|d|z   z  }n|d|z   z  }d}d}t"          dft$          dft&          dffD ];\  }}|j                              |¦  «        }|rt)          |¦  «        }d|› d|› d�} nŒ<|r_|                     ¦   «         |                     ¦   «         vr7d|v r.|                     d¦  «        }|d |…         |z   ||d …         z   }n||z  } | |                     ¦   «         ||pd ¬¦  «        }|                     ¦   «         D ]\  }}t1          |||¦  «         Œ|S )Nrê   ÚerrorÚerror_descriptionú: Úerrorsrÿ   zContent-TyperÕ   Úhtmlc                 ó’   — g | ]D}t          |¦  «                             ¦   «         ¯#t          |¦  «                             ¦   «         ‘ŒES r+   )r(   rB   )Ú.0Úlines     r-   ú
<listcomp>z_format.<locals>.<listcomp>ö  s=   € ÐVÐVÐV¨4ÅCÈÁIÄIÇOÂOÑDUÔDUÐV•S˜‘Y”Y—_’_Ñ&Ô&ÐVÐVÐVr,   rð   rì   z
Request IDzAmzn Trace IDz	Amz CF IDrô   ú))rv   Úserver_message)r.   rW   ÚappendÚjsonrƒ   ÚResponseNotReadÚreadÚRuntimeErrorr¸   ÚlistÚextendÚJSONDecodeErrorÚtextr6   ÚdictÚfromkeysÚjoinrj   ri   ÚX_AMZ_CF_IDr(   ÚindexrB   ÚitemsÚsetattr)r  r  rv   r  Úserver_errorsÚfrom_headersr­   r  r  r  Úcontent_typer  Úfinal_error_messagerr   Úrequest_id_messageÚheaderÚlabelrD   Únewline_indexrÈ   ÚkÚvs                         r-   rù   rù   ½  s>  € ð €Mð Ô#×'Ò'Ð(9Ñ:Ô:€LØÐØ×Ò˜\Ñ*Ô*Ð*ð+0ð	Ø—=’=‘?”?ˆDˆDøÝÔ$ð 
	ð 
	ð 
	ð	Ø—’‘”�Ø—}’}‘”��øÝð ð ð ð ���ðøøøøøð	
	øøøð —’˜Ñ!Ô!ˆØ ŸHšHÐ%8Ñ9Ô9ÐØÐÝ˜%¥Ñ&Ô&ð ,à×$Ò$ UÑ+Ô+Ð+Ð+Ø"Ð.à×$Ò$¨Ð%DÐ%DÐ1BÐ%DÐ%DÑEÔEÐEÐEð ×$Ò$ UÑ+Ô+Ð+Ð+ØÐ*à× Ò Ð!2Ñ3Ô3Ð3à—’˜(Ñ#Ô#ˆØÐàð ;ð ;�Ø Ð%Ð%Ø!×(Ò(¨¨yÔ)9Ñ:Ô:Ð:øøøåÔð 0ð 0ð 0àÔ'×+Ò+¨N¸BÑ?Ô?ˆØŒ=ð 	0˜V¨<×+=Ò+=Ñ+?Ô+?Ð?Ð?Ø× Ò  ¤Ñ/Ô/Ð/øøð	0øøøð WÐV°=ÐVÑVÔV€Mõ �Ÿš }Ñ5Ô5Ñ6Ô6€Mð —Y’Y˜}Ñ-Ô-€Nð )ÐØð ;˜.×.Ò.Ñ0Ô0¸×8LÒ8LÑ8NÔ8NÐNÐNØ�^Ð#Ð#Ø 4¨.Ñ#8Ñ8ÐÐà 6¨NÑ#:Ñ:Ðð €JØÐå	�|Ð$Ý	˜/Ð*Ý	�kÐ"ðð 	ð 	‰ˆ�ð
 Ô ×$Ò$ VÑ,Ô,ˆØð 	Ý˜U™œˆJØ!7 eÐ!7Ð!7¨uÐ!7Ð!7Ð!7ÐØˆEð	ð ð 6�j×&Ò&Ñ(Ô(Ð0C×0IÒ0IÑ0KÔ0KÐKÐKØÐ&Ð&Ð&Ø/×5Ò5°dÑ;Ô;ˆMà# N ] NÔ3Ð6HÑHÐK^Ð_lÐ_mÐ_mÔKnÑnð  Ðð  Ð#5Ñ5Ðð ˆ*Ð(×.Ò.Ñ0Ô0¸8ÐTbÐTjÐfjÐ
kÑ
kÔ
k€CØ—’‘”ð ð ‰ˆˆ1Ý��Q˜ÑÔÐÐØ€JsU   ¶A Á
E9 ÁBÁ(BÂBÂBÂBÂBÂBÂE9 ÂBÂCE9 Å9A!GÇG)Úsubject_tokenÚaccess_tokenÚrefresh_tokenÚclient_secretÚdevice_codec                 ó€   — g | ];}t          j        d |› d�¦  «        dft          j        d|› d�¦  «        dffD ]}|‘ŒŒ<S )z("z"\s*:\s*")[^"]*(")z\1<REDACTED>\2z(^|&)(z=)[^&]*z\1\2<REDACTED>)ÚreÚcompile)r  r<   Úpatterns      r-   r  r  (  s   € ð ð ð àå	ŒÐ1˜#Ð1Ð1Ð1Ñ	2Ô	2Ð4EÐFÝ	ŒÐ*˜cÐ*Ð*Ð*Ñ	+Ô	+Ð->Ð?ððð ð 	ð ðð ð ð r,   Úbodyc                 óL   — t           D ]\  }}|                     || ¦  «        } Œ| S )zRRedact OAuth credential values from a JSON or form-urlencoded request body string.)Ú_SENSITIVE_BODY_PATTERNSÚsub)r>  r=  Úreplacements      r-   Ú_redact_sensitive_bodyrC  2  s0   € å 8ð .ð .Ñˆ�Ø�{Š{˜;¨Ñ-Ô-ˆˆØ€Kr,   c                 óð  — dd| j         fg}t          | j                             ¦   «         ¦  «        D ],\  }}|                     ¦   «         dk    rd}|d|› d|› �fgz  }Œ-d}	 | j        �K| j                             dd	¬
¦  «        }t          |¦  «        dk    r|dd…         › d�}t          |¦  «        }n# t          j
        $ r d}Y nw xY w|�|d|                     dd¦  «        fgz  }|d| j        fgz  }g }|D ]g\  }}|r/|                     t          t          |¦  «        ¦  «        ¦  «         |r/|                     t          t          |¦  «        ¦  «        ¦  «         Œhd                     |¦  «        S )zÞConvert a `httpx.Request` into a curl command (str).

    Used for debug purposes only.

    Implementation vendored from https://github.com/ofw/curlify/blob/master/curlify.py.
    MIT License Copyright (c) 2016 Egor.
    )ÚcurlNz-Xrg   z<TOKEN>z-Hr  Nzutf-8Úignore)r  iè  z ... [truncated]z<streaming body>z-drð   rÕ   r¯   )ro   Úsortedr.   r)  r6   ÚcontentÚdecodeÚlenrC  rƒ   ÚRequestNotReadrä   rP   r  r   r(   r&  )re   Úpartsr3  r4  r>  Ú
flat_partss         r-   rq   rq   9  s¶  € ð 	Ø	ˆwŒ~Ðð$€Eõ
 �w”×,Ò,Ñ.Ô.Ñ/Ô/ð 'ð '‰ˆˆ1Ø�7Š7‰9Œ9˜Ò'Ð'ØˆAØ�4˜A˜˜ ˜˜Ð%Ð&Ñ&ˆˆà€Dð"ØŒ?Ð&Ø”?×)Ò)¨'¸(Ð)ÑCÔCˆDÝ�4‰yŒy˜4ÒÐØ˜u ˜uœ+Ð7Ð7Ð7�Ý)¨$Ñ/Ô/ˆDøøÝÔð "ð "ð "Ø!ˆˆˆð"øøøàÐØ�4˜Ÿš d¨BÑ/Ô/Ð0Ð1Ñ1ˆà	ˆt�W”[Ð!Ð"Ñ"€Eà€JØð -ð -‰ˆˆ1Øð 	-Ø×Ò�e¥C¨¡F¤F™mœmÑ,Ô,Ð,Øð 	-Ø×Ò�e¥C¨¡F¤F™mœmÑ,Ô,Ð,øà�8Š8�JÑÔÐs   Á"AB5 Â5C	ÃC	z%^\s*bytes\s*=\s*(\d*)\s*-\s*(\d*)\s*$Úoriginal_rangeÚresume_sizec                 óú  — | sd|› d�S d| v rt          d| ›d�¦  «        ‚t                               | ¦  «        }|st          d| ›d�¦  «        ‚|                     ¦   «         \  }}|sG|st          d| ›d�¦  «        ‚t          |¦  «        |z
  }d|› �}|d	k    rt          d
|›d�¦  «        ‚|S t          |¦  «        }||z   }|r2t          |¦  «        }d|› d|› �}||k    rt          d
|›d�¦  «        ‚|S d|› d�S )zB
    Adjust HTTP Range header to account for resume position.
    zbytes=ú-ú,zMultiple ranges detected - z, not supported yet.zInvalid range format - rí   zbytes=-r   zEmpty new range - )rz   ÚRANGE_REGEXr>   r  Úgroupsr*   )rN  rO  r>   ÚstartÚendÚ
new_suffixÚ	new_rangeÚ	new_starts           r-   Ú_adjust_range_headerrZ  g  sq  € ð ð 'Ø&˜Ð&Ð&Ð&Ð&à
ˆnÐÐÝÐ]°~Ð]Ð]Ð]Ñ^Ô^Ð^å×Ò˜nÑ-Ô-€EØð JÝÐH°^ÐHÐHÐHÑIÔIÐIØ—’‘”�J€Eˆ3àð Øð 	NÝÐL¸ÐLÐLÐLÑMÔMÐMå˜‘X”X Ñ+ˆ
Ø*˜jÐ*Ð*ˆ	Ø˜Š?ˆ?ÝÐB°IÐBÐBÐBÑCÔCÐCØÐå�‰JŒJ€EØ˜Ñ#€IØ
ð Ý�#‰hŒhˆØ.˜YÐ.Ð.¨Ð.Ð.ˆ	Ø�sŠ?ˆ?ÝÐB°IÐBÐBÐBÑCÔCÐCØÐà �IÐ Ð Ð Ð r,   )r/   N)N)yr'   Úatexitrº   r  Úosr;  Ú	threadingrÂ   rk   Úcollections.abcr   r   r   Ú
contextlibr   Údataclassesr   Úshlexr   Útypingr	   r
   Úurllib.parser   rƒ   Úhuggingface_hub.errorsr   rÕ   r   r  r   r   r   r   r   r   r   r   r   r   Ú_lfsr   Ú_typingr   Ú
get_loggerr$   rm   r   r<  r7   r:   r(   r@   r*   rE   rj   ri   r'  ÚVERBOSErû   rú   rc   rU   r_   rX   Útupler]   ra   rd   ÚRequestrs   ru   r¾   r}   r„   r…   r‡   rˆ   ÚCLIENT_FACTORY_TÚASYNC_CLIENT_FACTORY_TÚLockrŽ   r‰   r)   rŠ   r‹   r�   r”   r–   r˜   r�   ÚregisterÚhasattrrŸ   ÚTimeoutExceptionÚNetworkErrorÚRemoteProtocolErrorr¡   r¹   r›   r£   rÁ   r¿   rÊ   rÏ   rÑ   rÝ   rå   r°   Úsetr  rö   r
  rù   Ú_SENSITIVE_BODY_KEYSr@  rC  rq   Ú
IGNORECASErS  rZ  r+   r,   r-   ú<module>rv     sH
  ðð EÐ DÐ Dà €€€Ø 	€	€	€	Ø €€€Ø 	€	€	€	Ø 	€	€	€	Ø Ð Ð Ð Ø €€€Ø €€€Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø %Ð %Ð %Ð %Ð %Ð %Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !à €€€à 7Ð 7Ð 7Ð 7Ð 7Ð 7à Ð Ð Ð Ð Ð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð 
ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "ð 
ˆÔ	˜HÑ	%Ô	%€ð €�$ÐÑÔð&ð &ð &ð &ð &ñ &ô &ñ Ôð&ð, �2”:ÐmÑnÔnÐ à$˜"œ*Ð%OÑPÔPÐ ð8 W¨S°#¨XÔ%6ð 8¸=È4Ñ;Oð 8ð 8ð 8ð 8ðv ¨¨S¨Ô 1ð °c¸D±jð ð ð ð ð6 €Ø#€Ø€à�”ð
ð Œ*ðñ ô €ð �2”:ðð Œ*ðñ ô Ð ð $˜œÐ$aÑbÔbÐ ð %˜"œ*Ð%iÑjÔjÐ ð '˜BœJÐ'SÑTÔTÐ ð qÐpÐpÐ ð 3ð ¨5°°t±¸SÀ4¹ZÐ1GÔ+Hð ð ð ð ð2- 3ð -¨3°©:ð -ð -ð -ð -ð- ð -¨¨d©
ð -ð -ð -ð -ð 5¤=ð °Tð ð ð ð ðB*¨u¬}ð *Àð *ð *ð *ð *ð'°´ð 'ÀDð 'ð 'ð 'ð 'ð ¤ð ð ð ð ð eÔ&7ð ð ð ð ð ˜B ¤Ð,Ô-Ð Ø! " eÔ&7Ð"7Ô8Ð àˆyŒ~ÑÔ€Ø+AÐ Ð(Ð AÐ AÑ AØ7SÐ Ð4Ð SÐ SÑ SØ&*€�”˜tÑ#Ð *Ð *Ñ *ð0Ð'7ð 0¸Dð 0ð 0ð 0ð 0ð"8Ð3Ið 8Èdð 8ð 8ð 8ð 8ð �U”\ð ð ð ð ð
*˜5Ô,ð 
*ð 
*ð 
*ð 
*ð9ð 9ð 9ð 9ð, €„�Ñ Ô Ð Ø
€7ˆ2Ð!Ñ"Ô"ð 6Ø€BÔ }Ð5Ñ5Ô5Ð5ð 
ÔØ	ÔØ	Ôð=Ð ˜e D¨¤O°SÐ$8Ô9ð ð ñ ð
 3QÐ   c¨3 h¤Ð PÐ PÑ Pð ØØØIeØ3QØða8ð a8ð a8Øða8à	ða8ð ð	a8ð
 ða8ð ða8ð ˜iœ¨5°°i´À#Ð1EÔ+FÑFða8ð   s¨C x¤Ñ0ða8ð ða8ð ˆuŒ~˜t TÐ)Ô*ða8ð a8ð a8ð a8ðP ØØØIeØ3QðMð Mð MØðMà	ðMð ð	Mð
 ðMð ðMð ˜iœ¨5°°i´À#Ð1EÔ+FÑFðMð   s¨C x¤Ñ0ðMð „^ðMð Mð Mð Mð` ð
 ØØØIeØ3QðLð Lð LØðLà	ðLð ð	Lð
 ðLð ðLð ˜iœ¨5°°i´À#Ð1EÔ+FÑFðLð   s¨C x¤Ñ0ðLð ˆuŒ~˜t TÐ)Ô*ðLð Lð Lñ „ðLð` AFð0ð 0ð 0Øð0Ø #ð0Ø9=ð0à
„^ð0ð 0ð 0ð 0ðf
 ð 
¨s°T©zð 
¸cð 
ð 
ð 
ð 
ði?ð i? %¤.ð i?ÀÀtÁð i?ÐW[ð i?ð i?ð i?ð i?ðX �‘”€ð( u¤~ð (¸$ð (ð (ð (ð (ð0 �7Ð-°^ÐDÑDÔDÐ ðfØÐ%Ô&ðfØ8;ðfØGLÄ~ðfØ`cðfàðfð fð fð fðT jÐ ðð à#ðñ ô Ð ð ð ¨ð ð ð ð ð' �e”mð ' ¨ð ' ð ' ð ' ð ' ðV ˆbŒjÐAÀ2Ä=ÑQÔQ€ð"!¨¨t©ð "!À#ð "!È#ÐPTÉ*ð "!ð "!ð "!ð "!ð "!ð "!r,   