Ë
    Ã?Æ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Ø  CC (NÃºmero de CartÃ£o de CidadÃ£o, Portuguese Identity number).

The Portuguese Identity Number is alphanumeric and consists of the numeric
NÃºmero de IdentificaÃ§Ã£o Civil, a two-letter version and a check digit.

More information:

* https://pt.wikipedia.org/wiki/CartÃ£o_de_cidadÃ£o
* https://www.autenticacao.gov.pt/documents/20126/115760/ValidaÃ§Ã£o+de+NÃºmero+de+Documento+do+CartÃ£o+de+CidadÃ£o.pdf

>>> validate('00000000 0 ZZ4')
'000000000ZZ4'
>>> validate('00000000 A ZZ4')  # invalid format
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('00000000 0 ZZ3')  # invalid check digits
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('000000000ZZ4')
'00000000 0 ZZ4'
é    )ÚannotationsN)Ú*)Úcleanz^\d*[A-Z0-9]{2}\d$c                óV   — 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.ú )r   ÚupperÚstrip©Únumbers    úS/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/pt/cc.pyÚcompactr   8   s'   € ô �6˜3Ó×%Ñ%Ó'×-Ñ-Ó/€FØ€Mó    c           	     ó|   ‡‡— dd„ŠdŠt        ˆˆfd„t        | ddd…   «      D «       «      }t        d|z
  dz  «      S )z)Calculate the check digit for the number.c                ó   — | dkD  r| dz
  S | S )Né	   © )Úxs    r   Úcutoffz calc_check_digit.<locals>.cutoffA   s   € Ø˜Ašˆq�1‰uÐ$ 1Ð$r   Ú$0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZc              3  óŠ   •K  — | ]:  \  }}|d z  dk(  r ‰‰j                  |«      d z  «      n‰j                  |«      –— Œ< y­w)é   r   N)Úindex)Ú.0ÚiÚnÚalphabetr   s      €€r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>D   sH   øè ø€ ò -áˆAˆqð *+¨Q©°!ª‰ˆx�~‰~˜aÓ  1Ñ$Ô%¸¿¹ÈÓ9JÓJñ-ùs   ƒA ANéÿÿÿÿé
   )r   ÚintÚreturnr    )ÚsumÚ	enumerateÚstr)r   Úsr   r   s     @@r   Úcalc_check_digitr&   ?   sF   ù€ ó%à5€HÜô -ä˜f¡T r T™lÓ+ô-ó 	-€Aô ��Q‘˜"‰}ÓÐr   c                ó–   — t        | «      } t        j                  | «      s
t        «       ‚t	        | dd «      | d   k7  r
t        «       ‚| S )ú8Check if the number is a valid cartao de cidadao number.Nr   )r   Ú_cc_reÚmatchÚInvalidFormatr&   ÚInvalidChecksumr
   s    r   Úvalidater-   J   sD   € ä�V‹_€FÜ�<‰<˜ÔÜ‹oÐÜ˜˜s ˜Ó$¨¨r©
Ò2ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)r(   F)Úboolr-   ÚValidationErrorr
   s    r   Úis_validr1   T   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                óR   — t        | «      } dj                  | dd | d   | dd g«      S )z8Reformat the number to the standard presentation format.r   Néüÿÿÿéýÿÿÿ)r   Újoinr
   s    r   Úformatr6   \   s1   € ä�V‹_€FØ�8‰8�V˜C˜R�[ &¨¡*¨f°R°S¨kÐ:Ó;Ð;r   )r   r$   r!   r$   )r   r$   r!   r/   )Ú__doc__Ú
__future__r   ÚreÚstdnum.exceptionsÚstdnum.utilr   Úcompiler)   r   r&   r-   r1   r6   r   r   r   ú<module>r=      sD   ðñ*õ0 #ã 	ä Ý ð 
ˆ�‰Ð)Ó	*€óóóóô<r   