
    Ng^                    l   d Z ddlmZ ddlZddlmZ ddlmZ ddlmZm	Z	 ddl
mZmZ ddlmZmZ  G d	 d
ee          Z G d de          ZddZ G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Z G d& d'e          Z G d( d)e          Z  G d* d+e          Z! G d, d-e          Z" G d. d/e          Z# G d0 d1e          Z$ G d2 d3e          Z% G d4 d5e          Z& G d6 d7e          Z' G d8 d9e          Z( G d: d;e          Z) G d< d=e          Z* G d> d?e          Z+ G d@ dAe          Z, G dB dCe          Z- G dD dEe          Z. G dF dGe          Z/ G dH dIe          Z0 G dJ dKe          Z1 G dL dMe          Z2 G dN dOe          Z3 G dP dQe          Z4 G dR dSe          Z5 G dT dUe          Z6 G dV dWe          Z7 G dX dYe          Z8 G dZ d[e          Z9 G d\ d]e          Z: G d^ d_e          Z; G d` dae          Z< G db dce          Z= G dd dee          Z> G df dge          Z? G dh die          Z@ G dj dke          ZA G dl dme          ZB G dn doe          ZC G dp dqe          ZD G dr dse          ZE G dt due          ZF G dv dwe          ZG G dx dye          ZH G dz d{e          ZI G d| d}e          ZJ G d~ de          ZK G d de          ZL G d de          ZM G d de          ZN G d de          ZO G d de          ZP G d de          ZQ G d de          ZR G d de          ZS G d de          ZT G d de          ZU G d de          ZV G d de          ZW G d de          ZX G d de          ZY G d de          ZZdS )af  
This file contains all classes allowed in the ontology V2.
This Type is used as intermediate representation between HTML
and Unstructured Elements.
All the processing could be done without the intermediate representation,
but it simplifies the process.
It needs to be decide whether we keep it or not.

The classes are represented as pydantic models to mimic Unstructured Elements V1 solutions.
However it results in lots of code that could be strongly simplified.

TODO (Pluto): OntologyElement is the only needed class. It could contains data about
 allowed html tags, css classes and descriptions as metadata.
    )annotationsN)copy)Enum)ListOptional)BeautifulSoupTag)	BaseModelFieldc                  F    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdS )ElementTypeEnumLayoutTextr   TableMediaCodeMathematical	ReferenceMetadata
NavigationForm
AnnotationzSpecialized TextzDocument-SpecificN)__name__
__module____qualname__layouttextlisttablemediacodemathematical	referencemetadata
navigationform
annotationspecialized_textdocument_specific     [/var/www/html/ai-engine/env/lib/python3.11/site-packages/unstructured/documents/ontology.pyr   r      sX        FDDEED!LIHJDJ)+r+   r   c                      e Zd ZU  edd          Zded<    ed d          Zded	<    ed
 d          Zded<    edd          Zded<    ee	d          Z
ded<    edd          Zded<    edd          Zded<    ei d          Zded<    fdZed0d            Zd1d0d!Zd2d0d"Zd3d%Zd4d(Zd5d+Zed6d-            Zed7d/            Z xZS )8OntologyElement zText content of the element)descriptionzOptional[str]r   c                     dS Nr/   r*   r*   r+   r,   <lambda>zOntologyElement.<lambda>/        r+   z%CSS class associated with the element)default_factoryr0   css_class_namec                     dS r2   r*   r*   r+   r,   r3   zOntologyElement.<lambda>2   r4   r+   z)HTML Tag name associated with the elementhtml_tag_name.zType of the elementr   elementTypezList of child elementszList['OntologyElement']childrenzDescription of the elementstrr0   z%HTML tags associated with the element	List[str]allowed_tagsz*Optional HTML attributes or CSS propertieszOptional[dict]additional_attributesc                     t                      j        di | | j        dk    r| j        j        | _        | j        dk    r| j        d         | _        d| j        vr|                                 | j        d<   d S d S )Nr/   r   idr*   )	super__init__r6   	__class__r   r8   r=   r>   generate_unique_id)selfkwargsrC   s     r,   rB   zOntologyElement.__init__@   s    ""6""""$$"&."9D##!%!21!5Dt111/3/F/F/H/HD&t,,, 21r+   returnc                 j    t          t          j                                                  dd          S )N-r/   )r;   uuiduuid4replacer*   r+   r,   rD   z"OntologyElement.generate_unique_idI   s&    4:<<  ((b111r+   Tc                4   t          | j                  }|                    dd            |                     |          }| j        rd| j         dnd}| d|                                 }|                     |          }|                     ||          }|S )Nclasszclass=""r/    )r   r>   pop_construct_attribute_stringr6   strip_generate_children_html_generate_final_html)rE   add_childrenadditional_attrsattr_str
class_attrcombined_attr_strchildren_htmlresult_htmls           r,   to_htmlzOntologyElement.to_htmlM   s     :;;Wd+++334DEE9=9LT5t25555RT
)66H66<<>>44\BB//0A=QQr+   c                   | j         r+r)d                    fd| j         D                       }|S t          |                                 d                                                                          }r5| j        dk    r*d| j        v r!|d| j                            dd           z  }|                                S )aK  
        Returns the text representation of the element.

        Args:
            add_children: If True, the text of the children will be included.
                            Otherwise, element is represented as single self-closing tag.
            add_img_alt_text: If True, the alt text of the image will be included.
        rP   c              3  h   K   | ],}|                                                               V  -d S N)to_textrS   ).0childrV   add_img_alt_texts     r,   	<genexpr>z*OntologyElement.to_text.<locals>.<genexpr>f   sO       % %JOl,<==CCEE% % % % % %r+   html.parserimgaltr/   )	r:   joinr   r]   get_textrS   r8   r>   get)rE   rV   rd   children_textr   s    ``  r,   ra   zOntologyElement.to_text\   s     = 	!\ 	!HH % % % % %SWS`% % %  M ! T\\^^];;DDFFLLNN 	D 2e ; ;Ic@c@cC266ubAACCCDzz||r+   
