a
    $ñ»j"  ã                   @  s0  d dl mZ d dlZd dlZd dlmZ ddlmZmZ ddl	m
Z
 ddl	mZ eG dd	„ d	ƒƒZeG d
d„ dƒƒZeG dd„ dƒƒZeG dd„ dƒƒZeG dd„ dƒƒZG dd„ dejƒZeG dd„ dƒƒZd*ddddddœdd„Zdddœd d!„Zdd"œd#d$„Zdd"œd%d&„Zed'ƒeG d(d)„ d)ƒƒƒZdS )+é    )ÚannotationsN)Ú	dataclassé   )Úevent_classÚT_JSON_DICT)Údom)Úpagec                   @  sX   e Zd ZU ded< ded< ded< ded< ded< ddœd	d
„Zedd dœdd„ƒZdS )Ú
CreditCardÚstrÚnumberÚnameÚexpiry_monthÚexpiry_yearÚcvcr   ©Úreturnc                 C  s<   t ƒ }| j|d< | j|d< | j|d< | j|d< | j|d< |S )Nr   r   ÚexpiryMonthÚ
expiryYearr   )Údictr   r   r   r   r   ©ÚselfÚjson© r   ú4E:\soccer\ml_env\Lib\site-packages\mycdp/autofill.pyÚto_json   s    




zCreditCard.to_json©r   r   c                 C  s:   | t |d ƒt |d ƒt |d ƒt |d ƒt |d ƒd�S )Nr   r   r   r   r   )r   r   r   r   r   ©r
   ©Úclsr   r   r   r   Ú	from_json'   s    




ûzCreditCard.from_jsonN©Ú__name__Ú
__module__Ú__qualname__Ú__annotations__r   Úclassmethodr   r   r   r   r   r	      s   
	r	   c                   @  s@   e Zd ZU ded< ded< ddœdd„Zedd dœd	d
„ƒZdS )ÚAddressFieldr
   r   Úvaluer   r   c                 C  s   t ƒ }| j|d< | j|d< |S )Nr   r'   )r   r   r'   r   r   r   r   r   9   s    

zAddressField.to_jsonr   c                 C  s   | t |d ƒt |d ƒd�S )Nr   r'   )r   r'   r   r   r   r   r   r   ?   s    

þzAddressField.from_jsonNr    r   r   r   r   r&   2   s
   
r&   c                   @  s<   e Zd ZU dZded< ddœdd„Zedd dœd	d
„ƒZdS )ÚAddressFieldszA list of address fields.útyping.List[AddressField]Úfieldsr   r   c                 C  s   t ƒ }dd„ | jD ƒ|d< |S )Nc                 S  s   g | ]}|  ¡ ‘qS r   ©r   ©Ú.0Úir   r   r   Ú
<listcomp>N   ó    z)AddressFields.to_json.<locals>.<listcomp>r*   ©r   r*   r   r   r   r   r   L   s    zAddressFields.to_jsonr   c                 C  s   | dd„ |d D ƒd�S )Nc                 S  s   g | ]}t  |¡‘qS r   ©r&   r   r,   r   r   r   r/   T   r0   z+AddressFields.from_json.<locals>.<listcomp>r*   ©r*   r   r   r   r   r   r   Q   s    ÿzAddressFields.from_jsonN©r!   r"   r#   Ú__doc__r$   r   r%   r   r   r   r   r   r(   G   s
   
r(   c                   @  s8   e Zd ZU ded< ddœdd„Zedd dœdd	„ƒZd
S )ÚAddressr)   r*   r   r   c                 C  s   t ƒ }dd„ | jD ƒ|d< |S )Nc                 S  s   g | ]}|  ¡ ‘qS r   r+   r,   r   r   r   r/   _   r0   z#Address.to_json.<locals>.<listcomp>r*   r1   r   r   r   r   r   ]   s    zAddress.to_jsonr   c                 C  s   | dd„ |d D ƒd�S )Nc                 S  s   g | ]}t  |¡‘qS r   r2   r,   r   r   r   r/   e   r0   z%Address.from_json.<locals>.<listcomp>r*   r3   r   r   r   r   r   r   b   s    ÿzAddress.from_jsonNr    r   r   r   r   r6   X   s   
r6   c                   @  s<   e Zd ZU dZded< ddœdd„Zedd dœd	d
„ƒZdS )Ú	AddressUIa   
    Defines how addresses can be displayed like in chrome://settings/addresses.
    Address UI is a two dimensional array, each inner array is an
    "address information line", and when rendered in a UI surface
    should be displayed as such.
    The following address UI for instance:
    [[{name: "GIVE_NAME", value: "Jon"}, {name: "FAMILY_NAME", value: "Doe"}],
    [{name: "CITY", value: "Munich"}, {name: "ZIP", value: "81456"}]]
    should allow the receiver to render:
    Jon Doe
    Munich 81456
    ztyping.List[AddressFields]Úaddress_fieldsr   r   c                 C  s   t ƒ }dd„ | jD ƒ|d< |S )Nc                 S  s   g | ]}|  ¡ ‘qS r   r+   r,   r   r   r   r/   }   r0   z%AddressUI.to_json.<locals>.<listcomp>ÚaddressFields)r   r8   r   r   r   r   r   {   s    zAddressUI.to_jsonr   c                 C  s   | dd„ |d D ƒd�S )Nc                 S  s   g | ]}t  |¡‘qS r   )r(   r   r,   r   r   r   r/   ƒ   s   z'AddressUI.from_json.<locals>.<listcomp>r9   )r8   r   r   r   r   r   r   €   s
    ÿÿzAddressUI.from_jsonNr4   r   r   r   r   r7   i   s
   
r7   c                   @  s:   e Zd ZdZdZdZddœdd„Zedd dœd	d
„ƒZdS )ÚFillingStrategyz{
    Specified whether a filled field was done so by using
    the html autocomplete attribute or autofill heuristics.
    ZautocompleteAttributeZautofillInferredr
   r   c                 C  s   | j S ©N)r'   )r   r   r   r   r   ‘   s    zFillingStrategy.to_jsonr   c                 C  s   | |ƒS r;   r   r   r   r   r   r   ”   s    zFillingStrategy.from_jsonN)	r!   r"   r#   r5   ZAUTOCOMPLETE_ATTRIBUTEZAUTOFILL_INFERREDr   r%   r   r   r   r   r   r:   ‰   s   r:   c                   @  sp   e Zd ZU ded< ded< ded< ded< ded< ded< d	ed
