+
    ‚°ñjw4  ã                   ó  € ^ RI t ^ RIHt ^ RIHt ^ RIt^ RIHt ]! RR04      t	]! 0 R%m4      t
R R ltR	 R
 ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R  ltR! R" ltR# R$ ltR# )&é    N)ÚPath)ÚLiteral)Úcached_prefix_matcherÚconfigsÚcustom_nodesc                ó’   € V ^8„  d   QhR\         \        \        \         \        ,          \        \        ,          3,          ,          /# )é   Úreturn)ÚlistÚtupleÚstrÚset)Úformats   "ÚBC:\Ai_Coding\apps\studio\ComfyUI\app\assets\services\path_utils.pyÚ__annotate__r      s,   € ÷ ñ ¤$¤u¬S´$´sµ)¼SÄ½XÐ-EÕ'FÕ"Gñ ó    c                 óà   € . p \         P                  P                  4        FI  w  rV\        9   d   K  V^ ,          V^,          rCV'       g   K-  V P	                  W\        V4      34       KK  	  V # )a‡  Build list of (folder_name, base_paths[], extensions) for all model locations.

Includes every category registered in folder_names_and_paths,
regardless of whether its paths are under the main models_dir,
but excludes non-model entries like configs and custom_nodes.

An empty extensions set means the category accepts any extension,
matching folder_paths.filter_files_extensions semantics.
)Úfolder_pathsÚfolder_names_and_pathsÚitemsÚ_NON_MODEL_FOLDER_NAMESÚappendr   )ÚtargetsÚnameÚvaluesÚpathsÚextss        r   Úget_comfy_models_foldersr      sa   € ð 68€GÜ$×;Ñ;×AÑAÖC‰ˆØÔ*Ô*ÙØ˜Q•i ¨¥ˆtß‰5Ø�N‰N˜D¬¨T«Ð3Ö4ñ Dð €Nr   c                ó~   € V ^8„  d   QhR\         \        ,          R\        \        \         \        ,          3,          /# )r	   Útagsr
   )r   r   r   )r   s   "r   r   r   !   s+   € ÷ !ñ !¬¬S­	ð !´e¼CÄÄcÅ¸NÕ6Kñ !r   c                ó�  € V  Uu. uF  qR
9   g   K  VNK  	  pp\        V4      ^8w  d   \        R4      hV^ ,          pVR8X  dâ   V  Uu. uF  qP                  R4      '       g   K  VNK  	  pp\        V4      ^8w  d   \        R4      hV^ ,          P                  R^4      ^,          pV'       g   \        R4      h\	        4        UUUu/ uF  w  rgq†VbK
  	  p	ppp W•,          p
T
'       g   \        R	T R24      h\        P                  P                  T
^ ,          4      pT. 3# VR8X  d7   \        P                  P                  \        P                  ! 4       4      pV. 3# \        P                  P                  \        P                  ! 4       4      pV. 3# u upi u upi u upppi   \
         d    \        RT R24      hi ; i)zßValidates and maps upload routing tags -> (base_dir, subdirs_for_fs).

