
    ,i3                        d dl mZmZmZ d dlmZ  G d d      Z G d d      Z G d d      Z G d	 d
      Z	 G d d      Z
 G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Zy)    )AnyOptionalUnion)command_builderc                        e Zd ZdZdZdZdZdZy)SameSitez5Represents the possible same site values for cookies.strictlaxnonedefaultN)__name__
__module____qualname____doc__STRICTLAXNONEDEFAULT     u/var/www/system.tvplus.app.br/jogos/scrap/venv/lib/python3.12/site-packages/selenium/webdriver/common/bidi/storage.pyr   r      s    ?F
CDGr   r   c                   4    e Zd ZdZdZdZdedefdZdefdZ	y	)

BytesValuezRepresents a bytes value.base64stringtypevaluec                      || _         || _        y Nr   r   )selfr   r   s      r   __init__zBytesValue.__init__&   s    	
r   returnc                 4    | j                   | j                  dS )zConverts the BytesValue to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the BytesValue.
        r    r    r!   s    r   to_dictzBytesValue.to_dict*   s     		DJJ77r   N)
r   r   r   r   TYPE_BASE64TYPE_STRINGstrr"   dictr&   r   r   r   r   r       s.    #KKS  8 8r   r   c                       e Zd ZdZ	 	 	 	 	 	 ddedededee   dee   dee   d	ee   d
ee   dee   fdZ	e
dedd fd       Zy)CookiezRepresents a cookie.Nnamer   domainpathsize	http_onlysecure	same_siteexpiryc
                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        y r   	r-   r   r.   r/   r0   r1   r2   r3   r4   
r!   r-   r   r.   r/   r0   r1   r2   r3   r4   s
             r   r"   zCookie.__init__7   C     	
		""r   datar#   c                    |j                  d      }|st        d      |j                  d      }|st        d      t        |j                  di       j                  d      |j                  di       j                  d            } | t        |      |t        |      |j                  d      |j                  d      |j                  d	      |j                  d
      |j                  d      |j                  d      	      S )zCreates a Cookie instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the cookie information.

        Returns:
        -------
            Cookie: 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   httpOnlyr2   sameSiter4   r6   )get
ValueErrorr   r)   )clsr9   r-   r.   r   s        r   	from_dictzCookie.from_dictM   s     xxCDD(#EFF488GR044V<dhhwPR>S>W>WX_>`aTv;&!&!hhz*88H%hhz*88H%

 
	
r   )NNNNNN)r   r   r   r   r)   r   r   intboolr"   classmethodr*   r@   r   r   r   r,   r,   4   s     #"$(!%#' $  	
 sm sm D>  C= , 
T 
h 
 
r   r,   c                       e Zd ZdZ	 	 	 	 	 	 	 	 	 ddee   dee   dee   dee   dee   dee   d	ee   d
ee   dee   fdZ	de
eef   fdZy)CookieFilterz Represents a filter for cookies.Nr-   r   r.   r/   r0   r1   r2   r3   r4   c
                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        y r   r6   r7   s
             r   r"   zCookieFilter.__init__r   r8   r   r#   c                    i }| j                   | j                   |d<   | j                  | j                  j                         |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j
                  | j
                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d	<   |S )
zConverts the CookieFilter to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the CookieFilter.
        r-   r   r.   r/   r0   r;   r2   r<   r4   )
r-   r   r&   r.   r/   r0   r1   r2   r3   r4   r!   results     r   r&   zCookieFilter.to_dict   s     "$99 !YYF6N::!"jj002F7O;;"#{{F899 !YYF6N99 !YYF6N>>%!%F:;;"#{{F8>>%!%F:;;"#{{F8r   )	NNNNNNNNN)r   r   r   r   r   r)   r   rA   rB   r"   r*   r   r&   r   r   r   rE   rE   o   s    * #&* $""$(!%#' $sm 
# 	
 sm sm D>  C= ,c3h r   rE   c                   H    e Zd ZdZd	dee   dee   fdZededd fd       Z	y)
