Ë
    Ã?Æi©™  ã                  ó°   — d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
mZmZmZ  G d„ d«      Z G d„ d«      Z G d	„ d
e«      Zdd„Z G d„ de«      Zy)é    )ÚannotationsN)ÚSequence)ÚCallableÚDictÚListÚOptionalÚTupleÚUnionc                  ó¢  — e Zd ZU dZedEd„«       ZedFd„«       ZedGdHd„«       Zded	<   ded
<   ded<   ded<   ded<   ded<   dId„Z	dJd„Z
dJd„ZdKd„ZdJd„ZdLd„ZdMd„ZdNd„ZdMd„ZdOd„ZdOd„ZdPd„ZdQd„ZdRd„ZdNd„ZdJd„ZdSd „ZedTd!„«       ZedUd"„«       ZedVd#„«       ZedWd$„«       ZedXd%„«       ZdYd&„ZdZd'„Z d[d(„Z!dZ"ded)<   dZ#ded*<   d+Z$ded,<   d+Z%ded-<   dZ&ded.<   d/Z'ded0<   d1Z(d2ed3<   d4Z)d2ed5<   d6„ d7„ d8„ d9„ d:„ d;„ d<„ d=„ fZ*d>ed?<    G d@„ dA«      Z+ e+dBd«      e+_,         e+ddB«      e+_-         e+dCd+«      e+_.         e+d+dC«      e+_/        yD)\ÚQrCodeaÓ  A QR Code symbol, which is a type of two-dimension barcode.
	Invented by Denso Wave and described in the ISO/IEC 18004 standard.
	Instances of this class represent an immutable square grid of dark and light cells.
	The class provides static factory functions to create a QR Code from text or binary data.
	The class covers the QR Code Model 2 specification, supporting all versions (sizes)
	from 1 to 40, all 4 error correction levels, and 4 character encoding modes.
	
	Ways to create a QR Code object:
	- High level: Take the payload data and call QrCode.encode_text() or QrCode.encode_binary().
	- Mid level: Custom-make the list of segments and call QrCode.encode_segments().
	- Low level: Custom-make the array of data codeword bytes (including
	  segment headers and final padding, excluding error correction codewords),
	  supply the appropriate version number, and call the QrCode() constructor.
	(Note that all ways require supplying the desired error correction level.)ú
QrCode.Eccc                óX   — t         j                  | «      }t        j                  ||«      S )aé  Returns a QR Code representing the given Unicode text string at the given error correction level.
		As a conservative upper bound, this function is guaranteed to succeed for strings that have 738 or fewer
		Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
		QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
		ecl argument if it can be done without increasing the version.)Ú	QrSegmentÚmake_segmentsr   Úencode_segments)ÚtextÚeclÚsegss      úP/var/www/html/myprovider/mon_projet_qr/lib/python3.12/site-packages/qrcodegen.pyÚencode_textzQrCode.encode_text2   s'   € ô $×1Ñ1°$Ó7€$Ü	×	Ñ	  cÓ	*Ð*ó    c                óV   — t         j                  t        j                  | «      g|«      S )a›  Returns a QR Code representing the given binary data at the given error correction level.
		This function always encodes using the binary segment mode, not any text mode. The maximum number of
		bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
		The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.)r   r   r   Ú
make_bytes)Údatar   s     r   Úencode_binaryzQrCode.encode_binary=   s%   € ô 
×	Ñ	¤×!5Ñ!5°dÓ!;Ð <¸cÓ	BÐBr   é   é(   Úintc           
     óò  — t         j                  |cxk  r|cxk  rt         j                  k  r$n t        d«      ‚d|cxk  rdk  st        d«      ‚ t        d«      ‚t	        ||dz   «      D ]W  }t         j                  ||«      dz  }t        j                  | |«      }|�||k  r n||k\  sŒAd}	|�	d|› d|› d	�}	t        |	«      ‚ €J ‚t         j                  j                  t         j                  j                  t         j                  j                  fD ]$  }
|sŒ|t         j                  |
«      dz  k  sŒ#|
}Œ& t        «       }| D ]ˆ  }|j                  |j                  «       j!                  «       d
«       |j                  |j#                  «       |j                  «       j%                  «      «       |j'                  |j(                  «       ŒŠ t+        |«      |k(  sJ ‚t         j                  |«      dz  }t+        |«      |k  sJ ‚|j                  dt-        d
|t+        |«      z
  «      «       |j                  dt+        |«       dz  «       t+        |«      dz  dk(  sJ ‚t/        j0                  d«      D ]$  }t+        |«      |k\  r n|j                  |d«       Œ& t3        dgt+        |«      dz  z  «      }t5        |«      D ]  \  }}||dz	  xx   |d|dz  z
  z  z  cc<   Œ  t        ||||«      S )aÙ  Returns a QR Code representing the given segments with the given encoding parameters.
		The smallest possible QR Code version within the given range is automatically
		chosen for the output. Iff boostecl is true, then the ECC level of the result
		may be higher than the ecl argument if it can be done without increasing the
		version. The mask number is either between 0 to 7 (inclusive) to force that
		mask, or -1 to automatically choose an appropriate mask (which may be slow).
		This function allows the user to create a custom sequence of segments that switches
		between modes (such as alphanumeric and byte) to encode text in less space.
		This is a mid-level API; the high-level API is encode_text() and encode_binary().éÿÿÿÿé   zInvalid valuer   é   zSegment too longzData length = z bits, Max capacity = z bitsé   r   )éì   é   é   )r   ÚMIN_VERSIONÚMAX_VERSIONÚ
ValueErrorÚrangeÚ_get_num_data_codewordsr   Úget_total_bitsÚDataTooLongErrorÚEccÚMEDIUMÚQUARTILEÚHIGHÚ
_BitBufferÚappend_bitsÚget_modeÚget_mode_bitsÚget_num_charsÚnum_char_count_bitsÚextendÚ_bitdataÚlenÚminÚ	itertoolsÚcycleÚ	bytearrayÚ	enumerate)r   r   Ú
minversionÚ
maxversionÚmaskÚboosteclÚversionÚdatacapacitybitsÚdatausedbitsÚmsgÚneweclÚbbÚsegÚpadbyteÚdatacodewordsÚiÚbits                    r   r   zQrCode.encode_segmentsH   sç  € ô ×
Ñ
 
