
    X j$                     x    S SK r S SKJr  S SKJr  S SKJr  S SKJr   " S S5      r	 " S S	5      r
 " S
 S5      rg)    N)Any)command_builder)UserPromptHandler)Proxyc                   4    \ rS rSrSrSrSrSrSr\\\\1r	Sr
g)	ClientWindowState   zRepresents a window state.
fullscreen	maximized	minimizednormal N)__name__
__module____qualname____firstlineno____doc__
FULLSCREEN	MAXIMIZED	MINIMIZEDNORMALVALID_STATES__static_attributes__r       w/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/selenium/webdriver/common/bidi/browser.pyr   r      s'    $JIIF	9f=Lr   r   c                       \ rS rSrSrS\S\S\S\S\S\S	\4S
 jrS\4S jr	S\4S jr
S\4S jrS\4S jrS\4S jrS\4S jrS\4S jr\S\SS 4S j5       rSrg)ClientWindowInfo$   z'Represents a client window information.client_windowstatewidthheightxyactivec                 X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g Nr   r    r!   r"   r#   r$   r%   )selfr   r    r!   r"   r#   r$   r%   s           r   __init__ClientWindowInfo.__init__'   s(     +

r   returnc                     U R                   $ )zGets the state of the client window.

Returns:
    str: The state of the client window (one of the ClientWindowState constants).
)r    r)   s    r   	get_stateClientWindowInfo.get_state9        zzr   c                     U R                   $ )zTGets the client window identifier.

Returns:
    str: The client window identifier.
)r   r.   s    r   get_client_window"ClientWindowInfo.get_client_windowA   s     !!!r   c                     U R                   $ )zXGets the width of the client window.

Returns:
    int: The width of the client window.
)r!   r.   s    r   	get_widthClientWindowInfo.get_widthI   r1   r   c                     U R                   $ )zZGets the height of the client window.

Returns:
    int: The height of the client window.
)r"   r.   s    r   
get_heightClientWindowInfo.get_heightQ        {{r   c                     U R                   $ )zfGets the x coordinate of the client window.

Returns:
    int: The x coordinate of the client window.
)r#   r.   s    r   get_xClientWindowInfo.get_xY        vvr   c                     U R                   $ )zfGets the y coordinate of the client window.

Returns:
    int: The y coordinate of the client window.
)r$   r.   s    r   get_yClientWindowInfo.get_ya   r?   r   c                     U R                   $ )zqChecks if the client window is active.