The request tags are only used to choose the write destination. Extra tags
remain labels; they do not become path components or trusted classification.
ÚinputÚmodelszFuploads require exactly one destination role: input, models, or outputúmodel_type:z?models uploads require exactly one model_type:<folder_name> tagÚ:zunknown model category 'Ú'z&no base path configured for category '>   r"   r#   Úoutput)ÚlenÚ
ValueErrorÚ
startswithÚsplitr   ÚKeyErrorÚosÚpathÚabspathr   Úget_input_directoryÚget_output_directory)r    ÚtÚdestination_rolesÚrootÚmodel_type_tagsÚfolder_namer   r   Ú_extsÚmodel_folder_pathsÚbasesÚbase_dirs   &           r   Úresolve_destination_from_tagsr;   !   s²  € ñ %)ÓO¡D˜qÐ1NÑ,NŸ˜¡DÐÐOÜ
ÐÓ Ô"ÜÐaÓbÐbà˜QÕ€DØˆxÔÙ&*ÓJ¡d ¯l©l¸=×.IŸ1˜1¡dˆÐJÜˆÓ 1Ô$ÜÐ^Ó_Ð_Ø% aÕ(×.Ñ.¨s°AÓ6°qÕ9ˆßÜÐ^Ó_Ð_ä2JÔ2Lõ
Ù2LÑ.˜D¨�%ŠKÑ2Lð 	ò 
ð	HØ&Õ3ˆE÷ ÜÐEÀkÀ]ÐRSÐTÓUÐUÜ—7‘7—?‘? 5¨¥8Ó,ˆð �Rˆ<Ðð 
�ŒÜ—7‘7—?‘?¤<×#CÒ#CÓ#EÓFˆð �Rˆ<Ðô —7‘7—?‘?¤<×#DÒ#DÓ#FÓGˆà�Rˆ<Ðùò7 Pùò Kùô
øô
 ô 	HÜÐ7¸°}ÀAÐFÓGÐGð	Hús(   …F’FÁ	FÁ&FÃ
F#ÃF* Æ*Gc                ó4   € V ^8„  d   QhR\         R\         RR/# )r	   Ú	candidateÚbaser
   N©r   )r   s   "r   r   r   E   s!   € ÷ ?ñ ?¬ð ?´Cð ?¸Dñ ?r   c                 óê   € \        \        P                  P                  V 4      4      p\        \        P                  P                  V4      4      pVP	                  V4      '       g   \        R 4      hR# )z"destination escapes base directoryN)r   r-   r.   r/   Úis_relative_tor)   )r=   r>   Úcand_absÚbase_abss   &&  r   Úvalidate_path_within_baserD   E   sR   € Ü”B—G‘G—O‘O IÓ.Ó/€HÜ”B—G‘G—O‘O DÓ)Ó*€HØ×"Ñ" 8×,Ò,ÜÐ=Ó>Ð>ñ -r   c                ó<   € V ^8„  d   QhR\         R\         R\         /# ©r	   ÚchildÚparentr
   r?   )r   s   "r   r   r   L   s!   € ÷ $ñ $¤#ð $¬sð $´sñ $r   c                 ó  € \         P                  P                  \         P                  P                  V 4      \         P                  P                  V4      4      pVR 8X  d   R# VP	                  \         P
                  R4      # ©Ú.Ú Ú/)r-   r.   Úrelpathr/   ÚreplaceÚsep©rG   rH   Úrels   && r   Ú_compute_relative_pathrS   L   sO   € Ü
�'‰'�/‰/œ"Ÿ'™'Ÿ/™/¨%Ó0´"·'±'·/±/À&Ó2IÓ
J€CØ
ˆc„zÙØ�;‰;”r—v‘v˜sÓ#Ð#r   c                ó<   € V ^8„  d   QhR\         R\         R\        /# rF   ©r   Úbool)r   s   "r   r   r   S   s&   € ÷ Pñ Pœ3ð P¬ð P´ñ Pr   c                 óª   € \        \        P                  P                  V 4      4      P	                  \        P                  P                  V4      4      # ©N)r   r-   r.   r/   rA   ©rG   rH   s   &&r   Ú_is_relative_torZ   S   s2   € Ü”—‘—‘ Ó&Ó'×6Ñ6´r·w±w·±ÀvÓ7NÓOÐOr   c                ón   € V ^8„  d   QhR\         R\        \         \         R,          3,          R,          /# ©r	   Ú	file_pathr
   N)r   r   )r   s   "r   r   r   W   s,   € ÷ !$ñ !$¬Cð !$´E¼#¼sÀT½z¸/Õ4JÈTÕ4Qñ !$r   c                óP  € \         P                  P                  V 4      p. p\        R\        P
                  ! 4       3R\        P                  ! 4       3R\        P                  ! 4       3R\        \        RR4      334       Fb  w  pw  rEV'       g   K  \         P                  P                  V4      p\        W4      '       g   KD  VP                  \        V4      V) WF34       Kd  	  V'       g   R# \        V4      w  rxrE\        W4      p	V	'       d   V RV	 2MTp