Ô
N¨jÔ
N¼F×<NÑ<NÔ
NÜ	�OÓ	$Ð$ð Y[Ð^bÔXgÐfgÒXgÜ	�OÓ	$Ð$ð YhÜ	�OÓ	$Ð$ô �z :°¡>Ó2ò 	 €gÜ!×9Ñ9¸'À3ÓGÈ!ÑKÐÜ!*×!9Ñ!9¸$ÀÓ!H€<ØÐ lÐ6FÒ&FÙ	Ø�ÓØ!€CØÐØ˜L˜>Ð)?Ð@PÐ?QÐQVÐW€SÜ
˜3Ó
Ðð	 ð 
Ð	!Ð!Ð	!ô —‘×"Ñ"¤F§J¡J×$7Ñ$7¼¿¹¿¹ÐIò €fÚ�L¤F×$BÑ$BÀ7ÈFÓ$SÐVWÑ$WÓWØ
�Cðô
 ƒ|€"Øò €cØ‡>�>�#—,‘,“.×.Ñ.Ó0°!Ô4Ø‡>�>�#×#Ñ#Ó% s§|¡|£~×'IÑ'IÈ'Ó'RÔSØ‡9�9ˆS�\‰\Õðô 
ˆR‹�LÒ	 Ð Ð	 ô ×3Ñ3°G¸SÓAÀAÑEÐÜ	ˆR‹Ð$Ò	$Ð$Ð	$Ø‡.�.�”C˜Ð+¬c°"«gÑ5Ó6Ô7Ø‡.�.�”S˜“W�H˜q‘LÔ!Ü	ˆR‹�1‰˜Ò	ÐÐ	ô —‘ Ó.ò €gÜ	ˆ"ƒgÐ!Ò!Ù	Ø‡>�>�'˜1Õðô ˜Q˜C¤3 r£7¨a¡<Ñ0Ó1€-Ü˜B“-ò 1�h€qˆ#Ø��a‘Ó˜C A¨¨Q©¡KÑ0Ñ0Ôð1ô 
�˜˜m¨TÓ	2Ð2r   Ú_versionÚ_sizeÚ
_errcorlvlÚ_maskzList[List[bool]]Ú_modulesÚ_isfunctionc                ó˜  — t         j                  |cxk  rt         j                  k  st        d«      ‚ t        d«      ‚d|cxk  rdk  st        d«      ‚ t        d«      ‚|| _        |dz  dz   | _        || _        t        | j
                  «      D �cg c]  }dg| j
                  z  ‘Œ c}| _        t        | j
                  «      D �cg c]  }dg| j
                  z  ‘Œ c}| _	        | j                  «        | j                  t        |«      «      }| j                  |«       |dk(  r^d}t        d	«      D ]N  }| j                  |«       | j                  |«       | j!                  «       }	|	|k  r|}|	}| j                  |«       ŒP d
|cxk  rdk  sJ ‚ J ‚|| _        | j                  |«       | j                  |«       | `	yc c}w c c}w )zìCreates a new QR Code with the given version number,
		error correction level, data codeword bytes, and mask number.
		This is a low-level API that most users should not use directly.
		A mid-level API is the encode_segments() function.zVersion value out of ranger    r!   úMask value out of ranger#   r%   Fl        r"   r   N)r   r'   r(   r)   rO   rP   rQ   r*   rS   rT   Ú_draw_function_patternsÚ_add_ecc_and_interleaver>   Ú_draw_codewordsÚ_apply_maskÚ_draw_format_bitsÚ_get_penalty_scorerR   )
ÚselfrD   Ú	errcorlvlrL   ÚmskÚ_ÚallcodewordsÚ
minpenaltyrM   Úpenaltys
             r   Ú__init__zQrCode.__init__£   s´  € ô ×
Ñ
 Ô
=¬6×+=Ñ+=Ò
=Ü	Ð0Ó	1Ð1ð >Ü	Ð0Ó	1Ð1Ø
�Œ.�qŠ.Ü	Ð-Ó	.Ð.ð Ü	Ð-Ó	.Ð.à€$„-Ø˜‰{˜RÑ€$„*Ø€$„/ô 5:¸$¿*¹*Ó4EÖF¨q�u�g §
¡
Ó*ÒF€$„-Ü49¸$¿*¹*Ó4EÖF¨q�u�g §
¡
Ó*ÒF€$Ôð ×ÑÔ Ø×4Ñ4´Y¸}Ó5MÓN€,Ø×Ñ�|Ô$ð 	ˆB‚YØ€:Ü�!‹Hò €qØ×Ñ�QÔØ×Ñ˜1ÔØ×%Ñ%Ó'€GØ�ÒØ€SØ€ZØ×Ñ�QÕðð 
ˆcŒ�QŠÐ‰ÐˆØ€$„*Ø×Ñ�3ÔØ×Ñ˜Ôà
Ñùò1 GùÚFs   ÂGÃ	Gc                ó   — | j                   S )z<Returns this QR Code's version number, in the range [1, 40].)rO   ©r]   s    r   Úget_versionzQrCode.get_versionÑ   s   € à	�‰Ðr   c                ó   — | j                   S )z4Returns this QR Code's size, in the range [21, 177].©rP   rf   s    r   Úget_sizezQrCode.get_sizeÕ   ó   € à	�‰Ðr   c                ó   — | j                   S )z.Returns this QR Code's error correction level.)rQ   rf   s    r   Úget_error_correction_levelz!QrCode.get_error_correction_levelÙ   s   € à	�‰Ðr   c                ó   — | j                   S )z1Returns this QR Code's mask, in the range [0, 7].)rR   rf   s    r   Úget_maskzQrCode.get_maskÝ   rk   r   c                ó–   — d|cxk  xr | j                   k  nc xr. d|cxk  xr | j                   k  nc xr | j                  |   |   S )zðReturns the color of the module (pixel) at the given coordinates, which is False
		for light or True for dark. The top left corner has the coordinates (x=0, y=0).
		If the given coordinates are out of bounds, then False (light) is returned.r   )rP   rS   )r]   ÚxÚys      r   Ú
get_modulezQrCode.get_moduleá   s>   € ð ˆqÖ
�4—:‘:Ô
Ò	P A¨Ö$7¨T¯Z©ZÔ$7Ò	P¸T¿]¹]È1Ñ=MÈaÑ=PÐPr   c                óP  — t        | j                  «      D ]4  }| j                  d||dz  dk(  «       | j                  |d|dz  dk(  «       Œ6 | j                  dd«       | j                  | j                  dz
  d«       | j                  d| j                  dz
  «       | j	                  «       }t        |«      }dd|dz
  f|dz
  dff}t        |«      D ]1  }t        |«      D ]!  }||f|vsŒ
| j                  ||   ||   «       Œ# Œ3 | j                  d«       | j                  «        y)	zLReads this object's version field, and draws and marks all function modules.é   é   r   r&   r#   )r   r   r   N)	r*   rP   Ú_set_function_moduleÚ_draw_finder_patternÚ _get_alignment_pattern_positionsr:   Ú_draw_alignment_patternr[   Ú_draw_version)r]   rM   ÚalignpatposÚnumalignÚskipsÚjs         r   rW   zQrCode._draw_function_patternsê   s4  € ô �—‘Óò /€aØ×Ñ˜Q  1 q¡5¨A¡:Ô.Ø×Ñ˜Q  1 q¡5¨A¡:Õ.ð/ð
 ×Ñ˜A˜qÔ!Ø×Ñ˜DŸJ™J¨™N¨AÔ.Ø×Ñ˜A˜tŸz™z¨A™~Ô.ð  ×@Ñ@ÓB€+Ü�kÓ"€(Ø%+¨a°¸A±Ð->ÀÈAÁÈqÐ@QÐ$R€%Ü�‹?ò B€aÜ�(‹Oò B€qØ	ˆ1€v�UÒØ	×!Ñ! +¨a¡.°+¸a±.ÕAñBðBð ×Ñ˜ÔØ×ÑÕr   c           	     óJ  — | j                   j                  dz  |z  }|}t        d«      D ]  }|dz  |dz	  dz  z  }Œ |dz  |z  dz  }|dz	  dk(  sJ ‚t        dd	«      D ]  }| j                  d
|t	        ||«      «       Œ! | j                  d
dt	        |d	«      «       | j                  d
d
t	        |d«      «       | j                  dd
t	        |d
«      «       t        dd«      D ]"  }| j                  d|z
  d
t	        ||«      «       Œ$ t        dd
«      D ]/  }| j                  | j
                  dz
  |z
  d
t	        ||«      «       Œ1 t        d
d«      D ]/  }| j                  d
| j
                  dz
  |z   t	        ||«      «       Œ1 | j                  d
| j
                  d
z
  d«       y)z’Draws two copies of the format bits (with its own error correction code)
		based on the given mask and this object's error correction level field.r&   é
   r   é	   i7  iT  é   r   ru   r"   r!   é   TN)rQ   Ú
formatbitsr*   rw   Ú_get_bitrP   )r]   rB   r   Úremr`   ÚbitsrM   s          r   r[   zQrCode._draw_format_bits  s²  € ð �o‰o×(Ñ(¨AÑ-°Ñ4€$Ø€#Ü�‹9ò +€aØ
�‰(˜˜q™ EÑ)Ñ	*�3ð+à�r‰z˜CÑ 6Ñ)€$Ø	�‰�qŠÐˆô ��A‹;ò 6€aØ×Ñ˜Q ¤8¨D°!Ó#4Õ5ð6à×Ñ˜A˜q¤(¨4°Ó"3Ô4Ø×Ñ˜A˜q¤(¨4°Ó"3Ô4Ø×Ñ˜A˜q¤(¨4°Ó"3Ô4Ü��B‹<ò ;€aØ×Ñ˜R !™V Q¬°°qÓ(9Õ:ð;ô ��A‹;ò G€aØ×Ñ˜TŸZ™Z¨!™^¨aÑ/°´H¸TÀ1Ó4EÕFðGä��B‹<ò H€aØ×Ñ˜Q §
¡
¨R¡°!Ñ 3´X¸dÀAÓ5FÕGðHà×Ñ˜A˜tŸz™z¨A™~¨tÕ4r   c                óh  — | j                   dk  ry| j                   }t        d«      D ]  }|dz  |dz	  dz  z  }Œ | j                   dz  |z  }|dz	  dk(  sJ ‚t        d«      D ]N  }t        ||«      }| j                  dz
  |d	z  z   }|d	z  }| j	                  |||«       | j	                  |||«       ŒP y)
