# Path: ui/stack/stack.py
# def stack(self, dimension, other, spacing = 0):
#   if self._backend.stacks():
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = spacing
#     coords = list(self._coords)
#     for i in range(len(coords)):
#       if i == dimension:
#         coords[i] += spacing + other._coords[i]
#       else:
#         coords[i] = max(coords[i], other._coords[i])
#     return Stack(coords, self._backend.stack(dimension, other._backend.shift(offset)))
#   else:
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = self.widths()[dimension] + spacing
#     return self.below(other.shift(offset))
# 
# Path: ui/stack/text.py
# class TextBackend(stack.Backend):
#   def __init__(self, strings):
#     self.strings = strings
#     if len(strings) > 0:
#       m = len(strings[0])
#       for s in strings:
#         assert(m == len(s))
# 
#   def stacks(self):
#     return True
# 
#   def uses_epsilon(self):
#     return False
# 
#   def stack(self, dimension, other):
#     if dimension == 0:
#       length = max(len(self.strings), len(other.strings))
#       self_strings = vextend(self.strings, length)
#       other_strings = vextend(other.strings, length)
#       for i in range(length):
#         self_strings[i] += other_strings[i]
#       return TextBackend(self_strings)
#     else:
#       assert(dimension == 1)
#       length = 0
#       if len(self.strings) > 0:
#         length = len(self.strings[0])
#       if len(other.strings) > 0:
#         length = max(length, len(other.strings[0]))
#       self_strings = hextend(self.strings, length)
#       other_strings = hextend(other.strings, length)
#       other_strings.extend(self_strings)
#       return TextBackend(other_strings)
# 
#   def below(self, other):
#     length = max(len(self.strings), len(other.strings))
#     self_strings = vextend(self.strings, length)
#     other_strings = vextend(other.strings, length)
# 
#     for i in range(len(self_strings)):
#       string = self_strings[i]
#       other_string = other_strings[i]
#       if len(string) >= len(other_string):
#         self_strings[i] = string
#       else:
#         self_strings[i] = string + other_string[len(string):]
#     return TextBackend(self_strings)
# 
#   # return: a new backend object in which self is draw transposed
#   def flip(self):
#     raise Exception("Abstract superclass.")
# 
#   # offset: a list of coordinates, meant to serve as a translation of other.
#   # return: a new backend object like self, but shifted by offset.
#   def shift(self, offset):
#     assert(len(offset) == 2 or offset[2] == 0)
#     strings = list(self.strings)
#     m = 0
#     if len(strings) > 0:
#       m = len(strings[0])
#     for i in range(offset[1]):
#       strings.append(blank * m)
#     strings = [blank * offset[0] + s for s in strings]
#     return TextBackend(strings)
# 
#   def __repr__(self):
#     return '\n'.join(self.strings)
# 
# Path: ui/render/text/colors.py
# def productPairsColor(i):
# def exponentialColor(isAlways):
# 
# Path: ui/render/text/distances.py



from ui.stack import stack
from ui.stack.text import TextBackend
from ui.render.text import colors, distances

def surroundWithNot(s):
  return negationStack.stack(0, s)

def solidSquare(color, widths):
  return stack.Stack(widths, TextBackend([' ' * widths[1] for i in range(widths[0])]))

def identical(covariant):
  if covariant:
    s = ' == '
  else:
    s = ' != '
  return newTextStack(None, s)

def iff():
  return newTextStack(None, " <==> ")

def _dimension_for_variance(covariant):
  if covariant:
    return 0
  else:
    return 1

def _dual_dimension(dimension):
  if dimension == 0:
    return 1
  else:
    assert(dimension == 1)
    return 0


# Path: ui/stack/stack.py
# def stack(self, dimension, other, spacing = 0):
#   if self._backend.stacks():
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = spacing
#     coords = list(self._coords)
#     for i in range(len(coords)):
#       if i == dimension:
#         coords[i] += spacing + other._coords[i]
#       else:
#         coords[i] = max(coords[i], other._coords[i])
#     return Stack(coords, self._backend.stack(dimension, other._backend.shift(offset)))
#   else:
#     offset = [0 for i in range(self.dimension())]
#     offset[dimension] = self.widths()[dimension] + spacing
#     return self.below(other.shift(offset))
# 
# Path: ui/stack/text.py
# class TextBackend(stack.Backend):
#   def __init__(self, strings):
#     self.strings = strings
#     if len(strings) > 0:
#       m = len(strings[0])
#       for s in strings:
#         assert(m == len(s))
# 
#   def stacks(self):
#     return True
# 
#   def uses_epsilon(self):
#     return False
# 
#   def stack(self, dimension, other):
#     if dimension == 0:
#       length = max(len(self.strings), len(other.strings))
#       self_strings = vextend(self.strings, length)
#       other_strings = vextend(other.strings, length)
#       for i in range(length):
#         self_strings[i] += other_strings[i]
#       return TextBackend(self_strings)
#     else:
#       assert(dimension == 1)
#       length = 0
#       if len(self.strings) > 0:
#         length = len(self.strings[0])
#       if len(other.strings) > 0:
#         length = max(length, len(other.strings[0]))
#       self_strings = hextend(self.strings, length)
#       other_strings = hextend(other.strings, length)
#       other_strings.extend(self_strings)
#       return TextBackend(other_strings)
# 
#   def below(self, other):
#     length = max(len(self.strings), len(other.strings))
#     self_strings = vextend(self.strings, length)
#     other_strings = vextend(other.strings, length)
# 
#     for i in range(len(self_strings)):
#       string = self_strings[i]
#       other_string = other_strings[i]
#       if len(string) >= len(other_string):
#         self_strings[i] = string
#       else:
#         self_strings[i] = string + other_string[len(string):]
#     return TextBackend(self_strings)
# 
#   # return: a new backend object in which self is draw transposed
#   def flip(self):
#     raise Exception("Abstract superclass.")
# 
#   # offset: a list of coordinates, meant to serve as a translation of other.
#   # return: a new backend object like self, but shifted by offset.
#   def shift(self, offset):
#     assert(len(offset) == 2 or offset[2] == 0)
#     strings = list(self.strings)
#     m = 0
#     if len(strings) > 0:
#       m = len(strings[0])
#     for i in range(offset[1]):
#       strings.append(blank * m)
#     strings = [blank * offset[0] + s for s in strings]
#     return TextBackend(strings)
# 
#   def __repr__(self):
#     return '\n'.join(self.strings)
# 
# Path: ui/render/text/colors.py
# def productPairsColor(i):
# def exponentialColor(isAlways):
# 
# Path: ui/render/text/distances.py



# Path: ui/render/text/primitives.py
from ui.stack import stack
from ui.stack.text import TextBackend
from ui.render.text import colors, distances


def surroundWithNot(s):
  return negationStack.stack(0, s)

def solidSquare(color, widths):
  return stack.Stack(widths, TextBackend([' ' * widths[1] for i in range(widths[0])]))

def identical(covariant):
  if covariant:
    s = ' == '
  else:
    s = ' != '
  return newTextStack(None, s)

def iff():
  return newTextStack(None, " <==> ")

def _dimension_for_variance(covariant):
  if covariant:
    return 0
  else:
    return 1

def _dual_dimension(dimension):
  if dimension == 0:
    return 1
  else:
    assert(dimension == 1)
    return 0


def andDivider(covariant):