§
    �Øjî  ã                   ó¶   — d dl Z ddlmZ  e j        ¦   «         Ze€ e j        d¦  «          ed¦  «        Ze j        j	        Z
e j        j        Zdefd„Zdd„ZdS )é    Né   )Ú
get_pixmapzGWarning: Tesseract OCR is not available. No OCR text will be extracted.iýÿ  Úreturnc                 óJ   — | d         t           z  s| d         t          z  rdS dS )NÚ
char_flagsFT)ÚSTROKED_TEXTÚFILLED_TEXT)Úspans    ú’/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/pymupdf4llm/ocr/tesseract_api.pyÚocr_textr      s/   € Øˆ\Ô�\Ñ)ð ¨t°LÔ/AÅKÑ/Oð ØˆuØˆ4ó    é–   ÚengFc                 óz  — t           €dS |                      ¦   «         }|                     t          j        ¬¦  «        }t          j        |¦  «        }|                     ¦   «         d         }g }	g }
g }|D ]‰}|d         D ]~}|d         D ]s}t          |¦  «        r|                     |d         ¦  «         Œ-t          |d         v r|
                     |d         ¦  «         ŒX|	                     |d         ¦  «         ŒtŒŒŠ|r|rdS t          |||	d¬	¦  «        \  }}|rdS t          j        d
|                     |¬¦  «        ¦  «        }|d         }|                     |j        ¦  «         |                     t          j        t          j        t          j        ¬¦  «         |                      | j        |d¦  «         dS )a2  This callback function performs OCR on the given page.

    It uses RapidOCR for text region detection and Tesseract OCR for text
    recognition in each identified region (boundary box).

    If a Pixmap is provided, the DPI parameter is ignored. Otherwise, an RGB
    Pixmap is created from the page at the specified DPI.
    The DPI parameter is also used if extractable text is present.

    We ensure that legible extractable text is excluded from OCR. If present
    on page we make a temporary copy without such text and perform OCR
    on that copy.
    N)ÚflagsÚblocksÚlinesÚspansÚbboxÚtextéú   )ÚdpiÚrectsÚempty_thresholdÚpdf)Úlanguager   )ÚimagesÚgraphicsr   )ÚTESSDATAÚget_displaylistÚget_textpageÚpymupdfÚTEXT_ACCURATE_BBOXESÚTextPageÚextractDICTr   ÚappendÚREPLACEMENT_UNICODEr   ÚopenÚpdfocr_tobytesÚadd_redact_annotÚrectÚapply_redactionsÚPDF_REDACT_IMAGE_REMOVEÚ%PDF_REDACT_LINE_ART_REMOVE_IF_TOUCHEDÚPDF_REDACT_TEXT_NONEÚshow_pdf_page)Úpager   Úpixmapr   Úkeep_ocr_textÚdisplaylistÚ	stextpageÚtextpageÚtext_blocksr   Ú
fffd_spansÚ	ocr_spansÚbÚlÚsÚemptyÚtemp_pdfÚ	temp_pages                     r   Úexec_ocrr@      sï  € õ ÐØˆØ×&Ò&Ñ(Ô(€KØ×(Ò(­wÔ/KÐ(ÑLÔL€IÝÔ 	Ñ*Ô*€HØ×&Ò&Ñ(Ô(¨Ô2€Kð €EØ€JØ€Iàð ,ð ,ˆØ�7”ð 	,ð 	,ˆAØ�w”Zð ,ð ,�Ý˜A‘;”;ð ,Ø×$Ò$ Q v¤YÑ/Ô/Ð/Ð/Ý(¨A¨f¬IÐ5Ð5Ø×%Ò% a¨¤iÑ0Ô0Ð0Ð0à—L’L  6¤Ñ+Ô+Ð+Ð+ð,ð	,ð ð �]ð ð 	ˆå˜{°¸5ÐRUÐVÑVÔV�M€FˆEØð Øˆõ Œ|˜E 6×#8Ò#8À(Ð#8Ñ#KÔ#KÑLÔL€HØ˜”€IØ×Ò˜yœ~Ñ.Ô.Ð.à×ÒÝÔ.ÝÔ>ÝÔ)ð ñ ô ð ð 	×Ò�t”y (¨AÑ.Ô.Ð.Ð.Ð.r   )r   Nr   F)r"   Úget_culled_pixmapr   Úget_tessdatar   ÚmessageÚchrr'   ÚmupdfÚFZ_STEXT_STROKEDr   ÚFZ_STEXT_FILLEDr	   Úboolr   r@   © r   r   ú<module>rJ      s¬   ðØ €€€à )Ð )Ð )Ð )Ð )Ð )àˆ7ÔÑ!Ô!€ØÐØ€G„OØQñô ð ð �c˜&‘k”kÐ ØŒ}Ô-€ØŒmÔ+€ð�dð ð ð ð ð8/ð 8/ð 8/ð 8/ð 8/ð 8/r   