o
    NhY                     @   sd   d dl mZ d dlZd dlmZ d dlmZ dd Zdd Z	de
d	ee
 fd
dZe fddZdS )    )ListN)get_plotlyjs_versionc                 C   sx   ddl m} t| |r|  }|S t| tr&|r"tj|  }|S | }|S t	| dr1|  }|S t
djt| | d)Nr   )
BaseFigureto_plotly_jsonzR
The fig parameter must be a dict or Figure.
    Received value of type {typ}: {v})typv)plotly.basedatatypesr   
isinstanceto_dictdictplotly
graph_objsFigurer   hasattr
ValueErrorformattype)figvalidater   fig_dict r   Q/var/www/html/Persson_Maskin/env/lib/python3.10/site-packages/plotly/io/_utils.pyvalidate_coerce_fig_to_dict   s$   

	

r   c                 C   sJ   | dks	| t jkrt j}|S | dkstt dr!| t jkr!t j}|S td)Nr   FigureWidgetzP
Invalid output type: {output_type}
    Must be one of: 'Figure', 'FigureWidget')gor   r   r   r   )output_typeclsr   r   r   validate_coerce_output_type   s   
r   kwargsreturnc                     sr   dd t |  D }|rtt|dkrtd|r|d ndfdd|  D   fddtD }|S )	a  
    Given one or more keyword arguments which may be either a single value or a list of values,
    return a list of keyword dictionaries by broadcasting the single valuesacross all the dicts.
    If more than one item in the input is a list, all lists must be the same length.

    Parameters
    ----------
    **kwargs: dict
        The keyword arguments

    Returns
    -------
    list of dicts
        A list of dictionaries

    Raises
    ------
    ValueError
        If any of the input lists are not the same length
    c                 S   s   g | ]}t |trt|qS r   )r	   listlen).0r   r   r   r   
<listcomp>F   s    z+broadcast_args_to_dicts.<locals>.<listcomp>   z-All list arguments must have the same length.r   c                    s*   i | ]\}}|t |ts|g  n|qS r   )r	   r    r"   kr   )list_lengthr   r   
<dictcomp>L   s    z+broadcast_args_to_dicts.<locals>.<dictcomp>c                    s"   g | ]  fd d  D qS )c                    s   i | ]	\}}||  qS r   r   r%   ir   r   r(   S   s    z6broadcast_args_to_dicts.<locals>.<listcomp>.<dictcomp>)items)r"   )expanded_kwargsr)   r   r#   R   s    )tuplevaluesr!   setr   r+   range)r   list_lengthslist_of_kwargsr   )r,   r'   r   broadcast_args_to_dicts.   s   

r3   c                 C   s   dj | dS )zReturn a valid plotly CDN url.z+https://cdn.plot.ly/plotly-{cdn_ver}.min.jscdn_ver)r   r4   r   r   r   plotly_cdn_urlY   s   r6   )typingr   r   plotly.graph_objsr   r   plotly.offliner   r   r   r   r3   r6   r   r   r   r   <module>   s    +