+
    ~jA                       a R t"0 t R t^ RIt^ RIt^ RIHtHt ^ RIHt ^ RI	H
t
 ^ RIHtHt ^RIHt ]
P                   P#                  4        U Uu/ uF  w  rWbK	  	  upp t] ^ k ]P&                  ! R4      t]! ]
P                   P-                  4       4      t] ^k ]! RR	7       ! R
 R4      4       t]! RR	7       ! R R4      4       tR R lt]P6                  R R l4       tR R ltR R ltR R ltR R lt R R lt!R# u upp i )a|  Centralized parser for Hugging Face Hub URIs ('hf://...') and mount specifications.

A HF URI is a URI-like string that identifies a location on the Hugging Face
Hub: a model/dataset/space/kernel repository, a bucket, optionally a revision,
and optionally a path inside the repo or bucket.

Canonical syntax:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]
```

A HF mount wraps a HF URI with a local mount path and an optional ':ro'/':rw'
flag (used by Spaces and Jobs volumes):

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
```

See 'docs/source/en/package_reference/hf_uris.md' for the full grammar and examples.
N)	dataclassfield)unquote)	constants)
HfUriErrorHFValidationError)validate_repo_idz ^refs/(?:convert/[\w.-]+|pr/\d+)T)frozenc                      a  ] tR t^>t o RtRtRt]! RRRRR7      tV 3R lR lt	]
V 3R lR	 l4       t]
V 3R
 lR l4       tV 3R lR ltV 3R ltRtV tR# )HfUria  Parsed representation of a Hugging Face Hub URI ('hf://...').

Attributes:
    type (`str`):
        One of 'model', 'dataset', 'space', 'kernel' or 'bucket'.
    id (`str`):
        The repository id ('namespace/name', e.g. 'my-org/my-model') for repo URIs, or the bucket id ('namespace/name') for bucket URIs.
    revision (`str`, *optional*):
        The revision specified after '@' in the URI, URL-decoded. 'None' if no revision was specified, or for bucket URIs (which
        never carry a revision). Special refs like 'refs/pr/10' and 'refs/convert/parquet' are preserved as-is.
    path_in_repo (`str`):
        The path inside the repo or bucket. Empty string if the URI points at the root.
N Freprhashcomparedefaultc                   < V ^8  d   QhRR/#    returnN )format__classdict__s   "s/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/huggingface_hub/utils/_hf_uris.py__annotate__HfUri.__annotate__T   s     t tt t    c           	     b   V P                   ;'       g    R pV P                  \        9  d,   \        VRV P                   R\	        \        4       R2R7      hV P
                  '       d!   V P
                  P                  R4      ^8w  d   \        VRV P
                   R2R7      hV P                  R8w  d    \        V P
                  4       V P                  e    V P                  '       g   \        VR
