o
    衡i2                     @  s   d dl mZ d dlmZmZ d dlmZ erd dlmZ G dd dZ	G dd dZ
G d	d
 d
ZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZG dd dZdS )    )annotations)TYPE_CHECKINGAny)command_builder)WebSocketConnectionc                   @  s    e Zd ZdZdZdZdZdZdS )SameSitez5Represents the possible same site values for cookies.strictlaxnonedefaultN)__name__
__module____qualname____doc__STRICTLAXNONEDEFAULT r   r   w/var/www/html/asbeauty/laura_geller_scraping/env/lib/python3.10/site-packages/selenium/webdriver/common/bidi/storage.pyr      s    r   c                   @  s,   e Zd ZdZdZdZdddZdddZdS )
BytesValuezRepresents a bytes value.base64stringtypestrvaluec                 C     || _ || _d S Nr   r   )selfr   r   r   r   r   __init__*      
zBytesValue.__init__returndict[str, str]c                 C     | j | jdS )z~Converts the BytesValue to a dictionary.

        Returns:
            A dictionary representation of the BytesValue.
        r   r   r   r   r   r   to_dict.      zBytesValue.to_dictN)r   r   r   r   r"   r#   )r   r   r   r   TYPE_BASE64TYPE_STRINGr    r&   r   r   r   r   r   $   s    
r   c                   @  s6   e Zd ZdZ						ddddZedddZdS )CookiezRepresents a cookie.Nnamer   r   r   domainpath
str | Nonesize
int | None	http_onlybool | Nonesecure	same_siteexpiryc
           
      C  :   || _ || _|| _|| _|| _|| _|| _|| _|	| _d S r   	r,   r   r-   r.   r0   r2   r4   r5   r6   
r   r,   r   r-   r.   r0   r2   r4   r5   r6   r   r   r   r    :      
zCookie.__init__datadict[str, Any]r"   c                 C  s   | d}|std| d}|stdt| di  d| di  d}| t||t|| d| d| d	| d
| d| dd	S )zCreates a Cookie instance from a dictionary.

        Args:
            data: A dictionary containing the cookie information.

        Returns:
            A new instance of Cookie.
        r,   z$name is required and cannot be emptyr-   z&domain is required and cannot be emptyr   r   r.   r0   httpOnlyr4   sameSiter6   r8   )get
ValueErrorr   r   )clsr;   r,   r-   r   r   r   r   	from_dictP   s$   

&zCookie.from_dict)NNNNNN)r,   r   r   r   r-   r   r.   r/   r0   r1   r2   r3   r4   r3   r5   r/   r6   r1   )r;   r<   r"   r+   r   r   r   r   r    classmethodrB   r   r   r   r   r+   7   s    r+   c                   @  s8   e Zd ZdZ									ddddZdddZdS )CookieFilterz Represents a filter for cookies.Nr,   r/   r   BytesValue | Noner-   r.   r0   r1   r2   r3   r4   r5   r6   c
           
      C  r7   r   r8   r9   r   r   r   r    s   r:   zCookieFilter.__init__r"   r<   c                 C  s   i }| j dur| j |d< | jdur| j |d< | jdur"| j|d< | jdur,| j|d< | jdur6| j|d< | jdur@| j|d< | jdurJ| j|d< | jdurT| j|d	< | j	dur^| j	|d
< |S )zConverts the CookieFilter to a dictionary.

        Returns:
            A dictionary representation of the CookieFilter.
        Nr,   r   r-   r.   r0   r=   r4   r>   r6   )
r,   r   r&   r-   r.   r0   r2   r4   r5   r6   r   resultr   r   r   r&      s(   
















zCookieFilter.to_dict)	NNNNNNNNN)r,   r/   r   rF   r-   r/   r.   r/   r0   r1   r2   r3   r4   r3   r5   r/   r6   r1   r"   r<   r   r   r   r   r    r&   r   r   r   r   rE   p   s    rE   c                   @  s*   e Zd ZdZddddZedddZdS )PartitionKeyz#Represents a storage partition key.Nuser_contextr/   source_originc                 C  r   r   rL   rM   r   rL   rM   r   r   r   r       r!   zPartitionKey.__init__r;   r<   r"   c                 C  s   | | d| ddS )zCreates a PartitionKey instance from a dictionary.

        Args:
            data: A dictionary containing the partition key information.

        Returns:
            A new instance of PartitionKey.
        userContextsourceOriginrN   )r?   )rA   r;   r   r   r   rB      s   
