
    #Yh2                    |   U d dl mZ d dlZd dlmZmZmZmZmZ ddl	m
Z
mZ ddlmZ erd dlZej        dk    rd dlmZ nd dlmZ ed	         Zd
ed<   e	 	 	 	 	 	 d4d5d            Ze	 	 	 	 	 	 d4d6d             Ze	 	 	 	 	 	 d4d7d"            Ze	 	 	 	 	 	 d4d8d%            Z	 	 	 	 	 	 d9d:d'Z	 	 d;d<d/Zd=d1Zd2 Zd>d3ZdS )?    )annotationsN)TYPE_CHECKINGAnyLiteralcastoverload   )import_vl_convertvl_version_for_vl_convert)spec_to_html)   
   )	TypeAlias)htmljsonpngsvgpdfvega	vega-liter   MimeBundleFormat.specdict[str, Any]formatLiteral['json', 'vega-lite']modeLiteral['vega-lite'] | Nonevega_version
str | Nonevegaembed_versionvegalite_versionembed_optionsdict[str, Any] | NoneengineLiteral['vl-convert'] | Nonereturndict[str, dict[str, Any]]c                    d S N 	r   r   r   r   r    r!   r"   r$   kwargss	            _D:\DownLoads\facial_attendance_system-main\venv311\Lib\site-packages\altair/utils/mimebundle.pyspec_to_mimebundler.      s	     !$    Literal['html']dict[str, str]c                    d S r)   r*   r+   s	            r-   r.   r.   "   	     Sr/   Literal['pdf', 'svg', 'vega']c                    d S r)   r*   r+   s	            r-   r.   r.   .   r3   r/   Literal['png']%tuple[dict[str, Any], dict[str, Any]]c                    d S r)   r*   r+   s	            r-   r.   r.   :   s	     -0Cr/   6dict[str, Any] | tuple[dict[str, Any], dict[str, Any]]c           	     J   ddl m}	 ddlm}
m} |dk    rd}t          |          |} |            r |
|           } d}||	j                            di           }n|}t          |          }|d	v rTt          | t          t          d
         |          |f||                    dd          |                    dd          d|S |dk    rt          | f|||||d|}d|iS |dk    r!|d}t          |          d|d          d| iS |dk    rd| iS d}t          |          )aE  
    Convert a vega-lite specification to a mimebundle.

    The mimebundle type is controlled by the ``format`` argument, which can be
    one of the following ['html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite']

    Parameters
    ----------
    spec : dict
        a dictionary representing a vega-lite plot spec
    format : string {'html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite'}
        the file format to be saved.
    mode : string {'vega-lite'}
        The rendering mode.
    vega_version : string
        The version of vega.js to use
    vegaembed_version : string
        The version of vegaembed.js to use
    vegalite_version : string
        The version of vegalite.js to use. Only required if mode=='vega-lite'
    embed_options : dict (optional)
        The vegaEmbed options dictionary. Defaults to the embed options set with
        alt.renderers.set_embed_options().
        (See https://github.com/vega/vega-embed for details)
    engine: string {'vl-convert'}
        the conversion engine to use for 'png', 'svg', 'pdf', and 'vega' formats
    **kwargs :
        Additional arguments will be passed to the generating function

    Returns
    -------
    output : dict
        a mime-bundle representing the image

    Note
    ----
    The png, svg, pdf, and vega outputs require the vl-convert package
    r   )	renderers)compile_with_vegafusionusing_vegafusionr   zmode must be 'vega-lite'r   Nr"   >   r   r   r   r   )r   r   r   r   formatLocaletimeFormatLocale)r$   format_localetime_format_localer   )r   r   r    r!   r"   z	text/htmlzMust specify vegalite_versionzapplication/vnd.vegalite.vz+jsonr   zapplication/jsonzPformat must be one of ['html', 'json', 'png', 'svg', 'pdf', 'vega', 'vega-lite'])altairr;   altair.utils.displayr<   r=   
ValueErroroptionsgetpreprocess_embed_options_spec_to_mimebundle_with_enginer   r   r   )r   r   r   r   r    r!   r"   r$   r,   r;   r<   r=   msginternal_modefinal_embed_optionsr   s                   r-   r.   r.   F   s   d !     NNNNNNNN{(oo26M &&t,, '/33ORHH+,-@AAM....45v>>
 '++NDAA,001CTJJ
 
 
 
 	
 
6		
%/-'
 
 
 
 T""	;		#1CS//!G-=a-@GGGNN	6		"D))I 	 oor/   dict$Literal['png', 'svg', 'pdf', 'vega']Literal['vega-lite', 'vega']r@   str | dict | NonerA   r   c                   |                     dd          }t          ||          }|dk    rt                      }t                      }	|dk    r$|dk    r| }
n|                    | |	          }
d|
iS |dk    r<|dk    r|                    | ||          }n|                    | |	||	          }d
|iS |dk    r|                    dd          }d}|                    d|          }|dk    r|                    | ||||          }n|	                    | |	||||          }||z  }t          |          \  }}d|id||z  ||z  difS |dk    rT|                    dd          }|dk    r|                    | |||          }n|                    | |	|||          }d|iS d|}t          |          d|}t          |          )a  
    Helper for Vega-Lite to mimebundle conversions that require an engine.

    Parameters
    ----------
    spec : dict
        a dictionary representing a vega-lite plot spec
    format : string {'png', 'svg', 'pdf', 'vega'}
        the format of the mimebundle to be returned
    mode : string {'vega-lite', 'vega'}
        The rendering mode.
    engine: string {'vl-convert'}
        the conversion engine to use
    format_locale : str or dict
        d3-format locale name or dictionary. Defaults to "en-US" for United States English.
        See https://github.com/d3/d3-format/tree/main/locale for available names and example
        definitions.
    time_format_locale : str or dict
        d3-time-format locale name or dictionary. Defaults to "en-US" for United States English.
        See https://github.com/d3/d3-time-format/tree/main/locale for available names and example
        definitions.
    **kwargs :
        Additional arguments will be passed to the conversion function
    r$   N	vlconvertr   )
