docs: def _solve(self):
          """
          Calculates the correct position of the port and keeps it aligned with the binding rect
          """
  
          # As the size of the containing state may has changed we need to update the distance to the border
          self.update_distance_to_border()
          px, py = self._point
          nw_x, nw_y, se_x, se_y = self.get_adjusted_border_positions()
  
          # If the port is located in one of the corners it is possible to move in two directions
          if ((self._initial_pos.x == nw_x and self._initial_pos.y == nw_y) or
                  (self._initial_pos.x == se_x and self._initial_pos.y == nw_y) or
                  (self._initial_pos.x == se_x and self._initial_pos.y == se_y) or
                  (self._initial_pos.x == nw_x and self._initial_pos.y == se_y)):
              self.limit_pos(px, se_x, nw_x)
              self.limit_pos(py, se_y, nw_y)
          # If port movement starts at LEFT position, keep X position at place and move Y
          elif self._initial_pos.x == nw_x:
              _update(px, nw_x)
              self.limit_pos(py, se_y, nw_y)
              self._port.side = SnappedSide.LEFT
          # If port movement starts at TOP position, keep Y position at place and move X
          elif self._initial_pos.y == nw_y:
              _update(py, nw_y)
              self.limit_pos(px, se_x, nw_x)
              self._port.side = SnappedSide.TOP
          # If port movement starts at RIGHT position, keep X position at place and move Y
          elif self._initial_pos.x == se_x:
              _update(px, se_x)
              self.limit_pos(py, se_y, nw_y)
              self._port.side = SnappedSide.RIGHT
          # If port movement starts at BOTTOM position, keep Y position at place and move X
          elif self._initial_pos.y == se_y:
              _update(py, se_y)
              self.limit_pos(px, se_x, nw_x)
              self._port.side = SnappedSide.BOTTOM
          # If containing state has been resized, snap ports accordingly to border
          else:
              self.set_nearest_border()
  
          # Update initial position for next reference
          _update(self._initial_pos.x, deepcopy(px.value))
          _update(self._initial_pos.y, deepcopy(py.value))