zPartitionKey.from_dictNNrL   r/   rM   r/   )r;   r<   r"   rK   rC   r   r   r   r   rK      s
    rK   c                   @  s$   e Zd ZdZdddZddd	Zd
S )"BrowsingContextPartitionDescriptorz3Represents a browsing context partition descriptor.contextr   c                 C  s   d| _ || _d S )NrU   r   rU   )r   rU   r   r   r   r       r!   z+BrowsingContextPartitionDescriptor.__init__r"   r#   c                 C  r$   )zConverts the BrowsingContextPartitionDescriptor to a dictionary.

        Returns:
            Dict: A dictionary representation of the BrowsingContextPartitionDescriptor.
        rV   rV   r%   r   r   r   r&      r'   z*BrowsingContextPartitionDescriptor.to_dictN)rU   r   r(   rJ   r   r   r   r   rT      s    
rT   c                   @  s&   e Zd ZdZddddZdd
dZdS )StorageKeyPartitionDescriptorz.Represents a storage key partition descriptor.NrL   r/   rM   c                 C  s   d| _ || _|| _d S )N
storageKeyr   rL   rM   rO   r   r   r   r       s   
z&StorageKeyPartitionDescriptor.__init__r"   r#   c                 C  s6   d| j i}| jdur| j|d< | jdur| j|d< |S )zConverts the StorageKeyPartitionDescriptor to a dictionary.

        Returns:
            Dict: A dictionary representation of the StorageKeyPartitionDescriptor.
        r   NrP   rQ   rY   rG   r   r   r   r&      s   




z%StorageKeyPartitionDescriptor.to_dictrR   rS   r(   rJ   r   r   r   r   rW      s    rW   c                   @  s0   e Zd ZdZ					ddddZdddZdS )PartialCookiez(Represents a partial cookie for setting.Nr,   r   r   r   r-   r.   r/   r2   r3   r4   r5   r6   r1   c	           	      C  s4   || _ || _|| _|| _|| _|| _|| _|| _d S r   )r,   r   r-   r.   r2   r4   r5   r6   )	r   r,   r   r-   r.   r2   r4   r5   r6   r   r   r   r       s   
zPartialCookie.__init__r"   r<   c                 C  s~   | j | j | jd}| jdur| j|d< | jdur| j|d< | jdur)| j|d< | jdur3| j|d< | jdur=| j|d< |S )zConverts the PartialCookie to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the PartialCookie.
        )r,   r   r-   Nr.   r=   r4   r>   r6   )	r,   r   r&   r-   r.   r2   r4   r5   r6   rG   r   r   r   r&      s   









zPartialCookie.to_dict)NNNNN)r,   r   r   r   r-   r   r.   r/   r2   r3   r4   r3   r5   r/   r6   r1   rI   rJ   r   r   r   r   rZ      s    rZ   c                   @  s(   e Zd ZdZdddZedddZdS )GetCookiesResultz.Represents the result of a getCookies command.cookieslist[Cookie]partition_keyrK   c                 C  r   r   r\   r^   )r   r\   r^   r   r   r   r      r!   zGetCookiesResult.__init__r;   r<   r"   c                 C  s4   dd | dg D }t| di }| ||dS )zCreates a GetCookiesResult instance from a dictionary.

        Args:
            data: A dictionary containing the get cookies result information.

        Returns:
            A new instance of GetCookiesResult.
        c                 S  s   g | ]}t |qS r   )r+   rB   ).0cookier   r   r   
