o
    no™iº	  ã                   @   st   d dl mZ d dl mZ d dl mZ d dlmZ dededee fdd	„Z	ded
ee dededee f
dd„Z
dS )é    )ÚDIRECT_DICT©ÚNUMBER_SCALE_DICT)ÚVARIATIONS_DICT)ÚcombineÚ
number_strÚ
number_lenÚreturnc                 C   sÜ   g }g }t | ƒdkrO|  d¡rO| t ¡ v r"|dkr"| t|  d ¡ | d t| d  td  ¡¡ | d tv rF| dd„ t| d  D ƒ¡ | dd…  d¡} | ri| t 	| g ¡d ¡ | tv rg| t|  ¡nd t
||ƒS )	zî
    Convert a number to its text representation.

    Args:
        number_str (str): The number to convert.
        number_len (int): The length of the number.

    Returns:
        list[str]: The text representation of the number.
    é   Ú0r   Ú c                 S   s   g | ]
}|t d  d  ‘qS )r   r   r   )Ú.0Ú	variation© r   úQ/home/ubuntu/.local/lib/python3.10/site-packages/indic_numtowords/brx/cardinal.pyÚ
<listcomp>   s    z#convert_to_text.<locals>.<listcomp>é   N)ÚlenÚlstripr   ÚkeysÚappendÚjoinr   r   ÚextendÚgetr   )r   r   ÚhundredsÚonesr   r   r   Úconvert_to_text   s    €
r   ÚtextsÚindexc                 C   s¬   t | tƒr
t |tƒstdƒ‚| dv r|S |dkr$| dkr$tt| |ƒ|ƒS t|  d¡ƒdks1|dkr3dnd}|dkrAt|  d¡|ƒntt|  d¡|ƒtt|ƒ |ƒ}t||ƒS )aá  
    Convert a number string to its text representation and append it to a list.

    Args:
        number_str (str): The number string to process.
        texts (list[str]): A list of texts to update with the converted number.
        index (int): The position of the number in the sequence, affecting scaling.
        number_len (int): The total length of the original number.

    Returns:
        list[str]: The updated list with the number's text representation appended.
    zInvalid input type>   Ú00Ú000r   r   é   ú r   )	Ú
isinstanceÚstrÚintÚ
ValueErrorr   r   r   r   r   )r   r   r   r   ÚsepÚconverted_textr   r   r   Úprocess_text'   s   "8
r)   N)Úindic_numtowords.brx.data.numsr   r   r   Úindic_numtowords.brx.utilsr   r$   r%   Úlistr   r)   r   r   r   r   Ú<module>   s    *!