
    &`i              
       f   d dl Z d dlZd dlZd dlZd dlmZ d dl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 d dlmZ  ej        e          Z eded	ef         
          Ze	 ddede
e         dedefd            Zddde	eee
e         f                  de
e         fdZddde	eee
e         f                  de
e         fdZede	eee
e         f                  deegef         fd            ZdefdZdefdZ edde
e         defd            Z!edde
e         defd            Z"dS )    Nwraps)AnyCallableIterableOptionalTypeVarUnion)Version)tabulate)DeveloperAPI)TemplateF.)boundnoneobjtitle
max_heightreturnc           
          i }t          |                                           D ]\  }}t          |t          t          t
          t          f          rt          |          ||<   @t          |t                    st          |d          rt          d          
                    t          t          |t                    r|                                n t          |                                          ddddg          d	          ||<   t          d          
                    t          |                                d
dddg          |	          }|r%t          d          
                    ||          }n|}|S )a]  Generate a generic html repr using a table.

    Args:
        obj: Object for which a repr is to be generated
        title: If present, a title for the section is included
        max_height: Maximum height of the table; valid values
            are given by the max-height CSS property

    Returns:
        HTML representation of the object
    __dict__zscrollableTable.html.j2htmlFSettingValue)tablefmt	showindexheadersr   )tabler   
unsafehtmlztitle_data.html.j2)r   data)varsitems
isinstancestrboolintfloatdicthasattrr   renderr   )r   r   r   r    kvr   contents           d/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/widgets/util.pymake_table_html_reprr/      s    DS		!!  1a#tS%011 	!ffDGG4   		GAz$:$: 		899@@!+At!4!4IAGGIII$q''--//##&0	   " A  DG .//66JJLL!(	
 
 
  7  E  /0077e%7PPN    )messagedepsr1   c                     g }|D ]9\  }}t           j                            |          |                    |           :|r=| sdd                    |           d} t
                              d| d|  d           |S )	zReturn a list of missing dependencies.

    Args:
        deps: Dependencies to check for
        message: Message to be emitted if a dependency isn't found

    Returns:
        A list of dependencies which can't be found, if any
    NzRun `pip install  ` for rich notebook output.zMissing packages: z.    
stacklevel)	importlibutil	find_specappendjoinloggerinfo)r1   r2   missinglib_s        r.   _has_missingrC   D   s     G    a>##C((0NN3 M 	YX#((7*;*;XXXG 	===G==!LLLNr0   c           
      L   g }|D ]n\  }}	 t          j        |          }|rBt          |j                  t          |          k     r|                    |||j        g           _# t
          $ r Y kw xY w|rg }g }|D ]@\  }}}|                    | d| d| d|            |                    | d|            At          j        d                    |          d          }	d                    |          }
| sd|
 d} t          
                    d	|	 d|  d
           |S )Nz==z found, needs z>=
z  r4   zRun `pip install -U r5   zOutdated packages:
r6   r7   )r9   import_moduler   __version__r<   ImportErrortextwrapindentr=   r>   r?   )r1   r2   outdatedrA   versionmoduleoutdated_strsinstall_args	installedoutdated_strinstall_strs              r.   _has_outdatedrS   `   s    H  g	,S11F D76#5669I9IIIgv/A BCCC 	 	 	D	  T'/ 	5 	5#C)  C!T!T9!T!TC!T!T7!T!TUUU3 3 3' 3 34444tyy'?'?FFhh|,, 	VU[UUUG 	D<DD7DDQRSSSOs   AA$$
A10A1notebook_depsc                  l    d}t          | d|irdt          dt          fd}ndt          dt          fd}|S )a  Decorator which strips rich notebook output from mimebundles in certain cases.

    Fallback to plaintext and don't use rich output in the following cases:
    1. In a notebook environment and the appropriate dependencies are not installed.
    2. In a ipython shell environment.
    3. In Google Colab environment.
        See https://github.com/googlecolab/colabtools/ issues/60 for more information
        about the status of this issue.

    Args:
        notebook_deps: The required dependencies and version for notebook environment.

    Returns:
        A function that returns the usual _repr_mimebundle_, unless any of the 3
        conditions above hold, in which case it returns a mimebundle that only contains
        a single text/plain mimetype.
    z[Run `pip install -U ipywidgets`, then restart the notebook server for rich notebook output.r1   funcr   c                 <     t                      fd            }|S )Nc                      | g|R i |S N )selfargskwargsrV   s      r.   wrappedz4repr_with_fallback.<locals>.wrapper.<locals>.wrapped   s#    tD242226222r0   r   rV   r^   s   ` r.   wrapperz#repr_with_fallback.<locals>.wrapper   s3    4[[3 3 3 3 [3 Nr0   c                 6    t          |           d             }|S )Nc                 $    dt          |           iS )Nz
text/plain)repr)r[   r\   r]   s      r.   r^   z4repr_with_fallback.<locals>.wrapper.<locals>.wrapped   s    $d4jj11r0   r   r_   s     r.   r`   z#repr_with_fallback.<locals>.wrapper   s(    4[[2 2 [2 Nr0   )_can_display_ipywidgetsr   )rT   r1   r`   s      r.   repr_with_fallbackre      ss    ,	8  ?w?? 	! 	 	 	 	 	 		! 	 	 	 	 	 Nr0   c                  V    dt           j        v rddlm}   |             j        j        S dS )NIPythonr   get_ipython )sysmodulesrg   ri   	__class____name__rh   s    r.   _get_ipython_shell_namero      s8    CK''''''{}}&//2r0   c                 V    t                      rt          |d| ist          |d| isdS dS )Nr1   TF)in_notebookrC   rS   )r1   r2   s     r.   rd   rd      sF     }} d,G,,0=t0UW0U0U t5r0   
shell_namec                 .    | st                      } | dk    S )z9Return whether we are in a Jupyter notebook or qtconsole.ZMQInteractiveShellro   rr   s    r.   rq   rq      s#      /,..
...r0   c                 .    | st                      } | dk    S )z3Return whether we are in a terminal running IPythonTerminalInteractiveShellru   rv   s    r.   in_ipython_shellry      s#      /,..
333r0   )Nr   rY   )#r9   loggingrk   rI   	functoolsr   typingr   r   r   r   r	   r
   packaging.versionr   )ray._private.thirdparty.tabulate.tabulater   ray.util.annotationsr   ray.widgetsr   	getLoggerrn   r>   r   r$   r/   rC   rS   re   ro   r%   rd   rq   ry   rZ   r0   r.   <module>r      s        



        D D D D D D D D D D D D D D D D % % % % % % > > > > > > - - - - - -            		8	$	$GCxS)*** =C- -	-c]-7:-- - - -b JN  E#x},-.9A#   : JN  E#x},-.9A#   B *U3#567*qc1f* * * *Z    t     / /HSM /T / / / / 4 4# 4$ 4 4 4 4 4 4r0   