< ded< ddœdd„Zedd dœdd„ƒZdS )ÚFilledFieldr
   Ú	html_typeÚid_r   r'   Úautofill_typer:   Úfilling_strategyzpage.FrameIdÚframe_idúdom.BackendNodeIdÚfield_idr   r   c                 C  sf   t ƒ }| j|d< | j|d< | j|d< | j|d< | j|d< | j ¡ |d< | j ¡ |d< | j	 ¡ |d< |S )	NÚhtmlTypeÚidr   r'   ÚautofillTypeÚfillingStrategyÚframeIdÚfieldId)
r   r=   r>   r   r'   r?   r@   r   rA   rC   r   r   r   r   r   ¬   s    




zFilledField.to_jsonr   c                 C  sb   | t |d ƒt |d ƒt |d ƒt |d ƒt |d ƒt |d ¡tj |d ¡tj |d ¡d	�S )
NrD   rE   r   r'   rF   rG   rH   rI   )r=   r>   r   r'   r?   r@   rA   rC   )r
   r:   r   r   ZFrameIdr   ZBackendNodeIdr   r   r   r   r   ¸   s    




ÿözFilledField.from_jsonNr    r   r   r   r   r<   ™   s   
r<   rB   ztyping.Optional[page.FrameId]ztyping.Optional[CreditCard]ztyping.Optional[Address]z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])rC   rA   ÚcardÚaddressr   c                 c  sb   t ƒ }|  ¡ |d< |dur&| ¡ |d< |dur:| ¡ |d< |durN| ¡ |d< d|dœ}|V }dS )aæ  
    Trigger autofill on a form identified by the fieldId.
    If the field and related form cannot be autofilled, returns an error.
    :param field_id: Identifies a field that serves as an anchor for autofill.
    :param frame_id: *(Optional)* Identifies the frame that field belongs to.
    :param card: Credit card information to fill out the form.
    Credit card data is not saved.
    :param address: *(Optional)* Address to fill out the form.
    Address data is not saved.
    rI   NrH   rJ   rK   zAutofill.trigger©ÚmethodÚparams)r   r   )rC   rA   rJ   rK   rN   Úcmd_dictr   r   r   r   ÚtriggerÈ   s    þrP   ztyping.List[Address])Ú	addressesr   c                 c  s,   t ƒ }dd„ | D ƒ|d< d|dœ}|V }dS )zg
    Set addresses so that developers can verify their forms implementation.
    :param addresses:
    c                 S  s   g | ]}|  ¡ ‘qS r   r+   r,   r   r   r   r/   ï   r0   z!set_addresses.<locals>.<listcomp>rQ   zAutofill.setAddressesrL   N)r   )rQ   rN   rO   r   r   r   r   Úset_addressesç   s    þrR   r   c                  c  s   ddi} | V }dS )z'Disables autofill domain notifications.rM   zAutofill.disableNr   ©rO   r   r   r   r   Údisable÷   s    ÿrT   c                  c  s   ddi} | V }dS )z&Enables autofill domain notifications.rM   zAutofill.enableNr   rS   r   r   r   Úenableÿ   s    ÿrU   zAutofill.addressFormFilledc                   @  s6   e Zd ZU dZded< ded< edd dœdd	„ƒZd
S )ÚAddressFormFilledz'Emitted when an address form is filled.ztyping.List[FilledField]Úfilled_fieldsr7   Ú
address_uir   r   c                 C  s$   | dd„ |d D ƒt  |d ¡d�S )Nc                 S  s   g | ]}t  |¡‘qS r   )r<   r   r,   r   r   r   r/     s   z/AddressFormFilled.from_json.<locals>.<listcomp>ZfilledFieldsZ	addressUi)rW   rX   )r7   r   r   r   r   r   r     s    ÿüzAddressFormFilled.from_jsonN)r!   r"   r#   r5   r$   r%   r   r   r   r   r   rV     s
   
rV   )NNN)Ú
__future__r   ÚenumÚtypingÚdataclassesr   Úutilr   r   Ú r   r   r	   r&   r(   r6   r7   ÚEnumr:   r<   rP   rR   rT   rU   rV   r   r   r   r   Ú<module>   s:    0   ü