Ë
    Ã?ÆiZ  ã                  óV   — 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	„Zy
)aÏ  PIN (Thailand Personal Identification Number).

The Thailand Personal Identification Number is a unique personal identifier
assigned at birth or upon receiving Thai citizenship issue by the Ministry of
Interior.

This number consists of 13 digits which the last is a check digit. Usually
separated into five groups using hyphens to make it easier to read.

More information:

* https://en.wikipedia.org/wiki/Thai_identity_card

>>> compact('1-2345-45678-78-1')
'1234545678781'
>>> validate('3100600445635')
'3100600445635'
>>> validate('1-2345-45678-78-1')
'1234545678781'
>>> validate('1-2345-45678-78-9')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('7100600445635')
'7-1006-00445-63-5'
é    )Úannotations)Ú*)Ú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.z -)r   Ústrip©Únumbers    úT/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/stdnum/th/pin.pyÚcompactr   5   s   € ô �˜Ó×$Ñ$Ó&Ð&ó    c                óf   — t        d„ t        | dd «      D «       «      dz  }t        d|z
  dz  «      S )zCalculate the check digit.c              3  óD   K  — | ]  \  }}d |z
  t        |«      z  –— Œ y­w)é   N)Úint)Ú.0ÚiÚns      r   ú	<genexpr>z#calc_check_digit.<locals>.<genexpr>=   s!   è ø€ Ò@¡  AˆQ�‰U”c˜!“fÕÑ@ùs   ‚ Né   é   é   é
   )ÚsumÚ	enumerateÚstr)r
   Úss     r   Úcalc_check_digitr   ;   s5   € äÑ@¬°6¸#¸2°;Ó)?Ô@Ó@À2ÑE€AÜ��A‘˜‰|ÓÐr   c                óÎ   — t        | «      } t        | «      dk7  r
t        «       ‚t        | «      s
t	        «       ‚| d   dv r
t        «       ‚| d   t        | «      k7  r
t        «       ‚| S )z[Check if the number is a valid PIN. This checks the length,
    formatting and check digit.é   r   )Ú0Ú9éÿÿÿÿ)r   ÚlenÚInvalidLengthr   ÚInvalidFormatÚInvalidComponentr   ÚInvalidChecksumr	   s    r   Úvalidater)   A   sf   € ô �V‹_€FÜ
ˆ6ƒ{�bÒÜ‹oÐÜ�FÔÜ‹oÐØˆa�y�JÑÜÓ Ð Øˆb�zÔ% fÓ-Ò-ÜÓÐØ€Mr   c                óJ   — 	 t        t        | «      «      S # t        $ r Y yw xY w)z"Check whether the number is valid.F)Úboolr)   ÚValidationErrorr	   s    r   Úis_validr-   P   s)   € ðÜ”H˜VÓ$Ó%Ð%øÜò Ùðús   ‚ –	"¡"c           	     ób   — t        | «      } dj                  | dd | dd | dd | dd | dd f«      S )z8Reformat the number to the standard presentation format.ú-Nr   é   r   r   )r   Újoinr	   s    r   Úformatr2   X   sM   € ä�V‹_€FØ�8‰8Øˆr�ˆ
�F˜1˜Q�K ¨¨" ¨v°b¸¨}¸fÀRÀS¸kðKó Lð Lr   N)r
   r   Úreturnr   )r
   r   r3   r+   )Ú__doc__Ú
__future__r   Ústdnum.exceptionsÚstdnum.utilr   r   r   r   r)   r-   r2   © r   r   ú<module>r9      s/   ðñ(õ6 #ä ß 'ó'óóóôLr   