
    ]Ogb              	         S r SSKJr  SSKrSSKJr  SSKJr  SSKJ	r	J
r
  \" \" \" SS5      5      \" \" SS	5      5      -   / S
Q-   / SQ-   \" \" SS5      5      -   \" \" SS5      5      -   5      rS S jrS!S"S jjrS!S#S jjr " S S\R$                  5      r " S S\\R(                  5      r " S S\\R,                  5      r " S S\R0                  5      r " S S\R4                  5      rS$S jr\R:                  " \5        SS/rg)%zImplement pdfdoc codec.    )annotationsN)	Container)Any)pdf_doc_to_utf8utf8_to_pdf_doc          ) i"   i    i!   i&   i   i   i  iD   i9   i:   i"  i0   i   i   i   i   i   i   i"!  i  i  iA  iR  i`  ix  i}  i1  iB  iS  ia  i~  i   )i  i  i  i  i  i  i  i              c                f    [        U 5       H  u  p#[        U5      U;  d  M  Us  $    [        S5      e)Nz'couldn't find the unencodable character)	enumerateord
ValueError)sordinalsnchars       R/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/pikepdf/codec.py_find_first_indexr   A   s1    Q<t9H$H   >
??    c                   US:X  a  SOSn[        X5      u  p4U(       a  U[        U 5      4$ US:X  a  UR                  SS5      nU[        U 5      4$ US:X  a  U[        U 5      4$ US:X  a]  U R                  S5      (       d  U R                  S5      (       a  [	        S	U S
SS5      e[        U [        5      n[	        S	U UUS-   S5      e[        U5      e)z0Convert input string to bytes in PdfDocEncoding.replace   ?   ignorer   strictu   þÿu   ÿþpdfdocr      zCstrings beginning with byte order marks cannot be encoded in pdfdoc   z2character cannot be represented in pdfdoc encoding)r   lenr   
startswithUnicodeEncodeErrorr   PDFDOC_ENCODABLELookupError)inputerrorserror_markersuccessr    offending_indexs         r   pdfdoc_encoder-   H   s    !Y.4GL%e:OGs5z!!-s5z!!s5z!!J''5+;+;J+G+G$U  ,E3CD a@
 	
 f
r   c                    [        U [        5      (       a  U R                  5       n [        U 5      nUS:X  a)  UR	                  S5      nUS:  a  [        SU UUS-   S5      eU[        U 5      4$ )z/Convert PdfDoc-encoded input into a Python str.r   u   �r   r    r"   z0no Unicode mapping is defined for this character)
isinstance
memoryviewtobytesr   findUnicodeDecodeErrorr#   )r(   r)   r   idxs       r   pdfdoc_decoder5   l   sq    %$$AffX!8$aB  c%j=r   c                  4    \ rS rSrSrSSS jjrSS	S jjrSrg)
PdfDocCodecr
   z8Implement PdfDocEncoding character map used inside PDFs.c                    [        X5      $ )z)Implement codecs.Codec.encode for pdfdoc.r-   selfr(   r)   s      r   encodePdfDocCodec.encode       U++r   c                    [        X5      $ )z)Implement codecs.Codec.decode for pdfdoc.)r5   r:   s      r   decodePdfDocCodec.decode   r>   r    Nr   r(   strr)   rE   returnztuple[bytes, int]r(   bytesr)   rE   rF   ztuple[str, int])__name__
__module____qualname____firstlineno____doc__r<   r@   __static_attributes__rB   r   r   r7   r7      s    B,, ,r   r7   c                      \ rS rSrSrSrg)PdfDocStreamWriter   z'Implement PdfDocEncoding stream writer.rB   N)rI   rJ   rK   rL   rM   rN   rB   r   r   rP   rP      s    1r   rP   c                  &    \ rS rSrSrSSS jjrSrg)PdfDocStreamReader   z'Implement PdfDocEncoding stream reader.c                .    [         R                  XU5      $ )z0Implement codecs.StreamReader.decode for pdfdoc.)r7   r@   r:   s      r   r@   PdfDocStreamReader.decode   s    !!$v66r   rB   NrC   rG   rI   rJ   rK   rL   rM   r@   rN   rB   r   r   rS   rS      s    17 7r   rS   c                  &    \ rS rSrSrSSS jjrSrg)PdfDocIncrementalEncoder   z-Implement PdfDocEncoding incremental encoder.c                     [        US5      S   $ )z6Implement codecs.IncrementalEncoder.encode for pdfdoc.r   r   r9   r;   r(   finals      r   r<   PdfDocIncrementalEncoder.encode   s    UH-a00r   rB   NF)r(   rE   r]   boolrF   rH   )rI   rJ   rK   rL   rM   r<   rN   rB   r   r   rY   rY      s    71 1r   rY   c                  &    \ rS rSrSrSSS jjrSrg)PdfDocIncrementalDecoder   z-Implement PdfDocEncoding incremental decoder.c                2    [        [        U5      S5      S   $ )z6Implement codecs.IncrementalDecoder.decode for pdfdoc.r   r   )r5   rH   r\   s      r   r@   PdfDocIncrementalDecoder.decode   s    U5\84Q77r   rB   Nr_   )r(   r   r]   r`   rF   rE   rW   rB   r   r   rb   rb      s    78 8r   rb   c           
         U S;   aH  [        5       n[        R                  " U UR                  UR                  [
        [        [        [        S9$ g)a|  Register pdfdoc codec with Python.

Both pdfdoc and pdfdoc_pikepdf are registered. Use "pdfdoc_pikepdf" if pikepdf's
codec is required. If another third party package installs a codec named pdfdoc,
the first imported by Python will be registered and will service all encoding.
Unfortunately, Python's codec infrastructure does not give a better mechanism
for resolving conflicts.
)r    pdfdoc_pikepdf)namer<   r@   streamwriterstreamreaderincrementalencoderincrementaldecoderN)	r7   codecs	CodecInfor<   r@   rP   rS   rY   rb   )encodingcodecs     r   find_pdfdocrq      sI     //<<<<++77
 	
 r   r   r   )r   rE   r   zContainer[int]rF   intrC   rD   rG   )ro   rE   rF   zcodecs.CodecInfo | None)rM   
__future__r   rm   collections.abcr   typingr   pikepdf._corer   r   	frozensetlistranger&   r   r-   r5   Codecr7   StreamWriterrP   StreamReaderrS   IncrementalEncoderrY   IncrementalDecoderrb   rq   register__all__rB   r   r   <module>r      s    "  %  : tX	
5x !"!#H GI$GJ 5x !K%"L 5x !M&"( V@!H&	,&,, 	,2f&9&9 27f&9&9 71v88 18v88 8.  /
0r   