Ë
    ¨Œjù4  ã                  óØ   — 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 d dl
mZ d dl
mZ d dl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mZ erd d
lZd dlm Z  d dl!m"Z"  G d„ d«      Z#y
)é    )Úannotations)Úcached_property)ÚTYPE_CHECKINGÚcast)Úformat_iso8824_dateÚparse_iso8824_date)ÚCatalogAttributes)Ú"FileSpecificationDictionaryEntries)ÚPageAttributes)ÚPdfReadErrorÚ
PyPdfError)
ÚArrayObjectÚByteStringObjectÚDecodedStreamObjectÚDictionaryObjectÚ
NameObjectÚ
NullObjectÚNumberObjectÚStreamObjectÚTextStringObjectÚis_null_or_noneN)Ú	Generator)Ú	PdfWriterc                  ó   — e Zd ZdZdd d„Zed!d„«       Zed"d„«       Zed#d„«       Z	e	j                  d$d„«       Z	ed#d„«       Zej                  d$d	„«       Zed!d
„«       Zej                  d%d„«       Zed&d„«       Zed'd„«       Zed'd„«       Zed#d„«       Zej                  d(d„«       Zed)d„«       Zej                  d*d„«       Zed+d„«       Zej                  d,d„«       Zed-d„«       Zej                  d.d„«       Zed-d„«       Zej                  d.d„«       Zed/d„«       Zej                  d0d„«       Zd1d„Zd!d„Zed2d„«       Zed3d„«       Zy)4ÚEmbeddedFilezØ
    Container holding the information on an embedded file.

    Attributes are evaluated lazily if possible.

    Further information on embedded files can be found in section 7.11 of the PDF 2.0 specification.
    Nc                ó.   — || _         || _        || _        y)zÖ
        Args:
            name: The (primary) name as provided in the name tree.
            pdf_object: The corresponding PDF object to allow retrieving further data.
            parent: The parent list.
        N)Ú_nameÚ
pdf_objectÚ_parent)ÚselfÚnamer   Úparents       ú^/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/pypdf/generic/_files.pyÚ__init__zEmbeddedFile.__init__'   s   € ð ˆŒ
Ø$ˆŒØˆ�ó    c                ó   — | j                   S )zEThe (primary) name of the embedded file as provided in the name tree.)r   ©r    s    r#   r!   zEmbeddedFile.name2   s   € ð �z‰zÐr%   c           	     ó”  — t        |t        «      r|j                  d«      }t        «       }|j	                  |«       |j                  t        t        j                  «      t        d«      i«       t        «       }|j                  t        d«      |j                  |«      i«       ddlm} t        «       }|j                  t        t        j                  «      t        d«      t        t        j                  «       ||«      t        t        j                  «      |i«       t         j"                  |j$                  vr=|j                  t        «       «      |j$                  t        t         j"                  «      <   t'        t        |j$                  t         j"                     «      }d|vrJt        t        t         j"                  «      t)        «       i«      }	|j                  |	«      |t        d«      <   nt'        t        |d   «      }	t'        t(        |	t         j"                     «      }
|
j+                   ||«      |g«        | |||
¬«      S )	aO  
        Create a new embedded file and add it to the PdfWriter.

        Args:
            writer: The PdfWriter instance to add the embedded file to.
            name: The filename to display.
            content: The data in the file.

        Returns:
            EmbeddedFile instance for the newly created embedded file.
        úlatin-1z/EmbeddedFilez/Fr   )Úcreate_string_objectz	/Filespecú/EmbeddedFiles©r!   r   r"   )Ú
isinstanceÚstrÚencoder   Úset_dataÚupdater   ÚPGÚTYPEr   Ú_add_objectÚpypdf.genericr*   r
   ÚFÚEFÚCAÚNAMESÚ_root_objectr   r   Úextend)ÚclsÚwriterr!   ÚcontentÚ
