
    j$                        d dl Z d dlZd dlmZ d dlmZ d dlmZmZmZ d dl	m
Z
mZmZmZ  G d de          Z G d d	e          Z G d
 de          Z G d dee                   Z G d de          Z G d de          Z G d dee          Z G d de          Z G d de          Z G d de          ZdS )    N)ABC)datetime)CallableListUnion)UUIDElementNoIDTextc                       e Zd ZdZdS )NoDatestampz?Class to indicate that an element do not have a datetime stamp.N__name__
__module____qualname____doc__     o/lsinfo/ai/hellotax_ai/base_platform/venv/lib/python3.11/site-packages/unstructured/documents/email_elements.pyr   r   
   s        IIIIr   r   c                       e Zd ZdZdS )EmailElementz+An email element is a section of the email.Nr   r   r   r   r   r      s        5555r   r   c                        e Zd ZdZdZ e             e            fdededee	ef         deee
j        eef         f fdZd Zd	 Zd
 ZdefdZ xZS )Namez:Base element for capturing free text from within document.Uncategorizednametext	datestamp
element_idc                    || _         || _        t          |t                    rAt	          j        |                                                                          d d         }n(t          |t                    rt          j
                    }t                                          |           t          |t                    r	|| _        d S d S )N    )r   )r   r   
isinstancer
   hashlibsha256encode	hexdigestr   uuiduuid4super__init__r   r   )selfr   r   r   r   	__class__s        r   r)   zName.__init__   s     		j$'' 	& 66@@BB3B3GJJ
D)) 	&JJ///i** 	1'0DNNN	1 	1r   c                 "    dt                      v S )Nzself.datestamp)globalsr*   s    r   has_datestampzName.has_datestamp-   s    799,,r   c                 $    | j          d| j         S )Nz: )r   r   r.   s    r   __str__zName.__str__0   s    )**ty***r   c                     |                                  r0| j        |j        k    o| j        |j        k    o| j        |j        k    S | j        |j        k    o| j        |j        k    S )N)r/   r   r   r   )r*   others     r   __eq__zName.__eq__3   sh     		UZ' 6I+6Neo5
 yEJ&B49
+BBr   cleanersc                     | j         }| j        }|D ]} ||          } ||          }t          |t                    rt          |t                    st	          d          || _         || _        dS )zApplies a cleaning brick to the text element. The function that's passed in
        should take a string as input and produce a string as output.z%Cleaner produced a non-string output.N)r   r   r!   str
ValueError)r*   r5   cleaned_textcleaned_namecleaners        r   applyz
Name.apply<   s     yy 	1 	1G"7<00L"7<00LL,,, 	FJ|S4Q4Q 	FDEEE 	 			r   )r   r   r   r   categoryr   r
   r7   r   r   r&   r   r)   r/   r1   r4   r   r<   __classcell__)r+   s   @r   r   r      s        DDH 3>+--8<1 11 1 ;./	1
 #ty$451 1 1 1 1 1,- - -+ + +C C C!x ! ! ! ! ! ! ! !r   r   c                       e Zd ZdZd ZdS )BodyTextzBodyText is an element consisting of multiple, well-formulated sentences. This
    excludes elements such titles, headers, footers, and captions. It is the body of an email.Nr   r   r   r   r=   r   r   r   r@   r@   M   s!        b b HHHr   r@   c                       e Zd ZdZd ZdS )	RecipientzBA text element for capturing the recipient information of an emailNrA   r   r   r   rC   rC   T   s        LLHHHr   rC   c                       e Zd ZdZd ZdS )Senderz?A text element for capturing the sender information of an emailNrA   r   r   r   rE   rE   Z   s        IIHHHr   rE   c                       e Zd ZdZd ZdS )Subjectz@A text element for capturing the subject information of an emailNrA   r   r   r   rG   rG   `   s        JJHHHr   rG   c                       e Zd ZdZd ZdS )MetaDataz`A text element for capturing header meta data of an email
    (miscellaneous data in the email).NrA   r   r   r   rI   rI   f   s        * * HHHr   rI   c                       e Zd ZdZd ZdS )ReceivedInfozUA text element for capturing header information of an email (e.g. IP addresses, etc).NrA   r   r   r   rK   rK   m   s        __HHHr   rK   c                       e Zd ZdZd ZdS )
Attachmentz_A text element for capturing the attachment name in an email (e.g. documents,
    images, etc).NrA   r   r   r   rM   rM   s   s          HHHr   rM   )r"   r&   abcr   r   typingr   r   r   unstructured.documents.elementsr   r	   r
   r   r   r   r   r@   rC   rE   rG   rI   rK   rM   r   r   r   <module>rQ      s:                 ( ( ( ( ( ( ( ( ( ( E E E E E E E E E E E EJ J J J J# J J J6 6 6 6 67 6 6 68! 8! 8! 8! 8!< 8! 8! 8!v    tDz              T       dL       t       4            r   