R7      hV P                  R8X  d   V P                  e   \        VRR7      hV P                  '       dP   V P                  P                  R4      '       g   RV P                  9   d   \        VRV P                   R2R7      hR	# R	#   \         d   p\        T\        T4      R7      ThR	p?ii ; i)r   zInvalid type 'z'. Must be one of .urimsg/z"Id must be 'namespace/name', got ''.bucketNz%Revision must not be an empty string.z&Bucket URIs do not support a revision.z//z+Path must not contain empty segments (got 'z').)_rawtype_VALID_URI_TYPESr   sortedidcountr   r   strrevisionpath_in_repo
startswith)selfr    es   &  r   __post_init__HfUri.__post_init__T   si   iioo2 99,,N499+EWX^_oXpWqqr*stt www$''--,1,NtwwiWY*Z[[99 = )
 ==$T]]]*QRR99 T]]%>*RSS   ++C00DD<M<M4M S0[\`\m\m[nnq.rss 5N  % = Sc!f51<=s   6F F.F))F.c                    < V ^8  d   QhRS[ /# r   r   bool)r   r   s   "r   r   r   p   s     % %4 %r   c                     V P                   R8H  # )z$True if this URI points at a bucket.r$   r&   r/   s   &r   	is_bucketHfUri.is_bucketo        yyH$$r   c                    < V ^8  d   QhRS[ /# r4   r5   )r   r   s   "r   r   r   u   s     % % %r   c                     V P                   R8g  # )zJTrue if this URI points at a repository (model, dataset, space or kernel).r$   r8   r9   s   &r   is_repoHfUri.is_repot   r<   r   c                    < V ^8  d   QhRS[ /# r4   r+   )r   r   s   "r   r   r   y   s       r   c                   \         P                  \        V P                  ,          RV P                  .pV P
                  eQ   V P
                  pRV9   d*   \        P                  V4      f   VP                  RR4      pVP                  RV 24       V P                  '       d   VP                  RV P                   24       RP                  V4      # )zRender the URI as a canonical 'hf://' string.

The type prefix is always written explicitly (e.g. 'hf://models/my-org/my-model').
r"   z%2F@r   )r   HF_PROTOCOL_TYPE_TO_PREFIXr&   r)   r,   _SPECIAL_REFS_REVISION_REGEX	fullmatchreplaceappendr-   join)r/   partsr,   s   &  r   to_uriHfUri.to_uriy   s    
 &11?4993MsTXT[T[\==$ }}Hh#?#I#I(#S#[#++C7LL1XJ(LL1T../01wwu~r   c                   < V ^8  d   Qh/ S[ P                  ;R&   S[;R&   S[R,          ;R&   S[;R&   S[R,          ;R&   # )r   r&   r)   Nr,   r-   r%   )r   	HfUriTyper+   )r   r   s   "r   r   r   >   sS       

! " 	G# $ Dj% & ' ( *Q) r   r   )__name__
__module____qualname____firstlineno____doc__r,   r-   r   r%   r1   propertyr:   r?   rM   __annotate_func____static_attributes____classdictcell__r   s   @r   r   r   >   sl        HL%eUDQDt t6 % % % % w  r   r   c                   p   a  ] tR t^t o RtRt]! RRRRR7      tV 3R lR ltV 3R lR lt	V 3R	 lt
R
tV tR# )HfMounta  A HF URI paired with a local mount path and optional read-only flag.

Used by Spaces and Jobs to describe volume mounts. The full syntax is:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
```

Attributes:
    source ([`HfUri`]):
        The parsed HF URI identifying the Hub resource to mount.
    mount_path (`str`):
        The local mount path (always starts with '/').
    read_only (`bool`, *optional*):
        True if the mount ends with ':ro', False if it ends with ':rw', 'None' if no flag was provided.
NFr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   HfMount.__annotate__   s      t r   c                    V P                   ;'       g    R pV P                  P                  R4      '       d   V P                  R8X  d   \        VRV P                   R2R7      hR# )r   r"   zEMount path must be a non-empty absolute path starting with '/', got 'r#   r   N)r%   
mount_pathr.   r   )r/   raws   & r   r1   HfMount.__post_init__   s\    iioo2))#..$//S2H[\`\k\k[llno  3Ir   c                    < V ^8  d   QhRS[ /# r4   rB   )r   r   s   "r   r   r^      s       r   c                    V P                   P                  4       RV P                  .pV P                  e&   TP	                  V P                  '       d   RMR4       RP                  V4      # )zaRender the mount as a canonical 'hf://' string.

Example: 'hf://models/my-org/my-model:/data:ro'
::ro:rwr   )sourcerM   r`   	read_onlyrJ   rK   )r/   rL   s   & r   rM   HfMount.to_uri   sO    
 ##%sDOO<>>%LL$...e<wwu~r   c                f   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[R,          ;R&   S[R,          ;R&   # )r   rh   r`   Nri   r%   )r   r+   r6   )r   r   s   "r   r   r^      s?     & M' ( O) * d{!+ , *Q- r   r   )rQ   rR   rS   rT   rU   ri   r   r%   r1   rM   rW   rX   rY   rZ   s   @r   r\   r\      s=     & "I%eUDQD  A  r   r\   c                0    V ^8  d   QhR\         R\        /# r   r    r   )r+   r6   )r   s   "r   r   r      s      3 4 r   c                B     \        V 4       R#   \         d     R# i ; i)z'Check if a string is a valid hf:// URI.TF)parse_hf_urir   )r    s   &r   	is_hf_urirp      s$    S s    c                0    V ^8  d   QhR\         R\        /# rm   )r+   r   )r   s   "r   r   r      s     /6 /6c /6e /6r   c                   V P                  \        P                  4      '       g0   \        V R\        P                   R\        P                   R24      hT pV \	        \        P                  4      R pV'       g   \        V R\        P                   R24      h\        W!R7      w  r4VR8X  d   \        WCVR7      # \        WCVR7      # )	ar  Parse a Hugging Face Hub URI ('hf://...').

