o
    aqe9@                     @   s   d dl mZ d dlmZmZmZ ddlmZmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZ ddlmZmZ G dd deZd	S )
    )dumps)ListOptionalUnion   )
JsonObjectJsonValidatorextract_json)	AbstractDialogSelectorDialogChannelSelectorDialogConversationSelectorDialogExternalSelectorDialogStaticSelectorDialogTextAreaDialogTextComponentDialogTextFieldDialogUserSelector)OptionOptionGroupc                   @   s4  e Zd ZU i Zee ed< eee	e
f  ed< ee ed< eed< ee ed< dZdZdZdZd	d
 Zdedd fddZdeeef dd fddZdedd fddZdedd fddZdedd fddZddddddddd eded!ed"ee d#ee d$ee d%ed&ed'ee dd fd(d)Zddddddddd eded!ed"ee d#ee d$ee d%ed&ed'ee dd fd*d+Zdddd,d eded-eee ee f d!ed$ee d"ee dd fd.d/Zddddd0d eded!ed$ee d"ee d1ee dd fd2d3Zdddd,d eded!ed$ee d"ee dd fd4d5Zdddd,d eded!ed$ee d"ee dd fd6d7Zdddd,d eded!ed$ee d"ee dd fd8d9Z e!d:d;d< Z"e!d=e d>d?d@ Z#e!dAdBdC Z$e!dDe dEdFdG Z%e!dHe d>dIdJ Z&e!dKdLdM Z'e!dNe d>dOdP Z(defdQdRZ)dS )SDialogBuilder_callback_id	_elements_submit_label_notify_on_cancel_state   
   i  c                 C   s(   d| _ d| _g | _d| _d| _d| _dS )zw
        Create a DialogBuilder to more easily construct the JSON required to submit a
        dialog to Slack
        NF)_titler   r   r   r   r   self r    Z/var/www/html/humari/django-venv/lib/python3.10/site-packages/slack/web/classes/dialogs.py__init__!   s   
zDialogBuilder.__init__titlereturnc                 C   
   || _ | S )zo
        Specify a title for this dialog

        Args:
          title: must not exceed 24 characters
        r   )r   r#   r    r    r!   r#   -   s   zDialogBuilder.titlestatec                 C   s"   t |trt|| _| S || _| S )a  
        Pass state into this dialog - dictionaries will be automatically formatted to
        JSON

        Args:
            state: Extra state information that you need to pass from this dialog
                back to your application on submission
        )
isinstancedictr   r   )r   r'   r    r    r!   r'   7   s
   
	
zDialogBuilder.statecallback_idc                 C   r%   )z
        Specify a callback ID for this dialog, which your application will then
        receive upon dialog submission

        Args:
          callback_id: a string identifying this particular dialog
        r   )r   r*   r    r    r!   r*   F   s   zDialogBuilder.callback_idlabelc                 C   r%   )z
        The label to use on the 'Submit' button on the dialog. Defaults to 'Submit'
        if not specified.

        Args:
            label: must not exceed 24 characters, and must be a single word (no
                spaces)
        r   )r   r,   r    r    r!   submit_labelQ      	zDialogBuilder.submit_labelnotifyc                 C   r%   )aF  
        Whether this dialog should send a request to your application even if the
        user cancels their interaction. Defaults to False.

        Args:
            notify: Set to True to indicate that your application should receive a
                request even if the user cancels interaction with the dialog.
        )r   )r   r0   r    r    r!   notify_on_cancel]   r/   zDialogBuilder.notify_on_cancelFNr      )optionalplaceholderhintvalue
min_length
max_lengthsubtypenamer3   r4   r5   r6   r7   r8   r9   c       	   
      C   &   | j t|||||||||	d	 | S )a  
        Text elements are single-line plain text fields.

        https://api.slack.com/dialogs#attributes_text_elements

        Args:
            name: Name of form element. Required. No more than 300 characters.
            label: Label displayed to user. Required. 48 character maximum.
            optional: Provide true when the form element is not required. By
                default, form elements are required.
            placeholder: A string displayed as needed to help guide users in
                completing the element. 150 character maximum.
            hint: Helpful text provided to assist users in answering a question.
                Up to 150 characters.
            value: A default value for this field. Up to 150 characters.
            min_length: Minimum input length allowed for element. Up to 150
                characters. Defaults to 0.
            max_length: Maximum input length allowed for element. Up to 150
                characters. Defaults to 150.
            subtype: A subtype for this text input. Accepts email, number, tel,
                    or url. In some form factors, optimized input is provided for this
                    subtype.
        	r:   r,   r3   r4   r5   r6   r7   r8   r9   )r   appendr   
