
    i2                    ,   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      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)    )annotations)TYPE_CHECKINGAny)command_builder)WebSocketConnectionc                       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     b/var/www/html/BatchJob/venv/lib/python3.12/site-packages/selenium/webdriver/common/bidi/storage.pyr	   r	      s    ?F
CDGr   r	   c                  (    e Zd ZdZdZdZddZddZy)	
BytesValuezRepresents a bytes value.base64stringc                     || _         || _        y Ntypevalue)selfr    r!   s      r   __init__zBytesValue.__init__*   s    	
r   c                4    | j                   | j                  dS )z~Converts the BytesValue to a dictionary.

        Returns:
            A dictionary representation of the BytesValue.
        r   r   r"   s    r   to_dictzBytesValue.to_dict.   s     		DJJ77r   N)r    strr!   r'   returnzdict[str, str])r   r   r   r   TYPE_BASE64TYPE_STRINGr#   r&   r   r   r   r   r   $   s    #KK8r   r   c                  Z    e Zd ZdZ	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd       Zy)CookiezRepresents a cookie.Nc
                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        y r   	namer!   domainpathsize	http_onlysecure	same_siteexpiry
r"   r0   r!   r1   r2   r3   r4   r5   r6   r7   s
             r   r#   zCookie.__init__:   C     	
		""r   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.

        Args:
            data: A dictionary containing the cookie information.

        Returns:
            A new instance of Cookie.
        r0   z$name is required and cannot be emptyr1   z&domain is required and cannot be emptyr!   r    r2   r3   httpOnlyr5   sameSiter7   r/   )get
ValueErrorr   r'   )clsdatar0   r1   r!   s        r   	from_dictzCookie.from_dictP   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)r0   r'   r!   r   r1   r'   r2   
str | Noner3   
int | Noner4   bool | Noner5   rD   r6   rB   r7   rC   )r@   dict[str, Any]r)   r-   r   r   r   r   r#   classmethodrA   r   r   r   r-   r-   7   s      !%" $!  	
      , 
 
r   r-   c                  V    e Zd ZdZ	 	 	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZy)CookieFilterz Represents a filter for cookies.Nc
                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        y r   r/   r8   s
             r   r#   zCookieFilter.__init__s   r9   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:
            A dictionary representation of the CookieFilter.
        r0   r!   r1   r2   r3   r;   r5   r<   r7   )
r0   r!   r&   r1   r2   r3   r4   r5   r6   r7   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)r0   rB   r!   zBytesValue | Noner1   rB   r2   rB   r3   rC   r4   rD   r5   rD   r6   rB   r7   rC   r)   rE   r   r   r   r   r#   r&   r   r   r   rI   rI   p   s    *  #'!!%" $! ! 	
      ,r   rI   c                  ,    e Zd ZdZdddZedd       Zy)PartitionKeyz#Represents a storage partition key.Nc                     || _         || _        y r   user_contextsource_originr"   rT   rU   s      r   r#   zPartitionKey.__init__   s    (*r   c                R     | |j                  d      |j                  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sourceOriginrS   )r=   )r?   r@   s     r   rA   zPartitionKey.from_dict   s)     -0((>2
 	
r   NNrT   rB   rU   rB   )r@   rE   r)   rQ   rF   r   r   r   rQ   rQ      s    -+ 
 
r   rQ   c                       e Zd ZdZddZddZy)"BrowsingContextPartitionDescriptorz3Represents a browsing context partition descriptor.c                     d| _         || _        y )Ncontextr    r_   )r"   r_   s     r   r#   z+BrowsingContextPartitionDescriptor.__init__   s    	r   c                4    | j                   | j                  dS )zConverts the BrowsingContextPartitionDescriptor to a dictionary.

        Returns:
            Dict: A dictionary representation of the BrowsingContextPartitionDescriptor.
        r`   r`   r%   s    r   r&   z*BrowsingContextPartitionDescriptor.to_dict   s     		dll;;r   N)r_   r'   r(   rO   r   r   r   r]   r]      s    =<r   r]   c                  "    e Zd ZdZdddZddZy)StorageKeyPartitionDescriptorz.Represents a storage key partition descriptor.Nc                .    d| _         || _        || _        y )N