vl_versionzapplication/vnd.vega.v5+jsonr   )r@   rA   )rR   r@   rA   zimage/svg+xmlr   scale_factorr	   H   ppi)scalerU   r@   rA   )rR   rV   rU   r@   rA   z	image/png)widthheightr   )rV   r@   rA   )rR   rV   r@   rA   zapplication/pdfzUnexpected format zUnexpected normalized_engine )pop_validate_normalize_enginer
   r   vegalite_to_vegavega_to_svgvegalite_to_svgrF   vega_to_pngvegalite_to_png_pngxyvega_to_pdfvegalite_to_pdfrD   )r   r   r   r@   rA   r,   r$   normalized_enginevlcrR   vgr   rV   default_ppirU   r   factorwhr   rI   s                        r-   rH   rH      s   D ZZ$''F266BBK''!!.00
Vv~~))$:)FF2B77u__v~~oo"/'9 &   )))"/'9	 *   $S))u__JJ~q11EK**UK00Cv~~oo"/'9 &   )))"/'9 *   ;&F#;;DAq%q6zQZHH(   u__JJ~q11Ev~~oo"/'9	 &   )))"/'9 *   &s++ 2v11CS//! D.?CCoor/   strc                `   	 t                      }n# t          $ r d}Y nw xY w| dn;|                                                     dd                              dd          }|dk    r|d}t	          |          n1||d}n*d|d}t	          |          d	| d
}t	          |          |S )z
    Helper to validate and normalize the user-provided engine.

    engine : {None, 'vl-convert'}
        the user-provided engine string
    format : string {'png', 'svg', 'pdf', 'vega'}
        the format of the mimebundle to be returned
    N- _rQ   zIThe 'vl-convert' conversion engine requires the vl-convert-python packagezSaving charts in z format requires the vl-convert-python package: see https://altair-viz.github.io/user_guide/saving_charts.html#png-svg-and-pdf-formatzInvalid conversion engine z. Expected vl-convert)r
   ImportErrorlowerreplacerD   )r$   r   rd   rc   rI   s        r-   rZ   rZ   &  s    !!   
 FLLNN$:$:3$C$C$K$KCQS$T$T 
 K'';]CS//!  
	"? +hF h h h  S//!J6JJJoos      c                r    |                      d          }t          j        d| |dz   |dz                      S )zU
    read the (width, height) from a PNG header.

    Taken from IPython.display
    s   IHDRz>ii      )indexstructunpack)dataihdrs     r-   r`   r`   Q  s9     ::gD=TAXr	%9 :;;;r/   c                v   | pi                                  } |                     dd          }t          |t                    r&t	                      }|                    |          | d<   |                     dd          }t          |t                    r&t	                      }|                    |          | d<   | S )a  
    Preprocess embed options to a form compatible with Vega Embed.

    Parameters
    ----------
    embed_options : dict
        The embed options dictionary to preprocess.

    Returns
    -------
    embed_opts : dict
        The preprocessed embed options dictionary.
    r>   Nr?   )copyrF   
isinstancerj   r
   get_format_localeget_time_format_locale)r"   r@   rd   rA   s       r-   rG   rG   \  s     #(b..00M "%%nd;;M-%% M!!(+(=(=m(L(Ln%&**+=tDD$c** 
!!,/,F,F-
 -
() r/   )......)r   r   r   r   r   r   r   r   r    r   r!   r   r"   r#   r$   r%   r&   r'   )r   r   r   r0   r   r   r   r   r    r   r!   r   r"   r#   r$   r%   r&   r1   )r   r   r   r4   r   r   r   r   r    r   r!   r   r"   r#   r$   r%   r&   r   )r   r   r   r6   r   r   r   r   r    r   r!   r   r"   r#   r$   r%   r&   r7   )NNNNNN)r   r   r   r   r   r   r   r   r    r   r!   r   r"   r#   r$   r%   r&   r9   )NN)r   rL   r   rM   r   rN   r@   rO   rA   rO   r&   r   )r$   r%   r   rM   r&   rj   )r"   rL   r&   rL   )
__future__r   rv   typingr   r   r   r   r   
_importersr
   r   r   r   sysversion_infor   typing_extensionsr   __annotations__r.   rH   rZ   r`   rG   r*   r/   r-   <module>r      s_   " " " " " " "  > > > > > > > > > > > > > > D D D D D D D D       0JJJ
7""$$$$$$$//////%<     
 
 ),"$'#&+.+.
$ 
$ 
$ 
$ 

$ 
 ),"$'#&+.+.
 
 
 
 

 
 ),"$'#&+.+.
 
 
 
 

 
 ),"$'#&+.+.
0 
0 
0 
0 

0 )-#$(#'+/+/g g g g g\ (,,0s s s s sl( ( ( (V< < <     r/   