Ë
    Ã?Æi­  ã                  óX   — d Z ddlmZ ddl­ ddlmZmZ dd„Zdd„Zdd„Z	dd„Z
ddd	„Zy
)uÄ  NIR (French personal identification number).

The NIR (Numero d'Inscription au Repertoire national d'identification des
personnes physiques) is used to identify persons in France. It is popularly
known as the "social security number" and sometimes referred to as an INSEE
number. All persons born in France are registered in the Repertoire national
d'identification des personnes physiques (RNIPP) and assigned a NIR.

The number consists of 15 digits: the first digit indicates the gender,
followed by 2 digits for the year or birth, 2 for the month of birth, 5 for
the location of birth (COG), 3 for a serial and 2 check digits.

More information:

* https://www.insee.fr/en/metadonnees/definition/c1409
* https://en.wikipedia.org/wiki/INSEE_code
* https://web.archive.org/web/20160910153938/http://resoo.org/docs/_docs/regles-numero-insee.pdf
* https://fr.wikipedia.org/wiki/NumÃ©ro_de_sÃ©curitÃ©_sociale_en_France
* https://xml.insee.fr/schema/nir.html

>>> validate('2 95 10 99 126 111 93')
'295109912611193'
>>> validate('295109912611199')  # invalid check digit
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> validate('253072B07300470')
'253072B07300470'
>>> validate('253072A07300443')
'253072A07300443'
>>> validate('253072C07300443')
Traceback (most recent call last):
    ...
InvalidFormat: ...
>>> validate('6546546546546703')
Traceback (most recent call last):
    ...
InvalidLength: ...
>>> format('295109912611193')
'2 95 10 99 126 111 93'
é    )Úannotations)Ú*)ÚcleanÚisdigitsc                ó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    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/fr/nir.pyÚcompactr   F   s#   € ô �˜Ó×$Ñ$Ó&×,Ñ,Ó.Ð.ó    c                óˆ   — | dd }|dk(  r| dd dz   | dd z   } n|dk(  r| dd dz   | dd z   } dd	t        | dd
 «      d	z  z
  z  S )z*Calculate the check digits for the number.é   é   Ú2ANÚ19Ú2BÚ18z%02déa   é   )Úint)r   Ú
departments     r   Úcalc_check_digitsr   L   ss   € à˜˜!�€JØ�TÒØ˜˜�˜dÑ" V¨A¨B ZÑ/‰Ø	�tÒ	Ø˜˜�˜dÑ" V¨A¨B ZÑ/ˆØ�Rœ3˜v c r˜{Ó+¨bÑ0Ñ1Ñ2Ð2r   c                ó  — t        | «      } t        | dd «      rt        | dd «      s
t        «       ‚t        | dd «      s| dd dvr
t        «       ‚t        | «      dk7  r
t	        «       ‚t        | «      | dd k7  r
t        «       ‚| S )zSCheck if the number provided is valid. This checks the length
    and check digits.Nr   r   )r   r   é   r   )r   r   ÚInvalidFormatÚlenÚInvalidLengthr   ÚInvalidChecksumr
   s    r   Úvalidater!   V   sˆ   € ô �V‹_€FÜ�F˜2˜A�JÔ¤x°°q°r°
Ô';Ü‹oÐÜ�F˜1˜Q�KÔ  V¨A¨a [¸Ñ%DÜ‹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 provided is valid.F)Úboolr!   ÚValidationErrorr
   s    r   Úis_validr%   e   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c                ór   — t        | «      } |j                  | dd | dd | dd | dd | dd | dd | dd f«      S )z8Reformat the number to the standard presentation format.Né   é   r   r   é
   r   )r   Újoin)r   Ú	separators     r   Úformatr,   m   s[   € ä�V‹_€FØ�>‰>Øˆr�ˆ
�F˜1˜Q�K ¨¨! ¨f°Q°q¨k¸6À!ÀB¸<Øˆr�"ˆ�v˜b˜c�{ð$ó %ð %r   N)r   ÚstrÚreturnr-   )r   r-   r.   r#   )ú )r   r-   r+   r-   r.   r-   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r!   r%   r,   © r   r   ú<module>r5      s/   ðñ,(õT #ä ß 'ó/ó3óóõ%r   