




'''simple docstring'''





from typing import List

from .keymap import KEYMAP, get_character


def      UpperCamelCase_(	snake_case							:       str     ):

							'''simple docstring'''






							def decorator(snake_case							:       List[str]     ):
														snake_case_						=      getattr(snake_case							,				"handle_key"							,				[]     )
														handle += [key]
														setattr(snake_case							,				"handle_key"							,				snake_case     )
														return func

							return decorator


def      UpperCamelCase_(	*snake_case							:       List[str]     ):

							'''simple docstring'''






							def decorator(snake_case							:       Optional[Any]     ):
														snake_case_						=      getattr(snake_case							,				"handle_key"							,				[]     )
														handle += keys
														setattr(snake_case							,				"handle_key"							,				snake_case     )
														return func

							return decorator




class  _snake_case		(	lowercase_							):




			def __new__(					cls				,							a__				,							a__				,							a__							)				->				str:

										'''simple docstring'''




										snake_case_						=      super().__new__(cls				,							a__				,							a__				,							a__							)
										if not hasattr(a__				,							"key_handler"							):
																	setattr(a__				,							"key_handler"				,							{}							)
										setattr(a__				,							"handle_input"				,							KeyHandler.handle_input							)

										for value in attrs.values():
																	snake_case_						=      getattr(a__				,							"handle_key"				,							[]							)
																	for key in handled_keys:
																								snake_case_						=      value
										return new_cls




			@staticmethod
			def    lowerCAmelCase__				(					cls							)				->				List[str]:

										'''simple docstring'''




										snake_case_						=      get_character()
										if char != KEYMAP["undefined"]:
																	snake_case_						=      ord(a__							)
										snake_case_						=      cls.key_handler.get(a__							)
										if handler:
																	snake_case_						=      char
																	return handler(cls							)
										else:
																	return None


def      UpperCamelCase_(	cls							:       int     ):

							'''simple docstring'''






							return KeyHandler(cls.__name__							,				cls.__bases__							,				cls.__dict__.copy()     )








def 							__lowercase   ( __lowerCAmelCase							:				list[int]   ):
							a__             =     []
							if len(__lowerCAmelCase   ) == 1:
														return [nums.copy()]
							for _ in range(len(__lowerCAmelCase   )   ):
														a__             =     nums.pop(0   )
														a__             =     permute(__lowerCAmelCase   )
														for perm in permutations:
																					perm.append(__lowerCAmelCase   )
														result.extend(__lowerCAmelCase   )
														nums.append(__lowerCAmelCase   )
							return result






def 							__lowercase   ( __lowerCAmelCase							:				Optional[int]   ):

							def backtrack(__lowerCAmelCase							:				Any   ):
														if start == len(__lowerCAmelCase   ) - 1:
																					output.append(nums[:]   )
														else:
																					for i in range(__lowerCAmelCase					,    len(__lowerCAmelCase   )   ):
																												a__      ,					a__             =     nums[i], nums[start]
																												backtrack(start + 1   )
																												a__      ,					a__             =     nums[i], nums[start]  # backtrack

							a__             =     []
							backtrack(0   )
							return output


if __name__ == "__main__":
						import doctest

						# use res to print the data in permute2 function
						snake_case							:       Optional[Any]     			=      permutea([1, 2, 3])
						print(res)
						doctest.testmod()




