ó
    UB/jð  ã                  ó„   • S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr    S
         SS	 jjrg)ag  Visual flow: identify every table by looking at the rendered page.

Renders each page and runs the grid locator on it; the located full-anatomy
boxes ARE the table count and identity for the document. No Camelot, no
detector, no recovery. Pages are processed concurrently under a small
semaphore so the per-page vision calls overlap without flooding the API.
é    )ÚannotationsN)ÚPath)ÚList)ÚGridLocator)Úrender_pages)ÚVisualTablec           	   ƒ  ó²  ^ ^^	^
#   • [         R                  " SS9 n[        R                  " [        T U[        U5      5      I Sh  v•N n[        R                  " U5      m
SUU
U 4S jjm	[        R                  " U	4S j[        USS9 5       6 I Sh  v•N nSSS5        W VVs/ s H  ow  H  oˆPM     M     snn$  Nv N+! , (       d  f       N/= fs  snnf 7f)	zFLocate tables on every page of `source` and return them in page order.zquber-dual-vision-)ÚprefixNc              “  óN  >#   • T IS h  v•N   TR                  UTU 5      I S h  v•N nS S S 5      IS h  v•N   W Vs/ s H8  n[        U UR                  UR                  UR                  UR
                  S9PM:     sn$  Nu N\ NN! , IS h  v•N  (       d  f       Nc= fs  snf 7f)N)ÚpageÚordinalÚtitleÚregionÚ	tightened)Úlocater   r   r   r   r   )r   ÚimageÚlocatedÚtÚlocatorÚ	semaphoreÚsources       €€€Ú?/home/mande/repo/quber/src/quber/core/extractors/dual/vision.pyÚlocate_pageÚ$run_vision_flow.<locals>.locate_page    s‰   øé € ß ’yØ '§¡¨u°f¸dÓ C×C�÷ !—yñ !ó	ò !�Aô ØØŸI™IØŸ'™'ØŸ8™8ØŸk™kôñ !ñ	ð 	ñ !ÙC÷ !—y—y�yüò	ùs\   ƒB%ŠB ‹B%ŽB¥B¦BªB%µB¶B%¾?B Á=B%ÂBÂB%ÂBÂBÂBÂB%c              3  ó8   >#   • U  H  u  pT" X5      v •  M     g 7f)N© )Ú.0Úir   r   s      €r   Ú	<genexpr>Ú"run_vision_flow.<locals>.<genexpr>/   s   øé € ÐTÒ4S©¨‰k˜!×#Ð#Ò4Sùs   ƒé   )Ústart)r   Úintr   r   ÚreturnúList[VisualTable])	ÚtempfileÚTemporaryDirectoryÚasyncioÚ	to_threadr   r   Ú	SemaphoreÚgatherÚ	enumerate)r   r   ÚdpiÚconcurrencyÚtmpÚpage_imagesÚper_pageÚpage_tablesÚtabler   r   s   ``       @@r   Úrun_vision_flowr4      s´   ûé € ô 
×	$Ò	$Ð,@Ò	AÀSÜ#×-Ò-¬l¸FÀCÌÈcËÓS×SˆÜ×%Ò% kÓ2ˆ	÷	ñ 	ô !ŸšÜT´I¸kÐQRÒ4SÓTð
÷ 
ˆ÷% 
Bñ* &.ÔG¢X�k»;°%ŠE¹;‰E¡XÒGÐGñ) Tñ"
÷% 
BÕ	Aüó* HùsM   †C›*C ÁB<ÁAC ÂB>ÂC ÂCÂ$CÂ8CÂ<C Â>C Ã 
CÃ
C)éÈ   é   )
r   r   r   r   r-   r#   r.   r#   r$   r%   )Ú__doc__Ú
__future__r   r(   r&   Úpathlibr   Útypingr   Úquber.agents.grid_locatorr   Ú%quber.core.extractors.camelot.acquirer   Ú!quber.core.extractors.dual.modelsr   r4   r   ó    r   Ú<module>r?      se   ðñõ #ã Û Ý Ý å 1Ý >Ý 9ð Øð	HØðHàðHð 
ðHð ð	Hð
 öHr>   