Ë
    µŒjê  ã                  óÄ   — d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
 erddlmZ ddlmZ ddlmZ ddlmZ dd„Zdd„Z	 d	 	 	 	 	 dd	„Z	 d	 	 	 	 	 dd
„Z e
d«      Zdd„Zy)z+Utilities for the Playwright browser tools.é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚ	CoroutineÚListÚOptionalÚTypeVar)ÚBrowser)ÚPagec              ƒ  ó  K  — | j                   s0| j                  «       ƒ d{  –—† }|j                  «       ƒ d{  –—† S | j                   d   }|j                  s|j                  «       ƒ d{  –—† S |j                  d   S 7 Œ^7 ŒH7 Œ­w)zÅ
    Asynchronously get the current page of the browser.

    Args:
        browser: The browser (AsyncBrowser) to get the current page from.

    Returns:
        AsyncPage: The current page.
    Nr   éÿÿÿÿ©ÚcontextsÚnew_contextÚnew_pageÚpages©ÚbrowserÚcontexts     út/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langchain_community/tools/playwright/utils.pyÚaget_current_pager      s{   è ø€ ð ×ÒØ×+Ñ+Ó-×-ˆØ×%Ñ%Ó'×'Ð'Ø×Ñ˜qÑ!€GØ�=Š=Ø×%Ñ%Ó'×'Ð'à�=‰=˜ÑÐð .øØ'øð (ús1   ‚ B¢B£BºB»2BÁ-BÁ.BÂBÂBc                óÎ   — | j                   s | j                  «       }|j                  «       S | j                   d   }|j                  s|j                  «       S |j                  d   S )z¥
    Get the current page of the browser.
    Args:
        browser: The browser to get the current page from.

    Returns:
        SyncPage: The current page.
    r   r   r   r   s     r   Úget_current_pager   #   s_   € ð ×ÒØ×%Ñ%Ó'ˆØ×ÑÓ!Ð!Ø×Ñ˜qÑ!€GØ�=Š=Ø×ÑÓ!Ð!à�=‰=˜ÑÐó    c                ó–   — ddl m} t         |«       j                  «       «      }t        |j                  j                  | |¬«      «      S )a   
    Create an async playwright browser.

    Args:
        headless: Whether to run the browser in headless mode. Defaults to True.
        args: arguments to pass to browser.chromium.launch

    Returns:
        AsyncBrowser: The playwright browser.
    r   )Úasync_playwright©ÚheadlessÚargs)Úplaywright.async_apir   Ú	run_asyncÚstartÚchromiumÚlaunch)r   r   r   r   s       r   Úcreate_async_playwright_browserr%   6   s?   € õ 6äÑ(Ó*×0Ñ0Ó2Ó3€GÜ�W×%Ñ%×,Ñ,°hÀTÐ,ÓJÓKÐKr   c                ór   — ddl m}  |«       j                  «       }|j                  j	                  | |¬«      S )zø
    Create a playwright browser.

    Args:
        headless: Whether to run the browser in headless mode. Defaults to True.
        args: arguments to pass to browser.chromium.launch

    Returns:
        SyncBrowser: The playwright browser.
    r   )Úsync_playwrightr   )Úplaywright.sync_apir'   r"   r#   r$   )r   r   r'   r   s       r   Úcreate_sync_playwright_browserr)   I   s4   € õ 4áÓ×%Ñ%Ó'€GØ×Ñ×"Ñ"¨H¸4Ð"Ó@Ð@r   ÚTc                óL   — t        j                  «       }|j                  | «      S )z˜Run an async coroutine.

    Args:
        coro: The coroutine to run. Coroutine[Any, Any, T]

    Returns:
        T: The result of the coroutine.
    )ÚasyncioÚget_event_loopÚrun_until_complete)ÚcoroÚ
event_loops     r   r!   r!   _   s#   € ô ×'Ñ'Ó)€JØ×(Ñ(¨Ó.Ð.r   )r   ÚAsyncBrowserÚreturnÚ	AsyncPage)r   ÚSyncBrowserr2   ÚSyncPage)TN)r   Úboolr   úOptional[List[str]]r2   r1   )r   r6   r   r7   r2   r4   )r/   zCoroutine[Any, Any, T]r2   r*   )Ú__doc__Ú
__future__r   r,   Útypingr   r   r   r   r   r	   r    r
   r1   r   r3   r(   r4   r5   r   r   r%   r)   r*   r!   © r   r   Ú<module>r<      s‰   ðÙ 1å "ã ß I× IáÝ<Ý6Ý:Ý4óó(ð( 8<ðLØðLØ!4ðLàóLð( 8<ðAØðAØ!4ðAàóAñ& ˆCƒL€ô
/r   