zŠDraws two copies of the version bits (with its own error correction code),
		based on this object's version field, iff 7 <= version <= 40.r!   Né   r   é   i%  é   r   r&   )rO   r*   r†   rP   rw   )r]   r‡   r`   rˆ   rM   rN   ÚaÚbs           r   r{   zQrCode._draw_version   sÏ   € ð 
‡]�]�QÒØ	ð �]‰]€#Ü�‹9ò -€aØ
�‰(˜˜r™	 VÑ+Ñ	,�3ð-à�m‰m˜rÑ! CÑ'€$Ø	�‰�qŠÐˆô �‹9ò (€aÜ˜˜aÓ €3Ø�J‰J˜‰O˜a !™eÑ#€1Ø�‰F€1Ø×Ñ˜Q  3Ô'Ø×Ñ˜Q  3Õ'ñ(r   c                ó"  — t        dd«      D ]€  }t        dd«      D ]o  }||z   ||z   }}d|cxk  r| j                  k  sŒ#n Œ&d|cxk  r| j                  k  sŒ<n Œ?| j                  ||t        t	        |«      t	        |«      «      dv«       Œq Œ‚ y)z|Draws a 9*9 finder pattern including the border separator,
		with the center module at (x, y). Modules can be out of bounds.éüÿÿÿé   r   )rv   r#   N)r*   rP   rw   ÚmaxÚabs)r]   rq   rr   ÚdyÚdxÚxxÚyys          r   rx   zQrCode._draw_finder_pattern6  sŠ   € ô �"�a‹Lò L€bÜ�2�q‹\ò L€rØ�‰V�Q˜‘Vˆ€BØ	ˆRÔ�$—*‘*Ö 1¨Ô#7¨T¯Z©ZÖ#7à	×Ñ˜r 2¤s¬3¨r«7´C¸³GÓ'<ÀFÐ'JÕKñ	LñLr   c                ó¸   — t        dd«      D ]K  }t        dd«      D ]:  }| j                  ||z   ||z   t        t        |«      t        |«      «      dk7  «       Œ< ŒM y)zaDraws a 5*5 alignment pattern, with the center module
		at (x, y). All modules must be in bounds.éþÿÿÿr&   r   N)r*   rw   r’   r“   )r]   rq   rr   r”   r•   s        r   rz   zQrCode._draw_alignment_patternA  s`   € ô �"�a‹Lò J€bÜ�2�q‹\ò J€rØ×Ñ˜a "™f a¨"¡f¬c´#°b³'¼3¸r»7Ó.CÀqÑ.HÕIñJñJr   c                ór   — t        |«      t        u sJ ‚|| j                  |   |<   d| j                  |   |<   y)z|Sets the color of a module and marks it as a function module.
		Only used by the constructor. Coordinates must be in bounds.TN)ÚtypeÚboolrS   rT   )r]   rq   rr   Úisdarks       r   rw   zQrCode._set_function_moduleI  s>   € ô 
ˆf‹œÑ	ÐÐ	Ø€$‡-�-�Ñ�1ÑØ€$×Ñ�1Ñ�aÒr   c                óz  — | j                   }t        |«      t        j                  || j                  «      k(  sJ ‚t        j
                  | j                  j                     |   }t        j                  | j                  j                     |   }t        j                  |«      dz  }|||z  z
  }||z  }g }t        j                  |«      }	d}
t        |«      D ]e  }||
|
|z   |z
  ||k  rdndz    }|
t        |«      z  }
t        j                  ||	«      }||k  r|j                  d«       |j                  ||z   «       Œg |
t        |«      k(  sJ ‚t        «       }t        t        |d   «      «      D ]7  }t        |«      D ]'  \  }}|||z
  k7  s||k\  sŒ|j                  ||   «       Œ) Œ9 t        |«      |k(  sJ ‚|S )z²Returns a new byte string representing the given data with the appropriate error correction
		codewords appended to it, based on this object's version and error correction level.r"   r   r   )rO   r:   r   r+   rQ   Ú_NUM_ERROR_CORRECTION_BLOCKSÚordinalÚ_ECC_CODEWORDS_PER_BLOCKÚ_get_num_raw_data_modulesÚ_reed_solomon_compute_divisorr*   Ú_reed_solomon_compute_remainderÚappendr>   r?   )r]   r   rD   Ú	numblocksÚblockecclenÚrawcodewordsÚnumshortblocksÚshortblocklenÚblocksÚrsdivÚkrM   ÚdatÚeccÚresultr   Úblks                    r   rX   zQrCode._add_ecc_and_interleaveS  sÃ  € ð —‘€'Ü	ˆT‹”f×4Ñ4°W¸d¿o¹oÓNÒ	NÐNÐ	Nô ×6Ñ6°t·±×7NÑ7NÑOÐPWÑX€)Ü×4Ñ4°t·±×7NÑ7NÑOÐPWÑX€+Ü×6Ñ6°wÓ?À1ÑD€,Ø! L°9Ñ$<Ñ<€.Ø# yÑ0€-ð €&Ü×5Ñ5°kÓB€%Ø€!Ü�Óò €aØ˜˜Q Ñ.°Ñ<ÀQÈÒEWÁÐ]^Ñ_Ð`€3ØŒˆC‹�=€1Ü×6Ñ6°s¸EÓB€3Øˆ.ÒØ‡J�Jˆq„MØ	‡=�=��s‘Õðð 
