
    6DhI                         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Jr  S SK	J
r
  S SKJr   " S S\5      r\" 5       rS rS	r\S
-   rS rSS jrSS jrSS jrSS jrSS jrSS jrS rg)    N)Path)validate_coerce_fig_to_dictvalidate_coerce_output_type)
get_module)ImageUriValidatorc                   b    \ rS rSrSrS r\S 5       r\R                  S 5       r\	S 5       r
Srg)	
JsonConfig   )jsonorjsonautoc                     SU l         g )Nr   _default_engineselfs    A/var/www/html/env/lib/python3.13/site-packages/plotly/io/_json.py__init__JsonConfig.__init__   s
    %    c                     U R                   $ Nr   r   s    r   default_engineJsonConfig.default_engine   s    ###r   c                     U[         R                  ;  a'  [        SR                  [         R                  US95      eUS:X  a  U R	                  5         Xl        g )Nz9Supported JSON engines include {valid}
    Received {val})validvalr   )r	   _valid_engines
ValueErrorformatvalidate_orjsonr   )r   r   s     r   r   r      sR    j///%%+V*2K2KQTV%U 
 (?  ""r   c                 6    [        S5      nUc  [        S5      eg )Nr   z-The orjson engine requires the orjson package)r   r   )clsr   s     r   r!   JsonConfig.validate_orjson%   s"    H%>LMM r   r   N)__name__
