Ë
    Ã?Æi  ã                  ól   — d Z ddlmZ ddlZddl­ ddlmZmZ dd„Zdd„Z	ddd„Z
ddd	„Zddd
„Zdd„Zy)uã  RRN (South Korean resident registration number).

The RRN (resident registration number, ì£¼ë¯¼ë“±ë¡�ë²ˆí˜¸) is a 13-digit number
issued to all residents of the Republic of Korea. Foreigners residing in the
Republic of Korea receive an alien registration number (ARN) which follows
the same encoding pattern.

The first six digits code the date of birth. The seventh digit encodes the
century and gender. The next four digits encode the place of birth for
Koreans or the issuing agency for foreigners, followed by two digits for the
community center number, one serial number and a check digit.

More information:

* https://www.law.go.kr/lsSc.do?tabMenuId=tab18&p1=&subMenu=1&nwYn=1&section=&tabNo=&query=ê°œì�¸ì •ë³´+ë³´í˜¸ë²•
* https://en.wikipedia.org/wiki/Resident_registration_number
* https://techscience.org/a/2015092901/

>>> validate('971013-9019902')
'9710139019902'
>>> validate('971013-9019903')  # incorrect checksum
Traceback (most recent call last):
    ...
InvalidChecksum: ...
é    )ÚannotationsN)Ú*)ÚcleanÚisdigitsc                ó6   — t        | d«      j                  «       S )zˆConvert the number to the minimal representation. This strips the
    number of any valid separators and removes surrounding whitespace.ú-)r   Ústrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/kr/rrn.pyÚcompactr   8   s   € ô �˜Ó×#Ñ#Ó%Ð%ó    c                óf   — d}t        d„ t        || «      D «       «      }t        d|dz  z
  dz  «      S )zCalculate the check digit.)é   é   é   é   é   é   é   é	   r   r   r   r   c              3  ó>   K  — | ]  \  }}|t        |«      z  –— Œ y ­w)N)Úint)Ú.0ÚwÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>A   s   è ø€ Ò<™t˜q !�”C˜“F•
Ñ<ùs   ‚é   é
   )ÚsumÚzipÚstr)r   ÚweightsÚchecks      r   Úcalc_check_digitr%   >   s7   € à2€GÜÑ<¤s¨7°FÓ';Ô<Ó<€EÜ��e˜b‘jÑ! RÑ'Ó(Ð(r   c                óf  — t        | «      } t        | dd «      }t        | dd «      }t        | dd «      }| d   dv r|dz  }n| d   dv r|dz  }n|d	z  }	 t        j                  |||«      }|s+|t        j                  j	                  «       k\  r
t        «       ‚|S # t        $ r t        «       ‚w xY w)
z„Split the date parts from the number and return the birth date. If
    allow_future is False birth dates in the future are rejected.r   r   r   r   Ú1256il  Ú3478iÐ  i  )r   r   ÚdatetimeÚdateÚtodayÚInvalidComponentÚ
ValueError)r   Úallow_futureÚyearÚmonthÚdayÚdate_of_births         r   Úget_birth_dater3   E   sÉ   € ô �V‹_€FÜˆv�a˜ˆ{Ó€DÜ��q˜�Ó€EÜ
ˆf�Q�qˆkÓ
€CØˆa�y�FÑØ�‰‰Ø	�‰�fÑ	Ø�‰‰à�‰ˆð	%Ü Ÿ™ d¨E°3Ó7ˆñ  ´·±×1DÑ1DÓ1FÒ FÜ"Ó$Ð$ØÐøô ò !ÜÓ Ð ð!ús   ÁB ÂB0c                ó  — t        | «      } t        | «      s
t        «       ‚t        | «      dk7  r
t	        «       ‚t        | |«       t        | dd «      }|dkD  r
t        «       ‚| d   t        | dd «      k7  r
t        «       ‚| S )z Check if the number is a valid RNN. This checks the length, formatting
    and check digit. If allow_future is False birth dates in the future are
    rejected.é   r   r   é`   éÿÿÿÿN)
r   r   ÚInvalidFormatÚlenÚInvalidLengthr3   r   r,   r%   ÚInvalidChecksum)r   r.   Úplace_of_births      r   Úvalidater=   _   s„   € ô �V‹_€FÜ�FÔÜ‹oÐÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�6˜<Ô(Ü˜  !˜Ó%€NØ˜ÒÜÓ Ð ð ˆb�zÔ% f¨S¨b kÓ2Ò2ÜÓÐØ€Mr   c                óL   — 	 t        t        | |«      «      S # t        $ r Y yw xY w)z&Check if the number provided is valid.F)Úboolr=   ÚValidationError)r   r.   s     r   Úis_validrA   s   s+   € ðÜ”H˜V \Ó2Ó3Ð3øÜò Ùðús   ‚ —	#¢#c                óT   — t        | «      } t        | «      dk(  r| dd dz   | dd z   } | S )z8Reformat the number to the standard presentation format.r5   Nr   r   )r   r9   r
   s    r   ÚformatrC   {   s7   € ä�V‹_€FÜ
ˆ6ƒ{�bÒØ˜˜�˜cÑ! F¨1¨2 JÑ.ˆØ€Mr   )r   r"   Úreturnr"   )T)r   r"   r.   r?   rD   zdatetime.date)r   r"   r.   r?   rD   r"   )r   r"   r.   r?   rD   r?   )Ú__doc__Ú
__future__r   r)   Ústdnum.exceptionsÚstdnum.utilr   r   r   r%   r3   r=   rA   rC   © r   r   ú<module>rJ      s6   ðñ,õ4 #ã ä ß 'ó&ó)ôô4ô(ôr   