Œc�$‹iŠÐˆô ‹;€&Ü”�V˜A‘Y“Ó ò €aÜ˜VÓ$ò �xˆˆ3à	ˆ]˜[Ñ(Ò(¨a°>Ó.AØ‡]�]�3�q‘6Õñðô
 
ˆV‹˜Ò	$Ð$Ð	$Ø	€-r   c           	     ó$  — t        |«      t        j                  | j                  «      dz  k(  sJ ‚d}t	        | j
                  dz
  dd«      D ]®  }|dk  r|dz  }t	        | j
                  «      D ]Š  }t	        d«      D ]z  }||z
  }|dz   dz  dk(  }|r| j
                  dz
  |z
  n|}| j                  |   |   rŒ<|t        |«      dz  k  sŒNt        ||dz	     d|dz  z
  «      | j                  |   |<   |dz  }Œ| ŒŒ Œ° |t        |«      dz  k(  sJ ‚y	)
z²Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
		data area of this QR Code. Function modules need to be marked off before this is called.r"   r   r   r™   ru   rv   r&   r!   N)	r:   r   r¢   rO   r*   rP   rT   r†   rS   )	r]   r   rM   ÚrightÚvertr   rq   Úupwardrr   s	            r   rY   zQrCode._draw_codewordsx  s(  € ô 
ˆT‹”f×6Ñ6°t·}±}ÓEÈÑJÒ	JÐJÐ	Jà€!ä�T—Z‘Z !‘^ Q¨Ó+ò 
€eØˆq‚jØ	ˆQ�J€EÜ�T—Z‘ZÓ ò €tÜ�1‹Xò ˆØ�a‰i€QØ˜Q‘Y !‘O qÑ(€VÙ)/ˆt�z‰z˜A‰~ Ò$°T€QØ×Ñ˜aÑ  Ó#¨!¬c°$«i¸!©mÓ*;Ü$ T¨!¨q©&¡\°1¸¸A¹±;Ó?€d‡m�m�AÑ�qÑØˆ1�f�aññð
ð 
Œc�$‹i˜!‰mÒ	ÐÑ	r   c           	     óH  — d|cxk  rdk  st        d«      ‚ t        d«      ‚t        j                  |   }t        | j                  «      D ]U  }t        | j                  «      D ];  }| j
                  |   |xx    |||«      dk(  xr | j                  |   |    z  cc<   Œ= ŒW y)ag  XORs the codeword modules in this QR Code with the given mask pattern.
		The function modules must be marked and the codeword bits must be drawn
		before masking. Due to the arithmetic of XOR, calling _apply_mask() with
		the same mask value a second time will undo the mask. A final well-formed
		QR Code needs exactly one (not zero, two, etc.) mask applied.r   r!   rV   N)r)   r   Ú_MASK_PATTERNSr*   rP   rS   rT   )r]   rB   Úmaskerrr   rq   s        r   rZ   zQrCode._apply_mask�  s¬   € ð ˆtŒ.�qŠ.Ü	Ð-Ó	.Ð.ð Ü	Ð-Ó	.Ð.Ü$*×$9Ñ$9¸$Ñ$?€&Ü�—‘Óò P€aÜ�$—*‘*Óò P€qØ‡M�M�!Ñ�QÓ™F 1 a›L¨AÑ-ÒO¸×8HÑ8HÈÑ8KÈAÑ8NÐ4NÑOÔñPñPr   c                ól  — d}| j                   }| j                  }t        |«      D ]Ï  }d}d}t        j                  dgdz  d«      }t        |«      D ]z  }||   |   |k(  r*|dz  }|dk(  r|t
        j                  z  }Œ,|dkD  sŒ2|dz  }Œ8| j                  ||«       |s%|| j                  |«      t
        j                  z  z  }||   |   }d}Œ| || j                  |||«      t
        j                  z  z  }ŒÑ t        |«      D ]Ï  }d}d}	t        j                  dgdz  d«      }t        |«      D ]z  }||   |   |k(  r*|	dz  }	|	dk(  r|t
        j                  z  }Œ,|	dkD  sŒ2|dz  }Œ8| j                  |	|«       |s%|| j                  |«      t
        j                  z  z  }||   |   }d}	Œ| || j                  ||	|«      t
        j                  z  z  }ŒÑ t        |dz
  «      D ]a  }t        |dz
  «      D ]N  }||   |   ||   |dz      cxk(  r!||dz      |   cxk(  r||dz      |dz      k(  sŒ9n Œ<|t
        j                  z  }ŒP Œc t        d„ |D «       «      }
|dz  }t        |
dz  |d	z  z
  «      |z   dz
  |z  dz
  }d|cxk  rd
k  sJ ‚ J ‚||t
        j                  z  z  }d|cxk  rdk  sJ ‚ J ‚|S )zÇCalculates and returns the penalty score based on state of this QR Code's current modules.
		This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.r   Fr!   r   r‘   c              3  ó6   K  — | ]  }|D ]
  }|rd nd–— Œ Œ y­w)r   r   N© )Ú.0ÚrowÚcells      r   ú	<genexpr>z,QrCode._get_penalty_score.<locals>.<genexpr>Ò  s$   è ø€ ÒH¨ÀCÒH¸D™‘1 !Ó#ÐHÐ#ÑHùs   ‚rv   é   r�   r‚   i¸2' )rP   rS   r*   ÚcollectionsÚdequer   Ú_PENALTY_N1Ú_finder_penalty_add_historyÚ_finder_penalty_count_patternsÚ_PENALTY_N3Ú#_finder_penalty_terminate_and_countÚ_PENALTY_N2Úsumr“   Ú_PENALTY_N4)r]   r°   ÚsizeÚmodulesrr   ÚruncolorÚrunxÚ
runhistoryrq   ÚrunyÚdarkÚtotalr­   s                r   r\   zQrCode._get_penalty_score�  s!  € ð €&Ø�j‰j€$Ø"Ÿm™m€'ô �‹;ò g€aØ€8Ø€4Ü×!Ñ! 1 #¨¡'¨1Ó-€:Ü�$‹Kò €qØˆq�z�!�}˜Ò Ø	ˆQ�Y€TØ�Š	Ø”×"Ñ"Ñ"�fØ
�‹(Ø��k�fà	×%Ñ% d¨JÔ7ÙØ�×3Ñ3°JÓ?Ä&×BTÑBTÑTÑT€fØ˜‘
˜1‘€XØ�Tðð 
ˆT×5Ñ5°hÀÀjÓQÔTZ×TfÑTfÑfÑf�6ð#gô& �‹;ò g€aØ€8Ø
€4Ü×!Ñ! 1 #¨¡'¨1Ó-€:Ü�$‹Kò €qØˆq�z�!�}˜Ò Ø	ˆQ�Y€TØ�Š	Ø”×"Ñ"Ñ"�fØ
�‹(Ø��k�fà	×%Ñ% d¨JÔ7ÙØ�×3Ñ3°JÓ?Ä&×BTÑBTÑTÑT€fØ˜‘
˜1‘€XØ�Tðð 
ˆT×5Ñ5°hÀÀjÓQÔTZ×TfÑTfÑfÑf�6ð#gô( �˜‘‹?ò "€aÜ�$˜‘(‹Oò "€qØˆq�z�!�}˜ ™
 1 q¡5Ñ)ÔW¨W°Q¸±U©^¸AÑ->ÔWÀ'È!ÈaÉ%Á.ÐQRÐUVÑQVÑBWÖWØŒv×!Ñ!Ñ!�Vñ"ð"ô ÑH°ÔHÓH€$Ø�Q‰w€%ä��r‘	˜E B™JÑ&Ó'¨%Ñ/°!Ñ3¸Ñ=ÀÑA€!Ø	
ˆaŒ�1ŠÐ‰ÐˆØˆA”×"Ñ"Ñ"Ñ"€&Ø	
ˆfÔ	˜Ò	ÐÑ	ÐÐ	Ø	€-r   c                ó  — | j                   }|dk(  rg S |dz  dz   }|dk(  rdn|dz  |dz  z   dz   |dz  dz
  z  dz  }t        |dz
  «      D �cg c]  }| j                  dz
  ||z  z
  ‘Œ c}dgz   }t        t	        |«      «      S c c}w )zúReturns an ascending list of positions of alignment patterns for this version number.
		Each position is in the range [0,177), and are used on both the x and y axes.
		This could be implemented as lookup table of 40 variable-length lists of integers.r   r!   rv   é    é   r#   ru   )rO   r*   rP   ÚlistÚreversed)r]   Úverr}   ÚsteprM   r°   s         r   ry   z'QrCode._get_alignment_pattern_positionsÞ  s¥   € ð �]‰]€#ØˆA‚XØ