A HF URI is a URI-like string identifying a location on the Hugging Face Hub. The full grammar is:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]
```

See 'docs/source/en/package_reference/hf_uris.md' for the full specification.

Args:
    uri (`str`):
        The URI to parse. Must start with 'hf://'.

Returns:
    [`HfUri`]: the parsed URI.

Raises:
    [`HfUriError`]:
        If the URI is malformed (missing prefix, invalid type, missing id, etc.).

Examples:
    ```py
    >>> from huggingface_hub.utils import parse_hf_uri
    >>> parse_hf_uri("hf://my-org/my-model")
    HfUri(type='model', id='my-org/my-model', revision=None, path_in_repo='')
    >>> parse_hf_uri("hf://datasets/my-org/my-dataset@refs/pr/3/train.json")
    HfUri(type='dataset', id='my-org/my-dataset', revision='refs/pr/3', path_in_repo='train.json')
    ```
Must start with 'z'. Expected format: z#[<TYPE>/]<ID>[@<REVISION>][/<PATH>]NEmpty body after 'r#   ra   r$   )r.   r   rE   r   len_split_type_parse_bucket_body_parse_repo_body)r    ra   bodytype_locations   &    r   ro   ro      s    @ >>)//00	 5 56 7  ) 5 566Y[
 	
 Cs9(()+,D 293H3H2ILMM!$0OE!(s;;H55r   c                0    V ^8  d   QhR\         R\        /# )r   	mount_strr   )r+   r\   )r   s   "r   r   r      s     7X 7Xc 7Xg 7Xr   c                   V P                  \        P                  4      '       g    \        V R\        P                   R2R7      hT pV \	        \        P                  4      R pV'       g    \        VR\        P                   R2R7      h\        W!R7      w  r4pVf   \        VRR7      h\        P                  V,           p \        V4      p\        YtYQR7      #   \         d   p\        YP                  R7      ThRp?ii ; i)	a[  Parse a HF mount specification ('hf://...:<MOUNT_PATH>[:ro|:rw]').

A mount specification is a HF URI followed by a local mount path and an optional read-only/read-write flag.
The full grammar is:

```
hf://[<TYPE>/]<ID>[@<REVISION>][/<PATH>]:<MOUNT_PATH>[:ro|:rw]
```

See 'docs/source/en/package_reference/hf_uris.md' for the full specification.

Args:
    mount_str (`str`):
        The mount string to parse. Must start with 'hf://' and contain a ':<MOUNT_PATH>' segment.

Returns:
    [`HfMount`]: the parsed mount.

Raises:
    [`HfUriError`]:
        If the mount string is malformed (missing mount path, invalid URI, etc.).

Examples:
    ```py
    >>> from huggingface_hub.utils import parse_hf_mount
    >>> parse_hf_mount("hf://my-org/my-model:/data:ro")
    HfMount(source=HfUri(type='model', id='my-org/my-model', revision=None, path_in_repo=''), mount_path='/data', read_only=True)
    >>> parse_hf_mount("hf://buckets/my-org/my-bucket/sub/dir:/mnt:rw")
    HfMount(source=HfUri(type='bucket', id='my-org/my-bucket', revision=None, path_in_repo='sub/dir'), mount_path='/mnt', read_only=False)
    ```
rs   r#   r   Nrt   ru   zKMissing mount path. Expected ':<MOUNT_PATH>' (e.g. 'hf://org/model:/data').)rh   r`   ri   r%   )	r.   r   rE   r   rv   _split_mountro   r!   r\   )	r~   ra   rz   r|   r`   ri   uri_strrh   r0   s	   &        r   parse_hf_mountr      s    @ 	 5 566#I$9$9#:"=
 	

 CS../12DS(:9;P;P:QQS&TUU&24&A#H)S&stt ##h.G4g& &9WW  4See,!34s   C D%C<<Dc          
          V ^8  d   QhR\         R\         R\        \         \         R,          \        R,          3,          /# )r   rz   ra   r   N)r+   tupler6   )r   s   "r   r   r   -  s5     + +s +C +E#sTz4$;2N,O +r   c               \   V P                  R4      '       d   RV P                  R4      rM,V P                  R4      '       d   RV P                  R4      rMRpV P                  R4      pVR
8X  d   Ve   \        VRR7      hV RR3# V RV pW^,           R pV'       g   \        VR	R7      hWEV3# )zSplit the ':<MOUNT_PATH>[:ro|:rw]' suffix from 'body'.

Returns '(location, mount_path, read_only)' where 'mount_path' is 'None' if no mount segment is present.
rf   Trg   FNz:/zb':ro'/':rw' suffix is only valid when a mount path is provided (e.g. 'hf://...:/<MOUNT_PATH>:ro').r   z#Missing location before mount path.)endswithremovesuffixrfindr   )rz   ra   ri   idxr|   r`   s   &$    r   r   r   -  s    
 }}U 1 1% 84	u		!2!25!94	 **T
C
by x  T4DSzHAgiJS&KLL**r   c                r    V ^8  d   QhR\         R\         R\        \        P                  \         3,          /# )r   r|   ra   r   )r+   r   r   rP   )r   s   "r   r   r   K  s1      # s uY5H5H#5M/N r   c          	        V P                  R4      pVR8X  dx   V \        P                  9   d%   \        VRV  R\        P                   V  R2R7      h\
        P                  V 4      ;pe"   \        VR\        P                   V R2R7      hR	V 3# V RV pW^,           R pV\        P                  9   d   \        P                  V,          V3# \
        P                  V4      ;pe   \        VR