file_entryÚef_entryr*   ÚfilespecÚ
names_dictÚembedded_files_names_dictionaryÚnames_arrays              r#   Ú_create_newzEmbeddedFile._create_new7   sÌ  € ô �gœsÔ#Ø—n‘n YÓ/ˆGô )Ó*ˆ
Ø×Ñ˜GÔ$Ø×Ñœ:¤b§g¡gÓ.´
¸?Ó0KÐLÔMô $Ó%ˆØ�‰œ DÓ)¨6×+=Ñ+=¸jÓ+IÐJÔKõ 	7Ü#Ó%ˆØ�‰äœ2Ÿ7™7Ó#¤Z°Ó%<ÜÔ=×?Ñ?Ó@ÑBVÐW[ÓB\ÜÔ=×@Ñ@ÓAÀ8ðô	
ô �8‰8˜6×.Ñ.Ñ.Ø8>×8JÑ8JÔK[ÓK]Ó8^ˆF×Ñ¤
¬2¯8©8Ó 4Ñ5äÔ*¨F×,?Ñ,?ÄÇÁÑ,IÓJˆ
Ø :Ñ-Ü.>ÜœBŸH™HÓ%¤{£}Ð5ó/Ð+ð 8>×7IÑ7IÐJiÓ7jˆJ”zÐ"2Ó3Ò4ä.2Ô3CÀZÐP`ÑEaÓ.bÐ+ô œ;Ð(GÌÏÉÑ(QÓRˆØ×ÑÑ0°Ó6¸ÐAÔBñ ˜¨¸+ÔFÐFr%   c                óà   — t         j                  t         j                  fD ]K  }|| j                  v sŒ| j                  |   j	                  «       }t        |«      rŒ;t        t        |«      c S  y)z3Retrieve the alternative name (file specification).N)r
   ÚUFr6   r   Ú
get_objectr   r   r.   )r    ÚkeyÚvalues      r#   Úalternative_namezEmbeddedFile.alternative_namep   s`   € ô 7×9Ñ9Ô;]×;_Ñ;_Ó`ˆCð �d—o‘oÒ%ØŸ™¨Ñ,×7Ñ7Ó9�Ü& uÕ-Ü¤ UÓ+Ò+ð að r%   c                ó>  — |€–t         j                  | j                  v r.t        «       | j                  t	        t         j                  «      <   t         j
                  | j                  v r/t        «       | j                  t	        t         j
                  «      <   yyt         j                  | j                  v r&|| j                  t	        t         j                  «      <   t         j
                  | j                  v r'|| j                  t	        t         j
                  «      <   yy)z.Set the alternative name (file specification).N)r
   rG   r   r   r   r6   ©r    rJ   s     r#   rK   zEmbeddedFile.alternative_name|   sÍ   € ð ˆ=Ü1×4Ñ4¸¿¹ÑGÜU_ÓUa�—‘¤
