
    Uhj                       d Z ddlmZ ddlZddlZddlmZ  ej        dej                  Z	 ej        dej                  Z
ddZddZddZedk    r eej                  dk     r edd            ed           eej        d                   Ze                                r ee          n eej        d                   Zer ee            ed           ed          dS )u?   Telegram QR rasm → deviceId (t.me/Bot?start=… yoki 40 hex).    )annotationsN)Pathz\b([a-f0-9]{40})\bz?(?:t\.me|telegram\.me)/([A-Za-z0-9_]+)\?start=([A-Za-z0-9_\-]+)textstrreturn
str | Nonec                   | sd S t                               |                     dd                    }|rl|                    d                                          }t
                              |          }|r|                    d          n|                                S t
                              |           }|r'|                    d                                          nd S )Nz&amp;&      )START_REsearchreplacegroupstripID_RElower)r   mpayloadhids       "e:\newleap\Leap-Voice\qr_decode.pyextract_from_textr      s     tWc2233A :''!**""$$ll7## #0		!77999TA!",1771::,    databytesc                   | sd S 	 dd l }dd l}|                    | |j                  }|                    ||j                  }||                                }||                    ||j                  fD ]2}|	                    |          \  }}}t          |pd          }	|	r|	c S 3|j        d d         \  }
}t          |
|          dk     rM|                    |d dd|j                  }|	                    |          \  }}}t          |pd          }	|	r|	S n# t          $ r Y nw xY w	 ddlm} dd	lm} dd l}|                    |                    |                                         d
          }dD ]}|dk    r|n@|                    t1          |j        |z            t1          |j        |z            f          } ||          D ]2}t          |j                            dd                    }	|	r|	c c S 3n# t          $ r Y nw xY w	 |                     dd          }t          |          }	|	r|	S n# t          $ r Y nw xY wd S )Nr   )dtype r   i  g      @)fxfyinterpolation)decode)ImageRGB)      ?g       @g      @r%   zutf-8ignorezlatin-1)cv2numpy
frombufferuint8imdecodeIMREAD_COLORQRCodeDetectorcvtColorCOLOR_BGR2GRAYdetectAndDecoder   shapemaxresizeINTER_CUBIC	Exceptionpyzbar.pyzbarr"   PILr#   ioopenBytesIOconvertintwidthheightr   )r   r'   nparrimgdetframeval_gothwbigzbar_decoder#   r8   imscalecurobj
ascii_blobs                        r   decode_bytesrP      s     t


mmDm11ll3 011 	$$&&Cs||C1CDDE  //66	Q'	r22 JJJ 9RaR=DAq1ayy3 jjdss#/jZZ//44	Q'	r22 J   777777			ZZ

4(())11%88$ 	 	E """))RX%&&BI,=(>(>?+ +C #{3''  '(J(JKK JJJJJ		    [[H55

++ 	J	   4sD   B#D *A3D 
D,+D,0CH H 
HH(I 
IIpath
str | Pathc                ^    t          t          |                                                     S )N)rP   r   
read_bytes)rQ   s    r   decode_filerU   U   s"    T

--//000r   __main__r   r   )endr   )r   r   r   r   )r   r   r   r   )rQ   rR   r   r   )__doc__
__future__r   resyspathlibr   compileIr   r   r   rP   rU   __name__lenargvprint
SystemExitpis_fileout r   r   <module>rh      sx   E E " " " " " " 				 



      
("$//2:FD 	- 	- 	- 	-6 6 6 6r1 1 1 1 z 	
s38}}q bbjmmSXa[AIIKK
K++a...->->sx{-K-KC
 c


jmm
*Q--	 	r   