Y©;'       g    R3# )	aÌ  Return (logical_path, display_name) for a file path.

``logical_path`` is the internal namespaced storage locator (e.g.
``models/checkpoints/foo/bar.safetensors``); ``display_name`` is the
human-facing label below that namespace, served on Asset responses. These
are storage locators, not model-loader namespaces. Registered model-folder
membership is represented by backend tags such as
``model_type:<folder_name>``; these paths only use known storage roots.
r"   r'   Útempr#   Ú
models_dirrL   NrM   )r-   r.   r/   Ú	enumerater   r0   r1   Úget_temp_directoryÚgetattrrZ   r   r(   ÚmaxrS   )r]   Úfp_absÚ
candidatesÚorderÚ	namespacer>   rC   Ú	_base_lenÚ_orderrR   Úpublic_paths   &          r   Úcompute_asset_response_pathsrl   W   sþ   € ô �W‰W�_‰_˜YÓ'€FØ24€Jä$-à”l×6Ò6Ó8Ð9Ø”|×8Ò8Ó:Ð;Ø”\×4Ò4Ó6Ð7Ø”wœ|¨\¸2Ó>Ð?ð		
ö%Ñ ˆÑ �	÷ ÙÜ—7‘7—?‘? 4Ó(ˆÜ˜6×,Ô,Ø×Ñœs 8›}¨u¨f°iÐJÖKñ%÷ Ùä),¨Z«Ñ&€I�yÜ
  Ó
.€Cß*-�Y�K˜q  Ñ&°9€KØŸ˜˜tÐ#Ð#r   c                ó>   € V ^8„  d   QhR\         R\         R,          /# r\   r?   )r   s   "r   r   r   {   ó   € ÷ )ñ )¤Cð )¬C°$­Jñ )r   c                ó>   € \        V 4      pV'       d
   V^,          # R# )z=Return the asset's `display_name`, or None for unknown paths.N©rl   ©r]   Úresults   & r   Úcompute_display_namers   {   ó   € ä)¨)Ó4€Fßˆ6�!�9Ð( DÐ(r   c                ó>   € V ^8„  d   QhR\         R\         R,          /# r\   r?   )r   s   "r   r   r   �   rn   r   c                ó>   € \        V 4      pV'       d
   V^ ,          # R# )zJReturn the internal namespaced storage locator, or None for unknown paths.Nrp   rq   s   & r   Úcompute_logical_pathrw   �   rt   r   c                ó>   € V ^8„  d   QhR\         R\         R,          /# r\   r?   )r   s   "r   r   r   ‡   s   € ÷ ñ ¤3ð ¬3°­:ñ r   c                ón  €  \        V 4      w  r\        T4      pTP                   Uu. uF  qDRRTP                  39  g   K  TNK  	  ppT'       g   R# TR8X  d5   \        T4      ^8”  d
   TR,          M	T^ ,          .pRP                  T4      # RP                  T4      #   \         d     R# i ; iu upi )a¦  
Return the asset's in-root loader path: the path relative to the last
well-known folder (the model category), using forward slashes, eg:
  /.../models/checkpoints/flux/123/flux.safetensors -> "flux/123/flux.safetensors"
  /.../models/text_encoders/clip_g.safetensors -> "clip_g.safetensors"

This is the value model loaders consume (the model category is dropped). It
is persisted as ``AssetReference.loader_path`` and served as the public
Asset response `loader_path` field. The human-facing `display_name` comes
from compute_asset_response_paths().