V RV R2R7      hR	V 3# )zDetect the (optional) type prefix and return '(type, remaining_location)'.

A missing type prefix defaults to 'model'. Singular forms ('model/', 'dataset/', etc.) are explicitly rejected with a helpful error.
r"   zMissing identifier after 'z'. Expected 'z/<ID>'.r   Nz*Type prefix must be plural. Did you mean 'z/...'?modelz!Type prefix must be plural, got 'z/'. Did you mean 'z/'?r   )findr   HF_URI_TYPE_PREFIXESr   rE   rF   get)r|   ra   	slash_idxsingular_pluralfirstrests   &$    r   rw   rw   K  s-   
 c"IBy5550
-	H]H]G^_g^hhop   /228<<OI@AVAV@WXgWhhno    Zi EMO$D	...--e4d::*..u55B<UGCUVeUffij
 	
 Hr   c                \    V ^8  d   QhR\         R\        P                  R\         R\        /# r   r|   r{   ra   r   r+   r   rP   r   )r   s   "r   r   r   j  s6       
	
 r   c               n   V P                  R4      p V P                  R^4      p\        V4      ^8  g   V^ ,          '       d   V^,          '       g   \        VRV  R2R7      hV^ ,           RV^,           2pRV9   d   \        VRR7      h\        V4      ^8  d
   V^,          MRp\	        VVRVVR	7      # )
z8Parse the body of a bucket URI: 'namespace/name[/path]'.r"   z)Bucket id must be 'namespace/name', got 'r#   r   rD   z3Bucket URIs do not support a revision marker ('@').r   Nr&   r)   r,   r-   r%   )stripsplitrv   r   r   )r|   r{   ra   rL   	bucket_idpath_in_buckets   &&$   r   rx   rx   j  s     ~~c"HNN3"E
5zA~U1XXU1XXS(QRZQ[[]&^__8*AeAhZ(I
iS&[\\!$UqU1XbN# r   c                \    V ^8  d   QhR\         R\        P                  R\         R\        /# r   r   )r   s   "r   r   r     s6     8 888 
	8
 8r   c               \   V P                  R4      p V '       g   \        VRR7      hV P                  R4      pVR8X  g   V RV P                  R4      ^8  dg   RpV P	                  R^4      p\        V4      ^8  d   \        VRV  R2R7      hV^ ,           RV^,           2p\        V4      ^8  d
   V^,          MRpMV RV pW^,           R pV'       g   \        VR	R7      hVP                  R4      ^8w  d   \        VRV R
2R7      h\        P                  V4      p	V	e/   V	P                  4       pV\        V4      R P                  R4      pM-VP                  R4      p
V
R8X  d   TpRpMVRV
 pW^,           R p\        V4      pV'       g   \        VRR7      h\        VVVVVR7      # )z@Parse the body of a repo URI: '<repo_id>[@<revision>][/<path>]'.r"   zMissing repository id.r   rD   Nz-Repository id must be 'namespace/name', got 'z'. r   z!Missing repository id before '@'.r#   zEmpty revision after '@'.r   r   )r   r   r   r*   r   rv   rG   matchgroupremoveprefixr   r   )r|   r{   ra   at_idxr,   rL   repo_idr-   rev_and_pathr   r   s   &&$        r   ry   ry     s    ~~c"HS&>??
 ]]3F |x(..s3a7sA&u:>,YZbYccf*ghh1XJaaz*#&u:>uQxr7F#
-*MNN==",YZaYbbd*eff -22<@{{}H'H8EEcJL$))#.IB'!'
3+MO<8$*EFF! r   c                    V ^8  d   Qh/ ^ \         9   d   \        \        \        3,          ;R&   ^\         9   d   \        \        ,          ;R&   # )r   rF   r'   )__conditional_annotations__dictr+   	frozenset)r   s   "r   r   r      sB      F \ [c3h [GZ V U)C. U[r   )#r   rU   	functoolsredataclassesr   r   urllib.parser   huggingface_hubr   huggingface_hub.errorsr   r   _validatorsr   r   itemsrF   compilerG   r   valuesr'   r   r\   rp   	lru_cachero   r   r   rw   rx   ry   r   )kvr   s   00@r   <module>r      s  ,  	 (   % @ )
 5>4R4R4X4X4Z"[4ZDA144Z"[ [  "zz*MN  $-Y-K-K-R-R-T#U  U $J J JZ $' ' 'T /6 /6d7Xt+<>08c
 #\s   D