€9à˜!‘8˜a‘<€8Ø˜R’i‰rØˆ1�Wˆx˜!‰|Ñ˜aÑ X°¡\°AÑ%5Ñ6¸Ñ:ð ä=BÀ8ÈaÁ<Ó=PÖQ¸˜Ÿ™ a™¨!¨d©(Ó2ÒQÐUVÐTWÑW€6Ü
Œx˜ÓÓ
 Ð ùò Rs   ÁBc                ó  — t         j                  | cxk  rt         j                  k  st        d«      ‚ t        d«      ‚d| z  dz   | z  dz   }| dk\  r#| dz  dz   }|d|z  dz
  |z  d	z
  z  }| dk\  r|d
z  }d|cxk  rdk  sJ ‚ J ‚|S )a*  Returns the number of data bits that can be stored in a QR Code of the given version number, after
		all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
		The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.zVersion number out of rangeé   é€   é@   rv   r!   é   r�   é7   é$   éÐ   iÐs  )r   r'   r(   r)   )rØ   r°   r}   s      r   r¢   z QrCode._get_num_raw_data_modulesí  s°   € ô
 ×
Ñ
 Ô
9¤v×'9Ñ'9Ò
9Ü	Ð1Ó	2Ð2ð :Ü	Ð1Ó	2Ð2Ø�c‘˜C‘ 3Ñ&¨Ñ+€&ØˆA‚XØ˜!‘8˜a‘<€8Ø	ˆb�8‰m˜bÑ  HÑ,¨rÑ1Ñ1€6Ø	ˆQ‚hØ
ˆb�L€FØ	�Ô	˜%Ò	ÐÑ	ÐÐ	Ø	€-r   c                ó¶   — t         j                  | «      dz  t         j                  |j                     |    t         j                  |j                     |    z  z
  S )a  Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
		QR Code of the given version number and error correction level, with remainder bits discarded.
		This stateless pure function could be implemented as a (40*4)-cell lookup table.r"   )r   r¢   r¡   r    rŸ   )rØ   r   s     r   r+   zQrCode._get_num_data_codewordsþ  sT   € ô
 
×	)Ñ	)¨#Ó	.°!Ñ	3Ü×$Ñ$¨¯©Ñ5°cÑ:Ü×(Ñ(¨¯©Ñ5°cÑ:ñ;ñ
;ð ;r   c                óV  — d| cxk  rdk  st        d«      ‚ t        d«      ‚t        dg| dz
  z  dgz   «      }d}t        | «      D ]`  }t        | «      D ]:  }t        j	                  ||   |«      ||<   |dz   | k  sŒ(||xx   ||dz      z  cc<   Œ< t        j	                  |d«      }Œb |S )z³Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
		implemented as a lookup table over all possible parameter values, instead of as an algorithm.r   éÿ   zDegree out of ranger   rv   )r)   r>   r*   r   Ú_reed_solomon_multiply)Údegreer°   Úrootr`   r   s        r   r£   z$QrCode._reed_solomon_compute_divisor  sÏ   € ð ˆvÔ
˜Ò
Ü	Ð)Ó	*Ð*ð Ü	Ð)Ó	*Ð*ô �a�S˜F Q™JÑ'¨1¨#Ñ-Ó.€&ð
 €$Ü�‹=ò 4€aä�&‹Mò  €qÜ×-Ñ-¨f°Q©i¸Ó>€Fˆ1�IØˆ1�uˆvƒ~ØˆAƒY�&˜˜Q™‘-Ñ„Yð ô ×
'Ñ
'¨¨dÓ
3�4ð4ð 
€-r   c           	     óö   — t        dgt        |«      z  «      }| D ][  }||j                  d«      z  }|j                  d«       t	        |«      D ]&  \  }}||xx   t
        j                  ||«      z  cc<   Œ( Œ] |S )z^Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.r   )r>   r:   Úpopr¥   r?   r   rå   )r   Údivisorr°   rŽ   ÚfactorrM   Úcoefs          r   r¤   z&QrCode._reed_solomon_compute_remainder   s€   € ô �a�Sœ3˜w›<Ñ'Ó(€&Øò =€aØ�V—Z‘Z “]Ñ"€6Ø	‡=�=�ÔÜ˜gÓ&ò =�yˆˆ4Ø
ˆ1ƒI”×.Ñ.¨t°VÓ<Ñ<„Iñ=ð=ð
 
€-r   c                ó¾   — | dz	  dk7  s|dz	  dk7  rt        d«      ‚d}t        t        d«      «      D ]  }|dz  |dz	  dz  z  }|||z	  dz  | z  z  }Œ  |dz	  dk(  sJ ‚|S )zÊReturns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
		are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.r"   r   zByte out of ranger   r!   i  )r)   r×   r*   )rq   rr   ÚzrM   s       r   rå   zQrCode._reed_solomon_multiply,  s‡   € ð ˆ1�f�‚k�q˜A‘v ’{Ü	Ð'Ó	(Ð(à€!Ü”E˜!“HÓò €aØ	ˆQ‰�A˜‘F˜eÑ#Ñ$€1Øˆ!ˆq‰&�A‰˜ÑÑ�1ðð 