Ô+M×+PÑ+PÓ QÑRÜ1×3Ñ3°t·±ÑFÜT^ÓT`�—‘¤
Ô+M×+OÑ+OÓ PÒQð Gô 2×4Ñ4¸¿¹ÑGØUZ�—‘¤
Ô+M×+PÑ+PÓ QÑRÜ1×3Ñ3°t·±ÑFØTY�—‘¤
Ô+M×+OÑ+OÓ PÒQð Gr%   c                óp   — | j                   j                  t        j                  «      }t	        |«      ry|S )zRetrieve the description.N)r   Úgetr
   ÚDESCr   rM   s     r#   ÚdescriptionzEmbeddedFile.descriptionŠ   s/   € ð —‘×#Ñ#Ô$F×$KÑ$KÓLˆÜ˜5Ô!ØØˆr%   c                ó²   — |€/t        «       | j                  t        t        j                  «      <   y|| j                  t        t        j                  «      <   y)zSet the description.N)r   r   r   r
   rP   rM   s     r#   rQ   zEmbeddedFile.description’   s@   € ð ˆ=ÜS]ÓS_ˆD�O‰OœJÔ'I×'NÑ'NÓOÒPàSXˆD�O‰OœJÔ'I×'NÑ'NÓOÒPr%   c                ó:   — | j                   j                  dd«      S )zJRetrieve the relationship of the referring document to this embedded file.ú/AFRelationshipz/Unspecified)r   rO   r'   s    r#   Úassociated_file_relationshipz)EmbeddedFile.associated_file_relationshipš   s   € ð �‰×"Ñ"Ð#4°nÓEÐEr%   c                ó4   — || j                   t        d«      <   y)zESet the relationship of the referring document to this embedded file.rT   N)r   r   rM   s     r#   rU   z)EmbeddedFile.associated_file_relationshipŸ   s   € ð :?ˆ�‰œ
Ð#4Ó5Ò6r%   c                ó<  — d| j                   vrt        d| j                   › �«      ‚t        t        | j                   d   «      }t        j
                  t        j                  fD ])  }||v sŒt        t        ||   j                  «       «      c S  t        d|› �«      ‚)z)Retrieve the actual embedded file stream.z/EFz/EF entry not found: z'No /(U)F key found in file dictionary: )	r   r   r   r   r
   rG   r6   r   rH   )r    ÚefrI   s      r#   Ú_embedded_filezEmbeddedFile._embedded_file¤   s‘   € ð ˜Ÿ™Ñ'ÜÐ!6°t·±Ð6GÐHÓIÐIÜÔ" D§O¡O°EÑ$:Ó;ˆÜ6×9Ñ9Ô;]×;_Ñ;_Ó`ˆCØ�bŠyÜœL¨"¨S©'×*<Ñ*<Ó*>Ó?Ò?ð aô ÐDÀRÀDÐIÓJÐJr%   c                óf   — | j                   j                  dt        «       «      j                  «       S )z&Retrieve the file-specific parameters.ú/Params)rY   rO   r   rH   r'   s    r#   Ú_paramszEmbeddedFile._params¯   s*   € ð ×"Ñ"×&Ñ& yÔ2BÓ2DÓE×PÑPÓRÐRr%   c                ót   — | j                   }d|vrt        «       |t        d«      <   t        t        |d   «      S )z3Ensure the /Params dictionary exists and return it.r[   )rY   r   r   r   )r    Úembedded_files     r#   Ú_ensure_paramszEmbeddedFile._ensure_params´   s<   € ð ×+Ñ+ˆØ˜MÑ)Ü3CÓ3EˆMœ* YÓ/Ñ0ÜÔ$ m°IÑ&>Ó?Ð?r%   c                óT   — | j                   j                  d«      }t        |«      ry|S )zERetrieve the subtype. This is a MIME media type, prefixed by a slash.ú/SubtypeN)rY   rO   r   rM   s     r#   ÚsubtypezEmbeddedFile.subtype¼   s*   € ð ×#Ñ#×'Ñ'¨
