Ë
    Ã?ÆiÝ  ã                  ó~   — d Z ddlmZ ddlZddl­ ddlmZ  ej                  d«      Zdd„Z	dd„Z
dd	„Zdd
„Zdd„Zy)u½  CNPJ (Cadastro Nacional da Pessoa JurÃ­dica, Brazilian company identifier).

Numbers from the national register of legal entities have 14 alphanumeric digits.
The first 8 digits identify the company, the following 4 digits identify a
business unit and the last 2 digits are check digits.

>>> validate('16.727.230/0001-97')
'16727230000197'
>>> validate('12. ABC.345 /01DEâ€“35')  # new format from July 2026 onwards
'12ABC34501DE35'
>>> validate('16.727.230.0001-98')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('16.727.230/0001=97')  # invalid delimiter
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> format('16727230000197')
'16.727.230/0001-97'
é    )ÚannotationsN)Ú*)Úcleanz
^[\dA-Z]+$c                óR   — t        | d«      j                  «       j                  «       S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.z -./)r   ÚstripÚupper©Únumbers    úU/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/br/cnpj.pyÚcompactr   7   s#   € ô �˜Ó ×&Ñ&Ó(×.Ñ.Ó0Ð0ó    c                ó0  — t        | «      } | dd D �cg c]  }t        |«      dz
  ‘Œ }}g d¢}dt        d„ t        ||«      D «       «      z
  dz  dz  }|j	                  |«       g d¢}dt        d	„ t        ||«      D «       «      z
  dz  dz  }|› |› �S c c}w )
z*Calculate the check digits for the number.Né   é0   )é   é   é   é   é	   é   é   é   r   r   r   r   é   c              3  ó,   K  — | ]  \  }}||z  –— Œ y ­w©N© ©Ú.0ÚwÚvs      r   ú	<genexpr>z$calc_check_digits.<locals>.<genexpr>B   ó   è ø€ Ò:™T˜Q �1�q•5Ñ:ùó   ‚é
   )r   r   r   r   r   r   r   r   r   r   r   r   r   c              3  ó,   K  — | ]  \  }}||z  –— Œ y ­wr   r   r   s      r   r!   z$calc_check_digits.<locals>.<genexpr>E   r"   r#   )r   ÚordÚsumÚzipÚappend)r
   ÚnÚvaluesÚweightsÚd1Úd2s         r   Úcalc_check_digitsr/   =   s¡   € ä�V‹_€FØ#)¨#¨2 ;Ö/˜aŒc�!‹f�r‹kÐ/€FÐ/Ú2€GØ
ŒsÑ:¤S¨°&Ó%9Ô:Ó:Ñ
:¸bÑ	@À2Ñ	E€BØ
‡M�M�"ÔÚ5€GØ
ŒsÑ:¤S¨°&Ó%9Ô:Ó:Ñ
:¸bÑ	@À2Ñ	E€BØˆT�"�ˆ;Ðùò 0s   “Bc                óâ   — t        | «      } t        j                  | «      r| j                  d«      r
t	        «       ‚t        | «      dk7  r
t        «       ‚t        | «      | dd k7  r
t        «       ‚| S )ziCheck if the number is a valid CNPJ. This checks the length and
    whether the check digits are correct.Ú000000000000é   éþÿÿÿN)	r   Ú_cnpj_reÚmatchÚ
startswithÚInvalidFormatÚlenÚInvalidLengthr/   ÚInvalidChecksumr	   s    r   Úvalidater;   I   sc   € ô �V‹_€FÜ�>‰>˜&Ô! V×%6Ñ%6°~Ô%FÜ‹oÐÜ
ˆ6ƒ{�bÒÜ‹oÐÜ˜Ó  F¨2¨3 KÒ/ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z$Check if the number is a valid CNPJ.F)Úboolr;   ÚValidationErrorr	   s    r   Úis_validr?   V   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ój   — t        | «      } | dd dz   | dd z   dz   | dd z   dz   | dd z   dz   | dd	 z   S )
z8Reformat the number to the standard presentation format.r   r   ú.r   r   ú/r   ú-N)r   r	   s    r   ÚformatrD   ^   sb   € ä�V‹_€FØ�1�QˆK˜#Ñ  q¨ Ñ+¨cÑ1°F¸1¸Q°KÑ?À#ÑEØ�1�RˆLñØñØ!'¨¨ ñ-ð .r   )r
   ÚstrÚreturnrE   )r
   rE   rF   r=   )Ú__doc__Ú
__future__r   ÚreÚstdnum.exceptionsÚstdnum.utilr   Úcompiler4   r   r/   r;   r?   rD   r   r   r   ú<module>rM      sC   ðñ*õ, #ã 	ä Ý ð ˆ2�:‰:�mÓ$€ó1ó	ó
óô.r   