__module____qualname____firstlineno__r   r   propertyr   setterclassmethodr!   __static_attributes__ r   r   r	   r	      sP    /N& $ $ 
# 
# N Nr   r	   c                     U S;   a  gU $ )zE
This is used to ultimately *encode* into strict JSON, see `encode`

)Infinityz	-InfinityNaNNr-   )consts    r   coerce_to_strictr2   /   s     00r   ))<z\u003c)>z\u003e)/z\u002f))u    z\u2028)u    z\u2029c                 P    U nU H  u  p4X2;   d  M  UR                  X45      nM     U$ r   )replace)json_str_swapoutunsafe_char	safe_chars        r   _safer=   F   s/    
C"'++k5C #( Jr   c                    [        SSS9nUc  [        R                  nUS:X  a	  Ub  SnOSnOUS;  a  [        SU-  5      e[        S	S
S9[        SS
S9[        SS
S9[        SS
S9S.nUS:X  aA  0 nU(       a  SUS'   OSUS'   SSKJn  [        [        R                  " U 4SU0UD6[        5      $ US:X  a  [        R                  5         UR                  UR                  -  nU(       a  XSR                  -  n U R                  5       n  [        UR                  XS9R#                  S5      [$        5      $ g! [          a     N:f = f! [&         a     Of = f[)        U SSUS9n[        UR                  XuS9R#                  S5      [$        5      $ )am  
Convert a plotly/Dash object to a JSON string representation

Parameters
----------
plotly_object:
    A plotly/Dash object represented as a dict, graph_object, or Dash component

pretty: bool (default False)
    True if JSON representation should be pretty-printed, False if
    representation should be as compact as possible.

engine: str (default None)
    The JSON encoding engine to use. One of:
      - "json" for an engine based on the built-in Python json module
      - "orjson" for a faster engine that requires the orjson package
      - "auto" for the "orjson" engine if available, otherwise "json"
    If not specified, the default engine is set to the current value of
    plotly.io.json.config.default_engine.

Returns
-------
str
    Representation of input object as a JSON string

See Also
--------
to_json : Convert a plotly Figure to JSON with validation
r   Tshould_loadNr   r   r   r   Invalid json engine: %szsage.allFnumpypandasz	PIL.Image)sage_allnppdimage   indent),:
separatorsr   )PlotlyJSONEncoderr#   )optionutf8)numpy_alloweddatetime_allowedmodules)r   configr   r   _plotly_utils.utilsrN   r=   r   dumps
_swap_jsonr	   r!   OPT_NON_STR_KEYSOPT_SERIALIZE_NUMPYOPT_INDENT_2to_plotly_jsonAttributeErrordecode_swap_orjson	TypeErrorclean_to_json_compatible)plotly_objectprettyenginer   rS   optsrN   cleaneds           r   to_json_plotlyrf   N   s   < d3F ~&&FF	)	)2V;<< zu=e4u5KU;	G DN ",D9JJ}D*;DtDj
 	
 
8	""$&&)C)CC'''D	)88:M
	]8??G  
  		  		 +!	
 V\\'\7>>vFUUs$   8D6 	+E 6
EE
EEc                     [        X5      nU(       a+  UR                  S/ 5       H  nUR                  SS5        M     [        XRUS9$ )a2  
Convert a figure to a JSON string representation

Parameters
----------
fig:
    Figure object or dict representing a figure

validate: bool (default True)
    True if the figure should be validated before being converted to
    JSON, False otherwise.

pretty: bool (default False)
    True if JSON representation should be pretty-printed, False if
    representation should be as compact as possible.

remove_uids: bool (default True)
    True if trace UIDs should be omitted from the JSON representation

engine: str (default None)
    The JSON encoding engine to use. One of:
      - "json" for an engine based on the built-in Python json module
      - "orjson" for a faster engine that requires the orjson package
      - "auto" for the "orjson" engine if available, otherwise "json"
    If not specified, the default engine is set to the current value of
    plotly.io.json.config.default_engine.

Returns
-------
str
    Representation of figure as a JSON string

See Also
--------
to_json_plotly : Convert an arbitrary plotly graph_object or Dash component to JSON
datauidN)rb   rc   )r   getpoprf   )figvalidaterb   remove_uidsrc   fig_dicttraces          r   to_jsonrq      sF    N +39H \\&"-EIIeT" . (&AAr   c                 .   [        XX4US9n[        U[        5      (       a  [        U5      nO[        U[        5      (       a  UnOSnUc   UR	                  U5        gUR                  U5        g! [
         a     Of = f[        SR                  US95      e)a  
Convert a figure to JSON and write it to a file or writeable
object

Parameters
----------
fig:
    Figure object or dict representing a figure

file: str or writeable
    A string representing a local file path or a writeable object
    (e.g. a pathlib.Path object or an open file descriptor)

pretty: bool (default False)
    True if JSON representation should be pretty-printed, False if
    representation should be as compact as possible.

remove_uids: bool (default True)
    True if trace UIDs should be omitted from the JSON representation

engine: str (default None)
    The JSON encoding engine to use. One of:
      - "json" for an engine based on the built-in Python json module
      - "orjson" for a faster engine that requires the orjson package
      - "auto" for the "orjson" engine if available, otherwise "json"
    If not specified, the default engine is set to the current value of
    plotly.io.json.config.default_engine.
Returns
-------
None
)rm   rb   rn   rc   NzX
The 'file' argument '{file}' is not a string, pathlib.Path object, or file descriptor.
)file)	rq   
isinstancestrr   writer\   r   r    
write_text)rl   rs   rm   rb   rn   rc   r8   paths           r   
write_jsonry      s    H vvH $Dz	D$		  |	JJx  	!  		
F  
 	
s   A/ /
A<;A<c                    [        SSS9n[        U [        [        45      (       d"  [	        SR                  [        U 5      U S95      eUc  [        R                  nUS:X  a	  Ub  SnOSnOUS;  a  [	        S	U-  5      eUS:X  a'  [        R                  5         UR                  U 5      nU$ [        U [        5      (       a  U R                  S
5      n [        R                  " U 5      nU$ )a  
Parse JSON string using the specified JSON engine

Parameters
----------
value: str or bytes
    A JSON string or bytes object

engine: str (default None)
    The JSON decoding engine to use. One of:
      - if "json", parse JSON using built in json module
      - if "orjson", parse using the faster orjson module, requires the orjson
        package
      - if "auto" use orjson module if available, otherwise use the json module

    If not specified, the default engine is set to the current value of
    plotly.io.json.config.default_engine.

Returns
-------
dict

See Also
--------
from_json_plotly : Parse JSON with plotly conventions into a dict
r   Tr?   zr
from_json_plotly requires a string or bytes argument but received value of type {typ}
    Received value: {value})typvaluer   r   rA   rB   zutf-8)r   rt   ru   bytesr   r    typerT   r   r	   r!   loadsr]   r   )r|   rc   r   
value_dicts       r   from_json_plotlyr   ,  s    6 d3F ec5\**%vKu  &  
 	
 ~&&FF	)	)2V;<<""$\\%(
 	 eU##LL)EZZ&
r   c                 :    [        XS9n[        U5      nU" XBS9nU$ )a>  
Construct a figure from a JSON string

Parameters
----------
value: str or bytes
    String or bytes object containing the JSON representation of a figure

output_type: type or str (default 'Figure')
    The output figure type or type name.
    One of:  graph_objs.Figure, 'Figure', graph_objs.FigureWidget, 'FigureWidget'

skip_invalid: bool (default False)
    False if invalid figure properties should result in an exception.
    True if invalid figure properties should be silently ignored.

engine: str (default None)
    The JSON decoding engine to use. One of:
      - if "json", parse JSON using built in json module
      - if "orjson", parse using the faster orjson module, requires the orjson
        package
      - if "auto" use orjson module if available, otherwise use the json module

    If not specified, the default engine is set to the current value of
    plotly.io.json.config.default_engine.

Raises
------
ValueError
    if value is not a string, or if skip_invalid=False and value contains
    invalid figure properties

Returns
-------
Figure or FigureWidget
)rc   )skip_invalid)r   r   )r|   output_typer   rc   ro   r#   rl   s          r   	from_jsonr   m  s,    P  5H &k
2C h
2CJr   c                     [        U [        5      n[        U [        5      (       a  [        U 5      nO[        U [        5      (       a  U nOSnUb  UR                  5       nOU R	                  5       n[        XbXS9$ )a*  
Construct a figure from the JSON contents of a local file or readable
Python object

Parameters
----------
file: str or readable
   A string containing the path to a local file or a read-able Python
   object (e.g. a pathlib.Path object or an open file descriptor)

output_type: type or str (default 'Figure')
    The output figure type or type name.
    One of:  graph_objs.Figure, 'Figure', graph_objs.FigureWidget, 'FigureWidget'

skip_invalid: bool (default False)
    False if invalid figure properties should result in an exception.
    True if invalid figure properties should be silently ignored.

engine: str (default None)
    The JSON decoding engine to use. One of:
      - if "json", parse JSON using built in json module
      - if "orjson", parse using the faster orjson module, requires the orjson
        package
      - if "auto" use orjson module if available, otherwise use the json module

    If not specified, the default engine is set to the current value of
    plotly.io.json.config.default_engine.

Returns
-------
Figure or FigureWidget
N)r   r   rc   )rt   ru   r   	read_textreadr   )rs   r   r   rc   file_is_strrx   r8   s          r   	read_jsonr     ss    J T3'K$Dz	D$		  >>#99;  r   c           
      4   [        U [        [        [        45      (       a  U $ [        U [        5      (       a0  U R                  5        VVs0 s H  u  p#U[        U40 UD6_M     snn$ [        U [        [        45      (       a$  U (       a  U  Vs/ s H  n[        U40 UD6PM     sn$ UR                  SS5      nUR                  SS5      nUR                  S0 5      nUS   nUS   nUS   n	US   n
Ub4  XR                  ;   a  [        U 5      $ XR                  ;   a  [        U 5      $ UGb,  XR                  R                  R                  L a  [        S	5      $ [        XR                  5      (       a  U(       a+  U R                   R"                  S
;   a  UR%                  U 5      $ U R                   R"                  S:X  a  UR'                  U 5      R)                  5       $ U R                   R"                  S:X  a  U R)                  5       $ U R                   R"                  S:X  a  U R)                  5       n O%[        XR*                  5      (       a  [        U 5      $ U	Gb{  X	R,                  L d  X	R.                  L a  g [        X	R0                  U	R2                  45      (       Ga7  U(       a5  U R                   R"                  S
;   a  UR%                  U R4                  5      $ U R                   R"                  S:X  a  [        X	R0                  5      (       aq  [6        R8                  " 5          [6        R:                  " S[<        5        UR?                  U R@                  RC                  5       5      R)                  5       nS S S 5        OU RC                  5       R)                  5       nU(       d/  [E        [G        W5      5       H  nX   RI                  5       X'   M     W$  U RC                  5       n U(       d   U RI                  5       $ [        U [N        RN                  5      (       a  U $  U R)                  5       $ s  snnf s  snf ! , (       d  f       N= f! [J        [L        4 a     Nxf = f! [J        [L        4 a     NUf = f! [L         a     Of = f[        U [P        RR                  5      (       a  [        U 5      $ U
b0  [        X
RT                  5      (       a  [V        RX                  " U 5      $  U R[                  5       n O! [L         a     Of = f[        U [        5      (       a6  U R                  5        VVs0 s H  u  p#U[        U40 UD6_M     snn$ s  snnf [        U [        [        45      (       a)  U (       a"  U  Vs/ s H  n[        U40 UD6PM     sn$ s  snf U $ )NrQ   FrR   rS   rE   rF   rG   rH   nan)biufMUOignore).rt   intfloatru   dictitemsr`   listtuplerj   RRZZmacoremaskedndarraydtypekindascontiguousarraydatetime_as_stringtolist
datetime64NaTNASeriesDatetimeIndexvalueswarningscatch_warningssimplefilterFutureWarningarraydtto_pydatetimerangelen	isoformatr_   r\   datetimedecimalDecimalImager   pil_image_to_urir[   )objkwargskvrQ   rR   rS   rE   rF   rG   rH   	dt_valuesr   s                r   r`   r`     s   
 #UC())
#tEHYY[Q[TQ+A888[QQ	C$	'	'CFG3a,Q9&93GG JJ6Mzz"4e<jjB'Gz"H	B	BGE ++:KKs8O 
~%%**###<ZZ((3G!G++C003&,,S188::3&zz|#3&jjl]]++s8O 
~&&=C55Lii)9)9:;;3G!G++CJJ773&c99--!002 --hF %'HHSVV-A-A-C$D$K$K$M		 32 !$ 1 1 3 : : <I' #3y>2'0|'='='?	 3 !  ! 	==?" 
C**	+	+
zz|k R H\ 32, ~&  >* 		   #w''Sz Z[[99 11#66  "  #tEHYY[Q[TQ+A888[QQQ	C$	'	'CFG3a,Q9&93GGGJsm   P2P8%AP=Q 0Q$ "Q: =
QQ! Q!$Q76Q7:
RR(S9 9
TT1U:V)FN)TFTNr   )FigureFN)r   r   r   r   pathlibr   plotly.io._utilsr   r   _plotly_utils.optional_importsr   _plotly_utils.basevalidatorsr   objectr	   rT   r2   rW   r^   r=   rf   rq   ry   r   r   r   r`   r-   r   r   <module>r      s         U 5 :
N N< 
	

   ]V@/BdI"X>B1h<~xr   