
    6Dh;                         S SK r S SKrS SKrS SKrS SKrS SKJr   S SKJr  \" 5       r " S S\5      r\" 5       rCS rSS jrg! \	 a	    S SK
Jr   N1f = f)	    N)reduce)gcdc                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS r0 4S jr\S 5       r\R$                  S 5       rS rS rS rS rSrg)TemplatesConfig   zG
Singleton object containing the current figure templates (aka themes)
c                 n    0 U l         / SQnU H  n[        U R                   U'   M     S U l        S U l        g )N)ggplot2seabornsimple_whiteplotlyplotly_whiteplotly_darkpresentationxgridoffygridoffgridonnone)
_templatesLazy
_validator_default)selfdefault_templatestemplate_names      F/var/www/html/env/lib/python3.13/site-packages/plotly/io/_templates.py__init__TemplatesConfig.__init__   s=     
 /M-1DOOM* /     c                 ,    [        U R                  5      $ N)lenr   r   s    r   __len__TemplatesConfig.__len__7   s    4??##r   c                     XR                   ;   $ r    )r   )r   items     r   __contains__TemplatesConfig.__contains__:   s    &&r   c                 ,    [        U R                  5      $ r    )iterr   r"   s    r   __iter__TemplatesConfig.__iter__=   s    DOO$$r   c                 $   [        U[        5      (       a  UR                  S5      nOU/n/ nU H  nU R                  U   nU[        L a  SSKJn  US:X  a  U" 0 /S9nXPR                  U'   Ou[        R                  R                  SSUS-   5      n[        R                  " S	U5      R                  S
5      n[        R                  " U5      n	U" U	SS9nXPR                  U'   UR                  U R                  U   5        M     U R                   " U6 $ )N+r   Templater   )data_scatterpackage_data	templatesz.jsonr   zutf-8F)	_validate)
isinstancestrsplitr   r   plotly.graph_objs.layoutr0   ospathjoinpkgutilget_datadecodejsonloadsappendmerge_templates)
r   r&   template_namesr3   r   templater0   r:   template_strtemplate_dicts
             r   __getitem__TemplatesConfig.__getitem__@   s    dC  !ZZ_N"VN	+M}5H4= F*'bT:H5=OOM2 77<<&]W5LD $+#3#3Hd#C#J#J7#SL$(JJ|$<M'GH5=OOM2T__];<' ,* ##Y//r   c                 @    U R                  U5      U R                  U'   g r    )r4   r   )r   keyvalues      r   __setitem__TemplatesConfig.__setitem__^   s    #~~e4r   c                 N    U R                   U	 U R                  U:X  a  S U l        g g r    )r   r   )r   rJ   s     r   __delitem__TemplatesConfig.__delitem__a   s(    OOC  ==C DM  r   c                 ~    U R                   (       d  SSKJn  U" 5       U l         U R                   R                  U5      $ )Nr   )TemplateValidator)r   plotly.validators.layoutrR   validate_coerce)r   rK   rR   s      r   r4   TemplatesConfig._validatei   s+    B/1DO..u55r   c                 6    U R                   R                  5       $ r    )r   keysr"   s    r   rW   TemplatesConfig.keysq   s    ##%%r   c                 6    U R                   R                  5       $ r    )r   itemsr"   s    r   rZ   TemplatesConfig.itemst   s    $$&&r   c                 R    [        U40 UD6R                  5        H	  u  p4X@U'   M     g)a  
Update one or more templates from a dict or from input keyword
arguments.

Parameters
----------
d: dict
    Dictionary from template names to new template values.

kwargs
    Named argument value pairs where the name is a template name
    and the value is a new template value.
N)dictrZ   )r   dkwargskvs        r   updateTemplatesConfig.updatew   s*     %f%++-DAG .r   c                     U R                   $ )aT  
The name of the default template, or None if no there is no default

If not None, the default template is automatically applied to all
figures during figure construction if no explicit template is
specified.

The names of available templates may be retrieved with:

>>> import plotly.io as pio
>>> list(pio.templates)

Returns
-------
str
)r   r"   s    r   defaultTemplatesConfig.default   s    $ }}r   c                 2    U R                  U5        Xl        g r    )r4   r   )r   rK   s     r   re   rf      s     	ur   c                 d    SR                  [        U R                  5      U R                  5       S9$ )NzuTemplates configuration
-----------------------
    Default template: {default}
    Available templates:
{available}
)re   	available)formatreprre   _available_templates_strr"   s    r   __repr__TemplatesConfig.__repr__   s4     F&$2O2O2Q  
	