For input/output/temp paths the full path relative to that root is returned.
For paths outside any known root, returns None.
NrK   z..r#   :é   NNrM   )Ú$get_asset_category_and_relative_pathr)   r   ÚpartsÚanchorr(   Újoin)r]   Úroot_categoryÚrel_pathÚpÚsegr|   Úinsides   &      r   Úcompute_loader_pathr„   ‡   s¨   € ðÜ"FÀyÓ"QÑˆô 	ˆX‹€AØŸGšGÓH™G�S°3¸¸a¿h¹hÐ2GÑ'G�SˆS™G€EÐHßÙà˜Ô ä! %›j¨1œn��r–°5¸µ8°*ˆØ�x‰x˜ÓÐØ�8‰8�E‹?Ðøô ô Úðüò Is   ‚B  ¨B2ÁB2Â B/Â.B/c                ó`   € V ^8„  d   QhR\         R\        \        R,          \         3,          /# )r	   r]   r
   )r"   r'   r_   r#   )r   r   r   )r   s   "r   r   r   §   s0   € ÷ Fñ FÜðFä
Œ7Ð6Õ7¼Ð<Õ=ñFr   c                óþ  € \         P                  P                  V 4      pR R lpR R lp\         P                  P                  \        P                  ! 4       4      pV! W4      '       d   RV! W4      3# \         P                  P                  \        P
                  ! 4       4      pV! W4      '       d   RV! W4      3# \         P                  P                  \        P                  ! 4       4      pV! W4      '       d   RV! W4      3# \         P                  P                  V4      ^,          P                  4       pRp\        4        F~  w  ršpV'       d	   W{9  d   K  V
 Fb  p\         P                  P                  V4      pV! W4      '       g   K2  \        V4      W“! W4      3pVe   V^ ,          V^ ,          8”  g   K`  TpKd  	  K€  	  Ve¢   Vw  rùp\         P                  P                  V	V4      p\         P                  P                  \         P                  P                  \         P                  V4      \         P                  4      pR	VP                  \         P                  R
4      3# \        RV  24      h)a¦  Determine which root category a file path belongs to.

Categories:
  - 'input': under folder_paths.get_input_directory()
  - 'output': under folder_paths.get_output_directory()
  - 'temp': under folder_paths.get_temp_directory()
  - 'models': under any base path from get_comfy_models_folders()

Returns:
    (root_category, relative_path_inside_that_root)

Raises:
    ValueError: path does not belong to any known root.