ˆa‰�1ŠÐˆØ	
€(r   c                ó  — |d   }|| j                   dz  k  sJ ‚|dkD  xr. |d   |d   cxk(  xr |d   cxk(  xr |k(  nc xr |d   |dz  k(  }|r|d   |dz  k\  r
|d   |k\  rdnd|r|d   |dz  k\  r|d   |k\  rdz   S dz   S )z‡Can only be called immediately after a light run is added, and
		returns either 0, 1, or 2. A helper function for _get_penalty_score().r   r&   r   rv   r#   r‘   ru   ri   )r]   rÏ   ÚnÚcores       r   rÅ   z%QrCode._finder_penalty_count_patterns;  s¿   € ð �a‰=€!Ø	
ˆd�j‰j˜1‰nÒ	ÐÐ	Ø�1‰uÒj˜* Q™-¨:°a©=ÖN¸JÀq¹MÖNÈQÔNÒjÐT^Ð_`ÑTaÐefÐijÑejÑTj€$Ù˜ A™¨!¨a©%Ò/°J¸q±MÀQÒ4F‰!ÈQÙ˜ A™¨!¨a©%Ò/°J¸q±MÀQÒ4Fˆ!ñ
Pð PØMNñ
Pð Pr   c                ó’   — |r| j                  ||«       d}|| j                  z  }| j                  ||«       | j                  |«      S )zkMust be called at the end of a line (row or column) of modules. A helper function for _get_penalty_score().r   )rÄ   rP   rÅ   )r]   ÚcurrentruncolorÚcurrentrunlengthrÏ   s       r   rÇ   z*QrCode._finder_penalty_terminate_and_countE  sM   € áØ×#Ñ#Ð$4°jÔAØÐØ�d—j‘jÑ ÐØ×"Ñ"Ð#3°ZÔ@Ø	×	,Ñ	,¨ZÓ	8Ð8r   c                óT   — |d   dk(  r|| j                   z  }|j                  |«       y )Nr   )rP   Ú
appendleft)r]   rô   rÏ   s      r   rÄ   z"QrCode._finder_penalty_add_historyO  s,   € Ø��]�aÒØ�t—z‘zÑ!ÐØ×ÑÐ(Õ)r   r'   r(   r&   rÃ   rÈ   rÆ   r�   rÊ   )))r    r!   r�   rƒ   rÀ   rÕ   rŒ   rÀ   é   é   rŒ   rÀ   r÷   rÕ   rø   é   r÷   é   rø   rú   rú   rú   rú   rø   rø   rÕ   rú   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   ))r    r�   rÛ   rÕ   rŒ   r÷   rÛ   rŒ   rù   rù   rÕ   rø   rù   rù   r÷   r÷   rú   rú   rÕ   rÕ   rÕ   rÕ   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   rú   ))r    é   rù   rŒ   rÕ   rŒ   r÷   rŒ   rù   rÀ   r÷   rú   rÕ   r÷   rÀ   rø   r÷   rú   rú   rÕ   rø   rú   rø   rø   rø   rø   rú   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   ))r    r%   rú   rù   rÛ   rù   rú   rÕ   rÕ   r÷   rú   r÷   rú   rù   r÷   r÷   rø   rú   rú   rÕ   rú   rø   r÷   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   rø   zSequence[Sequence[int]]r¡   )))r    r   r   r   r   r   rv   rv   rv   rv   r#   r#   r#   r#   r#   ru   ru   ru   ru   r!   r"   r"   r‚   r‚   r�   rŠ   rŠ   rŠ   rû   r„   rƒ   rÛ   r%   rŒ   é   rü   rÀ   é   rù   r÷   rÞ   ))r    r   r   r   rv   rv   r#   r#   r#   r‘   r‘   r‘   r"   r‚   r‚   r�   r�   r‹   rû   r„   rÛ   r%   r%   rŒ   rÀ   rý   é   rÞ   rÕ   rú   é   é   é!   é#   é%   é&   r   é+   é-   é/   é1   ))r    r   r   rv   rv   r#   r#   ru   ru   r"   r"   r"   r�   rŠ   rÛ   rŠ   r%   rÛ   rŒ   rý   rÀ   rþ   rþ   rÞ   é   rÿ   é"   r
  r  r  r   r  r  é0   é3   é5   é8   é;   é>   éA   éD   ))r    r   r   rv   r#   r#   r#   r‘   ru   r"   r"   r‹   r‹   rÛ   rÛ   rŒ   rÛ   rü   rý   rÞ   rÞ   rÞ   r
  rø   rÔ   r  r  r   é*   r  r  r  é6   é9   é<   é?   éB   éF   éJ   éM   éQ   rŸ   c                ó   — | |z   dz  S ©Nrv   r»   ©rq   rr   s     r   ú<lambda>zQrCode.<lambda>q  ó   € �!�a‘%˜1‘€ r   c                ó   — |dz  S r  r»   r  s     r   r   zQrCode.<lambda>r  ó
   € ��Q‘€ r   c                ó   — | dz  S ©Nr&   r»   r  s     r   r   zQrCode.<lambda>s  r#  r   c                ó   — | |z   dz  S r%  r»   r  s     r   r   zQrCode.<lambda>t  r!  r   c                ó   — | dz  |dz  z   dz  S )Nr&   rv   r»   r  s     r   r   zQrCode.<lambda>u  s   € �!�q‘&˜1 ™6‘/ QÑ&€ r   c                ó$   — | |z  dz  | |z  dz  z   S ©Nrv   r&   r»   r  s     r   r   zQrCode.<lambda>v  s   € ��Q‘˜‘˜Q ™U Q™YÑ&€ r   c                ó*   — | |z  dz  | |z  dz  z   dz  S r)  r»   r  s     r   r   zQrCode.<lambda>w  s    € �!�a‘%˜!‘)˜a !™e a™iÑ'¨1Ñ,€ r   c                ó*   — | |z   dz  | |z  dz  z   dz  S r)  r»   r  s     r   r   zQrCode.<lambda>x  s    € �1�q‘5˜A‘+  A¡¨¡	Ñ)¨QÑ.€ r   z#Sequence[Callable[[int, int], int]]r·   c                  óT   — e Zd ZU ded<   ded<   	 d
d„Zd ed<   d ed<   d ed<   d ed<   y	)r   r   r    r…   c                ó    — || _         || _        y ©N)r    r…   )r]   rM   Úfbs      r   rd   zQrCode.Ecc.__init__„  s   € Ø€4„<Ø€4…?r   ÚLOWr/   r0   r1   N)rM   r   r/  r   ÚreturnÚNone)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__rd   r»   r   r   r.   z
QrCode.Ecc~  s.   … Øƒ,Øƒ/àBóð
 ÓØÓØÓØÔr   r.   r   rv   N)r   Ústrr   r   r1  r   )r   úUnion[bytes, Sequence[int]]r   r   r1  r   )r   r   r    T)r   úSequence[QrSegment]r   r   r@   r   rA   r   rB   r   rC   rœ   r1  r   )
rD   r   r^   r   rL   r8  r_   r   r1  r2  ©r1  r   )r1  r   )rq   r   rr   r   r1  rœ   )r1  r2  )rB   r   r1  r2  )rq   r   rr   r   r1  r2  )rq   r   rr   r   r�   rœ   r1  r2  )r   r>   r1  Úbytes)r   r;  r1  r2  ©r1  ú	List[int]©rØ   r   r1  r   )rØ   r   r   r   r1  r   )ræ   r   r1  r;  )r   r;  rê   r;  r1  r;  )rq   r   rr   r   r1  r   )rÏ   úcollections.dequer1  r   )ró   rœ   rô   r   rÏ   r?  r1  r   )rô   r   rÏ   r?  r1  r2  )0r3  r4  r5  Ú__doc__Ústaticmethodr   r   r   r6  rd   rg   rj   rm   ro   rs   rW   r[   r{   rx   rz   rw   rX   rY   rZ   r\   ry   r¢   r+   r£   r¤   rå   rÅ   rÇ   rÄ   r'   r(   rÃ   rÈ   rÆ   rÊ   r¡   rŸ   r·   r.   r0  r/   r0   r1   r»   r   r   r   r       s  … ñOð" ò+ó ð+ð òCó ðCð ó;3ó ð;3ðD ƒð 	ƒð Óð
 	ƒð Óð Óó
)ó\óóóóQóó45ó8(ó,LóJó ó"óJó.Pó<óB!ð òó ðð  ò;ó ð;ð òó ðð. òó ðð òó ðóPó9ó*ð €ˆcÓØ€ˆcÓð €ˆcÓØ€ˆcÓØ€ˆcÓØ€ˆcÓð6hÐÐ2ó hð:^ÐÐ6ó ^ñ ÙÙÙÙ&Ù&Ù,Ù.ð	6€Ð2ó 	÷ñ ñ" �A�q“	€„Ù�A�q“	€„Ù�A�q“	€„Ù�A�q“	€…r   r   c                  ó0  — e Zd ZU dZed)d„«       Zed*d„«       Zed+d„«       Zed,d„«       Zed-d„«       Z	ed.d„«       Z
ed.d	„«       Zd
ed<   ded<   ded<   d/d„Zd0d„Zd1d„Zd2d„Zed3d„«       Z ej&                  d«      Zded<    ej&                  d«      Zded<    ed«      D � ��ci c]  \  }}||“Œ
 c}}} Zded<    G d„ d«      Z edd«      e_         ed d!«      e_         ed"d#«      e_         ed$d%«      e_         ed&d'«      e_        y(c c}}} w )4r   ay  A segment of character/binary/control data in a QR Code symbol.
	Instances of this class are immutable.
	The mid-level way to create a segment is to take the payload data
	and call a static factory function such as QrSegment.make_numeric().
	The low-level way to create a segment is to custom-make the bit buffer
	and call the QrSegment() constructor with appropriate values.
	This segment class imposes no length restrictions, but QR Codes have restrictions.
	Even in the most favorable conditions, a QR Code can only hold 7089 characters of data.
	Any segment longer than this is meaningless for the purpose of generating QR Codes.c                ó¤   — t        «       }| D ]  }|j                  |d«       Œ t        t        j                  j                  t        | «      |«      S )zÛReturns a segment representing the given binary data encoded in byte mode.
		All input byte lists are acceptable. Any text string can be converted to
		UTF-8 bytes (s.encode("UTF-8")) and encoded as a byte mode segment.r"   )r2   r3   r   ÚModeÚBYTEr:   )r   rI   rŽ   s      r   r   zQrSegment.make_bytes¥  sE   € ô
 ƒ|€"Øò €aØ‡>�>�!�QÕðä	”9—>‘>×&Ñ&¬¨D«	°2Ó	6Ð6r   c                óx  — t         j                  | «      st        d«      ‚t        «       }d}|t	        | «      k  rSt        t	        | «      |z
  d«      }|j                  t        | |||z    «      |dz  dz   «       ||z  }|t	        | «      k  rŒSt        t         j                  j                  t	        | «      |«      S )zZReturns a segment representing the given string of decimal digits encoded in numeric mode.z&String contains non-numeric charactersr   r&   r   )
r   Ú
is_numericr)   r2   r:   r;   r3   r   rD  ÚNUMERIC)ÚdigitsrI   rM   rð   s       r   Úmake_numericzQrSegment.make_numeric°  s¤   € ô 
×	Ñ	˜fÔ	%Ü	Ð<Ó	=Ð=Üƒ|€"Ø€!Ø	ŒC�‹KŠÜ”�F“˜a‘ Ó#€1Ø‡>�>”#�f˜Q  Q¡Ð'Ó(¨!¨a©%°!©)Ô4Øˆ�6€1ð 	
ŒC�‹K‹ô 
”9—>‘>×)Ñ)¬3¨v«;¸Ó	;Ð;r   c                óê  — t         j                  | «      st        d«      ‚t        «       }t	        dt        | «      dz
  d«      D ]I  }t         j                  | |      dz  }|t         j                  | |dz         z  }|j                  |d«       ŒK t        | «      dz  dkD  r&|j                  t         j                  | d      d«       t        t         j                  j                  t        | «      |«      S )	zÙReturns a segment representing the given text string encoded in alphanumeric mode.
		The characters allowed are: 0 to 9, A to Z (uppercase only), space,
		dollar, percent, asterisk, plus, hyphen, period, slash, colon.z;String contains unencodable characters in alphanumeric moder   r   rv   r  r‹   r    ru   )
r   Úis_alphanumericr)   r2   r*   r:   Ú_ALPHANUMERIC_ENCODING_TABLEr3   rD  ÚALPHANUMERIC)r   rI   rM   Útemps       r   Úmake_alphanumericzQrSegment.make_alphanumeric¾  sÕ   € ô
 
×	"Ñ	" 4Ô	(Ü	ÐQÓ	RÐRÜƒ|€"Ü�”C˜“I ‘M 1Ó%ò €aÜ×5Ñ5°d¸1±gÑ>ÀÑC€4ØŒ9×1Ñ1°$°q¸1±u±+Ñ>Ñ>€4Ø‡>�>�$˜Õðô 	ˆƒY��]�QÒØ‡>�>”)×8Ñ8¸¸b¹ÑBÀAÔFÜ	”9—>‘>×.Ñ.´°D³	¸2Ó	>Ð>r   c                ó  — | dk(  rg S t         j                  | «      rt         j                  | «      gS t         j                  | «      rt         j	                  | «      gS t         j                  | j                  d«      «      gS )zÅReturns a new mutable list of zero or more segments to represent the given Unicode text string.
		The result may use various segment modes and switch modes to optimize the length of the bit stream.Ú zUTF-8)r   rG  rJ  rL  rP  r   Úencode©r   s    r   r   zQrSegment.make_segmentsÏ  sq   € ð 
ˆR‚ZØ
€9Ü×Ñ˜DÔ!Ü×!Ñ! $Ó'Ð
(Ð(Ü× Ñ  Ô&Ü×&Ñ& tÓ,Ð
-Ð-ä×Ñ §¡¨GÓ 4Ó5Ð
6Ð6r   r   c                ón  — t        «       }| dk  rt        d«      ‚| dk  r|j                  | d«       n_| dk  r%|j                  dd«       |j                  | d«       n5| dk  r%|j                  d	d
«       |j                  | d«       nt        d«      ‚t        t        j                  j
                  d|«      S )zuReturns a segment representing an Extended Channel Interpretation
		(ECI) designator with the given assignment value.r   z!ECI assignment value out of rangerÜ   r"   i @  rv   r„   i@B ru   r&   rý   )r2   r)   r3   r   rD  ÚECI)Ú	assignvalrI   s     r   Úmake_ecizQrSegment.make_eciß  s¡   € ô ƒ|€"Ø�‚]Ü	Ð7Ó	8Ð8Ø�FÒØ‡>�>�)˜QÕØ�GÒØ‡>�>�$˜ÔØ‡>�>�)˜RÕ Ø�7ÒØ‡>�>�%˜ÔØ‡>�>�)˜RÕ ä	Ð7Ó	8Ð8Ü	”9—>‘>×%Ñ% q¨"Ó	-Ð-r   c                óD   — t         j                  j                  | «      d uS r.  )r   Ú_NUMERIC_REGEXÚ	fullmatchrT  s    r   rG  zQrSegment.is_numericõ  s   € ä	×	!Ñ	!×	+Ñ	+¨DÓ	1¸Ð	=Ð=r   c                óD   — t         j                  j                  | «      d uS r.  )r   Ú_ALPHANUMERIC_REGEXr[  rT  s    r   rL  zQrSegment.is_alphanumericý  s   € ä	×	&Ñ	&×	0Ñ	0°Ó	6¸dÐ	BÐBr   úQrSegment.ModeÚ_modeÚ	_numcharsr=  r9   c                ó^   — |dk  r
t        «       ‚|| _        || _        t        |«      | _        y)zâCreates a new QR Code segment with the given attributes and data.
		The character count (numch) must agree with the mode and the bit buffer length,
		but the constraint isn't checked. The given bit buffer is cloned and stored.r   N)r)   r_  r`  rÖ   r9   )r]   ÚmodeÚnumchÚbitdatas       r   rd   zQrSegment.__init__  s,   € ð ˆQ‚YÜ	‹ÐØ€$„*Ø€$„.Ü�w“-€$…-r   c                ó   — | j                   S )z'Returns the mode field of this segment.)r_  rf   s    r   r4   zQrSegment.get_mode   rk   r   c                ó   — | j                   S )z2Returns the character count field of this segment.)r`  rf   s    r   r6   zQrSegment.get_num_chars$  s   € à	�‰Ðr   c                ó,   — t        | j                  «      S )z4Returns a new copy of the data bits of this segment.)rÖ   r9   rf   s    r   Úget_datazQrSegment.get_data(  s   € ä	ˆd�m‰mÓ	Ðr   c                óÂ   — d}| D ]W  }|j                  «       j                  |«      }|j                  «       d|z  k\  r y|d|z   t        |j                  «      z   z  }ŒY |S )zÝCalculates the number of bits needed to encode the given segments at
		the given version. Returns a non-negative number if successful. Otherwise
		returns None if a segment has too many characters to fit its length field.r   r   Nr#   )r4   r7   r6   r:   r9   )r   rD   r°   rJ   Úccbitss        r   r,   zQrSegment.get_total_bits.  si   € ð
 €&Øò ,€cØ—‘“×3Ñ3°GÓ<€6Ø	×ÑÓ˜a 6™kÒ*ÙØ	ˆQ�‰Zœ#˜cŸl™lÓ+Ñ+Ñ+�6ð	,ð
 
