
    -iF                         S SK r S SKJr  S SKJr  S SKJr  S SKJr  S SK	J
r
  SSKJr   " S	 S
5      rS r\" S5      r\" S5      r\" 5       r " S S5      r         SS jrS r   SS jrS rg)    N)closing)isclass)StringIO)Path)Template   )config_contextc                   $    \ rS rSrSrS rS rSrg)
_IDCounter   z&Generate sequential ids with a prefix.c                     Xl         SU l        g )Nr   )prefixcount)selfr   s     U/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/_repr_html/estimator.py__init___IDCounter.__init__   s    
    c                 b    U =R                   S-  sl         U R                   SU R                    3$ )N   -r   r   r   s    r   get_id_IDCounter.get_id   s(    

a
++a

|,,r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s    0-r   r   c                      [        [        5      R                  S-  n [        [        5      R                  S-  nU R                  SS9nUR                  SS9nU SU 3$ )Nzestimator.cssz
params.csszutf-8)encoding
)r   __file__parent	read_text)estimator_css_fileparams_css_fileestimator_css
params_csss       r   _get_css_styler-      sb    h..@8n++l:O&00'0BM **G*<J_Bzl++r   zsk-container-idzsk-estimator-idc                   4    \ rS rSrSrSSSSSS.S jrS rSrg)	_VisualBlock)   a  HTML Representation of Estimator

Parameters
----------
kind : {'serial', 'parallel', 'single'}
    kind of HTML block

estimators : list of estimators or `_VisualBlock`s or a single estimator
    If kind != 'single', then `estimators` is a list of
    estimators.
    If kind == 'single', then `estimators` is a single estimator.

names : list of str, default=None
    If kind != 'single', then `names` corresponds to estimators.
    If kind == 'single', then `names` is a single string corresponding to
    the single estimator.

name_details : list of str, str, or None, default=None
    If kind != 'single', then `name_details` corresponds to `names`.
    If kind == 'single', then `name_details` is a single string
    corresponding to the single estimator.

name_caption : str, default=None
    The caption below the name. `None` stands for no caption.
    Only active when kind == 'single'.

doc_link_label : str, default=None
    The label for the documentation link. If provided, the label would be
    "Documentation for {doc_link_label}". Otherwise it will look for `names`.
    Only active when kind == 'single'.

dash_wrapped : bool, default=True
    If true, wrapped HTML element will be wrapped with a dashed border.
    Only active when kind != 'single'.
NT)namesname_detailsname_captiondoc_link_labeldash_wrappedc                    Xl         X l        Xpl        XPl        X`l        U R                   S;   a"  Uc  S[        U5      -  nUc  S[        U5      -  nX0l        X@l        g )N)parallelserialN)kind
estimatorsr5   r3   r4   lenr1   r2   )r   r:   r;   r1   r2   r3   r4   r5   s           r   r   _VisualBlock.__init__N   s_     	$((,99..}#j/1#&Z8
(r   c                     U $ r9   r"   r   s    r   _sk_visual_block__VisualBlock._sk_visual_block_h   s    r   )r5   r4   r;   r:   r3   r2   r1   )r   r   r   r   r    r   r?   r!   r"   r   r   r/   r/   )   s#    "R )4r   r/   c                    U R                  SU SU SU
 S35        [        R                  " U5      nUGb.  [        R                  " [        U5      5      nU(       a  SOSn[        R                  5       nU	(       a!  SnUb  S	U S
3nO	Ub  S	U S
3nSU
 SU	 SU S3n	Uc  SOS[        R                  " U5       S3nSU SU S3nU	(       d  U(       a  SU	 U S3OSnSU SU
 SU U S3nSU SU SU SU
 S[        R                  " U5       S3nU(       a  SR                  UU S3/5      nO$U(       a  SU;  a  SR                  USU S3/5      nU R                  U5        OU R                  S U S35        U R                  S!5        g)"ay  Write labeled html with or without a dropdown with named details.

Parameters
----------
out : file-like object
    The file to write the HTML representation to.
params: str
    If estimator has `get_params` method, this is the HTML representation
    of the estimator's parameters and their values. When the estimator
    does not have `get_params`, it is an empty string.
name : str
    The label for the estimator. It corresponds either to the estimator class name
    for a simple estimator or in the case of a `Pipeline` and `ColumnTransformer`,
    it corresponds to the name of the step.
name_details : str
    The details to show as content in the dropdown part of the toggleable label. It
    can contain information such as non-default parameters or column information for
    `ColumnTransformer`.
name_caption : str, default=None
    The caption below the name. If `None`, no caption will be created.
doc_link_label : str, default=None
    The label for the documentation link. If provided, the label would be
    "Documentation for {doc_link_label}". Otherwise it will look for `name`.
outer_class : {"sk-label-container", "sk-item"}, default="sk-label-container"
    The CSS class for the outer container.
inner_class : {"sk-label", "sk-estimator"}, default="sk-label"
    The CSS class for the inner container.
checked : bool, default=False
    Whether the dropdown is folded or not. With a single estimator, we intend to
    unfold the content.
doc_link : str, default=""
    The link to the documentation for the estimator. If an empty string, no link is
    added to the diagram. This can be generated for an estimator if it uses the
    `_HTMLDocumentationLinkMixin`.
is_fitted_css_class : {"", "fitted"}
    The CSS class to indicate whether or not the estimator is fitted. The
    empty string means that the estimator is not fitted and "fitted" means that the
    estimator is fitted.
is_fitted_icon : str, default=""
    The HTML representation to show the fitted information in the diagram. An empty
    string means that no information is shown.
param_prefix : str, default=""
    The prefix to prepend to parameter names for nested estimators.
z<div class="z"><div class=" z sk-toggleable">Nchecked z!<span>Online documentation</span>z<span>Documentation for </span>z <a class="sk-estimator-doc-link z)" rel="noreferrer" target="_blank" href="z">?z</a>z<div class="caption"></div>z
<div><div>z<div>z<label for="z" class="sk-toggleable__label z sk-toggleable__label-arrow">z</label>z><input class="sk-toggleable__control sk-hidden--visually" id="z" type="checkbox" >z#<div class="sk-toggleable__content z" data-param-prefix="">Pipelinez<pre>z</pre></div>z<label></div></div>)writehtmlescapestr_ESTIMATOR_ID_COUNTERr   join)outparamsnamer2   r3   r4   outer_classinner_classrC   doc_linkis_fitted_css_classis_fitted_iconparam_prefixchecked_strest_id	doc_labelname_caption_div	links_div
label_htmlfmt_strs                       r   _write_label_htmlra   l   s   v II
{m $-q!4 55E	G ;;tD{{3|#45#*i&--/;I)6~6FgN	!6tfGD	23F2G H;;C*C	{RVX  # (\)B(C6J 	
 (vV4D3EVL > H:n-V4 	 6("@AT@U V++;*<YKxQ 	 MVH U*m1ZL 9--@,A B""&++l";!<B@ 	 ggw6(&(9:;Gz5ggw%~\(JKLG		'		GD6*+IInr   c                    [        U S5      (       a   U R                  5       $ [        U [        5      (       a  [        SX U S9$ U c  [        SU SSS9$ [        U S5      (       a  [        U 5      (       d  U R                  SS9R                  5        VVs/ s H@  u  p[        US5      (       d  M  [        US5      (       d  M+  [        U5      (       a  M=  X4PMB     nnnU(       am  [        S	U VVs/ s H  u  pBUPM	     snnU VVs/ s H   u  pU S
UR                  R
                   3PM"     snnU VVs/ s H  u  pB[        U5      PM     snnS9$ [        SU U R                  R
                  [        U 5      S9$ ! [         a,    [        SU U R                  R
                  [        U 5      S9s $ f = fs  snnf s  snnf s  snnf s  snnf )z7Generate information about how to display an estimator.r?   single)r1   r2   None
get_paramsFdeepfitr7   z: )hasattrr?   	Exceptionr/   	__class__r   rN   
isinstancer   re   items)	estimatorkeyestr;   _s        r   _get_visual_blockrr      s   y-..	..00 )S!!iy
 	
 
	HivFSS y,''	0B0B &00e0<BBD
DsL) .5c5.A JQRU, SJD 	 

 #-.::.JTU*hc#b!7!7 89*U5?@Z61c#hZ@	  !!**^	 =  	))22 ^	 	"
 /U@s;   E: F3.F3F3F3/F9'F?4G:3F0/F0c                 X   U(       a  [        U5      nOSn[        SS9   [        U5      nSSS5        [        US5      (       a  UR                  5       n	OSn	WR                  S;   Ga  U=(       d    UR
                  n
U
(       a  SOSnU R                  SU S	35        U(       aR  [        US
5      (       a/  [        US5      (       a  UR                  SS9R                  5       nOSn[        U UUUU	UUUS9  UR                  nU R                  SU S	35        [        UR                  UR                  UR                  5      nU H  u  nnnU(       a+  [        US5      (       a  U UR                  S5      S    S3nO4[        US5      (       a!  U(       a  UR                  S5      S    S3OSnOUnUS:X  a  [        U UUUUUS9  M  U R                  S5        [!        SU/SS9n[        U UUUUUS9  U R                  S5        M     U R                  S5        gUR                  S:X  ap  [        US5      (       a  UR                  5       R                  5       nOSn[        U UUR                  UR                  UR"                  UR$                  SSUU	UUUS9  gg! , (       d  f       GNv= f)a  Write estimator to html in serial, parallel, or by itself (single).

For multiple estimators, this function is called recursively.

Parameters
----------
out : file-like object
    The file to write the HTML representation to.
estimator : estimator object
    The estimator to visualize.
estimator_label : str
    The label for the estimator. It corresponds either to the estimator class name
    for simple estimator or in the case of `Pipeline` and `ColumnTransformer`, it
    corresponds to the name of the step.
estimator_label_details : str
    The details to show as content in the dropdown part of the toggleable label.
    It can contain information as non-default parameters or column information for
    `ColumnTransformer`.
is_fitted_css_class : {"", "fitted"}
    The CSS class to indicate whether or not the estimator is fitted or not. The
    empty string means that the estimator is not fitted and "fitted" means that the
    estimator is fitted.
is_fitted_icon : str, default=""
    The HTML representation to show the fitted information in the diagram. An empty
    string means that no information is shown. If the estimator to be shown is not
    the first estimator (i.e. `first_call=False`), `is_fitted_icon` is always an
    empty string.
first_call : bool, default=False
    Whether this is the first time this function is called.
param_prefix : str, default=""
    The prefix to prepend to parameter names for nested estimators.
    For example, in a pipeline this might be "pipeline__stepname__".
rD   T)print_changed_onlyN_get_doc_link)r8   r7   z sk-dashed-wrappedz<div class="sk-itemrH   re   _get_params_htmlFrf   )rV   rW   rX   rY   z<div class="sk-split:r   __r8   )rW   rY   z<div class="sk-parallel-item">)r5   rF   rJ   rc   zsk-itemzsk-estimator)rT   rU   rC   rV   rW   rX   rY   )rr   r	   ri   ru   r:   r5   rK   rv   _repr_html_innerra   zipr;   r1   r2   rw   _write_estimator_htmlr/   r3   r4   )rQ   rn   estimator_labelestimator_label_detailsrW   rX   
first_callrY   	est_blockrV   dashed_wrappeddash_clsrR   r:   	est_infosrp   rS   r2   
new_prefixserial_blocks                       r   r|   r|   
  s   V %i0	t4))4I 5 y/****,~~//#=y'='=+9'r		'z45y,//G-5 5 #333?PPR'!$7-)	 ~~		OD6,-	,,iooy?U?UV	'0#C| g 6 6 ,~djjoa.@-AD
w'':>

3 2326B
)
x% (;!+ 		:;+Hse%P%  (;!+ 		(#C (1F 			.!	8	#9011//1BBDFFOO""""$$!& 3)%	
 
$O 54s   J
J)c                     SSK Jn  SSKJn  [	        U S5      (       d  SnSnO U" U 5        SnSnS	U S
U S3n[        [        5       5       n[        R                  5       n[        [        5      nUR                  US9n	[        U 5      n
SnSU	 SU S[        R                  " U
5       SU S3	nUR                  U5        [!        UU U R"                  R$                  U
SUUS9  ['        [        [)        [*        5      R,                  S-  5      S5       nUR/                  5       nSSS5        SW S3nUR                  U5        UR1                  5       nUsSSS5        $ ! U a    SnSn GN:f = f! , (       d  f       NQ= f! , (       d  f       g= f)a  Build a HTML representation of an estimator.

Read more in the :ref:`User Guide <visualizing_composite_estimators>`.

Parameters
----------
estimator : estimator object
    The estimator to visualize.

Returns
-------
html: str
    HTML representation of estimator.

Examples
--------
>>> from sklearn.utils._repr_html.estimator import estimator_html_repr
>>> from sklearn.linear_model import LogisticRegression
>>> estimator_html_repr(LogisticRegression())
'<style>#sk-container-id...'
r   )NotFittedError)check_is_fittedrh   z<span>Not fitted</span>rD   z<span>Fitted</span>fittedz#<span class="sk-estimator-doc-link z">irE   )idzIn a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.z<style>z</style><body><div id="zC" class="sk-top-container"><div class="sk-text-repr-fallback"><pre>z	</pre><b>z+</b></div><div class="sk-container" hidden>T)r   rW   rX   zestimator.jsrNz</div></div><script>z</script></body>)sklearn.exceptionsr   sklearn.utils.validationr   ri   r   r   _CONTAINER_ID_COUNTERr   r   
_CSS_STYLE
substituterN   rL   rM   rK   r|   rk   r   openr   r&   r'   readgetvalue)rn   r   r   status_labelrW   rX   rQ   container_idstyle_templatestyle_with_idestimator_strfallback_msghtml_templatefscripthtml_endhtml_outputs                    r   estimator_html_reprr     s   , 289e$$0 	%I&0L"* ..A-B C>	"  
	,335!*-&11\1BI" 	 m_ %$~ &KK./y G0	0 	 			- (( 3)	
 #d8n++n<=sCqVVXF D *&1AB		(llnc 
	  	%4L"$	%b DCS 
	s6   E CE?E.#0E?
E+*E+.
E<	8E??
F)	NNzsk-label-containerzsk-labelFrD   rD   rD   rD   )rD   FrD   )rL   
contextlibr   inspectr   ior   pathlibr   stringr   rD   r	   r   r-   r   rO   r   r/   ra   rr   r|   r   r"   r   r   <module>r      s          	- 	-, ##45 "#45 
@ @P $pf(b J
ZZr   