
"""simple docstring"""
from __future__ import annotations

def  lowercase     (_lowerCAmelCase ,    _lowerCAmelCase = None ,    _lowerCAmelCase = None						):
						if start is None:
												__lowerCAmelCase     =  0

						if end is None:
												__lowerCAmelCase     =  len(_lowerCAmelCase						) - 1

						if start >= end:
												return

						__lowerCAmelCase     =  (start + end) // 2

						slowsort(_lowerCAmelCase ,    _lowerCAmelCase ,    _lowerCAmelCase						)
						slowsort(_lowerCAmelCase ,    mid + 1 ,    _lowerCAmelCase						)

						if sequence[end] < sequence[mid]:
												__lowerCAmelCase   ,     __lowerCAmelCase     =  sequence[mid], sequence[end]

						slowsort(_lowerCAmelCase ,    _lowerCAmelCase ,    end - 1						)


if __name__ == "__main__":
			from doctest import testmod

			testmod()


"""simple docstring"""
from typing import List

from .keymap import KEYMAP, get_character

def  lowercase     (_lowerCAmelCase						):

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

						return decorator

def  lowercase     (*_lowerCAmelCase						):

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

						return decorator
class       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							def __new__( cls    ,				snake_case_    ,				snake_case_    ,				snake_case_				)       ->  Any:
													__lowerCAmelCase     =  super().__new__(cls    ,				snake_case_    ,				snake_case_    ,				snake_case_				)
													if not hasattr(snake_case_    ,				"""key_handler"""				):
																			setattr(snake_case_    ,				"""key_handler"""    ,				{}				)
													setattr(snake_case_    ,				"""handle_input"""    ,				KeyHandler.handle_input				)

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




							@staticmethod
							def    A__						( cls				)       ->  Tuple:
													__lowerCAmelCase     =  get_character()
													if char != KEYMAP["undefined"]:
																			__lowerCAmelCase     =  ord(snake_case_				)
													__lowerCAmelCase     =  cls.key_handler.get(snake_case_				)
													if handler:
																			__lowerCAmelCase     =  char
																			return handler(cls				)
													else:
																			return None

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