
    _}dg                     4    d Z ddlZddlmZ d ZddZd	dZdS )
z&
Helpers for dealing with HTML input.
    N)MultiValueDictc                 "    t          | d          S )Ngetlist)hasattr)
dictionarys    X/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/rest_framework/utils/html.pyis_html_inputr	   	   s     :y)))     c                   	 i 	t          j        dt          j        |          z            }|                                 D ]\  }}|                    |          }|s|                                \  }}t          |          }|s|	|<   Kt          	                    |          t                    r|	|         |<   t          ||gi          	|<   	r	fdt          	          D             n|S )ad  
    Used to support list values in HTML forms.
    Supports lists of primitives and/or dictionaries.

    * List of primitives.

    {
        '[0]': 'abc',
        '[1]': 'def',
        '[2]': 'hij'
    }
        -->
    [
        'abc',
        'def',
        'hij'
    ]

    * List of dictionaries.

    {
        '[0]foo': 'abc',
        '[0]bar': 'def',
        '[1]foo': 'hij',
        '[1]bar': 'klm',
    }
        -->
    [
        {'foo': 'abc', 'bar': 'def'},
        {'foo': 'hij', 'bar': 'klm'}
    ]

    :returns a list of objects, or the value specified in ``default`` if the list is empty
    z^%s\[([0-9]+)\](.*)$c                      g | ]
}|         S  r   ).0itemrets     r   
<listcomp>z#parse_html_list.<locals>.<listcomp>B   s    ...$CI...r
   )recompileescapeitemsmatchgroupsint
isinstancegetdictr   sorted)
r   prefixdefaultregexfieldvaluer   indexkeyr   s
            @r   parse_html_listr%      s   F CJ.61B1BBCCE"((** 8 8uE"" 	\\^^
sE

 	8CJJ-- 	8#CJsOO'ug77CJJ 36B....&++....7Br
   c                 8   t                      }t          j        dt          j        |          z            }| D ]_}|                    |          }|s|                                d         }|                     |          }|                    ||           `|S )a#  
    Used to support dictionary values in HTML forms.

    {
        'profile.username': 'example',
        'profile.email': 'example@example.com',
    }
        -->
    {
        'profile': {
            'username': 'example',
            'email': 'example@example.com'
        }
    }
    z
^%s\.(.+)$r   )r   r   r   r   r   r   r   setlist)r   r   r   r    r!   r   r$   r"   s           r   parse_html_dictr(   E   s      

CJ}ry'8'8899E    E"" 	llnnQ""5))CJr
   )r   N)r   )__doc__r   django.utils.datastructuresr   r	   r%   r(   r   r
   r   <module>r+      sr     
			 6 6 6 6 6 6* * *3C 3C 3C 3Cl     r
   