c                ó<   € V ^8„  d   QhR\         R\         R\        /# rF   rU   )r   s   "r   r   Ú:get_asset_category_and_relative_path.<locals>.__annotate__º   s!   € ÷ 2ñ 2¤ð 2¬Sð 2´Tñ 2r   c                 ó6   € \        V 4      P                  V4      # rX   )r   rA   rY   s   &&r   Ú_check_is_withinÚ>get_asset_category_and_relative_path.<locals>._check_is_withinº   s   € Ü�E‹{×)Ñ)¨&Ó1Ð1r   c                ó<   € V ^8„  d   QhR\         R\         R\         /# rF   r?   )r   s   "r   r   rˆ   ½   s!   € ÷ >ñ >¤ð >¬cð >´cñ >r   c           	      óB  € \         P                  P                  \         P                  P                  \         P                  \         P                  P                  W4      4      \         P                  4      pVR 8X  d   R# VP                  \         P                  R4      # rJ   )r-   r.   rN   r~   rP   rO   rQ   s   && r   Ú_compute_relativeÚ?get_asset_category_and_relative_path.<locals>._compute_relative½   sa   € ô �g‰g�o‰oÜ�G‰G�L‰LœŸ™¤§¡§¡°Ó!?Ó@Ä"Ç&Á&ó
ˆð ˜C”ZˆrÐ= S§[¡[´·±¸Ó%=Ð=r   r"   r'   r_   Nr#   rM   úCPath is not within input, output, temp, or configured model bases: )r-   r.   r/   r   r0   r1   rb   ÚsplitextÚlowerr   r(   r~   rN   rP   rO   r)   )r]   re   rŠ   rŽ   Ú
input_baseÚoutput_baseÚ	temp_baseÚextÚbestÚbucketr9   Ú
extensionsÚbrC   ÚcandÚ_Ú
rel_insideÚcombinedÚ
normalizeds   &                  r   r{   r{   §   sñ  € ô" �W‰W�_‰_˜YÓ'€Fõ2õ>ô —‘—‘¤×!AÒ!AÓ!CÓD€JÙ˜×+Ò+ØÑ)¨&Ó=Ð=Ð=ô —'‘'—/‘/¤,×"CÒ"CÓ"EÓF€KÙ˜×,Ò,ØÑ*¨6Ó?Ð?Ð?ô —‘—‘¤× ?Ò ?Ó AÓB€IÙ˜×*Ò*ØÑ(¨Ó;Ð;Ð;ô �'‰'×
Ñ
˜6Ó
" 1Õ
%×
+Ñ
+Ó
-€CØ(,€DÜ%=Ö%?Ñ!ˆ�z÷ ˜#Ô/ÙÛˆAÜ—w‘w—‘ qÓ)ˆHÙ# F×5Ò5ÙÜ˜“M 6Ð+<¸VÓ+NÐOˆDØŠ|˜t A�w¨¨a­Ö0Ø’ó ñ &@ð ÒØ $Ñˆ�:Ü—7‘7—<‘< ¨
Ó3ˆÜ—W‘W—_‘_¤R§W¡W§\¡\´"·&±&¸(Ó%CÄRÇVÁVÓLˆ
Ø˜×+Ñ+¬B¯F©F°CÓ8Ð8Ð8ä
Ø
MÈiÈ[ÐYóð r   c                óF   € V ^8„  d   QhR\         R\        \         ,          /# ©r	   r.   r
   ©r   r   )r   s   "r   r   r   ð   s   € ÷ 0ñ 0¬Cð 0´D¼µIñ 0r   c                óÐ  a€ \         P                  P                  V 4      p. oR V3R llpR\        P                  ! 4       3R\        P
                  ! 4       3R\        P                  ! 4       33 F'  w  r4\        V34      ! V4      '       g   K  V! V4       K)  	  \         P                  P                  V4      ^,          P                  4       p. pRp\        4        FK  w  r‰p
\        \        V	4      4      ! V4      '       g   K(  RpV
'       d	   WZ9   g   K:  VP                  V4       KM  	  V'       d	   V! R4       V F  pV! R	V 24       K  	  S'       g   \        R
V  24      hS# )aN  Return trusted backend tags derived from current filesystem facts.

The returned tags are only the backend-generated system tags: ``models``,
``model_type:<folder_name>``, ``input``, ``output``, and ``temp``. Model
type tags are based on registered folder names, not path components.

A ``model_type:<folder_name>`` tag is only emitted when the file's
extension is accepted by that folder's registered extension set, so
categories sharing a base directory tag only the files they can
actually load. Files under a model base whose extension matches no
category still get the ``models`` tag.
c                ó(   € V ^8„  d   QhR\         RR/# )r	   Útagr
   Nr?   )r   s   "r   r   Ú7get_backend_system_tags_from_path.<locals>.__annotate__   s   € ÷ ñ ”#ð ˜$ñ r   c                 ó<   <€ V S9  d   SP                  V 4       R # R # rX   )r   )r¥   r    s   &€r   Ú_addÚ/get_backend_system_tags_from_path.<locals>._add   s   ø€ Ø�dŒ?Ø�K‰K˜Öñ r   r"   r'   r_   FTr#   r$   r�   )r-   r.   r/   r   r0   r1   rb   r   r‘   r’   r   r   r   r)   )r.   re   r¨   Úroler>   r–   Úmodel_typesÚunder_models_baser6   r9   r™   r    s   &          @r   Ú!get_backend_system_tags_from_pathr­   ð   sB  ø€ ô �W‰W�_‰_˜TÓ"€FØ€D÷ð ð
 
”,×2Ò2Ó4Ð5Ø	”<×4Ò4Ó6Ð7Ø	”×0Ò0Ó2Ð3ó‰
ˆô
 ! $ Ô)¨&×1Ô1Ù�ŽJñô �'‰'×
Ñ
˜6Ó
" 1Õ
%×
+Ñ
+Ó
-€CØ€KØÐÜ*BÖ*DÑ&ˆ˜JÜ ¤ u£Ô.¨v×6Ô6Ø $Ð÷  Ö!2Ø×"Ñ" ;Ö/ñ +E÷ ÙˆXŒÛ"ˆÙˆ{˜;˜-Ð(Ö)ñ #÷ ÜØQÐRVÐQWÐXó
ð 	
ð €Kr   c                óT   € V ^8„  d   QhR\         R,          R\        \         ,          /# )r	   Ú	subfolderNr
   r¢   )r   s   "r   r   r   #  s"   € ÷ ñ ¬¨d­
ð ´t¼Cµyñ r   c                ó"   € V \         9   d   V .# . # )z/Return tags for known UI/input subfolder names.)Ú_KNOWN_SUBFOLDER_TAGS)r¯   s   &r   Úget_known_subfolder_tagsr²   #  s   € àÔ)Ô)Øˆ{ÐØ€Ir   c                óF   € V ^8„  d   QhR\         R\        \         ,          /# r¡   r¢   )r   s   "r   r   r   *  s   € ÷ ñ ´3ð ¼4Ä½9ñ r   c                óˆ  € \         P                  P                  V 4      p\         P                  P                  \        P                  ! 4       4      p\        V34      ! V4      '       g   . # \         P                  P                  W4      p\        V4      P                  p\        V4      ^8X  d   \        V^ ,          4      # . # )a'  Return known input-layout tags for files in canonical input subfolders.

These are compatibility tags for current UI-origin input directories such as
``pasted`` and ``webcam``. They are intentionally narrow: only files directly
inside a known top-level input directory receive the matching tag.
)r-   r.   r/   r   r0   r   rN   r   r|   r(   r²   )r.   re   r“   rR   r|   s   &    r   Ú(get_known_input_subfolder_tags_from_pathrµ   *  s†   € ô �W‰W�_‰_˜TÓ"€FÜ—‘—‘¤×!AÒ!AÓ!CÓD€JÜ  * Ô/°×7Ò7Øˆ	ä
�'‰'�/‰/˜&Ó
-€CÜ�‹I�O‰O€EÜ
ˆ5ƒz�Q„Ü'¨¨a­Ó1Ð1Ø€Ir   c                óF   € V ^8„  d   QhR\         R\        \         ,          /# r¡   r¢   )r   s   "r   r   r   =  s   € ÷ ñ ¬#ð ´$´sµ)ñ r   c                ór   € \        V 4      p\        V 4       F  pW!9  g   K  VP                  V4       K  	  V# )z2Return all backend-derived tags for an asset path.)r­   rµ   r   )r.   r    r¥   s   &  r   Úget_path_derived_tags_from_pathr¸   =  s3   € ä,¨TÓ2€DÜ7¸Ö=ˆØŽ?Ø�K‰K˜Öñ >ð €Kr   c                óh   € V ^8„  d   QhR\         R\        \         \        \         ,          3,          /# )r	   r]   r
   )r   r   r   )r   s   "r   r   r   F  s+   € ÷ 
Lñ 
L´ð 
L¼¼sÄDÌÅI¸~Õ9Nñ 
Lr   c                óB   € \        V 4      P                  \        V 4      3# )a  Return (name, tags) derived from a filesystem path.

- name: base filename with extension
- tags: backend-derived tags from root/model classification and known input
  subfolder layout conventions

Raises:
    ValueError: path does not belong to any known root.
)r   r   r¸   )r]   s   &r   Ú!get_name_and_tags_from_asset_pathr»   F  s   € ô �	‹?×ÑÔ!@ÀÓ!KÐKÐKr   >   Ú3dÚpastedÚthreedÚwebcamÚpainter)r-   Úpathlibr   Útypingr   r   Úapp.assets.helpersr   Ú	frozensetr   r±   r   r;   rD   rS   rZ   rl   rs   rw   r„   r{   r­   r²   rµ   r¸   r»   © r   r   Ú<module>rÆ      s…   ðÛ 	Ý Ý ã Ý 4ñ $ Y°Ð$?Ó@Ð Ù!Ò"QÓRÐ õõ(!õH?õ$õPõ!$õH)õ)õõ@FõR0õfõõ&÷
Lr   