Returns:
    bool: True if the client window is active, False otherwise.
)r%   r.   s    r   	is_activeClientWindowInfo.is_activei   r;   r   datac           
      R    US   n[        U[        5      (       d  [        S5      eUS   n[        U[        5      (       d  [        S5      eU[        R                  ;  a  [        SU S[        R                   35      eUS   n[        U[
        5      (       a  US:  a  [        S	U 35      eUS
   n[        U[
        5      (       a  US:  a  [        SU 35      eUS   n[        U[
        5      (       d!  [        S[        U5      R                   35      eUS   n[        U[
        5      (       d!  [        S[        U5      R                   35      eUS   n[        U[        5      (       d  [        S5      eU " UUUUUUUS9$ ! [        [        4 a  n	[        SU	 35      U	eSn	A	ff = f)a  Creates a ClientWindowInfo instance from a dictionary.

Args:
    data: A dictionary containing the client window information.

Returns:
    ClientWindowInfo: A new instance of ClientWindowInfo.

Raises:
    ValueError: If required fields are missing or have invalid types.
clientWindowzclientWindow must be a stringr    zstate must be a stringzInvalid state: z. Must be one of r!   r   z*width must be a non-negative integer, got r"   z+height must be a non-negative integer, got r#   zx must be an integer, got r$   zy must be an integer, got r%   zactive must be a booleanr(   z*Invalid data format for ClientWindowInfo: N)
isinstancestr
ValueErrorr   r   inttyper   boolKeyError	TypeError)
clsrF   r   r    r!   r"   r#   r$   r%   es
             r   	from_dictClientWindowInfo.from_dictq   s   )	V 0MmS11 !@AAMEeS)) !9::-::: ?5'9JK\KiKiJj!kllMEeS))UQY #MeW!UVV(^Ffc**fqj #Nvh!WXXS	Aa%% #=d1g>N>N=O!PQQS	Aa%% #=d1g>N>N=O!PQQ(^Ffd++ !;<<+  )$ 	VI!MNTUU	Vs   E?F F&F!!F&)r%   r   r"   r    r!   r#   r$   N)r   r   r   r   r   rJ   rL   rN   r*   r/   r3   r6   r9   r=   rA   rD   classmethoddictrS   r   r   r   r   r   r   $   s    1  	
    $3 "3 "3 C s s 4  5VT 5V&8 5V 5Vr   r   c            	           \ rS rSrSrS r   SS\S-  S\S-  S\S-  S\	4S	 jjr
S\\	   4S
 jrS\	SS4S jrS\\   4S jrSSSS.S\S-  S\	\R"                  -  S-  S\\	   S-  SS4S jjrSrg)Browser   z*BiDi implementation of the browser module.c                     Xl         g r'   conn)r)   r\   s     r   r*   Browser.__init__   s    	r   Naccept_insecure_certsproxyunhandled_prompt_behaviorr,   c                     0 nUb  XS'   Ub  UR                  5       US'   Ub  UR                  5       US'   U R                  R                  [	        SU5      5      nUS   $ )a7  Creates a new user context.

Args:
    accept_insecure_certs: Optional flag to accept insecure TLS certificates.
    proxy: Optional proxy configuration for the user context.
    unhandled_prompt_behavior: Optional configuration for handling user prompts.

Returns:
    str: The ID of the created user context.
acceptInsecureCertsr_   unhandledPromptBehaviorzbrowser.createUserContextuserContext)to_bidi_dictto_dictr\   executer   )r)   r^   r_   r`   paramsresults         r   create_user_contextBrowser.create_user_context   sr      "$ ,,A()#002F7O$00I0Q0Q0SF,-""?3NPV#WXm$$r   c                     U R                   R                  [        S0 5      5      nUS    Vs/ s H  o"S   PM	     sn$ s  snf )zMGets all user contexts.

Returns:
    List[str]: A list of user context IDs.
zbrowser.getUserContextsuserContextsrd   )r\   rg   r   )r)   ri   context_infos      r   get_user_contextsBrowser.get_user_contexts   sB     ""?3Lb#QR@F~@VW@V]+@VWWWs   >user_context_idc                 x    US:X  a  [        S5      eSU0nU R                  R                  [        SU5      5        g)zRemoves a user context.

Args:
    user_context_id: The ID of the user context to remove.

Raises:
    ValueError: If the user context ID is "default" or does not exist.
defaultz&Cannot remove the default user contextrd   zbrowser.removeUserContextN)rK   r\   rg   r   )r)   rq   rh   s      r   remove_user_contextBrowser.remove_user_context   s<     i'EFF1		/*EvNOr   c                     U R                   R                  [        S0 5      5      nUS    Vs/ s H  n[        R	                  U5      PM     sn$ s  snf )zdGets all client windows.

Returns:
    List[ClientWindowInfo]: A list of client window information.
zbrowser.getClientWindowsclientWindows)r\   rg   r   r   rS   )r)   ri   windows      r   get_client_windowsBrowser.get_client_windows   sK     ""?3Mr#RSAGAXYAXv **62AXYYYs   A)alloweddestination_folderuser_contextsr{   r|   r}   c                   0 nUc  SUS'   OOU(       a/  U(       d  [        S5      eS[        R                  " U5      S.US'   OU(       a  [        S5      eSS0US'   Ub  X4S	'   U R                  R	                  [        S
U5      5        g)aD  Set the download behavior for the browser or specific user contexts.

Args:
    allowed: True to allow downloads, False to deny downloads, or None to
        clear download behavior (revert to default).
    destination_folder: Required when allowed is True. Specifies the folder
        to store downloads in.
    user_contexts: Optional list of user context IDs to apply this
        behavior to. If omitted, updates the default behavior.

Raises:
    ValueError: If allowed=True and destination_folder is missing, or if
        allowed=False and destination_folder is provided.
NdownloadBehaviorz1destination_folder is required when allowed=True.r{   )rM   destinationFolderz=destination_folder should not be provided when allowed=False.rM   deniedrm   zbrowser.setDownloadBehavior)rK   osfspathr\   rg   r   )r)   r{   r|   r}   rh   s        r   set_download_behaviorBrowser.set_download_behavior   s    * "$?)-F%&)$%XYY%)+3E)F.)*
 &$%dee.4h-?)*$%2>"		/*GPQr   r[   )NNN)r   r   r   r   r   r*   rN   r   r   rJ   rj   listro   rt   r   ry   r   PathLiker   r   r   r   r   rX   rX      s    4
 .2">B	%#d{% t|% $5t#;	%
 
%<X49 XP3 P4 PZD)9$: Z  $7;*.)R )R  "++-4	)R
 Cy4')R 
)R )Rr   rX   )r   typingr   %selenium.webdriver.common.bidi.commonr   &selenium.webdriver.common.bidi.sessionr   selenium.webdriver.common.proxyr   r   r   rX   r   r   r   <module>r      s=   " 
  A D 1> >CV CVLnR nRr   