





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


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


@input.register
class 					__a      :

							def __init__(							self							:     str       ,     __magic_name__							:     str = None       ,     __magic_name__							:     list = []   )					->       Dict:







													"""simple docstring"""
													UpperCAmelCase_			:      Dict     						=  0
													UpperCAmelCase_			:      List[str]     						=  choices
													UpperCAmelCase_			:      Any     						=  prompt
													if sys.platform == "win32":
																			UpperCAmelCase_			:      List[Any]     						=  '''*'''
													else:
																			UpperCAmelCase_			:      List[Any]     						=  '''➔ '''

							def     UpperCAmelCase__	(							self							:     Tuple       ,     __magic_name__							:     Any       ,     __magic_name__							:     str = ""   )					->       Tuple:







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

							def     UpperCAmelCase__	(							self							:     Dict       ,     __magic_name__							:     int   )					->       str:







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

							def     UpperCAmelCase__	(							self							:     str       ,     __magic_name__							:     Direction       ,     __magic_name__							:     int = 1   )					->       Tuple:







													"""simple docstring"""
													UpperCAmelCase_			:      Optional[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(__magic_name__   )
													move_cursor(__magic_name__       ,     direction.name   )
													self.print_choice(self.position   )

							@input.mark(KEYMAP['''up''']   )
							def     UpperCAmelCase__	(							self							:     Tuple   )					->       Tuple:







													"""simple docstring"""
													self.move_direction(Direction.UP   )

							@input.mark(KEYMAP['''down''']   )
							def     UpperCAmelCase__	(							self							:     str   )					->       Tuple:







													"""simple docstring"""
													self.move_direction(Direction.DOWN   )

							@input.mark(KEYMAP['''newline''']   )
							def     UpperCAmelCase__	(							self							:     Dict   )					->       Optional[Any]:







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

							@input.mark(KEYMAP['''interrupt''']   )
							def     UpperCAmelCase__	(							self							:     Optional[int]   )					->       Optional[int]:







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

							@input.mark_multiple(*[KEYMAP[str(__magic_name__   )] for number in range(10   )]   )
							def     UpperCAmelCase__	(							self							:     str   )					->       List[Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      Any     						=  int(chr(self.current_selection   )   )
													UpperCAmelCase_			:      List[str]     						=  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       ,     __magic_name__   )
																			else:
																									return
													else:
																			return



							def     UpperCAmelCase__	(							self							:     Any       ,     __magic_name__							:     int = 0   )					->       Union[str, Any]:







													"""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'''   )
													UpperCAmelCase_			:      Tuple     						=  default_choice
													for i in range(len(self.choices   )   ):
																			self.print_choice(__magic_name__   )
																			forceWrite('''\n'''   )
													move_cursor(len(self.choices   ) - self.position       ,     '''UP'''   )
													with cursor.hide():
																			while True:
																									if in_colab:
																															try:
																																					UpperCAmelCase_			:      int     						=  int(builtins.input()   )
																															except ValueError:
																																					UpperCAmelCase_			:      Tuple     						=  default_choice
																									else:
																															UpperCAmelCase_			:      Dict     						=  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(__magic_name__       ,     '''\n'''   )
																															return choice












'''simple docstring'''







import sys
import turtle





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			tuple[float, float],			SCREAMING_SNAKE_CASE__      :			tuple[float, float]   ) ->	tuple[float, float]:
						return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2





def        lowerCamelCase_      (  SCREAMING_SNAKE_CASE__      :			tuple[float, float],			SCREAMING_SNAKE_CASE__      :			tuple[float, float],			SCREAMING_SNAKE_CASE__      :			tuple[float, float],			SCREAMING_SNAKE_CASE__      :			int,			) ->	None:
						my_pen.up()
						my_pen.goto(vertexa[0],			vertexa[1]   )
						my_pen.down()
						my_pen.goto(vertexa[0],			vertexa[1]   )
						my_pen.goto(vertexa[0],			vertexa[1]   )
						my_pen.goto(vertexa[0],			vertexa[1]   )

						if depth == 0:
												return

						triangle(SCREAMING_SNAKE_CASE__,			get_mid(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   ),			get_mid(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   ),			depth - 1   )
						triangle(SCREAMING_SNAKE_CASE__,			get_mid(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   ),			get_mid(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   ),			depth - 1   )
						triangle(SCREAMING_SNAKE_CASE__,			get_mid(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   ),			get_mid(SCREAMING_SNAKE_CASE__,			SCREAMING_SNAKE_CASE__   ),			depth - 1   )


if __name__ == "__main__":
					if len(sys.argv) != 2:
										raise ValueError(
										    "Correct format for using this script: "
										    "python fractals.py <int:depth_for_fractal>"
										)
					snake_case_     :       Any						=  turtle.Turtle()
					my_pen.ht()
					my_pen.speed(5)
					my_pen.pencolor("red")

					snake_case_     :       Tuple						=  [(-1_75, -1_25), (0, 1_75), (1_75, -1_25)]  # vertices of triangle
					triangle(vertices[0], vertices[1], vertices[2], int(sys.argv[1]))