<listcomp>#  s    z.GetCookiesResult.from_dict.<locals>.<listcomp>r\   partitionKeyr_   )r?   rK   rB   )rA   r;   r\   r^   r   r   r   rB     s   
zGetCookiesResult.from_dictN)r\   r]   r^   rK   )r;   r<   r"   r[   rC   r   r   r   r   r[     s
    
r[   c                   @  (   e Zd ZdZdddZedd	d
ZdS )SetCookieResultz-Represents the result of a setCookie command.r^   rK   c                 C  
   || _ d S r   r^   r   r^   r   r   r   r    +     
zSetCookieResult.__init__r;   r<   r"   c                 C     t |di }| |dS )zCreates a SetCookieResult instance from a dictionary.

        Args:
            data: A dictionary containing the set cookie result information.

        Returns:
            A new instance of SetCookieResult.
        rc   rg   rK   rB   r?   rA   r;   r^   r   r   r   rB   .     

zSetCookieResult.from_dictNr^   rK   )r;   r<   r"   re   rC   r   r   r   r   re   (  
    
re   c                   @  rd   )DeleteCookiesResultz1Represents the result of a deleteCookies command.r^   rK   c                 C  rf   r   rg   rh   r   r   r   r    ?  ri   zDeleteCookiesResult.__init__r;   r<   r"   c                 C  rj   )zCreates a DeleteCookiesResult instance from a dictionary.

        Args:
            data: A dictionary containing the delete cookies result information.

        Returns:
            A new instance of DeleteCookiesResult.
        rc   rg   rk   rl   r   r   r   rB   B  rm   zDeleteCookiesResult.from_dictNrn   )r;   r<   r"   rp   rC   r   r   r   r   rp   <  ro   rp   c                   @  sH   e Zd ZdZdddZ		ddddZ	ddddZ		ddddZdS )Storagez*BiDi implementation of the storage module.connr   r"   Nonec                 C  rf   r   )rr   )r   rr   r   r   r   r    S  ri   zStorage.__init__NfilterCookieFilter | None	partitionIBrowsingContextPartitionDescriptor | StorageKeyPartitionDescriptor | Noner[   c                 C  H   i }|dur|  |d< |dur|  |d< | jtd|}t|S )a  Gets cookies matching the specified filter.

        Args:
            filter: Optional filter to specify which cookies to retrieve.
            partition: Optional partition key to limit the scope of the operation.

        Returns:
            A GetCookiesResult containing the cookies and partition key.

        Example:
            result = await storage.get_cookies(
                filter=CookieFilter(name="sessionId"),
                partition=PartitionKey(...)
            )
        Nrt   rv   zstorage.getCookies)r&   rr   executer   r[   rB   r   rt   rv   paramsrH   r   r   r   get_cookiesV  s   
zStorage.get_cookiesra   rZ   re   c                 C  s<   d|  i}|dur|  |d< | jtd|}t|S )zSets a cookie in the browser.

        Args:
            cookie: The cookie to set.
            partition: Optional partition descriptor.

        Returns:
            The result of the set cookie command.
        ra   Nrv   zstorage.setCookie)r&   rr   ry   r   re   rB   )r   ra   rv   r{   rH   r   r   r   
set_cookies  s
   
zStorage.set_cookierp   c                 C  rx   )a  Deletes cookies that match the given parameters.

        Args:
            filter: Optional filter to match cookies to delete.
            partition: Optional partition descriptor.

        Returns:
            The result of the delete cookies command.
        Nrt   rv   zstorage.deleteCookies)r&   rr   ry   r   rp   rB   rz   r   r   r   delete_cookies  s   
zStorage.delete_cookies)rr   r   r"   rs   rR   )rt   ru   rv   rw   r"   r[   r   )ra   rZ   rv   rw   r"   re   )rt   ru   rv   rw   r"   rp   )r   r   r   r   r    r|   r}   r~   r   r   r   r   rq   P  s    
 rq   N)
__future__r   typingr   r   %selenium.webdriver.common.bidi.commonr   .selenium.webdriver.remote.websocket_connectionr   r   r   r+   rE   rK   rT   rW   rZ   r[   re   rp   rq   r   r   r   r   <module>   s"   	950