Ó3ˆÜ˜5Ô!ØØˆr%   c                ój   — | j                   }|€t        «       |t        d«      <   y||t        d«      <   y)zGSet the subtype. This should be a MIME media type, prefixed by a slash.Nra   )rY   r   r   )r    rJ   r^   s      r#   rb   zEmbeddedFile.subtypeÄ   s4   € ð ×+Ñ+ˆØˆ=Ü4>³LˆMœ* ZÓ0Ò1à49ˆMœ* ZÓ0Ò1r%   c                ó6   — | j                   j                  «       S )z!Retrieve the actual file content.)rY   Úget_datar'   s    r#   r>   zEmbeddedFile.contentÍ   s   € ð ×"Ñ"×+Ñ+Ó-Ð-r%   c                ó|   — t        |t        «      r|j                  d«      }| j                  j	                  |«       y)zSet the file content.r)   N)r-   r.   r/   rY   r0   rM   s     r#   r>   zEmbeddedFile.contentÒ   s0   € ô �eœSÔ!Ø—L‘L Ó+ˆEØ×Ñ×$Ñ$ UÕ+r%   c                óT   — | j                   j                  d«      }t        |«      ry|S )z4Retrieve the size of the uncompressed file in bytes.ú/SizeN©r\   rO   r   rM   s     r#   ÚsizezEmbeddedFile.sizeÙ   s(   € ð —‘× Ñ  Ó)ˆÜ˜5Ô!ØØˆr%   c                ój   — | j                   }|€t        «       |t        d«      <   y||t        d«      <   y)z/Set the size of the uncompressed file in bytes.Nrh   ©r_   r   r   ©r    rJ   Úparamss      r#   rj   zEmbeddedFile.sizeá   s4   € ð ×$Ñ$ˆØˆ=Ü*4«,ˆF”:˜gÓ&Ò'à*/ˆF”:˜gÓ&Ò'r%   c                óJ   — t        | j                  j                  d«      «      S )z$Retrieve the file creation datetime.ú/CreationDate©r   r\   rO   r'   s    r#   Úcreation_datezEmbeddedFile.creation_dateê   s   € ô " $§,¡,×"2Ñ"2°?Ó"CÓDÐDr%   c                ó’   — | j                   }|€t        «       |t        d«      <   yt        |«      }t	        |«      |t        d«      <   y)zSet the file creation datetime.Nrp   ©r_   r   r   r   r   ©r    rJ   rn   Údate_strs       r#   rr   zEmbeddedFile.creation_dateï   sC   € ð ×$Ñ$ˆØˆ=Ü2<³,ˆF”:˜oÓ.Ò/ä*¨5Ó1ˆHÜ2BÀ8Ó2LˆF”:˜oÓ.Ò/r%   c                óJ   — t        | j                  j                  d«      «      S )z4Retrieve the datetime of the last file modification.ú/ModDaterq   r'   s    r#   Úmodification_datezEmbeddedFile.modification_dateù   s   € ô " $§,¡,×"2Ñ"2°:Ó">Ó?Ð?r%   c                ó’   — | j                   }|€t        «       |t        d«      <   yt        |«      }t	        |«      |t        d«      <   y)z/Set the datetime of the last file modification.Nrx   rt   ru   s       r#   ry   zEmbeddedFile.modification_dateþ   sC   € ð ×$Ñ$ˆØˆ=Ü-7«\ˆF”:˜jÓ)Ò*ä*¨5Ó1ˆHÜ-=¸hÓ-GˆF”:˜jÓ)Ò*r%   c                óT   — | j                   j                  d«      }t        |«      ry|S )z5Retrieve the MD5 checksum of the (uncompressed) file.ú	/CheckSumNri   rM   s     r#   ÚchecksumzEmbeddedFile.checksum  s(   € ð —‘× Ñ  Ó-ˆÜ˜5Ô!ØØˆr%   c                ój   — | j                   }|€t        «       |t        d«      <   y||t        d«      <   y)z0Set the MD5 checksum of the (uncompressed) file.Nr|   rl   rm   s      r#   r}   zEmbeddedFile.checksum  s4   € ð ×$Ñ$ˆØˆ=Ü.8«lˆF”:˜kÓ*Ò+à.3ˆF”:˜kÓ*Ò+r%   c                óR  — | j                   st        d«      ‚| j                  | j                   vrt        d«      ‚| j                   j                  | j                  «      }| j                   j	                  |«       | j                   j	                  |dz
  «       t        «       | _        y)z"Delete the file from the document.z-Parent required to delete file from document.z File not found in parent object.é   N)r   r   r   ÚindexÚpopr   )r    r�   s     r#   ÚdeletezEmbeddedFile.delete  s{   € à�|Š|ÜÐLÓMÐMØ�?‰? $§,¡,Ñ.ÜÐ?Ó@Ð@Ø—‘×"Ñ" 4§?¡?Ó3ˆØ�‰×Ñ˜ÔØ�‰×Ñ˜ ™Ô#Ü*Ó,ˆ�r%   c                óP   — d| j                   j                  › d| j                  ›d�S )NÚ<z name=Ú>)Ú	__class__Ú__name__r!   r'   s    r#   Ú__repr__zEmbeddedFile.__repr__$  s&   € Ø�4—>‘>×*Ñ*Ð+¨6°$·)±)°¸aÐ@Ð@r%   c              #  óÀ   K  — t        |«      D ]L  \  }}t        |t        «      rŒ|j                  «       }||dz
     j                  «       }t	        |||¬«      –— ŒN y­w)zÙ
        Convert the given name tree into class instances.

        Args:
            names: The name tree to load the data from.

        Returns:
            Iterable of class instances for the files found.
        r€   r,   N)Ú	enumerater-   r.   rH   r   )r<   ÚnamesÚir!   Úfile_dictionaryÚdirect_names         r#   Ú_load_from_nameszEmbeddedFile._load_from_names'  sW   è ø€ ô ! Ö'‰GˆAˆtÜ˜d¤CÕ(à"&§/¡/Ó"3�Ø# A¨¡E™l×5Ñ5Ó7�Ü"¨ÀÐX]Ô^Ó^ñ (ùs
   ‚"A¥9Ac              #  ó¬  K  — 	 t        t        t        t        |d   «      d   «      }d|v ret        t        |d   j	                  «       «      D ]A  }|j	                  «       }d|v sŒ| j                  t        t        |d   «      «      E d{  –—†  ŒC d|v r+| j                  t        t        |d   «      «      E d{  –—†  yy# t        $ r Y yw xY w7 ŒE7 Œ­w)aI  
        Load the embedded files for the given document catalog.

        This method and its signature are considered internal API and thus not exposed publicly for now.

        Args:
            catalog: The document catalog to load from.

        Returns:
            Iterable of class instances for the files found.
        z/Namesr+   Nz/Kids)r   r   ÚKeyErrorr   rH   r�   )r<   ÚcatalogÚ	containerÚkids       r#   Ú_loadzEmbeddedFile._load:  sÙ   è ø€ ð	ÜÜ ÜÔ% w¨xÑ'8Ó9Ð:JÑKóˆIð �iÑÜœK¨°7Ñ);×)FÑ)FÓ)HÖI�ð —n‘nÓ&�Ø˜s’?Ø"×3Ñ3´D¼ÀcÈ(ÁmÓ4TÓU×UÑUð Jð �yÑ Ø×+Ñ+¬D´¸iÈÑ>QÓ,RÓS×SÑSð !øô ò 	Ùð	úð VøàSúsK   ‚C„$C ¨<CÁ%%CÂ
