o
    h(
                     @   sh   d Z ddlZddlmZ g dZdd Zdd Zd	d
 Zdd ZefddZ	dd Z
G dd deZdS )z'
Support serializing objects into JSON
    N)
PydeckType)
mapbox_keygoogle_maps_keydeck_widgetbinary_data_sets_binary_data_tooltip_kwargsc                 C   sP   d}d}t | D ]\}}|dkr|dkrd}q|r||  n|| }d}q|S )a.  Makes a snake case string into a camel case one

    Parameters
    -----------
    snake_case : str
        Snake-cased string (e.g., "snake_cased") to be converted to camel-case (e.g., "camelCase")

    Returns
    -------
    str
        Camel-cased (e.g., "camelCased") version of input string
     F_r   T)	enumerateupper)
snake_case
output_strshould_upper_caseic r   N/var/www/vscode/kcb/lib/python3.10/site-packages/pydeck/bindings/json_tools.pyto_camel_case   s   r   c                 C   s$   | r| d d   | dd   S dS )N   r
   )lower)sr   r   r   lower_first_letter,   s   $r   c                 C   s   t t| S N)r   r   )wr   r   r   camel_and_lower0   s   r   c                 C   sD   t |  D ]}d|vrq|dkrd}nt|}| || |< qdS )zMakes all the keys in a dictionary camel-cased and lower-case

    Parameters
    ----------
    attrs : dict
        Dictionary for which all the keys should be converted to camel-case
    r   _datadataN)listkeysr   pop)attrs	snake_key	camel_keyr   r   r   lower_camel_case_keys4   s   r%   c                 C   sZ   t t| trt| S t| }dd | D }tD ]
}||r$||= q|r+|| |S )z3Default method for rendering JSON from a dictionaryc                 S   s   i | ]\}}|d ur||qS r   r   ).0kvr   r   r   
<dictcomp>K   s    z%default_serialize.<locals>.<dictcomp>)
issubclasstyper   reprvarsitemsIGNORE_KEYSget)oremap_functionr"   ignore_attrr   r   r   default_serializeF   s   
r4   c                 C   s   t j| dtddS )z,Takes a serializable object and JSONifies itT   )	sort_keysdefaultindent)jsondumpsr4   )serializabler   r   r   	serializeT   s   r<   c                   @   s   e Zd Zdd Zdd ZdS )	JSONMixinc                 C      t | S )zu
        Override of string representation method to return a JSON-ified version of the
        Deck object.
        r<   selfr   r   r   __repr__Z   s   zJSONMixin.__repr__c                 C   r>   )zA
        Return a JSON-ified version of the Deck object.
        r?   r@   r   r   r   to_jsona   s   zJSONMixin.to_jsonN)__name__
__module____qualname__rB   rC   r   r   r   r   r=   Y   s    r=   )__doc__r9   pydeck.types.baser   r/   r   r   r   r%   r4   r<   objectr=   r   r   r   r   <module>   s    