r   r:   r,   r3   r4   r5   r6   r7   r8   r9   r    r    r!   
text_fieldi   s   $zDialogBuilder.text_fieldc       	   
      C   r;   )a  
        A textarea is a multi-line plain text editing control. You've likely
        encountered these on the world wide web. Use this element if you want a
        relatively long answer from users. The element UI provides a remaining
        character count to the max_length you have set or the default,
        3000.

        https://api.slack.com/dialogs#attributes_textarea_elements

        Args:
            name: Name of form element. Required. No more than 300 characters.
            label: Label displayed to user. Required. 48 character maximum.
            optional: Provide true when the form element is not required. By
                default, form elements are required.
            placeholder: A string displayed as needed to help guide users in
                completing the element. 150 character maximum.
            hint: Helpful text provided to assist users in answering a question.
                Up to 150 characters.
            value: A default value for this field. Up to 3000 characters.
            min_length: Minimum input length allowed for element. 1-3000
                characters. Defaults to 0.
            max_length: Maximum input length allowed for element. 0-3000
                characters. Defaults to 3000.
            subtype: A subtype for this text input. Accepts email, number, tel,
                or url. In some form factors, optimized input is provided for this
                subtype.
        r<   )r   r=   r   r>   r    r    r!   	text_area   s   (zDialogBuilder.text_area)r3   r6   r4   optionsc             
   C       | j t||||||d | S )a  
        Use the select element for multiple choice selections allowing users to pick
        a single item from a list. True to web roots, this selection is displayed as
        a dropdown menu.

        A select element may contain up to 100 selections, provided as a list of
        Option or OptionGroup objects

        https://api.slack.com/dialogs#attributes_select_elements

        Args:
            name: Name of form element. Required. No more than 300 characters.
            label: Label displayed to user. Required. No more than 48 characters.
            options: A list of up to 100 Option or OptionGroup objects. Object
                types cannot be mixed.
            optional: Provide true when the form element is not required. By
                default, form elements are required.
            value: Provide a default selected value.
            placeholder: A string displayed as needed to help guide users in
                completing the element. 150 character maximum.
        )r:   r,   rA   r3   r6   r4   )r   r=   r   )r   r:   r,   rA   r3   r6   r4   r    r    r!   static_selector   s   
zDialogBuilder.static_selector)r3   r6   r4   min_query_lengthrD   c             
   C   rB   )a  
        Use the select element for multiple choice selections allowing users to pick
        a single item from a list. True to web roots, this selection is displayed as
        a dropdown menu.

        A list of options can be loaded from an external URL and used in your dialog
        menus.

        https://api.slack.com/dialogs#dynamic_select_elements_external

        Args:
            name: Name of form element. Required. No more than 300 characters.
            label: Label displayed to user. Required. No more than 48 characters.
            min_query_length: Specify the number of characters that must be
                typed by a user into a dynamic select menu before dispatching to your
                application.
            optional: Provide true when the form element is not required. By
                default, form elements are required.
            value: Provide a default selected value. This should be a single
                Option or OptionGroup that exactly matches one that will be returned
                from your external endpoint.
            placeholder: A string displayed as needed to help guide users in
                completing the element. 150 character maximum.
        )r:   r,   r3   r6   r4   rD   )r   r=   r   )r   r:   r,   r3   r6   r4   rD   r    r    r!   external_selector   s   "
