


"""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


snake_case__						:   Dict			 = False
try:
 snake_case__						:   Any			 = _is_package_available('''google.colab''')
except ModuleNotFoundError:
 pass



@input.register
class 						snake_case_:






     def __init__(		self     :    List[Any]    , UpperCamelCase_     :    str = None    , UpperCamelCase_     :    list = [] ):
           lowerCAmelCase    :		Union[str, Any]				=      0
           lowerCAmelCase    :		str				=      choices
           lowerCAmelCase    :		Any				=      prompt
           if sys.platform == "win32":
                 lowerCAmelCase    :		Optional[Any]				=      '''*'''
           else:
                 lowerCAmelCase    :		List[str]				=      '''➔ '''






     def    lowerCamelCase__   (		self     :    int    , UpperCamelCase_     :    Union[str, Any]    , UpperCamelCase_     :    str = "" ):
           if sys.platform != "win32":
                 writeColor(self.choices[index]    , 3_2    , UpperCamelCase_ )
           else:
                 forceWrite(self.choices[index]    , UpperCamelCase_ )






     def    lowerCamelCase__   (		self     :    Any    , UpperCamelCase_     :    int ):
           if index == self.position:
                 forceWrite(F''' {self.arrow_char} ''' )
                 self.write_choice(UpperCamelCase_ )
           else:
                 forceWrite(F'''    {self.choices[index]}''' )
           reset_cursor()






     def    lowerCamelCase__   (		self     :    Any    , UpperCamelCase_     :    Direction    , UpperCamelCase_     :    int = 1 ):
           lowerCAmelCase    :		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(UpperCamelCase_ )
           move_cursor(UpperCamelCase_    , direction.name )
           self.print_choice(self.position )






     @input.mark(KEYMAP['''up'''] )
     def    lowerCamelCase__   (		self     :    Dict ):
           self.move_direction(Direction.UP )






     @input.mark(KEYMAP['''down'''] )
     def    lowerCamelCase__   (		self     :    List[Any] ):
           self.move_direction(Direction.DOWN )






     @input.mark(KEYMAP['''newline'''] )
     def    lowerCamelCase__   (		self     :    List[str] ):
           move_cursor(len(self.choices ) - self.position    , '''DOWN''' )
           return self.position






     @input.mark(KEYMAP['''interrupt'''] )
     def    lowerCamelCase__   (		self     :    Optional[Any] ):
           move_cursor(len(self.choices ) - self.position    , '''DOWN''' )
           raise KeyboardInterrupt






     @input.mark_multiple(*[KEYMAP[str(UpperCamelCase_ )] for number in range(1_0 )] )
     def    lowerCamelCase__   (		self     :    Optional[int] ):
           lowerCAmelCase    :		List[Any]				=      int(chr(self.current_selection ) )
           lowerCAmelCase    :		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    , UpperCamelCase_ )
                 else:
                       return
           else:
                 return






     def    lowerCamelCase__   (		self     :    Dict    , UpperCamelCase_     :    int = 0 ):
           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''' )
           lowerCAmelCase    :		Tuple				=      default_choice
           for i in range(len(self.choices ) ):
                 self.print_choice(UpperCamelCase_ )
                 forceWrite('''\n''' )
           move_cursor(len(self.choices ) - self.position    , '''UP''' )
           with cursor.hide():
                 while True:
                       if in_colab:
                             try:
                                   lowerCAmelCase    :		List[str]				=      int(builtins.input() )
                             except ValueError:
                                   lowerCAmelCase    :		Optional[int]				=      default_choice
                       else:
                             lowerCAmelCase    :		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(UpperCamelCase_    , '''\n''' )
                             return choice






"""simple docstring"""





import numpy as np


def    _snake_case  (  _snake_case :	np.array	):
      return 1 / (1 + np.exp(-vector	))


if __name__ == "__main__":
 import doctest

 doctest.testmod()