€-r   z[0-9]*z
re.PatternrZ  z[A-Z0-9 $%*+./:-]*r]  z-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:zDict[str, int]rM  c                  óp   — e Zd ZU dZded<   ded<   dd„Zdd„Zdd„Zd ed	<   d ed
<   d ed<   d ed<   d ed<   y)r^  z?Describes how a segment's data bits are interpreted. Immutable.r   Ú	_modebitsúTuple[int, int, int]Ú_charcountsc                ó    — || _         || _        y r.  )rl  rn  )r]   ÚmodebitsÚ
charcountss      r   rd   zQrSegment.Mode.__init__Q  s   € Ø€4„>Ø €4Õr   c                ó   — | j                   S )zrReturns an unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object.)rl  rf   s    r   r5   zQrSegment.Mode.get_mode_bitsV  s   € à
�.‰.Ðr   c                ó,   — | j                   |dz   dz     S )zžReturns the bit width of the character count field for a segment in this mode
			in a QR Code at the given version number. The result is in the range [0, 16].r!   r%   )rn  )r]   rØ   s     r   r7   z"QrSegment.Mode.num_char_count_bits[  s   € ð ×
Ñ
˜C !™G¨™?Ñ
+Ð+r   rH  rN  rE  ÚKANJIrV  N)rp  r   rq  rm  r:  r>  )r3  r4  r5  r@  r6  rd   r5   r7   r»   r   r   rD  zQrSegment.ModeJ  s?   … ÙGàƒ.Ø!Ó!ó!ó
ó
,ð ÓØÓØÓØÓØÔr   rD  r   )r�   rŠ   r„   rv   )r‚   r‹   rû   r#   )r"   rÛ   rÛ   r"   )r"   r�   rŠ   r!   )r   r   r   N)r   r8  r1  r   )rI  r7  r1  r   )r   r7  r1  r   )r   r7  r1  zList[QrSegment])rW  r   r1  r   )r   r7  r1  rœ   )rb  r^  rc  r   rd  zSequence[int]r1  r2  )r1  r^  r:  r<  )r   r9  rD   r   r1  zOptional[int])r3  r4  r5  r@  rA  r   rJ  rP  r   rX  rG  rL  r6  rd   r4   r6   rh  r,   ÚreÚcompilerZ  r]  r?   rM  rD  rH  rN  rE  rt  rV  )r¼   rM   Úchs   000r   r   r   ˜  s–  … ñXð ò7ó ð7ð ò
<ó ð
<ð ò?ó ð?ð  ò7ó ð7ð ò.ó ð.ð* ò>ó ð>ð òCó ðCð 	Óð ƒð Óó
 óóóð ò