CÂ/CÂ:CÂ;CÃ	CÃ
CÃCÃCÃC)N)r!   r.   r   r   r"   zArrayObject | NoneÚreturnÚNone)r—   r.   )r=   r   r!   r.   r>   ústr | bytesr—   r   )r—   z
str | None)rJ   zTextStringObject | Noner—   r˜   )rJ   r   r—   r˜   )r—   r   )r—   r   )rJ   zNameObject | Noner—   r˜   )r—   Úbytes)rJ   r™   r—   r˜   )r—   z
int | None)rJ   zNumberObject | Noner—   r˜   )r—   údatetime.datetime | None)rJ   r›   r—   r˜   )r—   zbytes | None)rJ   zByteStringObject | Noner—   r˜   )r—   r˜   )rŒ   r   r—   úGenerator[EmbeddedFile])r“   r   r—   rœ   )rˆ   Ú
__module__Ú__qualname__Ú__doc__r$   Úpropertyr!   ÚclassmethodrE   rK   ÚsetterrQ   rU   rY   r\   r   r_   rb   r>   rj   rr   ry   r}   rƒ   r‰   r�   r–   © r%   r#   r   r      sT  „ ñô	ð òó ðð ò6Gó ð6Gðp ò	ó ð	ð ×ÑòZó ðZð òó ðð ×ÑòYó ðYð òFó ðFð "×(Ñ(ò?ó )ð?ð òKó ðKð òSó ðSð ò@ó ð@ð òó ðð ‡^�^ò:ó ð:ð ò.ó ð.ð ‡^�^ò,ó ð,ð òó ðð 
‡[�[ò0ó ð0ð òEó ðEð ×ÑòMó ðMð ò@ó ð@ð ×ÑòHó ðHð òó ðð ‡_�_ò4ó ð4ó	-óAð ò_ó ð_ð$ òTó ñTr%   r   )$Ú
__future__r   Ú	functoolsr   Útypingr   r   Úpypdf._utilsr   r   Úpypdf.constantsr	   r8   r
   r   r2   Úpypdf.errorsr   r   r5   r   r   r   r   r   r   r   r   r   r   ÚdatetimeÚcollections.abcr   Úpypdf._writerr   r   r£   r%   r#   Ú<module>r­      sH   ðÝ "å %ß &ç @Ý 3Ý >Ý 0ß 1÷÷ ÷ ñ ÛÝ)å'÷xTò xTr%   