PartitionKeyz#Represents a storage partition key.Nuser_contextsource_originc                      || _         || _        y r   rL   rM   r!   rL   rM   s      r   r"   zPartitionKey.__init__   s    (*r   r9   r#   c                 R     | |j                  d      |j                  d            S )a	  Creates a PartitionKey instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the partition key information.

        Returns:
        -------
            PartitionKey: A new instance of PartitionKey.
        userContextsourceOriginrO   )r=   )r?   r9   s     r   r@   zPartitionKey.from_dict   s)     -0((>2
 	
r   NN)
r   r   r   r   r   r)   r"   rC   r*   r@   r   r   r   rK   rK      sC    -+Xc] +(SV- + 
T 
n 
 
r   rK   c                   (    e Zd ZdZdefdZdefdZy)"BrowsingContextPartitionDescriptorz3Represents a browsing context partition descriptor.contextc                      d| _         || _        y )NrW   r   rW   )r!   rW   s     r   r"   z+BrowsingContextPartitionDescriptor.__init__   s    	r   r#   c                 4    | j                   | j                  dS )zConverts the BrowsingContextPartitionDescriptor to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the BrowsingContextPartitionDescriptor.
        rY   rY   r%   s    r   r&   z*BrowsingContextPartitionDescriptor.to_dict   s     		dll;;r   N)r   r   r   r   r)   r"   r*   r&   r   r   r   rV   rV      s    = < <r   rV   c                   :    e Zd ZdZddee   dee   fdZdefdZy)	StorageKeyPartitionDescriptorz.Represents a storage key partition descriptor.NrL   rM   c                 .    d| _         || _        || _        y )N