attributesdictc                d    d                     d |                                D                       S )NrP   c              3  6   K   | ]\  }}|r| d | dn| V  dS )z="rO   Nr*   )rb   keyvalues      r,   re   z>OntologyElement._construct_attribute_string.<locals>.<genexpr>s   sT       
 
:D#u%5seX
 
 
 
 
 
r+   )ri   items)rE   rm   s     r,   rR   z+OntologyElement._construct_attribute_stringr   s@    xx 
 
HRHXHXHZHZ
 
 
 
 
 	
r+   rV   boolc                `    |r| j         sdS d                    d | j         D                       S )Nr/   c              3  >   K   | ]}|                                 V  d S r`   )r]   )rb   rc   s     r,   re   z:OntologyElement._generate_children_html.<locals>.<genexpr>z   s*      BB5u}}BBBBBBr+   )r:   ri   )rE   rV   s     r,   rT   z'OntologyElement._generate_children_htmlw   s;     	4= 	2wwBBDMBBBBBBr+   rX   r[   c                p    | j         pd}|s|rd| j         d| d| d| d| j         dS d| j         d| dS )Nr/   <rP   >z</z />)r   r8   )rE   rX   r[   r   s       r,   rU   z$OntologyElement._generate_final_html|   so    yB 	:= 	:dt)ddHddtddmddtOadddd9t)99H9999r+   
str | Nonec                8    | j                             dd           S )Nr@   )r>   rk   rE   s    r,   r@   zOntologyElement.id   s    )--dD999r+   
int | Nonec                    d| j         v r9	 t          | j                             d                    S # t          $ r Y d S w xY wd S )Nzdata-page-number)r>   intrk   
ValueErrorr|   s    r,   page_numberzOntologyElement.page_number   s\    !;;;4599:LMMNNN   ttts   &2 
A A rG   r;   TTT)rm   rn   rG   r;   )rV   rt   rG   r;   )rX   r;   r[   r;   rG   r;   )rG   rz   )rG   r}   )r   r   r   r   r   __annotations__r6   r8   r9   r   r:   r0   r=   r>   rB   staticmethodrD   r]   ra   rR   rT   rU   propertyr@   r   __classcell__rC   s   @r,   r.   r.   ,   s`        %0MNNNDNNNN$)E"
0W% % %N     $)5"
0[$ $ $M     $)5:O#P#P#PKPPPP(-*B) ) )H     uS.JKKKKKKKK#eC5\]]]L]]]],1E
D- - -    I I I I I 2 2 2 \2        ,
 
 
 

C C C C
: : : : : : : X:    X    r+   r.   soupr	   c                   |                      d          D ]k}|j        dk    r6|j                            dd            |j                            dd            |j        dv rd                    |j                  |_        l| S )NTr   rN   r@   )tdthrP   )find_allnameattrsrQ   ri   stripped_stringsstring)r   tags     r,   remove_ids_and_class_from_tabler      s    }}T"" 8 88wIMM'4(((IMM$%%%8|###"677CJKr+   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )DocumentzRoot element of the documentTfrozenr;   r0   r   r9   bodyr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r      sx         u;DIIIKIIII#(5)?#M#M#MKMMMM#eVHT:::L::::::r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Sectionz,A distinct part or subdivision of a documentTr   r;   r0   r   r9   sectionr<   r=   Nr   r*   r+   r,   r   r      sy         uKTXYYYKYYYY#(5)?#M#M#MKMMMM#eYK===L======r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Pagez&A single side of a paper in a documentTr   r;   r0   r   r9   divr<   r=   Nr   r*   r+   r,   r   r      sx         uEdSSSKSSSS#(5)?#M#M#MKMMMM#eUGD999L999999r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )ColumnzA vertical section of a pageTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r      sx         u;DIIIKIIII#(5)?#M#M#MKMMMM#eUGD999L999999r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	Paragraphz-A self-contained unit of discourse in writingTr   r;   r0   r   r9   pr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r      sy         uLUYZZZKZZZZ#(5)=d#K#K#KKKKKK#eSE$777L777777r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )HeaderzThe top section of a pageTr   r;   r0   r   r9   headerr<   r=   Nr   r*   r+   r,   r   r      sx         u8FFFKFFFF#(5)?#M#M#MKMMMM#eXJt<<<L<<<<<<r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )FooterzThe bottom section of a pageTr   r;   r0   r   r9   footerr<   r=   Nr   r*   r+   r,   r   r      sx         u;DIIIKIIII#(5)?#M#M#MKMMMM#eXJt<<<L<<<<<<r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )SidebarzA side section of a pageTr   r;   r0   r   r9   asider<   r=   Nr   r*   r+   r,   r   r      sx         u7EEEKEEEE#(5)?#M#M#MKMMMM#eWId;;;L;;;;;;r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	PageBreakzA break between pagesTr   r;   r0   r   r9   hrr<   r=   Nr   r*   r+   r,   r   r      sx         u4TBBBKBBBB#(5)?#M#M#MKMMMM#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Titlez%Main heading of a document or sectionTr   r;   r0   r   r9   h1r<   r=   Nr   r*   r+   r,   r   r      x         uDTRRRKRRRR#(5)=d#K#K#KKKKKK#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Subtitlez(Secondary title of a document or sectionTr   r;   r0   r   r9   h2r<   r=   Nr   r*   r+   r,   r   r      sy         uGPTUUUKUUUU#(5)=d#K#K#KKKKKK#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    eg dd          Z	d	ed
<   dS )HeadingzSection headings (levels 1-6)Tr   r;   r0   r   r9   )r   r   h3h4h5h6r<   r=   Nr   r*   r+   r,   r   r      s~         u<TJJJKJJJJ#(5)=d#K#K#KKKKKK#e$H$H$HQUVVVLVVVVVVr+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )NarrativeTextzMain content textTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r      sx         u0>>>K>>>>#(5)=d#K#K#KKKKKK#eSE$777L777777r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Quotez(A repetition of someone else's statementTr   r;   r0   r   r9   
blockquoter<   r=   Nr   r*   r+   r,   r   r      sy         uGPTUUUKUUUU#(5)=d#K#K#KKKKKK#e\N4@@@L@@@@@@r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )FootnotezA note at the bottom of a pageTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r      sx         u=dKKKKKKKK#(5)=d#K#K#KKKKKK#eUGD999L999999r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Captionz!Text describing a figure or imageTr   r;   r0   r   r9   
figcaptionr<   r=   Nr   r*   r+   r,   r   r      sx         u@NNNKNNNN#(5)=d#K#K#KKKKKK#e\N4@@@L@@@@@@r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )
PageNumberzThe number of a pageTr   r;   r0   r   r9   spanr<   r=   Nr   r*   r+   r,   r   r      sx         u3DAAAKAAAA#(5)=d#K#K#KKKKKK#eVHT:::L::::::r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )UncategorizedTextzMiscellaneous textTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r     sx         u1$???K????#(5)=d#K#K#KKKKKK#eVHT:::L::::::r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )OrderedListzA list with a specific sequenceTr   r;   r0   r   r9   olr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r   	  sx         u>tLLLKLLLL#(5)=d#K#K#KKKKKK#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )UnorderedListz"A list without a specific sequenceTr   r;   r0   r   r9   ulr<   r=   Nr   r*   r+   r,   r   r     sx         uA$OOOKOOOO#(5)=d#K#K#KKKKKK#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )DefinitionList%A list of terms and their definitionsTr   r;   r0   r   r9   dlr<   r=   Nr   r*   r+   r,   r   r     r   r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )ListItemzAn item in a listTr   r;   r0   r   r9   lir<   r=   Nr   r*   r+   r,   r   r     sx         u0>>>K>>>>#(5)=d#K#K#KKKKKK#eTF4888L888888r+   r   c                       e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dd fdZ
 xZS )r   zA structured set of dataTr   r;   r0   r   r9   r   r<   r=   rG   c                    t          t                                          |          d          }t          |          }t	          |          S Nrf   r   rA   r]   r   r;   rE   rV   r   rC   s      r,   r]   zTable.to_html&  ;    UWW__\::MJJ.t444yyr+   r   r   r   r   r   r   r0   r   r   r   r9   r=   r]   r   r   s   @r,   r   r   !  s         u7EEEKEEEE#(5)>t#L#L#LKLLLL#eWId;;;L;;;;          r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	TableBodyzA body of the tableTr   r;   r0   r   r9   tbodyr<   r=   N
r   r   r   r   r0   r   r   r   r9   r=   r*   r+   r,   r   r   ,  sx         u24@@@K@@@@#(5)>t#L#L#LKLLLL#eWId;;;L;;;;;;r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )TableHeaderzA header of the tableTr   r;   r0   r   r9   theadr<   r=   Nr   r*   r+   r,   r   r   2  sx         u4TBBBKBBBB#(5)>t#L#L#LKLLLL#eWId;;;L;;;;;;r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )TableRowzA row in a tableTr   r;   r0   r   r9   trr<   r=   Nr   r*   r+   r,   r   r   8  sx         u/===K====#(5)>t#L#L#LKLLLL#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	TableCellzA cell in a tableTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r   >  sx         u0>>>K>>>>#(5)>t#L#L#LKLLLL#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )TableCellHeaderzA header cell in a tableTr   r;   r0   r   r9   r   r<   r=   Nr   r*   r+   r,   r   r   E  sx         u7EEEKEEEE#(5)>t#L#L#LKLLLL#eTF4888L888888r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )ImagezA visual representationTr   r;   r0   r   r9   rg   r<   r=   N
r   r   r   r   r0   r   r   r    r9   r=   r*   r+   r,   r   r   K  sx         u6tDDDKDDDD#(5)>t#L#L#LKLLLL#eUGD999L999999r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Figurez(An illustration or diagram in a documentTr   r;   r0   r   r9   figurer<   r=   Nr   r*   r+   r,   r   r   Q  sy         uGPTUUUKUUUU#(5)>t#L#L#LKLLLL#eXJt<<<L<<<<<<r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )VideozA moving visual media elementTr   r;   r0   r   r9   videor<   r=   Nr   r*   r+   r,   r   r   W  sx         u<TJJJKJJJJ#(5)>t#L#L#LKLLLL#eWId;;;L;;;;;;r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )AudiozA sound or music elementTr   r;   r0   r   r9   audior<   r=   Nr   r*   r+   r,   r   r   ]  sx         u7EEEKEEEE#(5)>t#L#L#LKLLLL#eWId;;;L;;;;;;r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Barcodez)A machine-readable representation of dataTr   r;   r0   r   r9   rg   r<   r=   Nr   r*   r+   r,   r   r   c  sy         uHQUVVVKVVVV#(5)>t#L#L#LKLLLL#eUGD999L999999r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )QRCodezA two-dimensional barcodeTr   r;   r0   r   r9   rg   r<   r=   Nr   r*   r+   r,   r  r  i  sx         u8FFFKFFFF#(5)>t#L#L#LKLLLL#eUGD999L999999r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Logoz0A graphical representation of a company or brandTr   r;   r0   r   r9   rg   r<   r=   Nr   r*   r+   r,   r  r  o  sy         uOX\]]]K]]]]#(5)>t#L#L#LKLLLL#eUGD999L999999r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edd	gd          Z	d
ed<   dS )	CodeBlockzA block of programming codeTr   r;   r0   r   r9   prer!   r<   r=   N
r   r   r   r   r0   r   r   r!   r9   r=   r*   r+   r,   r  r  u  sz         u:4HHHKHHHH#(5)=d#K#K#KKKKKK#eUFODAAALAAAAAAr+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )
InlineCodezCode within a line of textTr   r;   r0   r   r9   r!   r<   r=   Nr  r*   r+   r,   r	  r	  {  sx         u9$GGGKGGGG#(5)=d#K#K#KKKKKK#eVHT:::L::::::r+   r	  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )FormulazA mathematical formulaTr   r;   r0   r   r9   mathr<   r=   N
r   r   r   r   r0   r   r   r"   r9   r=   r*   r+   r,   r  r    sx         u5dCCCKCCCC#(5)Ed#S#S#SKSSSS#eVHT:::L::::::r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )EquationzA mathematical equationTr   r;   r0   r   r9   r  r<   r=   Nr  r*   r+   r,   r  r    sx         u6tDDDKDDDD#(5)Ed#S#S#SKSSSS#eVHT:::L::::::r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )FootnoteReferencez9A subscripted reference to a note at the bottom of a pageTr   r;   r0   r   r9   subr<   r=   N
r   r   r   r   r0   r   r   r#   r9   r=   r*   r+   r,   r  r    s         uCD  K     $)5)B4#P#P#PKPPPP#eUGD999L999999r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )CitationzA reference to a sourceTr   r;   r0   r   r9   citer<   r=   Nr  r*   r+   r,   r  r    sx         u6tDDDKDDDD#(5)B4#P#P#PKPPPP#eVHT:::L::::::r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )BibliographyzA list of sourcesTr   r;   r0   r   r9   r   r<   r=   Nr  r*   r+   r,   r  r    sx         u0>>>K>>>>#(5)B4#P#P#PKPPPP#eTF4888L888888r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Glossaryr   Tr   r;   r0   r   r9   r   r<   r=   Nr  r*   r+   r,   r  r    sx         uDTRRRKRRRR#(5)B4#P#P#PKPPPP#eTF4888L888888r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )AuthorzThe creator of the documentTr   r;   r0   r   r9   metar<   r=   N
r   r   r   r   r0   r   r   r$   r9   r=   r*   r+   r,   r  r    sx         u:4HHHKHHHH#(5)A$#O#O#OKOOOO#eVHT:::L::::::r+   r  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )MetaDatez%The date associated with the documentTr   r;   r0   r   r9   r  r<   r=   Nr  r*   r+   r,   r   r     sx         uDTRRRKRRRR#(5)A$#O#O#OKOOOO#eVHT:::L::::::r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Keywordsz&Key terms associated with the documentTr   r;   r0   r   r9   r  r<   r=   Nr  r*   r+   r,   r"  r"    sx         uEdSSSKSSSS#(5)A$#O#O#OKOOOO#eVHT:::L::::::r+   r"  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )AbstractzA summary of the documentTr   r;   r0   r   r9   r   r<   r=   Nr  r*   r+   r,   r$  r$    sx         u8FFFKFFFF#(5)A$#O#O#OKOOOO#eYK===L======r+   r$  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	Hyperlinkz1A reference to data that can be directly followedTr   r;   r0   r   r9   ar<   r=   N
r   r   r   r   r0   r   r   r%   r9   r=   r*   r+   r,   r&  r&    sy         uPY]^^^K^^^^#(5)CD#Q#Q#QKQQQQ#eSE$777L777777r+   r&  c                       e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dd fdZ
 xZS )TableOfContentszA list of the document's contents. Total table columns will be equal to the degree of hierarchy (n) plus 1 for the target value. Header Row: L1,L2,...Ln,ValueTr   r;   r0   r   r9   r   r<   r=   rG   c                    t          t                                          |          d          }t          |          }t	          |          S r   r   r   s      r,   r]   zTableOfContents.to_html  r   r+   r   r   r   r   s   @r,   r*  r*    s         u	( 	  K     $)5)>t#L#L#LKLLLL#eWId;;;L;;;;          r+   r*  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Indexz4An alphabetical list of terms and their page numbersTr   r;   r0   r   r9   navr<   r=   Nr(  r*   r+   r,   r-  r-    sy         uS\`aaaKaaaa#(5)CD#Q#Q#QKQQQQ#eUGD999L999999r+   r-  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )r   z,A document section with interactive controlsTr   r;   r0   r   r9   r&   r<   r=   N
r   r   r   r   r0   r   r   r&   r9   r=   r*   r+   r,   r   r     sy         uKTXYYYKYYYY#(5)=d#K#K#KKKKKK#eVHT:::L::::::r+   r   c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	FormFieldzA property value of a formTr   r;   r0   r   r9   labelr<   r=   Nr0  r*   r+   r,   r2  r2    sx         u9$GGGKGGGG#(5)=d#K#K#KKKKKK#eWId;;;L;;;;;;r+   r2  c                       e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dd fdZ
 xZS )FormFieldValuezA field for user inputTr   r;   r0   r   r9   inputr<   r=   rG   c                    t                                          ||          }| j                            dd          }|s|S | d|                                 S )Nrr   r/   rP   )rA   ra   r>   rk   rS   )rE   rV   rd   r   rr   rC   s        r,   ra   zFormFieldValue.to_text  s`    ww|-=>>*..w;; 	K    &&(((r+   r   r   )r   r   r   r   r0   r   r   r&   r9   r=   ra   r   r   s   @r,   r5  r5    s         u5dCCCKCCCC#(5)=d#K#K#KKKKKK#eWId;;;L;;;;) ) ) ) ) ) ) ) ) ) )r+   r5  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )Checkboxz,A small box that can be checked or uncheckedTr   r;   r0   r   r9   r6  r<   r=   Nr0  r*   r+   r,   r9  r9    sy         uKTXYYYKYYYY#(5)=d#K#K#KKKKKK#eWId;;;L;;;;;;r+   r9  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )RadioButtonz&A circular button that can be selectedTr   r;   r0   r   r9   r6  r<   r=   Nr0  r*   r+   r,   r;  r;    sx         uEdSSSKSSSS#(5)=d#K#K#KKKKKK#eWId;;;L;;;;;;r+   r;  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )ButtonzAn interactive button elementTr   r;   r0   r   r9   buttonr<   r=   Nr0  r*   r+   r,   r=  r=     sx         u<TJJJKJJJJ#(5)=d#K#K#KKKKKK#eXJt<<<L<<<<<<r+   r=  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )CommentzA note or remarkTr   r;   r0   r   r9   r   r<   r=   N
r   r   r   r   r0   r   r   r'   r9   r=   r*   r+   r,   r@  r@    sx         u/===K====#(5)CD#Q#Q#QKQQQQ#eVHT:::L::::::r+   r@  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	HighlightzEmphasized text or sectionTr   r;   r0   r   r9   markr<   r=   NrA  r*   r+   r,   rC  rC    sx         u9$GGGKGGGG#(5)CD#Q#Q#QKQQQQ#eVHT:::L::::::r+   rC  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )RevisionInsertionA changed or edited elementTr   r;   r0   r   r9   insr<   r=   NrA  r*   r+   r,   rF  rF    x         u:4HHHKHHHH#(5)CD#Q#Q#QKQQQQ#eUGD999L999999r+   rF  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )RevisionDeletionrG  Tr   r;   r0   r   r9   delr<   r=   NrA  r*   r+   r,   rK  rK    rI  r+   rK  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )AddresszA physical locationTr   r;   r0   r   r9   addressr<   r=   N
r   r   r   r   r0   r   r   r(   r9   r=   r*   r+   r,   rN  rN    sy         u24@@@K@@@@#(5)IRV#W#W#WKWWWW#eYK===L======r+   rN  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )EmailAddresszAn email addressTr   r;   r0   r   r9   r'  r<   r=   NrP  r*   r+   r,   rR  rR  $  sy         u/===K====#(5)IRV#W#W#WKWWWW#eSE$777L777777r+   rR  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )PhoneNumberzA telephone numberTr   r;   r0   r   r9   r   r<   r=   NrP  r*   r+   r,   rT  rT  *  sy         u1$???K????#(5)IRV#W#W#WKWWWW#eVHT:::L::::::r+   rT  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )CalendarDatezA calendar dateTr   r;   r0   r   r9   timer<   r=   NrP  r*   r+   r,   rV  rV  0  y         u.t<<<K<<<<#(5)IRV#W#W#WKWWWW#eVHT:::L::::::r+   rV  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )TimezA specific timeTr   r;   r0   r   r9   rW  r<   r=   NrP  r*   r+   r,   rZ  rZ  6  rX  r+   rZ  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )CurrencyzA monetary valueTr   r;   r0   r   r9   r   r<   r=   NrP  r*   r+   r,   r\  r\  <  sy         u/===K====#(5)IRV#W#W#WKWWWW#eVHT:::L::::::r+   r\  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )MeasurementzA quantitative value with unitsTr   r;   r0   r   r9   r   r<   r=   NrP  r*   r+   r,   r^  r^  B  sy         u>tLLLKLLLL#(5)IRV#W#W#WKWWWW#eVHT:::L::::::r+   r^  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )
Letterheadz"The heading at the top of a letterTr   r;   r0   r   r9   r   r<   r=   N
r   r   r   r   r0   r   r   r)   r9   r=   r*   r+   r,   r`  r`  H  sy         uA$OOOKOOOO#(5)JSW#X#X#XKXXXX#eXJt<<<L<<<<<<r+   r`  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edd	gd          Z	d
ed<   dS )	Signaturez,A person's name written in a distinctive wayTr   r;   r0   r   r9   rg   svgr<   r=   Nra  r*   r+   r,   rc  rc  N  s|         uKTXYYYKYYYY#(5)JSW#X#X#XKXXXX#eUEN4@@@L@@@@@@r+   rc  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edgd          Z	d	ed
<   dS )	Watermarkz/A faint design made in paper during manufactureTr   r;   r0   r   r9   r   r<   r=   Nra  r*   r+   r,   rf  rf  T  sz         uNW[\\\K\\\\#(5)JSW#X#X#XKXXXX#eUGD999L999999r+   rf  c                      e Zd ZU  edd          Zded<    eej        d          Zded<    edd	gd          Z	d
ed<   dS )StampzAn official mark or sealTr   r;   r0   r   r9   rg   rd  r<   r=   Nra  r*   r+   r,   rh  rh  Z  s{         u7EEEKEEEE#(5)JSW#X#X#XKXXXX#eUEN4@@@L@@@@@@r+   rh  )r   r	   )[__doc__
__future__r   rJ   r   enumr   typingr   r   bs4r   r	   pydanticr
   r   r;   r   r.   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r	  r  r  r  r  r  r  r  r   r"  r$  r&  r*  r-  r   r2  r5  r9  r;  r=  r@  rC  rF  rK  rN  rR  rT  rV  rZ  r\  r^  r`  rc  rf  rh  r*   r+   r,   <module>ro     s    # " " " " "              ! ! ! ! ! ! ! ! " " " " " " " " % % % % % % % %, , , , ,c4 , , ,"c c c c ci c c cL   ; ; ; ; ; ; ; ;> > > > >o > > >: : : : :? : : :: : : : :_ : : :8 8 8 8 8 8 8 8= = = = =_ = = == = = = =_ = = =< < < < <o < < <9 9 9 9 9 9 9 99 9 9 9 9O 9 9 99 9 9 9 9 9 9 9W W W W Wo W W W8 8 8 8 8O 8 8 8A A A A AO A A A: : : : : : : :A A A A Ao A A A; ; ; ; ; ; ; ;; ; ; ; ; ; ; ;9 9 9 9 9/ 9 9 99 9 9 9 9O 9 9 99 9 9 9 9_ 9 9 99 9 9 9 9 9 9 9    O   < < < < < < < << < < < </ < < <9 9 9 9 9 9 9 99 9 9 9 9 9 9 99 9 9 9 9o 9 9 9: : : : :O : : := = = = =_ = = =< < < < <O < < << < < < <O < < <: : : : :o : : :: : : : :_ : : :: : : : :? : : :B B B B B B B B; ; ; ; ; ; ; ;; ; ; ; ;o ; ; ;; ; ; ; ; ; ; ;: : : : : : : :; ; ; ; ; ; ; ;9 9 9 9 9? 9 9 99 9 9 9 9 9 9 9; ; ; ; ;_ ; ; ;; ; ; ; ; ; ; ;; ; ; ; ; ; ; ;> > > > > > > >8 8 8 8 8 8 8 8    o    : : : : :O : : :; ; ; ; ;? ; ; ;< < < < < < < <
) 
) 
) 
) 
)_ 
) 
) 
)< < < < < < < << < < < </ < < <= = = = =_ = = =; ; ; ; ;o ; ; ;; ; ; ; ; ; ; ;: : : : : : : :: : : : : : : :> > > > >o > > >8 8 8 8 8? 8 8 8; ; ; ; ;/ ; ; ;; ; ; ; ;? ; ; ;; ; ; ; ;? ; ; ;; ; ; ; ; ; ; ;; ; ; ; ;/ ; ; ;= = = = = = = =A A A A A A A A: : : : : : : :A A A A AO A A A A Ar+   