




"""simple docstring"""

import builtins
import sys

from ...utils.imports import _is_package_available
from . import cursor, input
from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
from .keymap import KEYMAP


_lowerCamelCase  :			Any        =       False
try:
		_lowerCamelCase  :			Optional[int]        =       _is_package_available('google.colab')
except ModuleNotFoundError:
		pass

@input.register
class        lowercase      :







				def __init__(							self   :					Optional[int]      ,     _lowerCamelCase   :					str = None      ,     _lowerCamelCase   :					list = []       ):



					"""simple docstring"""

					A_  :				Tuple	   =		0
					A_  :				Tuple	   =		choices
					A_  :				Dict	   =		prompt
					if sys.platform == "win32":
						A_  :				Tuple	   =		'''*'''
					else:
						A_  :				int	   =		'''➔ '''







				def 					a_  (							self   :					Tuple      ,     _lowerCamelCase   :					Any      ,     _lowerCamelCase   :					str = ""       ):



					"""simple docstring"""

					if sys.platform != "win32":
						writeColor(self.choices[index]      ,     32      ,     _lowerCamelCase       )
					else:
						forceWrite(self.choices[index]      ,     _lowerCamelCase       )







				def 					a_  (							self   :					Optional[int]      ,     _lowerCamelCase   :					int       ):



					"""simple docstring"""

					if index == self.position:
						forceWrite(F""" {self.arrow_char} """       )
						self.write_choice(_lowerCamelCase       )
					else:
						forceWrite(F"""    {self.choices[index]}"""       )
					reset_cursor()







				def 					a_  (							self   :					Dict      ,     _lowerCamelCase   :					Direction      ,     _lowerCamelCase   :					int = 1       ):



					"""simple docstring"""

					A_  :				int	   =		self.position
					if direction == Direction.DOWN:
						if self.position + 1 >= len(self.choices       ):
							return
						self.position += num_spaces
					else:
						if self.position - 1 < 0:
							return
						self.position -= num_spaces
					clear_line()
					self.print_choice(_lowerCamelCase       )
					move_cursor(_lowerCamelCase      ,     direction.name       )
					self.print_choice(self.position       )







				@input.mark(KEYMAP['''up''']       )
				def 					a_  (							self   :					str       ):



					"""simple docstring"""

					self.move_direction(Direction.UP       )







				@input.mark(KEYMAP['''down''']       )
				def 					a_  (							self   :					List[Any]       ):



					"""simple docstring"""

					self.move_direction(Direction.DOWN       )







				@input.mark(KEYMAP['''newline''']       )
				def 					a_  (							self   :					Dict       ):



					"""simple docstring"""

					move_cursor(len(self.choices       ) - self.position      ,     '''DOWN'''       )
					return self.position







				@input.mark(KEYMAP['''interrupt''']       )
				def 					a_  (							self   :					Optional[Any]       ):



					"""simple docstring"""

					move_cursor(len(self.choices       ) - self.position      ,     '''DOWN'''       )
					raise KeyboardInterrupt







				@input.mark_multiple(*[KEYMAP[str(_lowerCamelCase       )] for number in range(10       )]       )
				def 					a_  (							self   :					Any       ):



					"""simple docstring"""

					A_  :				List[str]	   =		int(chr(self.current_selection       )       )
					A_  :				Union[str, Any]	   =		index - self.position
					if index == self.position:
						return
					if index < len(self.choices       ):
						if self.position > index:
							self.move_direction(Direction.UP      ,     -movement       )
						elif self.position < index:
							self.move_direction(Direction.DOWN      ,     _lowerCamelCase       )
						else:
							return
					else:
						return







				def 					a_  (							self   :					Optional[int]      ,     _lowerCamelCase   :					int = 0       ):



					"""simple docstring"""

					if self.prompt:
						linebreak()
						forceWrite(self.prompt      ,     '''\n'''       )
						if in_colab:
							forceWrite('''Please input a choice index (starting from 0), and press enter'''      ,     '''\n'''       )
						else:
							forceWrite('''Please select a choice using the arrow or number keys, and selecting with enter'''      ,     '''\n'''       )
					A_  :				str	   =		default_choice
					for i in range(len(self.choices       )       ):
						self.print_choice(_lowerCamelCase       )
						forceWrite('''\n'''       )
					move_cursor(len(self.choices       ) - self.position      ,     '''UP'''       )
					with cursor.hide():
						while True:
							if in_colab:
								try:
									A_  :				str	   =		int(builtins.input()       )
								except ValueError:
									A_  :				List[str]	   =		default_choice
							else:
								A_  :				Tuple	   =		self.handle_input()
							if choice is not None:
								reset_cursor()
								for _ in range(len(self.choices       ) + 1       ):
									move_cursor(1      ,     '''UP'''       )
									clear_line()
								self.write_choice(_lowerCamelCase      ,     '''\n'''       )
								return choice











"""simple docstring"""

# Function to print upper half of diamond (pyramid)

def 		lowercase_      (		_UpperCAmelCase	):




	"""simple docstring"""






	for i in range(0  ,      _UpperCAmelCase	):
		for _ in range(0  ,      n - i - 1	):  # printing spaces
			print(''' '''  ,      end=''''''	)
		for _ in range(0  ,      i + 1	):  # printing stars
			print('''* '''  ,      end=''''''	)
		print()

def 		lowercase_      (		_UpperCAmelCase	):




	"""simple docstring"""






	for i in range(_UpperCAmelCase  ,      0  ,      -1	):
		for _ in range(_UpperCAmelCase  ,      0  ,      -1	):  # printing stars
			print('''* '''  ,      end=''''''	)
		print()
		for _ in range(n - i + 1  ,      0  ,      -1	):  # printing spaces
			print(''' '''  ,      end=''''''	)

def 		lowercase_      (		_UpperCAmelCase	):




	"""simple docstring"""






	if n <= 0:
		print('''       ...       ....        nothing printing :('''	)
		return
	floyd(_UpperCAmelCase	)  # upper half
	reverse_floyd(_UpperCAmelCase	)  # lower half


if __name__ == "__main__":
		print(r'| /\ | |- |  |-  |--| |\  /| |-')
		print(r'|/  \| |- |_ |_  |__| | \/ | |_')
		_lowerCamelCase  :			Tuple        =       1
		while K:
				_lowerCamelCase  :			Optional[int]        =       int(input('enter the number and , and see the magic : '))
				print()
				pretty_print(user_number)
				_lowerCamelCase  :			Optional[Any]        =       int(input('press 0 to exit... and 1 to continue...'))

		print('Good Bye...')