storageKeyr   rL   rM   rP   s      r   r"   z&StorageKeyPartitionDescriptor.__init__   s     	(*r   r#   c                     d| j                   i}| j                  | j                  |d<   | j                  | j                  |d<   |S )zConverts the StorageKeyPartitionDescriptor to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the StorageKeyPartitionDescriptor.
        r   rR   rS   r_   rH   s     r   r&   z%StorageKeyPartitionDescriptor.to_dict   sO     $))$($($5$5F=!)%)%7%7F>"r   rT   )	r   r   r   r   r   r)   r"   r*   r&   r   r   r   r\   r\      s-    8+Xc] +(SV- +
 r   r\   c                   x    e Zd ZdZ	 	 	 	 	 ddedededee   dee   dee   d	ee   d
ee   fdZ	de
eef   fdZy)PartialCookiez(Represents a partial cookie for setting.Nr-   r   r.   r/   r1   r2   r3   r4   c	                 t    || _         || _        || _        || _        || _        || _        || _        || _        y r   )r-   r   r.   r/   r1   r2   r3   r4   )	r!   r-   r   r.   r/   r1   r2   r3   r4   s	            r   r"   zPartialCookie.__init__   s<     	
	""r   r#   c                 x   | j                   | j                  j                         | j                  d}| j                  | j                  |d<   | j
                  | j
                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   |S )zConverts the PartialCookie to a dictionary.

        Returns:
        -------
            Dict: A dictionary representation of the PartialCookie.
        )r-   r   r.   r/   r;   r2   r<   r4   )	r-   r   r&   r.   r/   r1   r2   r3   r4   rH   s     r   r&   zPartialCookie.to_dict   s     IIZZ'')kk"

 99 !YYF6N>>%!%F:;;"#{{F8>>%!%F:;;"#{{F8r   )NNNNN)r   r   r   r   r)   r   r   rB   rA   r"   r*   r   r&   r   r   r   rb   rb      s    2 #$(!%#' $  	
 sm D>  C= (c3h r   rb   c                   @    e Zd ZdZdee   defdZede	dd fd       Z
y)	GetCookiesResultz.Represents the result of a getCookies command.cookiespartition_keyc                      || _         || _        y r   rg   rh   )r!   rg   rh   s      r   r"   zGetCookiesResult.__init__  s    *r   r9   r#   c                     |j                  dg       D cg c]  }t        j                  |       }}t        j                  |j                  di             } | ||      S c c}w )a  Creates a GetCookiesResult instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the get cookies result information.

        Returns:
        -------
            GetCookiesResult: A new instance of GetCookiesResult.
        rg   partitionKeyrj   )r=   r,   r@   rK   )r?   r9   cookierg   rh   s        r   r@   zGetCookiesResult.from_dict  s[     ;?((9b:QR6##F+RR$..txx/KL7-@@ Ss   A"N)r   r   r   r   listr,   rK   r"   rC   r*   r@   r   r   r   rf   rf     sC    8+V +\ + AT A&8 A Ar   rf   c                   6    e Zd ZdZdefdZededd fd       Zy)SetCookieResultz-Represents the result of a setCookie command.rh   c                     || _         y r   rh   r!   rh   s     r   r"   zSetCookieResult.__init__1  
    *r   r9   r#   c                 ^    t         j                  |j                  di             } | |      S )a  Creates a SetCookieResult instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the set cookie result information.

        Returns:
        -------
            SetCookieResult: A new instance of SetCookieResult.
        rl   rr   rK   r@   r=   r?   r9   rh   s      r   r@   zSetCookieResult.from_dict4  *     %..txx/KL//r   N	r   r   r   r   rK   r"   rC   r*   r@   r   r   r   rp   rp   .  s4    7+l + 0T 0&7 0 0r   rp   c                   6    e Zd ZdZdefdZededd fd       Zy)DeleteCookiesResultz1Represents the result of a deleteCookies command.rh   c                     || _         y r   rr   rs   s     r   r"   zDeleteCookiesResult.__init__G  rt   r   r9   r#   c                 ^    t         j                  |j                  di             } | |      S )a&  Creates a DeleteCookiesResult instance from a dictionary.

        Parameters:
        -----------
            data: A dictionary containing the delete cookies result information.

        Returns:
        -------
            DeleteCookiesResult: A new instance of DeleteCookiesResult.
        rl   rr   rv   rw   s      r   r@   zDeleteCookiesResult.from_dictJ  rx   r   Nry   r   r   r   r{   r{   D  s4    ;+l + 0T 0&; 0 0r   r{   c                       e Zd ZdZd Z	 	 ddee   deeee	f      de
fdZ	 ddedeeee	f      defd	Z	 	 ddee   deeee	f      defd
Zy)Storagez*BiDi implementation of the storage module.c                     || _         y r   )conn)r!   r   s     r   r"   zStorage.__init__]  s	    	r   Nfilter	partitionr#   c                     i }||j                         |d<   ||j                         |d<   | j                  j                  t        d|            }t        j                  |      S )a7  Retrieves cookies that match the given parameters.

        Parameters:
        -----------
            filter: Optional filter to match cookies.
            partition: Optional partition descriptor.

        Returns:
        -------
            GetCookiesResult: The result of the get cookies command.
        r   r   zstorage.getCookies)r&   r   executer   rf   r@   r!   r   r   paramsrI   s        r   get_cookieszStorage.get_cookies`  sf      %~~/F8 "+"3"3"5F;""?3G#PQ))&11r   rm   c                     d|j                         i}||j                         |d<   | j                  j                  t        d|            }t        j                  |      S )a  Sets a cookie in the browser.

        Parameters:
        -----------
            cookie: The cookie to set.
            partition: Optional partition descriptor.

        Returns:
        -------
            SetCookieResult: The result of the set cookie command.
        rm   r   zstorage.setCookie)r&   r   r   r   rp   r@   )r!   rm   r   r   rI   s        r   
set_cookiezStorage.set_cookiey  s[      FNN,- "+"3"3"5F;""?3F#OP((00r   c                     i }||j                         |d<   ||j                         |d<   | j                  j                  t        d|            }t        j                  |      S )aE  Deletes cookies that match the given parameters.

        Parameters:
        -----------
            filter: Optional filter to match cookies to delete.
            partition: Optional partition descriptor.

        Returns:
        -------
            DeleteCookiesResult: The result of the delete cookies command.
        r   r   zstorage.deleteCookies)r&   r   r   r   r{   r@   r   s        r   delete_cookieszStorage.delete_cookies  sf      %~~/F8 "+"3"3"5F;""?3JF#ST",,V44r   rT   r   )r   r   r   r   r"   r   rE   r   rV   r\   rf   r   rb   rp   r   r{   r   r   r   r   r   r   Z  s    4
 *.hl2&2 E"DFc"cde2 
	28 im11 E"DFc"cde1 
	12 *.hl5&5 E"DFc"cde5 
	5r   r   N)typingr   r   r   %selenium.webdriver.common.bidi.commonr   r   r   r,   rE   rK   rV   r\   rb   rf   rp   r{   r   r   r   r   <module>r      s   $ ( ' A 8 8(8
 8
v3 3l
 
2< <" .- -`A A00 0,0 0,M5 M5r   