
    WhY                         d dl Z d dlmZ d dlmZmZmZ d dlmZ ddZ	 G d de
      Z G d d	e      Zdd
Zd Zd Zy)    N)PrettyPrinter)NotEncodablePlotlyJSONEncoder
get_module)image_array_to_data_uric           
         t        | t              rd\  }}n-t        | t              rd\  }}nt        dt	        |       z        t        |       |k  r| }n"t        | d|       dgz   t        | | d       z   }|dj                  |D cg c]  }t        |       c}      z   |z   }	dj                  t        j                  |	|d|d	z   z  d|d	z   z  
            j                         }
|
S c c}w )a  
    Return a string representation for of a list where list is elided if
    it has more than n elements

    Parameters
    ----------
    v : list
        Input list
    threshold :
        Maximum number of elements to display

    Returns
    -------
    str
    )[])()zInvalid value of type: %sNz...z, 
    )widthinitial_indentsubsequent_indent)
isinstancelisttuple
ValueErrortypelenjoinstrtextwrapwrapstrip)v	threshold	edgeitemsindentr   	open_char
close_chardisp_vev_str	v_wrappeds              F/var/www/html/jupyter_env/lib/python3.12/site-packages/plotly/utils.py_list_repr_elidedr)   	   s      !T (	:	Au	 (	:4tAw>??
1va
m$w.a
n1EE		6":a3q6":;;jHE		&1*-!VaZ0		
 eg   #;s   C)
c                   ,    e Zd ZdZd Zed        Zd Zy)ElidedWrapperz
    Helper class that wraps values of certain types and produces a custom
    __repr__() that may be elided and is suitable for use during pretty
    printing
    c                 .    || _         || _        || _        y N)r   r!   r   )selfr   r   r!   s       r(   __init__zElidedWrapper.__init__9   s    "    c                     t        d      }t        | t        t        f      r"t	        |       dkD  rt        | d   t
              sy|rt        | |j                        ryt        | t              ryy)Nnumpyr   TF)r   r   r   r   r   dictndarrayr   )r   r2   s     r(   is_wrappablezElidedWrapper.is_wrappable>   sX    7#a$'CFQJz!A$PT?Uz!U]]33r0   c           
      j   t        d      }t        | j                  t        t        f      r.t        | j                  | j                  | j                        }|S |rt        | j                  |j                        r|j                         } |j                  di t        || j                  dd       | j                  j                         }|j                  d      }dd| j                  z  z   j                  |      } |j                  di | |S t        | j                  t              rlt!        | j                        dkD  r:dt#        | j                  d d	       z   d
z   t#        | j                  dd        z   dz   S | j                  j                         S | j                  j                         S )Nr2   )r   r!      P   )r   r    	linewidthr   r   r      z ... ir    )r   r   r   r   r   r)   r   r!   r4   get_printoptionsset_printoptionsr3   __repr__splitr   r   r   repr)r.   r2   res	orig_opts	res_liness        r(   r>   zElidedWrapper.__repr__J   sb   7#dfftUm,#$..C Jz$&&%--8 ..0I #E"" yDNNaSUV &&//#C 		$I#++11)<C #E""/Y/J$466{RT$&&"+..84st;MMPSSSvv((66??$$r0   N)__name__
__module____qualname____doc__r/   staticmethodr5   r>   r;   r0   r(   r+   r+   2   s%    #
 	 	#%r0   r+   c                       e Zd ZdZd Zd Zy)ElidedPrettyPrinterzF
    PrettyPrinter subclass that elides long lists/arrays/strings
    c                 d    |j                  dd      | _        t        j                  | g|i | y )Nr      )popr   r   r/   )r.   argskwargss      r(   r/   zElidedPrettyPrinter.__init__u   s,    K5t5d5f5r0   c           	          t         j                  |      r-t        || j                  |      }| j                  ||||||      S t	        j                  | ||||||      S r-   )r+   r5   r   _formatr   )r.   valstreamr!   	allowancecontextlevel
elided_vals           r(   rQ   zElidedPrettyPrinter._formaty   s^    %%c*&sDNNFCJ<<
FFIwPUVV ((c669gu r0   N)rD   rE   rF   rG   r/   rQ   r;   r0   r(   rJ   rJ   p   s    6r0   rJ   c              #      K   t        | t              sy| |f | j                         D ]/  \  }}t        |t              st        |||fz         D ]  }|  1 yw)a  
    General, node-yielding generator.

    Yields (node, path) tuples when it finds values that are dict
    instances.

    A path is a sequence of hashable values that can be used as either keys to
    a mapping (dict) or indices to a sequence (list). A path is always wrt to
    some object. Given an object, a path explains how to get from the top level
    of that object to a nested value in the object.

    :param (dict) node: Part of a dict to be traversed.
    :param (tuple[str]) path: Defines the path of the current node.
    :return: (Generator)

    Example:

        >>> for node, path in node_generator({'a': {'b': 5}}):
        ...     print(node, path)
        {'a': {'b': 5}} ()
        {'b': 5} ('a',)

    N)r   r3   itemsnode_generator)nodepathkeyrR   items        r(   rZ   rZ      sc     0 dD!
*JJL Sc4 &sDC6M: 
s   >AAc                     |D ]  }| |   } 	 | S )aR  
    Iteratively get on obj for each key in path.

    :param (list|dict) obj: The top-level object.
    :param (tuple[str]|tuple[int]) path: Keys to access parts of obj.

    :return: (*)

    Example:

        >>> figure = {'data': [{'x': [5]}]}
        >>> path = ('data', 0, 'x')
        >>> get_by_path(figure, path)
        [5]
    r;   )objr\   r]   s      r(   get_by_pathra      s!       #hJr0   c                    t        | t              rZt        |       D ]J  \  }}t        |t        t        f      rt	        |      | |<   +t        |t
              s<	 t        |      | |<   L | S t        | t              rt        | j                               t        | j                               }}t        ||      D ]f  \  }}t        |t        t        f      rt	        |      | |<   nt        |t
              r	 t        |      | |<   | j                  |      | t        |      <   h | S # t        $ r Y w xY w# t        $ r Y <w xY wr-   )r   r   	enumerater3   decode_unicoder   UnicodeEncodeErrorkeysvaluesziprM   )collnoentryrf   valsr]   rR   s          r(   rd   rd      s#   $"4 	IB%$.)%0ReS)#&u:R	( K 
D$	$))+&T[[](;dD$ 	+HC#d|,*3/S	C% #CDI "XXc]DSN	+ K .  * s$   D$5D4$	D10D14	E ?E )rL   r7   r   r8   )r;   )r   pprintr   _plotly_utils.utilsr   r   r   _plotly_utils.data_utilsr   r)   objectr+   rJ   rZ   ra   rd   r;   r0   r(   <module>rq      sC       K K <&R;%F ;%|- (B*r0   