ó ð
ð  )˜bŸj™j¨Ó3€�Ó3ð $. 2§:¡:Ð.CÓ#DÐ�jÓDñ FOÐO~ÓE÷  0Að  0A¹'¸1¸b°°A±ô  0AÐ˜}ó  A÷
ñ ñ< ˜#˜|Ó,€„Ù˜#˜|Ó,€ÔÙ˜#˜|Ó,€„Ù˜#˜|Ó,€„Ù˜#˜|Ó,€…ùôO 0As   Â)Dr   c                  ó   — e Zd ZdZdd„Zy)r2   zEAn appendable sequence of bits (0s and 1s). Mainly used by QrSegment.c                óŽ   ‡— |dk  s‰|z	  dk7  rt        d«      ‚| j                  ˆfd„t        t        |«      «      D «       «       y)zsAppends the given number of low-order bits of the given
		value to this buffer. Requires n >= 0 and 0 <= val < 2^n.r   zValue out of rangec              3  ó.   •K  — | ]  }‰|z	  d z  –— Œ y­w)r   Nr»   )r¼   rM   Úvals     €r   r¿   z)_BitBuffer.append_bits.<locals>.<genexpr>z  s   øè ø€ Ò; 1��q‘˜A�~Ñ;ùs   ƒN)r)   r8   r×   r*   )r]   r{  rð   s    ` r   r3   z_BitBuffer.append_bitsu  s=   ø€ ð ˆ!‚e�˜‘˜Q’Ü	Ð(Ó	)Ð)Ø‡+�+Ó;¬´°q³Ó(:Ô;Õ;r   N)r{  r   rð   r   r1  r2  )r3  r4  r5  r@  r3   r»   r   r   r2   r2   r  s
   „ ÙLô<r   r2   c                ó   — | |z	  dz  dk7  S )z/Returns true iff the i'th bit of x is set to 1.r   r   r»   )rq   rM   s     r   r†   r†   }  s   € à	
ˆa‰�1‰˜ÑÐr   c                  ó   — e Zd ZdZy)r-   a×  Raised when the supplied data does not fit any QR Code version. Ways to handle this exception include:
	- Decrease the error correction level if it was greater than Ecc.LOW.
	- If the encode_segments() function was called with a maxversion argument, then increase
	  it if it was less than QrCode.MAX_VERSION. (This advice does not apply to the other
	  factory functions because they search all versions up to QrCode.MAX_VERSION.)
	- Split the text data into better or optimal segments in order to reduce the number of bits required.
	- Change the text or binary data to be shorter.
	- Change the text to fit the character set of a particular segment mode (e.g. alphanumeric).
	- Propagate the error upward to the caller/user.N)r3  r4  r5  r@  r»   r   r   r-   r-   ƒ  s   „ ñ5ð r   r-   )rq   r   rM   r   r1  rœ   )Ú
__future__r   rÁ   r<   ru  Úcollections.abcr   Útypingr   r   r   r   r	   r
   r   r   rÖ   r2   r†   r)   r-   r»   r   r   ú<module>r�     sP   ðõ0 #ß !Ó !Ý $ß ?× ?÷
r	ñ r	÷pT-ñ T-ôt<�ô <óô
�zõ 
r   