o
    _c0	                     @   s0   d Z ddlmZ ddlmZ G dd deZdS )zDialog module.    )SimpleNamespace)
CDPSessionc                   @   s   e Zd ZdZedddddZ	dded	ed
ededdf
ddZe	defddZ
e	defddZe	defddZddeddfddZdddZdS )Dialoga  Dialog class.

    Dialog objects are dispatched by page via the ``dialog`` event.

    An example of using ``Dialog`` class:

    .. code::

        browser = await launch()
        page = await browser.newPage()

        async def close_dialog(dialog):
            print(dialog.message)
            await dialog.dismiss()
            await browser.close()

        page.on(
            'dialog',
            lambda dialog: asyncio.ensure_future(close_dialog(dialog))
        )
        await page.evaluate('() => alert("1")')
    alertZbeforeunloadZconfirmprompt)ZAlertZBeforeUnloadZConfirmPrompt clienttypemessagedefaultValuereturnNc                 C   s"   || _ || _|| _d| _|| _d S )NF)_client_type_message_handled_defaultValue)selfr	   r
   r   r    r   ;/usr/local/lib/python3.10/dist-packages/pyppeteer/dialog.py__init__*   s
   
zDialog.__init__c                 C      | j S )zbGet dialog type.

        One of ``alert``, ``beforeunload``, ``confirm``, or ``prompt``.
        )r   r   r   r   r   r
   2      zDialog.typec                 C   r   )zGet dialog message.)r   r   r   r   r   r   :   s   zDialog.messagec                 C   r   )zwIf dialog is prompt, get default prompt value.

        If dialog is not prompt, return empty string (``''``).
        )r   r   r   r   r   r   ?   r   zDialog.defaultValue
promptTextc                    s&   d| _ | jdd|dI dH  dS )zAccept the dialog.

        * ``promptText`` (str): A text to enter in prompt. If the dialog's type
          is not prompt, this does not cause any effect.
        TPage.handleJavaScriptDialog)acceptr   Nr   r   send)r   r   r   r   r   r   G   s   zDialog.acceptc                    s$   d| _ | jdddiI dH  dS )zDismiss the dialog.Tr   r   FNr   r   r   r   r   dismissS   s
   zDialog.dismiss)r   )r   N)__name__
__module____qualname____doc__r   Typer   strr   propertyr
   r   r   r   r   r   r   r   r   r      s,    
r   N)r#   typesr   Zpyppeteer.connectionr   objectr   r   r   r   r   <module>   s   