zDialogBuilder.external_selectorc             	   C      | j t|||||d | S )aq  
        Now you can easily populate a select menu with a list of users. For example,
        when you are creating a bug tracking app, you want to include a field for an
        assignee. Slack pre-populates the user list in client-side, so your app
        doesn't need access to a related OAuth scope.

        https://api.slack.com/dialogs#dynamic_select_elements_users

        Args:
            name: Name of form element. Required. No more than 300 characters.
            label: Label displayed to user. Required. No more than 48 characters.
            optional: Provide true when the form element is not required. By
                default, form elements are required.
            value: Provide a default selected value.
            placeholder: A string displayed as needed to help guide users in
                completing the element. 150 character maximum.
        r:   r,   r3   r6   r4   )r   r=   r   r   r:   r,   r3   r6   r4   r    r    r!   user_selector,  s   	zDialogBuilder.user_selectorc             	   C   rF   )a  
        You can also provide a select menu with a list of channels. Specify your
        data_source as channels to limit only to public channels

        https://api.slack.com/dialogs#dynamic_select_elements_channels_conversations

        Args:
            name: Name of form element. Required. No more than 300 characters.
            label: Label displayed to user. Required. No more than 48 characters.
            optional: Provide true when the form element is not required. By
                default, form elements are required.
            value: Provide a default selected value.
            placeholder: A string displayed as needed to help guide users in
                completing the element. 150 character maximum.
        rG   )r   r=   r   rH   r    r    r!   channel_selectorQ  s   	zDialogBuilder.channel_selectorc             	   C   rF   )a  
        You can also provide a select menu with a list of conversations - including
        private channels, direct messages, MPIMs, and whatever else we consider a
        conversation-like thing.

        https://api.slack.com/dialogs#dynamic_select_elements_channels_conversations

        Args:
            name: Name of form element. Required. No more than 300 characters.
            label: Label displayed to user. Required. No more than 48 characters.
            optional: Provide true when the form element is not required. By
                default, form elements are required.
            value: Provide a default selected value.
            placeholder: A string displayed as needed to help guide users in
                completing the element. 150 character maximum.
        rG   )r   r=   r   rH   r    r    r!   conversation_selectort  s   	z#DialogBuilder.conversation_selectorztitle attribute is requiredc                 C   
   | j d uS Nr&   r   r    r    r!   title_present     
zDialogBuilder.title_presentztitle attribute cannot exceed z charactersc                 C   s   | j d uot| j | jkS rM   )r   lentitle_max_lengthr   r    r    r!   title_length  s   zDialogBuilder.title_lengthz!callback_id attribute is requiredc                 C   rL   rM   r+   r   r    r    r!   callback_id_present  rO   z!DialogBuilder.callback_id_presentz#dialogs must contain between 1 and z	 elementsc                 C   s    dt | j  k o| jkS   S )Nr   )rP   r   elements_max_lengthr   r    r    r!   elements_length  s    zDialogBuilder.elements_lengthzsubmit_label cannot exceed c                 C   s   | j d u pt| j | jkS rM   )r   rP   submit_label_max_lengthr   r    r    r!   submit_label_length  s   
z!DialogBuilder.submit_label_lengthz!submit_label can only be one wordc                 C   s   | j d u p	d| j vS )N r-   r   r    r    r!   submit_label_valid  s   z DialogBuilder.submit_label_validzstate cannot exceed c                 C   s   | j  pt| j | jkS rM   )r   rP   state_max_lengthr   r    r    r!   state_length  s   zDialogBuilder.state_lengthc                 C   sN   |    | j| jt| j| jd}| jd ur| j|d< | jd ur%| j|d< |S )N)r#   r*   elementsr1   r.   r'   )validate_jsonr   r   r	   r   r   r   r   )r   jsonr    r    r!   to_dict  s   



zDialogBuilder.to_dict)*__name__
__module____qualname__
attributesr   str__annotations__r   r   r   r
   boolrQ   rV   rT   rZ   r"   r#   r)   r'   r*   r.   r1   intr?   r@   r   r   rC   rE   rI   rJ   rK   r   rN   rR   rS   rU   rW   rY   r[   r_   r    r    r    r!   r      sZ  
 
	

8	

=	
0	
3
*
(
$






r   N)r^   r   typingr   r   r    r   r   r	   dialog_elementsr
   r   r   r   r   r   r   r   r   objectsr   r   r   r    r    r    r!   <module>   s    ,