storageKeyr    rT   rU   rV   s      r   r#   z&StorageKeyPartitionDescriptor.__init__   s     	(*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    rX   rY   rf   rL   s     r   r&   z%StorageKeyPartitionDescriptor.to_dict   sO     $))$($($5$5F=!)%)%7%7F>"r   rZ   r[   r(   rO   r   r   r   rc   rc      s    8+
r   rc   c                  J    e Zd ZdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZy)PartialCookiez(Represents a partial cookie for setting.Nc	                t    || _         || _        || _        || _        || _        || _        || _        || _        y r   )r0   r!   r1   r2   r4   r5   r6   r7   )	r"   r0   r!   r1   r2   r4   r5   r6   r7   s	            r   r#   zPartialCookie.__init__   s<     	
	""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.
        )r0   r!   r1   r2   r;   r5   r<   r7   )	r0   r!   r&   r1   r2   r4   r5   r6   r7   rL   s     r   r&   zPartialCookie.to_dict   s     IIZZ'')kk"

 99 !YYF6N>>%!%F:;;"#{{F8>>%!%F:;;"#{{F8r   )NNNNN)r0   r'   r!   r   r1   r'   r2   rB   r4   rD   r5   rD   r6   rB   r7   rC   rN   rO   r   r   r   ri   ri      sn    2  !%" $!  	
     (r   ri   c                  *    e Zd ZdZddZedd       Zy)GetCookiesResultz.Represents the result of a getCookies command.c                     || _         || _        y r   cookiespartition_key)r"   rp   rq   s      r   r#   zGetCookiesResult.__init__  s    *r   c                    |j                  dg       D cg c]  }t        j                  |       }}t        j                  |j                  di             } | ||      S c c}w )zCreates a GetCookiesResult instance from a dictionary.

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

        Returns:
            A new instance of GetCookiesResult.
        rp   partitionKeyro   )r=   r-   rA   rQ   )r?   r@   cookierp   rq   s        r   rA   zGetCookiesResult.from_dict  s[     ;?((9b:QR6##F+RR$..txx/KL7-@@ Ss   A"N)rp   zlist[Cookie]rq   rQ   )r@   rE   r)   rm   rF   r   r   r   rm   rm     s     8+ A Ar   rm   c                  *    e Zd ZdZddZedd       Zy)SetCookieResultz-Represents the result of a setCookie command.c                    || _         y r   rq   r"   rq   s     r   r#   zSetCookieResult.__init__+  
    *r   c                ^    t         j                  |j                  di             } | |      S )zCreates a SetCookieResult instance from a dictionary.

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

        Returns:
            A new instance of SetCookieResult.
        rs   rx   rQ   rA   r=   r?   r@   rq   s      r   rA   zSetCookieResult.from_dict.  *     %..txx/KL//r   Nrq   rQ   )r@   rE   r)   rv   rF   r   r   r   rv   rv   (  s    7+ 
0 
0r   rv   c                  *    e Zd ZdZddZedd       Zy)DeleteCookiesResultz1Represents the result of a deleteCookies command.c                    || _         y r   rx   ry   s     r   r#   zDeleteCookiesResult.__init__?  rz   r   c                ^    t         j                  |j                  di             } | |      S )zCreates a DeleteCookiesResult instance from a dictionary.

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

        Returns:
            A new instance of DeleteCookiesResult.
        rs   rx   r|   r}   s      r   rA   zDeleteCookiesResult.from_dictB  r~   r   Nr   )r@   rE   r)   r   rF   r   r   r   r   r   <  s    ;+ 
0 
0r   r   c                  ^    e Zd ZdZddZ	 	 d	 	 	 	 	 d	dZ	 d
	 	 	 	 	 ddZ	 	 d	 	 	 	 	 ddZy)Storagez*BiDi implementation of the storage module.c                    || _         y r   )conn)r"   r   s     r   r#   zStorage.__init__S  s	    	r   Nc                    i }||j                         |d<   ||j                         |d<   | j                  j                  t        d|            }t        j                  |      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(...)
            )
        filter	partitionzstorage.getCookies)r&   r   executer   rm   rA   r"   r   r   paramsrM   s        r   get_cookieszStorage.get_cookiesV  sf    ( %~~/F8 "+"3"3"5F;""?3G#PQ))&11r   c                    d|j                         i}||j                         |d<   | j                  j                  t        d|            }t        j                  |      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.
        rt   r   zstorage.setCookie)r&   r   r   r   rv   rA   )r"   rt   r   r   rM   s        r   
set_cookiezStorage.set_cookies  s[     FNN,- "+"3"3"5F;""?3F#OP((00r   c                    i }||j                         |d<   ||j                         |d<   | j                  j                  t        d|            }t        j                  |      S )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.
        r   r   zstorage.deleteCookies)r&   r   r   r   r   rA   r   s        r   delete_cookieszStorage.delete_cookies  sf     %~~/F8 "+"3"3"5F;""?3JF#ST",,V44r   )r   r   r)   NonerZ   )r   CookieFilter | Noner   IBrowsingContextPartitionDescriptor | StorageKeyPartitionDescriptor | Noner)   rm   r   )rt   ri   r   r   r)   rv   )r   r   r   r   r)   r   )r   r   r   r   r#   r   r   r   r   r   r   r   r   P  s    4
 '+_c2#2 ]2 
	2@ `d11 ]1 
	1. '+_c5#5 ]5 
	5r   r   N)
__future__r   typingr   r   %selenium.webdriver.common.bidi.commonr   .selenium.webdriver.remote.websocket_connectionr   r	   r   r-   rI   rQ   r]   rc   ri   rm   rv   r   r   r   r   r   <module>r      s   " # % AR 8 8&6
 6
r2 2j
 
.< <  ,- -`A A,0 0(0 0(M5 M5r   