
'''simple docstring'''



from typing import List

from .keymap import KEYMAP, get_character


def A (__lowerCamelCase :str						):

						def decorator(__lowerCamelCase :Optional[int]						):
												_lowerCAmelCase    		=					getattr(__lowerCamelCase					,      """handle_key"""					,      []						)
												handle += [key]
												setattr(__lowerCamelCase					,      """handle_key"""					,      __lowerCamelCase						)
												return func

						return decorator


def A (*__lowerCamelCase :List[str]						):

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

						return decorator




class     UpperCAmelCase_	(						_SCREAMING_SNAKE_CASE					):






						'''simple docstring'''






						def __new__(   cls       ,  _lowercase       ,  _lowercase       ,  _lowercase ):

												"""simple docstring"""



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

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




						@staticmethod
						def    _lowercase      (   cls ):

												"""simple docstring"""



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






def A (cls :Any						):
						return KeyHandler(cls.__name__					,      cls.__bases__					,      cls.__dict__.copy()						)

"""simple docstring"""


from .imports import is_rich_available


if is_rich_available():
	from rich.traceback import install

	install(show_locals=False)

else:
	raise ModuleNotFoundError('To use the rich extension, install rich with `pip install rich`')


