o
    "iy	                     @   s   d Z ddlmZmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
mZmZ ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZ g dZedZG dd deZdefddZ eede	de	defddZ!dS )z#Preconfigured converters for ujson.    )	b85decode	b85encode)Set)datedatetime)AnyAnyStrTypeVarUnion)dumpsloads   )BaseConverter	Converter)identity)is_literal_containing_enums)configure_union_passthrough   )is_primitive_enum'literals_with_enums_unstructure_factorywrap)UjsonConverterconfigure_convertermake_converterTc                	   @   sF   e Zd ZddedededefddZded	ee dedefd
dZ	dS )r   Nobjunstructure_askwargsreturnc                 K   s   t | j||dfi |S )N)r   )r   unstructure)selfr   r   r    r!   T/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/preconf/ujson.pyr      s   zUjsonConverter.dumpsdataclc                 K   s   |  t|fi ||S N)	structurer   )r    r#   r$   r   r!   r!   r"   r      s   zUjsonConverter.loadsr%   )
__name__
__module____qualname__r   strr   r   typer   r   r!   r!   r!   r"   r      s    "r   	converterc                 C   s   |  tdd  | tdd  |  tdd  | tdd  |  tdd  | tdd  | tt | t	t
 ttttttdf |  dS )	af  
    Configure the converter for use with the ujson library.

    * bytes are serialized as base64 strings
    * datetimes are serialized as ISO 8601
    * sets are serialized as lists
    * string and int enums are passed through when unstructuring

    .. versionchanged:: 24.2.0
        Enums are left to the library to unstructure, speeding them up.
    c                 S   s   | r	t | dS ddS )N    utf8)r   decodevr!   r!   r"   <lambda>*   s    z%configure_converter.<locals>.<lambda>c                 S   s   t | S r%   )r   r1   _r!   r!   r"   r2   ,       c                 S      |   S r%   	isoformatr0   r!   r!   r"   r2   .   r5   c                 S   
   t | S r%   )r   fromisoformatr3   r!   r!   r"   r2   /      
 c                 S   r6   r%   r7   r0   r!   r!   r"   r2   0   r5   c                 S   r9   r%   )r   r:   r3   r!   r!   r"   r2   1   r;   N)register_unstructure_hookbytesregister_structure_hookr   r   register_unstructure_hook_funcr   r   !register_unstructure_hook_factoryr   r   r   r
   r*   boolintfloat)r,   r!   r!   r"   r      s   r   argsr   r   c                  O   s2   t ti|di |d< t| i |}t| |S )Nunstruct_collection_overrides)r   listgetr   r   )rD   r   resr!   r!   r"   r   9   s   
r   N)"__doc__base64r   r   collections.abcr   r   r   typingr   r   r	   r
   ujsonr   r   
convertersr   r   fnsr   literalsr   
strategiesr    r   r   r   __all__r   r   r   r   r!   r!   r!   r"   <module>   s"    