r   c           	      v    SR                  [        R                  " [        [	        U 5      5      SSSS95      nU$ )zM
Return nicely wrapped string representation of all
available template names

G   z        z	         )widthinitial_indentsubsequent_indent)r;   textwrapwraprk   list)r   ri   s     r   rl   (TemplatesConfig._available_templates_str   s;    
 IIMMT$Z &")	
	 r   c                 V    U(       a  [        U R                  U5      $ SSKJn  U" 5       $ )a	  
Merge a collection of templates into a single combined template.
Templates are process from left to right so if multiple templates
specify the same propery, the right-most template will take
precedence.

Parameters
----------
args: list of Template
    Zero or more template objects (or dicts with compatible properties)

Returns
-------
template:
    A combined template object

Examples
--------

>>> pio.templates.merge_templates(
...     go.layout.Template(layout={'font': {'size': 20}}),
...     go.layout.Template(data={'scatter': [{'mode': 'markers'}]}),
...     go.layout.Template(layout={'font': {'family': 'Courier'}}))
layout.Template({
    'data': {'scatter': [{'mode': 'markers', 'type': 'scatter'}]},
    'layout': {'font': {'family': 'Courier', 'size': 20}}
})
r   r/   )r   _merge_2_templatesr8   r0   )r   argsr0   s      r   rB   TemplatesConfig.merge_templates   s%    : $114889:r   c                    U R                  U5      nU R                  U5      nUR                   H  nUR                  U   nUR                  U   nU(       d  M*  U(       d  M3  [        U5      [        U5      -  [        [        U5      [        U5      5      -  nXh[        U5      -  -  UR                  U'   Xx[        U5      -  -  UR                  U'   M     UR	                  U5        U$ )z
Helper function for merge_templates that merges exactly two templates

Parameters
----------
template1: Template
template2: Template

Returns
-------
Template:
    merged template
)r4   datar!   r   rb   )	r   	template1	template2resultother
trace_typeresult_tracesother_traceslcms	            r   rz   "TemplatesConfig._merge_2_templates   s     	*y) !++J"KK
3M ::j1L}&,'(3}-s</@AB  +8#mBT;T*UJ' *6L@Q9Q)R

:& &$ 	er   )r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r#   r'   r+   rG   rL   rO   r4   rW   rZ   rb   propertyre   setterrm   rl   rB   rz   __static_attributes__ r   r   r   r      s    8$'%0<5!6&'  $  & ^^ 	
"H'r   r   c                    SSK JnJnJn  [	        U R
                  5       GH  nUS:X  d  Xb;   a  M  X   nX   nU R                  U5      n	[        X5      (       a%  [        XxU5        UR
                  (       d  SX'   M]  M_  [        X5      (       a  U(       a  [	        U5      n
U
 Vs/ s H  oR                  PM     nnXSS S-      nU H  nUR                  nU(       a  [        5       nUR                  U;   a.  UR                  UR                  5      nU
U   n[        UUU5        OIUR                  5       n[        UUU5        U
R                  U5        UR                  UR                  5        Xl	        M  [        XU5        M     XU'   GMn  U	R                  (       a  U" U5      (       a  GM  XqU'    SX'   GM     gs  snf ! [         a     GM  f = f)z
Move style properties from fig_obj to template_obj.

Parameters
----------
fig_obj: plotly.basedatatypes.BasePlotlyType
template_obj: plotly.basedatatypes.BasePlotlyType
skip: set of str
    Set of names of properties to skip
r   )CompoundValidatorCompoundArrayValidatoris_arrayrD   Ndefaults)_plotly_utils.basevalidatorsr   r   r   rw   _props_get_validatorr5   walk_push_to_templatenamesetindex	__class__rA   array_ok
ValueError)fig_objtemplate_objskipr   r   r   propfig_valtemplate_val	validatortemplate_elementseltemplate_element_namestemplate_propdefaultsfig_elelement_name
item_indextemplate_els                     r   r   r     s     W^^$:-#)**40	i33!'>>> $ " 	::w $\ 28I%J8I"gg8I"%J$0crZ1G$H!!%{{5D{{&<<%;%A%A&++%N
&7
&C-fk4H&,&6&6&8-fk4H)00=.55fkkB #/K)&N' "* "3##8G+<+<!( $_ %" &K>  s   %F>4G
GGc                    SSK Jn  SSKJn  [	        X5      (       d  U" U 5      n U(       d  [        5       nO[        U5      nUR                  S5        [        R                  " U 5      n[        UR                  UR                  R                  R                  US9  0 n[        UR                  5       H  nUR                  UR                  S5      n[        UR                  R                  R                  UR                     5      n[!        U5      U::  a0  UR#                  UR%                  5       5        [!        U5      U::  a  M0  X   n	[        XiUS9  XR                  R                  R                  UR                  '   US-   XVR                  '   M     Sn
UR                  R                  R                   H  nUR                  R                  R                  U   nU Vs/ s H  ofR'                  5       SU0:H  PM     nn[)        U5      (       a%  S	UR                  R                  R                  U'   M  S
n
M     U
(       d  S	UR                  R                  l        U$ s  snf )a	  
Return a copy of a figure where all styling properties have been moved
into the figure's template.  The template property of the resulting figure
may then be used to set the default styling of other figures.

Parameters
----------
fig
    Figure object or dict representing a figure
skip
    A collection of names of properties to skip when moving properties to
    the template. Defaults to ('title', 'text') so that the text
    of figure titles, axis titles, and annotations does not become part of
    the template

Examples
--------
Imports

>>> import plotly.graph_objs as go
>>> import plotly.io as pio

Construct a figure with large courier text

>>> fig = go.Figure(layout={'title': 'Figure Title',
...                         'font': {'size': 20, 'family': 'Courier'},
...                         'template':"none"})
>>> fig # doctest: +NORMALIZE_WHITESPACE
Figure({
    'data': [],
    'layout': {'font': {'family': 'Courier', 'size': 20},
               'template': '...', 'title': {'text': 'Figure Title'}}
})

Convert to a figure with a template. Note how the 'font' properties have
been moved into the template property.

>>> templated_fig = pio.to_templated(fig)
>>> templated_fig.layout.template
layout.Template({
    'layout': {'font': {'family': 'Courier', 'size': 20}}
})
>>> templated_fig
Figure({
    'data': [], 'layout': {'template': '...', 'title': {'text': 'Figure Title'}}
})


Next create a new figure with this template

>>> fig2 = go.Figure(layout={
...     'title': 'Figure 2 Title',
...     'template': templated_fig.layout.template})
>>> fig2.layout.template
layout.Template({
    'layout': {'font': {'family': 'Courier', 'size': 20}}
})

The default font in fig2 will now be size 20 Courier.

Next, register as a named template...

>>> pio.templates['large_courier'] = templated_fig.layout.template

and specify this template by name when constructing a figure.

>>> go.Figure(layout={
...     'title': 'Figure 3 Title',
...     'template': 'large_courier'}) # doctest: +ELLIPSIS
Figure(...)

Finally, set this as the default template to be applied to all new figures

>>> pio.templates.default = 'large_courier'
>>> fig = go.Figure(layout={'title': 'Figure 4 Title'})
>>> fig.layout.template
layout.Template({
    'layout': {'font': {'family': 'Courier', 'size': 20}}
})

Returns
-------
go.Figure
r   )
BaseFigure)Figureuid)r      FtypeNT)plotly.basedatatypesr   plotly.graph_objsr   r5   r   addcopydeepcopyr   layoutrD   rw   r~   getr   r!   rA   r   to_plotly_jsonall)figr   r   r   templated_figtrace_type_indexestracetemplate_indextemplate_tracestemplate_traceany_non_emptyr   tracesis_emptys                 r   to_templatedr   ]  s   n 0(c&&Sk u4y 	HHUO MM#&M m22;;BB
 m(()+//

A> }33<<AA%**MN/"n4""5??#45 /"n4
 )8 	e$? :I%%**5::6 *8!);::&' *, M#**3388
%%..33J?PVWPVu((*vz.BBPVWx===AM  ))..z: M 9 -1%%* Xs   "I!))titletext)ru   r<   r   r9   r?   	functoolsr   mathr   ImportError	fractionsobjectr   r   r3   r   r   r   r   r   <module>r      sf       	   x
vf vv 	
CLSe
  s   A AA